[PATCH] D20428: Tracking exception specification source locations

2016-12-30 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

The problem is that when a noexcept(bool expr) specification is invalid, e.g., 
bad bool expr, the NoexceptType in Parser::tryParseExceptionSpecification is 
set to EST_None and returned.  This will mean the FunctionDecl type won't have 
an exception TypeLoc, but the TypeSourceInfo type in 
ASTContext::adjustExceptionSpec will, which will trigger the assert in due to 
different sizes.

The easy fix is to set NoexceptType = EST_BasicNoexcept which will cause all 
tests to pass.  The other option would be to leave it as EST_ComputedNoexcept, 
but that would cause a crash later during template instantiation.

Here's a patch (not sure I can uploade it):

  diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
  index 4002b09..7cfb8d5 100644
  --- a/lib/Parse/ParseDeclCXX.cpp
  +++ b/lib/Parse/ParseDeclCXX.cpp
  @@ -3545,7 +3545,7 @@ Parser::tryParseExceptionSpecification(bool Delayed,
 Actions.CheckBooleanCondition(KeywordLoc, NoexceptExpr.get());
 NoexceptRange = SourceRange(KeywordLoc, T.getCloseLocation());
   } else {
  -  NoexceptType = EST_None;
  +  NoexceptType = EST_BasicNoexcept;
   }
 } else {
   // There is no argument.




https://reviews.llvm.org/D20428



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


[PATCH] D28153: [clang] Fix clean build of generate-order-file

2016-12-30 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290781: [clang] Fix clean build of generate-order-file 
(authored by alexshap).

Changed prior to commit:
  https://reviews.llvm.org/D28153?vs=82715=82755#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28153

Files:
  cfe/trunk/CMakeLists.txt
  cfe/trunk/utils/perf-training/CMakeLists.txt


Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -421,6 +421,29 @@
 endif()
 add_subdirectory(examples)
 
+if(APPLE)
+  # this line is needed as a cleanup to ensure that any CMakeCaches with the 
old
+  # default value get updated to the new default.
+  if(CLANG_ORDER_FILE STREQUAL "")
+unset(CLANG_ORDER_FILE CACHE)
+unset(CLANG_ORDER_FILE)
+  endif()
+
+
+  set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH
+"Order file to use when compiling clang in order to improve startup time 
(Darwin Only - requires ld64).")
+
+  if(NOT EXISTS ${CLANG_ORDER_FILE})
+string(FIND "${CLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START)
+if(PATH_START EQUAL 0)
+  file(WRITE ${CLANG_ORDER_FILE} "\n")
+else()
+  message(FATAL_ERROR "Specified order file '${CLANG_ORDER_FILE}' does not 
exist.")
+endif()
+  endif()
+endif()
+
+
 if( CLANG_INCLUDE_TESTS )
   if(EXISTS 
${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h)
 add_subdirectory(unittests)
@@ -455,29 +478,6 @@
   add_subdirectory(docs)
 endif()
 
-
-if(APPLE)
-  # this line is needed as a cleanup to ensure that any CMakeCaches with the 
old
-  # default value get updated to the new default.
-  if(CLANG_ORDER_FILE STREQUAL "")
-unset(CLANG_ORDER_FILE CACHE)
-unset(CLANG_ORDER_FILE)
-  endif()
-
-
-  set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH
-"Order file to use when compiling clang in order to improve startup time 
(Darwin Only - requires ld64).")
-
-  if(CLANG_ORDER_FILE AND NOT EXISTS ${CLANG_ORDER_FILE})
-string(FIND "${CLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START)
-if(PATH_START EQUAL 0)
-  file(WRITE ${CLANG_ORDER_FILE} "\n")
-else()
-  message(FATAL_ERROR "Specified order file '${CLANG_ORDER_FILE}' does not 
exist.")
-endif()
-  endif()
-endif()
-
 add_subdirectory(cmake/modules)
 
 if(CLANG_STAGE)
Index: cfe/trunk/utils/perf-training/CMakeLists.txt
===
--- cfe/trunk/utils/perf-training/CMakeLists.txt
+++ cfe/trunk/utils/perf-training/CMakeLists.txt
@@ -40,7 +40,7 @@
 endif()
 
 find_program(DTRACE dtrace)
-if(DTRACE)
+if(APPLE AND DTRACE)
   configure_lit_site_cfg(
 ${CMAKE_CURRENT_SOURCE_DIR}/order-files.lit.site.cfg.in
 ${CMAKE_CURRENT_BINARY_DIR}/order-files/lit.site.cfg
@@ -56,6 +56,10 @@
 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR} dtrace
 COMMENT "Clearing old dtrace data")
 
+  if(NOT CLANG_ORDER_FILE)
+message(FATAL_ERROR "Output clang order file is not set")
+  endif()
+
   add_custom_target(generate-order-file
 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
gen-order-file --binary $ --output ${CLANG_ORDER_FILE} 
${CMAKE_CURRENT_BINARY_DIR}
 COMMENT "Generating order file"


Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -421,6 +421,29 @@
 endif()
 add_subdirectory(examples)
 
+if(APPLE)
+  # this line is needed as a cleanup to ensure that any CMakeCaches with the old
+  # default value get updated to the new default.
+  if(CLANG_ORDER_FILE STREQUAL "")
+unset(CLANG_ORDER_FILE CACHE)
+unset(CLANG_ORDER_FILE)
+  endif()
+
+
+  set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH
+"Order file to use when compiling clang in order to improve startup time (Darwin Only - requires ld64).")
+
+  if(NOT EXISTS ${CLANG_ORDER_FILE})
+string(FIND "${CLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START)
+if(PATH_START EQUAL 0)
+  file(WRITE ${CLANG_ORDER_FILE} "\n")
+else()
+  message(FATAL_ERROR "Specified order file '${CLANG_ORDER_FILE}' does not exist.")
+endif()
+  endif()
+endif()
+
+
 if( CLANG_INCLUDE_TESTS )
   if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h)
 add_subdirectory(unittests)
@@ -455,29 +478,6 @@
   add_subdirectory(docs)
 endif()
 
-
-if(APPLE)
-  # this line is needed as a cleanup to ensure that any CMakeCaches with the old
-  # default value get updated to the new default.
-  if(CLANG_ORDER_FILE STREQUAL "")
-unset(CLANG_ORDER_FILE CACHE)
-unset(CLANG_ORDER_FILE)
-  endif()
-
-
-  set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH
-"Order file to use 

r290781 - [clang] Fix clean build of generate-order-file

2016-12-30 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Fri Dec 30 23:25:52 2016
New Revision: 290781

URL: http://llvm.org/viewvc/llvm-project?rev=290781=rev
Log:
[clang] Fix clean build of generate-order-file

This diff fixes the clean build of the target generate-order-file.
In llvm/tools/clang/CMakeLists.txt 
add_subdirectory(utils/perf-training) should go after the block where 
the value of the variable CLANG_ORDER_FILE is set - otherwise 
(tested with cmake's version 3.6.2) the arguments of perf-helper.py 
gen-order-file
will be ill-formed (CLANG_ORDER_FILE will be empty).

Differential revision: https://reviews.llvm.org/D28153

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/utils/perf-training/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=290781=290780=290781=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Dec 30 23:25:52 2016
@@ -421,6 +421,29 @@ else()
 endif()
 add_subdirectory(examples)
 
+if(APPLE)
+  # this line is needed as a cleanup to ensure that any CMakeCaches with the 
old
+  # default value get updated to the new default.
+  if(CLANG_ORDER_FILE STREQUAL "")
+unset(CLANG_ORDER_FILE CACHE)
+unset(CLANG_ORDER_FILE)
+  endif()
+
+
+  set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH
+"Order file to use when compiling clang in order to improve startup time 
(Darwin Only - requires ld64).")
+
+  if(NOT EXISTS ${CLANG_ORDER_FILE})
+string(FIND "${CLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START)
+if(PATH_START EQUAL 0)
+  file(WRITE ${CLANG_ORDER_FILE} "\n")
+else()
+  message(FATAL_ERROR "Specified order file '${CLANG_ORDER_FILE}' does not 
exist.")
+endif()
+  endif()
+endif()
+
+
 if( CLANG_INCLUDE_TESTS )
   if(EXISTS 
${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h)
 add_subdirectory(unittests)
@@ -455,29 +478,6 @@ if( CLANG_INCLUDE_DOCS )
   add_subdirectory(docs)
 endif()
 
-
-if(APPLE)
-  # this line is needed as a cleanup to ensure that any CMakeCaches with the 
old
-  # default value get updated to the new default.
-  if(CLANG_ORDER_FILE STREQUAL "")
-unset(CLANG_ORDER_FILE CACHE)
-unset(CLANG_ORDER_FILE)
-  endif()
-
-
-  set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH
-"Order file to use when compiling clang in order to improve startup time 
(Darwin Only - requires ld64).")
-
-  if(CLANG_ORDER_FILE AND NOT EXISTS ${CLANG_ORDER_FILE})
-string(FIND "${CLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START)
-if(PATH_START EQUAL 0)
-  file(WRITE ${CLANG_ORDER_FILE} "\n")
-else()
-  message(FATAL_ERROR "Specified order file '${CLANG_ORDER_FILE}' does not 
exist.")
-endif()
-  endif()
-endif()
-
 add_subdirectory(cmake/modules)
 
 if(CLANG_STAGE)

Modified: cfe/trunk/utils/perf-training/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/CMakeLists.txt?rev=290781=290780=290781=diff
==
--- cfe/trunk/utils/perf-training/CMakeLists.txt (original)
+++ cfe/trunk/utils/perf-training/CMakeLists.txt Fri Dec 30 23:25:52 2016
@@ -40,7 +40,7 @@ if(LLVM_BUILD_INSTRUMENTED)
 endif()
 
 find_program(DTRACE dtrace)
-if(DTRACE)
+if(APPLE AND DTRACE)
   configure_lit_site_cfg(
 ${CMAKE_CURRENT_SOURCE_DIR}/order-files.lit.site.cfg.in
 ${CMAKE_CURRENT_BINARY_DIR}/order-files/lit.site.cfg
@@ -56,6 +56,10 @@ if(DTRACE)
 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR} dtrace
 COMMENT "Clearing old dtrace data")
 
+  if(NOT CLANG_ORDER_FILE)
+message(FATAL_ERROR "Output clang order file is not set")
+  endif()
+
   add_custom_target(generate-order-file
 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
gen-order-file --binary $ --output ${CLANG_ORDER_FILE} 
${CMAKE_CURRENT_BINARY_DIR}
 COMMENT "Generating order file"


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


r290780 - Remove redundant assertion.

2016-12-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Dec 30 21:33:42 2016
New Revision: 290780

URL: http://llvm.org/viewvc/llvm-project?rev=290780=rev
Log:
Remove redundant assertion.

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

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=290780=290779=290780=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Fri Dec 30 21:33:42 2016
@@ -3244,11 +3244,8 @@ DeduceFromInitializerList(Sema , Templ
 getDeducedParameterFromExpr(Info, ArrTy->getSizeExpr())) {
   // We can perform template argument deduction for the given non-type
   // template parameter.
-  assert(NTTP->getDepth() == 0 &&
- "Cannot deduce non-type template argument at depth > 0");
   llvm::APInt Size(S.Context.getIntWidth(NTTP->getType()),
ILE->getNumInits());
-
   Result = DeduceNonTypeTemplateArgument(
   S, TemplateParams, NTTP, llvm::APSInt(Size), NTTP->getType(),
   /*ArrayBound=*/true, Info, Deduced);


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


r290777 - Typo fix in AST matcher documentation: s/aribtrary/arbitrary/

2016-12-30 Thread James Dennett via cfe-commits
Author: jdennett
Date: Fri Dec 30 19:04:02 2016
New Revision: 290777

URL: http://llvm.org/viewvc/llvm-project?rev=290777=rev
Log:
Typo fix in AST matcher documentation: s/aribtrary/arbitrary/

Modified:
cfe/trunk/docs/LibASTMatchers.rst

Modified: cfe/trunk/docs/LibASTMatchers.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchers.rst?rev=290777=290776=290777=diff
==
--- cfe/trunk/docs/LibASTMatchers.rst (original)
+++ cfe/trunk/docs/LibASTMatchers.rst Fri Dec 30 19:04:02 2016
@@ -103,7 +103,7 @@ you can :ref:`bind ` t
 processing.
 
 ``VariadicDynCastAllOfMatchers`` are callable classes that model variadic
-template functions in C++03.  They take an aribtrary number of
+template functions in C++03.  They take an arbitrary number of
 ``Matcher`` and return a ``Matcher``.
 
 ``AST_MATCHER_P(Type, Name, ParamType, Param)``


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


[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.

2016-12-30 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob updated this revision to Diff 82750.
arpith-jacob added a comment.

Alexey, thank you for your review.  I've updated the patch addressing your 
comments.

- I experimented with various ways of changing the name of the outlined 
function. In the end I decided against moving the two classes to the header 
file.  Instead I pass the name to the class via the constructor.  The name is 
returned by a virtual function.

- I also removed the overloaded implementation of getThreadID().  I'm fine 
using the default implementation.  We do not use the value returned by 
getThreadID() in our runtime and prefer to recompute it using PTX reserved 
registers.


https://reviews.llvm.org/D28145

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  test/OpenMP/nvptx_parallel_codegen.cpp

Index: test/OpenMP/nvptx_parallel_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_parallel_codegen.cpp
@@ -0,0 +1,323 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+template
+tx ftemplate(int n) {
+  tx a = 0;
+  short aa = 0;
+  tx b[10];
+
+  #pragma omp target if(0)
+  {
+#pragma omp parallel
+{
+  int a = 41;
+}
+a += 1;
+  }
+
+  #pragma omp target
+  {
+#pragma omp parallel
+{
+  int a = 42;
+}
+#pragma omp parallel if(0)
+{
+  int a = 43;
+}
+#pragma omp parallel if(1)
+{
+  int a = 44;
+}
+a += 1;
+  }
+
+  #pragma omp target if(n>40)
+  {
+#pragma omp parallel if(n>1000)
+{
+  int a = 45;
+}
+a += 1;
+aa += 1;
+b[2] += 1;
+  }
+
+  return a;
+}
+
+int bar(int n){
+  int a = 0;
+
+  a += ftemplate(n);
+
+  return a;
+}
+
+  // CHECK-NOT: define {{.*}}void {{@__omp_offloading_.+template.+l17}}_worker()
+
+
+
+
+
+
+  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l26}}_worker()
+  // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8,
+  // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*,
+  // CHECK: store i8* null, i8** [[OMP_WORK_FN]],
+  // CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]],
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK: call void @llvm.nvvm.barrier0()
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]])
+  // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
+  // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
+  // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
+  // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i8* [[WORK]], null
+  // CHECK: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]]
+  //
+  // CHECK: [[SEL_WORKERS]]
+  // CHECK: [[ST:%.+]] = load i8, i8* [[OMP_EXEC_STATUS]]
+  // CHECK: [[IS_ACTIVE:%.+]] = icmp ne i8 [[ST]], 0
+  // CHECK: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]]
+  //
+  // CHECK: [[EXEC_PARALLEL]]
+  // CHECK: [[WF1:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
+  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i32*, i32*)* [[PARALLEL_FN1:@.+]] to i8*)
+  // CHECK: br i1 [[WM1]], label {{%?}}[[EXEC_PFN1:.+]], label {{%?}}[[CHECK_NEXT1:.+]]
+  //
+  // CHECK: [[EXEC_PFN1]]
+  // CHECK: call void [[PARALLEL_FN1]](
+  // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+  // CHECK: [[CHECK_NEXT1]]
+  // CHECK: [[WF2:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
+  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i32*, i32*)* [[PARALLEL_FN2:@.+]] to i8*)
+  // CHECK: br i1 [[WM2]], label {{%?}}[[EXEC_PFN2:.+]], label {{%?}}[[CHECK_NEXT2:.+]]
+  //
+  // CHECK: [[EXEC_PFN2]]
+  // CHECK: call void [[PARALLEL_FN2]](
+  // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+  // CHECK: [[CHECK_NEXT2]]
+  // CHECK: br label 

[libcxx] r290775 - random: include __config before building

2016-12-30 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Dec 30 18:00:21 2016
New Revision: 290775

URL: http://llvm.org/viewvc/llvm-project?rev=290775=rev
Log:
random: include __config before building

We need to include __config to ensure that we know what random
implementation is being used.  Fixes compilation for Windows.

Modified:
libcxx/trunk/src/random.cpp

Modified: libcxx/trunk/src/random.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/random.cpp?rev=290775=290774=290775=diff
==
--- libcxx/trunk/src/random.cpp (original)
+++ libcxx/trunk/src/random.cpp Fri Dec 30 18:00:21 2016
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+#include <__config>
+
 #if defined(_LIBCPP_USING_WIN32_RANDOM)
 // Must be defined before including stdlib.h to enable rand_s().
 #define _CRT_RAND_S


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


[PATCH] D28022: [clang-tidy] Handle constructors in performance-unnecessary-value-param

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

LG


https://reviews.llvm.org/D28022



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


[PATCH] D21298: [Clang-tidy] delete null check

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

I've noticed a few more minor issues. Otherwise looks good.

Thank you for the new check!




Comment at: clang-tidy/readability/DeleteNullPointerCheck.cpp:27-38
+  const auto PointerCondition = castExpr(hasCastKind(CK_PointerToBoolean));
+  const auto BinaryPointerCheckCondition =
+  binaryOperator(hasEitherOperand(castExpr(hasCastKind(CK_NullToPointer))),
+ hasEitherOperand(ignoringImpCasts(declRefExpr(;
+
+  Finder->addMatcher(
+  ifStmt(

This can be simplified. Something like this (modulo formatting):

  const auto PointerExpr = 
ignoringImpCasts(declRefExpr(to(decl().bind("deletedPointer";
  const auto PointerCondition = castExpr(hasCastKind(CK_PointerToBoolean), 
hasSourceExpression(PointerExpr));
  const auto BinaryPointerCheckCondition =
  binaryOperator(hasEitherOperand(castExpr(hasCastKind(CK_NullToPointer))),
 hasEitherOperand(PointerExpr));


(and remove the second `hasCondition`).



Comment at: clang-tidy/readability/DeleteNullPointerCheck.cpp:53
+  "'if' statement is unnecessary; deleting null pointer has no effect");
+  if (IfWithDelete->getElse())
+return;

The check can suggest a fix in this case as well, but it's a bit more involved. 
Please add a FIXME.



Comment at: docs/clang-tidy/checks/readability-delete-null-pointer.rst:7
+Checks the 'if' statements where a pointer's existence is checked and then 
deletes the pointer.
+The check is unnecessary as deleting a nullpointer has no effect.
+

alexfh wrote:
> Either `null pointer` or `nullptr` (enclosed in double backquotes).
Sorry for not being clear enough: "null pointer" is not an inline code snippet, 
it shouldn't be enclosed in double backquotes or anything else. The "(enclosed 
in double backquotes)" part was meant to apply to `nullptr` only (since it's a 
keyword and should be highlighted as a code snippet).



Comment at: test/clang-tidy/readability-delete-null-pointer.cpp:8
+
+  // comment that should not be deleted #1
+  if (p) { // comment that should not be deleted #2

The `that should not be deleted` part is superfluous, IMO. You could even leave 
just `// #1`, `// #2`, etc.


https://reviews.llvm.org/D21298



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


Re: r290773 - Wdocumentation fix

2016-12-30 Thread Richard Smith via cfe-commits
On 30 Dec 2016 3:06 pm, "Simon Pilgrim via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

Author: rksimon
Date: Fri Dec 30 16:55:33 2016
New Revision: 290773

URL: http://llvm.org/viewvc/llvm-project?rev=290773=rev
Log:
Wdocumentation fix


Thanks, but please be careful you don't introduce trailing whitespace
changes to unrelated code in the future.

Also perhaps we should turn this warning on by default for regular
selfhosted builds so we don't need to wait for a buildbot to find issues
like this?

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

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
SemaTemplate.cpp?rev=290773=290772=290773=diff

==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Dec 30 16:55:33 2016
@@ -88,14 +88,14 @@ static NamedDecl *isAcceptableTemplateNa
   return nullptr;
 }

-void Sema::FilterAcceptableTemplateNames(LookupResult ,
+void Sema::FilterAcceptableTemplateNames(LookupResult ,
  bool AllowFunctionTemplates) {
   // The set of class templates we've already seen.
   llvm::SmallPtrSet ClassTemplates;
   LookupResult::Filter filter = R.makeFilter();
   while (filter.hasNext()) {
 NamedDecl *Orig = filter.next();
-NamedDecl *Repl = isAcceptableTemplateName(Context, Orig,
+NamedDecl *Repl = isAcceptableTemplateName(Context, Orig,
AllowFunctionTemplates);
 if (!Repl)
   filter.erase();
@@ -131,7 +131,7 @@ bool Sema::hasAnyAcceptableTemplateNames
   for (LookupResult::iterator I = R.begin(), IEnd = R.end(); I != IEnd;
++I)
 if (isAcceptableTemplateName(Context, *I, AllowFunctionTemplates))
   return true;
-
+
   return false;
 }

@@ -265,7 +265,7 @@ void Sema::LookupTemplateName(LookupResu
 assert((isDependent || !ObjectType->isIncompleteType() ||
 ObjectType->castAs()->isBeingDefined()) &&
"Caller should have completed object type");
-
+
 // Template names cannot appear inside an Objective-C class or object
type.
 if (ObjectType->isObjCObjectOrInterfaceType()) {
   Found.clear();
@@ -312,7 +312,7 @@ void Sema::LookupTemplateName(LookupResu
   } else {
 // Perform unqualified name lookup in the current scope.
 LookupName(Found, S);
-
+
 if (!ObjectType.isNull())
   AllowFunctionTemplatesInLookup = false;
   }
@@ -890,7 +890,7 @@ Decl *Sema::ActOnTemplateTemplateParamet
  Depth, Position, IsParameterPack,
  Name, Params);
   Param->setAccess(AS_public);
-
+
   // If the template template parameter has a name, then link the
identifier
   // into the scope and lookup mechanisms.
   if (Name) {
@@ -1020,8 +1020,8 @@ Sema::CheckClassTemplate(Scope *S, unsig
 if (RequireCompleteDeclContext(SS, SemanticContext))
   return true;

-// If we're adding a template to a dependent context, we may need to
-// rebuilding some of the types used within the template parameter
list,
+// If we're adding a template to a dependent context, we may need to
+// rebuilding some of the types used within the template parameter
list,
 // now that we know what the current instantiation is.
 if (SemanticContext->isDependentContext()) {
   ContextRAII SavedContext(*this, SemanticContext);
@@ -1247,10 +1247,10 @@ Sema::CheckClassTemplate(Scope *S, unsig
 DeclarationName(Name), TemplateParams,
 NewClass, PrevClassTemplate);
   NewClass->setDescribedClassTemplate(NewTemplate);
-
+
   if (ModulePrivateLoc.isValid())
 NewTemplate->setModulePrivate();
-
+
   // Build the type for the class template declaration now.
   QualType T = NewTemplate->getInjectedClassNameSpecialization();
   T = Context.getInjectedClassNameType(NewClass, T);
@@ -1341,7 +1341,7 @@ static bool DiagnoseDefaultTemplateArgum
 //   A default template-argument shall not be specified in a
 //   function template declaration or a function template
 //   definition [...]
-//   If a friend function template declaration specifies a default
+//   If a friend function template declaration specifies a default
 //   template-argument, that declaration shall be a definition and
shall be
 //   the only declaration of the function template in the translation
unit.
 // (C++98/03 doesn't have this wording; see DR226).
@@ -1768,10 +1768,10 @@ static SourceRange getRangeOfTypeInNeste
 return NNSLoc.getTypeLoc().getSourceRange();
 } else
   break;
-
+
 NNSLoc = NNSLoc.getPrefix();
   }
-
+
   return SourceRange();
 }

@@ -1814,34 +1814,34 @@ TemplateParameterList *Sema::MatchTempla
 bool , bool ) {
   IsExplicitSpecialization = false;
   Invalid = false;
-
+
   // The sequence of nested 

r290773 - Wdocumentation fix

2016-12-30 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Fri Dec 30 16:55:33 2016
New Revision: 290773

URL: http://llvm.org/viewvc/llvm-project?rev=290773=rev
Log:
Wdocumentation fix

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

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=290773=290772=290773=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Dec 30 16:55:33 2016
@@ -88,14 +88,14 @@ static NamedDecl *isAcceptableTemplateNa
   return nullptr;
 }
 
-void Sema::FilterAcceptableTemplateNames(LookupResult , 
+void Sema::FilterAcceptableTemplateNames(LookupResult ,
  bool AllowFunctionTemplates) {
   // The set of class templates we've already seen.
   llvm::SmallPtrSet ClassTemplates;
   LookupResult::Filter filter = R.makeFilter();
   while (filter.hasNext()) {
 NamedDecl *Orig = filter.next();
-NamedDecl *Repl = isAcceptableTemplateName(Context, Orig, 
+NamedDecl *Repl = isAcceptableTemplateName(Context, Orig,
AllowFunctionTemplates);
 if (!Repl)
   filter.erase();
@@ -131,7 +131,7 @@ bool Sema::hasAnyAcceptableTemplateNames
   for (LookupResult::iterator I = R.begin(), IEnd = R.end(); I != IEnd; ++I)
 if (isAcceptableTemplateName(Context, *I, AllowFunctionTemplates))
   return true;
-  
+
   return false;
 }
 
@@ -265,7 +265,7 @@ void Sema::LookupTemplateName(LookupResu
 assert((isDependent || !ObjectType->isIncompleteType() ||
 ObjectType->castAs()->isBeingDefined()) &&
"Caller should have completed object type");
-
+
 // Template names cannot appear inside an Objective-C class or object type.
 if (ObjectType->isObjCObjectOrInterfaceType()) {
   Found.clear();
@@ -312,7 +312,7 @@ void Sema::LookupTemplateName(LookupResu
   } else {
 // Perform unqualified name lookup in the current scope.
 LookupName(Found, S);
-
+
 if (!ObjectType.isNull())
   AllowFunctionTemplatesInLookup = false;
   }
@@ -890,7 +890,7 @@ Decl *Sema::ActOnTemplateTemplateParamet
  Depth, Position, IsParameterPack,
  Name, Params);
   Param->setAccess(AS_public);
-  
+
   // If the template template parameter has a name, then link the identifier
   // into the scope and lookup mechanisms.
   if (Name) {
@@ -1020,8 +1020,8 @@ Sema::CheckClassTemplate(Scope *S, unsig
 if (RequireCompleteDeclContext(SS, SemanticContext))
   return true;
 
-// If we're adding a template to a dependent context, we may need to 
-// rebuilding some of the types used within the template parameter list, 
+// If we're adding a template to a dependent context, we may need to
+// rebuilding some of the types used within the template parameter list,
 // now that we know what the current instantiation is.
 if (SemanticContext->isDependentContext()) {
   ContextRAII SavedContext(*this, SemanticContext);
@@ -1247,10 +1247,10 @@ Sema::CheckClassTemplate(Scope *S, unsig
 DeclarationName(Name), TemplateParams,
 NewClass, PrevClassTemplate);
   NewClass->setDescribedClassTemplate(NewTemplate);
-  
+
   if (ModulePrivateLoc.isValid())
 NewTemplate->setModulePrivate();
-  
+
   // Build the type for the class template declaration now.
   QualType T = NewTemplate->getInjectedClassNameSpecialization();
   T = Context.getInjectedClassNameType(NewClass, T);
@@ -1341,7 +1341,7 @@ static bool DiagnoseDefaultTemplateArgum
 //   A default template-argument shall not be specified in a
 //   function template declaration or a function template
 //   definition [...]
-//   If a friend function template declaration specifies a default 
+//   If a friend function template declaration specifies a default
 //   template-argument, that declaration shall be a definition and shall be
 //   the only declaration of the function template in the translation unit.
 // (C++98/03 doesn't have this wording; see DR226).
@@ -1768,10 +1768,10 @@ static SourceRange getRangeOfTypeInNeste
 return NNSLoc.getTypeLoc().getSourceRange();
 } else
   break;
-
+
 NNSLoc = NNSLoc.getPrefix();
   }
-  
+
   return SourceRange();
 }
 
@@ -1814,34 +1814,34 @@ TemplateParameterList *Sema::MatchTempla
 bool , bool ) {
   IsExplicitSpecialization = false;
   Invalid = false;
-  
+
   // The sequence of nested types to which we will match up the template
   // parameter lists. We first build this list by starting with the type named
   // by the nested-name-specifier and walking out until we run out of types.
   SmallVector NestedTypes;
   QualType T;
   if (SS.getScopeRep()) {
-if (CXXRecordDecl *Record 
+if 

[PATCH] D28180: Fixing small errors in libAST Matcher Tutorial.

2016-12-30 Thread Mads Ravn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290766: [clang] Minor fix to libASTMatcherTutorial (authored 
by madsravn).

Changed prior to commit:
  https://reviews.llvm.org/D28180?vs=82735=82742#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28180

Files:
  cfe/trunk/docs/LibASTMatchersTutorial.rst


Index: cfe/trunk/docs/LibASTMatchersTutorial.rst
===
--- cfe/trunk/docs/LibASTMatchersTutorial.rst
+++ cfe/trunk/docs/LibASTMatchersTutorial.rst
@@ -496,9 +496,9 @@
 
   void LoopPrinter::run(const MatchFinder::MatchResult ) {
 ASTContext *Context = Result.Context;
-const ForStmt *FS = Result.Nodes.getStmtAs("forLoop");
+const ForStmt *FS = Result.Nodes.getNodeAs("forLoop");
 // We do not want to convert header files!
-if (!FS || 
!Context->getSourceManager().isFromMainFile(FS->getForLoc()))
+if (!FS || 
!Context->getSourceManager().isWrittenInMainFile(FS->getForLoc()))
   return;
 const VarDecl *IncVar = Result.Nodes.getNodeAs("incVarName");
 const VarDecl *CondVar = 
Result.Nodes.getNodeAs("condVarName");


Index: cfe/trunk/docs/LibASTMatchersTutorial.rst
===
--- cfe/trunk/docs/LibASTMatchersTutorial.rst
+++ cfe/trunk/docs/LibASTMatchersTutorial.rst
@@ -496,9 +496,9 @@
 
   void LoopPrinter::run(const MatchFinder::MatchResult ) {
 ASTContext *Context = Result.Context;
-const ForStmt *FS = Result.Nodes.getStmtAs("forLoop");
+const ForStmt *FS = Result.Nodes.getNodeAs("forLoop");
 // We do not want to convert header files!
-if (!FS || !Context->getSourceManager().isFromMainFile(FS->getForLoc()))
+if (!FS || !Context->getSourceManager().isWrittenInMainFile(FS->getForLoc()))
   return;
 const VarDecl *IncVar = Result.Nodes.getNodeAs("incVarName");
 const VarDecl *CondVar = Result.Nodes.getNodeAs("condVarName");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290766 - [clang] Minor fix to libASTMatcherTutorial

2016-12-30 Thread Mads Ravn via cfe-commits
Author: madsravn
Date: Fri Dec 30 14:49:44 2016
New Revision: 290766

URL: http://llvm.org/viewvc/llvm-project?rev=290766=rev
Log:
[clang] Minor fix to libASTMatcherTutorial

There was a small error in the code in the tutorial. The tutorial contains a 
few errors which results in code not being able to compile.

One error was described here: https://llvm.org/bugs/show_bug.cgi?id=25583 .

I found and fixed the error and one additional error.

Reviewers: aaron.ballman, malcolm.parsons

Subscribers: cfe-commits

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

Modified:
cfe/trunk/docs/LibASTMatchersTutorial.rst

Modified: cfe/trunk/docs/LibASTMatchersTutorial.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersTutorial.rst?rev=290766=290765=290766=diff
==
--- cfe/trunk/docs/LibASTMatchersTutorial.rst (original)
+++ cfe/trunk/docs/LibASTMatchersTutorial.rst Fri Dec 30 14:49:44 2016
@@ -496,9 +496,9 @@ And change ``LoopPrinter::run`` to
 
   void LoopPrinter::run(const MatchFinder::MatchResult ) {
 ASTContext *Context = Result.Context;
-const ForStmt *FS = Result.Nodes.getStmtAs("forLoop");
+const ForStmt *FS = Result.Nodes.getNodeAs("forLoop");
 // We do not want to convert header files!
-if (!FS || 
!Context->getSourceManager().isFromMainFile(FS->getForLoc()))
+if (!FS || 
!Context->getSourceManager().isWrittenInMainFile(FS->getForLoc()))
   return;
 const VarDecl *IncVar = Result.Nodes.getNodeAs("incVarName");
 const VarDecl *CondVar = 
Result.Nodes.getNodeAs("condVarName");


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


[PATCH] D28180: Fixing small errors in libAST Matcher Tutorial.

2016-12-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for the documentation fix!


https://reviews.llvm.org/D28180



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


r290762 - CodeGen: use a StringSwitch instead of cascasding ifs

2016-12-30 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Dec 30 12:45:03 2016
New Revision: 290762

URL: http://llvm.org/viewvc/llvm-project?rev=290762=rev
Log:
CodeGen: use a StringSwitch instead of cascasding ifs

Change the cascading ifs to a StringSwitch to simplify the conversion of
the relocation model.  NFC

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

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=290762=290761=290762=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Dec 30 12:45:03 2016
@@ -504,21 +504,14 @@ void EmitAssemblyHelper::CreateTargetMac
 
   // Keep this synced with the equivalent code in tools/driver/cc1as_main.cpp.
   llvm::Optional RM;
-  if (CodeGenOpts.RelocationModel == "static") {
-RM = llvm::Reloc::Static;
-  } else if (CodeGenOpts.RelocationModel == "pic") {
-RM = llvm::Reloc::PIC_;
-  } else if (CodeGenOpts.RelocationModel == "ropi") {
-RM = llvm::Reloc::ROPI;
-  } else if (CodeGenOpts.RelocationModel == "rwpi") {
-RM = llvm::Reloc::RWPI;
-  } else if (CodeGenOpts.RelocationModel == "ropi-rwpi") {
-RM = llvm::Reloc::ROPI_RWPI;
-  } else {
-assert(CodeGenOpts.RelocationModel == "dynamic-no-pic" &&
-   "Invalid PIC model!");
-RM = llvm::Reloc::DynamicNoPIC;
-  }
+  RM = llvm::StringSwitch(CodeGenOpts.RelocationModel)
+   .Case("static", llvm::Reloc::Static)
+   .Case("pic", llvm::Reloc::PIC_)
+   .Case("ropi", llvm::Reloc::ROPI)
+   .Case("rwpi", llvm::Reloc::RWPI)
+   .Case("ropi-rwpi", llvm::Reloc::ROPI_RWPI)
+   .Case("dynamic-no-pic", llvm::Reloc::DynamicNoPIC);
+  assert(RM.hasValue() && "invalid PIC model!");
 
   CodeGenOpt::Level OptLevel = CodeGenOpt::Default;
   switch (CodeGenOpts.OptimizationLevel) {


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


[PATCH] D28180: Fixing small errors in libAST Matcher Tutorial.

2016-12-30 Thread Mads Ravn via Phabricator via cfe-commits
madsravn created this revision.
madsravn added reviewers: aaron.ballman, malcolm.parsons.
madsravn added a subscriber: cfe-commits.

The tutorial contains a few errors which results in code not being able to 
compile.

One error was described here: https://llvm.org/bugs/show_bug.cgi?id=25583 .

I found and fixed the error and one additional error.


https://reviews.llvm.org/D28180

Files:
  docs/LibASTMatchersTutorial.rst


Index: docs/LibASTMatchersTutorial.rst
===
--- docs/LibASTMatchersTutorial.rst
+++ docs/LibASTMatchersTutorial.rst
@@ -496,9 +496,9 @@
 
   void LoopPrinter::run(const MatchFinder::MatchResult ) {
 ASTContext *Context = Result.Context;
-const ForStmt *FS = Result.Nodes.getStmtAs("forLoop");
+const ForStmt *FS = Result.Nodes.getNodeAs("forLoop");
 // We do not want to convert header files!
-if (!FS || 
!Context->getSourceManager().isFromMainFile(FS->getForLoc()))
+if (!FS || 
!Context->getSourceManager().isWrittenInMainFile(FS->getForLoc()))
   return;
 const VarDecl *IncVar = Result.Nodes.getNodeAs("incVarName");
 const VarDecl *CondVar = 
Result.Nodes.getNodeAs("condVarName");


Index: docs/LibASTMatchersTutorial.rst
===
--- docs/LibASTMatchersTutorial.rst
+++ docs/LibASTMatchersTutorial.rst
@@ -496,9 +496,9 @@
 
   void LoopPrinter::run(const MatchFinder::MatchResult ) {
 ASTContext *Context = Result.Context;
-const ForStmt *FS = Result.Nodes.getStmtAs("forLoop");
+const ForStmt *FS = Result.Nodes.getNodeAs("forLoop");
 // We do not want to convert header files!
-if (!FS || !Context->getSourceManager().isFromMainFile(FS->getForLoc()))
+if (!FS || !Context->getSourceManager().isWrittenInMainFile(FS->getForLoc()))
   return;
 const VarDecl *IncVar = Result.Nodes.getNodeAs("incVarName");
 const VarDecl *CondVar = Result.Nodes.getNodeAs("condVarName");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27068: Improve string::find

2016-12-30 Thread Sebastian Pop via Phabricator via cfe-commits
sebpop added a comment.

In https://reviews.llvm.org/D27068#632685, @EricWF wrote:

> Holy crap those improvements are impressive.


You're welcome.

> This LGTM. I'm assuming @mclow.lists has nothing left to say about this.

Thanks for your review and LGTM.
I addressed your last comment, added some more comments, tested on 
x86_64-linux, and committed.


Repository:
  rL LLVM

https://reviews.llvm.org/D27068



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


[PATCH] D21298: [Clang-tidy] delete null check

2016-12-30 Thread Gergely Angeli via Phabricator via cfe-commits
SilverGeri updated this revision to Diff 82732.
SilverGeri added a comment.

remove redundant `allOf` statements;
refactor test's comment checking part


https://reviews.llvm.org/D21298

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/DeleteNullPointerCheck.cpp
  clang-tidy/readability/DeleteNullPointerCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-delete-null-pointer.rst
  test/clang-tidy/readability-delete-null-pointer.cpp

Index: test/clang-tidy/readability-delete-null-pointer.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-delete-null-pointer.cpp
@@ -0,0 +1,76 @@
+// RUN: %check_clang_tidy %s readability-delete-null-pointer %t
+
+#define NULL 0
+
+void f() {
+  int *p = 0;
+
+  // comment that should not be deleted #1
+  if (p) { // comment that should not be deleted #2
+delete p;
+  } // comment that should not be deleted #3
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer]
+
+  // CHECK-FIXES: {{^  }}// comment that should not be deleted #1
+  // CHECK-FIXES-NEXT: {{^  }}// comment that should not be deleted #2
+  // CHECK-FIXES-NEXT: delete p;
+  // CHECK-FIXES-NEXT: {{^  }}// comment that should not be deleted #3
+
+  int *p2 = new int[3];
+  // comment that should not be deleted #4
+  if (p2) // comment that should not be deleted #5
+delete[] p2;
+  // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: 'if' statement is unnecessary;
+
+  // CHECK-FIXES: // comment that should not be deleted #4
+  // CHECK-FIXES-NEXT: {{^  }}// comment that should not be deleted #5
+  // CHECK-FIXES-NEXT: delete[] p2;
+
+  int *p3 = 0;
+  if (NULL != p3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary;
+delete p3;
+  }
+  // CHECK-FIXES-NOT: if (NULL != p3) {
+  // CHECK-FIXES: delete p3;
+
+  int *p4 = nullptr;
+  if (p4 != nullptr) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary;
+delete p4;
+  }
+  // CHECK-FIXES-NOT: if (p4 != nullptr) {
+  // CHECK-FIXES: delete p4;
+
+  char *c;
+  if (c != 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary;
+delete c;
+  }
+  // CHECK-FIXES-NOT: if (c != 0) {
+  // CHECK-FIXES: delete c;
+
+  char *c2;
+  if (c2) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary;
+// CHECK-FIXES: } else {
+// CHECK-FIXES: c2 = c;
+delete c2;
+  } else {
+c2 = c;
+  }
+}
+
+void g() {
+  int *p5, *p6;
+  if (p5)
+delete p6;
+
+  if (p5 && p6)
+delete p5;
+
+  if (p6) {
+int x = 5;
+delete p6;
+  }
+}
Index: docs/clang-tidy/checks/readability-delete-null-pointer.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-delete-null-pointer.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - readability-delete-null-pointer
+
+readability-delete-null-pointer
+===
+
+Checks the ``if`` statements where a pointer's existence is checked and then deletes the pointer.
+The check is unnecessary as deleting a ``null pointer`` has no effect.
+
+.. code:: c++
+
+  int *p;
+  if (p)
+delete p;
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -127,6 +127,7 @@
readability-avoid-const-params-in-decls
readability-braces-around-statements
readability-container-size-empty
+   readability-delete-null-pointer
readability-deleted-default
readability-else-after-return
readability-function-size
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -13,6 +13,7 @@
 #include "AvoidConstParamsInDecls.h"
 #include "BracesAroundStatementsCheck.h"
 #include "ContainerSizeEmptyCheck.h"
+#include "DeleteNullPointerCheck.h"
 #include "DeletedDefaultCheck.h"
 #include "ElseAfterReturnCheck.h"
 #include "FunctionSizeCheck.h"
@@ -45,6 +46,8 @@
 "readability-braces-around-statements");
 CheckFactories.registerCheck(
 "readability-container-size-empty");
+CheckFactories.registerCheck(
+"readability-delete-null-pointer");
 CheckFactories.registerCheck(
 "readability-deleted-default");
 CheckFactories.registerCheck(
Index: clang-tidy/readability/DeleteNullPointerCheck.h
===
--- /dev/null
+++ clang-tidy/readability/DeleteNullPointerCheck.h
@@ -0,0 +1,35 @@
+//===--- DeleteNullPointerCheck.h - clang-tidy---*- C++ -*-===//
+//
+// 

[PATCH] D27068: Improve string::find

2016-12-30 Thread Sebastian Pop via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290761: improve performance of string::find (authored by 
spop).

Changed prior to commit:
  https://reviews.llvm.org/D27068?vs=80134=82731#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27068

Files:
  libcxx/trunk/benchmarks/string.bench.cpp
  libcxx/trunk/include/__string

Index: libcxx/trunk/include/__string
===
--- libcxx/trunk/include/__string
+++ libcxx/trunk/include/__string
@@ -538,19 +538,59 @@
 return static_cast<_SizeT>(__r - __p);
 }
 
+template 
+inline _LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT *
+__search_substring(const _CharT *__first1, const _CharT *__last1,
+   const _CharT *__first2, const _CharT *__last2) {
+  // Take advantage of knowing source and pattern lengths.
+  // Stop short when source is smaller than pattern.
+  const ptrdiff_t __len2 = __last2 - __first2;
+  if (__len2 == 0)
+return __first1;
+
+  ptrdiff_t __len1 = __last1 - __first1;
+  if (__len1 < __len2)
+return __last1;
+
+  // First element of __first2 is loop invariant.
+  _CharT __f2 = *__first2;
+  while (true) {
+__len1 = __last1 - __first1;
+// Check whether __first1 still has at least __len2 bytes.
+if (__len1 < __len2)
+  return __last1;
+
+// Find __f2 the first byte matching in __first1.
+__first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);
+if (__first1 == 0)
+  return __last1;
+
+// It is faster to compare from the first byte of __first1 even if we
+// already know that it matches the first byte of __first2: this is because
+// __first2 is most likely aligned, as it is user's "pattern" string, and
+// __first1 + 1 is most likely not aligned, as the match is in the middle of
+// the string.
+if (_Traits::compare(__first1, __first2, __len2) == 0)
+  return __first1;
+
+++__first1;
+  }
+}
+
 template
 inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 __str_find(const _CharT *__p, _SizeT __sz, 
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
 {
-if (__pos > __sz || __sz - __pos < __n)
+if (__pos > __sz)
 return __npos;
-if (__n == 0)
+
+if (__n == 0) // There is nothing to search, just return __pos.
 return __pos;
-const _CharT* __r = 
-_VSTD::__search(__p + __pos, __p + __sz,
-__s, __s + __n, _Traits::eq,
-random_access_iterator_tag(), random_access_iterator_tag()).first;
+
+const _CharT *__r = __search_substring<_CharT, _Traits>(
+__p + __pos, __p + __sz, __s, __s + __n);
+
 if (__r == __p + __sz)
 return __npos;
 return static_cast<_SizeT>(__r - __p);
Index: libcxx/trunk/benchmarks/string.bench.cpp
===
--- libcxx/trunk/benchmarks/string.bench.cpp
+++ libcxx/trunk/benchmarks/string.bench.cpp
@@ -0,0 +1,49 @@
+#include 
+#include 
+#include 
+
+#include "benchmark/benchmark_api.h"
+#include "GenerateInput.hpp"
+
+constexpr std::size_t MAX_STRING_LEN = 8 << 14;
+
+// Benchmark when there is no match.
+static void BM_StringFindNoMatch(benchmark::State ) {
+  std::string s1(state.range(0), '-');
+  std::string s2(8, '*');
+  while (state.KeepRunning())
+benchmark::DoNotOptimize(s1.find(s2));
+}
+BENCHMARK(BM_StringFindNoMatch)->Range(10, MAX_STRING_LEN);
+
+// Benchmark when the string matches first time.
+static void BM_StringFindAllMatch(benchmark::State ) {
+  std::string s1(MAX_STRING_LEN, '-');
+  std::string s2(state.range(0), '-');
+  while (state.KeepRunning())
+benchmark::DoNotOptimize(s1.find(s2));
+}
+BENCHMARK(BM_StringFindAllMatch)->Range(1, MAX_STRING_LEN);
+
+// Benchmark when the string matches somewhere in the end.
+static void BM_StringFindMatch1(benchmark::State ) {
+  std::string s1(MAX_STRING_LEN / 2, '*');
+  s1 += std::string(state.range(0), '-');
+  std::string s2(state.range(0), '-');
+  while (state.KeepRunning())
+benchmark::DoNotOptimize(s1.find(s2));
+}
+BENCHMARK(BM_StringFindMatch1)->Range(1, MAX_STRING_LEN / 4);
+
+// Benchmark when the string matches somewhere from middle to the end.
+static void BM_StringFindMatch2(benchmark::State ) {
+  std::string s1(MAX_STRING_LEN / 2, '*');
+  s1 += std::string(state.range(0), '-');
+  s1 += std::string(state.range(0), '*');
+  std::string s2(state.range(0), '-');
+  while (state.KeepRunning())
+benchmark::DoNotOptimize(s1.find(s2));
+}
+BENCHMARK(BM_StringFindMatch2)->Range(1, MAX_STRING_LEN / 4);
+
+BENCHMARK_MAIN()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r290761 - improve performance of string::find

2016-12-30 Thread Sebastian Pop via cfe-commits
Author: spop
Date: Fri Dec 30 12:01:36 2016
New Revision: 290761

URL: http://llvm.org/viewvc/llvm-project?rev=290761=rev
Log:
improve performance of string::find

string::find used to call the generic algorithm ::find.  The patch special
case string::find such that it ultimately gets converted to calls to memchr
and memcmp.

The patch improves the performance of the string::find routine by about 20x.

Without the patch, the performance on an x86_64-linux 3400 MHz machine is:

Benchmark   Time   CPU Iterations
-
BM_StringFindNoMatch/10 4 ns  4 ns  166421326
BM_StringFindNoMatch/6437 ns 37 ns   18754392
BM_StringFindNoMatch/512  268 ns268 ns2586060
BM_StringFindNoMatch/4k  2143 ns   2144 ns 328342
BM_StringFindNoMatch/32k16910 ns  16917 ns  40623
BM_StringFindNoMatch/128k   67577 ns  67602 ns  10138
BM_StringFindAllMatch/1 3 ns  3 ns  265163471
BM_StringFindAllMatch/8 6 ns  6 ns  112582467
BM_StringFindAllMatch/64   36 ns 36 ns   19566457
BM_StringFindAllMatch/512 209 ns209 ns3318893
BM_StringFindAllMatch/4k 1618 ns   1618 ns 432963
BM_StringFindAllMatch/32k   12909 ns  12914 ns  54317
BM_StringFindAllMatch/128k  48342 ns  48361 ns  13922
BM_StringFindMatch1/1   33777 ns  33790 ns  20698
BM_StringFindMatch1/8   33940 ns  33953 ns  20619
BM_StringFindMatch1/64  34038 ns  34051 ns  20571
BM_StringFindMatch1/512 34217 ns  34230 ns  20480
BM_StringFindMatch1/4k  35510 ns  35524 ns  19752
BM_StringFindMatch1/32k 46438 ns  46456 ns  15030
BM_StringFindMatch2/1   33839 ns  33852 ns  20648
BM_StringFindMatch2/8   33950 ns  33963 ns  20594
BM_StringFindMatch2/64  33846 ns  33859 ns  20668
BM_StringFindMatch2/512 34023 ns  34036 ns  20279
BM_StringFindMatch2/4k  35422 ns  35436 ns  19716
BM_StringFindMatch2/32k 46570 ns  46588 ns  15027

With the patch applied

Benchmark   Time   CPU Iterations
-
BM_StringFindNoMatch/10 5 ns  5 ns  133724346
BM_StringFindNoMatch/64 6 ns  6 ns  119312184
BM_StringFindNoMatch/512   13 ns 13 ns   51539628
BM_StringFindNoMatch/4k77 ns 77 ns8935934
BM_StringFindNoMatch/32k  551 ns551 ns1222808
BM_StringFindNoMatch/128k2684 ns   2685 ns 259957
BM_StringFindAllMatch/1 7 ns  7 ns   98017959
BM_StringFindAllMatch/8 7 ns  7 ns   91466911
BM_StringFindAllMatch/648 ns  8 ns   85707392
BM_StringFindAllMatch/512  20 ns 20 ns   34490895
BM_StringFindAllMatch/4k   93 ns 93 ns7360375
BM_StringFindAllMatch/32k 827 ns828 ns 829944
BM_StringFindAllMatch/128k   3593 ns   3594 ns 195815
BM_StringFindMatch1/11332 ns   1332 ns 516354
BM_StringFindMatch1/81336 ns   1336 ns 495876
BM_StringFindMatch1/64   1338 ns   1339 ns 516656
BM_StringFindMatch1/512  1357 ns   1357 ns 510717
BM_StringFindMatch1/4k   1485 ns   1486 ns 461228
BM_StringFindMatch1/32k  2235 ns   2236 ns 318253
BM_StringFindMatch2/11335 ns   1335 ns 517105
BM_StringFindMatch2/81336 ns   1337 ns 518004
BM_StringFindMatch2/64   1344 ns   1345 ns 511751
BM_StringFindMatch2/512  1361 ns   1361 ns 508150
BM_StringFindMatch2/4k   1611 ns   1611 ns 463388
BM_StringFindMatch2/32k  2187 ns   2187 ns 317532

Patch written by Aditya Kumar and Sebastian Pop.

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

Added:
libcxx/trunk/benchmarks/string.bench.cpp
Modified:
libcxx/trunk/include/__string

Added: libcxx/trunk/benchmarks/string.bench.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/string.bench.cpp?rev=290761=auto
==
--- libcxx/trunk/benchmarks/string.bench.cpp (added)
+++ libcxx/trunk/benchmarks/string.bench.cpp Fri Dec 30 12:01:36 2016
@@ -0,0 +1,49 @@
+#include 
+#include 
+#include 
+
+#include "benchmark/benchmark_api.h"
+#include "GenerateInput.hpp"
+
+constexpr std::size_t MAX_STRING_LEN = 8 << 14;
+
+// Benchmark when there is no match.
+static void BM_StringFindNoMatch(benchmark::State ) {
+  std::string s1(state.range(0), '-');
+  std::string s2(8, '*');
+  while (state.KeepRunning())
+

[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)

2016-12-30 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D26796#632602, @compnerd wrote:

> This would need an upgrade path, since the output name can actually be 
> different from the `AchTypeName` (e.g. i386 vs i686).


I was considering committing this alongside with the i686 removal, and assuming 
that people are going to upgrade clang and compiler-rt in lockstep. Is there 
any other case that needs explicit consideration? Do you have another 
suggestion on handling this?


https://reviews.llvm.org/D26796



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


[libcxx] r290758 - Fix some 'FIXME's in the tests.

2016-12-30 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Fri Dec 30 11:42:11 2016
New Revision: 290758

URL: http://llvm.org/viewvc/llvm-project?rev=290758=rev
Log:
Fix some 'FIXME's in the tests.

Modified:

libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pred.pass.cpp

libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/pred.pass.cpp

libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/hash.pred.pass.cpp

libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/pred.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pred.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pred.pass.cpp?rev=290758=290757=290758=diff
==
--- 
libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pred.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pred.pass.cpp
 Fri Dec 30 11:42:11 2016
@@ -54,13 +54,13 @@ unsigned count_equal::count = 0;
 
 template 
 void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result, unsigned 
max_count) {
-count_equal::count = 0;
 std::experimental::boyer_moore_searcher::type>,
  count_equal>
   s{b2, e2};
-assert(count_equal::count <= max_count);
+count_equal::count = 0;
 assert(result == std::experimental::search(b1, e1, s));
+assert(count_equal::count <= max_count);
 }
 
 template 
@@ -81,8 +81,7 @@ test()
 do_search(Iter1(ia), Iter1(ia+sa),   Iter2(ia),  Iter2(ia+sa), 
Iter1(ia),  sa*sa);
 do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia),  Iter2(ia+sa), 
Iter1(ia+sa-1), (sa-1)*sa);
 
-// FIXME: The max_count for this search should be 'sa'
-do_search(Iter1(ia), Iter1(ia+1),Iter2(ia),  Iter2(ia+sa), 
Iter1(ia+1), sa * 2);
+do_search(Iter1(ia), Iter1(ia+1),Iter2(ia),  Iter2(ia+sa), 
Iter1(ia+1), sa);
 
 int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4};
 const unsigned sb = sizeof(ib)/sizeof(ib[0]);
@@ -119,8 +118,7 @@ test2()
 do_search(Iter1(ia), Iter1(ia+sa),   Iter2(ia),  Iter2(ia+sa), 
Iter1(ia),  sa*sa);
 do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia),  Iter2(ia+sa), 
Iter1(ia+sa-1), (sa-1)*sa);
 
-// FIXME: The max_count for this search should be 'sa'
-do_search(Iter1(ia), Iter1(ia+1),Iter2(ia),  Iter2(ia+sa), 
Iter1(ia+1),sa * 2);
+do_search(Iter1(ia), Iter1(ia+1),Iter2(ia),  Iter2(ia+sa), 
Iter1(ia+1),sa);
 
 char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4};
 const unsigned sb = sizeof(ib)/sizeof(ib[0]);

Modified: 
libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/pred.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/pred.pass.cpp?rev=290758=290757=290758=diff
==
--- 
libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/pred.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/pred.pass.cpp
 Fri Dec 30 11:42:11 2016
@@ -75,8 +75,7 @@ test()
 do_search(Iter1(ia), Iter1(ia+sa),   Iter2(ia),  Iter2(ia+sa), 
Iter1(ia),  sa*sa);
 do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia),  Iter2(ia+sa), 
Iter1(ia+sa-1), (sa-1)*sa);
 
-// FIXME: The max_count for this search should be 'sa'
-do_search(Iter1(ia), Iter1(ia+1),Iter2(ia),  Iter2(ia+sa), 
Iter1(ia+1),sa * 2);
+do_search(Iter1(ia), Iter1(ia+1),Iter2(ia),  Iter2(ia+sa), 
Iter1(ia+1),sa);
 
 int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4};
 const unsigned sb = sizeof(ib)/sizeof(ib[0]);
@@ -111,8 +110,7 @@ test2()
 do_search(Iter1(ia), Iter1(ia+sa),   Iter2(ia+sa-3), Iter2(ia+sa), 
Iter1(ia+sa-3), 3*sa);
 do_search(Iter1(ia), Iter1(ia+sa),   Iter2(ia),  Iter2(ia+sa), 
Iter1(ia),  sa*sa);
 do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia),  Iter2(ia+sa), 
Iter1(ia+sa-1), (sa-1)*sa);
-// FIXME: The max_count for this search should be 'sa'
-do_search(Iter1(ia), Iter1(ia+1),Iter2(ia),  Iter2(ia+sa), 
Iter1(ia+1),sa*2);
+do_search(Iter1(ia), Iter1(ia+1),Iter2(ia),  Iter2(ia+sa), 
Iter1(ia+1),sa);
 char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4};
 const unsigned sb = sizeof(ib)/sizeof(ib[0]);
 char ic[] = {1};

Modified: 
libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/hash.pred.pass.cpp
URL: 

[clang-tools-extra] r290756 - [clang-tidy] google-explicit-constructor: ignore macros

2016-12-30 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Dec 30 09:15:14 2016
New Revision: 290756

URL: http://llvm.org/viewvc/llvm-project?rev=290756=rev
Log:
[clang-tidy] google-explicit-constructor: ignore macros

Modified:
clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp?rev=290756=290755=290756=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp Fri 
Dec 30 09:15:14 2016
@@ -89,6 +89,10 @@ void ExplicitConstructorCheck::check(con
   if (const auto *Conversion =
   Result.Nodes.getNodeAs("conversion")) {
 SourceLocation Loc = Conversion->getLocation();
+// Ignore all macros until we learn to ignore specific ones (e.g. used in
+// gmock to define matchers).
+if (Loc.isMacroID())
+  return;
 diag(Loc, WarningMessage)
 << Conversion << FixItHint::CreateInsertion(Loc, "explicit ");
 return;

Modified: 
clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp?rev=290756=290755=290756=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp Fri 
Dec 30 09:15:14 2016
@@ -168,5 +168,11 @@ void f2() {
   if (b) {}
   (void)(F*)b;
   (void)(F*)b;
-
 }
+
+#define DEFINE_STRUCT_WITH_OPERATOR_BOOL(name) \
+  struct name {\
+operator bool() const; \
+  }
+
+DEFINE_STRUCT_WITH_OPERATOR_BOOL(H);


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


[PATCH] D22584: constexpr array support C++1z (P0031)

2016-12-30 Thread Jason Turner via Phabricator via cfe-commits
lefticus marked an inline comment as done.
lefticus added a subscriber: EricFowler.
lefticus added a comment.

@EricFowler I have too many other things going on right now to be able to look 
at it for at least the next few months.


https://reviews.llvm.org/D22584



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


[libcxx] r290754 - Recommit r290750: Fix PR19460 - std::ios is convertible to int.

2016-12-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Dec 30 08:05:52 2016
New Revision: 290754

URL: http://llvm.org/viewvc/llvm-project?rev=290754=rev
Log:
Recommit r290750: Fix PR19460 - std::ios is convertible to int.

There were two problems with the initial fix.

1. The added tests flushed out that we misconfigured _LIBCPP_EXPLICIT with GCC.

2. Because the boolean type was a member function template it caused weird link
   errors. I'm assuming due to the vague linkage rules. This time the bool type
   is a non-template member function pointer. That seems to have fixed the
   failing tests. Plus it will end up generating less symbols overall, since
   the bool type is no longer per instantiation.

original commit message below
-

std::basic_ios has an operator bool(). In C++11 and later
it is explicit, and only allows contextual implicit conversions.

However explicit isn't available in C++03 which causes std::istream (et al)
to have an implicit conversion to int. This can easily cause ambiguities
when calling operator<< and operator>>.

This patch uses a "bool-like" type in C++03 to work around this. The
"bool-like" type is an arbitrary pointer to member function type. It
will not convert to either int or void*, but will convert to bool.

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/ios

libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=290754=290753=290754=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Dec 30 08:05:52 2016
@@ -727,7 +727,8 @@ template  struct __static_asse
 #define _NOALIAS
 #endif
 
-#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__)
+#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
+(!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC 
versions
 #   define _LIBCPP_EXPLICIT explicit
 #else
 #   define _LIBCPP_EXPLICIT

Modified: libcxx/trunk/include/ios
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ios?rev=290754=290753=290754=diff
==
--- libcxx/trunk/include/ios (original)
+++ libcxx/trunk/include/ios Fri Dec 30 08:05:52 2016
@@ -572,6 +572,13 @@ ios_base::exceptions(iostate __iostate)
 clear(__rdstate_);
 }
 
+#if defined(_LIBCPP_CXX03_LANG)
+struct _LIBCPP_TYPE_VIS_ONLY __cxx03_bool {
+  typedef void (__cxx03_bool::*__bool_type)();
+  void __true_value() {}
+};
+#endif
+
 template 
 class _LIBCPP_TYPE_VIS_ONLY basic_ios
 : public ios_base
@@ -585,9 +592,19 @@ public:
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
 
+  // __true_value will generate undefined references when linking unless
+  // we give it internal linkage.
+
+#if defined(_LIBCPP_CXX03_LANG)
 _LIBCPP_ALWAYS_INLINE
-_LIBCPP_EXPLICIT
-operator bool() const {return !fail();}
+operator __cxx03_bool::__bool_type() const {
+return !fail() ? &__cxx03_bool::__true_value : nullptr;
+}
+#else
+_LIBCPP_ALWAYS_INLINE
+_LIBCPP_EXPLICIT operator bool() const {return !fail();}
+#endif
+
 _LIBCPP_ALWAYS_INLINE bool operator!() const{return  fail();}
 _LIBCPP_ALWAYS_INLINE iostate rdstate() const   {return 
ios_base::rdstate();}
 _LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) 
{ios_base::clear(__state);}

Modified: 
libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp?rev=290754=290753=290754=diff
==
--- 
libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
 Fri Dec 30 08:05:52 2016
@@ -14,12 +14,21 @@
 // operator unspecified-bool-type() const;
 
 #include 
+#include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 std::ios ios(0);
 assert(static_cast(ios) == !ios.fail());
 ios.setstate(std::ios::failbit);
 assert(static_cast(ios) == !ios.fail());
+static_assert((!std::is_convertible::value), "");
+static_assert((!std::is_convertible::value), "");
+static_assert((!std::is_convertible::value), "");
+#if TEST_STD_VER >= 11
+static_assert((!std::is_convertible::value), "");
+#endif
 }


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


[clang-tools-extra] r290753 - [clang-tidy] google-explicit-constructor: ignore template instantiations

2016-12-30 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Dec 30 07:25:03 2016
New Revision: 290753

URL: http://llvm.org/viewvc/llvm-project?rev=290753=rev
Log:
[clang-tidy] google-explicit-constructor: ignore template instantiations

Modified:
clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp?rev=290753=290752=290753=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp Fri 
Dec 30 07:25:03 2016
@@ -27,8 +27,10 @@ void ExplicitConstructorCheck::registerM
   Finder->addMatcher(cxxConstructorDecl(unless(isInstantiated())).bind("ctor"),
  this);
   Finder->addMatcher(
-  cxxConversionDecl(unless(isExplicit()), // Already marked explicit.
-unless(isImplicit())) // Compiler-generated.
+  cxxConversionDecl(unless(anyOf(isExplicit(), // Already marked explicit.
+ isImplicit(), // Compiler-generated.
+ isInstantiated(
+
   .bind("conversion"),
   this);
 }

Modified: 
clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp?rev=290753=290752=290753=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp Fri 
Dec 30 07:25:03 2016
@@ -138,3 +138,35 @@ void f(std::initializer_list list)
   E e(list);
   E e2(list);
 }
+
+template 
+struct F {};
+
+template
+struct G {
+  operator bool() const;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator bool' must be marked
+  // CHECK-FIXES: {{^}}  explicit operator bool() const;
+  operator F() const;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator F' 
must be marked
+  // CHECK-FIXES: {{^}}  explicit operator F() const;
+  template
+  operator F*() const;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator F 
*' must be marked
+  // CHECK-FIXES: {{^}}  explicit operator F*() const;
+};
+
+void f2() {
+  G a;
+  (void)(F)a;
+  if (a) {}
+  (void)(F*)a;
+  (void)(F*)a;
+
+  G b;
+  (void)(F)b;
+  if (b) {}
+  (void)(F*)b;
+  (void)(F*)b;
+
+}


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


[libcxx] r290752 - Revert r290750 - Fix PR19460 - std::ios is convertible to int.

2016-12-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Dec 30 07:11:17 2016
New Revision: 290752

URL: http://llvm.org/viewvc/llvm-project?rev=290752=rev
Log:
Revert r290750 - Fix PR19460 - std::ios is convertible to int.

Modified:
libcxx/trunk/include/ios

libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp

Modified: libcxx/trunk/include/ios
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ios?rev=290752=290751=290752=diff
==
--- libcxx/trunk/include/ios (original)
+++ libcxx/trunk/include/ios Fri Dec 30 07:11:17 2016
@@ -585,22 +585,9 @@ public:
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
 
-#if defined(_LIBCPP_CXX03_LANG)
-private:
-struct __bool_tag {};
-typedef void (basic_ios::*_BoolType)(__bool_tag) const;
-void __true_value(__bool_tag) const {}
-
-public:
-_LIBCPP_ALWAYS_INLINE
-operator _BoolType() const {
-return !fail() ? _ios::__true_value : nullptr;
-}
-#else
 _LIBCPP_ALWAYS_INLINE
-_LIBCPP_EXPLICIT operator bool() const {return !fail();}
-#endif
-
+_LIBCPP_EXPLICIT
+operator bool() const {return !fail();}
 _LIBCPP_ALWAYS_INLINE bool operator!() const{return  fail();}
 _LIBCPP_ALWAYS_INLINE iostate rdstate() const   {return 
ios_base::rdstate();}
 _LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) 
{ios_base::clear(__state);}

Modified: 
libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp?rev=290752=290751=290752=diff
==
--- 
libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
 Fri Dec 30 07:11:17 2016
@@ -14,21 +14,12 @@
 // operator unspecified-bool-type() const;
 
 #include 
-#include 
 #include 
 
-#include "test_macros.h"
-
 int main()
 {
 std::ios ios(0);
 assert(static_cast(ios) == !ios.fail());
 ios.setstate(std::ios::failbit);
 assert(static_cast(ios) == !ios.fail());
-static_assert((!std::is_convertible::value), "");
-static_assert((!std::is_convertible::value), "");
-static_assert((!std::is_convertible::value), "");
-#if TEST_STD_VER >= 11
-static_assert((!std::is_convertible::value), "");
-#endif
 }


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


[libcxx] r290750 - Fix PR19460 - std::ios is convertible to int.

2016-12-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Dec 30 06:44:58 2016
New Revision: 290750

URL: http://llvm.org/viewvc/llvm-project?rev=290750=rev
Log:
Fix PR19460 - std::ios is convertible to int.

std::basic_ios has an operator bool(). In C++11 and later
it is explicit, and only allows contextual implicit conversions.

However explicit isn't available in C++03 which causes std::istream (et al)
to have an implicit conversion to int. This can easily cause ambiguities
when calling operator<< and operator>>.

This patch uses a "bool-like" type in C++03 to work around this. The
"bool-like" type is an arbitrary pointer to member function type. It
will not convert to either int or void*, but will convert to bool.

Modified:
libcxx/trunk/include/ios

libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp

Modified: libcxx/trunk/include/ios
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ios?rev=290750=290749=290750=diff
==
--- libcxx/trunk/include/ios (original)
+++ libcxx/trunk/include/ios Fri Dec 30 06:44:58 2016
@@ -585,9 +585,22 @@ public:
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
 
+#if defined(_LIBCPP_CXX03_LANG)
+private:
+struct __bool_tag {};
+typedef void (basic_ios::*_BoolType)(__bool_tag) const;
+void __true_value(__bool_tag) const {}
+
+public:
+_LIBCPP_ALWAYS_INLINE
+operator _BoolType() const {
+return !fail() ? _ios::__true_value : nullptr;
+}
+#else
 _LIBCPP_ALWAYS_INLINE
-_LIBCPP_EXPLICIT
-operator bool() const {return !fail();}
+_LIBCPP_EXPLICIT operator bool() const {return !fail();}
+#endif
+
 _LIBCPP_ALWAYS_INLINE bool operator!() const{return  fail();}
 _LIBCPP_ALWAYS_INLINE iostate rdstate() const   {return 
ios_base::rdstate();}
 _LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) 
{ios_base::clear(__state);}

Modified: 
libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp?rev=290750=290749=290750=diff
==
--- 
libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
 Fri Dec 30 06:44:58 2016
@@ -14,6 +14,7 @@
 // operator unspecified-bool-type() const;
 
 #include 
+#include 
 #include 
 
 int main()
@@ -22,4 +23,10 @@ int main()
 assert(static_cast(ios) == !ios.fail());
 ios.setstate(std::ios::failbit);
 assert(static_cast(ios) == !ios.fail());
+static_assert((!std::is_convertible::value), "");
+static_assert((!std::is_convertible::value), "");
+static_assert((!std::is_convertible::value), "");
+#if TEST_STD_VER >= 11
+static_assert((!std::is_convertible::value), "");
+#endif
 }


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


[libcxx] r290751 - Add missing include in test.

2016-12-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Dec 30 06:45:30 2016
New Revision: 290751

URL: http://llvm.org/viewvc/llvm-project?rev=290751=rev
Log:
Add missing include in test.

Modified:

libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp

Modified: 
libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp?rev=290751=290750=290751=diff
==
--- 
libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
 Fri Dec 30 06:45:30 2016
@@ -17,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 std::ios ios(0);


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


[PATCH] D21599: [Libcxx][MIPS] Use LLVM CheckAtomic.cmake module to figure out whether we need to link with libatomic.

2016-12-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D21599#481593, @dsanders wrote:

> I haven't used it that way either and I'm not sure it's a supported build for 
> libcxx but most LLVM projects support a standalone build as far as I know. 
> Can someone from the libcxx project confirm whether standalone builds are 
> supported?


Standalone builds are supported. So this breaks those.


Repository:
  rL LLVM

https://reviews.llvm.org/D21599



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


[PATCH] D15434: [libcxx] Export 2 basic_string methods to minimize the effect from internal_linkage switch

2016-12-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF resigned from this revision.
EricWF removed a reviewer: EricWF.
EricWF added a comment.

Resigning as reviewer. These changes are quite old, and can be redone if 
needed. In all likelihood I think I would rather remove the symbols from the 
dylib instead of keep them.


Repository:
  rL LLVM

https://reviews.llvm.org/D15434



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


[PATCH] D20874: [libcxx] Two more threading dependencies

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

Most of this is no longer needed. I'll submit patches for the parts that are 
actually needed (e.g. nanosleep) later on. Thanks.


https://reviews.llvm.org/D20874



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


[PATCH] D14686: Protect against overloaded comma in random_shuffle and improve tests

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

@gribozavr The tests have changed a bunch since this patch was created. I took 
the liberty of re-merging the tests. You can find the updated patch here:

https://gist.github.com/EricWF/a69933b79adf8cd61f1daa68c633cc03

Feel free to commit with the new tests.




Comment at: 
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp:35
 }
+
+template 

mclow.lists wrote:
> gribozavr wrote:
> > gribozavr wrote:
> > > mclow.lists wrote:
> > > > This is not how I would rewrite this test.
> > > > I would write a routine that took two "iterators", and called 
> > > > `random_shuffle`, and then checked for the desired results.
> > > > 
> > > > Then call it with pointers. and RA iters, etc.
> > > > for example:
> > > > 
> > > > template 
> > > > void test(Iter first, Iter last, Iter resFirst, Iter resLast);
> > > > 
> > > > test(nullptr, nullptr, nullptr, nullptr);
> > > > int source[] = {1, 2, 3, 4};
> > > > int res  [] = {1, 2, 3, 4};
> > > > const unsigned size = sizeof(source)/sizeof(source[0]);
> > > > 
> > > > test(source, source + size, res, res+size); 
> > > > test(random_access_iterator(source)  );
> > > > 
> > > > 
> > > I actually thought about this, and it is hard to rewrite it like that for 
> > > two reasons.  First, `random_shuffle` mutates the elements, so one needs 
> > > to restore the original sequence between calls to `test()` (otherwise it 
> > > is not obvious that it was mutated).  Second, this overload of 
> > > `random_shuffle` takes randomness from global state, so one can't just 
> > > specify one expected result in the test.  That's why I first check for 
> > > the initial shuffle exactly, and then only check that the output is a 
> > > permutation of input.
> > > 
> > Ping?
> Which is why I think that your use of `is_permutation` is good below.
> 
> What do we want to know after calling `random_shuffle`?
> 1) The same items are in the range, only in a different order. (right? Can it 
> ever "do nothing")
> 2) Nothing else is changed.
> 
> If you have two collections with the same contents, you should be able to 
> shuffle one over and over, and call `is_permutation` to compare the two after 
> each call.
> 
> Tests that have duplicates are good, too.
> [ Yes, I know that your bug report (and fix!) are very localized, but these 
> tests are really lacking ]
> 
> If you don't want to do this, I'll rewrite these tests sometime in the next 
> couple weeks, and then we can revisit your patch.
> 
I think the tests as written are an improvement over the current tests, and I 
think @gribozavr addressed most of @mclow.lists points above pretty well.

@mclow.lists  Feel free to rewrite the tests once this has been committed.


Repository:
  rL LLVM

https://reviews.llvm.org/D14686



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


[PATCH] D23041: Un-XFAIL GCC atomics.align

2016-12-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Have you filed a bug against GCC regarding its current behavior?

Also it seems like a bad idea to add `-fabi-version=6`, since it selects an 
older ABI version and not a newer one. Testing the old behavior is not what we 
want.

I think the best plan is to simply split the `vector_size` tests into another 
file and XFAIL that for GCC. At least then we get some coverage.


https://reviews.llvm.org/D23041



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


[libcxx] r290748 - Remove mblen(), mbtowc() and wctomb() from the thread-unsafe functions.

2016-12-30 Thread Ed Schouten via cfe-commits
Author: ed
Date: Fri Dec 30 04:44:00 2016
New Revision: 290748

URL: http://llvm.org/viewvc/llvm-project?rev=290748=rev
Log:
Remove mblen(), mbtowc() and wctomb() from the thread-unsafe functions.

Back in r240527 I added a knob to prevent thread-unsafe functions from
being exposed. mblen(), mbtowc() and wctomb() were also added to this
list, as the latest issue of POSIX doesn't require these functions to be
thread-safe.

It turns out that the only circumstance in which these functions are not
thread-safe is in case they are used in combination with state-dependent
character sets (e.g., Shift-JIS). According to Austin Group Bug 708,
these character sets "[...] are mostly a relic of the past and which
were never supported on most POSIX systems".

Though in many cases the use of these functions can be prevented by
using the reentrant counterparts, they are the only functions that allow
you to query whether the locale's character set is state-dependent. This
means that omitting these functions removes actual functionality.

Let's be a bit less pedantic and drop the guards around these functions.

Links:
http://austingroupbugs.net/view.php?id=708
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2037.htm

Reviewed by:ericwf
Differential Revision:  https://reviews.llvm.org/D21436

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/cstdlib
libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp
libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=290748=290747=290748=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Dec 30 04:44:00 2016
@@ -917,7 +917,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
 #endif
 
-// Thread-unsafe functions such as strtok(), mbtowc() and localtime()
+// Thread-unsafe functions such as strtok() and localtime()
 // are not available.
 #ifdef __CloudABI__
 #define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS

Modified: libcxx/trunk/include/cstdlib
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstdlib?rev=290748=290747=290748=diff
==
--- libcxx/trunk/include/cstdlib (original)
+++ libcxx/trunk/include/cstdlib Fri Dec 30 04:44:00 2016
@@ -144,11 +144,9 @@ using ::ldiv;
 #ifndef _LIBCPP_HAS_NO_LONG_LONG
 using ::lldiv;
 #endif // _LIBCPP_HAS_NO_LONG_LONG
-#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
 using ::mblen;
 using ::mbtowc;
 using ::wctomb;
-#endif
 using ::mbstowcs;
 using ::wcstombs;
 #ifdef _LIBCPP_HAS_QUICK_EXIT

Modified: libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp?rev=290748=290747=290748=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp Fri Dec 30 
04:44:00 2016
@@ -104,11 +104,9 @@ int main()
 wchar_t* pw = 0;
 const wchar_t* pwc = 0;
 char* pc = 0;
-#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
-#endif
 static_assert((std::is_same::value), 
"");
 static_assert((std::is_same::value), 
"");
 }

Modified: 
libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp?rev=290748=290747=290748=diff
==
--- libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp 
(original)
+++ libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp Fri 
Dec 30 04:44:00 2016
@@ -96,11 +96,9 @@ int main()
 wchar_t* pw = 0;
 const wchar_t* pwc = 0;
 char* pc = 0;
-#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), 
"");
 static_assert((std::is_same::value), 
"");
-#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 }


___
cfe-commits mailing list

[PATCH] D17053: [libcxx]: vector: Use < instead of != to improve failure mode

2016-12-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Maybe if we want to improve the failure mode we can add a 
`_LIBCPP_ASSERT(__new_last <= __end, "invalid range")`?


https://reviews.llvm.org/D17053



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


[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2016-12-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added a reviewer: EricWF.
EricWF added a comment.
This revision now requires changes to proceed.

Added a bunch of inline comments.

The biggest requested change is removing the `__atomic_support` header. We only 
need one atomic call within the headers. It's overkill to add a new header.




Comment at: libcxx/include/__atomic_support:1
+//===--===
+//

I would greatly prefer if this patch didn't add another header, and simply 
defined `__libcpp_atomic_increment` and `__libcpp_atomic_decrement` in place of 
`__atomic_inc_dec::increment`/`__atomic_inc_dec::decrement`.



Comment at: libcxx/include/memory:3802
+{
+  return __libcpp_atomic_add(, 1, _AO_Relaxed);
+}

sebpop wrote:
> EricWF wrote:
> > Why add `increment` and `decrement` at all? Just manually inline 
> > `__libcpp_atomic_add` at the callsites.
> I like the idea to manually inline the inc and dec functions.
> What should we do with the NOTE: above?
> 
> // NOTE: Relaxed and acq/rel atomics (for increment and decrement 
> respectively)
> // should be sufficient for thread safety.
> // See https://llvm.org/bugs/show_bug.cgi?id=22803
> 
> should we just go ahead and remove the note, or you want to have it where 
> inc/dec are called?  (about a dozen places.) 
Neremind about the manually inlining bit.

Please remove the `__atomic_inc_dec` namespace and rename `increment` to 
`__libcpp_atomic_increment` and `decrement` to `__libcpp_atomic_decrement`.

Please also remove the `__atomic_support` header and instead simply call 
`__atomic_add_fetch` from inside the functions.



Comment at: libcxx/include/memory:3911
+#ifdef _LIBCPP_BUILDING_MEMORY
 void __add_shared() _NOEXCEPT;
 bool __release_shared() _NOEXCEPT;

Please apply `_LIBCPP_FUNC_VIS` to both of these methods.



Comment at: libcxx/include/memory:3914
+#else
+inline _LIBCPP_INLINE_VISIBILITY
+void __add_shared() _NOEXCEPT {

the `inline` in redundant if you define the function inside the class.



Comment at: libcxx/include/memory:3948
+#ifdef _LIBCPP_BUILDING_MEMORY
 void __add_shared() _NOEXCEPT;
 void __add_weak() _NOEXCEPT;

Please add `_LIBCPP_FUNC_VIS` to the three methods.



Comment at: libcxx/include/memory:3952
+#else
+inline _LIBCPP_INLINE_VISIBILITY
+void __add_shared() _NOEXCEPT {

`inline` is redundant here.


https://reviews.llvm.org/D24991



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


[PATCH] D27068: Improve string::find

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

Holy crap those improvements are impressive.

This LGTM. I'm assuming @mclow.lists has nothing left to say about this.




Comment at: libcxx/include/__string:542
+template 
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+const _CharT *

Please add `inline` to the template so `-fvisibility-inlines-hidden` works with 
it.


https://reviews.llvm.org/D27068



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


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

2016-12-30 Thread Mads Ravn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290747: [clang-tidy] Add check 'misc-string-compare'. 
(authored by madsravn).

Changed prior to commit:
  https://reviews.llvm.org/D27210?vs=82521=82721#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27210

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

Index: clang-tools-extra/trunk/clang-tidy/misc/StringCompareCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/StringCompareCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/StringCompareCheck.cpp
@@ -0,0 +1,82 @@
+//===--- MiscStringCompare.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 "StringCompareCheck.h"
+#include "../utils/FixItHintUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/FixIt.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+static const StringRef CompareMessage = "do not use 'compare' to test equality "
+"of strings; use the string equality "
+"operator instead";
+
+void StringCompareCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  const auto StrCompare = cxxMemberCallExpr(
+  callee(cxxMethodDecl(hasName("compare"),
+   ofClass(classTemplateSpecializationDecl(
+   hasName("::std::basic_string"),
+  hasArgument(0, expr().bind("str2")), argumentCountIs(1),
+  callee(memberExpr().bind("str1")));
+
+  // First and second case: cast str.compare(str) to boolean.
+  Finder->addMatcher(implicitCastExpr(hasImplicitDestinationType(booleanType()),
+  has(StrCompare))
+ .bind("match1"),
+ this);
+
+  // Third and fourth case: str.compare(str) == 0 and str.compare(str) != 0.
+  Finder->addMatcher(
+  binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")),
+ hasEitherOperand(StrCompare.bind("compare")),
+ hasEitherOperand(integerLiteral(equals(0)).bind("zero")))
+  .bind("match2"),
+  this);
+}
+
+void StringCompareCheck::check(const MatchFinder::MatchResult ) {
+  if (const auto *Matched = Result.Nodes.getNodeAs("match1")) {
+diag(Matched->getLocStart(), CompareMessage);
+return;
+  }
+
+  if (const auto *Matched = Result.Nodes.getNodeAs("match2")) {
+const ASTContext  = *Result.Context;
+
+if (const auto *Zero = Result.Nodes.getNodeAs("zero")) {
+  const auto *Str1 = Result.Nodes.getNodeAs("str1");
+  const auto *Str2 = Result.Nodes.getNodeAs("str2");
+  const auto *Compare = Result.Nodes.getNodeAs("compare");
+
+  auto Diag = diag(Matched->getLocStart(), CompareMessage);
+
+  if (Str1->isArrow())
+Diag << FixItHint::CreateInsertion(Str1->getLocStart(), "*");
+
+  Diag << tooling::fixit::createReplacement(*Zero, *Str2, Ctx)
+   << tooling::fixit::createReplacement(*Compare, *Str1->getBase(),
+Ctx);
+}
+  }
+
+  // FIXME: Add fixit to fix the code for case one and two (match1).
+}
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/trunk/clang-tidy/misc/StringCompareCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/misc/StringCompareCheck.h
+++ clang-tools-extra/trunk/clang-tidy/misc/StringCompareCheck.h
@@ -0,0 +1,36 @@
+//===--- StringCompareCheck.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_STRING_COMPARE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_COMPARE_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// This 

[clang-tools-extra] r290747 - [clang-tidy] Add check 'misc-string-compare'.

2016-12-30 Thread Mads Ravn via cfe-commits
Author: madsravn
Date: Fri Dec 30 04:09:46 2016
New Revision: 290747

URL: http://llvm.org/viewvc/llvm-project?rev=290747=rev
Log:
[clang-tidy] Add check 'misc-string-compare'.

I have a created a new check for clang tidy: misc-string-compare. This will 
check for incorrect usage of std::string::compare when used to check equality 
or inequality of string instead of the string equality or inequality operators.

Example:
```
  std::string str1, str2;
  if (str1.compare(str2)) {
  }
```

Reviewers: hokein, aaron.ballman, alexfh, malcolm.parsons

Subscribers: xazax.hun, Eugene.Zelenko, cfe-commits, malcolm.parsons, Prazek, 
mgorny, JDevlieghere

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

Added:
clang-tools-extra/trunk/clang-tidy/misc/StringCompareCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/StringCompareCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-compare.rst
clang-tools-extra/trunk/test/clang-tidy/misc-string-compare.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=290747=290746=290747=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Fri Dec 30 04:09:46 
2016
@@ -28,6 +28,7 @@ add_clang_library(clangTidyMiscModule
   SizeofContainerCheck.cpp
   SizeofExpressionCheck.cpp
   StaticAssertCheck.cpp
+  StringCompareCheck.cpp
   StringConstructorCheck.cpp
   StringIntegerAssignmentCheck.cpp
   StringLiteralWithEmbeddedNulCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=290747=290746=290747=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Fri Dec 30 
04:09:46 2016
@@ -35,6 +35,7 @@
 #include "SizeofContainerCheck.h"
 #include "SizeofExpressionCheck.h"
 #include "StaticAssertCheck.h"
+#include "StringCompareCheck.h"
 #include "StringConstructorCheck.h"
 #include "StringIntegerAssignmentCheck.h"
 #include "StringLiteralWithEmbeddedNulCheck.h"
@@ -106,6 +107,7 @@ public:
 CheckFactories.registerCheck(
 "misc-sizeof-expression");
 CheckFactories.registerCheck("misc-static-assert");
+CheckFactories.registerCheck("misc-string-compare");
 CheckFactories.registerCheck(
 "misc-string-constructor");
 CheckFactories.registerCheck(

Added: clang-tools-extra/trunk/clang-tidy/misc/StringCompareCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/StringCompareCheck.cpp?rev=290747=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/StringCompareCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/misc/StringCompareCheck.cpp Fri Dec 30 
04:09:46 2016
@@ -0,0 +1,82 @@
+//===--- MiscStringCompare.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 "StringCompareCheck.h"
+#include "../utils/FixItHintUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/FixIt.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+static const StringRef CompareMessage = "do not use 'compare' to test equality 
"
+"of strings; use the string equality "
+"operator instead";
+
+void StringCompareCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  const auto StrCompare = cxxMemberCallExpr(
+  callee(cxxMethodDecl(hasName("compare"),
+   ofClass(classTemplateSpecializationDecl(
+   hasName("::std::basic_string"),
+  hasArgument(0, expr().bind("str2")), argumentCountIs(1),
+  callee(memberExpr().bind("str1")));
+
+  // First and second case: cast str.compare(str) to boolean.
+  
Finder->addMatcher(implicitCastExpr(hasImplicitDestinationType(booleanType()),
+  has(StrCompare))
+ .bind("match1"),
+

[PATCH] D22584: constexpr array support C++1z (P0031)

2016-12-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

@lefticus Are you still interested in working on this? If so could you please 
split the changes for `array` into a separate patch? Marshall seems to have 
implemented some of the changes in `` and that's causing merge 
conflicts.


https://reviews.llvm.org/D22584



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


[PATCH] D26753: ASTImporter: improve support for C++ templates

2016-12-30 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Kareem, I have re-checked it and I cannot see the failure. But I'm not going to 
commit it until NY holidays end (and, anyway, I will not commit it if somebody 
has failing tests). Could you describe your configuration?


https://reviews.llvm.org/D26753



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


[PATCH] D23831: [libcxx] Fix gcc 4.9 -Wcast-qual warning.

2016-12-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF resigned from this revision.
EricWF removed a reviewer: EricWF.
EricWF added a comment.

Resigning as a reviewer since this revision is dead.


https://reviews.llvm.org/D23831



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


[PATCH] D26244: [Driver] Prefer libraries installed next to Clang over those from GCC

2016-12-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF resigned from this revision.
EricWF removed a reviewer: EricWF.
EricWF added a comment.

I don't feel comfortable reviewing driver changes, since I never work on that 
code.


https://reviews.llvm.org/D26244



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


[PATCH] D25811: [libcxx] Fix toupper/tolower tests for UTF-8 locale

2016-12-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D25811#586053, @kparzysz wrote:

> In https://reviews.llvm.org/D25811#586000, @arphaman wrote:
>
> > I've tested this patch on OS X and these 4 tests that you've changed now 
> > fail.
> >
> > The `XFAIL: with_system_cxx_lib` lines don't have any effect on my system - 
> > these tests get invoked as expected by lit. Let me know if there's anything 
> > else I can do to help you.
>
>
> That's surprising.


"XFAIL: with_system_lib=..." are used for testing against OS X's installed 
libc++, which is very rarely done. @arphaman is probably testing against the 
in-tree libc++ on OS X, which is why the XFAIL's have no effect.

> Seems like something is different on OS X.

The reason for the different output on Linux and OS X is that they each provide 
their own different locale data. In particular they provide different 
toupper/tolower conversion tables. For some reason the ones on OS X seem to 
support UTF-16 conversions as well. Currently GLIBC doesn't even support UTF-8 
multi-byte characters.

While I was attempting to review this patch I ended up coming up with fixed 
tests myself. I committed them in r290746. I'm very sorry to step on your toes.
However there are plenty more `//XFAIL: linux` localization tests to fix!


Repository:
  rL LLVM

https://reviews.llvm.org/D25811



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


[libcxx] r290746 - Get ctype_byname tests passing on Linux.

2016-12-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Dec 30 03:28:58 2016
New Revision: 290746

URL: http://llvm.org/viewvc/llvm-project?rev=290746=rev
Log:
Get ctype_byname tests passing on Linux.

Modified:

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp

Modified: 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp?rev=290746=290745=290746=diff
==
--- 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
 Fri Dec 30 03:28:58 2016
@@ -17,7 +17,6 @@
 
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
-// XFAIL: linux
 
 #include 
 #include 
@@ -27,10 +26,11 @@
 int main()
 {
 {
-std::locale l(LOCALE_en_US_UTF_8);
+std::locale l;
 {
-typedef std::ctype F;
-const F& f = std::use_facet(l);
+typedef std::ctype_byname F;
+std::locale ll(l, new F(LOCALE_en_US_UTF_8));
+const F& f = std::use_facet(ll);
 
 assert(f.tolower(' ') == ' ');
 assert(f.tolower('A') == 'a');
@@ -38,15 +38,15 @@ int main()
 assert(f.tolower('.') == '.');
 assert(f.tolower('a') == 'a');
 assert(f.tolower('1') == '1');
-assert(f.tolower('\xDA') == '\xFA');
 assert(f.tolower('\xFA') == '\xFA');
 }
 }
 {
-std::locale l("C");
+std::locale l;
 {
-typedef std::ctype F;
-const F& f = std::use_facet(l);
+typedef std::ctype_byname F;
+std::locale ll(l, new F("C"));
+const F& f = std::use_facet(ll);
 
 assert(f.tolower(' ') == ' ');
 assert(f.tolower('A') == 'a');
@@ -59,10 +59,11 @@ int main()
 }
 }
 {
-std::locale l(LOCALE_en_US_UTF_8);
+std::locale l;
 {
-typedef std::ctype F;
-const F& f = std::use_facet(l);
+typedef std::ctype_byname F;
+std::locale ll(l, new F(LOCALE_en_US_UTF_8));
+const F& f = std::use_facet(ll);
 
 assert(f.tolower(L' ') == L' ');
 assert(f.tolower(L'A') == L'a');
@@ -75,10 +76,11 @@ int main()
 }
 }
 {
-std::locale l("C");
+std::locale l;
 {
-typedef std::ctype F;
-const F& f = std::use_facet(l);
+typedef std::ctype_byname F;
+std::locale ll(l, new F("C"));
+const F& f = std::use_facet(ll);
 
 assert(f.tolower(L' ') == L' ');
 assert(f.tolower(L'A') == L'a');

Modified: 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp?rev=290746=290745=290746=diff
==
--- 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
 Fri Dec 30 03:28:58 2016
@@ -17,7 +17,6 @@
 
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
-// XFAIL: linux
 
 #include 
 #include 
@@ -28,14 +27,15 @@
 int main()
 {
 {
-std::locale l(LOCALE_en_US_UTF_8);
+std::locale l;
 {
-typedef std::ctype F;
-const F& f = std::use_facet(l);
-std::string in("\xDA A\x07.a1");
+typedef std::ctype_byname F;
+std::locale ll(l, new F(LOCALE_en_US_UTF_8));
+const F& f = std::use_facet(ll);
+std::string in("c A\x07.a1");
 
 assert(f.tolower([0], in.data() + in.size()) == in.data() + 
in.size());
-

[clang-tools-extra] r290745 - Fix another nondeterminism in a tidy test.

2016-12-30 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri Dec 30 03:20:10 2016
New Revision: 290745

URL: http://llvm.org/viewvc/llvm-project?rev=290745=rev
Log:
Fix another nondeterminism in a tidy test.

Modified:

clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp?rev=290745=290744=290745=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp 
Fri Dec 30 03:20:10 2016
@@ -64,7 +64,7 @@ int trigger() {
   // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different 
enum types
   if (P + Q == R)
 return 1;
-  else if ((Q | R) == T)
+  else if ((S | R) == T)
 return 1;
   else
 int k = ZZ | Z;


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


[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.

2016-12-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:114
   /// \brief Get the name of the capture helper.
-  StringRef getHelperName() const override { return ".omp_outlined."; }
+  StringRef getHelperName() const override { return "__omp_outlined__"; }
 

arpith-jacob wrote:
> ABataev wrote:
> > arpith-jacob wrote:
> > > On the nvptx device, it is illegal for an identifier to contain a dot 
> > > ('.') so I've modified it here.  If there is a better way to do this, 
> > > please let me know.
> > Could you just override this function in CGOpenMPRuntimeNVPTX?
> Alexey, thank you for your review of this patch.
> 
> To override getHelperName() in CGOpenMPRuntime.cpp, I will have to move the 
> two classes  CGOpenMPRegionInfo and CGOpenMPOutlinedRegionInfo from the 
> anonymous namespace to the header file in CGOpenMPRuntime.h (under protected 
> mode).  I would prefer to do this since I will need to use these classes for 
> implementing codegen of other directives in the future.
> 
> Is that okay with you?
Yes, go ahead


https://reviews.llvm.org/D28145



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