Re: [PATCH] D19831: [scan-build] fix dead store warnings emitted on clang code base

2016-05-02 Thread Apelete Seketeli via cfe-commits
apelete updated this revision to Diff 55952.
apelete added a comment.

[scan-build] fix dead store warnings emitted on clang code base

Changes since last revision:

- remove dead store since the do {} while() loop overwrite it immediatly anyway.


http://reviews.llvm.org/D19831

Files:
  tools/c-index-test/c-index-test.c

Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1435,7 +1435,6 @@
 CXCursor Parent, Record;
 unsigned RecordIsAnonymous = 0;
 if (clang_getCursorKind(cursor) == CXCursor_FieldDecl) {
-  Record = Parent = p;
   do {
 Record = Parent;
 Parent = clang_getCursorSemanticParent(Record);


Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1435,7 +1435,6 @@
 CXCursor Parent, Record;
 unsigned RecordIsAnonymous = 0;
 if (clang_getCursorKind(cursor) == CXCursor_FieldDecl) {
-  Record = Parent = p;
   do {
 Record = Parent;
 Parent = clang_getCursorSemanticParent(Record);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19831: [scan-build] fix dead store warnings emitted on clang code base

2016-05-02 Thread Apelete Seketeli via cfe-commits
apelete added a comment.

In http://reviews.llvm.org/D19831#419456, @dblaikie wrote:

> Sorry, I meant remove the /store/, if it's dead. The do/while loop
>  overwrites the store immediately, so just remove the assignment to Record?


Makes sense, I overlooked that. Will fix in next revision.


http://reviews.llvm.org/D19831



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


Re: [PATCH] D19835: Tolerate incorrect return type for 'isinf' and 'isnan' in tests.

2016-05-02 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D19835#419547, @mclow.lists wrote:

> How about not using XFAIL?
>  Instead, just test for those two conditions.
>
> Psuedo-code:
>
>   #if defined(GLIBC)
>   #if GLIBC < 226
>   #error
>   #elif TEST_STD_VER >= 11
>   #error
>   #endif.


Because I want this test to pass, not fail. I definitely don't want to force 
failure of a passing test.
(Also it's not really that easy to test the GLIBC version.)


http://reviews.llvm.org/D19835



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


Re: [libcxx] r268124 - [CMake] Create a separate install target for libcxx headers

2016-05-02 Thread Eric Fiselier via cfe-commits
On Fri, Apr 29, 2016 at 4:17 PM, Chris Bieneman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: cbieneman
> Date: Fri Apr 29 17:17:15 2016
> New Revision: 268124
>
> URL: http://llvm.org/viewvc/llvm-project?rev=268124&view=rev
> Log:
> [CMake] Create a separate install target for libcxx headers
>
> This change doesn't impact the behavior of the install-libcxx target which
> installs whichever libcxx components you build, it just adds a separate
> target to just install the headers.
>
> Modified:
> libcxx/trunk/include/CMakeLists.txt
> libcxx/trunk/lib/CMakeLists.txt
>
> Modified: libcxx/trunk/include/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=268124&r1=268123&r2=268124&view=diff
>
> ==
> --- libcxx/trunk/include/CMakeLists.txt (original)
> +++ libcxx/trunk/include/CMakeLists.txt Fri Apr 29 17:17:15 2016
> @@ -19,7 +19,7 @@ file(COPY .
>  if (LIBCXX_INSTALL_HEADERS)
>install(DIRECTORY .
>  DESTINATION include/c++/v1
> -COMPONENT libcxx
> +COMPONENT libcxx-headers
>  FILES_MATCHING
>  ${LIBCXX_HEADER_PATTERN}
>  PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
> @@ -46,7 +46,17 @@ if (LIBCXX_INSTALL_HEADERS)
>DESTINATION include/c++/v1
>PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
>RENAME __config
> -  COMPONENT libcxx)
> +  COMPONENT libcxx-headers)
> +  endif()
> +
> +  if (NOT CMAKE_CONFIGURATION_TYPES)
> +# this target is just needed as a placeholder for the distribution
> target
> +add_custom_target(libcxx-headers)
> +add_custom_target(install-libcxx-headers
> +  DEPENDS ${name} libcxx-headers
>

What's `${name}` ?



> +  COMMAND "${CMAKE_COMMAND}"
> +  -DCMAKE_INSTALL_COMPONENT=libcxx-headers
> +  -P
> "${CMAKE_BINARY_DIR}/cmake_install.cmake")
>endif()
>
>  endif()
>
> Modified: libcxx/trunk/lib/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=268124&r1=268123&r2=268124&view=diff
>
> ==
> --- libcxx/trunk/lib/CMakeLists.txt (original)
> +++ libcxx/trunk/lib/CMakeLists.txt Fri Apr 29 17:17:15 2016
> @@ -180,8 +180,11 @@ if (NOT CMAKE_CONFIGURATION_TYPES AND (L
>  if(LIBCXX_INSTALL_LIBRARY)
>set(deps DEPENDS cxx)
>  endif()
> +if(LIBCXX_INSTALL_HEADERS)
> +  set(deps DEPENDS install-libcxx-headers)
> +endif()
>  add_custom_target(install-libcxx
> -  ${deps}
> +  ${deps}
>COMMAND "${CMAKE_COMMAND}"
>-DCMAKE_INSTALL_COMPONENT=libcxx
>-P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19856: Create new library 'libc++experimental.a' for packaging TS symbols.

2016-05-02 Thread Eric Fiselier via cfe-commits
EricWF added a subscriber: cfe-commits.
EricWF added a comment.

Adding cfe-commits to the subscribers.


http://reviews.llvm.org/D19856



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


Re: [PATCH] D19524: [OpenCL] Fix pipe type dump.

2016-05-02 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268364: [OpenCL] Fix pipe type dump. (authored by pxl).

Changed prior to commit:
  http://reviews.llvm.org/D19524?vs=55161&id=55946#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19524

Files:
  cfe/trunk/lib/AST/ASTDumper.cpp
  cfe/trunk/lib/AST/TypePrinter.cpp
  cfe/trunk/test/Misc/ast-dump-pipe.cl
  cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl
  cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl

Index: cfe/trunk/lib/AST/ASTDumper.cpp
===
--- cfe/trunk/lib/AST/ASTDumper.cpp
+++ cfe/trunk/lib/AST/ASTDumper.cpp
@@ -404,6 +404,9 @@
 void VisitAtomicType(const AtomicType *T) {
   dumpTypeAsChild(T->getValueType());
 }
+void VisitPipeType(const PipeType *T) {
+  dumpTypeAsChild(T->getElementType());
+}
 void VisitAdjustedType(const AdjustedType *T) {
   dumpTypeAsChild(T->getOriginalType());
 }
Index: cfe/trunk/lib/AST/TypePrinter.cpp
===
--- cfe/trunk/lib/AST/TypePrinter.cpp
+++ cfe/trunk/lib/AST/TypePrinter.cpp
@@ -895,7 +895,8 @@
 void TypePrinter::printPipeBefore(const PipeType *T, raw_ostream &OS) {
   IncludeStrongLifetimeRAII Strong(Policy);
 
-  OS << "pipe";
+  OS << "pipe ";
+  print(T->getElementType(), OS, StringRef());
   spaceBeforePlaceHolder(OS);
 }
 
Index: cfe/trunk/test/Misc/ast-dump-pipe.cl
===
--- cfe/trunk/test/Misc/ast-dump-pipe.cl
+++ cfe/trunk/test/Misc/ast-dump-pipe.cl
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple spir64 -cl-std=CL2.0 -ast-dump -ast-dump-filter 
pipetype %s | FileCheck -strict-whitespace %s
+typedef pipe int pipetype;
+// CHECK:  PipeType {{.*}} 'pipe int'
+// CHECK-NEXT:   BuiltinType {{.*}} 'int'
Index: cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl
===
--- cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl
+++ cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl
@@ -8,7 +8,7 @@
 void test3(read_only read_only image1d_t i){} // expected-error{{multiple 
access qualifiers}}
 
 #ifdef CL20
-void test4(read_write pipe int i){} // expected-error{{access qualifier 
'read_write' can not be used for 'pipe'}}
+void test4(read_write pipe int i){} // expected-error{{access qualifier 
'read_write' can not be used for 'pipe int'}}
 #else
 void test4(__read_write image1d_t i) {} // expected-error{{access qualifier 
'__read_write' can not be used for '__read_write image1d_t' earlier than 
OpenCL2.0 version}}
 #endif
Index: cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -7,5 +7,5 @@
 void test3(int pipe p){// expected-error {{cannot combine with previous 'int' 
declaration specifier}}
 }
 void test4() {
-  pipe int p; // expected-error {{type 'pipe' can only be used as a function 
parameter}}
+  pipe int p; // expected-error {{type 'pipe int' can only be used as a 
function parameter}}
 }


Index: cfe/trunk/lib/AST/ASTDumper.cpp
===
--- cfe/trunk/lib/AST/ASTDumper.cpp
+++ cfe/trunk/lib/AST/ASTDumper.cpp
@@ -404,6 +404,9 @@
 void VisitAtomicType(const AtomicType *T) {
   dumpTypeAsChild(T->getValueType());
 }
+void VisitPipeType(const PipeType *T) {
+  dumpTypeAsChild(T->getElementType());
+}
 void VisitAdjustedType(const AdjustedType *T) {
   dumpTypeAsChild(T->getOriginalType());
 }
Index: cfe/trunk/lib/AST/TypePrinter.cpp
===
--- cfe/trunk/lib/AST/TypePrinter.cpp
+++ cfe/trunk/lib/AST/TypePrinter.cpp
@@ -895,7 +895,8 @@
 void TypePrinter::printPipeBefore(const PipeType *T, raw_ostream &OS) {
   IncludeStrongLifetimeRAII Strong(Policy);
 
-  OS << "pipe";
+  OS << "pipe ";
+  print(T->getElementType(), OS, StringRef());
   spaceBeforePlaceHolder(OS);
 }
 
Index: cfe/trunk/test/Misc/ast-dump-pipe.cl
===
--- cfe/trunk/test/Misc/ast-dump-pipe.cl
+++ cfe/trunk/test/Misc/ast-dump-pipe.cl
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple spir64 -cl-std=CL2.0 -ast-dump -ast-dump-filter pipetype %s | FileCheck -strict-whitespace %s
+typedef pipe int pipetype;
+// CHECK:  PipeType {{.*}} 'pipe int'
+// CHECK-NEXT:   BuiltinType {{.*}} 'int'
Index: cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl
===
--- cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl
+++ cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl
@@ -8,7 +8,7 @@
 void test3(read_only read_only image1d_t i){} // expected-error{{multiple access qualifie

r268364 - [OpenCL] Fix pipe type dump.

2016-05-02 Thread Xiuli Pan via cfe-commits
Author: pxl
Date: Tue May  3 00:37:07 2016
New Revision: 268364

URL: http://llvm.org/viewvc/llvm-project?rev=268364&view=rev
Log:
[OpenCL] Fix pipe type dump.

Summary:
Fix the dump of PipeType.
Now we will have "pipe int" and element type.

Reviewers: yaxunl, Anastasia

Subscribers: cfe-commits, bader

Differential Revision: http://reviews.llvm.org/D19524

Added:
cfe/trunk/test/Misc/ast-dump-pipe.cl
Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl
cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=268364&r1=268363&r2=268364&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue May  3 00:37:07 2016
@@ -404,6 +404,9 @@ namespace  {
 void VisitAtomicType(const AtomicType *T) {
   dumpTypeAsChild(T->getValueType());
 }
+void VisitPipeType(const PipeType *T) {
+  dumpTypeAsChild(T->getElementType());
+}
 void VisitAdjustedType(const AdjustedType *T) {
   dumpTypeAsChild(T->getOriginalType());
 }

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=268364&r1=268363&r2=268364&view=diff
==
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Tue May  3 00:37:07 2016
@@ -895,7 +895,8 @@ void TypePrinter::printAtomicAfter(const
 void TypePrinter::printPipeBefore(const PipeType *T, raw_ostream &OS) {
   IncludeStrongLifetimeRAII Strong(Policy);
 
-  OS << "pipe";
+  OS << "pipe ";
+  print(T->getElementType(), OS, StringRef());
   spaceBeforePlaceHolder(OS);
 }
 

Added: cfe/trunk/test/Misc/ast-dump-pipe.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-pipe.cl?rev=268364&view=auto
==
--- cfe/trunk/test/Misc/ast-dump-pipe.cl (added)
+++ cfe/trunk/test/Misc/ast-dump-pipe.cl Tue May  3 00:37:07 2016
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple spir64 -cl-std=CL2.0 -ast-dump -ast-dump-filter 
pipetype %s | FileCheck -strict-whitespace %s
+typedef pipe int pipetype;
+// CHECK:  PipeType {{.*}} 'pipe int'
+// CHECK-NEXT:   BuiltinType {{.*}} 'int'

Modified: cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl?rev=268364&r1=268363&r2=268364&view=diff
==
--- cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl Tue May  3 00:37:07 
2016
@@ -8,7 +8,7 @@ void test2(read_only write_only image1d_
 void test3(read_only read_only image1d_t i){} // expected-error{{multiple 
access qualifiers}}
 
 #ifdef CL20
-void test4(read_write pipe int i){} // expected-error{{access qualifier 
'read_write' can not be used for 'pipe'}}
+void test4(read_write pipe int i){} // expected-error{{access qualifier 
'read_write' can not be used for 'pipe int'}}
 #else
 void test4(__read_write image1d_t i) {} // expected-error{{access qualifier 
'__read_write' can not be used for '__read_write image1d_t' earlier than 
OpenCL2.0 version}}
 #endif

Modified: cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl?rev=268364&r1=268363&r2=268364&view=diff
==
--- cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl Tue May  3 00:37:07 2016
@@ -7,5 +7,5 @@ void test2(pipe p){// expected-error {{m
 void test3(int pipe p){// expected-error {{cannot combine with previous 'int' 
declaration specifier}}
 }
 void test4() {
-  pipe int p; // expected-error {{type 'pipe' can only be used as a function 
parameter}}
+  pipe int p; // expected-error {{type 'pipe int' can only be used as a 
function parameter}}
 }


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


Re: [PATCH] D19835: Tolerate incorrect return type for 'isinf' and 'isnan' in tests.

2016-05-02 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

How about not using XFAIL?
Instead, just test for those two conditions.

Psuedo-code:

  #if defined(GLIBC)
  #if GLIBC < 226
  #error
  #elif TEST_STD_VER >= 11
  #error
  #endif.


http://reviews.llvm.org/D19835



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


[libcxx] r268363 - Fix dependencies on install-libcxx CMake target

2016-05-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  3 00:34:38 2016
New Revision: 268363

URL: http://llvm.org/viewvc/llvm-project?rev=268363&view=rev
Log:
Fix dependencies on install-libcxx CMake target

Modified:
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=268363&r1=268362&r2=268363&view=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Tue May  3 00:34:38 2016
@@ -178,13 +178,13 @@ endif()
 if (NOT CMAKE_CONFIGURATION_TYPES AND (LIBCXX_INSTALL_LIBRARY OR
LIBCXX_INSTALL_HEADERS))
 if(LIBCXX_INSTALL_LIBRARY)
-  set(deps DEPENDS cxx)
+  set(lib_install_target cxx)
 endif()
 if(LIBCXX_INSTALL_HEADERS)
-  set(deps DEPENDS install-libcxx-headers)
+  set(header_install_target install-libcxx-headers)
 endif()
 add_custom_target(install-libcxx
-  ${deps} 
+  DEPENDS ${lib_install_target} ${header_install_target}
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=libcxx
   -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")


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


[PATCH] D19854: Define Contiki OS toolchain

2016-05-02 Thread Michael LeMay via cfe-commits
mlemay-intel created this revision.
mlemay-intel added reviewers: pcc, eugenis.
mlemay-intel added a subscriber: cfe-commits.

It is defined with support for the SafeStack sanitizer on x86.

http://reviews.llvm.org/D19854

Files:
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h

Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -1175,6 +1175,14 @@
   Tool *buildLinker() const override;
 };
 
+class LLVM_LIBRARY_VISIBILITY Contiki : public Generic_ELF {
+public:
+  Contiki(const Driver &D, const llvm::Triple &Triple,
+ const llvm::opt::ArgList &Args);
+
+  SanitizerMask getSupportedSanitizers() const override;
+};
+
 } // end namespace toolchains
 } // end namespace driver
 } // end namespace clang
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4624,3 +4624,14 @@
   Res |= SanitizerKind::Vptr;
   return Res;
 }
+
+Contiki::Contiki(const Driver &D, const llvm::Triple &Triple, const ArgList 
&Args)
+: Generic_ELF(D, Triple, Args) {}
+
+SanitizerMask Contiki::getSupportedSanitizers() const {
+  const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
+  SanitizerMask Res = ToolChain::getSupportedSanitizers();
+  if (IsX86)
+Res |= SanitizerKind::SafeStack;
+  return Res;
+}
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -2499,6 +2499,9 @@
 case llvm::Triple::PS4:
   TC = new toolchains::PS4CPU(*this, Target, Args);
   break;
+case llvm::Triple::Contiki:
+  TC = new toolchains::Contiki(*this, Target, Args);
+  break;
 default:
   // Of these targets, Hexagon is the only one that might have
   // an OS of Linux, in which case it got handled above already.


Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -1175,6 +1175,14 @@
   Tool *buildLinker() const override;
 };
 
+class LLVM_LIBRARY_VISIBILITY Contiki : public Generic_ELF {
+public:
+  Contiki(const Driver &D, const llvm::Triple &Triple,
+ const llvm::opt::ArgList &Args);
+
+  SanitizerMask getSupportedSanitizers() const override;
+};
+
 } // end namespace toolchains
 } // end namespace driver
 } // end namespace clang
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4624,3 +4624,14 @@
   Res |= SanitizerKind::Vptr;
   return Res;
 }
+
+Contiki::Contiki(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+: Generic_ELF(D, Triple, Args) {}
+
+SanitizerMask Contiki::getSupportedSanitizers() const {
+  const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
+  SanitizerMask Res = ToolChain::getSupportedSanitizers();
+  if (IsX86)
+Res |= SanitizerKind::SafeStack;
+  return Res;
+}
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -2499,6 +2499,9 @@
 case llvm::Triple::PS4:
   TC = new toolchains::PS4CPU(*this, Target, Args);
   break;
+case llvm::Triple::Contiki:
+  TC = new toolchains::Contiki(*this, Target, Args);
+  break;
 default:
   // Of these targets, Hexagon is the only one that might have
   // an OS of Linux, in which case it got handled above already.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19853: [safestack] Add -fruntime-init to support invoking functions during runtime init

2016-05-02 Thread Michael LeMay via cfe-commits
mlemay-intel created this revision.
mlemay-intel added reviewers: pcc, eugenis.
mlemay-intel added a subscriber: cfe-commits.

SafeStack uses thread-local storage by default in most OSes for the unsafe stack
pointer. For SafeStack to be applied to functions that may be invoked while
initializing the dynamic linker and libc, the functions can be compiled to
support a single-threaded unsafe stack pointer. This flag signals that such code
should be emitted.

http://reviews.llvm.org/D19853

Files:
  docs/CommandGuide/clang.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/runtime-init-attr.c

Index: test/CodeGen/runtime-init-attr.c
===
--- /dev/null
+++ test/CodeGen/runtime-init-attr.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - %s -fruntime-init | FileCheck -check-prefix=DEF -check-prefix=CHECK %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - %s -fruntime-init -fsanitize=safe-stack | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK %s
+
+// DEF: define {{.*}}void @test1() #[[A:.*]] {
+void test1() {
+}
+
+// CHECK: attributes #[[A]] = {{.*}} runtime_init
+// SAFESTACK: attributes #[[A]] = {{.*}} runtime_init safestack
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1730,6 +1730,7 @@
   if (!Opts.NoBuiltin)
 getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
   Opts.NoMathBuiltin = Args.hasArg(OPT_fno_math_builtin);
+  Opts.RuntimeInit = Args.hasArg(OPT_fruntime_init);
   Opts.SizedDeallocation = Args.hasArg(OPT_fsized_deallocation);
   Opts.ConceptsTS = Args.hasArg(OPT_fconcepts_ts);
   Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4777,6 +4777,9 @@
   KernelOrKext)
 CmdArgs.push_back("-ffreestanding");
 
+  if (Args.hasArg(options::OPT_fruntime_init))
+CmdArgs.push_back("-fruntime-init");
+
   // Forward -f (flag) options which we can pass directly.
   Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls);
   Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -698,6 +698,9 @@
   if (SanOpts.has(SanitizerKind::SafeStack))
 Fn->addFnAttr(llvm::Attribute::SafeStack);
 
+  if (getLangOpts().RuntimeInit)
+Fn->addFnAttr(llvm::Attribute::RuntimeInit);
+
   // Pass inline keyword to optimizer if it appears explicitly on any
   // declaration. Also, in the case of -fno-inline attach NoInline
   // attribute to all function that are not marked AlwaysInline.
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -279,6 +279,9 @@
   Fn->addFnAttr(llvm::Attribute::SafeStack);
   }
 
+  if (getLangOpts().RuntimeInit)
+Fn->addFnAttr(llvm::Attribute::RuntimeInit);
+
   return Fn;
 }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1031,6 +1031,7 @@
 def freg_struct_return : Flag<["-"], "freg-struct-return">, Group, Flags<[CC1Option]>,
   HelpText<"Override the default ABI to return small structs in registers">;
 def frtti : Flag<["-"], "frtti">, Group;
+def fruntime_init : Flag<["-"], "fruntime-init">, Group, Flags<[CC1Option]>;
 def : Flag<["-"], "fsched-interblock">, Group;
 def fshort_enums : Flag<["-"], "fshort-enums">, Group, Flags<[CC1Option]>,
   HelpText<"Allocate to an enum type only as many bytes as it needs for the declared range of possible values">;
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -132,6 +132,7 @@
 LANGOPT(Freestanding, 1, 0, "freestanding implementation")
 LANGOPT(NoBuiltin , 1, 0, "disable builtin functions")
 LANGOPT(NoMathBuiltin , 1, 0, "disable math builtin functions")
+LANGOPT(RuntimeInit   , 1, 0, "used during runtime initialization")
 LANGOPT(GNUAsm, 1, 1, "GNU-style inline assembly")
 LANGOPT(Coroutines, 1, 0, "C++ coroutines")
 
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -313,6 +313,13 @@
   model can be overridden with t

[PATCH] D19851: Warn on binding reference to null in copy initialization

2016-05-02 Thread Nick Lewycky via cfe-commits
nicholas created this revision.
nicholas added a reviewer: cfe-commits.

The attached patch adds a warning when placing a call like:
  func(*static_cast(nullptr));
to the existing -Wnull-dereference warning.

The existing warning catches the case where the empty lvalue undergoes 
lvalue-to-rvalue conversion. The attached patch adds the check when it is used 
for copy initialization.

There's some significant opportunity for refactoring with the static 
CheckForNullPointerDereference function in SemaExpr.cpp (not to be confused 
with the one I'm adding to SemaInit.cpp). Also, I've chosen different warning 
text since all cases where the existing warning fires get compiled to nothing, 
while cases where this warning fires may generate object code (creating "null 
references" usually).

Please review!

http://reviews.llvm.org/D19851

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaInit.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
  test/Parser/cxx-casting.cpp

Index: test/Parser/cxx-casting.cpp
===
--- test/Parser/cxx-casting.cpp
+++ test/Parser/cxx-casting.cpp
@@ -37,7 +37,7 @@
 // This was being incorrectly tentatively parsed.
 namespace test1 {
   template  class A {}; // expected-note 2{{here}}
-  void foo() { A(*(A*)0); }
+  void foo() { A(*(A*)0); } // expected-warning {{binding null 
pointer to reference has undefined behavior}}
 }
 
 typedef char* c;
Index: test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
+++ test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
@@ -11,7 +11,7 @@
 
 template
 struct bogus_override_if_virtual : public T {
-  bogus_override_if_virtual() : T(*(T*)0) { }
+  bogus_override_if_virtual() : T(*(T*)0) { } // expected-warning {{binding 
null pointer to reference has undefined behavior}}
   int operator()() const;
 };
 
@@ -36,7 +36,7 @@
   lv(); // expected-error{{no matching function for call to object of type}}
   mlv(); // expected-error{{no matching function for call to object of type}}
 
-  bogus_override_if_virtual bogus;
+  bogus_override_if_virtual bogus; // expected-note{{in 
instantiation of member function 'bogus_override_if_virtual<(lambda}}
 }
 
 // Core issue 974: default arguments (8.3.6) may be specified in the
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -3510,6 +3510,23 @@
   return CandidateSet.BestViableFunction(S, DeclLoc, Best);
 }
 
+static void CheckForNullPointerDereference(Sema &S, Expr *E) {
+  // Check to see if we are dereferencing a null pointer.  If so,
+  // and if not volatile-qualified, this is undefined behavior that the
+  // optimizer will delete, so warn about it.  People sometimes try to use this
+  // to get a deterministic trap and are surprised by clang's behavior.  This
+  // only handles the pattern "*null", which is a very syntactic check.
+  if (UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts()))
+if (UO->getOpcode() == UO_Deref &&
+UO->getSubExpr()->IgnoreParenCasts()->
+  isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull) 
&&
+!UO->getType().isVolatileQualified()) {
+S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
+  S.PDiag(diag::warn_binding_null_to_reference)
+<< UO->getSubExpr()->getSourceRange());
+  }
+}
+
 /// \brief Attempt initialization by constructor (C++ [dcl.init]), which
 /// enumerates the constructors of the initialized entity and performs overload
 /// resolution to select the best.
@@ -3629,6 +3646,10 @@
 return;
   }
 
+  for (Expr *Arg : Args) {
+CheckForNullPointerDereference(S, Arg);
+  }
+
   // Add the constructor initialization step. Any cv-qualification conversion 
is
   // subsumed by the initialization.
   bool HadMultipleCandidates = (CandidateSet.size() > 1);
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -5359,6 +5359,8 @@
   InGroup>;
 def warn_indirection_through_null : Warning<
   "indirection of non-volatile null pointer will be deleted, not trap">, 
InGroup;
+def warn_binding_null_to_reference : Warning<
+  "binding null pointer to reference has undefined behavior">, 
InGroup;
 def note_indirection_through_null : Note<
   "consider using __builtin_trap() or qualifying pointer with 'volatile'">;
 def warn_pointer_indirection_from_incompatible_type : Warning<


Index: test/Parser/cxx-casting.cpp
===
--- test/Parser/cxx-casting.cpp
+++ test/Parser/cxx-casting.cpp
@@ -37,7 +37,7 @@
 // This was being incorrectly tentatively parsed.
 namespace test1 {
   temp

[libcxx] r268359 - Fix PR27538. Remove __is_convertible specializations for array and function types.

2016-05-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May  2 23:26:02 2016
New Revision: 268359

URL: http://llvm.org/viewvc/llvm-project?rev=268359&view=rev
Log:
Fix PR27538. Remove __is_convertible specializations for array and function 
types.

This patch fixes a bunch of bugs in the fallback implementation of
is_convertible, which is used by GCC. Removing the "__is_convertible"
specializations for array/function types we fallback on the SFINAE test,
which is more correct.

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

Modified:
libcxx/trunk/include/type_traits
libcxx/trunk/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=268359&r1=268358&r2=268359&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Mon May  2 23:26:02 2016
@@ -1423,41 +1423,6 @@ struct __is_convertible
 >
 {};
 
-template  struct __is_convertible<_T1, _T2, 1, 0> : 
false_type {};
-
-template  struct __is_convertible<_T1, const _T1&, 1, 0> : 
true_type {};
-template  struct __is_convertible : 
true_type {};
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-template  struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
-template  struct __is_convertible<_T1, const _T1&&, 1, 0> : 
true_type {};
-template  struct __is_convertible<_T1, volatile _T1&&, 1, 0> : 
true_type {};
-template  struct __is_convertible<_T1, const volatile _T1&&, 1, 0> 
: true_type {};
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-template  struct __is_convertible<_T1, _T2*, 1, 0>
-: public integral_constant::type*, _T2*>::value> {};
-
-template  struct __is_convertible<_T1, _T2* const, 1, 0>
-: public integral_constant::type*, _T2*const>::value> {};
-
-template  struct __is_convertible<_T1, _T2* volatile, 1, 
0>
-: public integral_constant::type*, _T2*volatile>::value> {};
-
-template  struct __is_convertible<_T1, _T2* const 
volatile, 1, 0>
-: public integral_constant::type*, _T2*const volatile>::value> {};
-
-template  struct __is_convertible<_T1, _T2, 2, 0>
: public false_type {};
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-template struct __is_convertible<_T1, _T1&&, 2, 0>  
 : public true_type {};
-#endif
-template struct __is_convertible<_T1, _T1&, 2, 0>   
: public true_type {};
-template struct __is_convertible<_T1, _T1*, 2, 0>   
: public true_type {};
-template struct __is_convertible<_T1, _T1*const, 2, 0>  
: public true_type {};
-template struct __is_convertible<_T1, _T1*volatile, 2, 
0>   : public true_type {};
-template struct __is_convertible<_T1, _T1*const 
volatile, 2, 0> : public true_type {};
-
-template  struct __is_convertible<_T1, _T2, 3, 0> : 
public false_type {};
-
 template  struct __is_convertible<_T1, _T2, 0, 1> : 
public false_type {};
 template  struct __is_convertible<_T1, _T2, 1, 1> : 
public false_type {};
 template  struct __is_convertible<_T1, _T2, 2, 1> : 
public false_type {};

Modified: libcxx/trunk/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp?rev=268359&r1=268358&r2=268359&view=diff
==
--- libcxx/trunk/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp 
(original)
+++ libcxx/trunk/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp Mon 
May  2 23:26:02 2016
@@ -12,7 +12,6 @@
 // is_convertible
 
 #include 
-
 #include "test_macros.h"
 
 template 
@@ -46,8 +45,13 @@ void test_is_not_convertible()
 }
 
 typedef void Function();
+typedef void ConstFunction() const;
 typedef char Array[1];
 
+struct StringType {
+  StringType(const char*) {}
+};
+
 class NonCopyable {
   NonCopyable(NonCopyable&);
 };
@@ -69,12 +73,19 @@ int main()
 test_is_not_convertible ();
 test_is_not_convertible ();
 test_is_not_convertible ();
+test_is_not_convertible();
 
 // Function
 test_is_not_convertible ();
 test_is_not_convertible ();
 test_is_convertible ();
 test_is_convertible ();
+test_is_convertible ();
+
+#if TEST_STD_VER >= 11
+static_assert(( std::is_convertible::value), "");
+#endif
+
 test_is_not_convertible ();
 test_is_not_convertible ();
 test_is_not_convertible ();
@@ -105,6 +116,16 @@ int main()
 test_is_not_convertible ();
 test_is_not_convertible ();
 
+// Non-referencable function type
+static_assert((!std::is_convertible::value), "");
+static_assert((!std::is_convertible::value), "");
+static_assert((!std::is_convertible::value), "");
+static_assert((!std::is_convertible::value), "");
+static_assert((!std::is_convertible::value), "");
+static_assert((!st

Re: [PATCH] D19841: [clang-tidy] Lift common matchers to utils namespace

2016-05-02 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

Who is the owner of ASTMatcher?

If he is willing to receive these matchers in ASTMatcher, I'll lift them.
Otherwise, we should at least lift them within clang-tidy.


http://reviews.llvm.org/D19841



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


[clang-tools-extra] r268356 - [clang-tidy] Cleanup namespace in utils folder.

2016-05-02 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Mon May  2 21:54:05 2016
New Revision: 268356

URL: http://llvm.org/viewvc/llvm-project?rev=268356&view=rev
Log:
[clang-tidy] Cleanup namespace in utils folder.

Summary:
This is a step forward cleaning up the namespaces in clang-tidy/utils.
There is no behavior change.

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19819

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.h
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.h
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.h
clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.h
clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp

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

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp
clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.h
clang-tools-extra/trunk/clang-tidy/utils/FixItHintUtils.cpp
clang-tools-extra/trunk/clang-tidy/utils/FixItHintUtils.h
clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp
clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.h
clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp
clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.h
clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp
clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.h
clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.cpp
clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.h
clang-tools-extra/trunk/clang-tidy/utils/Matchers.h
clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp
clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h
clang-tools-extra/trunk/unittests/clang-tidy/IncludeInserterTest.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp?rev=268356&r1=268355&r2=268356&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 Mon May  2 21:54:05 2016
@@ -22,7 +22,7 @@ namespace cppcoreguidelines {
 ProBoundsConstantArrayIndexCheck::ProBoundsConstantArrayIndexCheck(
 StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context), GslHeader(Options.get("GslHeader", "")),
-  IncludeStyle(IncludeSorter::parseIncludeStyle(
+  IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
   Options.get("IncludeStyle", "llvm"))) {}
 
 void ProBoundsConstantArrayIndexCheck::storeOptions(
@@ -36,8 +36,8 @@ void ProBoundsConstantArrayIndexCheck::r
   if (!getLangOpts().CPlusPlus)
 return;
 
-  Inserter.reset(new IncludeInserter(Compiler.getSourceManager(),
- Compiler.getLangOpts(), IncludeStyle));
+  Inserter.reset(new utils::IncludeInserter(
+  Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle));
   Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
 }
 

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h?rev=268356&r1=268355&r2=268356&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
 Mon May  2 21:54:05 2016
@@ -24,8 +24,8 @@ namespace cppcoreguidelines {
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.html
 class ProBoundsConstantArrayIndexCheck : public ClangTidyCheck {
   const std::string GslHeader;
-  const IncludeSorter::IncludeStyle IncludeStyle;
-  std::unique_ptr Inserter;
+  const utils::IncludeSorter::IncludeStyle IncludeStyle;
+  std::unique_ptr Inserter;
 
 public:
   ProBoundsCo

Re: [PATCH] D19827: Do not disable completely loop unroll according to optimization level.

2016-05-02 Thread Chad Rosier via cfe-commits
mcrosier added a subscriber: mcrosier.
mcrosier added a comment.

I believe the LLVM blog post is in error.  Loop vectorization commonly 
generates two versions of the loop: vectorized and scalar.  The scalar loop is 
necessary to handle the case where the trip count isn't evenly divisible by the 
vectorization factor.  Therefore, it's reasonable to disable these type of 
optimizations (e.g., vectorization, unrolling) when we're optimizing for size.  
It's also reasonable to disable these optimizations at -O0.

However, I also understand the argument being made by Chandler.  Can you please 
create an LLVM patch the shows the loop unroll pass respects the equivalent 
-Os/-Oz/-O0 in LLVM IR?

I believe the first two are handled by checking Function::optForSize() and for 
the latter you can check the function for the optnone attribute.


Repository:
  rL LLVM

http://reviews.llvm.org/D19827



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


Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-05-02 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D19412#417729, @rmaprath wrote:

> So, perhaps it is best to leave these pthread mutexes alone, purely for 
> performance reasons. We'll have to excuse a couple of `#ifdef 
> _LIBCPP_THREAD_API_` conditionals in the library sources to allow the 
> external threading API to function.
>
> Does that sound like an OK compromise? @EricWF, @mclow.lists?


Sounds good to me.  Although we should probably change these from 
`pthread_mutex_t` to `__libcpp_mutex_t`.


http://reviews.llvm.org/D19412



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


Re: [PATCH] D19758: [libcxx] [test] Replace non-Standard "atomic_flag f(false); " with Standard "atomic_flag f; "

2016-05-02 Thread Eric Fiselier via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268355: [libcxx] [test] Replace non-Standard "atomic_flag 
f(false);" with Standard… (authored by EricWF).

Changed prior to commit:
  http://reviews.llvm.org/D19758?vs=55920&id=55937#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19758

Files:
  libcxx/trunk/include/atomic
  libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
  libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
  libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
  libcxx/trunk/test/std/atomics/atomics.flag/clear.pass.cpp
  libcxx/trunk/test/std/atomics/atomics.flag/init03.pass.cpp

Index: libcxx/trunk/include/atomic
===
--- libcxx/trunk/include/atomic
+++ libcxx/trunk/include/atomic
@@ -1689,7 +1689,7 @@
 #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 
 _LIBCPP_INLINE_VISIBILITY
-atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {}
+atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION
 
 #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
 atomic_flag(const atomic_flag&) = delete;
Index: libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
===
--- libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
+++ libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
@@ -22,37 +22,37 @@
 int main()
 {
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
 assert(f.test_and_set() == 0);
 }
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear_explicit(&f, std::memory_order_release);
 assert(f.test_and_set() == 0);
 }
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
 assert(f.test_and_set() == 0);
 }
 {
-volatile std::atomic_flag f(false);
+volatile std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
 assert(f.test_and_set() == 0);
 }
 {
-volatile std::atomic_flag f(false);
+volatile std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear_explicit(&f, std::memory_order_release);
 assert(f.test_and_set() == 0);
 }
 {
-volatile std::atomic_flag f(false);
+volatile std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
 assert(f.test_and_set() == 0);
Index: libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
===
--- libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
+++ libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
@@ -22,13 +22,13 @@
 int main()
 {
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear(&f);
 assert(f.test_and_set() == 0);
 }
 {
-volatile std::atomic_flag f(false);
+volatile std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear(&f);
 assert(f.test_and_set() == 0);
Index: libcxx/trunk/test/std/atomics/atomics.flag/clear.pass.cpp
===
--- libcxx/trunk/test/std/atomics/atomics.flag/clear.pass.cpp
+++ libcxx/trunk/test/std/atomics/atomics.flag/clear.pass.cpp
@@ -22,49 +22,49 @@
 int main()
 {
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 f.clear();
 assert(f.test_and_set() == 0);
 }
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 f.clear(std::memory_order_relaxed);
 assert(f.test_and_set() == 0);
 }
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 f.clear(std::memory_order_release);
 assert(f.test_and_set() == 0);
 }
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 f.clear(std::memory_order_seq_cst);
 assert(f.test_and_set() == 0);
 }
 {
-volatile std::atomic_flag f(false);
+volatile std::atomic_flag f;
 f.test_and_set();
 f.clear();
 assert(f.test_and_set() == 0);
 }
 {
-volatile std::atomic_flag f(false);
+volatile std::atomic_flag f;
 f.test_and_set();
 f.clear(std::memory_order_relaxed);
 assert(f.test_and_set() == 0);
 }
  

[libcxx] r268355 - [libcxx] [test] Replace non-Standard "atomic_flag f(false); " with Standard "atomic_flag f; "

2016-05-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May  2 21:12:26 2016
New Revision: 268355

URL: http://llvm.org/viewvc/llvm-project?rev=268355&view=rev
Log:
[libcxx] [test] Replace non-Standard "atomic_flag f(false);" with Standard 
"atomic_flag f;" 

Summary:
Replace non-Standard "atomic_flag f(false);" with Standard "atomic_flag f;" in 
clear tests.
Although the  value of 'f' is unspecified it shouldn't matter because these 
tests always call `f.test_and_set()` without checking the result, so the 
initial state shouldn't matter.

The test init03.pass.cpp is explicitly testing this non-Standard extension; It 
has been moved into the `test/libcxx` directory.

Reviewers: mclow.lists, STL_MSFT

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19758

Added:
libcxx/trunk/test/libcxx/atomics/atomics.flag/
libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
Removed:
libcxx/trunk/test/std/atomics/atomics.flag/init03.pass.cpp
Modified:
libcxx/trunk/include/atomic
libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp

libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
libcxx/trunk/test/std/atomics/atomics.flag/clear.pass.cpp

Modified: libcxx/trunk/include/atomic
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?rev=268355&r1=268354&r2=268355&view=diff
==
--- libcxx/trunk/include/atomic (original)
+++ libcxx/trunk/include/atomic Mon May  2 21:12:26 2016
@@ -1689,7 +1689,7 @@ typedef struct atomic_flag
 #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 
 _LIBCPP_INLINE_VISIBILITY
-atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {}
+atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION
 
 #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
 atomic_flag(const atomic_flag&) = delete;

Added: libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp?rev=268355&view=auto
==
--- libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp Mon May  2 
21:12:26 2016
@@ -0,0 +1,31 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// 
+
+// struct atomic_flag
+
+// TESTING EXTENSION atomic_flag(bool)
+
+#include 
+#include 
+
+int main()
+{
+{
+std::atomic_flag f(false);
+assert(f.test_and_set() == 0);
+}
+{
+std::atomic_flag f(true);
+assert(f.test_and_set() == 1);
+}
+}

Modified: libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp?rev=268355&r1=268354&r2=268355&view=diff
==
--- libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp 
(original)
+++ libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp Mon 
May  2 21:12:26 2016
@@ -22,13 +22,13 @@
 int main()
 {
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear(&f);
 assert(f.test_and_set() == 0);
 }
 {
-volatile std::atomic_flag f(false);
+volatile std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear(&f);
 assert(f.test_and_set() == 0);

Modified: 
libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp?rev=268355&r1=268354&r2=268355&view=diff
==
--- 
libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp 
Mon May  2 21:12:26 2016
@@ -22,37 +22,37 @@
 int main()
 {
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
 assert(f.test_and_set() == 0);
 }
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear_explicit(&f, std::memory_order_release);
 assert(f.test_and_set() == 0);
 }
 {
-std::atomic_flag f(fal

Re: [PATCH] D19849: [clang-tidy] MoveConstructorInitCheck - Add parameter name to check message.

2016-05-02 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/MoveConstructorInitCheck.cpp:114
@@ -114,1 +113,3 @@
+  "value argument %0 can be moved to avoid copy")
+ << MovableParam->getName();
   DiagOut << FixItHint::CreateReplacement(

I guess, it should work without `->getName()`. Could you try?


Repository:
  rL LLVM

http://reviews.llvm.org/D19849



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


[libcxx] r268354 - Don't use std::__clz in 'test/support/hexfloat.h'.

2016-05-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May  2 21:04:26 2016
New Revision: 268354

URL: http://llvm.org/viewvc/llvm-project?rev=268354&view=rev
Log:
Don't use std::__clz in 'test/support/hexfloat.h'.

std::__clz is a libc++ specific function so it can't be used in the test suite.
This patch implements a dumb "count leading zeros" implementation within
hexfloat itself.

This patch also fixes UB since the output of `__builtin_clz(0)` is undefined
according to the GCC docs.

Modified:
libcxx/trunk/test/support/hexfloat.h

Modified: libcxx/trunk/test/support/hexfloat.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/hexfloat.h?rev=268354&r1=268353&r2=268354&view=diff
==
--- libcxx/trunk/test/support/hexfloat.h (original)
+++ libcxx/trunk/test/support/hexfloat.h Mon May  2 21:04:26 2016
@@ -15,7 +15,6 @@
 #ifndef HEXFLOAT_H
 #define HEXFLOAT_H
 
-#include 
 #include 
 #include 
 
@@ -23,13 +22,26 @@ template 
 class hexfloat
 {
 T value_;
+
+static int CountLeadingZeros(unsigned long long n) {
+const std::size_t Digits = sizeof(unsigned long long) * CHAR_BIT;
+const unsigned long long TopBit = 1ull << (Digits - 1);
+if (n == 0) return Digits;
+int LeadingZeros = 0;
+while ((n & TopBit) == 0) {
+++LeadingZeros;
+n <<= 1;
+}
+return LeadingZeros;
+}
+
 public:
 hexfloat(long long m1, unsigned long long m0, int exp)
 {
-const std::size_t n = sizeof(unsigned long long) * CHAR_BIT;
+const std::size_t Digits = sizeof(unsigned long long) * CHAR_BIT;
 int s = m1 < 0 ? -1 : 1;
-value_ = std::ldexp(m1 + s * std::ldexp(T(m0), -static_cast(n -
- std::__clz(m0)/4*4)), 
exp);
+int exp2 = -static_cast(Digits - CountLeadingZeros(m0)/4*4);
+value_ = std::ldexp(m1 + s * std::ldexp(T(m0), exp2), exp);
 }
 
 operator T() const {return value_;}


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


Re: [PATCH] D19831: [scan-build] fix dead store warnings emitted on clang code base

2016-05-02 Thread David Blaikie via cfe-commits
Sorry, I meant remove the /store/, if it's dead. The do/while loop
overwrites the store immediately, so just remove the assignment to Record?

On Mon, May 2, 2016 at 2:59 PM, Apelete Seketeli via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> apelete added a comment.
>
> In http://reviews.llvm.org/D19831#419140, @dblaikie wrote:
>
> > Any reason not to remove the story instead?
>
>
> What do you mean by "remove the story" ?
>
>
> http://reviews.llvm.org/D19831
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19815: Support '#pragma once' in headers when using PCH

2016-05-02 Thread Warren Ristow via cfe-commits
wristow updated this revision to Diff 55936.
wristow added a comment.

Moved "test/PCH/pragma-once.h" to the "test/PCH/Inputs" directory (and changed 
"pragma-once.c" appropriately).


http://reviews.llvm.org/D19815

Files:
  include/clang/Lex/PreprocessorOptions.h
  lib/Frontend/InitPreprocessor.cpp
  lib/Lex/Pragma.cpp
  test/PCH/Inputs/pragma-once.h
  test/PCH/pragma-once.c

Index: test/PCH/pragma-once.c
===
--- /dev/null
+++ test/PCH/pragma-once.c
@@ -0,0 +1,13 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/pragma-once.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %S/Inputs/pragma-once.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+// Including "pragma-once.h" twice, to verify the 'once' aspect is honored.
+#include "Inputs/pragma-once.h"
+#include "Inputs/pragma-once.h"
+int foo(void) { return 0; }
Index: test/PCH/Inputs/pragma-once.h
===
--- /dev/null
+++ test/PCH/Inputs/pragma-once.h
@@ -0,0 +1,5 @@
+#pragma once
+
+/* For use with the pragma-once.c test */
+
+int x = 3;
Index: lib/Lex/Pragma.cpp
===
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -19,6 +19,7 @@
 #include "clang/Lex/LexDiagnostic.h"
 #include "clang/Lex/LiteralSupport.h"
 #include "clang/Lex/MacroInfo.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -354,7 +355,9 @@
 /// HandlePragmaOnce - Handle \#pragma once.  OnceTok is the 'once'.
 ///
 void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
-  if (isInPrimaryFile()) {
+  // Don't honor the 'once' when handling the primary source file, unless
+  // we're generating a PCH file.
+  if (isInPrimaryFile() && !getPreprocessorOpts().GeneratePCHMode) {
 Diag(OnceTok, diag::pp_pragma_once_in_main_file);
 return;
   }
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -1021,6 +1021,10 @@
   if (!InitOpts.ImplicitPTHInclude.empty())
 AddImplicitIncludePTH(Builder, PP, InitOpts.ImplicitPTHInclude);
 
+  // Instruct the preprocessor that we're generating a PCH file.
+  if (FEOpts.ProgramAction == frontend::GeneratePCH)
+PP.getPreprocessorOpts().GeneratePCHMode = true;
+
   // Process -include directives.
   for (unsigned i = 0, e = InitOpts.Includes.size(); i != e; ++i) {
 const std::string &Path = InitOpts.Includes[i];
Index: include/clang/Lex/PreprocessorOptions.h
===
--- include/clang/Lex/PreprocessorOptions.h
+++ include/clang/Lex/PreprocessorOptions.h
@@ -61,6 +61,9 @@
   /// \brief Headers that will be converted to chained PCHs in memory.
   std::vector ChainedIncludes;
 
+  /// \brief When true, we are generating a pre-compiled header.
+  bool GeneratePCHMode;
+
   /// \brief When true, disables most of the normal validation performed on
   /// precompiled headers.
   bool DisablePCHValidation;
@@ -141,6 +144,7 @@
 
 public:
   PreprocessorOptions() : UsePredefines(true), DetailedRecord(false),
+  GeneratePCHMode(false),
   DisablePCHValidation(false),
   AllowPCHWithCompilerErrors(false),
   DumpDeserializedPCHDecls(false),


Index: test/PCH/pragma-once.c
===
--- /dev/null
+++ test/PCH/pragma-once.c
@@ -0,0 +1,13 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/pragma-once.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %S/Inputs/pragma-once.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+// Including "pragma-once.h" twice, to verify the 'once' aspect is honored.
+#include "Inputs/pragma-once.h"
+#include "Inputs/pragma-once.h"
+int foo(void) { return 0; }
Index: test/PCH/Inputs/pragma-once.h
===
--- /dev/null
+++ test/PCH/Inputs/pragma-once.h
@@ -0,0 +1,5 @@
+#pragma once
+
+/* For use with the pragma-once.c test */
+
+int x = 3;
Index: lib/Lex/Pragma.cpp
===
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -19,6 +19,7 @@
 #include "clang/Lex/LexDiagnostic.h"
 #include "clang/Lex/LiteralSupport.h"
 #include "clang/Lex/MacroInfo.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -354,7 +355,9 @@
 /// HandlePragmaOnce - Handle \#pragma once.  OnceTok is the 'once'.
 ///
 void Prep

[PATCH] D19849: [clang-tidy] MoveConstructorInitCheck - Add parameter name to check message.

2016-05-02 Thread Felix Berger via cfe-commits
flx created this revision.
flx added a reviewer: alexfh.
flx added a subscriber: cfe-commits.
flx set the repository for this revision to rL LLVM.

Repository:
  rL LLVM

http://reviews.llvm.org/D19849

Files:
  clang-tidy/misc/MoveConstructorInitCheck.cpp
  test/clang-tidy/misc-move-constructor-init.cpp

Index: test/clang-tidy/misc-move-constructor-init.cpp
===
--- test/clang-tidy/misc-move-constructor-init.cpp
+++ test/clang-tidy/misc-move-constructor-init.cpp
@@ -96,7 +96,7 @@
 
 struct Positive {
   Positive(Movable M) : M_(M) {}
-  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument can be moved to 
avoid copy [misc-move-constructor-init]
+  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument M can be moved to 
avoid copy [misc-move-constructor-init]
   // CHECK-FIXES: Positive(Movable M) : M_(std::move(M)) {}
   Movable M_;
 };
Index: clang-tidy/misc/MoveConstructorInitCheck.cpp
===
--- clang-tidy/misc/MoveConstructorInitCheck.cpp
+++ clang-tidy/misc/MoveConstructorInitCheck.cpp
@@ -109,8 +109,9 @@
   if (parmVarDeclRefExprOccurences(*MovableParam, *ConstructorDecl,
*Result.Context) > 1)
 return;
-  auto DiagOut =
-  diag(InitArg->getLocStart(), "value argument can be moved to avoid 
copy");
+  auto DiagOut = diag(InitArg->getLocStart(),
+  "value argument %0 can be moved to avoid copy")
+ << MovableParam->getName();
   DiagOut << FixItHint::CreateReplacement(
   InitArg->getSourceRange(),
   (Twine("std::move(") + MovableParam->getName() + ")").str());


Index: test/clang-tidy/misc-move-constructor-init.cpp
===
--- test/clang-tidy/misc-move-constructor-init.cpp
+++ test/clang-tidy/misc-move-constructor-init.cpp
@@ -96,7 +96,7 @@
 
 struct Positive {
   Positive(Movable M) : M_(M) {}
-  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument can be moved to avoid copy [misc-move-constructor-init]
+  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument M can be moved to avoid copy [misc-move-constructor-init]
   // CHECK-FIXES: Positive(Movable M) : M_(std::move(M)) {}
   Movable M_;
 };
Index: clang-tidy/misc/MoveConstructorInitCheck.cpp
===
--- clang-tidy/misc/MoveConstructorInitCheck.cpp
+++ clang-tidy/misc/MoveConstructorInitCheck.cpp
@@ -109,8 +109,9 @@
   if (parmVarDeclRefExprOccurences(*MovableParam, *ConstructorDecl,
*Result.Context) > 1)
 return;
-  auto DiagOut =
-  diag(InitArg->getLocStart(), "value argument can be moved to avoid copy");
+  auto DiagOut = diag(InitArg->getLocStart(),
+  "value argument %0 can be moved to avoid copy")
+ << MovableParam->getName();
   DiagOut << FixItHint::CreateReplacement(
   InitArg->getSourceRange(),
   (Twine("std::move(") + MovableParam->getName() + ")").str());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-05-02 Thread John McCall via cfe-commits
rjmccall added a comment.

This discussion of the command line interface makes me think that we should be 
taking Richard's suggestion one step further.  Why is Clang's involvement here 
more than just handing down specific requests for optimization data to LLVM and 
packaging that information back into some reasonable format?  The actual 
presentation of that data seems like it belongs in a separate library / tool, 
which can have a rich set of visualization options.  This is also a more 
rigorously testable design, since the tool has a well-defined input format 
that's not just an incidental by-product of the compiler.

If we did that, then Clang just needs (1) an output filename, (2) an optional 
list of passes to collect data from, and (3) maybe some stringly-typed 
configuration data for each.


http://reviews.llvm.org/D19678



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


Re: [PATCH] D19841: [clang-tidy] Lift common matchers to utils namespace

2016-05-02 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: clang-tidy/utils/Matchers.h:20
@@ -19,1 +19,3 @@
 
+AST_MATCHER_P(StringLiteral, lengthIs, unsigned, N) {
+  return Node.getLength() == N;

All these should go to ASTMatchers.h (with tests and documentation).


http://reviews.llvm.org/D19841



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


Re: [PATCH] D18300: [clang-tidy] ProTypeMemberInitCheck - check that field decls do not have in-class initializer

2016-05-02 Thread Felix Berger via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268352: [clang-tidy] ProTypeMemberInitCheck - check that 
field decls do not have in… (authored by flx).

Changed prior to commit:
  http://reviews.llvm.org/D18300?vs=51123&id=55934#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18300

Files:
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -31,6 +31,8 @@
  ASTContext &Context,
  SmallPtrSetImpl &FieldsToInit) {
   for (const FieldDecl *F : Fields) {
+if (F->hasInClassInitializer())
+  continue;
 QualType Type = F->getType();
 if (!F->hasInClassInitializer() &&
 type_traits::isTriviallyDefaultConstructible(Type, Context))
Index: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -85,6 +85,14 @@
   int I;
 };
 
+struct A {};
+template  class AA;
+template  class NegativeTemplateConstructor {
+  NegativeTemplateConstructor(const AA &, A) {}
+  bool Bool{false};
+  // CHECK-FIXES: bool Bool{false};
+};
+
 #define UNINITIALIZED_FIELD_IN_MACRO_BODY(FIELD) \
   struct UninitializedField##FIELD { \
 UninitializedField##FIELD() {}   \


Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -31,6 +31,8 @@
  ASTContext &Context,
  SmallPtrSetImpl &FieldsToInit) {
   for (const FieldDecl *F : Fields) {
+if (F->hasInClassInitializer())
+  continue;
 QualType Type = F->getType();
 if (!F->hasInClassInitializer() &&
 type_traits::isTriviallyDefaultConstructible(Type, Context))
Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -85,6 +85,14 @@
   int I;
 };
 
+struct A {};
+template  class AA;
+template  class NegativeTemplateConstructor {
+  NegativeTemplateConstructor(const AA &, A) {}
+  bool Bool{false};
+  // CHECK-FIXES: bool Bool{false};
+};
+
 #define UNINITIALIZED_FIELD_IN_MACRO_BODY(FIELD) \
   struct UninitializedField##FIELD { \
 UninitializedField##FIELD() {}   \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r268352 - [clang-tidy] ProTypeMemberInitCheck - check that field decls do not have in-class initializer.

2016-05-02 Thread Felix Berger via cfe-commits
Author: flx
Date: Mon May  2 20:41:19 2016
New Revision: 268352

URL: http://llvm.org/viewvc/llvm-project?rev=268352&view=rev
Log:
[clang-tidy] ProTypeMemberInitCheck - check that field decls do not have 
in-class initializer.

Reviewers: alexfh, JVApen, aaron.ballman

Subscribers: flx, aaron.ballman, cfe-commits

Differential Revision: http://reviews.llvm.org/D18300

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=268352&r1=268351&r2=268352&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Mon May  2 20:41:19 2016
@@ -31,6 +31,8 @@ void fieldsRequiringInit(const RecordDec
  ASTContext &Context,
  SmallPtrSetImpl &FieldsToInit) {
   for (const FieldDecl *F : Fields) {
+if (F->hasInClassInitializer())
+  continue;
 QualType Type = F->getType();
 if (!F->hasInClassInitializer() &&
 type_traits::isTriviallyDefaultConstructible(Type, Context))

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp?rev=268352&r1=268351&r2=268352&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 Mon May  2 20:41:19 2016
@@ -85,6 +85,14 @@ struct NegativeInitializedInBody {
   int I;
 };
 
+struct A {};
+template  class AA;
+template  class NegativeTemplateConstructor {
+  NegativeTemplateConstructor(const AA &, A) {}
+  bool Bool{false};
+  // CHECK-FIXES: bool Bool{false};
+};
+
 #define UNINITIALIZED_FIELD_IN_MACRO_BODY(FIELD) \
   struct UninitializedField##FIELD { \
 UninitializedField##FIELD() {}   \


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


Re: [PATCH] D19819: [clang-tidy] Cleanup namespace in utils folder.

2016-05-02 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thank you!


http://reviews.llvm.org/D19819



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


[PATCH] D19846: [clang-tidy] Lift parsing of sequence of names functions to utils.

2016-05-02 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

Lift some common code used by multiple checkers.

This function is also used by checkers that are coming.
It is quite common for a checker to parse a list of names.

http://reviews.llvm.org/D19846

Files:
  clang-tidy/misc/DanglingHandleCheck.cpp
  clang-tidy/misc/SuspiciousStringCompareCheck.cpp
  clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tidy/utils/CMakeLists.txt
  clang-tidy/utils/OptionUtils.cpp
  clang-tidy/utils/OptionUtils.h

Index: clang-tidy/utils/OptionUtils.h
===
--- /dev/null
+++ clang-tidy/utils/OptionUtils.h
@@ -0,0 +1,31 @@
+//===--- DanglingHandleCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_OPTIONUTILS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_OPTIONUTILS_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace option {
+
+/// \brief Parse a list of names separated by ";" character.
+std::vector parseNames(StringRef Option);
+
+/// \brief Serialize a sequence of names that can be parse by parseNames.
+std::string serializeNames(const std::vector &Names);
+
+} // namespace option
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_OPTIONUTILS_H
Index: clang-tidy/utils/OptionUtils.cpp
===
--- /dev/null
+++ clang-tidy/utils/OptionUtils.cpp
@@ -0,0 +1,38 @@
+//===--- DanglingHandleCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "OptionUtils.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace option {
+
+static const char NamesDelimiter[] = ";";
+
+std::vector parseNames(StringRef Option) {
+  SmallVector Names;
+  Option.split(Names, NamesDelimiter);
+  std::vector Result;
+  for (StringRef &Name : Names) {
+Name = Name.trim();
+if (!Name.empty())
+  Result.push_back(Name);
+  }
+  return Result;
+}
+
+std::string serializeNames(const std::vector &Names) {
+  return llvm::join(Names.begin(), Names.end(), NamesDelimiter);
+}
+
+} // namespace option
+} // namespace utils
+} // namespace tidy
+} // namespace clang
Index: clang-tidy/utils/CMakeLists.txt
===
--- clang-tidy/utils/CMakeLists.txt
+++ clang-tidy/utils/CMakeLists.txt
@@ -3,11 +3,12 @@
 add_clang_library(clangTidyUtils
   DeclRefExprUtils.cpp
   FixItHintUtils.cpp
-  HeaderGuard.cpp
   HeaderFileExtensionsUtils.cpp
+  HeaderGuard.cpp
   IncludeInserter.cpp
   IncludeSorter.cpp
   LexerUtils.cpp
+  OptionUtils.cpp
   TypeTraits.cpp
 
   LINK_LIBS
Index: clang-tidy/performance/FasterStringFindCheck.cpp
===
--- clang-tidy/performance/FasterStringFindCheck.cpp
+++ clang-tidy/performance/FasterStringFindCheck.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "FasterStringFindCheck.h"
+#include "../utils/OptionUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "llvm/ADT/Optional.h"
@@ -21,20 +22,6 @@
 
 namespace {
 
-static const char StringLikeClassesDelimiter[] = ";";
-
-std::vector ParseClasses(StringRef Option) {
-  SmallVector Classes;
-  Option.split(Classes, StringLikeClassesDelimiter);
-  std::vector Result;
-  for (StringRef &Class : Classes) {
-Class = Class.trim();
-if (!Class.empty())
-  Result.push_back(Class);
-  }
-  return Result;
-}
-
 llvm::Optional MakeCharacterLiteral(const StringLiteral *Literal) {
   std::string Result;
   {
@@ -64,14 +51,13 @@
 FasterStringFindCheck::FasterStringFindCheck(StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  StringLikeClasses(
-  ParseClasses(Options.get("StringLikeClasses", "std::basic_string"))) {
+  StringLikeClasses(utils::option::parseNames(
+  Options.get("StringLikeClasses", "std::basic_string"))) {
 }
 
 void FasterStringFindCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "StringLikeClasses",
-llvm::join(StringLikeClasses.begin(), StringLikeClasses.end(),
-   S

[clang-tools-extra] r268349 - [Clang-tidy] Fix Clang-tidy modernize-use-override and some Include What You Use warnings in modernize/MakeSmartPtrCheck.h.

2016-05-02 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Mon May  2 20:13:27 2016
New Revision: 268349

URL: http://llvm.org/viewvc/llvm-project?rev=268349&view=rev
Log:
[Clang-tidy] Fix Clang-tidy modernize-use-override and some Include What You 
Use warnings in modernize/MakeSmartPtrCheck.h.

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h?rev=268349&r1=268348&r2=268349&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h Mon May  2 
20:13:27 2016
@@ -11,6 +11,9 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_SMART_PTR_H
 
 #include "../ClangTidy.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
+#include "llvm/ADT/StringRef.h"
 #include 
 
 namespace clang {
@@ -22,9 +25,8 @@ class MakeSmartPtrCheck : public ClangTi
 public:
   MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context,
 std::string makeSmartPtrFunctionName);
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override final;
-  void
-  check(const ast_matchers::MatchFinder::MatchResult &Result) override final;
+  void registerMatchers(ast_matchers::MatchFinder *Finder) final;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) final;
 
 protected:
   using SmartPtrTypeMatcher = 
ast_matchers::internal::BindableMatcher;


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


Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-05-02 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

In http://reviews.llvm.org/D19678#419361, @rcox2 wrote:

> Of course, it would be my preference to mirror the functionality of what is 
> available in the "new" hierarchical form of optimization report Intel 
> compiler.  So, I would like to distinguish between what Hal is proposing 
> (which we call an "annotated listing") and what I am proposing, which we call 
> an "optimization report".
>
> If Hal wants to call what he is proposing the "optimization report", then we 
> need to come up with another name for what I am proposing.


To be clear, I'm fine with calling this something else. How about "optimization 
summary" or "annotated optimization summary"? I could name the option 
-fannotated-optimization-summary, for example.

> To summarize what the Intel compiler has

> 

>   -qopt-report[=N] where the default is 2 and the range is 1-5, with 1 
> having the least detail and 5 having the most detail 

>   -qopt-report-file=F   where F is a file name or stdout or stderr 

>   -qopt-report-phase=P where P is a sequence of phases (like ipo,cg, etc.) 
> and only those phases are printed 

>   -qopt-report-filter=X  where X allows you to filter opt reports only for 
> certain routines or parts of routines 

> 

> Use of ANY of these implies the generation of an opt report, so you don't 
> need to say:

> 

>   -qopt-report -qopt-report-file=stderr

> 

> since

> 

>   -qopt-report-file=stderr 

> 

> is sufficient.

> 

> On a slightly different topic 

> 

>

> 

> One key question I have about Hal's proposal is whether there is any 
> annotation associated with code that is inlined, beyond noting the call site 
> that is inlined.

> 

> For example, if we have:

> 

>int foo() { 

>... 

>loop 

>

>   } 

>   int main() { 

>   ...

>   foo(); 

>   ...

>} 

> 

> and foo gets inlined, we have two loops of interest, the loop in foo() and 
> the loop inlined into main().  Each of these could be vectorized, unrolled, 
> etc. and it isn't always the case that both loops would have the same 
> properties.  So, does Hal's report indicate info only about the loop in 
> foo(), or are the properties of the two loops ANDed or ORed together and 
> reported next to the loop in foo, or something else?

> 

> In general, you want info about both loops, and you can that with a classic 
> optimization report.  But it's not clear how to effectively represent this on 
> the lightweight annotated listing.  And it is often the case that the inlined 
> loop is actually the more executed one, and therefore more important.


Currently, the information is ORed together. This has exactly the problem that 
you indicate, although the problem can be even worse than that: Functions are 
often transitively inlined multiple times into the same function, and users 
often want to know if the loops in those functions (or the inlining decisions 
themselves) differed each time. In the future, I'd like to detect this 
situation and present this information to the user. The common case (same 
behavior everywhere) should carry a succinct annotation, but otherwise we might 
want to do something like this:

  1234  |for (...)
 V  |^
|* When inlined into foo (file.c:789), doit (d.c:45) -> bar 
(bar.c:234), not when inlined into work (work.c:345), doit (d.c:45) -> bar 
(bar.c:254)

Or we might just want to indicate that the annotation applies only to some 
places where the code was inlined and the user can generate a more-detailed 
optimization report for more information. I'm certainly open to suggestions, 
but I'd like to handle this in follow-up because it will likely require backend 
enhancements as well.

A related issue comes up with templated code; we might want to indicate the 
types when the optimizations end up being type dependent.


http://reviews.llvm.org/D19678



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


Re: [PATCH] D19758: [libcxx] [test] Replace non-Standard "atomic_flag f(false); " with Standard "atomic_flag f; "

2016-05-02 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT added a comment.

I think this will work for me. Thanks!


http://reviews.llvm.org/D19758



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


[libcxx] r268346 - Guard use of in test.

2016-05-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May  2 19:36:57 2016
New Revision: 268346

URL: http://llvm.org/viewvc/llvm-project?rev=268346&view=rev
Log:
Guard use of  in test.

Modified:
libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp

Modified: libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp?rev=268346&r1=268345&r2=268346&view=diff
==
--- libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp (original)
+++ libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp Mon May  2 
19:36:57 2016
@@ -22,7 +22,11 @@
 #include 
 #include 
 #include 
+
+#if !defined(_WIN32)
 #include 
+#endif
+
 
 bool is_valid_random_device(const std::string &token) {
 #if defined(_LIBCPP_USING_DEV_RANDOM)
@@ -41,32 +45,19 @@ void check_random_device_invalid(const s
   try {
 std::random_device r(token);
 assert(false);
-  } catch (const std::system_error &e) {
+  } catch (const std::system_error&) {
   }
 }
 
-int main() {
-  { std::random_device r; }
 
+int main() {
   {
-int ec;
-ec = close(STDIN_FILENO);
-assert(!ec);
-ec = close(STDOUT_FILENO);
-assert(!ec);
-ec = close(STDERR_FILENO);
-assert(!ec);
 std::random_device r;
   }
-
   {
 std::string token = "wrong file";
-if (is_valid_random_device(token))
-  check_random_device_valid(token);
-else
-  check_random_device_invalid(token);
+check_random_device_invalid(token);
   }
-
   {
 std::string token = "/dev/urandom";
 if (is_valid_random_device(token))
@@ -74,7 +65,6 @@ int main() {
 else
   check_random_device_invalid(token);
   }
-
   {
 std::string token = "/dev/random";
 if (is_valid_random_device(token))
@@ -82,4 +72,19 @@ int main() {
 else
   check_random_device_invalid(token);
   }
+#if !defined(_WIN32)
+// Test that random_device(const string&) properly handles getting
+// a file descriptor with the value '0'. Do this by closing the standard
+// streams so that the descriptor '0' is available.
+  {
+int ec;
+ec = close(STDIN_FILENO);
+assert(!ec);
+ec = close(STDOUT_FILENO);
+assert(!ec);
+ec = close(STDERR_FILENO);
+assert(!ec);
+std::random_device r;
+  }
+#endif // !defined(_WIN32)
 }


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


Re: [PATCH] D19048: Test for a module related crash in CGDebugInfo.cpp

2016-05-02 Thread Douglas Yung via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268344: Adding a test for a compiler crash that was fixed in 
r248069. (authored by dyung).

Changed prior to commit:
  http://reviews.llvm.org/D19048?vs=55495&id=55925#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19048

Files:
  cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/h1.h
  cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
  cfe/trunk/test/Modules/getSourceDescriptor-crash.cpp

Index: cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/h1.h
===
--- cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/h1.h
+++ cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/h1.h
@@ -0,0 +1 @@
+#pragma once
Index: cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
===
--- cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
+++ cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
@@ -0,0 +1,3 @@
+module foo {
+   header "h1.h"
+}
Index: cfe/trunk/test/Modules/getSourceDescriptor-crash.cpp
===
--- cfe/trunk/test/Modules/getSourceDescriptor-crash.cpp
+++ cfe/trunk/test/Modules/getSourceDescriptor-crash.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -I %S/Inputs/getSourceDescriptor-crash -S -emit-llvm 
-debug-info-kind=limited -fimplicit-module-maps %s -o - | FileCheck %s
+
+#include "h1.h"
+#include "h1.h"
+
+// CHECK: DIImportedEntity
+// CHECK-SAME: entity: ![[ENTITY:[0-9]+]]
+// CHECK: ![[ENTITY]] = !DIModule
+// CHECK-SAME: name: "foo"


Index: cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/h1.h
===
--- cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/h1.h
+++ cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/h1.h
@@ -0,0 +1 @@
+#pragma once
Index: cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
===
--- cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
+++ cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
@@ -0,0 +1,3 @@
+module foo {
+   header "h1.h"
+}
Index: cfe/trunk/test/Modules/getSourceDescriptor-crash.cpp
===
--- cfe/trunk/test/Modules/getSourceDescriptor-crash.cpp
+++ cfe/trunk/test/Modules/getSourceDescriptor-crash.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -I %S/Inputs/getSourceDescriptor-crash -S -emit-llvm -debug-info-kind=limited -fimplicit-module-maps %s -o - | FileCheck %s
+
+#include "h1.h"
+#include "h1.h"
+
+// CHECK: DIImportedEntity
+// CHECK-SAME: entity: ![[ENTITY:[0-9]+]]
+// CHECK: ![[ENTITY]] = !DIModule
+// CHECK-SAME: name: "foo"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268344 - Adding a test for a compiler crash that was fixed in r248069.

2016-05-02 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Mon May  2 19:29:56 2016
New Revision: 268344

URL: http://llvm.org/viewvc/llvm-project?rev=268344&view=rev
Log:
Adding a test for a compiler crash that was fixed in r248069.

Differential Revision: http://reviews.llvm.org/D19048


Added:
cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/
cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/h1.h
cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
cfe/trunk/test/Modules/getSourceDescriptor-crash.cpp

Added: cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/h1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/h1.h?rev=268344&view=auto
==
--- cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/h1.h (added)
+++ cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/h1.h Mon May  2 
19:29:56 2016
@@ -0,0 +1 @@
+#pragma once

Added: cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap?rev=268344&view=auto
==
--- cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap 
(added)
+++ cfe/trunk/test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap 
Mon May  2 19:29:56 2016
@@ -0,0 +1,3 @@
+module foo {
+   header "h1.h"
+}

Added: cfe/trunk/test/Modules/getSourceDescriptor-crash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/getSourceDescriptor-crash.cpp?rev=268344&view=auto
==
--- cfe/trunk/test/Modules/getSourceDescriptor-crash.cpp (added)
+++ cfe/trunk/test/Modules/getSourceDescriptor-crash.cpp Mon May  2 19:29:56 
2016
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -I %S/Inputs/getSourceDescriptor-crash -S -emit-llvm 
-debug-info-kind=limited -fimplicit-module-maps %s -o - | FileCheck %s
+
+#include "h1.h"
+#include "h1.h"
+
+// CHECK: DIImportedEntity
+// CHECK-SAME: entity: ![[ENTITY:[0-9]+]]
+// CHECK: ![[ENTITY]] = !DIModule
+// CHECK-SAME: name: "foo"


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


[PATCH] D19843: Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-05-02 Thread Eric Niebler via cfe-commits
eric_niebler created this revision.
eric_niebler added a reviewer: bruno.
eric_niebler added a subscriber: cfe-commits.

Full discussion of this diff can be found here: 
http://lists.llvm.org/pipermail/cfe-dev/2016-April/048298.html

See D19842 for the corresponding LLVM diff.

Before this is accepted, I will need to decide what to do about the test, which 
is likely to be somewhat flakey due to the very nature of the problem.

http://reviews.llvm.org/D19843

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticLexKinds.td
  include/clang/Basic/FileManager.h
  include/clang/Basic/VirtualFileSystem.h
  include/clang/Lex/DirectoryLookup.h
  include/clang/Lex/HeaderSearch.h
  lib/Basic/FileManager.cpp
  lib/Basic/VirtualFileSystem.cpp
  lib/Lex/HeaderSearch.cpp
  lib/Lex/PPDirectives.cpp
  test/Lexer/Inputs/case-insensitive-include.h
  test/Lexer/case-insensitive-include.c
  test/PCH/case-insensitive-include.c

Index: test/PCH/case-insensitive-include.c
===
--- test/PCH/case-insensitive-include.c
+++ test/PCH/case-insensitive-include.c
@@ -2,7 +2,7 @@
 
 // Test this without pch.
 // RUN: cp %S/Inputs/case-insensitive-include.h %T
-// RUN: %clang_cc1 -fsyntax-only %s -include %s -I %T -verify
+// RUN: %clang_cc1 -Wno-nonportable-include-path -fsyntax-only %s -include %s -I %T -verify
 
 // Test with pch.
 // RUN: %clang_cc1 -emit-pch -o %t.pch %s -I %T
Index: test/Lexer/case-insensitive-include.c
===
--- /dev/null
+++ test/Lexer/case-insensitive-include.c
@@ -0,0 +1,42 @@
+// REQUIRES: case-insensitive-filesystem
+
+// RUN: mkdir -p %T/apath
+// RUN: cp %S/Inputs/case-insensitive-include.h %T
+// RUN: %clang_cc1 -fsyntax-only %s -include %s -I %T -verify
+
+// RUN: cp %S/Inputs/case-insensitive-include.h %T
+// RUN: %clang_cc1 -fsyntax-only -fms-compatibility -DMS_COMPATIBILITY %s -include %s -I %T -verify
+
+#ifndef HEADER
+#define HEADER
+
+#include "case-insensitive-include.h"
+#include "Case-Insensitive-Include.h" // expected-warning {{Non-portable path}}
+
+#include "../Output/./case-insensitive-include.h"
+#include "../Output/./Case-Insensitive-Include.h" // expected-warning {{Non-portable path}}
+#include "../output/./case-insensitive-include.h" // expected-warning {{Non-portable path}}
+
+#include "apath/.././case-insensitive-include.h"
+#include "apath/.././Case-Insensitive-Include.h" // expected-warning {{Non-portable path}}
+#include "APath/.././case-insensitive-include.h" // For the sake of efficiency, this case is not diagnosed. :-(
+
+#include "../Output/./apath/.././case-insensitive-include.h"
+#include "../Output/./APath/.././case-insensitive-include.h" // For the sake of efficiency, this case is not diagnosed. :-(
+#include "../output/./apath/.././case-insensitive-include.h" // expected-warning {{Non-portable path}}
+
+#if MS_COMPATIBILITY
+#include "..\Output\.\case-insensitive-include.h"
+#include "..\Output\.\Case-Insensitive-Include.h" // expected-warning {{Non-portable path}}
+#include "..\output\.\case-insensitive-include.h" // expected-warning {{Non-portable path}}
+
+#include "apath\..\.\case-insensitive-include.h"
+#include "apath\..\.\Case-Insensitive-Include.h" // expected-warning {{Non-portable path}}
+#include "APath\..\.\case-insensitive-include.h" // For the sake of efficiency, this case is not diagnosed. :-(
+#endif
+
+#else
+
+#include "Case-Insensitive-Include.h" // expected-warning {{Non-portable path}}
+
+#endif
Index: test/Lexer/Inputs/case-insensitive-include.h
===
--- /dev/null
+++ test/Lexer/Inputs/case-insensitive-include.h
@@ -0,0 +1,5 @@
+#pragma once
+
+struct S {
+  int x;
+};
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -24,6 +24,9 @@
 #include "clang/Lex/ModuleLoader.h"
 #include "clang/Lex/Pragma.h"
 #include "llvm/ADT/APInt.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/SaveAndRestore.h"
@@ -1661,6 +1664,53 @@
 }
   }
 
+  // Issue a diagnostic if the name of the file on disk has a different case
+  // than the one we're about to open.
+
+  // Because typo correction is expensive, only do it if the implicit
+  // function declaration is going to be treated as an error.
+  if (File && !File->tryGetRealPathName().empty() &&
+!Diags->isIgnored(diag::pp_nonportable_path, FilenameTok.getLocation())) {
+StringRef Name = LangOpts.MSVCCompat ? NormalizedPath.c_str() : Filename;
+StringRef RealPathName = File->tryGetRealPathName();
+SmallVector Components(llvm::sys::path::begin(Name),
+  llvm::sys::path::end(Name));
+au

Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-05-02 Thread Robert Cox via cfe-commits
rcox2 added a comment.

Of course, it would be my preference to mirror the functionality of what is 
available in the "new" hierarchical form of optimization report Intel compiler. 
 So, I would like to distinguish between what Hal is proposing (which we call 
an "annotated listing") and what I am proposing, which we call an "optimization 
report".

If Hal wants to call what he is proposing the "optimization report", then we 
need to come up with another name for what I am proposing.

To summarize what the Intel compiler has

  -qopt-report[=N] where the default is 2 and the range is 1-5, with 1 
having the least detail and 5 having the most detail 
  -qopt-report-file=F   where F is a file name or stdout or stderr 
  -qopt-report-phase=P where P is a sequence of phases (like ipo,cg, etc.) and 
only those phases are printed 
  -qopt-report-filter=X  where X allows you to filter opt reports only for 
certain routines or parts of routines 

Use of ANY of these implies the generation of an opt report, so you don't need 
to say:

  -qopt-report -qopt-report-file=stderr

since

  -qopt-report-file=stderr 

is sufficient.

On a slightly different topic 

  

One key question I have about Hal's proposal is whether there is any annotation 
associated with code that is inlined, beyond noting the call site that is 
inlined.

For example, if we have:

   int foo() { 
   ... 
   loop 
   
  } 
  int main() { 
  ...
  foo(); 
  ...
   } 

and foo gets inlined, we have two loops of interest, the loop in foo() and the 
loop inlined into main().  Each of these could be vectorized, unrolled, etc. 
and it isn't always the case that both loops would have the same properties.  
So, does Hal's report indicate info only about the loop in foo(), or are the 
properties of the two loops ANDed or ORed together and reported next to the 
loop in foo, or something else?

In general, you want info about both loops, and you can that with a classic 
optimization report.  But it's not clear how to effectively represent this on 
the lightweight annotated listing.  And it is often the case that the inlined 
loop is actually the more executed one, and therefore more important.


http://reviews.llvm.org/D19678



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


Re: [PATCH] D19758: [libcxx] [test] Replace non-Standard "atomic_flag f(false); " with Standard "atomic_flag f; "

2016-05-02 Thread Eric Fiselier via cfe-commits
EricWF retitled this revision from "[libcxx] [test] Replace non-Standard 
"atomic_flag f(false);" with Standard "atomic_flag f = ATOMIC_FLAG_INIT;"." to 
"[libcxx] [test] Replace non-Standard "atomic_flag f(false);" with Standard 
"atomic_flag f;" ".
EricWF updated the summary for this revision.
EricWF updated this revision to Diff 55920.
EricWF added a comment.

@STL_MSFT Does this work for you? I simply removed the initializer and call the 
default constructor instead. This leaves 'f' in an unspecified state but that 
shouldn't matter because we always call 'f.test_and_set()' before testing the 
clear operation.


http://reviews.llvm.org/D19758

Files:
  include/atomic
  test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
  test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
  test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
  test/std/atomics/atomics.flag/clear.pass.cpp
  test/std/atomics/atomics.flag/init03.pass.cpp

Index: test/std/atomics/atomics.flag/init03.pass.cpp
===
--- test/std/atomics/atomics.flag/init03.pass.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===--===//
-//
-// 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.
-//
-//===--===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
-
-// 
-
-// struct atomic_flag
-
-// TESTING EXTENSION atomic_flag(bool)
-
-#include 
-#include 
-
-int main()
-{
-std::atomic_flag f(false);
-assert(f.test_and_set() == 0);
-}
Index: test/std/atomics/atomics.flag/clear.pass.cpp
===
--- test/std/atomics/atomics.flag/clear.pass.cpp
+++ test/std/atomics/atomics.flag/clear.pass.cpp
@@ -22,49 +22,49 @@
 int main()
 {
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 f.clear();
 assert(f.test_and_set() == 0);
 }
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 f.clear(std::memory_order_relaxed);
 assert(f.test_and_set() == 0);
 }
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 f.clear(std::memory_order_release);
 assert(f.test_and_set() == 0);
 }
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 f.clear(std::memory_order_seq_cst);
 assert(f.test_and_set() == 0);
 }
 {
-volatile std::atomic_flag f(false);
+volatile std::atomic_flag f;
 f.test_and_set();
 f.clear();
 assert(f.test_and_set() == 0);
 }
 {
-volatile std::atomic_flag f(false);
+volatile std::atomic_flag f;
 f.test_and_set();
 f.clear(std::memory_order_relaxed);
 assert(f.test_and_set() == 0);
 }
 {
-volatile std::atomic_flag f(false);
+volatile std::atomic_flag f;
 f.test_and_set();
 f.clear(std::memory_order_release);
 assert(f.test_and_set() == 0);
 }
 {
-volatile std::atomic_flag f(false);
+volatile std::atomic_flag f;
 f.test_and_set();
 f.clear(std::memory_order_seq_cst);
 assert(f.test_and_set() == 0);
Index: test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
===
--- test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
+++ test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
@@ -22,37 +22,37 @@
 int main()
 {
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
 assert(f.test_and_set() == 0);
 }
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear_explicit(&f, std::memory_order_release);
 assert(f.test_and_set() == 0);
 }
 {
-std::atomic_flag f(false);
+std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
 assert(f.test_and_set() == 0);
 }
 {
-volatile std::atomic_flag f(false);
+volatile std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
 assert(f.test_and_set() == 0);
 }
 {
-volatile std::atomic_flag f(false);
+volatile std::atomic_flag f;
 f.test_and_set();
 atomic_flag_clear_explicit(&f, std::memory_order_release);
 assert(f.test_and_set() == 0);
 }
 {
-volatile std:

Re: [PATCH] D19758: [libcxx] [test] Replace non-Standard "atomic_flag f(false); " with Standard "atomic_flag f = ATOMIC_FLAG_INIT; ".

2016-05-02 Thread Eric Fiselier via cfe-commits
EricWF commandeered this revision.
EricWF edited reviewers, added: STL_MSFT; removed: EricWF.
EricWF added a comment.

Stealing this review from STL.


http://reviews.llvm.org/D19758



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


[PATCH] D19841: [clang-tidy] Lift common matchers to utils namespace

2016-05-02 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

This patch is lifting matchers used by more than one checkers
to the common namespace.

http://reviews.llvm.org/D19841

Files:
  clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp
  clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tidy/readability/ImplicitBoolCastCheck.cpp
  clang-tidy/readability/RedundantStringInitCheck.cpp
  clang-tidy/utils/Matchers.h

Index: clang-tidy/utils/Matchers.h
===
--- clang-tidy/utils/Matchers.h
+++ clang-tidy/utils/Matchers.h
@@ -17,6 +17,19 @@
 namespace tidy {
 namespace matchers {
 
+AST_MATCHER_P(StringLiteral, lengthIs, unsigned, N) {
+  return Node.getLength() == N;
+}
+
+AST_MATCHER_P(Expr, ignoringImplicit,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  return InnerMatcher.matches(*Node.IgnoreImplicit(), Finder, Builder);
+}
+
+AST_MATCHER_P(CastExpr, hasCastKind, CastKind, Kind) {
+  return Node.getCastKind() == Kind;
+}
+
 AST_MATCHER(BinaryOperator, isRelationalOperator) {
   return Node.isRelationalOp();
 }
Index: clang-tidy/readability/RedundantStringInitCheck.cpp
===
--- clang-tidy/readability/RedundantStringInitCheck.cpp
+++ clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -8,25 +8,16 @@
 //===--===//
 
 #include "RedundantStringInitCheck.h"
+#include "../utils/Matchers.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 
 using namespace clang::ast_matchers;
+using namespace clang::tidy::matchers;
 
 namespace clang {
 namespace tidy {
 namespace readability {
 
-namespace {
-
-AST_MATCHER(StringLiteral, lengthIsZero) { return Node.getLength() == 0; }
-
-AST_MATCHER_P(Expr, ignoringImplicit,
-  ast_matchers::internal::Matcher, InnerMatcher) {
-  return InnerMatcher.matches(*Node.IgnoreImplicit(), Finder, Builder);
-}
-
-} // namespace
-
 void RedundantStringInitCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
@@ -45,7 +36,7 @@
   const auto EmptyStringCtorExpr =
   cxxConstructExpr(StringConstructorExpr,
   hasArgument(0, ignoringParenImpCasts(
- stringLiteral(lengthIsZero();
+ stringLiteral(lengthIs(0);
 
   const auto EmptyStringCtorExprWithTemporaries =
   expr(ignoringImplicit(
Index: clang-tidy/readability/ImplicitBoolCastCheck.cpp
===
--- clang-tidy/readability/ImplicitBoolCastCheck.cpp
+++ clang-tidy/readability/ImplicitBoolCastCheck.cpp
@@ -8,22 +8,20 @@
 //===--===//
 
 #include "ImplicitBoolCastCheck.h"
+#include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
+using namespace clang::tidy::matchers;
 
 namespace clang {
 namespace tidy {
 namespace readability {
 
 namespace {
 
-AST_MATCHER_P(CastExpr, hasCastKind, CastKind, Kind) {
-  return Node.getCastKind() == Kind;
-}
-
 AST_MATCHER(Stmt, isMacroExpansion) {
   SourceManager &SM = Finder->getASTContext().getSourceManager();
   SourceLocation Loc = Node.getLocStart();
Index: clang-tidy/performance/FasterStringFindCheck.cpp
===
--- clang-tidy/performance/FasterStringFindCheck.cpp
+++ clang-tidy/performance/FasterStringFindCheck.cpp
@@ -8,12 +8,14 @@
 //===--===//
 
 #include "FasterStringFindCheck.h"
+#include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang::ast_matchers;
+using namespace clang::tidy::matchers;
 
 namespace clang {
 namespace tidy {
@@ -51,8 +53,6 @@
   return Result;
 }
 
-AST_MATCHER(StringLiteral, lengthIsOne) { return Node.getLength() == 1; }
-
 AST_MATCHER_FUNCTION(ast_matchers::internal::Matcher,
  hasSubstitutedType) {
   return hasType(qualType(anyOf(substTemplateTypeParmType(),
@@ -79,7 +79,7 @@
 return;
 
   const auto SingleChar =
-  expr(ignoringParenCasts(stringLiteral(lengthIsOne()).bind("literal")));
+  expr(ignoringParenCasts(stringLiteral(lengthIs(1)).bind("literal")));
 
   const auto StringFindFunctions =
   anyOf(hasName("find"), hasName("rfind"), hasName("find_first_of"),
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -8,13

Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-05-02 Thread Sean Silva via cfe-commits
On Mon, May 2, 2016 at 4:14 PM, Hal Finkel via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> hfinkel added a comment.
>
> In http://reviews.llvm.org/D19678#416127, @rcox2 wrote:
>
> > Actually, the Intel compiler distinguishes between an optimization
> report (-qopt-report) and an annotated listing (-qopt-report-annotate).
> The optimization report lists the info for optimizations in a hierarchical
> fashion.  To use you example,
> >
> >   icc -c -O3 -qopt-report=1 -qopt-report-file=stderr v.c
> >
> > yields:
>
>
> Robert, John, (et al.), do you think I should change this to have an
> -foptimization-report-file= and -foptimization-report, instead of
> -foptimization-report=? In the future, when we have multiple
> kinds of reports (a detailed inlining report, for example), maybe we want
> to use -foptimization-report=inlining,somethingelse,andmore?
>

If we have `-foptimization-report=foo,bar`, would we want them to share the
same output file? Or maybe `-foptimization-report-file=` would result
in `.foo` and `.bar` for the different reports?

-- Sean Silva


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


Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-05-02 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

In http://reviews.llvm.org/D19678#416127, @rcox2 wrote:

> Actually, the Intel compiler distinguishes between an optimization report 
> (-qopt-report) and an annotated listing (-qopt-report-annotate).  The 
> optimization report lists the info for optimizations in a hierarchical 
> fashion.  To use you example,
>
>   icc -c -O3 -qopt-report=1 -qopt-report-file=stderr v.c 
>
> yields:


Robert, John, (et al.), do you think I should change this to have an 
-foptimization-report-file= and -foptimization-report, instead of 
-foptimization-report=? In the future, when we have multiple kinds of 
reports (a detailed inlining report, for example), maybe we want to use 
-foptimization-report=inlining,somethingelse,andmore?


http://reviews.llvm.org/D19678



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


Re: [PATCH] D19802: Fix a crash in cppcoreguidelines-pro-type-member-init when checking a class that initializes itself as a base

2016-05-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp:342
@@ +341,3 @@
+
+// This pathological template fails to compile if actually instantiated. It
+// results in the check seeing a null RecordDecl when examining the base class

michael_miller wrote:
> Added a comment explaining why the check is there.
Thank you, the comment is excellent.


http://reviews.llvm.org/D19802



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


Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-05-02 Thread Hal Finkel via cfe-commits
hfinkel updated this revision to Diff 55907.
hfinkel added a comment.

Renamed the option from -flisting to -foptimization-report as suggested. Moved 
I/O-related and formatting-related code into Frontend.


http://reviews.llvm.org/D19678

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CompilerInstance.h
  include/clang/Frontend/CompilerInvocation.h
  include/clang/Frontend/FrontendActions.h
  include/clang/Frontend/OptReport.h
  lib/CodeGen/CodeGenAction.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CMakeLists.txt
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/OptReport.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  test/CodeGen/opt-report.c
  test/Driver/opt-report.c

Index: test/Driver/opt-report.c
===
--- /dev/null
+++ test/Driver/opt-report.c
@@ -0,0 +1,9 @@
+// RUN: %clang -### -S -o FOO -foptimization-report %s 2>&1 | FileCheck %s
+// RUN: %clang -### -S -o FOO -foptimization-report=BAR.txt %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ
+
+// CHECK: "-cc1"
+// CHECK: "-opt-report-file" "opt-report.lst"
+
+// CHECK-EQ: "-cc1"
+// CHECK-EQ: "-opt-report-file" "BAR.txt"
+
Index: test/CodeGen/opt-report.c
===
--- /dev/null
+++ test/CodeGen/opt-report.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -O3 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 %s -o %t -dwarf-column-info -opt-report-file %t.lst -emit-obj
+// RUN: cat %t.lst | FileCheck %s
+// REQUIRES: x86-registered-target
+
+void bar();
+void foo() { bar(); }
+
+void Test(int *res, int *c, int *d, int *p, int n) {
+  int i;
+
+#pragma clang loop vectorize(assume_safety)
+  for (i = 0; i < 1600; i++) {
+res[i] = (p[i] == 0) ? res[i] : res[i] + d[i];
+  }
+
+// CHECK: {{[0-9]+}} | #pragma clang loop vectorize(assume_safety)
+// CHECK: {{[0-9]+}}   V |   for (i = 0; i < 1600; i++) {
+
+  for (i = 0; i < 16; i++) {
+res[i] = (p[i] == 0) ? res[i] : res[i] + d[i];
+  }
+
+  foo();
+// CHECK: {{[0-9]+}} I   |   foo();
+
+  foo(); bar(); foo();
+// CHECK: {{[0-9]+}} |   foo(); bar(); foo();
+// CHECK-NEXT:   I   |   ^
+// CHECK-NEXT:   I   | ^
+}
+
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -165,6 +165,10 @@
 Act = llvm::make_unique(std::move(Act),
 FEOpts.ASTMergeFiles);
 
+  // If an optimization report is requested, generate this after compilation.
+  if (!CI.getOptReportInfo().FileName.empty())
+Act = llvm::make_unique(std::move(Act));
+
   return Act;
 }
 
Index: lib/Frontend/OptReport.cpp
===
--- /dev/null
+++ lib/Frontend/OptReport.cpp
@@ -0,0 +1,123 @@
+//=== OptReport.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Frontend/OptReport.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Format.h"
+
+using namespace clang;
+
+void OptReportAction::EndSourceFileAction() {
+  GenerateReportFile();
+  WrapperFrontendAction::EndSourceFileAction();
+}
+
+void OptReportAction::GenerateReportFile() {
+  CompilerInstance &CI = getCompilerInstance();
+  DiagnosticsEngine &Diags = CI.getDiagnostics();
+  OptReportInfo &OptReport = CI.getOptReportInfo();
+  if (OptReport.FileName.empty())
+return;
+
+  std::error_code EC;
+  llvm::raw_fd_ostream OS(OptReport.FileName, EC,
+  llvm::sys::fs::F_Text);
+  if (EC) {
+Diags.Report(diag::err_fe_error_opening) << OptReport.FileName <<
+EC.message();
+return;
+  }
+
+  SourceManager &SourceMgr = CI.getSourceManager();
+  std::set FileIDs;
+  for (auto &I : OptReport.LocationInfo)
+FileIDs.insert(SourceMgr.getFileID(I.first));
+
+  for (auto &FID : FileIDs) {
+SourceLocation FirstLoc = SourceMgr.getLocForStartOfFile(FID);
+OS << "< " << SourceMgr.getFilename(FirstLoc) << "\n";
+
+auto I = OptReport.LocationInfo.lower_bound(FirstLoc);
+StringRef MB = SourceMgr.getBufferData(FID);
+const SrcMgr::ContentCache *
+  Content = SourceMgr.getSLocEntry(FID).getFile().getContentCache();
+unsigned LNDigits = llvm::utostr(Content->NumLines).size();
+for (unsigned L = 0; L < Content->NumLines - 1; ++L) {
+  unsigned LStartOff = Content->SourceLineCache[L];
+  unsigned LEndOff = (L == Content->NumLine

r268322 - [CMake] Enable LIBCXX HEADERS in Apple-Stage2.cmake

2016-05-02 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Mon May  2 17:43:23 2016
New Revision: 268322

URL: http://llvm.org/viewvc/llvm-project?rev=268322&view=rev
Log:
[CMake] Enable LIBCXX HEADERS in Apple-Stage2.cmake

This enables installing the libcxx headers.

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=268322&r1=268321&r2=268322&view=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Mon May  2 17:43:23 2016
@@ -34,7 +34,7 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 
 set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
-set(LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
+set(LIBCXX_INSTALL_HEADERS ON CACHE BOOL "")
 set(LIBCXX_INCLUDE_TESTS OFF CACHE BOOL "")
 set(LLVM_LTO_VERSION_OFFSET 3000 CACHE STRING "")
 


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


r268320 - [CMake] Install libcxx-headers as part of the Apple-stage2 distribution

2016-05-02 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Mon May  2 17:42:09 2016
New Revision: 268320

URL: http://llvm.org/viewvc/llvm-project?rev=268320&view=rev
Log:
[CMake] Install libcxx-headers as part of the Apple-stage2 distribution

This installs the clang headers as part of the install-distribution target.

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=268320&r1=268319&r2=268320&view=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Mon May  2 17:42:09 2016
@@ -55,6 +55,7 @@ set(LLVM_DISTRIBUTION_COMPONENTS
   LTO
   clang-format
   clang-headers
+  libcxx-headers
   ${LLVM_TOOLCHAIN_TOOLS}
   CACHE STRING "")
 


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


r268321 - Fix argument expansion of reference fields of structs

2016-05-02 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon May  2 17:42:34 2016
New Revision: 268321

URL: http://llvm.org/viewvc/llvm-project?rev=268321&view=rev
Log:
Fix argument expansion of reference fields of structs

r268261 made Clang "expand" more struct arguments on Windows. It removed
the check for 'RD->isCLike()', which was preventing us from attempting
to expand structs with reference type fields.

Our expansion code was attempting to load and pass each field of the
type in turn. We were accidentally doing one to many loads on reference
type fields.

On the function prologue side, we can use
EmitLValueForFieldInitialization, which obviously gets the address of
the field. On the call side, I tweaked EmitRValueForField directly,
since this is the only use of this method.

Fixes PR27607

Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=268321&r1=268320&r2=268321&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon May  2 17:42:34 2016
@@ -948,7 +948,7 @@ void CodeGenFunction::ExpandTypeFromArgs
 }
 for (auto FD : RExp->Fields) {
   // FIXME: What are the right qualifiers here?
-  LValue SubLV = EmitLValueForField(LV, FD);
+  LValue SubLV = EmitLValueForFieldInitialization(LV, FD);
   ExpandTypeFromArgs(FD->getType(), SubLV, AI);
 }
   } else if (isa(Exp.get())) {

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=268321&r1=268320&r2=268321&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon May  2 17:42:34 2016
@@ -3667,6 +3667,10 @@ RValue CodeGenFunction::EmitRValueForFie
   case TEK_Aggregate:
 return FieldLV.asAggregateRValue();
   case TEK_Scalar:
+// This routine is used to load fields one-by-one to perform a copy, so
+// don't load reference fields.
+if (FD->getType()->isReferenceType())
+  return RValue::get(FieldLV.getPointer());
 return EmitLoadOfLValue(FieldLV, Loc);
   }
   llvm_unreachable("bad evaluation kind");

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp?rev=268321&r1=268320&r2=268321&view=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp Mon May  2 
17:42:34 2016
@@ -217,6 +217,28 @@ void big_arg(Big s) {}
 // WIN32: define void @"\01?big_arg@@YAXUBig@@@Z"(%struct.Big* byval align 4 
%s)
 // WIN64: define void @"\01?big_arg@@YAXUBig@@@Z"(%struct.Big* %s)
 
+// PR27607: We would attempt to load i32 value out of the reference instead of
+// just loading the pointer from the struct during argument expansion.
+struct RefField {
+  RefField(int &x);
+  int &x;
+};
+void takes_ref_field(RefField s) {}
+// LINUX-LABEL: define void @_Z15takes_ref_field8RefField(%struct.RefField* 
byval align 4 %s)
+// WIN32: define void @"\01?takes_ref_field@@YAXURefField@@@Z"(i32* %s.0)
+// WIN64: define void @"\01?takes_ref_field@@YAXURefField@@@Z"(i64 %s.coerce)
+
+void pass_ref_field() {
+  int x;
+  takes_ref_field(RefField(x));
+}
+// LINUX-LABEL: define void @_Z14pass_ref_fieldv()
+// LINUX: call void @_Z15takes_ref_field8RefField(%struct.RefField* byval 
align 4 %{{.*}})
+// WIN32-LABEL: define void @"\01?pass_ref_field@@YAXXZ"()
+// WIN32: call void @"\01?takes_ref_field@@YAXURefField@@@Z"(i32* %{{.*}})
+// WIN64-LABEL: define void @"\01?pass_ref_field@@YAXXZ"()
+// WIN64: call void @"\01?takes_ref_field@@YAXURefField@@@Z"(i64 %{{.*}})
+
 class Class {
  public:
   Small thiscall_method_small() { return Small(); }


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


r268319 - [CMake] Adding clang-headers to the Apple-stage2 distribution

2016-05-02 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Mon May  2 17:38:06 2016
New Revision: 268319

URL: http://llvm.org/viewvc/llvm-project?rev=268319&view=rev
Log:
[CMake] Adding clang-headers to the Apple-stage2 distribution

This installs the clang headers as part of the install-distribution target.

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=268319&r1=268318&r2=268319&view=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Mon May  2 17:38:06 2016
@@ -54,6 +54,7 @@ set(LLVM_DISTRIBUTION_COMPONENTS
   clang
   LTO
   clang-format
+  clang-headers
   ${LLVM_TOOLCHAIN_TOOLS}
   CACHE STRING "")
 


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


Re: r268314 - [CodeGenObjCXX] Don't rematerialize default arguments of function

2016-05-02 Thread Akira Hatanaka via cfe-commits
Thanks, fixed in r268318.

> On May 2, 2016, at 3:05 PM, Richard Smith  wrote:
> 
> On Mon, May 2, 2016 at 2:52 PM, Akira Hatanaka via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: ahatanak
> Date: Mon May  2 16:52:57 2016
> New Revision: 268314
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=268314&view=rev 
> 
> Log:
> [CodeGenObjCXX] Don't rematerialize default arguments of function
> parameters in the body of a block.
> 
> This fixes a bug where clang would materialize the default argument
> inside the body of a block instead of passing the value via the block
> descriptor.
> 
> For example, in the code below, foo1 would always print 42 regardless
> of the value of argument "a" passed to foo1.
> 
> void foo1(const int a = 42 ) {
>   auto block = ^{
> printf("%d\n", a);
>   };
>   block();
> }
> 
> rdar://problem/24449235
> 
> Added:
> cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm 
> 
> Modified:
> cfe/trunk/lib/CodeGen/CGBlocks.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=268314&r1=268313&r2=268314&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Mon May  2 16:52:57 2016
> @@ -262,6 +262,11 @@ static bool isSafeForCXXConstantCapture(
>  static llvm::Constant *tryCaptureAsConstant(CodeGenModule &CGM,
>  CodeGenFunction *CGF,
>  const VarDecl *var) {
> +  // Don't rematerialize default arguments of function parameters.
> +  if (auto *PD = dyn_cast(var))
> +if (PD->hasDefaultArg())
> 
> I don't think you need this test, and I think it somewhat confuses the intent 
> here. (A reader would wonder why you want to keep going for ParmVarDecls that 
> don't have default arguments.)
>  
> +  return nullptr;
> +
>QualType type = var->getType();
> 
>// We can only do this if the variable is const.
> 
> Added: cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm 
> 
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm?rev=268314&view=auto
>  
> 
> ==
> --- cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm 
>  (added)
> +++ cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm 
>  Mon May  2 16:52:57 2016
> @@ -0,0 +1,16 @@
> +// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s 
> -std=c++11 -fblocks -fobjc-arc | FileCheck  %s
> +
> +// CHECK: define internal void @___Z16test_default_argi_block_invoke(i8* 
> %[[BLOCK_DESCRIPTOR:.*]])
> +// CHECK: %[[BLOCK:.*]] = bitcast i8* %[[BLOCK_DESCRIPTOR]] to <{ i8*, i32, 
> i32, i8*, %struct.__block_descriptor*, i32 }>*
> +// CHECK: %[[BLOCK_CAPTURE_ADDR:.*]] = getelementptr inbounds <{ i8*, i32, 
> i32, i8*, %struct.__block_descriptor*, i32 }>, <{ i8*, i32, i32, i8*, 
> %struct.__block_descriptor*, i32 }>* %[[BLOCK]], i32 0, i32 5
> +// CHECK: %[[V0:.*]] = load i32, i32* %[[BLOCK_CAPTURE_ADDR]]
> +// CHECK: call void @_Z4foo1i(i32 %[[V0]])
> +
> +void foo1(int);
> +
> +void test_default_arg(const int a = 42) {
> +  auto block = ^{
> +foo1(a);
> +  };
> +  block();
> +}
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19835: Tolerate incorrect return type for 'isinf' and 'isnan' in tests.

2016-05-02 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.



> Alternatively `static_assert(std::is_same bool>::value);` :-P

> 

> Testing the return type isn't the problem. The problem is telling LIT *when* 
> we expect the test to fail using the `XFAIL` directive.


O. I see.


http://reviews.llvm.org/D19835



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


Re: [PATCH] D19802: Fix a crash in cppcoreguidelines-pro-type-member-init when checking a class that initializes itself as a base

2016-05-02 Thread Michael Miller via cfe-commits
michael_miller updated this revision to Diff 55904.
michael_miller added a comment.

Added a comment explaining the new test added.


http://reviews.llvm.org/D19802

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -338,3 +338,14 @@
 
   Template F;
 };
+
+// This pathological template fails to compile if actually instantiated. It
+// results in the check seeing a null RecordDecl when examining the base class
+// initializer list.
+template 
+class PositiveSelfInitialization : NegativeAggregateType
+{
+  PositiveSelfInitialization() : PositiveSelfInitialization() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these bases: NegativeAggregateType
+  // CHECK-FIXES: PositiveSelfInitialization() : NegativeAggregateType(), 
PositiveSelfInitialization() {}
+};
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -179,7 +179,7 @@
   const auto *InitDecl =
   Init->isMemberInitializer()
   ? static_cast(Init->getMember())
-  : Init->getBaseClass()->getAs()->getDecl();
+  : Init->getBaseClass()->getAsCXXRecordDecl();
 
   // Add all fields between current field up until the next intializer.
   for (; Decl != std::end(OrderedDecls) && *Decl != InitDecl; ++Decl) {
@@ -398,7 +398,7 @@
   // Remove any bases that were explicitly written in the initializer list.
   for (const CXXCtorInitializer *Init : Ctor->inits()) {
 if (Init->isBaseInitializer() && Init->isWritten())
-  BasesToInit.erase(Init->getBaseClass()->getAs()->getDecl());
+  BasesToInit.erase(Init->getBaseClass()->getAsCXXRecordDecl());
   }
 
   if (BasesToInit.empty())


Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -338,3 +338,14 @@
 
   Template F;
 };
+
+// This pathological template fails to compile if actually instantiated. It
+// results in the check seeing a null RecordDecl when examining the base class
+// initializer list.
+template 
+class PositiveSelfInitialization : NegativeAggregateType
+{
+  PositiveSelfInitialization() : PositiveSelfInitialization() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these bases: NegativeAggregateType
+  // CHECK-FIXES: PositiveSelfInitialization() : NegativeAggregateType(), PositiveSelfInitialization() {}
+};
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -179,7 +179,7 @@
   const auto *InitDecl =
   Init->isMemberInitializer()
   ? static_cast(Init->getMember())
-  : Init->getBaseClass()->getAs()->getDecl();
+  : Init->getBaseClass()->getAsCXXRecordDecl();
 
   // Add all fields between current field up until the next intializer.
   for (; Decl != std::end(OrderedDecls) && *Decl != InitDecl; ++Decl) {
@@ -398,7 +398,7 @@
   // Remove any bases that were explicitly written in the initializer list.
   for (const CXXCtorInitializer *Init : Ctor->inits()) {
 if (Init->isBaseInitializer() && Init->isWritten())
-  BasesToInit.erase(Init->getBaseClass()->getAs()->getDecl());
+  BasesToInit.erase(Init->getBaseClass()->getAsCXXRecordDecl());
   }
 
   if (BasesToInit.empty())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19802: Fix a crash in cppcoreguidelines-pro-type-member-init when checking a class that initializes itself as a base

2016-05-02 Thread Michael Miller via cfe-commits
michael_miller marked 4 inline comments as done.


Comment at: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp:342
@@ +341,3 @@
+
+// This pathological template fails to compile if actually instantiated. It
+// results in the check seeing a null RecordDecl when examining the base class

Added a comment explaining why the check is there.


http://reviews.llvm.org/D19802



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


Re: [PATCH] D19536: [CodeGenObjCXX] Fix handling of blocks in lambda

2016-05-02 Thread Akira Hatanaka via cfe-commits
ahatanak added inline comments.


Comment at: lib/CodeGen/CGBlocks.cpp:806
@@ -792,1 +805,3 @@
+  }
+  src = Builder.CreateStructGEP(Addr, Idx, Offset, FD->getName());
 } else {

rjmccall wrote:
> Hmm.  It's become increasingly clear that my original decision to expand the 
> decl-ref logic here was a mistake.  Please just turn this entire block of 
> conditions into:
> 
>   if (blockDecl->isConversionFromLambda()) {
> // The lambda capture in a lambda's conversion-to-block-pointer is
> // special; we'll simply emit it directly.
> src = Address::invalid();
>   } else {
> DeclRefExpr declRef(
> const_cast(variable),
> /*RefersToEnclosingVariableOrCapture*/ CI.isNested(), type,
> VK_LValue, SourceLocation());
> src = EmitDeclRefLValue(&declRef).getAddress();
>   }
Seems like a lot of regression tests fail if I try the code above. Currently 
investigating.


http://reviews.llvm.org/D19536



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


r268318 - Remove unneeded test in tryCaptureAsConstant.

2016-05-02 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon May  2 17:29:40 2016
New Revision: 268318

URL: http://llvm.org/viewvc/llvm-project?rev=268318&view=rev
Log:
Remove unneeded test in tryCaptureAsConstant.

It isn't necessary to call hasDefaultArg because we can't rematerialize
a captured variable that is a function parameter, regardless of whether
or not it has a default argument. NFC.

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=268318&r1=268317&r2=268318&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Mon May  2 17:29:40 2016
@@ -262,10 +262,10 @@ static bool isSafeForCXXConstantCapture(
 static llvm::Constant *tryCaptureAsConstant(CodeGenModule &CGM,
 CodeGenFunction *CGF,
 const VarDecl *var) {
-  // Don't rematerialize default arguments of function parameters.
-  if (auto *PD = dyn_cast(var))
-if (PD->hasDefaultArg())
-  return nullptr;
+  // Return if this is a function paramter. We shouldn't try to
+  // rematerialize default arguments of function parameters.
+  if (isa(var))
+return nullptr;
 
   QualType type = var->getType();
 


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


Re: [PATCH] D19802: Fix a crash in cppcoreguidelines-pro-type-member-init when checking a class that initializes itself as a base

2016-05-02 Thread Michael Miller via cfe-commits
michael_miller added inline comments.


Comment at: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp:342
@@ +341,3 @@
+
+template 
+class PositiveSelfInitialization : NegativeAggregateType

aaron.ballman wrote:
> hokein wrote:
> > aaron.ballman wrote:
> > > Is it required to be a templated class to trigger the crash?
> > Yes, it's required.
> Then some comments in this test would be good, I would assume otherwise from 
> just looking at the test.
It's a little bit of a pathological example. Without the template, the code 
won't compile at all due to an error. The check doesn't crash in that case 
(error: constructor for 'PositiveSelfInitialization' creates a delegation cycle 
[clang-diagnostic-delegating-ctor-cycles]). With the template in the mix, 
apparently PositiveSelfInitialization doesn't have a valid RecordDecl. If you 
instantiate the template, though, the code again fails to compile.


http://reviews.llvm.org/D19802



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


Re: r268314 - [CodeGenObjCXX] Don't rematerialize default arguments of function

2016-05-02 Thread Akira Hatanaka via cfe-commits
It looks like turning it to an assert wouldn’t be correct, I’ll probably just 
remove it.

> On May 2, 2016, at 3:12 PM, Akira Hatanaka via cfe-commits 
>  wrote:
> 
> I see. Perhaps this should be an assert?
> 
>> On May 2, 2016, at 3:05 PM, Richard Smith > > wrote:
>> 
>> On Mon, May 2, 2016 at 2:52 PM, Akira Hatanaka via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> Author: ahatanak
>> Date: Mon May  2 16:52:57 2016
>> New Revision: 268314
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=268314&view=rev 
>> 
>> Log:
>> [CodeGenObjCXX] Don't rematerialize default arguments of function
>> parameters in the body of a block.
>> 
>> This fixes a bug where clang would materialize the default argument
>> inside the body of a block instead of passing the value via the block
>> descriptor.
>> 
>> For example, in the code below, foo1 would always print 42 regardless
>> of the value of argument "a" passed to foo1.
>> 
>> void foo1(const int a = 42 ) {
>>   auto block = ^{
>> printf("%d\n", a);
>>   };
>>   block();
>> }
>> 
>> rdar://problem/24449235 
>> 
>> Added:
>> cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm 
>> 
>> Modified:
>> cfe/trunk/lib/CodeGen/CGBlocks.cpp
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=268314&r1=268313&r2=268314&view=diff
>>  
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Mon May  2 16:52:57 2016
>> @@ -262,6 +262,11 @@ static bool isSafeForCXXConstantCapture(
>>  static llvm::Constant *tryCaptureAsConstant(CodeGenModule &CGM,
>>  CodeGenFunction *CGF,
>>  const VarDecl *var) {
>> +  // Don't rematerialize default arguments of function parameters.
>> +  if (auto *PD = dyn_cast(var))
>> +if (PD->hasDefaultArg())
>> 
>> I don't think you need this test, and I think it somewhat confuses the 
>> intent here. (A reader would wonder why you want to keep going for 
>> ParmVarDecls that don't have default arguments.)
>>  
>> +  return nullptr;
>> +
>>QualType type = var->getType();
>> 
>>// We can only do this if the variable is const.
>> 
>> Added: cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm 
>> 
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm?rev=268314&view=auto
>>  
>> 
>> ==
>> --- cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm 
>>  (added)
>> +++ cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm 
>>  Mon May  2 16:52:57 2016
>> @@ -0,0 +1,16 @@
>> +// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s 
>> -std=c++11 -fblocks -fobjc-arc | FileCheck  %s
>> +
>> +// CHECK: define internal void @___Z16test_default_argi_block_invoke(i8* 
>> %[[BLOCK_DESCRIPTOR:.*]])
>> +// CHECK: %[[BLOCK:.*]] = bitcast i8* %[[BLOCK_DESCRIPTOR]] to <{ i8*, i32, 
>> i32, i8*, %struct.__block_descriptor*, i32 }>*
>> +// CHECK: %[[BLOCK_CAPTURE_ADDR:.*]] = getelementptr inbounds <{ i8*, i32, 
>> i32, i8*, %struct.__block_descriptor*, i32 }>, <{ i8*, i32, i32, i8*, 
>> %struct.__block_descriptor*, i32 }>* %[[BLOCK]], i32 0, i32 5
>> +// CHECK: %[[V0:.*]] = load i32, i32* %[[BLOCK_CAPTURE_ADDR]]
>> +// CHECK: call void @_Z4foo1i(i32 %[[V0]])
>> +
>> +void foo1(int);
>> +
>> +void test_default_arg(const int a = 42) {
>> +  auto block = ^{
>> +foo1(a);
>> +  };
>> +  block();
>> +}
>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org 
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
>> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


Re: r268314 - [CodeGenObjCXX] Don't rematerialize default arguments of function

2016-05-02 Thread Akira Hatanaka via cfe-commits
I see. Perhaps this should be an assert?

> On May 2, 2016, at 3:05 PM, Richard Smith  wrote:
> 
> On Mon, May 2, 2016 at 2:52 PM, Akira Hatanaka via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: ahatanak
> Date: Mon May  2 16:52:57 2016
> New Revision: 268314
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=268314&view=rev 
> 
> Log:
> [CodeGenObjCXX] Don't rematerialize default arguments of function
> parameters in the body of a block.
> 
> This fixes a bug where clang would materialize the default argument
> inside the body of a block instead of passing the value via the block
> descriptor.
> 
> For example, in the code below, foo1 would always print 42 regardless
> of the value of argument "a" passed to foo1.
> 
> void foo1(const int a = 42 ) {
>   auto block = ^{
> printf("%d\n", a);
>   };
>   block();
> }
> 
> rdar://problem/24449235
> 
> Added:
> cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm 
> 
> Modified:
> cfe/trunk/lib/CodeGen/CGBlocks.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=268314&r1=268313&r2=268314&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Mon May  2 16:52:57 2016
> @@ -262,6 +262,11 @@ static bool isSafeForCXXConstantCapture(
>  static llvm::Constant *tryCaptureAsConstant(CodeGenModule &CGM,
>  CodeGenFunction *CGF,
>  const VarDecl *var) {
> +  // Don't rematerialize default arguments of function parameters.
> +  if (auto *PD = dyn_cast(var))
> +if (PD->hasDefaultArg())
> 
> I don't think you need this test, and I think it somewhat confuses the intent 
> here. (A reader would wonder why you want to keep going for ParmVarDecls that 
> don't have default arguments.)
>  
> +  return nullptr;
> +
>QualType type = var->getType();
> 
>// We can only do this if the variable is const.
> 
> Added: cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm 
> 
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm?rev=268314&view=auto
>  
> 
> ==
> --- cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm 
>  (added)
> +++ cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm 
>  Mon May  2 16:52:57 2016
> @@ -0,0 +1,16 @@
> +// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s 
> -std=c++11 -fblocks -fobjc-arc | FileCheck  %s
> +
> +// CHECK: define internal void @___Z16test_default_argi_block_invoke(i8* 
> %[[BLOCK_DESCRIPTOR:.*]])
> +// CHECK: %[[BLOCK:.*]] = bitcast i8* %[[BLOCK_DESCRIPTOR]] to <{ i8*, i32, 
> i32, i8*, %struct.__block_descriptor*, i32 }>*
> +// CHECK: %[[BLOCK_CAPTURE_ADDR:.*]] = getelementptr inbounds <{ i8*, i32, 
> i32, i8*, %struct.__block_descriptor*, i32 }>, <{ i8*, i32, i32, i8*, 
> %struct.__block_descriptor*, i32 }>* %[[BLOCK]], i32 0, i32 5
> +// CHECK: %[[V0:.*]] = load i32, i32* %[[BLOCK_CAPTURE_ADDR]]
> +// CHECK: call void @_Z4foo1i(i32 %[[V0]])
> +
> +void foo1(int);
> +
> +void test_default_arg(const int a = 42) {
> +  auto block = ^{
> +foo1(a);
> +  };
> +  block();
> +}
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r268314 - [CodeGenObjCXX] Don't rematerialize default arguments of function

2016-05-02 Thread Richard Smith via cfe-commits
On Mon, May 2, 2016 at 2:52 PM, Akira Hatanaka via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ahatanak
> Date: Mon May  2 16:52:57 2016
> New Revision: 268314
>
> URL: http://llvm.org/viewvc/llvm-project?rev=268314&view=rev
> Log:
> [CodeGenObjCXX] Don't rematerialize default arguments of function
> parameters in the body of a block.
>
> This fixes a bug where clang would materialize the default argument
> inside the body of a block instead of passing the value via the block
> descriptor.
>
> For example, in the code below, foo1 would always print 42 regardless
> of the value of argument "a" passed to foo1.
>
> void foo1(const int a = 42 ) {
>   auto block = ^{
> printf("%d\n", a);
>   };
>   block();
> }
>
> rdar://problem/24449235
>
> Added:
> cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm
> Modified:
> cfe/trunk/lib/CodeGen/CGBlocks.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=268314&r1=268313&r2=268314&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Mon May  2 16:52:57 2016
> @@ -262,6 +262,11 @@ static bool isSafeForCXXConstantCapture(
>  static llvm::Constant *tryCaptureAsConstant(CodeGenModule &CGM,
>  CodeGenFunction *CGF,
>  const VarDecl *var) {
> +  // Don't rematerialize default arguments of function parameters.
> +  if (auto *PD = dyn_cast(var))
> +if (PD->hasDefaultArg())
>

I don't think you need this test, and I think it somewhat confuses the
intent here. (A reader would wonder why you want to keep going for
ParmVarDecls that don't have default arguments.)


> +  return nullptr;
> +
>QualType type = var->getType();
>
>// We can only do this if the variable is const.
>
> Added: cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm?rev=268314&view=auto
>
> ==
> --- cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm (added)
> +++ cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm Mon May  2 16:52:57
> 2016
> @@ -0,0 +1,16 @@
> +// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s
> -std=c++11 -fblocks -fobjc-arc | FileCheck  %s
> +
> +// CHECK: define internal void @___Z16test_default_argi_block_invoke(i8*
> %[[BLOCK_DESCRIPTOR:.*]])
> +// CHECK: %[[BLOCK:.*]] = bitcast i8* %[[BLOCK_DESCRIPTOR]] to <{ i8*,
> i32, i32, i8*, %struct.__block_descriptor*, i32 }>*
> +// CHECK: %[[BLOCK_CAPTURE_ADDR:.*]] = getelementptr inbounds <{ i8*,
> i32, i32, i8*, %struct.__block_descriptor*, i32 }>, <{ i8*, i32, i32, i8*,
> %struct.__block_descriptor*, i32 }>* %[[BLOCK]], i32 0, i32 5
> +// CHECK: %[[V0:.*]] = load i32, i32* %[[BLOCK_CAPTURE_ADDR]]
> +// CHECK: call void @_Z4foo1i(i32 %[[V0]])
> +
> +void foo1(int);
> +
> +void test_default_arg(const int a = 42) {
> +  auto block = ^{
> +foo1(a);
> +  };
> +  block();
> +}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19831: [scan-build] fix dead store warnings emitted on clang code base

2016-05-02 Thread Apelete Seketeli via cfe-commits
apelete added a comment.

In http://reviews.llvm.org/D19831#419140, @dblaikie wrote:

> Any reason not to remove the story instead?


What do you mean by "remove the story" ?


http://reviews.llvm.org/D19831



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


r268314 - [CodeGenObjCXX] Don't rematerialize default arguments of function

2016-05-02 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon May  2 16:52:57 2016
New Revision: 268314

URL: http://llvm.org/viewvc/llvm-project?rev=268314&view=rev
Log:
[CodeGenObjCXX] Don't rematerialize default arguments of function
parameters in the body of a block.

This fixes a bug where clang would materialize the default argument
inside the body of a block instead of passing the value via the block
descriptor.

For example, in the code below, foo1 would always print 42 regardless
of the value of argument "a" passed to foo1.

void foo1(const int a = 42 ) {
  auto block = ^{
printf("%d\n", a);
  };
  block();
}

rdar://problem/24449235

Added:
cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=268314&r1=268313&r2=268314&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Mon May  2 16:52:57 2016
@@ -262,6 +262,11 @@ static bool isSafeForCXXConstantCapture(
 static llvm::Constant *tryCaptureAsConstant(CodeGenModule &CGM,
 CodeGenFunction *CGF,
 const VarDecl *var) {
+  // Don't rematerialize default arguments of function parameters.
+  if (auto *PD = dyn_cast(var))
+if (PD->hasDefaultArg())
+  return nullptr;
+
   QualType type = var->getType();
 
   // We can only do this if the variable is const.

Added: cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm?rev=268314&view=auto
==
--- cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/block-default-arg.mm Mon May  2 16:52:57 2016
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s 
-std=c++11 -fblocks -fobjc-arc | FileCheck  %s
+
+// CHECK: define internal void @___Z16test_default_argi_block_invoke(i8* 
%[[BLOCK_DESCRIPTOR:.*]])
+// CHECK: %[[BLOCK:.*]] = bitcast i8* %[[BLOCK_DESCRIPTOR]] to <{ i8*, i32, 
i32, i8*, %struct.__block_descriptor*, i32 }>*
+// CHECK: %[[BLOCK_CAPTURE_ADDR:.*]] = getelementptr inbounds <{ i8*, i32, 
i32, i8*, %struct.__block_descriptor*, i32 }>, <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i32 }>* %[[BLOCK]], i32 0, i32 5
+// CHECK: %[[V0:.*]] = load i32, i32* %[[BLOCK_CAPTURE_ADDR]]
+// CHECK: call void @_Z4foo1i(i32 %[[V0]])
+
+void foo1(int);
+
+void test_default_arg(const int a = 42) {
+  auto block = ^{
+foo1(a);
+  };
+  block();
+}


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


Re: [PATCH] D19835: Tolerate incorrect return type for 'isinf' and 'isnan' in tests.

2016-05-02 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D19835#419211, @jroelofs wrote:

> I think you could lean on the linker to cause the test to fail when the type 
> is wrong:
>
>   bool isinf(double);
>  
>   typedef int (*expected_signature)(double);
>  
>   void assert_via_linker(decltype(isinf) blah);
>   void assert_via_linker(expected_signature blah) {}
>  
>   void foo() {
> assert_via_linker(isinf);
>   }
>  
>


Alternatively `static_assert(std::is_same::value);` :-P

Testing the return type isn't the problem. The problem is telling LIT *when* we 
expect the test to fail using the `XFAIL` directive.

The test will pass for:

- non-linux systems
- GLIBC >= 2.26 and C++ >= 11.

The test will fail for:

- GLIBC < 2.26
- GLIBC >= 2.26 and C++ < 11.

Trying to encode that within 'XFAIL' is currently not possible and


http://reviews.llvm.org/D19835



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


Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-02 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

Check is still not mentioned in docs/ReleaseNotes.rst.


Repository:
  rL LLVM

http://reviews.llvm.org/D18919



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


Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-02 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

lgtm, but I'd rather see Hokein acceptance.


Repository:
  rL LLVM

http://reviews.llvm.org/D18919



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


Re: [PATCH] D19835: Tolerate incorrect return type for 'isinf' and 'isnan' in tests.

2016-05-02 Thread Jonathan Roelofs via cfe-commits
jroelofs added a subscriber: jroelofs.
jroelofs added a comment.

I think you could lean on the linker to cause the test to fail when the type is 
wrong:

  bool isinf(double);
  
  typedef int (*expected_signature)(double);
  
  void assert_via_linker(decltype(isinf) blah);
  void assert_via_linker(expected_signature blah) {}
  
  void foo() {
assert_via_linker(isinf);
  }


http://reviews.llvm.org/D19835



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


[PATCH] D19835: Tolerate incorrect return type for 'isinf' and 'isnan' it tests.

2016-05-02 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: rsmith, mclow.lists.
EricWF added a subscriber: cfe-commits.

GLIBC recently removed the incorrect `int isinf(double)` and `int 
isnan(double)` overloads in C++11 and greater. This causes previously `XFAIL: 
linux`  tests to start passing.

Since there is no longer a way to 'XFAIL' the tests I choose to simply tolerate 
this bug.

See https://sourceware.org/bugzilla/show_bug.cgi?id=19439


http://reviews.llvm.org/D19835

Files:
  test/std/depr/depr.c.headers/math_h.pass.cpp
  test/std/depr/depr.c.headers/math_h_isinf.pass.cpp
  test/std/depr/depr.c.headers/math_h_isnan.pass.cpp
  test/std/numerics/c.math/cmath.pass.cpp
  test/std/numerics/c.math/cmath_isinf.pass.cpp
  test/std/numerics/c.math/cmath_isnan.pass.cpp

Index: test/std/numerics/c.math/cmath_isnan.pass.cpp
===
--- test/std/numerics/c.math/cmath_isnan.pass.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-//===--===//
-//
-// 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.
-//
-//===--===//
-
-// 
-
-// isnan
-
-// XFAIL: linux
-
-#include 
-#include 
-#include 
-
-int main()
-{
-#ifdef isnan
-#error isnan defined
-#endif
-static_assert((std::is_same::value), "");
-static_assert((std::is_same::value), "");
-static_assert((std::is_same::value), "");
-static_assert((std::is_same::value), "");
-assert(std::isnan(-1.0) == false);
-}
Index: test/std/numerics/c.math/cmath_isinf.pass.cpp
===
--- test/std/numerics/c.math/cmath_isinf.pass.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-//===--===//
-//
-// 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.
-//
-//===--===//
-
-// 
-
-// isinf
-
-// XFAIL: linux
-
-#include 
-#include 
-#include 
-
-int main()
-{
-#ifdef isinf
-#error isinf defined
-#endif
-static_assert((std::is_same::value), "");
-static_assert((std::is_same::value), "");
-static_assert((std::is_same::value), "");
-static_assert((std::is_same::value), "");
-assert(std::isinf(-1.0) == false);
-}
\ No newline at end of file
Index: test/std/numerics/c.math/cmath.pass.cpp
===
--- test/std/numerics/c.math/cmath.pass.cpp
+++ test/std/numerics/c.math/cmath.pass.cpp
@@ -9,9 +9,6 @@
 
 // 
 
-// NOTE: isinf and isnan are tested separately because they are expected to fail
-// on linux. We don't want their expected failure to hide other failures in this file.
-
 #include 
 #include 
 #include 
@@ -631,6 +628,29 @@
 assert(std::isgreaterequal(-1.0, 0.F) == false);
 }
 
+void test_isinf()
+{
+#ifdef isinf
+#error isinf defined
+#endif
+static_assert((std::is_same::value), "");
+
+typedef decltype(std::isinf((double)0)) DoubleRetType;
+#ifndef __linux__
+static_assert((std::is_same::value), "");
+#else
+// GLIBC < 2.26 defines 'isinf(double)' with a return type of 'int' in
+// all C++ dialects. The test should tolerate this.
+// See: https://sourceware.org/bugzilla/show_bug.cgi?id=19439
+static_assert((std::is_same::value
+|| std::is_same::value), "");
+#endif
+
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+assert(std::isinf(-1.0) == false);
+}
+
 void test_isless()
 {
 #ifdef isless
@@ -688,6 +708,29 @@
 assert(std::islessgreater(-1.0, 0.F) == true);
 }
 
+void test_isnan()
+{
+#ifdef isnan
+#error isnan defined
+#endif
+static_assert((std::is_same::value), "");
+
+typedef decltype(std::isnan((double)0)) DoubleRetType;
+#ifndef __linux__
+static_assert((std::is_same::value), "");
+#else
+// GLIBC < 2.26 defines 'isnan(double)' with a return type of 'int' in
+// all C++ dialects. The test should tolerate this.
+// See: https://sourceware.org/bugzilla/show_bug.cgi?id=19439
+static_assert((std::is_same::value
+|| std::is_same::value), "");
+#endif
+
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+assert(std::isnan(-1.0) == false);
+}
+
 void test_isunordered()
 {
 #ifdef isunordered
@@ -1443,9 +1486,11 @@
 test_isnormal();
 test_isgreater();
 test_isgreaterequal();
+test_isinf();
 test_isless();
 test_islessequal();
 test_islessgreater();
+test_isnan();
 test_isunordered();
 test_acosh();
 test_asinh();
Index: test/std/d

Re: [PATCH] D19831: [scan-build] fix dead store warnings emitted on clang code base

2016-05-02 Thread David Blaikie via cfe-commits
Any reason not to remove the story instead?

On Mon, May 2, 2016 at 1:36 PM, Apelete Seketeli via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> apelete created this revision.
> apelete added a reviewer: akyrtzi.
> apelete added a subscriber: cfe-commits.
>
> This fixes dead store warnings of the type "dead assignment" reported
> by CLang Static Analyzer on the following file:
>
> - tools/c-index-test/c-index-test.c.
>
> Signed-off-by: Apelete Seketeli 
>
> http://reviews.llvm.org/D19831
>
> Files:
>   tools/c-index-test/c-index-test.c
>
> Index: tools/c-index-test/c-index-test.c
> ===
> --- tools/c-index-test/c-index-test.c
> +++ tools/c-index-test/c-index-test.c
> @@ -1436,6 +1436,7 @@
>  unsigned RecordIsAnonymous = 0;
>  if (clang_getCursorKind(cursor) == CXCursor_FieldDecl) {
>Record = Parent = p;
> +  (void) Record;
>do {
>  Record = Parent;
>  Parent = clang_getCursorSemanticParent(Record);
>
>
>
> ___
> 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] D19831: [scan-build] fix dead store warnings emitted on clang code base

2016-05-02 Thread Apelete Seketeli via cfe-commits
apelete created this revision.
apelete added a reviewer: akyrtzi.
apelete added a subscriber: cfe-commits.

This fixes dead store warnings of the type "dead assignment" reported
by CLang Static Analyzer on the following file:

- tools/c-index-test/c-index-test.c.

Signed-off-by: Apelete Seketeli 

http://reviews.llvm.org/D19831

Files:
  tools/c-index-test/c-index-test.c

Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1436,6 +1436,7 @@
 unsigned RecordIsAnonymous = 0;
 if (clang_getCursorKind(cursor) == CXCursor_FieldDecl) {
   Record = Parent = p;
+  (void) Record;
   do {
 Record = Parent;
 Parent = clang_getCursorSemanticParent(Record);


Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1436,6 +1436,7 @@
 unsigned RecordIsAnonymous = 0;
 if (clang_getCursorKind(cursor) == CXCursor_FieldDecl) {
   Record = Parent = p;
+  (void) Record;
   do {
 Record = Parent;
 Parent = clang_getCursorSemanticParent(Record);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19748: [CUDA] Make sure device-side __global__ functions are always visible.

2016-05-02 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268299: [CUDA] Make sure device-side __global__ functions 
are always visible. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D19748?vs=55674&id=55885#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19748

Files:
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/test/CodeGenCUDA/ptx-kernels.cu

Index: cfe/trunk/test/CodeGenCUDA/ptx-kernels.cu
===
--- cfe/trunk/test/CodeGenCUDA/ptx-kernels.cu
+++ cfe/trunk/test/CodeGenCUDA/ptx-kernels.cu
@@ -19,8 +19,17 @@
 
 // Make sure host-instantiated kernels are preserved on device side.
 template  __global__ void templated_kernel(T param) {}
-// CHECK-LABEL: define weak_odr void @_Z16templated_kernelIiEvT_
-void host_function() { templated_kernel<<<0,0>>>(0); }
+// CHECK-DAG: define weak_odr void @_Z16templated_kernelIiEvT_(
+
+namespace {
+__global__ void anonymous_ns_kernel() {}
+// CHECK-DAG: define weak_odr void @_ZN12_GLOBAL__N_119anonymous_ns_kernelEv(
+}
+
+void host_function() {
+  templated_kernel<<<0, 0>>>(0);
+  anonymous_ns_kernel<<<0,0>>>();
+}
 
 // CHECK: !{{[0-9]+}} = !{void ()* @global_function, !"kernel", i32 1}
 // CHECK: !{{[0-9]+}} = !{void (i32)* @_Z16templated_kernelIiEvT_, !"kernel", 
i32 1}
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -8418,22 +8418,29 @@
   return GVA_DiscardableODR;
 }
 
-static GVALinkage adjustGVALinkageForAttributes(GVALinkage L, const Decl *D) {
+static GVALinkage adjustGVALinkageForAttributes(const ASTContext &Context,
+GVALinkage L, const Decl *D) {
   // See http://msdn.microsoft.com/en-us/library/xa0d9ste.aspx
   // dllexport/dllimport on inline functions.
   if (D->hasAttr()) {
 if (L == GVA_DiscardableODR || L == GVA_StrongODR)
   return GVA_AvailableExternally;
-  } else if (D->hasAttr() || D->hasAttr()) {
+  } else if (D->hasAttr()) {
 if (L == GVA_DiscardableODR)
   return GVA_StrongODR;
+  } else if (Context.getLangOpts().CUDA && Context.getLangOpts().CUDAIsDevice 
&&
+ D->hasAttr()) {
+// Device-side functions with __global__ attribute must always be
+// visible externally so they can be launched from host.
+if (L == GVA_DiscardableODR || L == GVA_Internal)
+  return GVA_StrongODR;
   }
   return L;
 }
 
 GVALinkage ASTContext::GetGVALinkageForFunction(const FunctionDecl *FD) const {
-  return adjustGVALinkageForAttributes(basicGVALinkageForFunction(*this, FD),
-   FD);
+  return adjustGVALinkageForAttributes(
+  *this, basicGVALinkageForFunction(*this, FD), FD);
 }
 
 static GVALinkage basicGVALinkageForVariable(const ASTContext &Context,
@@ -8490,8 +8497,8 @@
 }
 
 GVALinkage ASTContext::GetGVALinkageForVariable(const VarDecl *VD) {
-  return adjustGVALinkageForAttributes(basicGVALinkageForVariable(*this, VD),
-   VD);
+  return adjustGVALinkageForAttributes(
+  *this, basicGVALinkageForVariable(*this, VD), VD);
 }
 
 bool ASTContext::DeclMustBeEmitted(const Decl *D) {


Index: cfe/trunk/test/CodeGenCUDA/ptx-kernels.cu
===
--- cfe/trunk/test/CodeGenCUDA/ptx-kernels.cu
+++ cfe/trunk/test/CodeGenCUDA/ptx-kernels.cu
@@ -19,8 +19,17 @@
 
 // Make sure host-instantiated kernels are preserved on device side.
 template  __global__ void templated_kernel(T param) {}
-// CHECK-LABEL: define weak_odr void @_Z16templated_kernelIiEvT_
-void host_function() { templated_kernel<<<0,0>>>(0); }
+// CHECK-DAG: define weak_odr void @_Z16templated_kernelIiEvT_(
+
+namespace {
+__global__ void anonymous_ns_kernel() {}
+// CHECK-DAG: define weak_odr void @_ZN12_GLOBAL__N_119anonymous_ns_kernelEv(
+}
+
+void host_function() {
+  templated_kernel<<<0, 0>>>(0);
+  anonymous_ns_kernel<<<0,0>>>();
+}
 
 // CHECK: !{{[0-9]+}} = !{void ()* @global_function, !"kernel", i32 1}
 // CHECK: !{{[0-9]+}} = !{void (i32)* @_Z16templated_kernelIiEvT_, !"kernel", i32 1}
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -8418,22 +8418,29 @@
   return GVA_DiscardableODR;
 }
 
-static GVALinkage adjustGVALinkageForAttributes(GVALinkage L, const Decl *D) {
+static GVALinkage adjustGVALinkageForAttributes(const ASTContext &Context,
+GVALinkage L, const Decl *D) {
   // See http://msdn.microsoft.com/en-us/library/xa0d9ste.aspx
   // dllexport/dllimport on inline functions.
   if (D->hasAttr()) {
 if (L == GVA_DiscardableODR || L == GVA_StrongODR)
   return GVA_AvailableExternally;
-  } else if (D->hasAttr() || D->hasA

r268299 - [CUDA] Make sure device-side __global__ functions are always visible.

2016-05-02 Thread Artem Belevich via cfe-commits
Author: tra
Date: Mon May  2 15:30:03 2016
New Revision: 268299

URL: http://llvm.org/viewvc/llvm-project?rev=268299&view=rev
Log:
[CUDA] Make sure device-side __global__ functions are always visible.

__global__ functions are a special case in CUDA.

Even when the symbol would normally not be externally
visible according to C++ rules, they still must be visible
in CUDA GPU object so host-side stub can launch them.

Differential Revision: http://reviews.llvm.org/D19748

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGenCUDA/ptx-kernels.cu

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=268299&r1=268298&r2=268299&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon May  2 15:30:03 2016
@@ -8418,22 +8418,29 @@ static GVALinkage basicGVALinkageForFunc
   return GVA_DiscardableODR;
 }
 
-static GVALinkage adjustGVALinkageForAttributes(GVALinkage L, const Decl *D) {
+static GVALinkage adjustGVALinkageForAttributes(const ASTContext &Context,
+GVALinkage L, const Decl *D) {
   // See http://msdn.microsoft.com/en-us/library/xa0d9ste.aspx
   // dllexport/dllimport on inline functions.
   if (D->hasAttr()) {
 if (L == GVA_DiscardableODR || L == GVA_StrongODR)
   return GVA_AvailableExternally;
-  } else if (D->hasAttr() || D->hasAttr()) {
+  } else if (D->hasAttr()) {
 if (L == GVA_DiscardableODR)
   return GVA_StrongODR;
+  } else if (Context.getLangOpts().CUDA && Context.getLangOpts().CUDAIsDevice 
&&
+ D->hasAttr()) {
+// Device-side functions with __global__ attribute must always be
+// visible externally so they can be launched from host.
+if (L == GVA_DiscardableODR || L == GVA_Internal)
+  return GVA_StrongODR;
   }
   return L;
 }
 
 GVALinkage ASTContext::GetGVALinkageForFunction(const FunctionDecl *FD) const {
-  return adjustGVALinkageForAttributes(basicGVALinkageForFunction(*this, FD),
-   FD);
+  return adjustGVALinkageForAttributes(
+  *this, basicGVALinkageForFunction(*this, FD), FD);
 }
 
 static GVALinkage basicGVALinkageForVariable(const ASTContext &Context,
@@ -8490,8 +8497,8 @@ static GVALinkage basicGVALinkageForVari
 }
 
 GVALinkage ASTContext::GetGVALinkageForVariable(const VarDecl *VD) {
-  return adjustGVALinkageForAttributes(basicGVALinkageForVariable(*this, VD),
-   VD);
+  return adjustGVALinkageForAttributes(
+  *this, basicGVALinkageForVariable(*this, VD), VD);
 }
 
 bool ASTContext::DeclMustBeEmitted(const Decl *D) {

Modified: cfe/trunk/test/CodeGenCUDA/ptx-kernels.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/ptx-kernels.cu?rev=268299&r1=268298&r2=268299&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/ptx-kernels.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/ptx-kernels.cu Mon May  2 15:30:03 2016
@@ -19,8 +19,17 @@ __global__ void global_function() {
 
 // Make sure host-instantiated kernels are preserved on device side.
 template  __global__ void templated_kernel(T param) {}
-// CHECK-LABEL: define weak_odr void @_Z16templated_kernelIiEvT_
-void host_function() { templated_kernel<<<0,0>>>(0); }
+// CHECK-DAG: define weak_odr void @_Z16templated_kernelIiEvT_(
+
+namespace {
+__global__ void anonymous_ns_kernel() {}
+// CHECK-DAG: define weak_odr void @_ZN12_GLOBAL__N_119anonymous_ns_kernelEv(
+}
+
+void host_function() {
+  templated_kernel<<<0, 0>>>(0);
+  anonymous_ns_kernel<<<0,0>>>();
+}
 
 // CHECK: !{{[0-9]+}} = !{void ()* @global_function, !"kernel", i32 1}
 // CHECK: !{{[0-9]+}} = !{void (i32)* @_Z16templated_kernelIiEvT_, !"kernel", 
i32 1}


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


[PATCH] D19830: [scan-build] fix dead store warnings emitted on clang code base

2016-05-02 Thread Apelete Seketeli via cfe-commits
apelete created this revision.
apelete added a reviewer: doug.gregor.
apelete added a subscriber: cfe-commits.

This fixes dead store warnings of the type "dead assignment" reported
by CLang Static Analyzer on the following files:

- lib/Lex/Lexer.cpp,
- lib/Lex/ModuleMap.cpp.

Signed-off-by: Apelete Seketeli 

http://reviews.llvm.org/D19830

Files:
  lib/Lex/Lexer.cpp
  lib/Lex/ModuleMap.cpp

Index: lib/Lex/ModuleMap.cpp
===
--- lib/Lex/ModuleMap.cpp
+++ lib/Lex/ModuleMap.cpp
@@ -2197,6 +2197,7 @@
 if (Framework) {
   Diags.Report(StarLoc, diag::err_mmap_inferred_framework_submodule);
   Framework = false;
+  (void) Framework;
 }
   } else if (Explicit) {
 Diags.Report(StarLoc, diag::err_mmap_explicit_inferred_framework);
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -672,6 +672,7 @@
   // directive or it was one that can't occur in the preamble at this
   // point. Roll back the current token to the location of the '#'.
   InPreprocessorDirective = false;
+  (void) InPreprocessorDirective;
   TheTok = HashTok;
 }
 


Index: lib/Lex/ModuleMap.cpp
===
--- lib/Lex/ModuleMap.cpp
+++ lib/Lex/ModuleMap.cpp
@@ -2197,6 +2197,7 @@
 if (Framework) {
   Diags.Report(StarLoc, diag::err_mmap_inferred_framework_submodule);
   Framework = false;
+  (void) Framework;
 }
   } else if (Explicit) {
 Diags.Report(StarLoc, diag::err_mmap_explicit_inferred_framework);
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -672,6 +672,7 @@
   // directive or it was one that can't occur in the preamble at this
   // point. Roll back the current token to the location of the '#'.
   InPreprocessorDirective = false;
+  (void) InPreprocessorDirective;
   TheTok = HashTok;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19829: [scan-build] fix dead store warnings emitted on clang code base

2016-05-02 Thread Apelete Seketeli via cfe-commits
apelete created this revision.
apelete added reviewers: rjmccall, rtrieu, rsmith.
apelete added a subscriber: cfe-commits.

This fixes dead store warnings of the type "dead assignment" reported
by CLang Static Analyzer on the following files:

- lib/Sema/SemaDeclCXX.cpp,
- lib/Sema/SemaExpr.cpp,
- lib/Sema/SemaLookup.cpp,
- lib/Sema/SemaTemplate.cpp.

Signed-off-by: Apelete Seketeli 

http://reviews.llvm.org/D19829

Files:
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaTemplate.cpp

Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -6243,8 +6243,6 @@
 SourceRange(TemplateParams->getTemplateLoc(),
 TemplateParams->getRAngleLoc()))
 << SourceRange(LAngleLoc, RAngleLoc);
-else
-  isExplicitSpecialization = true;
   } else {
 assert(TUK == TUK_Friend && "should have a 'template<>' for this decl");
   }
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -4907,12 +4907,6 @@
  bool NeedDefinition, bool Recover) {
   assert(!isVisible(Decl) && "missing import for non-hidden decl?");
 
-  // Suggest importing a module providing the definition of this entity, if
-  // possible.
-  NamedDecl *Def = getDefinitionToImport(Decl);
-  if (!Def)
-Def = Decl;
-
   // FIXME: Add a Fix-It that imports the corresponding module or includes
   // the header.
   Module *Owner = getOwningModule(Decl);
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -9634,6 +9634,7 @@
   while (true) {
 IsDereference = NextIsDereference;
 NextIsDereference = false;
+(void) NextIsDereference;
 
 E = E->IgnoreParenImpCasts();
 if (const MemberExpr *ME = dyn_cast(E)) {
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -12396,6 +12396,7 @@
   Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
 << TypeWithKeyword::getTagTypeKindName(Kind) << Name;
   isExplicitSpecialization = true;
+  (void) isExplicitSpecialization;
 }
   }
 


Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -6243,8 +6243,6 @@
 SourceRange(TemplateParams->getTemplateLoc(),
 TemplateParams->getRAngleLoc()))
 << SourceRange(LAngleLoc, RAngleLoc);
-else
-  isExplicitSpecialization = true;
   } else {
 assert(TUK == TUK_Friend && "should have a 'template<>' for this decl");
   }
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -4907,12 +4907,6 @@
  bool NeedDefinition, bool Recover) {
   assert(!isVisible(Decl) && "missing import for non-hidden decl?");
 
-  // Suggest importing a module providing the definition of this entity, if
-  // possible.
-  NamedDecl *Def = getDefinitionToImport(Decl);
-  if (!Def)
-Def = Decl;
-
   // FIXME: Add a Fix-It that imports the corresponding module or includes
   // the header.
   Module *Owner = getOwningModule(Decl);
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -9634,6 +9634,7 @@
   while (true) {
 IsDereference = NextIsDereference;
 NextIsDereference = false;
+(void) NextIsDereference;
 
 E = E->IgnoreParenImpCasts();
 if (const MemberExpr *ME = dyn_cast(E)) {
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -12396,6 +12396,7 @@
   Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
 << TypeWithKeyword::getTagTypeKindName(Kind) << Name;
   isExplicitSpecialization = true;
+  (void) isExplicitSpecialization;
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268297 - Revert "[Driver] Quote clang full version in dwarf producer when invoking cc1as"

2016-05-02 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon May  2 15:20:49 2016
New Revision: 268297

URL: http://llvm.org/viewvc/llvm-project?rev=268297&view=rev
Log:
Revert "[Driver] Quote clang full version in dwarf producer when invoking cc1as"

This reverts commit r264813 / 6484b95d634f53dd929c75265ef3c4decf397584.

While using it in the shell is fine, this a problem when cc1as is
invoked directly by the driver because single quoting the clang full
version makes cc1as write out the version with the quotes in the final
binary.

If the user wants to copy-n-pastable output, it could use either -###
or CC_PRINT_OPTIONS=1 clang -v ...

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Misc/cc1as-asm.s

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=268297&r1=268296&r2=268297&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon May  2 15:20:49 2016
@@ -6251,8 +6251,7 @@ void ClangAs::ConstructJob(Compilation &
 // Set the AT_producer to the clang version when using the integrated
 // assembler on assembly source files.
 CmdArgs.push_back("-dwarf-debug-producer");
-std::string QuotedClangVersion("'" + getClangFullVersion() + "'");
-CmdArgs.push_back(Args.MakeArgString(QuotedClangVersion));
+CmdArgs.push_back(Args.MakeArgString(getClangFullVersion()));
 
 // And pass along -I options
 Args.AddAllArgs(CmdArgs, options::OPT_I);

Modified: cfe/trunk/test/Misc/cc1as-asm.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/cc1as-asm.s?rev=268297&r1=268296&r2=268297&view=diff
==
--- cfe/trunk/test/Misc/cc1as-asm.s (original)
+++ cfe/trunk/test/Misc/cc1as-asm.s Mon May  2 15:20:49 2016
@@ -1,5 +1,3 @@
 // Run cc1as asm output path just to make sure it works
 // REQUIRES: x86-registered-target
 // RUN: %clang -cc1as -triple x86_64-apple-macosx10.10.0 -filetype asm %s -o 
/dev/null
-// Test that cc1as is able to consume a quoted clang full version
-// RUN: %clang -cc1as -triple x86_64-apple-macosx10.10.0 -dwarf-debug-producer 
'clang dummy version' -filetype asm %s -o /dev/null


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


Re: [PATCH] D19708: [CGDebugInfo] Generate debug info for member calls in the context of the callee expression

2016-05-02 Thread Hal Finkel via cfe-commits
- Original Message -
> From: "David Blaikie" 
> To: reviews+d19708+public+e9ddc42503732...@reviews.llvm.org, "Hal Finkel" 
> 
> Cc: "Richard Smith" , "Adrian Prantl" 
> , "Duncan P. N. Exon Smith"
> , "Eric Christopher" , "Jun Bum 
> Lim" ,
> "cfe-commits" 
> Sent: Friday, April 29, 2016 4:52:26 PM
> Subject: Re: [PATCH] D19708: [CGDebugInfo] Generate debug info for member 
> calls in the context of the callee
> expression
> 
> 
> You could simplify the test case further, down to just:
> 
> struct foo { void bar(); };
> void f(foo *f) {
> f->bar();
> }
> 
> and check that the call instruction has the desired column (or if you
> want a test that doesn't depend on column info (you can force it on
> with a flag, but we might vary whether it's on by default based on
> target, etc, I'm not sure) you could put 'bar();' on a separate line
> from 'f->' and check the call was on the second line and not the
> first).

Certainly. I'm not sure much we want to reduce the test case, however, because 
I particularly want to cover the case of two calls on the same line with column 
info. Given that this is still pretty simple, I think that covering it directly 
seems reasonable.

> 
> Richard might be able to tell us whether there's a preferred place
> for a test for a change like this - should it be a debug info test,
> a diagnostic test,

At least for the test you suggested in a previous e-mail, this patch has no 
effect on the output diagnostics (although it certainly does have the desired 
effect on the debug info). Specifically, even with this patch, we still have:

  $ cat /tmp/loc.cpp 
  struct foo {
const foo *x() const;
void y();
  };
  
  void f(const foo *g) {
g->x()->y();
g->x()->x()->y();
  }

$ clang /tmp/loc.cpp -fsyntax-only
  /tmp/loc.cpp:7:3: error: member function 'y' not viable: 'this' argument has 
type 'const foo', but function is not marked const
g->x()->y();
^~
  /tmp/loc.cpp:3:8: note: 'y' declared here
void y();
 ^
  /tmp/loc.cpp:8:3: error: member function 'y' not viable: 'this' argument has 
type 'const foo', but function is not marked const
g->x()->x()->y();
^~~
  /tmp/loc.cpp:3:8: note: 'y' declared here
void y();
 ^
  2 errors generated.

Thanks again,
Hal

> or perhaps just an ast dump test?
> 
> Perhaps a test for the case where there is no valid callee would be
> good? Where does that come up - call through a member function
> pointer?
> 
> 
> On Fri, Apr 29, 2016 at 9:19 AM, Hal Finkel via cfe-commits <
> cfe-commits@lists.llvm.org > wrote:
> 
> 
> hfinkel updated this revision to Diff 55610.
> hfinkel added a comment.
> 
> Use David's suggested approach: Modify the preferred expression
> location for member calls. If the callee has a valid location (not
> all do), then use that. Otherwise, fall back to the starting
> location. This seems to cleanly fix the debug-info problem.
> 
> 
> http://reviews.llvm.org/D19708
> 
> Files:
> include/clang/AST/ExprCXX.h
> 
> 
> test/CodeGenCXX/debug-info-member-call.cpp
> 
> Index: test/CodeGenCXX/debug-info-member-call.cpp
> ===
> --- /dev/null
> +++ test/CodeGenCXX/debug-info-member-call.cpp
> @@ -0,0 +1,24 @@
> +// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm
> -debug-info-kind=standalone -dwarf-column-info %s -o - | FileCheck
> %s
> +void ext();
> +
> +struct Bar {
> + void bar() { ext(); }
> +};
> +
> +struct Foo {
> + Bar *b;
> +
> + Bar *foo() { return b; }
> +};
> +
> +void test(Foo *f) {
> + f->foo()->bar();
> +}
> +
> +// CHECK-LABEL: @_Z4testP3Foo
> +// CHECK: call {{.*}} @_ZN3Foo3fooEv{{.*}}, !dbg ![[CALL1LOC:.*]]
> +// CHECK: call void @_ZN3Bar3barEv{{.*}}, !dbg ![[CALL2LOC:.*]]
> +
> +// CHECK: ![[CALL1LOC]] = !DILocation(line: [[LINE:[0-9]+]], column:
> 6,
> +// CHECK: ![[CALL2LOC]] = !DILocation(line: [[LINE]], column: 13,
> +
> Index: include/clang/AST/ExprCXX.h
> ===
> --- include/clang/AST/ExprCXX.h
> +++ include/clang/AST/ExprCXX.h
> @@ -145,6 +145,14 @@
> /// FIXME: Returns 0 for member pointer call exprs.
> CXXRecordDecl *getRecordDecl() const;
> 
> + SourceLocation getExprLoc() const LLVM_READONLY {
> + SourceLocation CLoc = getCallee()->getExprLoc();
> + if (CLoc.isValid())
> + return CLoc;
> +
> + return getLocStart();
> + }
> +
> static bool classof(const Stmt *T) {
> return T->getStmtClass() == CXXMemberCallExprClass;
> }
> 
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 
> 
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19827: Do not disable completely loop unroll according to optimization level.

2016-05-02 Thread Marianne Mailhot-Sarrasin via cfe-commits
mamai created this revision.
mamai added a reviewer: chandlerc.
mamai added a subscriber: cfe-commits.
mamai set the repository for this revision to rL LLVM.

By disabling completely the loop unroll at some optimization levels (e.g. /Os), 
the #pragma unroll have no effect at those optimization levels.

This contradicts the paragraph in an llvm blog post about the loop pragmas 
(http://blog.llvm.org/2014/11/loop-vectorization-diagnostics-and.html) saying 
the following:

> For example, when compiling for size (-Os) it's a good idea to vectorize the 
> hot loops of the application to improve performance. Vectorization, 
> interleaving, and unrolling can be explicitly specified using the #pragma 
> clang loop directive prior to any for, while, do-while, or c++11 range-based 
> for loop.

Also, as explained in a previous commit, the  loop unroll pass already have the 
logic to unroll loop are not according to optimization level 
(http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20130805/085399.html).

Repository:
  rL LLVM

http://reviews.llvm.org/D19827

Files:
  lib/Frontend/CompilerInvocation.cpp

Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -511,9 +511,7 @@
 Args.hasArg(OPT_ffreestanding));
   if (Opts.SimplifyLibCalls)
 getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
-  Opts.UnrollLoops =
-  Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
-   (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize));
+  Opts.UnrollLoops = Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops);
   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -511,9 +511,7 @@
 Args.hasArg(OPT_ffreestanding));
   if (Opts.SimplifyLibCalls)
 getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
-  Opts.UnrollLoops =
-  Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
-   (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize));
+  Opts.UnrollLoops = Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops);
   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-05-02 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

typo. saved 300KB space.


http://reviews.llvm.org/D18369



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


[libcxx] r268294 - Cleanup warnings and remove use of __builtin_va_list in depr.c.headers

2016-05-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May  2 15:08:16 2016
New Revision: 268294

URL: http://llvm.org/viewvc/llvm-project?rev=268294&view=rev
Log:
Cleanup warnings and remove use of __builtin_va_list in depr.c.headers

Modified:
libcxx/trunk/test/std/depr/depr.c.headers/fenv_h.pass.cpp
libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp
libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp
libcxx/trunk/test/std/depr/depr.c.headers/time_h.pass.cpp
libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp

Modified: libcxx/trunk/test/std/depr/depr.c.headers/fenv_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/fenv_h.pass.cpp?rev=268294&r1=268293&r2=268294&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/fenv_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/fenv_h.pass.cpp Mon May  2 
15:08:16 2016
@@ -60,7 +60,7 @@
 
 int main()
 {
-fenv_t fenv = {0};
+fenv_t fenv = {};
 fexcept_t fex = 0;
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");

Modified: libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp?rev=268294&r1=268293&r2=268294&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp Mon May  2 
15:08:16 2016
@@ -917,7 +917,7 @@ int main()
 uintmax_t i4 = 0;
 }
 {
-imaxdiv_t  i1 = {0};
+imaxdiv_t  i1 = {};
 }
 intmax_t i = 0;
 static_assert((std::is_same::value), "");

Modified: libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp?rev=268294&r1=268293&r2=268294&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp Mon May  2 
15:08:16 2016
@@ -107,7 +107,7 @@
 int main()
 {
 FILE* fp = 0;
-fpos_t fpos = {0};
+fpos_t fpos = {};
 size_t s = 0;
 char* cp = 0;
 char arr[] = {'a', 'b'};

Modified: libcxx/trunk/test/std/depr/depr.c.headers/time_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/time_h.pass.cpp?rev=268294&r1=268293&r2=268294&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/time_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/time_h.pass.cpp Mon May  2 
15:08:16 2016
@@ -25,7 +25,7 @@ int main()
 clock_t c = 0; ((void)c);
 size_t s = 0;
 time_t t = 0;
-tm tmv = {0};
+tm tmv = {};
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");

Modified: libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp?rev=268294&r1=268293&r2=268294&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp Mon May  2 
15:08:16 2016
@@ -10,6 +10,7 @@
 // 
 
 #include 
+#include 
 #include 
 
 #ifndef NULL
@@ -31,27 +32,15 @@
 int main()
 {
 // mbstate_t comes from the underlying C library; it is defined (in C99) as:
-//a complete object type other than an array type that can hold the 
conversion 
-//state information necessary to convert between sequences of multibyte 
+//a complete object type other than an array type that can hold the 
conversion
+//state information necessary to convert between sequences of multibyte
 //characters and wide characters
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wmissing-braces"
-#endif
-mbstate_t mb = {0};
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
-
+mbstate_t mb = {};
 size_t s = 0;
 tm *tm = 0;
 wint_t w = 0;
 ::FILE* fp = 0;
-#ifdef __APPLE__
-__darwin_va_list va;
-#else
-__builtin_va_list va;
-#endif
+::va_list va;
 char* ns = 0;
 wchar_t* ws = 0;
 static_assert((std::is_same::value), "");


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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-05-02 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: lib/Headers/opencl-c.h:4872
@@ +4871,3 @@
+
+#ifdef cl_khr_fp64
+char __const_func __attribute__((overloadable)) convert_char(double);

Anastasia wrote:
> Interesting, macro has the same name as an extension?
The spec requires a macro to be defined with the same name as the supported 
extension, so it is natural to use it here.


Comment at: lib/Headers/opencl-c.h:14056
@@ +14055,3 @@
+#ifdef _CL20_AND_ABOVE
+#define ATOMIC_VAR_INIT(x) (x)
+

Anastasia wrote:
> I am not sure this implementation of macro is generic enough!
This macro is for initializing global variables with atomic type. In SPIR it is 
represented as usual initializer the same way as a non-atomic type. OpenCL 
runtime initializes it the same way as a non-atomic type before kernel 
execution. I don't think there is need to define this macro another way.


http://reviews.llvm.org/D18369



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


Re: [PATCH] D19819: [clang-tidy] Cleanup namespace in utils folder.

2016-05-02 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 55876.
etienneb added a comment.

fix unittests


http://reviews.llvm.org/D19819

Files:
  clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tidy/llvm/HeaderGuardCheck.h
  clang-tidy/misc/MoveConstructorInitCheck.cpp
  clang-tidy/misc/MoveConstructorInitCheck.h
  clang-tidy/misc/SuspiciousSemicolonCheck.cpp
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/modernize/PassByValueCheck.h
  clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tidy/modernize/ReplaceAutoPtrCheck.h
  clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tidy/utils/DeclRefExprUtils.h
  clang-tidy/utils/FixItHintUtils.cpp
  clang-tidy/utils/FixItHintUtils.h
  clang-tidy/utils/HeaderGuard.cpp
  clang-tidy/utils/HeaderGuard.h
  clang-tidy/utils/IncludeInserter.cpp
  clang-tidy/utils/IncludeInserter.h
  clang-tidy/utils/IncludeSorter.cpp
  clang-tidy/utils/IncludeSorter.h
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  clang-tidy/utils/Matchers.h
  clang-tidy/utils/TypeTraits.cpp
  clang-tidy/utils/TypeTraits.h
  unittests/clang-tidy/IncludeInserterTest.cpp

Index: unittests/clang-tidy/IncludeInserterTest.cpp
===
--- unittests/clang-tidy/IncludeInserterTest.cpp
+++ unittests/clang-tidy/IncludeInserterTest.cpp
@@ -33,9 +33,10 @@
   : ClangTidyCheck(CheckName, Context) {}
 
   void registerPPCallbacks(CompilerInstance &Compiler) override {
-Inserter.reset(new IncludeInserter(Compiler.getSourceManager(),
-   Compiler.getLangOpts(),
-   IncludeSorter::IS_Google));
+Inserter.reset(new utils::IncludeInserter(
+Compiler.getSourceManager(),
+Compiler.getLangOpts(),
+utils::IncludeSorter::IS_Google));
 Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
   }
 
@@ -58,7 +59,7 @@
   virtual std::vector HeadersToInclude() const = 0;
   virtual bool IsAngledInclude() const = 0;
 
-  std::unique_ptr Inserter;
+  std::unique_ptr Inserter;
 };
 
 class NonSystemHeaderInserterCheck : public IncludeInserterCheckBase {
Index: clang-tidy/utils/TypeTraits.h
===
--- clang-tidy/utils/TypeTraits.h
+++ clang-tidy/utils/TypeTraits.h
@@ -15,6 +15,7 @@
 
 namespace clang {
 namespace tidy {
+namespace utils {
 namespace type_traits {
 
 // \brief Returns true If \c Type is expensive to copy.
@@ -28,6 +29,7 @@
const ASTContext &Context);
 
 } // type_traits
+} // namespace utils
 } // namespace tidy
 } // namespace clang
 
Index: clang-tidy/utils/TypeTraits.cpp
===
--- clang-tidy/utils/TypeTraits.cpp
+++ clang-tidy/utils/TypeTraits.cpp
@@ -13,6 +13,7 @@
 
 namespace clang {
 namespace tidy {
+namespace utils {
 namespace type_traits {
 
 namespace {
@@ -106,6 +107,7 @@
   return false;
 }
 
-} // type_traits
+} // namespace type_traits
+} // namespace utils
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/utils/Matchers.h
===
--- clang-tidy/utils/Matchers.h
+++ clang-tidy/utils/Matchers.h
@@ -31,12 +31,12 @@
 
 AST_MATCHER(QualType, isExpensiveToCopy) {
   llvm::Optional IsExpensive =
-  type_traits::isExpensiveToCopy(Node, Finder->getASTContext());
+  utils::type_traits::isExpensiveToCopy(Node, Finder->getASTContext());
   return IsExpensive && *IsExpensive;
 }
 
 AST_MATCHER(RecordDecl, isTriviallyDefaultConstructible) {
-  return type_traits::recordIsTriviallyDefaultConstructible(
+  return utils::type_traits::recordIsTriviallyDefaultConstructible(
   Node, Finder->getASTContext());
 }
 
Index: clang-tidy/utils/LexerUtils.h
===
--- clang-tidy/utils/LexerUtils.h
+++ clang-tidy/utils/LexerUtils.h
@@ -15,14 +15,16 @@
 
 namespace clang {
 namespace tidy {
-namespace lexer_utils {
+namespace utils {
+namespace lexer {
 
 // Returns previous non-comment token skipping over any comment text or
 // tok::unknown if not found.
 Token getPreviousNonCommentToken(const ASTContext &Context,
  SourceLocation Location);
 
-} // namespace lexer_utils
+} // namespace lexer
+} // namespace utils
 } // namespace tidy
 } // namespace clang
 
Index: clang-tidy/utils/LexerUtils.cpp
===
--- clang-tidy/utils/LexerUtils.cpp
+++ clang-tidy/utils/LexerUtils.cpp
@@ -11,7 +11,8 @@
 
 namespace clang {
 namespace tidy {
-n

Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-02 Thread Krystyna via cfe-commits
krystyna marked 4 inline comments as done.
krystyna added a comment.

Repository:
  rL LLVM

http://reviews.llvm.org/D18919



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


Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-02 Thread Krystyna via cfe-commits
krystyna updated this revision to Diff 55867.

Repository:
  rL LLVM

http://reviews.llvm.org/D18919

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseUsingCheck.cpp
  clang-tidy/modernize/UseUsingCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-using.rst
  test/clang-tidy/modernize-use-using.cpp

Index: test/clang-tidy/modernize-use-using.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-using.cpp
@@ -0,0 +1,79 @@
+// RUN: %check_clang_tidy %s modernize-use-using %t
+
+typedef int Type;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use using instead of typedef [modernize-use-using]
+// CHECK-FIXES: using Type = int;
+
+typedef long LL;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use using instead of typedef
+// CHECK-FIXES: using LL = long;
+
+typedef int Bla;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use using instead of typedef
+// CHECK-FIXES: using Bla = int;
+
+typedef Bla Bla2;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use using instead of typedef
+// CHECK-FIXES: using Bla2 = Bla;
+
+typedef void (*type)(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use using instead of typedef
+// CHECK-FIXES: using type = void (*)(int);
+
+typedef void (*type2)();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use using instead of typedef
+// CHECK-FIXES: using type2 = void (*)();
+
+class Class {
+typedef long long Type;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use using instead of typedef
+	// CHECK-FIXES: using Type = long long;
+};
+
+typedef void (Class::* MyPtrType)(Bla) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use using instead of typedef
+// CHECK-FIXES: using MyPtrType = void (Class::*)(Bla) const;
+
+class Iterable {
+public:
+	class Iterator {};
+};
+
+template
+class Test {
+typedef typename T::iterator Iter;
+	// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use using instead of typedef
+	// CHECK-FIXES: using Iter = typename T::iterator;
+};
+
+using balba = long long;
+
+union A {};
+
+typedef void (A::*PtrType)(int, int) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use using instead of typedef
+// CHECK-FIXES: using PtrType = void (A::*)(int, int) const;
+
+typedef Class some_class;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use using instead of typedef
+// CHECK-FIXES: using some_class = Class;
+
+typedef Class Cclass;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use using instead of typedef
+// CHECK-FIXES: using Cclass = Class;
+
+typedef Cclass cclass2;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use using instead of typedef
+// CHECK-FIXES: using cclass2 = Cclass;
+
+class cclass {};
+
+typedef void (cclass::* MyPtrType3)(Bla);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use using instead of typedef
+// CHECK-FIXES: using MyPtrType3 = void (cclass::*)(Bla);
+
+using my_class = int;
+
+typedef Test another;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use using instead of typedef
+// CHECK-FIXES: using another = Test;
Index: docs/clang-tidy/checks/modernize-use-using.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-using.rst
@@ -0,0 +1,24 @@
+.. title:: clang-tidy - modernize-use-using
+
+modernize-use-using
+===
+
+Use C++11's ``using`` instead of ``typedef``.
+
+Before:
+
+.. code:: c++
+
+  typedef int variable;
+
+  class Class{};
+  typedef void (Class::* MyPtrType)() const;
+
+After:
+
+.. code:: c++
+
+  using varible = int;
+
+  class Class{};
+  using MyPtrType = void (Class::*)() const;
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -96,6 +96,7 @@
modernize-use-default
modernize-use-nullptr
modernize-use-override
+   modernize-use-using
performance-faster-string-find
performance-for-range-copy
performance-implicit-cast-in-loop
Index: clang-tidy/modernize/UseUsingCheck.h
===
--- /dev/null
+++ clang-tidy/modernize/UseUsingCheck.h
@@ -0,0 +1,35 @@
+//===--- UseUsingCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_USING_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_USING_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+/// Check finds typedefs and replaces it with usings.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/mode

Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-02 Thread Krystyna via cfe-commits
krystyna added a comment.

hide done comments


Repository:
  rL LLVM

http://reviews.llvm.org/D18919



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


Re: [PATCH] D19758: [libcxx] [test] Replace non-Standard "atomic_flag f(false); " with Standard "atomic_flag f = ATOMIC_FLAG_INIT; ".

2016-05-02 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT added a comment.

Makes sense. MSVC will never have C++03 or C++11 modes (only 14/17/future) so 
anything you do in C++03 mode is fine by me.


http://reviews.llvm.org/D19758



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


Re: [PATCH] D19758: [libcxx] [test] Replace non-Standard "atomic_flag f(false); " with Standard "atomic_flag f = ATOMIC_FLAG_INIT; ".

2016-05-02 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I actually want this form of initialization to break in C++03, From the 
original review:

> After putting this question up on cfe-dev I have decided that it would be 
> best to allow the use of  in C++03. Although static initialization is 
> a concern the syntax required to get it is C++11 only. Meaning that C++11 
> constant static initialization cannot silently break in C++03, it will always 
> cause a syntax error. Furthermore ATOMIC_VAR_INIT and ATOMIC_FLAG_INIT remain 
> defined in C++03 even though they cannot be used because C++03 usages will 
> cause better error messages.


I think I'll just hack up these tests, or make them require C++11 or greater 
and add C++03 specific tests elsewhere.


http://reviews.llvm.org/D19758



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


Re: [PATCH] D19623: [libcxx] [test] Initialize local doubles to NaN.

2016-05-02 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r268285.


http://reviews.llvm.org/D19623



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


[libcxx] r268285 - Initialize local doubles to NaN. Patch from s...@microsoft.com

2016-05-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May  2 14:20:16 2016
New Revision: 268285

URL: http://llvm.org/viewvc/llvm-project?rev=268285&view=rev
Log:
Initialize local doubles to NaN. Patch from s...@microsoft.com

Modified:

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp

Modified: 
libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp?rev=268285&r1=268284&r2=268285&view=diff
==
--- 
libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp
 Mon May  2 14:20:16 2016
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 template 
 inline
@@ -60,10 +61,10 @@ int main()
 }
 std::sort(u.begin(), u.end());
 int kp = -1;
-double a;
-double m;
-double bk;
-double c;
+double a = std::numeric_limits::quiet_NaN();
+double m = std::numeric_limits::quiet_NaN();
+double bk = std::numeric_limits::quiet_NaN();
+double c = std::numeric_limits::quiet_NaN();
 std::vector areas(Np);
 double S = 0;
 for (int i = 0; i < areas.size(); ++i)
@@ -110,10 +111,10 @@ int main()
 }
 std::sort(u.begin(), u.end());
 int kp = -1;
-double a;
-double m;
-double bk;
-double c;
+double a = std::numeric_limits::quiet_NaN();
+double m = std::numeric_limits::quiet_NaN();
+double bk = std::numeric_limits::quiet_NaN();
+double c = std::numeric_limits::quiet_NaN();
 std::vector areas(Np);
 double S = 0;
 for (int i = 0; i < areas.size(); ++i)
@@ -160,10 +161,10 @@ int main()
 }
 std::sort(u.begin(), u.end());
 int kp = -1;
-double a;
-double m;
-double bk;
-double c;
+double a = std::numeric_limits::quiet_NaN();
+double m = std::numeric_limits::quiet_NaN();
+double bk = std::numeric_limits::quiet_NaN();
+double c = std::numeric_limits::quiet_NaN();
 std::vector areas(Np);
 double S = 0;
 for (int i = 0; i < areas.size(); ++i)
@@ -210,10 +211,10 @@ int main()
 }
 std::sort(u.begin(), u.end());
 int kp = -1;
-double a;
-double m;
-double bk;
-double c;
+double a = std::numeric_limits::quiet_NaN();
+double m = std::numeric_limits::quiet_NaN();
+double bk = std::numeric_limits::quiet_NaN();
+double c = std::numeric_limits::quiet_NaN();
 std::vector areas(Np);
 double S = 0;
 for (int i = 0; i < areas.size(); ++i)
@@ -260,10 +261,10 @@ int main()
 }
 std::sort(u.begin(), u.end());
 int kp = -1;
-double a;
-double m;
-double bk;
-double c;
+double a = std::numeric_limits::quiet_NaN();
+double m = std::numeric_limits::quiet_NaN();
+double bk = std::numeric_limits::quiet_NaN();
+double c = std::numeric_limits::quiet_NaN();
 std::vector areas(Np);
 double S = 0;
 for (int i = 0; i < areas.size(); ++i)
@@ -310,10 +311,10 @@ int main()
 }
 std::sort(u.begin(), u.end());
 int kp = -1;
-double a;
-double m;
-double bk;
-double c;
+double a = std::numeric_limits::quiet_NaN();
+double m = std::numeric_limits::quiet_NaN();
+double bk = std::numeric_limits::quiet_NaN();
+double c = std::numeric_limits::quiet_NaN();
 std::vector areas(Np);
 double S = 0;
 for (int i = 0; i < areas.size(); ++i)

Modified: 
libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp?rev=268285&r1=268284&r2=268285&view=diff
==
--- 
libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp
 Mon May  2 14:20:16 2016
@@ -22,6 +22,7 @@
 #include 
 #include// for sort
 #include 
+#include 
 
 template 
 inline
@@ -59,10 +60,10 @@ int main()
 }
 std::sort(u.begin(), u.end());
 int kp = -1;
-double a;
-double m;

Re: [PATCH] D19758: [libcxx] [test] Replace non-Standard "atomic_flag f(false); " with Standard "atomic_flag f = ATOMIC_FLAG_INIT; ".

2016-05-02 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT added a comment.

Since you control the definition of ATOMIC_FLAG_INIT, can you make it something 
like __secret_tag_type() in C++03?  That would allow you to continue to provide 
the atomic_flag(bool) extension in C++03.


http://reviews.llvm.org/D19758



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


Re: [PATCH] D19623: [libcxx] [test] Initialize local doubles to NaN.

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

I have no objections to this change. Howard seems to agree.


http://reviews.llvm.org/D19623



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


Re: [PATCH] D19625: [libc++] Void-cast runtime-unused variables.

2016-05-02 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r268284.

In http://reviews.llvm.org/D19625#418697, @STL_MSFT wrote:

> No problem! With these changes, my test runs are currently clean wrt "warning 
> C4100: unreferenced formal parameter" and "warning C4101: unreferenced local 
> variable", but note that (1) Clang may emit unused-variable warnings in 
> somewhat different situations, and (2) I've still got 25% of the tests 
> failing to compile, which may be hiding further warnings.


I'm hoping Clang is pretty similar. I guess we will see. I'm going to hold off 
setting up a bot for a while still.


http://reviews.llvm.org/D19625



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


[libcxx] r268284 - Void cast runtime-unused variables. Patch from s...@microsoft.com

2016-05-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May  2 14:15:48 2016
New Revision: 268284

URL: http://llvm.org/viewvc/llvm-project?rev=268284&view=rev
Log:
Void cast runtime-unused variables. Patch from s...@microsoft.com

Modified:
libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp
libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp
libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.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/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp

libcxx/trunk/test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp

libcxx/trunk/test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp

libcxx/trunk/test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp

libcxx/trunk/test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp

libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp

libcxx/trunk/test/std/language.support/support.exception/propagation/current_exception.pass.cpp
libcxx/trunk/test/std/language.support/support.runtime/csetjmp.pass.cpp
libcxx/trunk/test/std/language.support/support.runtime/ctime.pass.cpp
libcxx/trunk/test/std/localization/c.locales/clocale.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
libcxx/trunk/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp
libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp

libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp

libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp
libcxx/trunk/test/std/utilities/time/date.time/ctime.pass.cpp
libcxx/trunk/test/std/utilities/utility/forward/forward.pass.cpp

Modified: libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp?rev=268284&r1=268283&r2=268284&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp Mon May  2 
14:15:48 2016
@@ -19,6 +19,7 @@
 int main()
 {
 jmp_buf jb;
+((void)jb); // Prevent unused warning
 static_assert((std::is_same::value),
   "std::is_same::value");
 }

Modified: libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp?rev=268284&r1=268283&r2=268284&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp Mon May  2 
14:15:48 2016
@@ -108,10 +108,16 @@ int main()
 {
 FILE* fp = 0;
 fpos_t fpos = {0};
-size_t s = 0; ((void)s);
+size_t s = 0;
 char* cp = 0;
 char arr[] = {'a', 'b'};
 va_list va;
+((void)fp); // Prevent unused warning
+((void)fpos); // Prevent unused warning
+((void)s); // Prevent unused warning
+((void)cp); // Prevent unused warning
+((void)arr); // Prevent unused warning
+((void)va); // Prevent unused warning
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");

Modified: 
libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp?rev=268284&r1=268283&r2=268284&view=diff
==
--- libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp 
(original)
+++ libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp Mon 
May  2 14:15:48 2016
@@ -91,6 +91,11 @@ int main()
 std::size_t s = 0;
 char* cp = 0;
 std::va_list va;
+((void)fp); // Prevent unused warning
+((void)fpos); // Prevent unused warning
+((void)s); // Prevent unused warning
+((void)cp); // Prevent unused warning
+((void)va); // Prevent unused warning
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), 
"");

Modified: 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic

Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-02 Thread Krystyna via cfe-commits
krystyna marked 8 inline comments as done.
krystyna added a comment.

Repository:
  rL LLVM

http://reviews.llvm.org/D18919



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


Re: [PATCH] D19758: [libcxx] [test] Replace non-Standard "atomic_flag f(false); " with Standard "atomic_flag f = ATOMIC_FLAG_INIT; ".

2016-05-02 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

This is a small problem. We actually provide  in C++03 minus 
`ATOMIC_FLAG_INIT` since it requires C++11.
I'll come up with a way to fix these tests so they keep working in C++03.


http://reviews.llvm.org/D19758



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


Re: [PATCH] D19819: [clang-tidy] Cleanup namespace in utils folder.

2016-05-02 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 55858.
etienneb added a comment.

add missing case


http://reviews.llvm.org/D19819

Files:
  clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tidy/llvm/HeaderGuardCheck.h
  clang-tidy/misc/MoveConstructorInitCheck.cpp
  clang-tidy/misc/MoveConstructorInitCheck.h
  clang-tidy/misc/SuspiciousSemicolonCheck.cpp
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/modernize/PassByValueCheck.h
  clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tidy/modernize/ReplaceAutoPtrCheck.h
  clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tidy/utils/DeclRefExprUtils.h
  clang-tidy/utils/FixItHintUtils.cpp
  clang-tidy/utils/FixItHintUtils.h
  clang-tidy/utils/HeaderGuard.cpp
  clang-tidy/utils/HeaderGuard.h
  clang-tidy/utils/IncludeInserter.cpp
  clang-tidy/utils/IncludeInserter.h
  clang-tidy/utils/IncludeSorter.cpp
  clang-tidy/utils/IncludeSorter.h
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  clang-tidy/utils/Matchers.h
  clang-tidy/utils/TypeTraits.cpp
  clang-tidy/utils/TypeTraits.h

Index: clang-tidy/utils/TypeTraits.h
===
--- clang-tidy/utils/TypeTraits.h
+++ clang-tidy/utils/TypeTraits.h
@@ -15,6 +15,7 @@
 
 namespace clang {
 namespace tidy {
+namespace utils {
 namespace type_traits {
 
 // \brief Returns true If \c Type is expensive to copy.
@@ -28,6 +29,7 @@
const ASTContext &Context);
 
 } // type_traits
+} // namespace utils
 } // namespace tidy
 } // namespace clang
 
Index: clang-tidy/utils/TypeTraits.cpp
===
--- clang-tidy/utils/TypeTraits.cpp
+++ clang-tidy/utils/TypeTraits.cpp
@@ -13,6 +13,7 @@
 
 namespace clang {
 namespace tidy {
+namespace utils {
 namespace type_traits {
 
 namespace {
@@ -106,6 +107,7 @@
   return false;
 }
 
-} // type_traits
+} // namespace type_traits
+} // namespace utils
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/utils/Matchers.h
===
--- clang-tidy/utils/Matchers.h
+++ clang-tidy/utils/Matchers.h
@@ -31,12 +31,12 @@
 
 AST_MATCHER(QualType, isExpensiveToCopy) {
   llvm::Optional IsExpensive =
-  type_traits::isExpensiveToCopy(Node, Finder->getASTContext());
+  utils::type_traits::isExpensiveToCopy(Node, Finder->getASTContext());
   return IsExpensive && *IsExpensive;
 }
 
 AST_MATCHER(RecordDecl, isTriviallyDefaultConstructible) {
-  return type_traits::recordIsTriviallyDefaultConstructible(
+  return utils::type_traits::recordIsTriviallyDefaultConstructible(
   Node, Finder->getASTContext());
 }
 
Index: clang-tidy/utils/LexerUtils.h
===
--- clang-tidy/utils/LexerUtils.h
+++ clang-tidy/utils/LexerUtils.h
@@ -15,14 +15,16 @@
 
 namespace clang {
 namespace tidy {
-namespace lexer_utils {
+namespace utils {
+namespace lexer {
 
 // Returns previous non-comment token skipping over any comment text or
 // tok::unknown if not found.
 Token getPreviousNonCommentToken(const ASTContext &Context,
  SourceLocation Location);
 
-} // namespace lexer_utils
+} // namespace lexer
+} // namespace utils
 } // namespace tidy
 } // namespace clang
 
Index: clang-tidy/utils/LexerUtils.cpp
===
--- clang-tidy/utils/LexerUtils.cpp
+++ clang-tidy/utils/LexerUtils.cpp
@@ -11,7 +11,8 @@
 
 namespace clang {
 namespace tidy {
-namespace lexer_utils {
+namespace utils {
+namespace lexer {
 
 Token getPreviousNonCommentToken(const ASTContext &Context,
  SourceLocation Location) {
@@ -34,6 +35,7 @@
   return Token;
 }
 
-} // namespace lexer_utils
+} // namespace lexer
+} // namespace utils
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/utils/IncludeSorter.h
===
--- clang-tidy/utils/IncludeSorter.h
+++ clang-tidy/utils/IncludeSorter.h
@@ -15,6 +15,7 @@
 
 namespace clang {
 namespace tidy {
+namespace utils {  
 
 // Class used by IncludeSorterCallback and IncludeInserterCallback to record the
 // names of the inclusions in a given source file being processed and generate
@@ -83,6 +84,7 @@
   SmallVector IncludeBucket[IK_InvalidInclude];
 };
 
+} // namespace utils
 } // namespace tidy
 } // namespace clang
 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDESORTER_H
Index: clang-tidy/utils/IncludeSorter.cpp
===
--- clang-tidy/utils/Include

Re: [PATCH] D19754: Allow 'nodebug' on local variables

2016-05-02 Thread David Blaikie via cfe-commits
dblaikie added inline comments.


Comment at: test/CodeGenCXX/debug-info-nodebug.cpp:50
@@ -49,1 +49,3 @@
   NODEBUG static int static_local = 6;
+  NODEBUG const  int const_local = 7;
+  NODEBUGint normal_local = 8;

Doesn't look like the const case is any different from the non-const case, is 
it?


Comment at: test/CodeGenObjC/debug-info-nodebug.m:17
@@ +16,3 @@
+  // CHECK-NOT: !DILocalVariable(name: "strongSelf"
+  __attribute__((nodebug)) __typeof(self) weakSelf = self;
+  Block = [^{

Is this case outside of the block interesting in some way? It doesn't look like 
it.


http://reviews.llvm.org/D19754



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


[PATCH] D19819: [clang-tidy] Cleanup namespace in utils folder.

2016-05-02 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

This is a step forward cleaning up the namespaces in clang-tidy/utils.
There is no behavior change.

http://reviews.llvm.org/D19819

Files:
  clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tidy/llvm/HeaderGuardCheck.h
  clang-tidy/misc/MoveConstructorInitCheck.cpp
  clang-tidy/misc/MoveConstructorInitCheck.h
  clang-tidy/misc/SuspiciousSemicolonCheck.cpp
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/modernize/PassByValueCheck.h
  clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tidy/modernize/ReplaceAutoPtrCheck.h
  clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tidy/utils/DeclRefExprUtils.h
  clang-tidy/utils/FixItHintUtils.cpp
  clang-tidy/utils/FixItHintUtils.h
  clang-tidy/utils/HeaderGuard.cpp
  clang-tidy/utils/HeaderGuard.h
  clang-tidy/utils/IncludeInserter.cpp
  clang-tidy/utils/IncludeInserter.h
  clang-tidy/utils/IncludeSorter.cpp
  clang-tidy/utils/IncludeSorter.h
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h

Index: clang-tidy/utils/LexerUtils.h
===
--- clang-tidy/utils/LexerUtils.h
+++ clang-tidy/utils/LexerUtils.h
@@ -15,14 +15,16 @@
 
 namespace clang {
 namespace tidy {
-namespace lexer_utils {
+namespace utils {
+namespace lexer {
 
 // Returns previous non-comment token skipping over any comment text or
 // tok::unknown if not found.
 Token getPreviousNonCommentToken(const ASTContext &Context,
  SourceLocation Location);
 
-} // namespace lexer_utils
+} // namespace lexer
+} // namespace utils
 } // namespace tidy
 } // namespace clang
 
Index: clang-tidy/utils/LexerUtils.cpp
===
--- clang-tidy/utils/LexerUtils.cpp
+++ clang-tidy/utils/LexerUtils.cpp
@@ -11,7 +11,8 @@
 
 namespace clang {
 namespace tidy {
-namespace lexer_utils {
+namespace utils {
+namespace lexer {
 
 Token getPreviousNonCommentToken(const ASTContext &Context,
  SourceLocation Location) {
@@ -34,6 +35,7 @@
   return Token;
 }
 
-} // namespace lexer_utils
+} // namespace lexer
+} // namespace utils
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/utils/IncludeSorter.h
===
--- clang-tidy/utils/IncludeSorter.h
+++ clang-tidy/utils/IncludeSorter.h
@@ -15,6 +15,7 @@
 
 namespace clang {
 namespace tidy {
+namespace utils {  
 
 // Class used by IncludeSorterCallback and IncludeInserterCallback to record the
 // names of the inclusions in a given source file being processed and generate
@@ -83,6 +84,7 @@
   SmallVector IncludeBucket[IK_InvalidInclude];
 };
 
+} // namespace utils
 } // namespace tidy
 } // namespace clang
 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDESORTER_H
Index: clang-tidy/utils/IncludeSorter.cpp
===
--- clang-tidy/utils/IncludeSorter.cpp
+++ clang-tidy/utils/IncludeSorter.cpp
@@ -12,6 +12,7 @@
 
 namespace clang {
 namespace tidy {
+namespace utils {  
 
 namespace {
 
@@ -291,5 +292,6 @@
   return Style == IS_LLVM ? "llvm" : "google";
 }
 
+} // namespace utils
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/utils/IncludeInserter.h
===
--- clang-tidy/utils/IncludeInserter.h
+++ clang-tidy/utils/IncludeInserter.h
@@ -20,6 +20,7 @@
 
 namespace clang {
 namespace tidy {
+namespace utils {
 
 // IncludeInserter can be used by ClangTidyChecks in the following fashion:
 // class MyCheck : public ClangTidyCheck {
@@ -70,6 +71,7 @@
   friend class IncludeInserterCallback;
 };
 
+} // namespace utils
 } // namespace tidy
 } // namespace clang
 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDEINSERTER_H
Index: clang-tidy/utils/IncludeInserter.cpp
===
--- clang-tidy/utils/IncludeInserter.cpp
+++ clang-tidy/utils/IncludeInserter.cpp
@@ -12,6 +12,7 @@
 
 namespace clang {
 namespace tidy {
+namespace utils {
 
 class IncludeInserterCallback : public PPCallbacks {
 public:
@@ -80,5 +81,6 @@
   end_location);
 }
 
+} // namespace utils
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/utils/HeaderGuard.h
===
--- clang-tidy/utils/HeaderGuard.h
+++ clang-tidy/utils/HeaderGuard.h
@@ -14,6 +14,7 @@
 
 namespace clang {
 namespace tidy {
+namespace utils {
 
 /// Finds and fixes header 

Re: [PATCH] D19567: PR21823: 'nodebug' attribute on global/static variables

2016-05-02 Thread David Blaikie via cfe-commits
dblaikie added a comment.

In http://reviews.llvm.org/D19567#414906, @probinson wrote:

> Huh.  There are strange interactions here, which makes me even more nervous 
> about testing fewer cases.


Generally this sort of thing makes me more interested in testing fewer cases so 
we can see/make sure they're properly covering, as you just did by the sounds 
of it. It's hard to see if everything's really covered if there's lots of 
redundant coverage that adds noise to the test case.

> As it happens, the test as written did not exercise all 3 modified paths. 
> Because 'struct S2' had all its members marked with nodebug, none of the 
> static-member references caused debug info for the class as a whole to be 
> attempted.


Not sure I quite follow. Even without nodebug:

  struct foo { static const int x = 3; int y; };
  int i = foo::x;

doesn't produce any debug info for 'foo', x, etc. Just for 'i'.

>   I needed to add a variable of type S2 (without 'nodebug') in order to 
> exercise that path.  Once that was done, then the modification to 
> CollectRecordFields became necessary.

> Even in an unmodified compiler, "static_const_member" never 
> shows up as a DIGlobalVariable, although the other cases all do.  So, testing 
> only for DIGlobalVariable wouldn't be sufficient to show that it gets 
> suppressed by 'nodebug'.


Have you tested cases where the static member is ODR used and/or defined:

  struct foo { static const int x = 3; };
  const int foo::x; // defined
  void sink(void*);
  void use() { sink(&foo::x); } // ODR used

I'm guessing that the out of line definition will create the DIGlobalVariable 
you're not seeing. But probably through a common codepath you've already 
corrected for.

The ODR use probably doesn't cause anything interesting to happen.

>   "static_member" shows up unless we have modified both 
> EmitGlobalVariable(VarDecl case) and CollectRecordFields, given that the test 
> actually tries to emit debug info for S2 as a whole.


I would imagine this could still boil down to: check-not DIGlobalVariable, 
check-not DIFlagStaticMember ?

But once the test is smaller/more targeted, checking the extra details of the 
member list of a composite type, etc, seems OK.

> So, the genuinely most-minimal did-this-change-do-anything test would need 
> only "static_member" and "const_global_int_def" to show that each path had 
> some effect.  This approach does not fill me with warm fuzzies, or the 
> feeling that future changes in this area will not break the intended 
> behavior.  What do you think?

> --paulr



Repository:
  rL LLVM

http://reviews.llvm.org/D19567



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


Re: [PATCH] D19802: Fix a crash in cppcoreguidelines-pro-type-member-init when checking a class that initializes itself as a base

2016-05-02 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM with a commenting request.



Comment at: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp:342
@@ +341,3 @@
+
+template 
+class PositiveSelfInitialization : NegativeAggregateType

hokein wrote:
> aaron.ballman wrote:
> > Is it required to be a templated class to trigger the crash?
> Yes, it's required.
Then some comments in this test would be good, I would assume otherwise from 
just looking at the test.


http://reviews.llvm.org/D19802



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


Re: [PATCH] D19322: Concepts: Create space for requires-clause in TemplateParameterList; NFC

2016-05-02 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast marked 2 inline comments as done.
hubert.reinterpretcast added a comment.

@rsmith; I've addressed Faisal's comment. Please let me know if this patch (and 
http://reviews.llvm.org/D19770) is good to go. If it isn't ready yet, I'd like 
your opinion on http://reviews.llvm.org/D19770+http://reviews.llvm.org/D19771.


http://reviews.llvm.org/D19322



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


[clang-tools-extra] r268264 - [clang-tidy] Cleaning namespaces to be more consistant across checkers.

2016-05-02 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Mon May  2 13:00:29 2016
New Revision: 268264

URL: http://llvm.org/viewvc/llvm-project?rev=268264&view=rev
Log:
[clang-tidy] Cleaning namespaces to be more consistant across checkers.

Summary:
The goal of the patch is to bring checkers in their appropriate namespace.
This path doesn't change any behavior.

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19811

Modified:
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeConstCastCheck.cpp
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeConstCastCheck.h

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.h

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.h

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeUnionAccessCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeUnionAccessCheck.h
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.h
clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.h

clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/IncorrectRoundings.cpp
clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.h
clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.h
clang-tools-extra/trunk/clang-tidy/misc/NewDeleteOverloadsCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h
clang-tools-extra/trunk/clang-tidy/misc/NonCopyableObjects.cpp
clang-tools-extra/trunk/clang-tidy/misc/NonCopyableObjects.h
clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.h
clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.h
clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.h

clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h
clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.h
clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.h
clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.h
clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
clang-tools-extra/trunk/clang-tidy/performance/ImplicitCastInLoopCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.h

clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp

clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-

Re: [PATCH] D19815: Support '#pragma once' in headers when using PCH

2016-05-02 Thread Reid Kleckner via cfe-commits
rnk added a subscriber: rnk.
rnk added a comment.

I think threading this through PP options is reasonable.



Comment at: test/PCH/pragma-once.h:1
@@ +1,2 @@
+#pragma once
+

This should be in test/PCH/Inputs


http://reviews.llvm.org/D19815



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


  1   2   >