r285544 - Add support for __builtin_alloca_with_align

2016-10-30 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Oct 31 00:37:48 2016
New Revision: 285544

URL: http://llvm.org/viewvc/llvm-project?rev=285544=rev
Log:
Add support for __builtin_alloca_with_align

__builtin_alloca always uses __BIGGEST_ALIGNMENT__ for the alignment of
the allocation.  __builtin_alloca_with_align allows the programmer to
specify the alignment of the allocation.

This fixes PR30658.

Added:
cfe/trunk/test/Sema/builtin-alloca-with-align.c
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
cfe/trunk/test/CodeGen/builtins-ms.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=285544=285543=285544=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Mon Oct 31 00:37:48 2016
@@ -512,6 +512,7 @@ BUILTIN(__builtin_unreachable, "v", "nr"
 BUILTIN(__builtin_shufflevector, "v."   , "nc")
 BUILTIN(__builtin_convertvector, "v."   , "nct")
 BUILTIN(__builtin_alloca, "v*z"   , "Fn")
+BUILTIN(__builtin_alloca_with_align, "v*zIz", "Fn")
 BUILTIN(__builtin_call_with_static_chain, "v.", "nt")
 
 // "Overloaded" Atomic operator builtins.  These are overloaded to support data

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=285544=285543=285544=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct 31 00:37:48 
2016
@@ -2440,6 +2440,10 @@ def err_no_accessor_for_property : Error
 def error_cannot_find_suitable_accessor : Error<
   "cannot find suitable %select{getter|setter}0 for property %1">;
 
+def err_alignment_too_small : Error<
+  "requested alignment must be %0 or greater">;
+def err_alignment_too_big : Error<
+  "requested alignment must be %0 or smaller">;
 def err_alignment_not_power_of_two : Error<
   "requested alignment is not a power of 2">;
 def err_alignment_dependent_typedef_name : Error<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=285544=285543=285544=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Oct 31 00:37:48 2016
@@ -9719,6 +9719,7 @@ public:
 
 private:
   bool SemaBuiltinPrefetch(CallExpr *TheCall);
+  bool SemaBuiltinAllocaWithAlign(CallExpr *TheCall);
   bool SemaBuiltinAssume(CallExpr *TheCall);
   bool SemaBuiltinAssumeAligned(CallExpr *TheCall);
   bool SemaBuiltinLongjmp(CallExpr *TheCall);

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=285544=285543=285544=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 31 00:37:48 2016
@@ -1147,6 +1147,19 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 AI->setAlignment(SuitableAlignmentInBytes);
 return RValue::get(AI);
   }
+
+  case Builtin::BI__builtin_alloca_with_align: {
+Value *Size = EmitScalarExpr(E->getArg(0));
+Value *AlignmentValue = EmitScalarExpr(E->getArg(1));
+auto *AlignmentCI = cast(AlignmentValue);
+unsigned Alignment = AlignmentCI->getZExtValue();
+const TargetInfo  = getContext().getTargetInfo();
+unsigned AlignmentInBytes = Alignment / TI.getCharWidth();
+AllocaInst *AI = Builder.CreateAlloca(Builder.getInt8Ty(), Size);
+AI->setAlignment(AlignmentInBytes);
+return RValue::get(AI);
+  }
+
   case Builtin::BIbzero:
   case Builtin::BI__builtin_bzero: {
 Address Dest = EmitPointerWithAlignment(E->getArg(0));

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=285544=285543=285544=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 31 00:37:48 2016
@@ -791,6 +791,10 @@ Sema::CheckBuiltinFunctionCall(FunctionD
 if (SemaBuiltinPrefetch(TheCall))
   return ExprError();
 break;
+  case Builtin::BI__builtin_alloca_with_align:
+if (SemaBuiltinAllocaWithAlign(TheCall))
+  return ExprError();
+break;
   case Builtin::BI__assume:
   case 

r285543 - Make output of ast-print closer to C++ code

2016-10-30 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Mon Oct 31 00:11:12 2016
New Revision: 285543

URL: http://llvm.org/viewvc/llvm-project?rev=285543=rev
Log:
Make output of ast-print closer to C++ code

Put semicolon after non-defining method declaration and a class
specialization body.

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=285543=285542=285543=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon Oct 31 00:11:12 2016
@@ -337,10 +337,9 @@ void DeclPrinter::VisitDeclContext(DeclC
 const char *Terminator = nullptr;
 if (isa(*D) || isa(*D))
   Terminator = nullptr;
-else if (isa(*D) &&
- cast(*D)->isThisDeclarationADefinition())
+else if (isa(*D) && cast(*D)->hasBody())
   Terminator = nullptr;
-else if (isa(*D) && cast(*D)->getBody())
+else if (isa(*D) && cast(*D)->hasBody())
   Terminator = nullptr;
 else if (isa(*D) || isa(*D) ||
  isa(*D) ||
@@ -984,7 +983,7 @@ void DeclPrinter::VisitClassTemplateDecl
 for (auto *I : D->specializations()) {
   PrintTemplateParameters(Params, >getTemplateArgs());
   Visit(I);
-  Out << '\n';
+  Out << ";\n";
 }
   }
 


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


r285539 - [AVX-512] Remove many of the masked 128/256-bit shift builtins and replace them with unmasked builtins and selects.

2016-10-30 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sun Oct 30 23:30:51 2016
New Revision: 285539

URL: http://llvm.org/viewvc/llvm-project?rev=285539=rev
Log:
[AVX-512] Remove many of the masked 128/256-bit shift builtins and replace them 
with unmasked builtins and selects.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=285539=285538=285539=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sun Oct 30 23:30:51 2016
@@ -1365,60 +1365,22 @@ TARGET_BUILTIN(__builtin_ia32_psllw512_m
 TARGET_BUILTIN(__builtin_ia32_psllwi512_mask, "V32sV32sIiV32sUi","","avx512bw")
 TARGET_BUILTIN(__builtin_ia32_psllv16hi_mask, 
"V16sV16sV16sV16sUs","","avx512bw,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psllv8hi_mask, 
"V8sV8sV8sV8sUc","","avx512bw,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psllw128_mask, 
"V8sV8sV8sV8sUc","","avx512bw,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psllw256_mask, 
"V16sV16sV8sV16sUs","","avx512bw,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psllwi128_mask, 
"V8sV8sIiV8sUc","","avx512bw,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psllwi256_mask, 
"V16sV16sIiV16sUs","","avx512bw,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psllv2di_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psllv4di_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psllv4si_mask, "V4iV4iV4iV4iUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psllv8si_mask, "V8iV8iV8iV8iUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pslldi512_mask, "V16iV16iIiV16iUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_psllqi512_mask, 
"V8LLiV8LLiIiV8LLiUc","","avx512f")
-TARGET_BUILTIN(__builtin_ia32_pslld128_mask, "V4iV4iV4iV4iUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_pslld256_mask, "V8iV8iV4iV8iUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_pslldi128_mask, "V4iV4iIiV4iUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_pslldi256_mask, "V8iV8iIiV8iUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psllq128_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psllq256_mask, 
"V4LLiV4LLiV2LLiV4LLiUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psllqi128_mask, 
"V2LLiV2LLiIiV2LLiUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psllqi256_mask, 
"V4LLiV4LLiIiV4LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psrlv32hi_mask, 
"V32sV32sV32sV32sUi","","avx512bw")
 TARGET_BUILTIN(__builtin_ia32_psrlv16hi_mask, 
"V16sV16sV16sV16sUs","","avx512bw,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psrlv8hi_mask, 
"V8sV8sV8sV8sUc","","avx512bw,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psrlv2di_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psrlv4di_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psrlv4si_mask, "V4iV4iV4iV4iUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psrlv8si_mask, "V8iV8iV8iV8iUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psrldi512_mask, "V16iV16iIiV16iUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_psrlqi512_mask, 
"V8LLiV8LLiIiV8LLiUc","","avx512f")
-TARGET_BUILTIN(__builtin_ia32_psrld128_mask, "V4iV4iV4iV4iUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psrld256_mask, "V8iV8iV4iV8iUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psrldi128_mask, "V4iV4iIiV4iUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psrldi256_mask, "V8iV8iIiV8iUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psrlq128_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psrlq256_mask, 
"V4LLiV4LLiV2LLiV4LLiUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psrlqi128_mask, 
"V2LLiV2LLiIiV2LLiUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psrlqi256_mask, 
"V4LLiV4LLiIiV4LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psrav32hi_mask, 
"V32sV32sV32sV32sUi","","avx512bw")
 TARGET_BUILTIN(__builtin_ia32_psrav16hi_mask, 
"V16sV16sV16sV16sUs","","avx512bw,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psrav8hi_mask, 
"V8sV8sV8sV8sUc","","avx512bw,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psrav4si_mask, "V4iV4iV4iV4iUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_psrav8si_mask, "V8iV8iV8iV8iUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psravq128_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psravq256_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psraw512_mask, "V32sV32sV8sV32sUi","","avx512bw")
 TARGET_BUILTIN(__builtin_ia32_psrawi512_mask, "V32sV32sIiV32sUi","","avx512bw")
-TARGET_BUILTIN(__builtin_ia32_psraw128_mask, 

r285540 - [AVX-512] Remove masked vector extract builtins and replace with native shufflevectors and selects.

2016-10-30 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sun Oct 30 23:30:56 2016
New Revision: 285540

URL: http://llvm.org/viewvc/llvm-project?rev=285540=rev
Log:
[AVX-512] Remove masked vector extract builtins and replace with native 
shufflevectors and selects.

Unfortunately, the backend currently doesn't fold masks into the instructions 
correctly when they come from these shufflevectors. I'll work on that in a 
future commit.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512dqintrin.h
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vldqintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/avx512dq-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/avx512vldq-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=285540=285539=285540=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sun Oct 30 23:30:56 2016
@@ -1004,8 +1004,6 @@ TARGET_BUILTIN(__builtin_ia32_alignd128_
 TARGET_BUILTIN(__builtin_ia32_alignd256_mask, "V8iV8iV8iIiV8iUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_alignq128_mask, 
"V2LLiV2LLiV2LLiIiV2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_alignq256_mask, 
"V4LLiV4LLiV4LLiIiV4LLiUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_extractf64x4_mask, "V4dV8dIiV4dUc", "", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_extractf32x4_mask, "V4fV16fIiV4fUc", "", 
"avx512f")
 
 TARGET_BUILTIN(__builtin_ia32_gather3div2df, "V2dV2ddC*V2LLiUci","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_gather3div2di, 
"V2LLiV2LLiLLiC*V2LLiUci","","avx512vl")
@@ -1727,16 +1725,6 @@ TARGET_BUILTIN(__builtin_ia32_pmovqw128_
 TARGET_BUILTIN(__builtin_ia32_pmovqw128mem_mask, "vV8s*V2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pmovqw256_mask, "V8sV4LLiV8sUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pmovqw256mem_mask, "vV8s*V4LLiUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_extractf32x8_mask, 
"V8fV16fIiV8fUc","","avx512dq")
-TARGET_BUILTIN(__builtin_ia32_extractf64x2_512_mask, 
"V2dV8dIiV2dUc","","avx512dq")
-TARGET_BUILTIN(__builtin_ia32_extracti32x8_mask, 
"V8iV16iIiV8iUc","","avx512dq")
-TARGET_BUILTIN(__builtin_ia32_extracti64x2_512_mask, 
"V2LLiV8LLiIiV2LLiUc","","avx512dq")
-TARGET_BUILTIN(__builtin_ia32_extracti32x4_mask, "V4iV16iIiV4iUc","","avx512f")
-TARGET_BUILTIN(__builtin_ia32_extracti64x4_mask, 
"V4LLiV8LLiIiV4LLiUc","","avx512f")
-TARGET_BUILTIN(__builtin_ia32_extractf64x2_256_mask, 
"V2dV4dIiV2dUc","","avx512dq,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_extracti64x2_256_mask, 
"V2LLiV4LLiIiV2LLiUc","","avx512dq,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_extractf32x4_256_mask, 
"V4fV8fIiV4fUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_extracti32x4_256_mask, 
"V4iV8iIiV4iUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_insertf32x8_mask, 
"V16fV16fV8fIiV16fUs","","avx512dq")
 TARGET_BUILTIN(__builtin_ia32_insertf64x2_512_mask, 
"V8dV8dV2dIiV8dUc","","avx512dq")
 TARGET_BUILTIN(__builtin_ia32_inserti32x8_mask, 
"V16iV16iV8iIiV16iUs","","avx512dq")

Modified: cfe/trunk/lib/Headers/avx512dqintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512dqintrin.h?rev=285540=285539=285540=diff
==
--- cfe/trunk/lib/Headers/avx512dqintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512dqintrin.h Sun Oct 30 23:30:56 2016
@@ -1116,70 +1116,80 @@ _mm512_maskz_broadcast_i64x2 (__mmask8 _
 }
 
 #define _mm512_extractf32x8_ps(A, imm) __extension__ ({ \
-  (__m256)__builtin_ia32_extractf32x8_mask((__v16sf)(__m512)(A), (int)(imm), \
-   (__v8sf)_mm256_setzero_ps(), \
-   (__mmask8)-1); })
+  (__m256)__builtin_shufflevector((__v16sf)(__m512)(A),   \
+  (__v16sf)_mm512_undefined_ps(), \
+  ((imm) & 1) ?  8 : 0,   \
+  ((imm) & 1) ?  9 : 1,   \
+  ((imm) & 1) ? 10 : 2,   \
+  ((imm) & 1) ? 11 : 3,   \
+  ((imm) & 1) ? 12 : 4,   \
+  ((imm) & 1) ? 13 : 5,   \
+  ((imm) & 1) ? 14 : 6,   \
+  ((imm) & 1) ? 15 : 7); })
 
 #define _mm512_mask_extractf32x8_ps(W, U, A, imm) __extension__ ({ \
-  (__m256)__builtin_ia32_extractf32x8_mask((__v16sf)(__m512)(A), (int)(imm), \
-   (__v8sf)(__m256)(W), \
-

[libcxx] r285538 - Add 'inline' but not 'always_inline' to std::strings destructor.

2016-10-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Oct 30 22:42:50 2016
New Revision: 285538

URL: http://llvm.org/viewvc/llvm-project?rev=285538=rev
Log:
Add 'inline' but not 'always_inline' to std::strings destructor.

Adding both 'inline' and 'always_inline' to the destructor has been contentious.
However most of the performance benefits can be gained by only adding 'inline',
and there is no reason to hold up that change while discussing the other.

Modified:
libcxx/trunk/include/string

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=285538=285537=285538=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Sun Oct 30 22:42:50 2016
@@ -806,7 +806,7 @@ public:
 basic_string(initializer_list __il, const allocator_type& __a);
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
-~basic_string();
+inline ~basic_string();
 
 _LIBCPP_INLINE_VISIBILITY
 operator __self_view() const _NOEXCEPT { return __self_view(data(), 
size()); }


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


[libcxx] r285537 - Remove additional function template definitions from the dylib

2016-10-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Oct 30 22:40:29 2016
New Revision: 285537

URL: http://llvm.org/viewvc/llvm-project?rev=285537=rev
Log:
Remove additional function template definitions from the dylib

Modified:
libcxx/trunk/include/string
libcxx/trunk/lib/abi/CHANGELOG.TXT
libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=285537=285536=285537=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Sun Oct 30 22:40:29 2016
@@ -927,7 +927,7 @@ public:
 basic_string& append(const value_type* __s);
 basic_string& append(size_type __n, value_type __c);
 template 
-basic_string& __append_forward_unsafe(_ForwardIterator, _ForwardIterator);
+inline basic_string& __append_forward_unsafe(_ForwardIterator, 
_ForwardIterator);
 template
 typename enable_if
 <

Modified: libcxx/trunk/lib/abi/CHANGELOG.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/CHANGELOG.TXT?rev=285537=285536=285537=diff
==
--- libcxx/trunk/lib/abi/CHANGELOG.TXT (original)
+++ libcxx/trunk/lib/abi/CHANGELOG.TXT Sun Oct 30 22:40:29 2016
@@ -16,6 +16,21 @@ New entries should be added directly bel
 Version 4.0
 ---
 
+* rTBD - Remove std::string::append template methods which should be inline
+
+  These functions should never have had visible definitions in the dylib but
+  since they were previously not specified with 'inline' they accidentally
+  got emitted. This change is non-ABI breaking because every "linkage unit"
+  must contain its own definition.
+
+  x86_64-linux-gnu
+  
+  SYMBOL REMOVED: 
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendIPcEENS_9enable_ifIXaasr21__is_forward_iteratorIT_EE5valuesr38__libcpp_string_gets_noexcept_iteratorIS9_EE5valueERS5_E4typeES9_S9_
+  SYMBOL REMOVED: 
_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendIPwEENS_9enable_ifIXaasr21__is_forward_iteratorIT_EE5valuesr38__libcpp_string_gets_noexcept_iteratorIS9_EE5valueERS5_E4typeES9_S9_
+
+  x86_64-apple-darwin16.0
+  ---
+  No changes
 
 * r285101 - Add -fvisibility-inlines-hidden when building libc++.
 

Modified: libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist?rev=285537=285536=285537=diff
==
--- libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist (original)
+++ libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist Sun Oct 30 22:40:29 2016
@@ -585,7 +585,6 @@
 {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKcm'}
 {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendERKS5_mm'}
 {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEmc'}
-{'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendIPcEENS_9enable_ifIXaasr21__is_forward_iteratorIT_EE5valuesr38__libcpp_string_gets_noexcept_iteratorIS9_EE5valueERS5_E4typeES9_S9_'}
 {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKc'}
 {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKcm'}
 {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignERKS5_mm'}
@@ -626,7 +625,6 @@
 {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendEPKwm'}
 {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendERKS5_mm'}
 {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendEmw'}
-{'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6appendIPwEENS_9enable_ifIXaasr21__is_forward_iteratorIT_EE5valuesr38__libcpp_string_gets_noexcept_iteratorIS9_EE5valueERS5_E4typeES9_S9_'}
 {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignEPKw'}
 {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignEPKwm'}
 {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6assignERKS5_mm'}


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


[PATCH] D25624: Added 'inline' attribute to basic_string's destructor

2016-10-30 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

I talked with Eric on IRC, he mentioned some benchmarks were ran. I'd like to 
understand what was the baseline?
Here we add *both* the inline keyword and the always_inline attribute. I'd like 
to know if there is a benchmarks that shows that always_inline is beneficial on 
top of the inline keyword. 
If we need to add always_inline anywhere: this is likely an inliner heuristic 
failure and we should at minima track it as an example to improve it.


https://reviews.llvm.org/D25624



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


[PATCH] D13419: Fix several problems at the intersection of template instantiations and visibility

2016-10-30 Thread Keno Fischer via cfe-commits
loladiro added a comment.

I'm really out of my depth in this code, but it looks like that test case is 
triggering the one code path in that function that is actually correct. Could 
you adjust it to trigger the code path behind the first if statement?


Repository:
  rL LLVM

https://reviews.llvm.org/D13419



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


r285533 - [analyzer] NumberObjectConversion: support more types, misc updates.

2016-10-30 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Sun Oct 30 22:08:48 2016
New Revision: 285533

URL: http://llvm.org/viewvc/llvm-project?rev=285533=rev
Log:
[analyzer] NumberObjectConversion: support more types, misc updates.

Support CFNumberRef and OSNumber objects, which may also be accidentally
converted to plain integers or booleans.

Enable explicit boolean casts by default in non-pedantic mode.

Improve handling for warnings inside macros.

Improve error messages.

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

Added:
cfe/trunk/test/Analysis/number-object-conversion.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
cfe/trunk/test/Analysis/number-object-conversion.cpp
cfe/trunk/test/Analysis/number-object-conversion.m

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp?rev=285533=285532=285533=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp Sun 
Oct 30 22:08:48 2016
@@ -63,33 +63,30 @@ public:
 } // end of anonymous namespace
 
 void Callback::run(const MatchFinder::MatchResult ) {
-  bool IsPedanticMatch = (Result.Nodes.getNodeAs("pedantic") != nullptr);
+  bool IsPedanticMatch =
+  (Result.Nodes.getNodeAs("pedantic") != nullptr);
   if (IsPedanticMatch && !C->Pedantic)
 return;
 
-  const Stmt *Conv = Result.Nodes.getNodeAs("conv");
-  assert(Conv);
-  const Expr *Osboolean = Result.Nodes.getNodeAs("osboolean");
-  const Expr *Nsnumber = Result.Nodes.getNodeAs("nsnumber");
-  bool IsObjC = (bool)Nsnumber;
-  const Expr *Obj = IsObjC ? Nsnumber : Osboolean;
-  assert(Obj);
-
   ASTContext  = ADC->getASTContext();
 
   if (const Expr *CheckIfNull =
   Result.Nodes.getNodeAs("check_if_null")) {
-// We consider NULL to be a pointer, even if it is defined as a plain 0.
-// FIXME: Introduce a matcher to implement this logic?
+// Unless the macro indicates that the intended type is clearly not
+// a pointer type, we should avoid warning on comparing pointers
+// to zero literals in non-pedantic mode.
+// FIXME: Introduce an AST matcher to implement the macro-related logic?
+bool MacroIndicatesWeShouldSkipTheCheck = false;
 SourceLocation Loc = CheckIfNull->getLocStart();
 if (Loc.isMacroID()) {
   StringRef MacroName = Lexer::getImmediateMacroName(
   Loc, ACtx.getSourceManager(), ACtx.getLangOpts());
-  if (MacroName != "YES" && MacroName != "NO")
+  if (MacroName == "NULL" || MacroName == "nil")
 return;
-} else {
-  // Otherwise, comparison of pointers to 0 might still be intentional.
-  // See if this is the case.
+  if (MacroName == "YES" || MacroName == "NO")
+MacroIndicatesWeShouldSkipTheCheck = true;
+}
+if (!MacroIndicatesWeShouldSkipTheCheck) {
   llvm::APSInt Result;
   if (CheckIfNull->IgnoreParenCasts()->EvaluateAsInt(
   Result, ACtx, Expr::SE_AllowSideEffects)) {
@@ -102,33 +99,92 @@ void Callback::run(const MatchFinder::Ma
 }
   }
 
+  const Stmt *Conv = Result.Nodes.getNodeAs("conv");
+  assert(Conv);
+
+  const Expr *ConvertedCObject = Result.Nodes.getNodeAs("c_object");
+  const Expr *ConvertedCppObject = Result.Nodes.getNodeAs("cpp_object");
+  const Expr *ConvertedObjCObject = 
Result.Nodes.getNodeAs("objc_object");
+  bool IsCpp = (ConvertedCppObject != nullptr);
+  bool IsObjC = (ConvertedObjCObject != nullptr);
+  const Expr *Obj = IsObjC ? ConvertedObjCObject
+  : IsCpp ? ConvertedCppObject
+  : ConvertedCObject;
+  assert(Obj);
+
+  bool IsComparison =
+  (Result.Nodes.getNodeAs("comparison") != nullptr);
+
+  bool IsOSNumber =
+  (Result.Nodes.getNodeAs("osnumber") != nullptr);
+
+  bool IsInteger =
+  (Result.Nodes.getNodeAs("int_type") != nullptr);
+  bool IsObjCBool =
+  (Result.Nodes.getNodeAs("objc_bool_type") != nullptr);
+  bool IsCppBool =
+  (Result.Nodes.getNodeAs("cpp_bool_type") != nullptr);
+
   llvm::SmallString<64> Msg;
   llvm::raw_svector_ostream OS(Msg);
-  OS << "Converting '"
- << Obj->getType().getCanonicalType().getUnqualifiedType().getAsString()
- << "' to a plain ";
-
-  if (Result.Nodes.getNodeAs("int_type") != nullptr)
-OS << "integer value";
-  else if (Result.Nodes.getNodeAs("objc_bool_type") != nullptr)
-OS << "BOOL value";
-  else if (Result.Nodes.getNodeAs("cpp_bool_type") != nullptr)
-OS << "bool value";
+
+  // Remove ObjC ARC qualifiers.
+  QualType ObjT = Obj->getType().getUnqualifiedType();
+
+  // Remove consts from pointers.
+  if (IsCpp) {
+assert(ObjT.getCanonicalType()->isPointerType());
+ObjT = ACtx.getPointerType(
+

[PATCH] D25731: [analyzer] NumberObjectConversion: Support OSNumber and CFNumberRef.

2016-10-30 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285533: [analyzer] NumberObjectConversion: support more 
types, misc updates. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D25731?vs=76043=76349#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25731

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  cfe/trunk/test/Analysis/number-object-conversion.c
  cfe/trunk/test/Analysis/number-object-conversion.cpp
  cfe/trunk/test/Analysis/number-object-conversion.m

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
@@ -63,33 +63,30 @@
 } // end of anonymous namespace
 
 void Callback::run(const MatchFinder::MatchResult ) {
-  bool IsPedanticMatch = (Result.Nodes.getNodeAs("pedantic") != nullptr);
+  bool IsPedanticMatch =
+  (Result.Nodes.getNodeAs("pedantic") != nullptr);
   if (IsPedanticMatch && !C->Pedantic)
 return;
 
-  const Stmt *Conv = Result.Nodes.getNodeAs("conv");
-  assert(Conv);
-  const Expr *Osboolean = Result.Nodes.getNodeAs("osboolean");
-  const Expr *Nsnumber = Result.Nodes.getNodeAs("nsnumber");
-  bool IsObjC = (bool)Nsnumber;
-  const Expr *Obj = IsObjC ? Nsnumber : Osboolean;
-  assert(Obj);
-
   ASTContext  = ADC->getASTContext();
 
   if (const Expr *CheckIfNull =
   Result.Nodes.getNodeAs("check_if_null")) {
-// We consider NULL to be a pointer, even if it is defined as a plain 0.
-// FIXME: Introduce a matcher to implement this logic?
+// Unless the macro indicates that the intended type is clearly not
+// a pointer type, we should avoid warning on comparing pointers
+// to zero literals in non-pedantic mode.
+// FIXME: Introduce an AST matcher to implement the macro-related logic?
+bool MacroIndicatesWeShouldSkipTheCheck = false;
 SourceLocation Loc = CheckIfNull->getLocStart();
 if (Loc.isMacroID()) {
   StringRef MacroName = Lexer::getImmediateMacroName(
   Loc, ACtx.getSourceManager(), ACtx.getLangOpts());
-  if (MacroName != "YES" && MacroName != "NO")
+  if (MacroName == "NULL" || MacroName == "nil")
 return;
-} else {
-  // Otherwise, comparison of pointers to 0 might still be intentional.
-  // See if this is the case.
+  if (MacroName == "YES" || MacroName == "NO")
+MacroIndicatesWeShouldSkipTheCheck = true;
+}
+if (!MacroIndicatesWeShouldSkipTheCheck) {
   llvm::APSInt Result;
   if (CheckIfNull->IgnoreParenCasts()->EvaluateAsInt(
   Result, ACtx, Expr::SE_AllowSideEffects)) {
@@ -102,33 +99,92 @@
 }
   }
 
+  const Stmt *Conv = Result.Nodes.getNodeAs("conv");
+  assert(Conv);
+
+  const Expr *ConvertedCObject = Result.Nodes.getNodeAs("c_object");
+  const Expr *ConvertedCppObject = Result.Nodes.getNodeAs("cpp_object");
+  const Expr *ConvertedObjCObject = Result.Nodes.getNodeAs("objc_object");
+  bool IsCpp = (ConvertedCppObject != nullptr);
+  bool IsObjC = (ConvertedObjCObject != nullptr);
+  const Expr *Obj = IsObjC ? ConvertedObjCObject
+  : IsCpp ? ConvertedCppObject
+  : ConvertedCObject;
+  assert(Obj);
+
+  bool IsComparison =
+  (Result.Nodes.getNodeAs("comparison") != nullptr);
+
+  bool IsOSNumber =
+  (Result.Nodes.getNodeAs("osnumber") != nullptr);
+
+  bool IsInteger =
+  (Result.Nodes.getNodeAs("int_type") != nullptr);
+  bool IsObjCBool =
+  (Result.Nodes.getNodeAs("objc_bool_type") != nullptr);
+  bool IsCppBool =
+  (Result.Nodes.getNodeAs("cpp_bool_type") != nullptr);
+
   llvm::SmallString<64> Msg;
   llvm::raw_svector_ostream OS(Msg);
-  OS << "Converting '"
- << Obj->getType().getCanonicalType().getUnqualifiedType().getAsString()
- << "' to a plain ";
-
-  if (Result.Nodes.getNodeAs("int_type") != nullptr)
-OS << "integer value";
-  else if (Result.Nodes.getNodeAs("objc_bool_type") != nullptr)
-OS << "BOOL value";
-  else if (Result.Nodes.getNodeAs("cpp_bool_type") != nullptr)
-OS << "bool value";
+
+  // Remove ObjC ARC qualifiers.
+  QualType ObjT = Obj->getType().getUnqualifiedType();
+
+  // Remove consts from pointers.
+  if (IsCpp) {
+assert(ObjT.getCanonicalType()->isPointerType());
+ObjT = ACtx.getPointerType(
+ObjT->getPointeeType().getCanonicalType().getUnqualifiedType());
+  }
+
+  if (IsComparison)
+OS << "Comparing ";
   else
-OS << "boolean value for branching";
+OS << "Converting ";
 
-  if (IsPedanticMatch) {
-if (IsObjC) {
-  OS << "; please compare the pointer to nil instead "
-"to suppress this warning";
-} else {
-  OS << "; please compare the pointer to NULL or nullptr instead "
-"to suppress this warning";

[PATCH] D25624: Added 'inline' attribute to basic_string's destructor

2016-10-30 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

Before this gets re-committed, I'd like to understand why only the destructor?


https://reviews.llvm.org/D25624



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


[libcxx] r285532 - Optimize filesystem::path by providing weaker exception guarantees.

2016-10-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Oct 30 21:46:25 2016
New Revision: 285532

URL: http://llvm.org/viewvc/llvm-project?rev=285532=rev
Log:
Optimize filesystem::path by providing weaker exception guarantees.

path uses string::append to construct, append, and concatenate paths. 
Unfortunatly
string::append has a strong exception safety guaranteed and if it can't prove
that the iterator operations don't throw then it will allocate a temporary
string copy to append to. However this extra allocation and copy is very
undesirable for path which doesn't have the same exception guarantees.

To work around this this patch adds string::__append_forward_unsafe which 
exposes
the std::string::append interface for forward iterators without enforcing
that the iterator is noexcept.


Modified:
libcxx/trunk/benchmarks/CMakeLists.txt
libcxx/trunk/benchmarks/filesystem.bench.cpp
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/include/string

Modified: libcxx/trunk/benchmarks/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/CMakeLists.txt?rev=285532=285531=285532=diff
==
--- libcxx/trunk/benchmarks/CMakeLists.txt (original)
+++ libcxx/trunk/benchmarks/CMakeLists.txt Sun Oct 30 21:46:25 2016
@@ -69,6 +69,7 @@ set(BENCHMARK_NATIVE_INSTALL ${CMAKE_CUR
 set(BENCHMARK_TEST_COMPILE_FLAGS
 -std=c++14 -O2
 -I${BENCHMARK_LIBCXX_INSTALL}/include
+-I${LIBCXX_SOURCE_DIR}/test/support
 )
 set(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS
 -nostdinc++

Modified: libcxx/trunk/benchmarks/filesystem.bench.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/filesystem.bench.cpp?rev=285532=285531=285532=diff
==
--- libcxx/trunk/benchmarks/filesystem.bench.cpp (original)
+++ libcxx/trunk/benchmarks/filesystem.bench.cpp Sun Oct 30 21:46:25 2016
@@ -2,6 +2,7 @@
 
 #include "benchmark/benchmark_api.h"
 #include "GenerateInput.hpp"
+#include "test_iterators.h"
 
 namespace fs = std::experimental::filesystem;
 
@@ -41,6 +42,39 @@ void BM_PathConstructCStr(benchmark::Sta
 BENCHMARK_CAPTURE(BM_PathConstructCStr, large_string,
   getRandomStringInputs)->Arg(TestNumInputs);
 
+
+template  class ItType, class GenInputs>
+void BM_PathConstructIter(benchmark::State , GenInputs gen) {
+  using namespace fs;
+  using Iter = ItType;
+  const auto in = gen(st.range(0));
+  path PP;
+  for (auto& Part : in)
+PP /= Part;
+  auto Start = Iter(PP.native().begin());
+  auto End = Iter(PP.native().end());
+  benchmark::DoNotOptimize(PP.native().data());
+  benchmark::DoNotOptimize(Start);
+  benchmark::DoNotOptimize(End);
+  while (st.KeepRunning()) {
+const path P(Start, End);
+benchmark::DoNotOptimize(P.native().data());
+  }
+}
+template 
+void BM_PathConstructInputIter(benchmark::State , GenInputs gen) {
+  BM_PathConstructIter(st, gen);
+}
+template 
+void BM_PathConstructForwardIter(benchmark::State , GenInputs gen) {
+  BM_PathConstructIter(st, gen);
+}
+BENCHMARK_CAPTURE(BM_PathConstructInputIter, large_string,
+  getRandomStringInputs)->Arg(TestNumInputs);
+BENCHMARK_CAPTURE(BM_PathConstructForwardIter, large_string,
+  getRandomStringInputs)->Arg(TestNumInputs);
+
+
 template 
 void BM_PathIterateMultipleTimes(benchmark::State , GenInputs gen) {
   using namespace fs;

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=285532=285531=285532=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Sun Oct 30 21:46:25 2016
@@ -625,8 +625,18 @@ template <>
 struct _PathCVT {
 
 template 
-static void __append_range(string& __dest, _Iter __b, _Iter __e) {
-__dest.append(__b, __e);
+static typename enable_if<
+__is_exactly_input_iterator<_Iter>::value
+>::type __append_range(string& __dest, _Iter __b, _Iter __e) {
+for (; __b != __e; ++__b)
+__dest.push_back(*__b);
+}
+
+template 
+static typename enable_if<
+__is_forward_iterator<_Iter>::value
+>::type __append_range(string& __dest, _Iter __b, _Iter __e) {
+__dest.__append_forward_unsafe(__b, __e);
 }
 
 template 

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=285532=285531=285532=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Sun Oct 30 21:46:25 2016
@@ -926,6 +926,8 @@ public:
 basic_string& append(const value_type* __s, size_type __n);
 basic_string& append(const value_type* __s);
 basic_string& append(size_type __n, value_type __c);
+template 
+basic_string& 

Re: [libcxx] r285456 - Added 'inline' attribute to basic_string's destructor

2016-10-30 Thread Eric Fiselier via cfe-commits
Hi All,

This problem was caused by the definition of
_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY.
The issue was fixed in r285531, which also adds linkage tests for
std::strings destructor.

@Adtiya feel free to recommit this change.

/Eric

On Fri, Oct 28, 2016 at 7:00 PM, Mehdi Amini via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Adtiya,
>
> I had to revert in r285485 to unbreak this build bot:
> http://lab.llvm.org:8080/green/job/clang-stage2-
> configure-Rlto_build/10737/
> (LTO bootstrap of clang).
>
> Let’s iterate on the revision on Phabricator to figure out what it the
> right fix!
>
> Best,
>
> —
> Mehdi
>
>
> On Oct 28, 2016, at 2:27 PM, Aditya Kumar via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: hiraditya
> Date: Fri Oct 28 16:27:24 2016
> New Revision: 285456
>
> URL: http://llvm.org/viewvc/llvm-project?rev=285456=rev
> Log:
> Added 'inline' attribute to basic_string's destructor
>
> Author: laxmansole
>
> Reviewers: howard.hinnant
>   mclow.lists
> Subscribers: EricWF, flyingforyou, evandro
>
> Differential Revision: https://reviews.llvm.org/D25624
>
> Reapplying the patch as the bug https://llvm.org/bugs/show_
> bug.cgi?id=30341 is fixed.
>
> Currently basic_string's destructor is not getting inlined. So adding
> 'inline' attribute to ~basic_string().
> Worked in collaboration with Aditya Kumar.
>
> Modified:
>libcxx/trunk/include/string
>
> Modified: libcxx/trunk/include/string
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/
> string?rev=285456=285455=285456=diff
> 
> ==
> --- libcxx/trunk/include/string (original)
> +++ libcxx/trunk/include/string Fri Oct 28 16:27:24 2016
> @@ -806,6 +806,7 @@ public:
> basic_string(initializer_list __il, const allocator_type&
> __a);
> #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
>
> +inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
> ~basic_string();
>
> _LIBCPP_INLINE_VISIBILITY
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r285531 - Fix _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to always have default visibility.

2016-10-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Oct 30 21:07:23 2016
New Revision: 285531

URL: http://llvm.org/viewvc/llvm-project?rev=285531=rev
Log:
Fix _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to always have default visibility.

This prevent the symbols from being both externally available and hidden, which
causes them to be linked incorrectly. This is only a problem when the address
of the function is explicitly taken since it will always be inlined otherwise.

This patch fixes the issues that caused r285456 to be reverted, and can
now be reapplied.

Modified:
libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst
libcxx/trunk/include/__config

libcxx/trunk/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp

Modified: libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst?rev=285531=285530=285531=diff
==
--- libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst (original)
+++ libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst Sun Oct 30 21:07:23 2016
@@ -92,14 +92,13 @@ Visibility Macros
   On all other platforms, this macro has an empty definition.
 
 **_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY**
-  Mark a member function of a class template as hidden and inline except when
-  building the libc++ library where it marks the symbol as being exported by
-  the library.
+  Mark a member function of a class template as visible and always inline. This
+  macro should only be applied to member functions of class templates that are
+  externally instantiated. It is important that these symbols are not marked
+  as hidden as that will prevent the dylib definition from being found.
 
   This macro is used to maintain ABI compatibility for symbols that have been
-  historically exported by the libc++ library but are now marked inline. It
-  should only be applied to member functions of class templates that are
-  externally instantiated.
+  historically exported by the libc++ library but are now marked inline.
 
 **_LIBCPP_EXCEPTION_ABI**
   Mark the member functions, typeinfo, and vtable of the type as being exported

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=285531=285530=285531=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Sun Oct 30 21:07:23 2016
@@ -609,11 +609,7 @@ namespace std {
 #endif
 
 #ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
-# ifdef _LIBCPP_BUILDING_LIBRARY
-#   define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY 
__attribute__((__visibility__("default"), __always_inline__))
-# else
-#   define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
-# endif
+# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY 
__attribute__((__visibility__("default"), __always_inline__))
 #endif
 
 #ifndef _LIBCPP_PREFERRED_OVERLOAD

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp?rev=285531=285530=285531=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp 
Sun Oct 30 21:07:23 2016
@@ -27,6 +27,11 @@ struct some_alloc
 ~some_alloc() noexcept(false);
 };
 
+// Test that it's possible to take the address of basic_string's destructors
+// by creating globals which will register their destructors with cxa_atexit.
+std::string s;
+std::wstring ws;
+
 int main()
 {
 {


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


[PATCH] D25857: [tsan][clang] Introduce a function attribute to disable TSan checking at run time

2016-10-30 Thread Dmitry Vyukov via cfe-commits
dvyukov added inline comments.



Comment at: lib/CodeGen/CodeGenFunction.cpp:717
 
+  // Ignore TSan memory acesses from within dealloc and all of its calees at
+  // run time.

This is unpleasant. We had recursive ignores in the old Valgrind-based tsan, 
but managed to not reintroduce them in the new tsan so far. But I also don't 
see any better solution.




Comment at: lib/CodeGen/CodeGenFunction.cpp:721
+if (const auto *M = dyn_cast_or_null(D))
+  if (M->getMethodFamily() == OMF_dealloc)
+Fn->addFnAttr("sanitize_thread_no_checking_at_run_time");

Can we do this check right in the tsan pass? Or this information is already 
lost there?



Comment at: lib/CodeGen/CodeGenFunction.cpp:722
+  if (M->getMethodFamily() == OMF_dealloc)
+Fn->addFnAttr("sanitize_thread_no_checking_at_run_time");
+

Also do:
   Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
That's what will effectively happen. And it will allow to simplify the other 
patch.


https://reviews.llvm.org/D25857



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


[PATCH] D26132: [clang-format] Skip over AnnotatedLines with >50 levels of nesting.

2016-10-30 Thread Sam McCall via cfe-commits
sammccall updated this revision to Diff 76348.
sammccall added a comment.

Fixing style.


https://reviews.llvm.org/D26132

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7179,6 +7179,30 @@
   verifyFormat("operator");
 }
 
+TEST_F(FormatTest, SkipsDeeplyNestedLines) {
+  // This code would be painfully slow to format if we didn't skip it.
+  std::string Code("A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n" // 20x
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(1, 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n" // 10x
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1);\n");
+  // Deeply nested part is untouched, rest is formatted.
+  EXPECT_EQ(std::string("int i;\n") + Code + "int j;\n",
+format(std::string("inti;\n") + Code + "intj;\n",
+   getLLVMStyle(), IC_ExpectIncomplete));
+}
+
 
//===--===//
 // Objective-C tests.
 
//===--===//
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1566,14 +1566,29 @@
   }
 }
 
+static unsigned maxNestingDepth(const AnnotatedLine ) {
+  unsigned Result = 0;
+  for (const auto* Tok = Line.First; Tok != nullptr; Tok = Tok->Next)
+Result = std::max(Result, Tok->NestingLevel);
+  return Result;
+}
+
 void TokenAnnotator::annotate(AnnotatedLine ) {
   for (SmallVectorImpl::iterator I = Line.Children.begin(),
   E = Line.Children.end();
I != E; ++I) {
 annotate(**I);
   }
   AnnotatingParser Parser(Style, Line, Keywords);
   Line.Type = Parser.parseLine();
+
+  // With very deep nesting, ExpressionParser uses lots of stack and the
+  // formatting algorithm is very slow. We're not going to do a good job here
+  // anyway - it's probably generated code being formatted by mistake.
+  // Just skip the whole line.
+  if (maxNestingDepth(Line) > 50)
+Line.Type = LT_Invalid;
+
   if (Line.Type == LT_Invalid)
 return;
 


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7179,6 +7179,30 @@
   verifyFormat("operator");
 }
 
+TEST_F(FormatTest, SkipsDeeplyNestedLines) {
+  // This code would be painfully slow to format if we didn't skip it.
+  std::string Code("A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n" // 20x
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(1, 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n" // 10x
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1);\n");
+  // Deeply nested part is untouched, rest is formatted.
+  EXPECT_EQ(std::string("int i;\n") + Code + "int j;\n",
+format(std::string("inti;\n") + Code + "intj;\n",
+   getLLVMStyle(), IC_ExpectIncomplete));
+}
+
 //===--===//
 // Objective-C tests.
 //===--===//
Index: lib/Format/TokenAnnotator.cpp

[PATCH] D26132: [clang-format] Skip over AnnotatedLines with >50 levels of nesting.

2016-10-30 Thread Sam McCall via cfe-commits
sammccall created this revision.
sammccall added a reviewer: djasper.
sammccall added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Skip over AnnotatedLines with >50 levels of nesting; don't format them.

Reasoning:

- ExpressionParser uses a lot of stack for these, bad in some environments.
- Our formatting algorithm is N^3 and gets really slow.
- The resulting formatting is unlikely to be any good.
- This is probably generated code we're formatting by accident.

We treat these as unparseable, and signal incomplete formatting.
50 is an arbitrary number, I've only seen real problems from ~150 levels.


https://reviews.llvm.org/D26132

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7179,6 +7179,30 @@
   verifyFormat("operator");
 }
 
+TEST_F(FormatTest, SkipsDeeplyNestedLines) {
+  // This code would be painfully slow to format if we didn't skip it.
+  std::string Code("A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n" // 20x
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(1, 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n" // 10x
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1);\n");
+  // Deeply nested part is untouched, rest is formatted.
+  EXPECT_EQ(std::string("int i;\n") + Code + "int j;\n",
+format(std::string("inti;\n") + Code + "intj;\n",
+   getLLVMStyle(), IC_ExpectIncomplete));
+}
+
 
//===--===//
 // Objective-C tests.
 
//===--===//
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1566,14 +1566,29 @@
   }
 }
 
+static unsigned MaxNestingDepth(const AnnotatedLine ) {
+  unsigned Result = 0;
+  for (const auto* Tok = Line.First; Tok != nullptr; Tok = Tok->Next)
+Result = std::max(Result, Tok->NestingLevel);
+  return Result;
+}
+
 void TokenAnnotator::annotate(AnnotatedLine ) {
   for (SmallVectorImpl::iterator I = Line.Children.begin(),
   E = Line.Children.end();
I != E; ++I) {
 annotate(**I);
   }
   AnnotatingParser Parser(Style, Line, Keywords);
   Line.Type = Parser.parseLine();
+
+  // With very deep nesting, ExpressionParser uses lots of stack and the
+  // formatting algorithm is very slow. We're not going to do a good job here
+  // anyway - it's probably generated code being formatted by mistake.
+  // Just skip the whole line.
+  if (MaxNestingDepth(Line) > 50)
+Line.Type = LT_Invalid;
+
   if (Line.Type == LT_Invalid)
 return;
 


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7179,6 +7179,30 @@
   verifyFormat("operator");
 }
 
+TEST_F(FormatTest, SkipsDeeplyNestedLines) {
+  // This code would be painfully slow to format if we didn't skip it.
+  std::string Code("A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n" // 20x
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(A(\n"
+   "A(1, 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n" // 10x
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+   ", 1), 1), 1), 1), 1), 1), 1), 1), 1), 1)\n"
+

[libcxx] r285530 - Improve performance of constructing filesystem::path from strings.

2016-10-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Oct 30 18:53:50 2016
New Revision: 285530

URL: http://llvm.org/viewvc/llvm-project?rev=285530=rev
Log:
Improve performance of constructing filesystem::path from strings.

This patch fixes a performance bug when constructing or appending to a path
from a string or c-string. Previously we called 'push_back' to append every
single character. This caused multiple re-allocation and copies when at most
one reallocation is necessary. The new behavior is to simply call
`string::append` so it can correctly handle reallocation.

For large strings this change is a ~4x improvement. This also makes our path
faster to construct than libstdc++'s.

Modified:
libcxx/trunk/benchmarks/filesystem.bench.cpp
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/src/experimental/filesystem/path.cpp

Modified: libcxx/trunk/benchmarks/filesystem.bench.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/filesystem.bench.cpp?rev=285530=285529=285530=diff
==
--- libcxx/trunk/benchmarks/filesystem.bench.cpp (original)
+++ libcxx/trunk/benchmarks/filesystem.bench.cpp Sun Oct 30 18:53:50 2016
@@ -21,11 +21,27 @@ void BM_PathConstructString(benchmark::S
 benchmark::DoNotOptimize(P.native().data());
   }
 }
-BENCHMARK_CAPTURE(BM_PathConstructString, iterate_elements,
+BENCHMARK_CAPTURE(BM_PathConstructString, large_string,
   getRandomStringInputs)->Arg(TestNumInputs);
 
 
 template 
+void BM_PathConstructCStr(benchmark::State , GenInputs gen) {
+  using namespace fs;
+  const auto in = gen(st.range(0));
+  path PP;
+  for (auto& Part : in)
+PP /= Part;
+  benchmark::DoNotOptimize(PP.native().data());
+  while (st.KeepRunning()) {
+const path P(PP.native().c_str());
+benchmark::DoNotOptimize(P.native().data());
+  }
+}
+BENCHMARK_CAPTURE(BM_PathConstructCStr, large_string,
+  getRandomStringInputs)->Arg(TestNumInputs);
+
+template 
 void BM_PathIterateMultipleTimes(benchmark::State , GenInputs gen) {
   using namespace fs;
   const auto in = gen(st.range(0));
@@ -85,6 +101,4 @@ void BM_PathIterateOnceBackwards(benchma
 BENCHMARK_CAPTURE(BM_PathIterateOnceBackwards, iterate_elements,
   getRandomStringInputs)->Arg(TestNumInputs);
 
-
-
 BENCHMARK_MAIN()

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=285530=285529=285530=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Sun Oct 30 18:53:50 2016
@@ -623,10 +623,10 @@ struct _PathCVT {
 
 template <>
 struct _PathCVT {
+
 template 
 static void __append_range(string& __dest, _Iter __b, _Iter __e) {
-for (; __b != __e; ++__b)
-__dest.push_back(*__b);
+__dest.append(__b, __e);
 }
 
 template 
@@ -640,7 +640,8 @@ struct _PathCVT {
 static void __append_source(string& __dest, _Source const& __s)
 {
 using _Traits = __is_pathable<_Source>;
-__append_range(__dest, _Traits::__range_begin(__s), 
_Traits::__range_end(__s));
+__append_range(__dest, _Traits::__range_begin(__s),
+   _Traits::__range_end(__s));
 }
 };
 

Modified: libcxx/trunk/src/experimental/filesystem/path.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/path.cpp?rev=285530=285529=285530=diff
==
--- libcxx/trunk/src/experimental/filesystem/path.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/path.cpp Sun Oct 30 18:53:50 2016
@@ -42,8 +42,7 @@ private:
 public:
   PathParser(string_view_t P, string_view_t E, unsigned char S)
   : Path(P), RawEntry(E), State(static_cast(S)) {
-assert(S != 0);
-assert(S != PS_BeforeBegin);
+// S cannot be '0' or PS_BeforeBegin.
   }
 
   static PathParser CreateBegin(string_view_t P) noexcept {
@@ -94,7 +93,6 @@ public:
 
 case PS_InFilenames: {
   PosPtr SepEnd = consumeSeparator(Start, End);
-  assert(SepEnd);
   if (SepEnd != End) {
 PosPtr TkEnd = consumeName(SepEnd, End);
 if (TkEnd)
@@ -131,7 +129,6 @@ public:
  SepEnd + 1, RStart + 1);
   } else {
 PosPtr TkStart = consumeName(RStart, REnd);
-assert(TkStart);
 if (TkStart == REnd + 2 && consumeSeparator(TkStart, REnd) == REnd)
   return makeState(PS_InRootName, Path.data(), RStart + 1);
 else
@@ -192,14 +189,10 @@ public:
 
 private:
   void makeState(ParserState NewState, PosPtr Start, PosPtr End) noexcept {
-assert(NewState != PS_BeforeBegin && NewState != PS_AtEnd);
 State = NewState;
-assert(Start < End);
-assert(Start >= () && End <= () + 1);
 RawEntry = string_view_t(Start, End - Start);
   

[libcxx] r285526 - Rewrite std::filesystem::path iterators and parser

2016-10-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Oct 30 18:30:38 2016
New Revision: 285526

URL: http://llvm.org/viewvc/llvm-project?rev=285526=rev
Log:
Rewrite std::filesystem::path iterators and parser

This patch entirely rewrites the parsing logic for paths. Unlike the previous
implementation this one stores information about the current state; For example
if we are in a trailing separator or a root separator. This avoids the need for
extra lookahead (and extra work) when incrementing or decrementing an iterator.
Roughly this gives us a 15% speedup over the previous implementation.

Unfortunately this implementation is still a lot slower than libstdc++'s.
Because libstdc++ pre-parses and splits the path upon construction their
iterators are trivial to increment/decrement. This makes libc++ lazy parsing
100x slower than libstdc++. However the pre-parsing libstdc++ causes a ton
of extra and unneeded allocations when constructing the string. For example
`path("/foo/bar/")` would require at least 5 allocations with libstdc++
whereas libc++ uses only one. The non-allocating behavior is much preferable
when you consider filesystem usages like 'exists("/foo/bar/")'.

Even then libc++'s path seems to be twice as slow to simply construct compared
to libstdc++. More investigation is needed about this.

Added:
libcxx/trunk/test/libcxx/experimental/filesystem/class.path/path.itr/

libcxx/trunk/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp
Modified:
libcxx/trunk/benchmarks/CMakeLists.txt
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/src/experimental/filesystem/path.cpp

Modified: libcxx/trunk/benchmarks/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/CMakeLists.txt?rev=285526=285525=285526=diff
==
--- libcxx/trunk/benchmarks/CMakeLists.txt (original)
+++ libcxx/trunk/benchmarks/CMakeLists.txt Sun Oct 30 18:30:38 2016
@@ -115,7 +115,8 @@ macro(add_benchmark_test name source_fil
   if (LIBCXX_BENCHMARK_NATIVE_STDLIB)
 set(native_target ${name}_native)
 add_executable(${native_target} EXCLUDE_FROM_ALL ${source_file})
-add_dependencies(${native_target} google-benchmark-native)
+add_dependencies(${native_target} google-benchmark-native
+  google-benchmark-libcxx)
 target_link_libraries(${native_target} -lbenchmark)
 if (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++")
   target_link_libraries(${native_target} -lstdc++fs)

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=285526=285525=285526=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Sun Oct 30 18:30:38 2016
@@ -1083,7 +1083,8 @@ public:
 typedef const path&reference;
 public:
 _LIBCPP_INLINE_VISIBILITY
-iterator() : __elem_(), __path_ptr_(nullptr), __pos_(0) {}
+iterator() : __stashed_elem_(), __path_ptr_(nullptr),
+ __entry_(), __state_(__singular) {}
 
 iterator(const iterator&) = default;
 ~iterator() = default;
@@ -1092,16 +1093,20 @@ public:
 
 _LIBCPP_INLINE_VISIBILITY
 reference operator*() const {
-return __elem_;
+return __stashed_elem_;
 }
 
 _LIBCPP_INLINE_VISIBILITY
 pointer operator->() const {
-return &__elem_;
+return &__stashed_elem_;
 }
 
 _LIBCPP_INLINE_VISIBILITY
 iterator& operator++() {
+_LIBCPP_ASSERT(__state_ != __singular,
+   "attempting to increment a singular iterator");
+_LIBCPP_ASSERT(__state_ != __at_end,
+  "attempting to increment the end iterator");
 return __increment();
 }
 
@@ -1114,6 +1119,10 @@ public:
 
 _LIBCPP_INLINE_VISIBILITY
 iterator& operator--() {
+_LIBCPP_ASSERT(__state_ != __singular,
+   "attempting to decrement a singular iterator");
+_LIBCPP_ASSERT(__entry_.data() != __path_ptr_->native().data(),
+   "attempting to decrement the begin iterator");
 return __decrement();
 }
 
@@ -1127,21 +1136,25 @@ public:
 private:
 friend class path;
 
+static constexpr unsigned char __singular = 0;
+static constexpr unsigned char __at_end = 6;
+
 inline _LIBCPP_INLINE_VISIBILITY
 friend bool operator==(const iterator&, const iterator&);
 
 _LIBCPP_FUNC_VIS iterator& __increment();
 _LIBCPP_FUNC_VIS iterator& __decrement();
 
-path __elem_;
+path __stashed_elem_;
 const path* __path_ptr_;
-size_t __pos_;
+path::__string_view __entry_;
+unsigned char __state_;
 };
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool operator==(const path::iterator& __lhs, const path::iterator& 

r285525 - Fix clang installed path to handle case where clang is invoked through a symlink

2016-10-30 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Sun Oct 30 18:26:13 2016
New Revision: 285525

URL: http://llvm.org/viewvc/llvm-project?rev=285525=rev
Log:
Fix clang installed path to handle case where clang is invoked through a symlink

This code path is used when generating the path to libLTO.dylib, which
is passed to the linker as `-lto_library'.
Without this, if clang is invoked through a symlink, libLTO is
searched in a path relative to where the symlink is instead of
where clang is actually installed.

Fix PR30811.

Patch by: Jack Howarth

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=285525=285524=285525=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sun Oct 30 18:26:13 2016
@@ -8208,7 +8208,7 @@ void darwin::Linker::AddLinkArgs(Compila
   // and 'ld' will use its default mechanism to search for libLTO.dylib.
   if (Version[0] >= 133) {
 // Search for libLTO in /../lib/libLTO.dylib
-StringRef P = llvm::sys::path::parent_path(D.getInstalledDir());
+StringRef P = llvm::sys::path::parent_path(D.Dir);
 SmallString<128> LibLTOPath(P);
 llvm::sys::path::append(LibLTOPath, "lib");
 llvm::sys::path::append(LibLTOPath, "libLTO.dylib");


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


[PATCH] D26075: Change from "XFAIL: libcpp-no-exceptions" to "UNSUPPORTED: libcpp-no-exceptions" tests that only check exceptions and nothing else

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

LGTM as well.


https://reviews.llvm.org/D26075



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


[libcxx] r285524 - Add start of filesystem benchmarks

2016-10-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Oct 30 17:53:00 2016
New Revision: 285524

URL: http://llvm.org/viewvc/llvm-project?rev=285524=rev
Log:
Add start of filesystem benchmarks

Added:
libcxx/trunk/benchmarks/filesystem.bench.cpp
Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/benchmarks/CMakeLists.txt
libcxx/trunk/benchmarks/GenerateInput.hpp
libcxx/trunk/docs/BuildingLibcxx.rst

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=285524=285523=285524=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Sun Oct 30 17:53:00 2016
@@ -58,8 +58,24 @@ option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRAR
 option(LIBCXX_ENABLE_FILESYSTEM
 "Build filesystem as part of libc++experimental.a" 
${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY})
 option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
+
+
+# Benchmark options ---
 option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their 
dependancies" ON)
-option(LIBCXX_BUILD_BENCHMARK_NATIVE_STDLIB "Build the benchmarks against the 
native STL" OFF)
+set(LIBCXX_BENCHMARK_NATIVE_STDLIB "" CACHE STRING
+"Build the benchmarks against the specified native STL.
+ The value must be one of libc++/libstdc++")
+set(LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN "" CACHE STRING
+"Use alternate GCC toolchain when building the native benchmarks")
+
+if (LIBCXX_BENCHMARK_NATIVE_STDLIB)
+  if (NOT (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++"
+OR LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++"))
+message(FATAL_ERROR "Invalid value for LIBCXX_BENCHMARK_NATIVE_STDLIB: "
+"'${LIBCXX_BENCHMARK_NATIVE_STDLIB}'")
+  endif()
+endif()
+
 option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." 
${LLVM_INCLUDE_DOCS})
 set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
 "Define suffix of library directory name (32/64)")

Modified: libcxx/trunk/benchmarks/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/CMakeLists.txt?rev=285524=285523=285524=diff
==
--- libcxx/trunk/benchmarks/CMakeLists.txt (original)
+++ libcxx/trunk/benchmarks/CMakeLists.txt Sun Oct 30 17:53:00 2016
@@ -37,7 +37,14 @@ ExternalProject_Add(google-benchmark-lib
 #==
 # Build Google Benchmark for the native stdlib
 #==
-if (LIBCXX_BUILD_BENCHMARK_NATIVE_STDLIB)
+set(BENCHMARK_NATIVE_TARGET_FLAGS)
+if (LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN)
+  set(BENCHMARK_NATIVE_TARGET_FLAGS
+  -gcc-toolchain ${LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN})
+endif()
+split_list(BENCHMARK_NATIVE_TARGET_FLAGS)
+
+if (LIBCXX_BENCHMARK_NATIVE_STDLIB)
   ExternalProject_Add(google-benchmark-native
 EXCLUDE_FROM_ALL ON
 PREFIX benchmark-native
@@ -46,6 +53,7 @@ if (LIBCXX_BUILD_BENCHMARK_NATIVE_STDLIB
 CMAKE_CACHE_ARGS
   -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
   -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
+  -DCMAKE_CXX_FLAGS:STRING=${BENCHMARK_NATIVE_TARGET_FLAGS}
   -DCMAKE_BUILD_TYPE:STRING=RELEASE
   -DCMAKE_INSTALL_PREFIX:PATH=
   -DBENCHMARK_ENABLE_TESTING:BOOL=OFF)
@@ -72,12 +80,18 @@ set(BENCHMARK_TEST_LIBCXX_LINK_FLAGS
 -nodefaultlibs
 -L${BENCHMARK_LIBCXX_INSTALL}/lib/
 )
+set(BENCHMARK_TEST_NATIVE_COMPILE_FLAGS
+  ${BENCHMARK_NATIVE_TARGET_FLAGS}
+  ${BENCHMARK_TEST_COMPILE_FLAGS}
+)
 set(BENCHMARK_TEST_NATIVE_LINK_FLAGS
--L${BENCHMARK_NATIVE_INSTALL}/lib/
+${BENCHMARK_NATIVE_TARGET_FLAGS}
+-L${BENCHMARK_NATIVE_INSTALL}/lib
 )
 split_list(BENCHMARK_TEST_COMPILE_FLAGS)
 split_list(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS)
 split_list(BENCHMARK_TEST_LIBCXX_LINK_FLAGS)
+split_list(BENCHMARK_TEST_NATIVE_COMPILE_FLAGS)
 split_list(BENCHMARK_TEST_NATIVE_LINK_FLAGS)
 macro(add_benchmark_test name source_file)
   set(libcxx_target ${name}_libcxx)
@@ -89,17 +103,25 @@ macro(add_benchmark_test name source_fil
   else()
 target_link_libraries(${libcxx_target} cxx_static)
   endif()
+  if (TARGET cxx_experimental)
+target_link_libraries(${libcxx_target} cxx_experimental)
+  endif()
   target_link_libraries(${libcxx_target} -lbenchmark)
   set_target_properties(${libcxx_target}
 PROPERTIES
   OUTPUT_NAME "${name}.libcxx.out"
   COMPILE_FLAGS "${BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS}"
   LINK_FLAGS "${BENCHMARK_TEST_LIBCXX_LINK_FLAGS}")
-  if (LIBCXX_BUILD_BENCHMARK_NATIVE_STDLIB)
+  if (LIBCXX_BENCHMARK_NATIVE_STDLIB)
 set(native_target ${name}_native)
 add_executable(${native_target} EXCLUDE_FROM_ALL ${source_file})
 

[PATCH] D26082: Support for Python 3 in libclang python bindings

2016-10-30 Thread Jonathan B Coe via cfe-commits
jbcoe removed rL LLVM as the repository for this revision.
jbcoe updated this revision to Diff 76344.
jbcoe added a comment.

Remove mistakenly committed debugging output.


https://reviews.llvm.org/D26082

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

Index: bindings/python/tests/cindex/test_translation_unit.py
===
--- bindings/python/tests/cindex/test_translation_unit.py
+++ bindings/python/tests/cindex/test_translation_unit.py
@@ -59,9 +59,13 @@
 assert spellings[-1] == 'y'
 
 def test_unsaved_files_2():
-import StringIO
+try:
+from StringIO import StringIO
+except:
+from io import StringIO
+
 tu = TranslationUnit.from_source('fake.c', unsaved_files = [
-('fake.c', StringIO.StringIO('int x;'))])
+('fake.c', StringIO('int x;'))])
 spellings = [c.spelling for c in tu.cursor.get_children()]
 assert spellings[-1] == 'x'
 
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -73,6 +73,30 @@
 # this by marshalling object arguments as void**.
 c_object_p = POINTER(c_void_p)
 
+# Python 3 strings are unicode, translate them to/from utf8 for C-interop
+if type(u"") == str:
+class c_string_p(c_char_p):
+def __init__(self, p=None):
+if type(p) == str:
+p = p.encode("utf8")
+super(c_char_p, self).__init__(p)
+
+def __str__(self):
+return str(self.value)
+
+@property
+def value(self):
+if super(c_char_p, self).value is None:
+return None
+return super(c_char_p, self).value.decode("utf8")
+
+@classmethod
+def from_param(cls, param):
+return cls(param)
+else:
+c_string_p = c_char_p
+
+
 callbacks = {}
 
 ### Exception Classes ###
@@ -147,7 +171,7 @@
 class _CXString(Structure):
 """Helper for transforming CXString results."""
 
-_fields_ = [("spelling", c_char_p), ("free", c_int)]
+_fields_ = [("spelling", c_string_p), ("free", c_int)]
 
 def __del__(self):
 conf.lib.clang_disposeString(self)
@@ -329,7 +353,7 @@
 
 @property
 def spelling(self):
-return conf.lib.clang_getDiagnosticSpelling(self)
+return str(conf.lib.clang_getDiagnosticSpelling(self))
 
 @property
 def ranges(self):
@@ -358,8 +382,8 @@
 
 def __getitem__(self, key):
 range = SourceRange()
-value = conf.lib.clang_getDiagnosticFixIt(self.diag, key,
-byref(range))
+value = str(conf.lib.clang_getDiagnosticFixIt(self.diag, key,
+byref(range)))
 if len(value) == 0:
 raise IndexError
 
@@ -392,20 +416,20 @@
 @property
 def category_name(self):
 """The string name of the category for this diagnostic."""
-return conf.lib.clang_getDiagnosticCategoryText(self)
+return str(conf.lib.clang_getDiagnosticCategoryText(self))
 
 @property
 def option(self):
 """The command-line option that enables this diagnostic."""
-return conf.lib.clang_getDiagnosticOption(self, None)
+return str(conf.lib.clang_getDiagnosticOption(self, None))
 
 @property
 def disable_option(self):
 """The command-line option that disables this diagnostic."""
 disable = _CXString()
 conf.lib.clang_getDiagnosticOption(self, byref(disable))
 
-return conf.lib.clang_getCString(disable)
+return str(conf.lib.clang_getCString(disable))
 
 def format(self, options=None):
 """
@@ -491,7 +515,7 @@
 
 token_group = TokenGroup(tu, tokens_memory, tokens_count)
 
-for i in xrange(0, count):
+for i in range(0, count):
 token = Token()
 token.int_data = tokens_array[i].int_data
 token.ptr_data = tokens_array[i].ptr_data
@@ -554,8 +578,8 @@
 if value >= len(self.__class__._kinds):
 self.__class__._kinds += [None] * (value - len(self.__class__._kinds) + 1)
 if self.__class__._kinds[value] is not None:
-raise ValueError,'{0} value {1} already loaded'.format(
-str(self.__class__), value)
+raise ValueError('{0} value {1} already loaded'.format(
+str(self.__class__), value))
 self.value = value
 self.__class__._kinds[value] = self
 self.__class__._name_map = None
@@ -572,12 +596,12 @@
 for key, value in self.__class__.__dict__.items():
 if isinstance(value, self.__class__):
 self._name_map[value] = key
-return self._name_map[self]
+return str(self._name_map[self])
 
 @classmethod
 def from_id(cls, 

[PATCH] D26075: Change from "XFAIL: libcpp-no-exceptions" to "UNSUPPORTED: libcpp-no-exceptions" tests that only check exceptions and nothing else

2016-10-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

This looks sensible to me. I'll let @EricWF approve.

/ Asiri


https://reviews.llvm.org/D26075



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


Re: [libcxx] r285382 - Add __libcpp_version file and __libcpp_library_version function.

2016-10-30 Thread Eric Fiselier via cfe-commits
> As I said, this is not a decision based on the libc++ version.

It is at least partially based on the libc++ version. We obviously can't
enable the feature if libc++ does not yet support them.

/Eric

On Sun, Oct 30, 2016 at 2:00 PM, Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Sun, Oct 30, 2016 at 01:49:53PM -0600, Eric Fiselier via cfe-commits
> wrote:
> > >  E.g. presence of libc++ won't tell you if you can use sized
> deallocation
> > > as that's a ABI library issue.
> >
> >  The value of __libcpp_version could easily be updated by vendors to
> store
> > the version of the system dylib,
> > so I don't see why this wouldn't work.
>
> As I said, this is not a decision based on the libc++ version. When we
> start adding random extra flags to the version file, it makes the point
> I'm raising even bigger: we are duplicating data and clang should not be
> magically changing its behavior like that anyway.
>
> Joerg
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24703: [clang-format] BreakBeforeBinaryOperations and AlignAfterOpenBracket conflict, bug 30304

2016-10-30 Thread Daphne Pfister via cfe-commits
daphnediane added a comment.

ping.

FYI I have found some additional similar cases when 
AlignConsecutiveDeclarations is also true, that I'll see if I can document/test 
case etc. at some point.


https://reviews.llvm.org/D24703



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


[libcxxabi] r285523 - Mark thread exit test as unsupported w/o threads

2016-10-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Oct 30 15:05:52 2016
New Revision: 285523

URL: http://llvm.org/viewvc/llvm-project?rev=285523=rev
Log:
Mark thread exit test as unsupported w/o threads

Modified:
libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp

Modified: libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp?rev=285523=285522=285523=diff
==
--- libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp (original)
+++ libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp Sun Oct 30 15:05:52 
2016
@@ -7,6 +7,7 @@
 //
 
//===--===//
 
+// UNSUPPORTED: libcppabi-no-threads
 // REQUIRES: linux
 
 #include 


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


[PATCH] D26125: [clang-tidy] Fixed else-after-return warning in cascade if statement

2016-10-30 Thread Paweł Żukowski via cfe-commits
idlecode added a comment.

@mgehre: Yes it does - in your case AST looks like `ifStmt(b) - CompoundStmt - 
ifStmt(c)`, so ifStmt's don't have direct parent-child relations.
But there is another problem:

  while(a)
if (b)
  return 1;
else
  doSomething(2);

In such case, generated fix (with and without this fix) will change semantics 
of program.
As @djasper suggested, I need to take a look at this check history and update 
patch accordingly.


https://reviews.llvm.org/D26125



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


Re: [libcxx] r285382 - Add __libcpp_version file and __libcpp_library_version function.

2016-10-30 Thread Joerg Sonnenberger via cfe-commits
On Sun, Oct 30, 2016 at 01:49:53PM -0600, Eric Fiselier via cfe-commits wrote:
> >  E.g. presence of libc++ won't tell you if you can use sized deallocation
> > as that's a ABI library issue.
> 
>  The value of __libcpp_version could easily be updated by vendors to store
> the version of the system dylib,
> so I don't see why this wouldn't work.

As I said, this is not a decision based on the libc++ version. When we
start adding random extra flags to the version file, it makes the point
I'm raising even bigger: we are duplicating data and clang should not be
magically changing its behavior like that anyway.

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


Re: [libcxx] r285382 - Add __libcpp_version file and __libcpp_library_version function.

2016-10-30 Thread Eric Fiselier via cfe-commits
>  E.g. presence of libc++ won't tell you if you can use sized deallocation
as that's a ABI library issue.

 The value of __libcpp_version could easily be updated by vendors to store
the version of the system dylib,
so I don't see why this wouldn't work.

> So, why again should clang care about the libc++ version in advance?

I'll leave that for Richard to answer.

/Eric

On Sun, Oct 30, 2016 at 1:32 PM, Joerg Sonnenberger  wrote:

> On Sun, Oct 30, 2016 at 12:54:28PM -0600, Eric Fiselier wrote:
> > Richard requested this change. Take a look at
> > https://reviews.llvm.org/D26044 for more rational.
>
> I don't see much rational and in fact, I disagree with some of the
> mentioned items. E.g. presence of libc++ won't tell you if you can use
> sized deallocation as that's a ABI library issue. So, why again should
> clang care about the libc++ version in advance?
>
> Joerg
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r285382 - Add __libcpp_version file and __libcpp_library_version function.

2016-10-30 Thread Joerg Sonnenberger via cfe-commits
On Sun, Oct 30, 2016 at 12:54:28PM -0600, Eric Fiselier wrote:
> Richard requested this change. Take a look at
> https://reviews.llvm.org/D26044 for more rational.

I don't see much rational and in fact, I disagree with some of the
mentioned items. E.g. presence of libc++ won't tell you if you can use
sized deallocation as that's a ABI library issue. So, why again should
clang care about the libc++ version in advance?

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


[PATCH] D26125: [clang-tidy] Fixed else-after-return warning in cascade if statement

2016-10-30 Thread Matthias Gehre via cfe-commits
mgehre added a comment.

With this fix, is there still a warning on the following code?

  if(b) {
 ...
 if(c)
  return;
 else
  doSomething()
 ...
  }

I would expect that the check still warns on it.


https://reviews.llvm.org/D26125



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


Re: [libcxx] r285382 - Add __libcpp_version file and __libcpp_library_version function.

2016-10-30 Thread Eric Fiselier via cfe-commits
Richard requested this change. Take a look at
https://reviews.llvm.org/D26044 for more rational.

On Sat, Oct 29, 2016 at 2:28 PM, Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Fri, Oct 28, 2016 at 06:06:50AM -, Eric Fiselier via cfe-commits
> wrote:
> > Author: ericwf
> > Date: Fri Oct 28 01:06:50 2016
> > New Revision: 285382
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=285382=rev
> > Log:
> > Add __libcpp_version file and __libcpp_library_version function.
>
> I really don't see why this is preferable over just checking __config or
> the classic approach of including  and checking the macros.
>
> Joerg
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26082: Support for Python 3 in libclang python bindings

2016-10-30 Thread Jonathan B Coe via cfe-commits
jbcoe retitled this revision from "Incomplete support for Python 3 in libclang 
python bindings" to "Support for Python 3 in libclang python bindings".
jbcoe updated the summary for this revision.
jbcoe updated this revision to Diff 76338.
jbcoe added a comment.

Python bindings tests now pass in Python 3.


Repository:
  rL LLVM

https://reviews.llvm.org/D26082

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_comment.py
  bindings/python/tests/cindex/test_translation_unit.py

Index: bindings/python/tests/cindex/test_translation_unit.py
===
--- bindings/python/tests/cindex/test_translation_unit.py
+++ bindings/python/tests/cindex/test_translation_unit.py
@@ -59,9 +59,13 @@
 assert spellings[-1] == 'y'
 
 def test_unsaved_files_2():
-import StringIO
+try:
+from StringIO import StringIO
+except:
+from io import StringIO
+
 tu = TranslationUnit.from_source('fake.c', unsaved_files = [
-('fake.c', StringIO.StringIO('int x;'))])
+('fake.c', StringIO('int x;'))])
 spellings = [c.spelling for c in tu.cursor.get_children()]
 assert spellings[-1] == 'x'
 
Index: bindings/python/tests/cindex/test_comment.py
===
--- bindings/python/tests/cindex/test_comment.py
+++ bindings/python/tests/cindex/test_comment.py
@@ -34,6 +34,12 @@
 f = get_cursor(tu, 'f')
 raw = f.raw_comment
 brief = f.brief_comment
+
+print(raw)
+print(type(raw))
+print(brief)
+print(type(brief))
+
 assert raw is None
 assert brief is None
 
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -73,6 +73,30 @@
 # this by marshalling object arguments as void**.
 c_object_p = POINTER(c_void_p)
 
+# Python 3 strings are unicode, translate them to/from utf8 for C-interop
+if type(u"") == str:
+class c_string_p(c_char_p):
+def __init__(self, p=None):
+if type(p) == str:
+p = p.encode("utf8")
+super(c_char_p, self).__init__(p)
+
+def __str__(self):
+return str(self.value)
+
+@property
+def value(self):
+if super(c_char_p, self).value is None:
+return None
+return super(c_char_p, self).value.decode("utf8")
+
+@classmethod
+def from_param(cls, param):
+return cls(param)
+else:
+c_string_p = c_char_p
+
+
 callbacks = {}
 
 ### Exception Classes ###
@@ -147,7 +171,7 @@
 class _CXString(Structure):
 """Helper for transforming CXString results."""
 
-_fields_ = [("spelling", c_char_p), ("free", c_int)]
+_fields_ = [("spelling", c_string_p), ("free", c_int)]
 
 def __del__(self):
 conf.lib.clang_disposeString(self)
@@ -329,7 +353,7 @@
 
 @property
 def spelling(self):
-return conf.lib.clang_getDiagnosticSpelling(self)
+return str(conf.lib.clang_getDiagnosticSpelling(self))
 
 @property
 def ranges(self):
@@ -358,8 +382,8 @@
 
 def __getitem__(self, key):
 range = SourceRange()
-value = conf.lib.clang_getDiagnosticFixIt(self.diag, key,
-byref(range))
+value = str(conf.lib.clang_getDiagnosticFixIt(self.diag, key,
+byref(range)))
 if len(value) == 0:
 raise IndexError
 
@@ -392,20 +416,20 @@
 @property
 def category_name(self):
 """The string name of the category for this diagnostic."""
-return conf.lib.clang_getDiagnosticCategoryText(self)
+return str(conf.lib.clang_getDiagnosticCategoryText(self))
 
 @property
 def option(self):
 """The command-line option that enables this diagnostic."""
-return conf.lib.clang_getDiagnosticOption(self, None)
+return str(conf.lib.clang_getDiagnosticOption(self, None))
 
 @property
 def disable_option(self):
 """The command-line option that disables this diagnostic."""
 disable = _CXString()
 conf.lib.clang_getDiagnosticOption(self, byref(disable))
 
-return conf.lib.clang_getCString(disable)
+return str(conf.lib.clang_getCString(disable))
 
 def format(self, options=None):
 """
@@ -491,7 +515,7 @@
 
 token_group = TokenGroup(tu, tokens_memory, tokens_count)
 
-for i in xrange(0, count):
+for i in range(0, count):
 token = Token()
 token.int_data = tokens_array[i].int_data
 token.ptr_data = tokens_array[i].ptr_data
@@ -554,8 +578,8 @@
 if value >= len(self.__class__._kinds):
 self.__class__._kinds += [None] * (value - len(self.__class__._kinds) + 1)
 if self.__class__._kinds[value] is 

[PATCH] D26125: [clang-tidy] Fixed else-after-return warning in cascade if statement

2016-10-30 Thread Daniel Jasper via cfe-commits
djasper added inline comments.



Comment at: clang-tidy/readability/ElseAfterReturnCheck.cpp:28
   stmt(forEach(
-  ifStmt(hasThen(stmt(
+  ifStmt(unless(hasParent(ifStmt())),
+ hasThen(stmt(

idlecode wrote:
> djasper wrote:
> > idlecode wrote:
> > > djasper wrote:
> > > > idlecode wrote:
> > > > > djasper wrote:
> > > > > > I think this now effectively does:
> > > > > > 
> > > > > >   stmt(forEach(ifStmt(unless(hasParent(ifSttmt())), ...)
> > > > > > 
> > > > > > I think that's equivalent to:
> > > > > > 
> > > > > >   stmt(unless(ifStmt()), forEach(ifStmt(...)))
> > > > > Apparently you are right - does that mean that this matcher actually 
> > > > > matches node above ifStmt (and just binds ifStmt)?
> > > > > If so maybe such expression would suffice? (it passes tests)
> > > > > ```
> > > > > Finder->addMatcher( // note lack of stmt(forEach(
> > > > >   ifStmt(unless(hasParent(ifStmt())),
> > > > >  hasThen(stmt(
> > > > >  anyOf(ControlFlowInterruptorMatcher,
> > > > >
> > > > > compoundStmt(has(ControlFlowInterruptorMatcher),
> > > > >  hasElse(stmt().bind("else")))
> > > > >   .bind("if"),
> > > > >   this);
> > > > > 
> > > > > ```
> > > > > 
> > > > > But I'm not sure if this would be any better than your version.
> > > > Yeah. That makes sense to me. The difference is that we would start 
> > > > binding ifStmts() that are direct children of declarations. But I don't 
> > > > know whether we have excluded those intentionally. Do any tests break 
> > > > if you make this change?
> > > I have just ran `make check-clang-tools` on updated source tree - no new 
> > > failures. Upload the change?
> > > What do you mean by 'if statement as children of declaration'? (I'm new 
> > > to compilers and just curious :) )
> > I did some more digging. It appears this bug was introduced in 
> > https://reviews.llvm.org/rL278257. The old code specifically did the 
> > forEach stuff to ensure that the ifStmt was a direct child of a compound 
> > stmt. I think we should investigate why this happened and probably undo it. 
> > There are similar to this one here if the ifStmt is a child of a for or 
> > while loop without a compound stmt.
> Indeed, my fix fails for loops.
> Also, do you see any reason why 'goto' was not included in interrupt 
> statements?
I don't think anyone cares about readability when there is "goto" ;)


https://reviews.llvm.org/D26125



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


[PATCH] D26125: [clang-tidy] Fixed else-after-return warning in cascade if statement

2016-10-30 Thread Paweł Żukowski via cfe-commits
idlecode planned changes to this revision.
idlecode added inline comments.



Comment at: clang-tidy/readability/ElseAfterReturnCheck.cpp:28
   stmt(forEach(
-  ifStmt(hasThen(stmt(
+  ifStmt(unless(hasParent(ifStmt())),
+ hasThen(stmt(

djasper wrote:
> idlecode wrote:
> > djasper wrote:
> > > idlecode wrote:
> > > > djasper wrote:
> > > > > I think this now effectively does:
> > > > > 
> > > > >   stmt(forEach(ifStmt(unless(hasParent(ifSttmt())), ...)
> > > > > 
> > > > > I think that's equivalent to:
> > > > > 
> > > > >   stmt(unless(ifStmt()), forEach(ifStmt(...)))
> > > > Apparently you are right - does that mean that this matcher actually 
> > > > matches node above ifStmt (and just binds ifStmt)?
> > > > If so maybe such expression would suffice? (it passes tests)
> > > > ```
> > > > Finder->addMatcher( // note lack of stmt(forEach(
> > > >   ifStmt(unless(hasParent(ifStmt())),
> > > >  hasThen(stmt(
> > > >  anyOf(ControlFlowInterruptorMatcher,
> > > >
> > > > compoundStmt(has(ControlFlowInterruptorMatcher),
> > > >  hasElse(stmt().bind("else")))
> > > >   .bind("if"),
> > > >   this);
> > > > 
> > > > ```
> > > > 
> > > > But I'm not sure if this would be any better than your version.
> > > Yeah. That makes sense to me. The difference is that we would start 
> > > binding ifStmts() that are direct children of declarations. But I don't 
> > > know whether we have excluded those intentionally. Do any tests break if 
> > > you make this change?
> > I have just ran `make check-clang-tools` on updated source tree - no new 
> > failures. Upload the change?
> > What do you mean by 'if statement as children of declaration'? (I'm new to 
> > compilers and just curious :) )
> I did some more digging. It appears this bug was introduced in 
> https://reviews.llvm.org/rL278257. The old code specifically did the forEach 
> stuff to ensure that the ifStmt was a direct child of a compound stmt. I 
> think we should investigate why this happened and probably undo it. There are 
> similar to this one here if the ifStmt is a child of a for or while loop 
> without a compound stmt.
Indeed, my fix fails for loops.
Also, do you see any reason why 'goto' was not included in interrupt statements?


https://reviews.llvm.org/D26125



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


[PATCH] D26125: [clang-tidy] Fixed else-after-return warning in cascade if statement

2016-10-30 Thread Daniel Jasper via cfe-commits
djasper added inline comments.



Comment at: clang-tidy/readability/ElseAfterReturnCheck.cpp:28
   stmt(forEach(
-  ifStmt(hasThen(stmt(
+  ifStmt(unless(hasParent(ifStmt())),
+ hasThen(stmt(

idlecode wrote:
> djasper wrote:
> > idlecode wrote:
> > > djasper wrote:
> > > > I think this now effectively does:
> > > > 
> > > >   stmt(forEach(ifStmt(unless(hasParent(ifSttmt())), ...)
> > > > 
> > > > I think that's equivalent to:
> > > > 
> > > >   stmt(unless(ifStmt()), forEach(ifStmt(...)))
> > > Apparently you are right - does that mean that this matcher actually 
> > > matches node above ifStmt (and just binds ifStmt)?
> > > If so maybe such expression would suffice? (it passes tests)
> > > ```
> > > Finder->addMatcher( // note lack of stmt(forEach(
> > >   ifStmt(unless(hasParent(ifStmt())),
> > >  hasThen(stmt(
> > >  anyOf(ControlFlowInterruptorMatcher,
> > >
> > > compoundStmt(has(ControlFlowInterruptorMatcher),
> > >  hasElse(stmt().bind("else")))
> > >   .bind("if"),
> > >   this);
> > > 
> > > ```
> > > 
> > > But I'm not sure if this would be any better than your version.
> > Yeah. That makes sense to me. The difference is that we would start binding 
> > ifStmts() that are direct children of declarations. But I don't know 
> > whether we have excluded those intentionally. Do any tests break if you 
> > make this change?
> I have just ran `make check-clang-tools` on updated source tree - no new 
> failures. Upload the change?
> What do you mean by 'if statement as children of declaration'? (I'm new to 
> compilers and just curious :) )
I did some more digging. It appears this bug was introduced in 
https://reviews.llvm.org/rL278257. The old code specifically did the forEach 
stuff to ensure that the ifStmt was a direct child of a compound stmt. I think 
we should investigate why this happened and probably undo it. There are similar 
to this one here if the ifStmt is a child of a for or while loop without a 
compound stmt.


https://reviews.llvm.org/D26125



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


[PATCH] D26125: [clang-tidy] Fixed else-after-return warning in cascade if statement

2016-10-30 Thread Paweł Żukowski via cfe-commits
idlecode marked an inline comment as done.
idlecode added inline comments.



Comment at: clang-tidy/readability/ElseAfterReturnCheck.cpp:28
   stmt(forEach(
-  ifStmt(hasThen(stmt(
+  ifStmt(unless(hasParent(ifStmt())),
+ hasThen(stmt(

djasper wrote:
> idlecode wrote:
> > djasper wrote:
> > > I think this now effectively does:
> > > 
> > >   stmt(forEach(ifStmt(unless(hasParent(ifSttmt())), ...)
> > > 
> > > I think that's equivalent to:
> > > 
> > >   stmt(unless(ifStmt()), forEach(ifStmt(...)))
> > Apparently you are right - does that mean that this matcher actually 
> > matches node above ifStmt (and just binds ifStmt)?
> > If so maybe such expression would suffice? (it passes tests)
> > ```
> > Finder->addMatcher( // note lack of stmt(forEach(
> >   ifStmt(unless(hasParent(ifStmt())),
> >  hasThen(stmt(
> >  anyOf(ControlFlowInterruptorMatcher,
> >
> > compoundStmt(has(ControlFlowInterruptorMatcher),
> >  hasElse(stmt().bind("else")))
> >   .bind("if"),
> >   this);
> > 
> > ```
> > 
> > But I'm not sure if this would be any better than your version.
> Yeah. That makes sense to me. The difference is that we would start binding 
> ifStmts() that are direct children of declarations. But I don't know whether 
> we have excluded those intentionally. Do any tests break if you make this 
> change?
I have just ran `make check-clang-tools` on updated source tree - no new 
failures. Upload the change?
What do you mean by 'if statement as children of declaration'? (I'm new to 
compilers and just curious :) )


https://reviews.llvm.org/D26125



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


[PATCH] D26125: [clang-tidy] Fixed else-after-return warning in cascade if statement

2016-10-30 Thread Daniel Jasper via cfe-commits
djasper added inline comments.



Comment at: clang-tidy/readability/ElseAfterReturnCheck.cpp:28
   stmt(forEach(
-  ifStmt(hasThen(stmt(
+  ifStmt(unless(hasParent(ifStmt())),
+ hasThen(stmt(

idlecode wrote:
> djasper wrote:
> > I think this now effectively does:
> > 
> >   stmt(forEach(ifStmt(unless(hasParent(ifSttmt())), ...)
> > 
> > I think that's equivalent to:
> > 
> >   stmt(unless(ifStmt()), forEach(ifStmt(...)))
> Apparently you are right - does that mean that this matcher actually matches 
> node above ifStmt (and just binds ifStmt)?
> If so maybe such expression would suffice? (it passes tests)
> ```
> Finder->addMatcher( // note lack of stmt(forEach(
>   ifStmt(unless(hasParent(ifStmt())),
>  hasThen(stmt(
>  anyOf(ControlFlowInterruptorMatcher,
>
> compoundStmt(has(ControlFlowInterruptorMatcher),
>  hasElse(stmt().bind("else")))
>   .bind("if"),
>   this);
> 
> ```
> 
> But I'm not sure if this would be any better than your version.
Yeah. That makes sense to me. The difference is that we would start binding 
ifStmts() that are direct children of declarations. But I don't know whether we 
have excluded those intentionally. Do any tests break if you make this change?


https://reviews.llvm.org/D26125



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


[PATCH] D26125: [clang-tidy] Fixed else-after-return warning in cascade if statement

2016-10-30 Thread Paweł Żukowski via cfe-commits
idlecode marked an inline comment as done.
idlecode added inline comments.



Comment at: clang-tidy/readability/ElseAfterReturnCheck.cpp:28
   stmt(forEach(
-  ifStmt(hasThen(stmt(
+  ifStmt(unless(hasParent(ifStmt())),
+ hasThen(stmt(

djasper wrote:
> I think this now effectively does:
> 
>   stmt(forEach(ifStmt(unless(hasParent(ifSttmt())), ...)
> 
> I think that's equivalent to:
> 
>   stmt(unless(ifStmt()), forEach(ifStmt(...)))
Apparently you are right - does that mean that this matcher actually matches 
node above ifStmt (and just binds ifStmt)?
If so maybe such expression would suffice? (it passes tests)
```
Finder->addMatcher( // note lack of stmt(forEach(
  ifStmt(unless(hasParent(ifStmt())),
 hasThen(stmt(
 anyOf(ControlFlowInterruptorMatcher,
   compoundStmt(has(ControlFlowInterruptorMatcher),
 hasElse(stmt().bind("else")))
  .bind("if"),
  this);

```

But I'm not sure if this would be any better than your version.


https://reviews.llvm.org/D26125



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


r285519 - Fixing "type" issue for (epi32)

2016-10-30 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Sun Oct 30 09:54:05 2016
New Revision: 285519

URL: http://llvm.org/viewvc/llvm-project?rev=285519=rev
Log:
Fixing "type" issue for (epi32) 
and replaceing hardcoded inf with clang builtin inf "__builtin_inff()" for 
float ({max|min}_{pd|ps})



Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512-reduceIntrin.c
cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=285519=285518=285519=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Sun Oct 30 09:54:05 2016
@@ -9784,43 +9784,43 @@ _mm512_mask_reduce_mul_pd(__mmask8 __M,
 
 #define _mm512_reduce_operator_32bit(Vec512, Operator, T2, T1) __extension__({ 
\
 __m256##T1 Vec256 =
\
-(__m256##T1)__builtin_shufflevector(   
\
+(__m256##T1)(__builtin_shufflevector(  
\
 (__v16s##T2)Vec512,
\
 (__v16s##T2)Vec512,
\
 0, 1, 2, 3, 4, 5, 6, 7)
\
 Operator   
\
-(__m256##T1)__builtin_shufflevector(   
\
+ __builtin_shufflevector(  
\
 (__v16s##T2)Vec512,
\
 (__v16s##T2)Vec512,
\
-8, 9, 10, 11, 12, 13, 14, 15); 
\
+8, 9, 10, 11, 12, 13, 14, 15));
\
 __m128##T1 Vec128 =
\
- (__m128##T1)__builtin_shufflevector(  
\
+ (__m128##T1)(__builtin_shufflevector( 
\
 (__v8s##T2)Vec256, 
\
 (__v8s##T2)Vec256, 
\
 0, 1, 2, 3)
\
 Operator   
\
- (__m128##T1)__builtin_shufflevector(  
\
+  __builtin_shufflevector( 
\
 (__v8s##T2)Vec256, 
\
 (__v8s##T2)Vec256, 
\
-4, 5, 6, 7);   
\
-Vec128 = (__m128##T1)__builtin_shufflevector(  
\
+4, 5, 6, 7));  
\
+Vec128 = (__m128##T1)(__builtin_shufflevector( 
\
 (__v4s##T2)Vec128, 
\
 (__v4s##T2)Vec128, 
\
 0, 1, -1, -1)  
\
 Operator   
\
- (__m128##T1)__builtin_shufflevector(  
\
+  __builtin_shufflevector( 
\
 (__v4s##T2)Vec128, 
\
 (__v4s##T2)Vec128, 
\
-2, 3, -1, -1); 
\
-Vec128 = (__m128##T1)__builtin_shufflevector(  
\
+2, 3, -1, -1));
\
+Vec128 = (__m128##T1)(__builtin_shufflevector( 
\
 (__v4s##T2)Vec128, 
\
 (__v4s##T2)Vec128, 
\
 0, -1, -1, -1) 
\
 Operator   
\
- (__m128##T1)__builtin_shufflevector(  
\
+  __builtin_shufflevector( 
\
 (__v4s##T2)Vec128, 
\
 (__v4s##T2)Vec128, 
\
-1, -1, -1, -1);
\

[PATCH] D26125: [clang-tidy] Fixed else-after-return warning in cascade if statement

2016-10-30 Thread Daniel Jasper via cfe-commits
djasper added inline comments.



Comment at: clang-tidy/readability/ElseAfterReturnCheck.cpp:28
   stmt(forEach(
-  ifStmt(hasThen(stmt(
+  ifStmt(unless(hasParent(ifStmt())),
+ hasThen(stmt(

I think this now effectively does:

  stmt(forEach(ifStmt(unless(hasParent(ifSttmt())), ...)

I think that's equivalent to:

  stmt(unless(ifStmt()), forEach(ifStmt(...)))


https://reviews.llvm.org/D26125



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


[PATCH] D26125: [clang-tidy] Fixed else-after-return warning in cascade if statement

2016-10-30 Thread Paweł Żukowski via cfe-commits
idlecode created this revision.
idlecode added reviewers: djasper, malcolm.parsons, omtcyfz.
idlecode added a subscriber: cfe-commits.

Fix applied to else in a cascade if statements changed
program semantics in cases when not all previous branches
resulted in flow change.

Fixes PR30652


https://reviews.llvm.org/D26125

Files:
  clang-tidy/readability/ElseAfterReturnCheck.cpp
  test/clang-tidy/readability-else-after-return.cpp


Index: test/clang-tidy/readability-else-after-return.cpp
===
--- test/clang-tidy/readability-else-after-return.cpp
+++ test/clang-tidy/readability-else-after-return.cpp
@@ -29,32 +29,60 @@
   else if (a > 10)
 return;
   else // comment-2
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use 'else' after 'return'
-  // CHECK-FIXES: {{^}}  // comment-2
+  // CHECK-FIXES-NOT: {{^}}  // comment-2
 f(0);
+
+  if (a > 0)
+if (a < 10)
+  return;
+else // comment-3
+// CHECK-FIXES-NOT: {{^}}// comment-3
+  f(0);
+  else
+if (a > 10)
+  return;
+else // comment-4
+// CHECK-FIXES-NOT: {{^}}// comment-4
+  f(0);
+
+  if (a > 0) {
+if (a < 10)
+  return;
+else // comment-5
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use 'else' after 
'return'
+// CHECK-FIXES: {{^}}// comment-5
+  f(0);
+  } else {
+if (a > 10)
+  return;
+else // comment-6
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use 'else' after 
'return'
+// CHECK-FIXES: {{^}}// comment-6
+  f(0);
+  }
 }
 
 void foo() {
   for (unsigned x = 0; x < 42; ++x) {
 if (x) {
   continue;
-} else { // comment-3
+} else { // comment-7
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use 'else' after 
'continue'
-// CHECK-FIXES: {{^}}} // comment-3
+// CHECK-FIXES: {{^}}} // comment-7
   x++;
 }
 if (x) {
   break;
-} else { // comment-4
+} else { // comment-8
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use 'else' after 'break'
-// CHECK-FIXES: {{^}}} // comment-4
+// CHECK-FIXES: {{^}}} // comment-8
   x++;
 }
 if (x) {
   throw 42;
-} else { // comment-5
+} else { // comment-9
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use 'else' after 'throw'
-// CHECK-FIXES: {{^}}} // comment-5
+// CHECK-FIXES: {{^}}} // comment-9
   x++;
 }
   }
Index: clang-tidy/readability/ElseAfterReturnCheck.cpp
===
--- clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -22,9 +22,11 @@
   const auto ControlFlowInterruptorMatcher =
   stmt(anyOf(returnStmt().bind("return"), continueStmt().bind("continue"),
  breakStmt().bind("break"), cxxThrowExpr().bind("throw")));
+
   Finder->addMatcher(
   stmt(forEach(
-  ifStmt(hasThen(stmt(
+  ifStmt(unless(hasParent(ifStmt())),
+ hasThen(stmt(
  anyOf(ControlFlowInterruptorMatcher,
compoundStmt(has(ControlFlowInterruptorMatcher),
  hasElse(stmt().bind("else")))


Index: test/clang-tidy/readability-else-after-return.cpp
===
--- test/clang-tidy/readability-else-after-return.cpp
+++ test/clang-tidy/readability-else-after-return.cpp
@@ -29,32 +29,60 @@
   else if (a > 10)
 return;
   else // comment-2
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use 'else' after 'return'
-  // CHECK-FIXES: {{^}}  // comment-2
+  // CHECK-FIXES-NOT: {{^}}  // comment-2
 f(0);
+
+  if (a > 0)
+if (a < 10)
+  return;
+else // comment-3
+// CHECK-FIXES-NOT: {{^}}// comment-3
+  f(0);
+  else
+if (a > 10)
+  return;
+else // comment-4
+// CHECK-FIXES-NOT: {{^}}// comment-4
+  f(0);
+
+  if (a > 0) {
+if (a < 10)
+  return;
+else // comment-5
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use 'else' after 'return'
+// CHECK-FIXES: {{^}}// comment-5
+  f(0);
+  } else {
+if (a > 10)
+  return;
+else // comment-6
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use 'else' after 'return'
+// CHECK-FIXES: {{^}}// comment-6
+  f(0);
+  }
 }
 
 void foo() {
   for (unsigned x = 0; x < 42; ++x) {
 if (x) {
   continue;
-} else { // comment-3
+} else { // comment-7
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use 'else' after 'continue'
-// CHECK-FIXES: {{^}}} // comment-3
+// CHECK-FIXES: {{^}}} // comment-7
   x++;
 }
 if (x) {
   break;
-} else { // comment-4
+} else { // comment-8
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use 'else' after 'break'
-// CHECK-FIXES: {{^}}} // comment-4
+// CHECK-FIXES: 

r285516 - [AVX-512] Remove masked 128/256-bit builtins for vpmaddwd and vpmaddubsw. Replace with unmasked builtins and select.

2016-10-30 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sun Oct 30 02:11:34 2016
New Revision: 285516

URL: http://llvm.org/viewvc/llvm-project?rev=285516=rev
Log:
[AVX-512] Remove masked 128/256-bit builtins for vpmaddwd and vpmaddubsw. 
Replace with unmasked builtins and select.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=285516=285515=285516=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sun Oct 30 02:11:34 2016
@@ -1314,10 +1314,6 @@ TARGET_BUILTIN(__builtin_ia32_reduceps12
 TARGET_BUILTIN(__builtin_ia32_reduceps256_mask, "V8fV8fIiV8fUc", "", 
"avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_reducesd_mask, "V2dV2dV2dV2dUcIiIi", "", 
"avx512dq")
 TARGET_BUILTIN(__builtin_ia32_reducess_mask, "V4fV4fV4fV4fUcIiIi", "", 
"avx512dq")
-TARGET_BUILTIN(__builtin_ia32_pmaddubsw128_mask, "V8sV16cV16cV8sUc", "", 
"avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pmaddubsw256_mask, "V16sV32cV32cV16sUs", "", 
"avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pmaddwd128_mask, "V4iV8sV8sV4iUc", "", 
"avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pmaddwd256_mask, "V8iV16sV16sV8iUc", "", 
"avx512vl,avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmovswb128_mask, "V16cV8sV16cUc", "", 
"avx512vl,avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmovswb256_mask, "V16cV16sV16cUs", "", 
"avx512vl,avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmovuswb128_mask, "V16cV8sV16cUc", "", 
"avx512vl,avx512bw")

Modified: cfe/trunk/lib/Headers/avx512vlbwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlbwintrin.h?rev=285516=285515=285516=diff
==
--- cfe/trunk/lib/Headers/avx512vlbwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlbwintrin.h Sun Oct 30 02:11:34 2016
@@ -1664,69 +1664,60 @@ _mm256_maskz_permutex2var_epi16 (__mmask
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm_mask_maddubs_epi16 (__m128i __W, __mmask8 __U, __m128i __X, __m128i __Y) {
-  return (__m128i) __builtin_ia32_pmaddubsw128_mask ((__v16qi) __X,
-   (__v16qi) __Y,
-   (__v8hi) __W,
-   (__mmask8) __U);
+_mm_mask_maddubs_epi16(__m128i __W, __mmask8 __U, __m128i __X, __m128i __Y) {
+  return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U,
+(__v8hi)_mm_maddubs_epi16(__X, 
__Y),
+(__v8hi)__W);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm_maskz_maddubs_epi16 (__mmask8 __U, __m128i __X, __m128i __Y) {
-  return (__m128i) __builtin_ia32_pmaddubsw128_mask ((__v16qi) __X,
-   (__v16qi) __Y,
-  (__v8hi) _mm_setzero_si128(),
-   (__mmask8) __U);
+_mm_maskz_maddubs_epi16(__mmask8 __U, __m128i __X, __m128i __Y) {
+  return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U,
+(__v8hi)_mm_maddubs_epi16(__X, 
__Y),
+(__v8hi)_mm_setzero_si128());
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
-_mm256_mask_maddubs_epi16 (__m256i __W, __mmask16 __U, __m256i __X,
- __m256i __Y) {
-  return (__m256i) __builtin_ia32_pmaddubsw256_mask ((__v32qi) __X,
-   (__v32qi) __Y,
-   (__v16hi) __W,
-   (__mmask16) __U);
+_mm256_mask_maddubs_epi16(__m256i __W, __mmask16 __U, __m256i __X,
+  __m256i __Y) {
+  return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U,
+(__v16hi)_mm256_maddubs_epi16(__X, 
__Y),
+(__v16hi)__W);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
-_mm256_maskz_maddubs_epi16 (__mmask16 __U, __m256i __X, __m256i __Y) {
-  return (__m256i) __builtin_ia32_pmaddubsw256_mask ((__v32qi) __X,
-   (__v32qi) __Y,
-   (__v16hi) _mm256_setzero_si256(),
-   (__mmask16) __U);
+_mm256_maskz_maddubs_epi16(__mmask16 __U, __m256i __X, __m256i __Y) {
+  return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U,
+(__v16hi)_mm256_maddubs_epi16(__X, 
__Y),
+(__v16hi)_mm256_setzero_si256());
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm_mask_madd_epi16 (__m128i __W, __mmask8 __U, __m128i __A,
- __m128i __B) {
-  return (__m128i) __builtin_ia32_pmaddwd128_mask ((__v8hi) __A,
-   (__v8hi) __B,
-   (__v4si) __W,
-   (__mmask8) __U);
+_mm_mask_madd_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) {
+  return 

Re: r284256 - Link static PIE programs against rcrt0.o on OpenBSD

2016-10-30 Thread Hal Finkel via cfe-commits
- Original Message -
> From: "Brad Smith via cfe-commits" 
> To: "Ed Maste" , sisnk...@gmail.com, 
> cfe-commits@lists.llvm.org
> Sent: Sunday, October 30, 2016 12:57:44 AM
> Subject: Re: r284256 - Link static PIE programs against rcrt0.o on OpenBSD
> 
> On 10/25/16 19:34, Brad Smith via cfe-commits wrote:
> > On 10/18/16 22:13, Brad Smith via cfe-commits wrote:
> >> On Fri, Oct 14, 2016 at 09:47:17PM -0400, Brad Smith via
> >> cfe-commits
> >> wrote:
> >>> On Fri, Oct 14, 2016 at 05:59:54PM -, Ed Maste via
> >>> cfe-commits
> >>> wrote:
>  Author: emaste
>  Date: Fri Oct 14 12:59:53 2016
>  New Revision: 284256
> 
>  URL: http://llvm.org/viewvc/llvm-project?rev=284256=rev
>  Log:
>  Link static PIE programs against rcrt0.o on OpenBSD
> 
>  Patch by Stefan Kempf.
> 
>  Differential Revision:https://reviews.llvm.org/D22130
> 
>  Modified:
>  cfe/trunk/lib/Driver/Tools.cpp
>  cfe/trunk/test/Driver/openbsd.c
> 
>  Modified: cfe/trunk/lib/Driver/Tools.cpp
>  URL:
>  http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=284256=284255=284256=diff
> 
>  ==
> 
>  --- cfe/trunk/lib/Driver/Tools.cpp (original)
>  +++ cfe/trunk/lib/Driver/Tools.cpp Fri Oct 14 12:59:53 2016
>  @@ -8519,6 +8519,10 @@ void openbsd::Linker::ConstructJob(Compi
> if (Args.hasArg(options::OPT_pg))
>   CmdArgs.push_back(
> 
>  Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
>  +  else if (Args.hasArg(options::OPT_static) &&
>  +   !Args.hasArg(options::OPT_nopie))
>  +CmdArgs.push_back(
>  +
>  Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
> else
>   CmdArgs.push_back(
>   Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));
> 
>  Modified: cfe/trunk/test/Driver/openbsd.c
>  URL:
>  http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=284256=284255=284256=diff
> 
>  ==
> 
>  --- cfe/trunk/test/Driver/openbsd.c (original)
>  +++ cfe/trunk/test/Driver/openbsd.c Fri Oct 14 12:59:53 2016
>  @@ -67,3 +67,26 @@
>   // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
>   // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
>   // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
>  +
>  +// Check linking against correct startup code when (not) using
>  PIE
>  +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd
>  %s
>  -### 2>&1 \
>  +// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
>  +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd
>  %s
>  -fno-pie %s -### 2>&1 \
>  +// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
>  +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd
>  -static %s -### 2>&1 \
>  +// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
>  +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd
>  -static -fno-pie %s -### 2>&1 \
>  +// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
>  +// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd
>  -nopie
>  %s -### 2>&1 \
>  +// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
>  +// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd
>  -fno-pie -nopie %s -### 2>&1 \
>  +// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
>  +// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd
>  -static
>  -nopie %s -### 2>&1 \
>  +// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
>  +// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd
>  -fno-pie -static -nopie %s -### 2>&1 \
>  +// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
>  +// CHECK-PIE: "/usr/lib/crt0.o"
>  +// CHECK-PIE-NOT: "-nopie"
>  +// CHECK-STATIC-PIE: "/usr/lib/rcrt0.o"
>  +// CHECK-STATIC-PIE-NOT: "-nopie"
>  +// CHECK-NOPIE: "-nopie" {{.*}}"/usr/lib/crt0.o"
> >>>
> >>> Ok, I see the obvious issue with -no-canonical-prefix vs
> >>> -no-canonical-prefixes
> >>> and fix the typo with the target triples.
> >>
> >> After seeing what the test failure was I have adjusted the tests
> >> as
> >> appropriate.
> >
> > ping.
> 
> ping ping.

What exactly are you pinging?

 -Hal

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

-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory
___
cfe-commits mailing list
cfe-commits@lists.llvm.org