r273249 - [AVX512] Move the 128-bit and 256-bit lzcnt intrinsics to avx512vlcdintrin.h where they belong.

2016-06-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Jun 21 01:53:58 2016
New Revision: 273249

URL: http://llvm.org/viewvc/llvm-project?rev=273249&view=rev
Log:
[AVX512] Move the 128-bit and 256-bit lzcnt intrinsics to avx512vlcdintrin.h 
where they belong.

Modified:
cfe/trunk/lib/Headers/avx512vlcdintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/avx512vlcd-builtins.c

Modified: cfe/trunk/lib/Headers/avx512vlcdintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlcdintrin.h?rev=273249&r1=273248&r2=273249&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlcdintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlcdintrin.h Tue Jun 21 01:53:58 2016
@@ -154,6 +154,110 @@ _mm256_maskz_conflict_epi32 (__mmask8 __
(__mmask8) __U);
 }
 
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_lzcnt_epi32 (__m128i __A)
+{
+  return (__m128i) __builtin_ia32_vplzcntd_128_mask ((__v4si) __A,
+ (__v4si)
+ _mm_setzero_si128 (),
+ (__mmask8) -1);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_mask_lzcnt_epi32 (__m128i __W, __mmask8 __U, __m128i __A)
+{
+  return (__m128i) __builtin_ia32_vplzcntd_128_mask ((__v4si) __A,
+ (__v4si) __W,
+ (__mmask8) __U);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_maskz_lzcnt_epi32 (__mmask8 __U, __m128i __A)
+{
+  return (__m128i) __builtin_ia32_vplzcntd_128_mask ((__v4si) __A,
+ (__v4si)
+ _mm_setzero_si128 (),
+ (__mmask8) __U);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_lzcnt_epi32 (__m256i __A)
+{
+  return (__m256i) __builtin_ia32_vplzcntd_256_mask ((__v8si) __A,
+ (__v8si)
+ _mm256_setzero_si256 (),
+ (__mmask8) -1);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_mask_lzcnt_epi32 (__m256i __W, __mmask8 __U, __m256i __A)
+{
+  return (__m256i) __builtin_ia32_vplzcntd_256_mask ((__v8si) __A,
+ (__v8si) __W,
+ (__mmask8) __U);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_maskz_lzcnt_epi32 (__mmask8 __U, __m256i __A)
+{
+  return (__m256i) __builtin_ia32_vplzcntd_256_mask ((__v8si) __A,
+ (__v8si)
+ _mm256_setzero_si256 (),
+ (__mmask8) __U);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_lzcnt_epi64 (__m128i __A)
+{
+  return (__m128i) __builtin_ia32_vplzcntq_128_mask ((__v2di) __A,
+ (__v2di)
+ _mm_setzero_di (),
+ (__mmask8) -1);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_mask_lzcnt_epi64 (__m128i __W, __mmask8 __U, __m128i __A)
+{
+  return (__m128i) __builtin_ia32_vplzcntq_128_mask ((__v2di) __A,
+ (__v2di) __W,
+ (__mmask8) __U);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_maskz_lzcnt_epi64 (__mmask8 __U, __m128i __A)
+{
+  return (__m128i) __builtin_ia32_vplzcntq_128_mask ((__v2di) __A,
+ (__v2di)
+ _mm_setzero_di (),
+ (__mmask8) __U);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_lzcnt_epi64 (__m256i __A)
+{
+  return (__m256i) __builtin_ia32_vplzcntq_256_mask ((__v4di) __A,
+ (__v4di)
+ _mm256_setzero_si256 (),
+ (__mmask8) -1);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_mask_lzcnt_epi64 (__m256i __W, __mmask8 __U, __m256i __A)
+{
+  return (__m256i) __builtin_ia32_vplzcntq_256_mask ((__v4di) __A,
+ (__v4di) __W,
+ (__mmask8) __U);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_maskz_lzcnt_epi64 (__mmask8 __U, __m256i __A)
+{
+  return (__m256i) __builtin_ia32_vplzcntq_256_mask ((__v4di) __A,
+ (__v4di)
+ _mm256_setzero_si256 (),
+ (__mmask8) __U);
+}
+
 #undef __DEFAULT_FN_ATTRS
 
-#endif /* __AVX512VLCDINTRIN_H */
\ No newline at end of file
+#endif /* __AVX512VLCDINTRIN_H */

Modified: cfe/trunk/lib/Headers/avx512vlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=273249&r1=273248&r2=273249&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Tue Jun 21 01:53:58 2016
@@ -6728,111 +6728,6 @@ _mm256_maskz_rcp14_ps (__mmask8 __U, __m
(__mmask8) __U);
 }
 
-static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm_lzcnt_epi32 (__m128i __A)
-{
-  return (__m128i) __builtin_ia32_vplzcntd_128_mask ((__v4si) __A,
- (__v4si)
- _mm_setzero_si128 (),
- (__mmask8) -1);
-}
-
-static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm_mask_lzcnt_epi32 (__m128i __W, __m

Re: [PATCH] D21547: Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 61340.
ioeric added a comment.

- fixed commenting.


http://reviews.llvm.org/D21547

Files:
  include/clang/Tooling/Core/Replacement.h
  lib/Tooling/Core/Replacement.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -471,6 +471,91 @@
   EXPECT_TRUE(Ranges[2].getLength() == 16);
 }
 
+TEST(Range, RangesAfterReplacements) {
+  std::vector Ranges = {Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 0, 2, "1234")};
+  std::vector Expected = {Range(0, 4), Range(7, 2), Range(12, 5)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesBeforeReplacements) {
+  std::vector Ranges = {Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 20, 2, "1234")};
+  std::vector Expected = {Range(5, 2), Range(10, 5), Range(20, 4)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, NotAffectedByReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 3, 2, "12"),
+   Replacement("foo", 12, 2, "12"),
+   Replacement("foo", 20, 5, "")};
+  std::vector Expected = {Range(0, 2), Range(3, 4), Range(10, 5),
+ Range(20, 0)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesWithNonOverlappingReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 3, 1, ""),
+   Replacement("foo", 6, 1, "123"),
+   Replacement("foo", 20, 2, "12345")};
+  std::vector Expected = {Range(0, 2), Range(3, 0), Range(4, 4),
+ Range(11, 5), Range(21, 5)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesWithOverlappingReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5),
+   Range(30, 5)};
+  Replacements Replaces = {
+  Replacement("foo", 1, 3, ""), Replacement("foo", 6, 1, "123"),
+  Replacement("foo", 13, 3, "1"), Replacement("foo", 25, 15, "")};
+  std::vector Expected = {Range(0, 1), Range(2, 4), Range(12, 5),
+ Range(22, 0)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, MergeIntoOneRange) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 1, 15, "1234567890")};
+  std::vector Expected = {Range(0, 15)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, ReplacementsStartingAtRangeOffsets) {
+  std::vector Ranges = {Range(0, 2), Range(5, 5), Range(15, 5)};
+  Replacements Replaces = {
+  Replacement("foo", 0, 2, "12"), Replacement("foo", 5, 1, "123"),
+  Replacement("foo", 7, 4, "12345"), Replacement("foo", 15, 10, "12")};
+  std::vector Expected = {Range(0, 2), Range(5, 9), Range(18, 2)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, ReplacementsEndingAtRangeEnds) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 6, 1, "123"),
+   Replacement("foo", 17, 3, "12")};
+  std::vector Expected = {Range(0, 2), Range(5, 4), Range(17, 4)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, AjacentReplacements) {
+  std::vector Ranges = {Range(0, 0), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 1, 2, "123"),
+   Replacement("foo", 12, 3, "1234")};
+  std::vector Expected = {Range(0, 0), Range(1, 3), Range(13, 9)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, MergeRangesAfterReplacements) {
+  std::vector Ranges = {Range(8, 0), Range(5, 2), Range(9, 0), Range(0, 1)};
+  Replacements Replaces = {Replacement("foo", 1, 3, ""),
+   Replacement("foo", 7, 0, "12"), Replacement("foo", 9, 2, "")};
+  std::vector Expected = {Range(0, 1), Range(2, 4), Range(7, 0), Range(8, 0)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
 TEST(DeduplicateTest, removesDuplicates) {
   std::vector Input;
   Input.push_back(Replacement("fileA", 50, 0, " foo "));
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -29,6 +29,17 @@
 
 static const char * const InvalidLocation = "";
 
+bool operator<(const Range &LHS, const Range

Re: [PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes

2016-06-21 Thread Beren Minor via cfe-commits
berenm added a comment.

In http://reviews.llvm.org/D21279#462578, @bmharper wrote:

> 2. friend functions: I don't really understand why the current behavior is 
> what it is, but I think it's reasonable to argue that it actually improves 
> readability by drawing attention to the fact these are friend functions, 
> which ought to be quite rare in most code


Actually it looks like it works now... I'm not sure what I did when I had this 
misalignment. It would have been fine by me anyway.

Regarding constructors, your comment seems reasonable to me. The patch already 
improves the current state, so I think it's good like it is and further 
improvements could be added later on.

Ping @djasper for his review and eventual merge.



Comment at: lib/Format/WhitespaceManager.cpp:95
@@ -97,2 +94,3 @@
   std::sort(Changes.begin(), Changes.end(), Change::IsBeforeInFile(SourceMgr));
+  calculateScopeLevel();
   calculateLineBreakInformation();

Maybe we could spare the computation if we aren't going to align anything?

Is it better for clarity to always compute additional information? @djasper 
what's the Clang way to do?



Repository:
  rL LLVM

http://reviews.llvm.org/D21279



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


Re: [PATCH] D21547: Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: include/clang/Tooling/Core/Replacement.h:68
@@ +67,3 @@
+/// \brief Less-than operator between two Ranges.
+bool operator<(const Range &LHS, const Range &RHS);
+

Can we keep these private for now?


Comment at: include/clang/Tooling/Core/Replacement.h:237
@@ +236,3 @@
+/// \brief Calculates the new ranges after \p Replaces are applied. These
+/// include both the original \p Ranges and the affected ranges of \p Replaces
+/// in the new code.

Should we make the latter optional?


Comment at: include/clang/Tooling/Core/Replacement.h:240
@@ +239,3 @@
+///
+/// \pre Replacemments must be for the same file.
+///

s/Replacemments/Replacements/


Comment at: include/clang/Tooling/Core/Replacement.h:245
@@ +244,3 @@
+std::vector
+calculateRangesAfterReplacements(const Replacements &Replaces,
+ std::vector Ranges);

I'd call this getShiftedRanges().


Comment at: include/clang/Tooling/Core/Replacement.h:246
@@ +245,3 @@
+calculateRangesAfterReplacements(const Replacements &Replaces,
+ std::vector Ranges);
+

const vector&?


Comment at: lib/Tooling/Core/Replacement.cpp:39
@@ +38,3 @@
+bool operator==(const Range &LHS, const Range &RHS) {
+  return (LHS.getOffset() == RHS.getOffset()) &&
+ (LHS.getLength() == RHS.getLength());

No need for parentheses.


Comment at: lib/Tooling/Core/Replacement.cpp:304
@@ -292,1 +303,3 @@
 
+// Returns a sorted ranges after merging all overlapping ranges.
+static void mergeAndSortRanges(std::vector &Ranges) {

Remove " a"


Comment at: lib/Tooling/Core/Replacement.cpp:305
@@ +304,3 @@
+// Returns a sorted ranges after merging all overlapping ranges.
+static void mergeAndSortRanges(std::vector &Ranges) {
+  if (Ranges.empty())

Just return the new vector and use a const parameter.


Comment at: lib/Tooling/Core/Replacement.cpp:328
@@ +327,3 @@
+std::vector
+calculateRangesAfterReplacements(const Replacements &Replaces,
+ std::vector Ranges) {

Couldn't we implement this using mergeReplacements?

Fundamentally:
- Turn Ranges into Replacements at (offset, length) with an empty (unimportant) 
replacement text of length "length".
- Merge these into Replaces
- Convert the resulting Replacements into Ranges, each with the Replacement's 
(offset, replacement_text.size()) and shifting subsequent ones forward.


http://reviews.llvm.org/D21547



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


Re: [PATCH] D20647: Add flag to add InlineHint attribute on implicitly inline functions

2016-06-21 Thread Paul Robinson via cfe-commits
probinson added a comment.

In http://reviews.llvm.org/D20647#462797, @Ilod wrote:

> There is no longer a flag to treat implicit and explicit inline functions 
> exactly the same way, I don't kow if it's really useful (it can be if we want 
> to use the threshold difference between InlineHint and standard functions). 
> If it's wanted for other uses, I can re-add it.


No, that's fine, if we decide we care deeply enough we can do our own patch.  I 
mentioned it mainly as a curiosity.


http://reviews.llvm.org/D20647



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


Re: [PATCH] D21373: [Clang][bmi][intrinsics] Adding _mm_tzcnt_64 _mm_tzcnt_32 intrinsics to clang.

2016-06-21 Thread michael zuckerman via cfe-commits
m_zuckerman updated this revision to Diff 61351.

http://reviews.llvm.org/D21373

Files:
  lib/Headers/bmiintrin.h
  test/CodeGen/bmi-builtins.c

Index: test/CodeGen/bmi-builtins.c
===
--- test/CodeGen/bmi-builtins.c
+++ test/CodeGen/bmi-builtins.c
@@ -64,6 +64,13 @@
   return __tzcnt_u32(__X);
 }
 
+int test_mm_tzcnt_32(unsigned int __X) {
+  // CHECK-LABEL: test_mm_tzcnt_32
+  // CHECK: icmp ne i32 %{{.*}}, 0
+  // CHECK: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
+  return _mm_tzcnt_32(__X);
+}
+
 unsigned long long test__andn_u64(unsigned long __X, unsigned long __Y) {
   // CHECK-LABEL: test__andn_u64
   // CHECK: xor i64 %{{.*}}, -1
@@ -105,6 +112,13 @@
   return __tzcnt_u64(__X);
 }
 
+long long test_mm_tzcnt_64(unsigned long long __X) {
+  // CHECK-LABEL: test_mm_tzcnt_64
+  // CHECK: icmp ne i64 %{{.*}}, 0
+  // CHECK: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 true)
+  return _mm_tzcnt_64(__X);
+}
+
 // Intel intrinsics
 
 unsigned short test_tzcnt_u16(unsigned short __X) {
Index: lib/Headers/bmiintrin.h
===
--- lib/Headers/bmiintrin.h
+++ lib/Headers/bmiintrin.h
@@ -281,12 +281,30 @@
 ///An unsigned 32-bit integer whose trailing zeros are to be counted.
 /// \returns An unsigned 32-bit integer containing the number of trailing zero
 ///bits in the operand.
+
 static __inline__ unsigned int __RELAXED_FN_ATTRS
 __tzcnt_u32(unsigned int __X)
 {
   return __X ? __builtin_ctz(__X) : 32;
 }
 
+/// \brief Counts the number of trailing zero bits in the operand.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c TZCNT instruction.
+///
+/// \param __X
+///An unsigned 32-bit integer whose trailing zeros are to be counted.
+/// \returns An 32-bit integer containing the number of trailing zero
+///bits in the operand.
+
+static __inline__ int __RELAXED_FN_ATTRS
+_mm_tzcnt_32(unsigned int __X)
+{
+  return __X ? __builtin_ctz(__X) : 32;
+}
+
 #ifdef __x86_64__
 
 /// \brief Performs a bitwise AND of the second operand with the one's
@@ -502,12 +520,30 @@
 ///An unsigned 64-bit integer whose trailing zeros are to be counted.
 /// \returns An unsigned 64-bit integer containing the number of trailing zero
 ///bits in the operand.
+
 static __inline__ unsigned long long __RELAXED_FN_ATTRS
 __tzcnt_u64(unsigned long long __X)
 {
   return __X ? __builtin_ctzll(__X) : 64;
 }
 
+/// \brief Counts the number of trailing zero bits in the operand.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c TZCNT instruction.
+///
+/// \param __X
+///An unsigned 64-bit integer whose trailing zeros are to be counted.
+/// \returns An 64-bit integer containing the number of trailing zero
+///bits in the operand.
+
+static __inline__ long long __RELAXED_FN_ATTRS
+_mm_tzcnt_64(unsigned long long __X)
+{
+  return __X ? __builtin_ctzll(__X) : 64;
+}
+
 #endif /* __x86_64__ */
 
 #undef __DEFAULT_FN_ATTRS


Index: test/CodeGen/bmi-builtins.c
===
--- test/CodeGen/bmi-builtins.c
+++ test/CodeGen/bmi-builtins.c
@@ -64,6 +64,13 @@
   return __tzcnt_u32(__X);
 }
 
+int test_mm_tzcnt_32(unsigned int __X) {
+  // CHECK-LABEL: test_mm_tzcnt_32
+  // CHECK: icmp ne i32 %{{.*}}, 0
+  // CHECK: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
+  return _mm_tzcnt_32(__X);
+}
+
 unsigned long long test__andn_u64(unsigned long __X, unsigned long __Y) {
   // CHECK-LABEL: test__andn_u64
   // CHECK: xor i64 %{{.*}}, -1
@@ -105,6 +112,13 @@
   return __tzcnt_u64(__X);
 }
 
+long long test_mm_tzcnt_64(unsigned long long __X) {
+  // CHECK-LABEL: test_mm_tzcnt_64
+  // CHECK: icmp ne i64 %{{.*}}, 0
+  // CHECK: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 true)
+  return _mm_tzcnt_64(__X);
+}
+
 // Intel intrinsics
 
 unsigned short test_tzcnt_u16(unsigned short __X) {
Index: lib/Headers/bmiintrin.h
===
--- lib/Headers/bmiintrin.h
+++ lib/Headers/bmiintrin.h
@@ -281,12 +281,30 @@
 ///An unsigned 32-bit integer whose trailing zeros are to be counted.
 /// \returns An unsigned 32-bit integer containing the number of trailing zero
 ///bits in the operand.
+
 static __inline__ unsigned int __RELAXED_FN_ATTRS
 __tzcnt_u32(unsigned int __X)
 {
   return __X ? __builtin_ctz(__X) : 32;
 }
 
+/// \brief Counts the number of trailing zero bits in the operand.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c TZCNT instruction.
+///
+/// \param __X
+///An unsigned 32-bit integer whose trailing zeros are to be counted.
+/// \returns An 32-bit integer containing the number of trailing zero
+///bits in the operand.
+
+static __inline__ int __RELAXED_FN_ATTRS
+_mm_tzcnt_32(unsigned int __X)
+{
+  return __X ? __builtin_ctz(__X) : 32;
+}
+
 #ifdef __x86_64__
 
 /// \brief Performs a bitwise AND of the second operand with the one's
@@ -502,

Re: [PATCH] D21373: [Clang][bmi][intrinsics] Adding _mm_tzcnt_64 _mm_tzcnt_32 intrinsics to clang.

2016-06-21 Thread michael zuckerman via cfe-commits
m_zuckerman added inline comments.


Comment at: lib/Headers/bmiintrin.h:296
@@ +295,3 @@
+/// This intrinsic corresponds to the \c TZCNT instruction.
+///
+/// \param __X

We can't use #define Here. The __mm_tzcnt_32(a) intrinsics is deferent from 
__tzcnt_u32  in the return value. The __mm_tzcnt_32 intrinsic return sign int 
while the __tzcnt_u32 return unsign value.   


http://reviews.llvm.org/D21373



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


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-06-21 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin updated this revision to Diff 61352.
DmitryPolukhin added a comment.

- removed wrong asserts that I used for an experiment


http://reviews.llvm.org/D18035

Files:
  lib/AST/ItaniumMangle.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCXX/mangle-abi-tag.cpp
  test/PCH/attrs.c
  test/SemaCXX/attr-abi-tag-syntax.cpp

Index: test/SemaCXX/attr-abi-tag-syntax.cpp
===
--- test/SemaCXX/attr-abi-tag-syntax.cpp
+++ test/SemaCXX/attr-abi-tag-syntax.cpp
@@ -16,28 +16,18 @@
 // expected-warning@-1 {{'abi_tag' attribute on anonymous namespace ignored}}
 
 inline namespace N __attribute__((__abi_tag__)) {}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-2 {{'__abi_tag__' attribute ignored}}
 
 } // namespcace N2
 
 __attribute__((abi_tag("B", "A"))) extern int a1;
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-2 {{'abi_tag' attribute ignored}}
 
 __attribute__((abi_tag("A", "B"))) extern int a1;
 // expected-note@-1 {{previous declaration is here}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
 
 __attribute__((abi_tag("A", "C"))) extern int a1;
 // expected-error@-1 {{'abi_tag' C missing in original declaration}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
 
 extern int a2;
 // expected-note@-1 {{previous declaration is here}}
 __attribute__((abi_tag("A")))extern int a2;
 // expected-error@-1 {{cannot add 'abi_tag' attribute in a redeclaration}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
Index: test/PCH/attrs.c
===
--- test/PCH/attrs.c
+++ test/PCH/attrs.c
@@ -9,7 +9,7 @@
 #define HEADER
 
 int f(int) __attribute__((visibility("default"), overloadable));
-int g(int) __attribute__((abi_tag("foo", "bar", "baz"), no_sanitize("address", "memory"))); // expected-warning {{ignored}}
+int g(int) __attribute__((abi_tag("foo", "bar", "baz"), no_sanitize("address", "memory")));
 
 #else
 
Index: test/CodeGenCXX/mangle-abi-tag.cpp
===
--- /dev/null
+++ test/CodeGenCXX/mangle-abi-tag.cpp
@@ -0,0 +1,182 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple %itanium_abi_triple -std=c++11 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -triple i686-linux-gnu -std=c++11 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-linux-gnu -std=c++11 -o - | FileCheck %s
+
+struct __attribute__((abi_tag("A", "B"))) A { };
+
+struct B: A { };
+
+template
+
+struct C {
+};
+
+struct D { A* p; };
+
+template
+struct __attribute__((abi_tag("C", "D"))) E {
+};
+
+struct __attribute__((abi_tag("A", "B"))) F { };
+
+A a1;
+// CHECK-DAG: @_Z2a1B1AB1B =
+
+__attribute__((abi_tag("C", "D")))
+A a2;
+// CHECK-DAG: @_Z2a2B1AB1BB1CB1D =
+
+B a3;
+// CHECK-DAG: @a3 =
+
+C a4;
+// CHECK-DAG: @_Z2a4B1AB1B =
+
+D a5;
+// CHECK-DAG: @a5 =
+
+E a6;
+// CHECK-DAG: @_Z2a6B1CB1D =
+
+E a7;
+// CHECK-DAG: @_Z2a7B1AB1BB1CB1D =
+
+template<>
+struct E {
+  static float a8;
+};
+float E::a8;
+// CHECK-DAG: @_ZN1EB1CB1DIfE2a8E =
+
+template<>
+struct E {
+  static bool a9;
+};
+bool E::a9;
+// CHECK-DAG: @_ZN1EB1CB1DI1FB1AB1BE2a9E =
+
+struct __attribute__((abi_tag("A", "B"))) A10 {
+  virtual ~A10() {}
+} a10;
+// vtable
+// CHECK-DAG: @_ZTV3A10B1AB1B =
+// typeinfo
+// CHECK-DAG: @_ZTI3A10B1AB1B =
+
+struct __attribute__((abi_tag("A"))) B11 {
+  static A10 b;
+};
+A10 B11::b;
+// B11[abi:A]::b[abi:B]
+// CHECK-DAG: @_ZN3B11B1A1bB1BE =
+
+__attribute__ ((abi_tag("C", "D")))
+void* f1() {
+  return 0;
+}
+// CHECK-DAG: define {{.*}} @_Z2f1B1CB1Dv(
+
+__attribute__ ((abi_tag("C", "D")))
+A* f2() {
+  return 0;
+}
+// CHECK-DAG: define {{.*}} @_Z2f2B1AB1BB1CB1Dv(
+
+B* f3() {
+  return 0;
+}
+// CHECK-DAG: define {{.*}} @_Z2f3v(
+
+C* f4() {
+  return 0;
+}
+// CHECK-DAG: define {{.*}} @_Z2f4B1AB1Bv(
+
+D* f5() {
+  return 0;
+}
+// CHECK-DAG: define {{.*}} @_Z2f5v(
+
+E* f6() {
+  return 0;
+}
+// CHECK-DAG: define {{.*}} @_Z2f6B1CB1Dv(
+
+E* f7() {
+  return 0;
+}
+// CHECK-DAG: define {{.*}} @_Z2f7B1AB1BB1CB1Dv(
+
+void f8(E*) {
+}
+// CHECK-DAG: define {{.*}} @_Z2f8P1EB1CB1DI1AB1AB1BE(
+
+inline namespace Names1 __attribute__((__abi_tag__)) {
+class C1 {};
+}
+C1 f9() { return C1(); }
+// CHECK-DAG: @_Z2f9B6Names1v(
+
+inline namespace Names2 __attribute__((__abi_tag__("Tag1", "Tag2"))) {
+class C2 {};
+}
+C2 f10() { return C2(); }
+// CHECK-DAG: @_Z3f10B4Tag1B4Tag2v(
+
+void __attribute__((abi_tag("A"))) f11(A) {}
+// f11[abi:A](A[abi:A][abi:B])
+// CHECK-DAG: define {{.*}} @_Z3f11B1A1AB1AB1B(
+
+A f12(A) { return A(); }
+// f12(A[abi:A][abi:B])
+// CHECK-DAG: define {{.*}} @_Z3f121AB1AB1B(
+
+inline void f13() {
+  stru

Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-06-21 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin updated this revision to Diff 61350.
DmitryPolukhin added a comment.

This patch set contains serious refactoring to make it closer to what Richard 
suggested. Unfortunately there is no way to fully implement Richard's idea 
because we have to mangle twice name of functions and variables. But this patch 
reuse mangled bare function type generated during tags calculation.

NOTE for people who use this patch for local testing: this patch set was not 
tested extensively on real world apps so it might have be worse than previous 
one. If you can, please test it in your environment and report any issues. For 
now "stable" version of this patch is previous patch set from May 23.

Richard, please take a look and let me know if it looks better for you. IMHO, 
it becomes smaller and simpler and reuse mangling for function prototype.


http://reviews.llvm.org/D18035

Files:
  lib/AST/ItaniumMangle.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCXX/mangle-abi-tag.cpp
  test/PCH/attrs.c
  test/SemaCXX/attr-abi-tag-syntax.cpp

Index: test/SemaCXX/attr-abi-tag-syntax.cpp
===
--- test/SemaCXX/attr-abi-tag-syntax.cpp
+++ test/SemaCXX/attr-abi-tag-syntax.cpp
@@ -16,28 +16,18 @@
 // expected-warning@-1 {{'abi_tag' attribute on anonymous namespace ignored}}
 
 inline namespace N __attribute__((__abi_tag__)) {}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-2 {{'__abi_tag__' attribute ignored}}
 
 } // namespcace N2
 
 __attribute__((abi_tag("B", "A"))) extern int a1;
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-2 {{'abi_tag' attribute ignored}}
 
 __attribute__((abi_tag("A", "B"))) extern int a1;
 // expected-note@-1 {{previous declaration is here}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
 
 __attribute__((abi_tag("A", "C"))) extern int a1;
 // expected-error@-1 {{'abi_tag' C missing in original declaration}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
 
 extern int a2;
 // expected-note@-1 {{previous declaration is here}}
 __attribute__((abi_tag("A")))extern int a2;
 // expected-error@-1 {{cannot add 'abi_tag' attribute in a redeclaration}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
Index: test/PCH/attrs.c
===
--- test/PCH/attrs.c
+++ test/PCH/attrs.c
@@ -9,7 +9,7 @@
 #define HEADER
 
 int f(int) __attribute__((visibility("default"), overloadable));
-int g(int) __attribute__((abi_tag("foo", "bar", "baz"), no_sanitize("address", "memory"))); // expected-warning {{ignored}}
+int g(int) __attribute__((abi_tag("foo", "bar", "baz"), no_sanitize("address", "memory")));
 
 #else
 
Index: test/CodeGenCXX/mangle-abi-tag.cpp
===
--- /dev/null
+++ test/CodeGenCXX/mangle-abi-tag.cpp
@@ -0,0 +1,182 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple %itanium_abi_triple -std=c++11 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -triple i686-linux-gnu -std=c++11 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-linux-gnu -std=c++11 -o - | FileCheck %s
+
+struct __attribute__((abi_tag("A", "B"))) A { };
+
+struct B: A { };
+
+template
+
+struct C {
+};
+
+struct D { A* p; };
+
+template
+struct __attribute__((abi_tag("C", "D"))) E {
+};
+
+struct __attribute__((abi_tag("A", "B"))) F { };
+
+A a1;
+// CHECK-DAG: @_Z2a1B1AB1B =
+
+__attribute__((abi_tag("C", "D")))
+A a2;
+// CHECK-DAG: @_Z2a2B1AB1BB1CB1D =
+
+B a3;
+// CHECK-DAG: @a3 =
+
+C a4;
+// CHECK-DAG: @_Z2a4B1AB1B =
+
+D a5;
+// CHECK-DAG: @a5 =
+
+E a6;
+// CHECK-DAG: @_Z2a6B1CB1D =
+
+E a7;
+// CHECK-DAG: @_Z2a7B1AB1BB1CB1D =
+
+template<>
+struct E {
+  static float a8;
+};
+float E::a8;
+// CHECK-DAG: @_ZN1EB1CB1DIfE2a8E =
+
+template<>
+struct E {
+  static bool a9;
+};
+bool E::a9;
+// CHECK-DAG: @_ZN1EB1CB1DI1FB1AB1BE2a9E =
+
+struct __attribute__((abi_tag("A", "B"))) A10 {
+  virtual ~A10() {}
+} a10;
+// vtable
+// CHECK-DAG: @_ZTV3A10B1AB1B =
+// typeinfo
+// CHECK-DAG: @_ZTI3A10B1AB1B =
+
+struct __attribute__((abi_tag("A"))) B11 {
+  static A10 b;
+};
+A10 B11::b;
+// B11[abi:A]::b[abi:B]
+// CHECK-DAG: @_ZN3B11B1A1bB1BE =
+
+__attribute__ ((abi_tag("C", "D")))
+void* f1() {
+  return 0;
+}
+// CHECK-DAG: define {{.*}} @_Z2f1B1CB1Dv(
+
+__attribute__ ((abi_tag("C", "D")))
+A* f2() {
+  return 0;
+}
+// CHECK-DAG: define {{.*}} @_Z2f2B1AB1BB1CB1Dv(
+
+B* f3() {
+  return 0;
+}
+// CHECK-DAG: define {{.*}} @_Z2f3v(
+
+C* f4() {
+  return 0;
+}
+// CHECK-DAG: define {{.*}} @_Z2f4B1AB1Bv(
+
+D* f5() {
+  return 0;
+}
+// CHECK-DAG: define {{.*}} @_Z2f5v(
+
+E* f6() {
+  return 0;
+}
+// CHECK-DAG: define {{.*}} @_Z2f6B1CB1D

Re: [PATCH] D21547: Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 61359.
ioeric marked 6 inline comments as done.
ioeric added a comment.

- Use mergeReplacements to calculate the new affected ranges.


http://reviews.llvm.org/D21547

Files:
  include/clang/Tooling/Core/Replacement.h
  lib/Tooling/Core/Replacement.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -462,13 +462,96 @@
 
   std::vector Ranges = calculateChangedRanges(Replaces);
 
-  EXPECT_EQ(3ul, Ranges.size());
+  EXPECT_EQ(2ul, Ranges.size());
   EXPECT_TRUE(Ranges[0].getOffset() == 0);
   EXPECT_TRUE(Ranges[0].getLength() == 0);
   EXPECT_TRUE(Ranges[1].getOffset() == 6);
-  EXPECT_TRUE(Ranges[1].getLength() == 6);
-  EXPECT_TRUE(Ranges[2].getOffset() == 12);
-  EXPECT_TRUE(Ranges[2].getLength() == 16);
+  EXPECT_TRUE(Ranges[1].getLength() == 22);
+}
+
+TEST(Range, RangesAfterReplacements) {
+  std::vector Ranges = {Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 0, 2, "1234")};
+  std::vector Expected = {Range(0, 4), Range(7, 2), Range(12, 5)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesBeforeReplacements) {
+  std::vector Ranges = {Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 20, 2, "1234")};
+  std::vector Expected = {Range(5, 2), Range(10, 5), Range(20, 4)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, NotAffectedByReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 3, 2, "12"),
+   Replacement("foo", 12, 2, "12"),
+   Replacement("foo", 20, 5, "")};
+  std::vector Expected = {Range(0, 2), Range(3, 4), Range(10, 5),
+ Range(20, 0)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesWithNonOverlappingReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 3, 1, ""),
+   Replacement("foo", 6, 1, "123"),
+   Replacement("foo", 20, 2, "12345")};
+  std::vector Expected = {Range(0, 2), Range(3, 0), Range(4, 4),
+ Range(11, 5), Range(21, 5)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesWithOverlappingReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5),
+   Range(30, 5)};
+  Replacements Replaces = {
+  Replacement("foo", 1, 3, ""), Replacement("foo", 6, 1, "123"),
+  Replacement("foo", 13, 3, "1"), Replacement("foo", 25, 15, "")};
+  std::vector Expected = {Range(0, 1), Range(2, 4), Range(12, 5),
+ Range(22, 0)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, MergeIntoOneRange) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 1, 15, "1234567890")};
+  std::vector Expected = {Range(0, 15)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, ReplacementsStartingAtRangeOffsets) {
+  std::vector Ranges = {Range(0, 2), Range(5, 5), Range(15, 5)};
+  Replacements Replaces = {
+  Replacement("foo", 0, 2, "12"), Replacement("foo", 5, 1, "123"),
+  Replacement("foo", 7, 4, "12345"), Replacement("foo", 15, 10, "12")};
+  std::vector Expected = {Range(0, 2), Range(5, 9), Range(18, 2)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, ReplacementsEndingAtRangeEnds) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 6, 1, "123"),
+   Replacement("foo", 17, 3, "12")};
+  std::vector Expected = {Range(0, 2), Range(5, 4), Range(17, 4)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, AjacentReplacements) {
+  std::vector Ranges = {Range(0, 0), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 1, 2, "123"),
+   Replacement("foo", 12, 3, "1234")};
+  std::vector Expected = {Range(0, 0), Range(1, 3), Range(13, 9)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, MergeRangesAfterReplacements) {
+  std::vector Ranges = {Range(8, 0), Range(5, 2), Range(9, 0), Range(0, 1)};
+  Replacements Replaces = {Replacement("foo", 1, 3, ""),
+   Replacement("foo", 7, 0, "12"), Replacement("foo", 9, 2, "")};
+  std::vector Expected = {Range(0, 1), Range(2, 4), Range(7, 0), Range(8, 0)};
+  EXPECT_EQ(Expected, c

Re: [PATCH] D21031: [OpenCL] Allow -cl-std and other standard -cl- options in driver

2016-06-21 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: include/clang/Basic/DiagnosticFrontendKinds.td:220
@@ +219,2 @@
+def warn_option_depre_ocl_version : Warning<
+  "Option %0 is deprecated for this OpenCL version">, InGroup; 

Looks good. If we could output the current OpenCL version as well to match the 
diagnostic style from http://reviews.llvm.org/D19780, it would be nice. 


Comment at: test/Driver/opencl.cl:32
@@ -14,2 +31,3 @@
+// CHECK-DENORMS-ARE-ZERO: .*clang.* "-cc1" .* "-cl-denorms-are-zero"
 
 kernel void func(void);

Could you also test the new diagnostic message you are adding please?


http://reviews.llvm.org/D21031



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


Re: [PATCH] D21547: Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: include/clang/Tooling/Core/Replacement.h:253
@@ +252,3 @@
+std::vector
+calculateRangesAfterReplacements(const Replacements &Replaces,
+ const std::vector &Ranges);

getShiftedRanges sounds like it's excluding affected ranges of Replaces. I 
think often time we want both?


Comment at: include/clang/Tooling/Core/Replacement.h:237
@@ +236,3 @@
+/// \brief Calculates the new ranges after \p Replaces are applied. These
+/// include both the original \p Ranges and the affected ranges of \p Replaces
+/// in the new code.

Why would why want to exclude the newly affected ranges? But if replaces 
overlap with original ranges, do we consider sub-ranges in original ranges 
being replaced as parts of the shifted ranges in the new code?


Comment at: lib/Tooling/Core/Replacement.cpp:305
@@ +304,3 @@
+// Merge and sort overlapping and adjacent ranges in \p Ranges.
+static void mergeAndSortRanges(std::vector &Ranges) {
+  if (Ranges.empty())

Shall we pass Ranges by value instead since it's gonna be sorted anyway?

Also, does it make sense to have calculateChangedRanges() call this?


Comment at: lib/Tooling/Core/Replacement.cpp:328
@@ +327,3 @@
+std::vector
+calculateRangesAfterReplacements(const Replacements &Replaces,
+ std::vector Ranges) {

That actually works very well! Thanks!


http://reviews.llvm.org/D21547



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-06-21 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Ping?

Thank you very much.


http://reviews.llvm.org/D20561



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


Re: [PATCH] D21212: Add documentation for RenderScript changes

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

LGTM with a tiny wording nit.



Comment at: include/clang/Basic/AttrDocs.td:2444
@@ +2443,3 @@
+In RenderScript, ``kernel`` functions are used to express data-parallel
+computation.  The RenderScript runtime efficiently parallelizes ``kernel``
+functions to run on computational resources such as multi-core CPUs and GPUs.

computations


http://reviews.llvm.org/D21212



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


Re: [gentoo-musl] Re: Add support for musl-libc on Linux

2016-06-21 Thread Lei Zhang via cfe-commits
2016-06-20 19:05 GMT+08:00 Lei Zhang :
> 2016-06-18 8:52 GMT+08:00 Rafael Espíndola :
>> There are probably a few more places that need to be patched.
>>
>> In particular, take a look at lib/Target/ARM. There are things like
>> computeTargetABI and isTargetHardFloat that probably need to be
>> updated (and tested).
>
> Any hints how to test the new changes? I guess merely checking clang's
> output like the previous test cases won't suffice this time.

Here're the refined patches. Please let me know if the test cases
aren't complete.

Thanks,
Lei


clang-musl-arm-v2.patch
Description: Binary data


llvm-musl-arm-v2.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21547: Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Nice :)



Comment at: include/clang/Tooling/Core/Replacement.h:62
@@ +61,3 @@
+  /// \brief Whether this range is less-than \p RHS or not.
+  bool operator<(const Range &RHS) const {
+if (Offset != RHS.getOffset())

Can we just add a lambda that does this to the std::sort operation? I am not 
sure that this is actually a natural order for all Replacements.


Comment at: include/clang/Tooling/Core/Replacement.h:69
@@ +68,3 @@
+  /// \brief Whether this range equals to \p RHS or not.
+  bool operator==(const Range &RHS) const {
+return Offset == RHS.getOffset() && Length == RHS.getLength();

Why is this required?


Comment at: lib/Tooling/Core/Replacement.cpp:287
@@ +286,3 @@
+  std::sort(Ranges.begin(), Ranges.end());
+  auto I = Ranges.begin();
+  unsigned CurBegin = I->getOffset();

maybe:

  std::vector Result;
  for (const auto &R: Ranges) {
if (Result.empty() || !Result.back().overlapsWith(R)) {
  Result.push_back(R);
} else {
  unsigned NewEnd = std::max(Result.back.getOffset() + 
Result.back.getLength(), R.getOffset() + R.getLength());
  Result[Result.size() - 1] = Range(Result.back.getOffset(), NewEnd - 
Result.back.getOffset());
}
  }


Comment at: lib/Tooling/Core/Replacement.cpp:319
@@ +318,3 @@
+ const std::vector &Ranges) {
+  if (Ranges.empty())
+return calculateChangedRanges(Replaces);

I'd probably leave these early exits out. I don't think anyone will ever notice 
the performance difference.


Comment at: lib/Tooling/Core/Replacement.cpp:321
@@ +320,3 @@
+return calculateChangedRanges(Replaces);
+
+  if (Replaces.empty())

I think you need to do:

  Ranges = mergeAndSortRanges(Ranges);

here


http://reviews.llvm.org/D21547



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


Re: [gentoo-musl] Re: Add support for musl-libc on Linux

2016-06-21 Thread Peter Smith via cfe-commits
Hello Lei,

The changes to llvm and clang look ok to me. I've got some suggestions
for testing.

For the clang patch, it looks like there isn't a test to check that
musleabihf implies hard floating point. It looks like
Driver/arm-mfpu.c CHECK-HF might be a good candidate to add a test.

For the llvm patch

I think you should be able to find a test that checks the behaviour of
GNUEABI and GNUEABIHF for each of the properties that you've added
Subtarget->isTargetMuslAEABI() to or equivalent. It would be useful to
add a test case for MUSLEABI and/or MUSLEABIHF. For example in the
RTLIB case there are a large number of tests that check whether the
correct __aeabi_ function is called.

Some files I came across (there are many more) that might be a good
place to check that musleabi and musleabihf behaves like gnueabi and
gnueabihf:
CodeGen/ARM/memfunc.ll
CodeGen/Thumb2/float-ops.ll
CodeGen/ARM/divmod-eabi.ll
CodeGen/ARM/fp16.ll (hard-float for HF)
MC/ARM/eh-directives-personalityindex.s

Peter

On 21 June 2016 at 14:36, Lei Zhang  wrote:
> 2016-06-20 19:05 GMT+08:00 Lei Zhang :
>> 2016-06-18 8:52 GMT+08:00 Rafael Espíndola :
>>> There are probably a few more places that need to be patched.
>>>
>>> In particular, take a look at lib/Target/ARM. There are things like
>>> computeTargetABI and isTargetHardFloat that probably need to be
>>> updated (and tested).
>>
>> Any hints how to test the new changes? I guess merely checking clang's
>> output like the previous test cases won't suffice this time.
>
> Here're the refined patches. Please let me know if the test cases
> aren't complete.
>
> Thanks,
> Lei
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21547: Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 61375.
ioeric marked 5 inline comments as done and an inline comment as not done.
ioeric added a comment.

- Addressed reviewer's comments.


http://reviews.llvm.org/D21547

Files:
  include/clang/Tooling/Core/Replacement.h
  lib/Tooling/Core/Replacement.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -462,13 +462,96 @@
 
   std::vector Ranges = calculateChangedRanges(Replaces);
 
-  EXPECT_EQ(3ul, Ranges.size());
+  EXPECT_EQ(2ul, Ranges.size());
   EXPECT_TRUE(Ranges[0].getOffset() == 0);
   EXPECT_TRUE(Ranges[0].getLength() == 0);
   EXPECT_TRUE(Ranges[1].getOffset() == 6);
-  EXPECT_TRUE(Ranges[1].getLength() == 6);
-  EXPECT_TRUE(Ranges[2].getOffset() == 12);
-  EXPECT_TRUE(Ranges[2].getLength() == 16);
+  EXPECT_TRUE(Ranges[1].getLength() == 22);
+}
+
+TEST(Range, RangesAfterReplacements) {
+  std::vector Ranges = {Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 0, 2, "1234")};
+  std::vector Expected = {Range(0, 4), Range(7, 2), Range(12, 5)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesBeforeReplacements) {
+  std::vector Ranges = {Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 20, 2, "1234")};
+  std::vector Expected = {Range(5, 2), Range(10, 5), Range(20, 4)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, NotAffectedByReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 3, 2, "12"),
+   Replacement("foo", 12, 2, "12"),
+   Replacement("foo", 20, 5, "")};
+  std::vector Expected = {Range(0, 2), Range(3, 4), Range(10, 5),
+ Range(20, 0)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesWithNonOverlappingReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 3, 1, ""),
+   Replacement("foo", 6, 1, "123"),
+   Replacement("foo", 20, 2, "12345")};
+  std::vector Expected = {Range(0, 2), Range(3, 0), Range(4, 4),
+ Range(11, 5), Range(21, 5)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesWithOverlappingReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5),
+   Range(30, 5)};
+  Replacements Replaces = {
+  Replacement("foo", 1, 3, ""), Replacement("foo", 6, 1, "123"),
+  Replacement("foo", 13, 3, "1"), Replacement("foo", 25, 15, "")};
+  std::vector Expected = {Range(0, 1), Range(2, 4), Range(12, 5),
+ Range(22, 0)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, MergeIntoOneRange) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 1, 15, "1234567890")};
+  std::vector Expected = {Range(0, 15)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, ReplacementsStartingAtRangeOffsets) {
+  std::vector Ranges = {Range(0, 2), Range(5, 5), Range(15, 5)};
+  Replacements Replaces = {
+  Replacement("foo", 0, 2, "12"), Replacement("foo", 5, 1, "123"),
+  Replacement("foo", 7, 4, "12345"), Replacement("foo", 15, 10, "12")};
+  std::vector Expected = {Range(0, 2), Range(5, 9), Range(18, 2)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, ReplacementsEndingAtRangeEnds) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 6, 1, "123"),
+   Replacement("foo", 17, 3, "12")};
+  std::vector Expected = {Range(0, 2), Range(5, 4), Range(17, 4)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, AjacentReplacements) {
+  std::vector Ranges = {Range(0, 0), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 1, 2, "123"),
+   Replacement("foo", 12, 3, "1234")};
+  std::vector Expected = {Range(0, 0), Range(1, 3), Range(13, 9)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, MergeRangesAfterReplacements) {
+  std::vector Ranges = {Range(8, 0), Range(5, 2), Range(9, 0), Range(0, 1)};
+  Replacements Replaces = {Replacement("foo", 1, 3, ""),
+   Replacement("foo", 7, 0, "12"), Replacement("foo", 9, 2, "")};
+  std::vector Expected = {Range(0, 1), Range(2, 4), Range(7, 0), Range(8, 0)};
+  EXPECT_EQ(Expect

Re: [PATCH] D21373: [Clang][bmi][intrinsics] Adding _mm_tzcnt_64 _mm_tzcnt_32 intrinsics to clang.

2016-06-21 Thread Simon Pilgrim via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM



Comment at: lib/Headers/bmiintrin.h:284
@@ -283,2 +283,3 @@
 ///bits in the operand.
+
 static __inline__ unsigned int __RELAXED_FN_ATTRS

Why the newlines? It  doesn't match the rest of the header.


Comment at: lib/Headers/bmiintrin.h:296
@@ +295,3 @@
+/// This intrinsic corresponds to the \c TZCNT instruction.
+///
+/// \param __X

m_zuckerman wrote:
> We can't use #define Here. The __mm_tzcnt_32(a) intrinsics is deferent from 
> __tzcnt_u32  in the return value. The __mm_tzcnt_32 intrinsic return sign int 
> while the __tzcnt_u32 return unsign value.   
Ah! Missed that bit - thats fine.


http://reviews.llvm.org/D21373



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


Re: [PATCH] D21547: Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: include/clang/Tooling/Core/Replacement.h:69
@@ +68,3 @@
+  /// \brief Whether this range equals to \p RHS or not.
+  bool operator==(const Range &RHS) const {
+return Offset == RHS.getOffset() && Length == RHS.getLength();

djasper wrote:
> Why is this required?
It is used in unit test to test the equality between two ranges.


Comment at: lib/Tooling/Core/Replacement.cpp:287
@@ +286,3 @@
+  std::sort(Ranges.begin(), Ranges.end());
+  auto I = Ranges.begin();
+  unsigned CurBegin = I->getOffset();

djasper wrote:
> maybe:
> 
>   std::vector Result;
>   for (const auto &R: Ranges) {
> if (Result.empty() || !Result.back().overlapsWith(R)) {
>   Result.push_back(R);
> } else {
>   unsigned NewEnd = std::max(Result.back.getOffset() + 
> Result.back.getLength(), R.getOffset() + R.getLength());
>   Result[Result.size() - 1] = Range(Result.back.getOffset(), NewEnd - 
> Result.back.getOffset());
> }
>   }
Thanks! Just one minor point: we also want to merge ranges `R1` and `R2` if 
```
R1.getOffset() + R1.getLength() == R2.getOffset()
``` 
For example, if we have `R1(1, 1)` and `R2(2, 1)`, then we can merge them into 
`R3(1, 2)`.


http://reviews.llvm.org/D21547



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


[clang-tools-extra] r273275 - [clang-tidy] Add modernize-use-emplace

2016-06-21 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Tue Jun 21 10:23:27 2016
New Revision: 273275

URL: http://llvm.org/viewvc/llvm-project?rev=273275&view=rev
Log:
[clang-tidy] Add modernize-use-emplace

Summary: Add check that replaces call of push_back to emplace_back

Reviewers: hokein

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

Added:
clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/utils/Matchers.h
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=273275&r1=273274&r2=273275&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Tue Jun 21 
10:23:27 2016
@@ -17,6 +17,7 @@ add_clang_library(clangTidyModernizeModu
   UseAutoCheck.cpp
   UseBoolLiteralsCheck.cpp
   UseDefaultCheck.cpp
+  UseEmplaceCheck.cpp
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp
 

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=273275&r1=273274&r2=273275&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Tue 
Jun 21 10:23:27 2016
@@ -23,6 +23,7 @@
 #include "UseAutoCheck.h"
 #include "UseBoolLiteralsCheck.h"
 #include "UseDefaultCheck.h"
+#include "UseEmplaceCheck.h"
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
 
@@ -54,6 +55,7 @@ public:
 CheckFactories.registerCheck(
 "modernize-use-bool-literals");
 CheckFactories.registerCheck("modernize-use-default");
+CheckFactories.registerCheck("modernize-use-emplace");
 CheckFactories.registerCheck("modernize-use-nullptr");
 CheckFactories.registerCheck("modernize-use-override");
   }

Added: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp?rev=273275&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp Tue Jun 21 
10:23:27 2016
@@ -0,0 +1,104 @@
+//===--- UseEmplaceCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UseEmplaceCheck.h"
+#include "../utils/Matchers.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+void UseEmplaceCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus11)
+return;
+
+  // FIXME: Bunch of functionality that could be easily added:
+  // + add handling of `push_front` for std::forward_list, std::list
+  // and std::deque.
+  // + add handling of `push` for std::stack, std::queue, std::priority_queue
+  // + add handling of `insert` for stl associative container, but be careful
+  // because this requires special treatment (it could cause performance
+  // regression)
+  // + match for emplace calls that should be replaced with insertion
+  // + match for make_pair calls.
+  auto callPushBack = cxxMemberCallExpr(
+  hasDeclaration(functionDecl(hasName("push_back"))),
+  on(hasType(cxxRecordDecl(hasAnyName("std::vector", "llvm::SmallVector",
+  "std::list", "std::deque");
+
+  // We can't replace push_backs of smart pointer because
+  // if emplacement fails (f.e. bad_alloc in vector) we will have leak of
+  // passed pointer because smart pointer won't be constructed
+  // (and destructed) as in push_back case.
+  auto isCtorOfSmartPtr = hasDeclaration(cxxConstructorDecl(
+  ofClass(hasAnyName("std::shared_ptr", "std::unique_ptr", "std::auto_ptr",
+ "std::weak_ptr";
+
+  // Bitfields binds only to consts and emplace_back take it by univ

Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-21 Thread Piotr Padlewski via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273275: [clang-tidy] Add modernize-use-emplace (authored by 
Prazek).

Changed prior to commit:
  http://reviews.llvm.org/D20964?vs=61214&id=61381#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20964

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h
  clang-tools-extra/trunk/clang-tidy/utils/Matchers.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp

Index: clang-tools-extra/trunk/clang-tidy/utils/Matchers.h
===
--- clang-tools-extra/trunk/clang-tidy/utils/Matchers.h
+++ clang-tools-extra/trunk/clang-tidy/utils/Matchers.h
@@ -45,6 +45,8 @@
   Node, Finder->getASTContext());
 }
 
+AST_MATCHER(FieldDecl, isBitfield) { return Node.isBitField(); }
+
 } // namespace matchers
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -0,0 +1,104 @@
+//===--- UseEmplaceCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UseEmplaceCheck.h"
+#include "../utils/Matchers.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+void UseEmplaceCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus11)
+return;
+
+  // FIXME: Bunch of functionality that could be easily added:
+  // + add handling of `push_front` for std::forward_list, std::list
+  // and std::deque.
+  // + add handling of `push` for std::stack, std::queue, std::priority_queue
+  // + add handling of `insert` for stl associative container, but be careful
+  // because this requires special treatment (it could cause performance
+  // regression)
+  // + match for emplace calls that should be replaced with insertion
+  // + match for make_pair calls.
+  auto callPushBack = cxxMemberCallExpr(
+  hasDeclaration(functionDecl(hasName("push_back"))),
+  on(hasType(cxxRecordDecl(hasAnyName("std::vector", "llvm::SmallVector",
+  "std::list", "std::deque");
+
+  // We can't replace push_backs of smart pointer because
+  // if emplacement fails (f.e. bad_alloc in vector) we will have leak of
+  // passed pointer because smart pointer won't be constructed
+  // (and destructed) as in push_back case.
+  auto isCtorOfSmartPtr = hasDeclaration(cxxConstructorDecl(
+  ofClass(hasAnyName("std::shared_ptr", "std::unique_ptr", "std::auto_ptr",
+ "std::weak_ptr";
+
+  // Bitfields binds only to consts and emplace_back take it by universal ref.
+  auto bitFieldAsArgument = hasAnyArgument(ignoringParenImpCasts(
+  memberExpr(hasDeclaration(fieldDecl(matchers::isBitfield());
+
+  // We could have leak of resource.
+  auto newExprAsArgument = hasAnyArgument(ignoringParenImpCasts(cxxNewExpr()));
+  auto constructingDerived =
+  hasParent(implicitCastExpr(hasCastKind(CastKind::CK_DerivedToBase)));
+
+  auto hasInitList = has(ignoringParenImpCasts(initListExpr()));
+  auto soughtConstructExpr =
+  cxxConstructExpr(
+  unless(anyOf(isCtorOfSmartPtr, hasInitList, bitFieldAsArgument,
+   newExprAsArgument, constructingDerived,
+   has(materializeTemporaryExpr(hasInitList)
+  .bind("ctor");
+  auto hasConstructExpr = has(ignoringParenImpCasts(soughtConstructExpr));
+
+  auto ctorAsArgument = materializeTemporaryExpr(
+  anyOf(hasConstructExpr, has(cxxFunctionalCastExpr(hasConstructExpr;
+
+  Finder->addMatcher(
+  cxxMemberCallExpr(callPushBack, has(ctorAsArgument)).bind("call"), this);
+}
+
+void UseEmplaceCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *Call = Result.Nodes.getNodeAs("call");
+  const auto *InnerCtorCall = Result.Nodes.getNodeAs("ctor");
+
+  auto FunctionNameSourceRange = CharSourceRange::getCharRange(
+  Call->getExprLoc(), Call->getArg(0)->getExprLoc());
+
+  auto Diag = diag(Call->getExprLoc(), "use emplace_back instead of push_back");
+
+  if (FunctionNameSourceRange.g

r273280 - [AArch64] Change the preferred alignment for char and short to word alignment

2016-06-21 Thread Evandro Menezes via cfe-commits
Author: evandro
Date: Tue Jun 21 10:55:29 2016
New Revision: 273280

URL: http://llvm.org/viewvc/llvm-project?rev=273280&view=rev
Log:
[AArch64] Change the preferred alignment for char and short to word alignment

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=273280&r1=273279&r2=273280&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Jun 21 10:55:29 2016
@@ -5994,7 +5994,7 @@ class AArch64leTargetInfo : public AArch
 if (getTriple().isOSBinFormatMachO())
   resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128");
 else
-  resetDataLayout("e-m:e-i64:64-i128:128-n32:64-S128");
+  resetDataLayout("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128");
   }
 
 public:
@@ -6012,7 +6012,7 @@ public:
 class AArch64beTargetInfo : public AArch64TargetInfo {
   void setDataLayout() override {
 assert(!getTriple().isOSBinFormatMachO());
-resetDataLayout("E-m:e-i64:64-i128:128-n32:64-S128");
+resetDataLayout("E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128");
   }
 
 public:


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


Re: [PATCH] D21212: Add documentation for RenderScript changes

2016-06-21 Thread Pirama Arumuga Nainar via cfe-commits
pirama updated this revision to Diff 61390.
pirama added a comment.

computation -> computations.


http://reviews.llvm.org/D21212

Files:
  docs/ReleaseNotes.rst
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td

Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -2433,3 +2433,18 @@
 See :doc:`LTOVisibility`.
   }];
 }
+
+def RenderScriptKernelAttributeDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+``__attribute__((kernel))`` is used to mark a ``kernel`` function in
+RenderScript.
+
+In RenderScript, ``kernel`` functions are used to express data-parallel
+computations.  The RenderScript runtime efficiently parallelizes ``kernel``
+functions to run on computational resources such as multi-core CPUs and GPUs.
+See the RenderScript_ documentation for more information.
+
+.. _RenderScript: 
https://developer.android.com/guide/topics/renderscript/compute.html
+  }];
+}
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -732,7 +732,7 @@
 def RenderScriptKernel : Attr {
   let Spellings = [GNU<"kernel">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [RenderScriptKernelAttributeDocs];
   let LangOpts = [RenderScript];
 }
 
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -84,6 +84,11 @@
 ---
 The -faltivec and -maltivec flags no longer silently include altivec.h on 
Power platforms.
 
+`RenderScript
+`_
+support added to the Frontend and enabled by the '-x renderscript' option or
+the '.rs' file extension.
+
 ...
 
 C11 Feature Support


Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -2433,3 +2433,18 @@
 See :doc:`LTOVisibility`.
   }];
 }
+
+def RenderScriptKernelAttributeDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+``__attribute__((kernel))`` is used to mark a ``kernel`` function in
+RenderScript.
+
+In RenderScript, ``kernel`` functions are used to express data-parallel
+computations.  The RenderScript runtime efficiently parallelizes ``kernel``
+functions to run on computational resources such as multi-core CPUs and GPUs.
+See the RenderScript_ documentation for more information.
+
+.. _RenderScript: https://developer.android.com/guide/topics/renderscript/compute.html
+  }];
+}
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -732,7 +732,7 @@
 def RenderScriptKernel : Attr {
   let Spellings = [GNU<"kernel">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [RenderScriptKernelAttributeDocs];
   let LangOpts = [RenderScript];
 }
 
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -84,6 +84,11 @@
 ---
 The -faltivec and -maltivec flags no longer silently include altivec.h on Power platforms.
 
+`RenderScript
+`_
+support added to the Frontend and enabled by the '-x renderscript' option or
+the '.rs' file extension.
+
 ...
 
 C11 Feature Support
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r273283 - Add documentation for RenderScript changes

2016-06-21 Thread Pirama Arumuga Nainar via cfe-commits
Author: pirama
Date: Tue Jun 21 11:09:30 2016
New Revision: 273283

URL: http://llvm.org/viewvc/llvm-project?rev=273283&view=rev
Log:
Add documentation for RenderScript changes

Summary:
- Document the new 'kernel' attribute
- Mention RenderScript support in the Release Notes.

Reviewers: rsmith

Subscribers: tberghammer, danalbert, cfe-commits, srhines

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

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=273283&r1=273282&r2=273283&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Jun 21 11:09:30 2016
@@ -84,6 +84,11 @@ C Language Changes in Clang
 ---
 The -faltivec and -maltivec flags no longer silently include altivec.h on 
Power platforms.
 
+`RenderScript
+`_
+support added to the Frontend and enabled by the '-x renderscript' option or
+the '.rs' file extension.
+
 ...
 
 C11 Feature Support

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=273283&r1=273282&r2=273283&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Jun 21 11:09:30 2016
@@ -734,7 +734,7 @@ def OpenCLNoSVM : Attr {
 def RenderScriptKernel : Attr {
   let Spellings = [GNU<"kernel">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [RenderScriptKernelAttributeDocs];
   let LangOpts = [RenderScript];
 }
 

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=273283&r1=273282&r2=273283&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Tue Jun 21 11:09:30 2016
@@ -2433,3 +2433,18 @@ def LTOVisibilityDocs : Documentation {
 See :doc:`LTOVisibility`.
   }];
 }
+
+def RenderScriptKernelAttributeDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+``__attribute__((kernel))`` is used to mark a ``kernel`` function in
+RenderScript.
+
+In RenderScript, ``kernel`` functions are used to express data-parallel
+computations.  The RenderScript runtime efficiently parallelizes ``kernel``
+functions to run on computational resources such as multi-core CPUs and GPUs.
+See the RenderScript_ documentation for more information.
+
+.. _RenderScript: 
https://developer.android.com/guide/topics/renderscript/compute.html
+  }];
+}


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


Re: [PATCH] D21212: Add documentation for RenderScript changes

2016-06-21 Thread Pirama Arumuga Nainar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273283: Add documentation for RenderScript changes (authored 
by pirama).

Changed prior to commit:
  http://reviews.llvm.org/D21212?vs=61390&id=61391#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21212

Files:
  cfe/trunk/docs/ReleaseNotes.rst
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td

Index: cfe/trunk/docs/ReleaseNotes.rst
===
--- cfe/trunk/docs/ReleaseNotes.rst
+++ cfe/trunk/docs/ReleaseNotes.rst
@@ -84,6 +84,11 @@
 ---
 The -faltivec and -maltivec flags no longer silently include altivec.h on 
Power platforms.
 
+`RenderScript
+`_
+support added to the Frontend and enabled by the '-x renderscript' option or
+the '.rs' file extension.
+
 ...
 
 C11 Feature Support
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -734,7 +734,7 @@
 def RenderScriptKernel : Attr {
   let Spellings = [GNU<"kernel">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [RenderScriptKernelAttributeDocs];
   let LangOpts = [RenderScript];
 }
 
Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -2433,3 +2433,18 @@
 See :doc:`LTOVisibility`.
   }];
 }
+
+def RenderScriptKernelAttributeDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+``__attribute__((kernel))`` is used to mark a ``kernel`` function in
+RenderScript.
+
+In RenderScript, ``kernel`` functions are used to express data-parallel
+computations.  The RenderScript runtime efficiently parallelizes ``kernel``
+functions to run on computational resources such as multi-core CPUs and GPUs.
+See the RenderScript_ documentation for more information.
+
+.. _RenderScript: 
https://developer.android.com/guide/topics/renderscript/compute.html
+  }];
+}


Index: cfe/trunk/docs/ReleaseNotes.rst
===
--- cfe/trunk/docs/ReleaseNotes.rst
+++ cfe/trunk/docs/ReleaseNotes.rst
@@ -84,6 +84,11 @@
 ---
 The -faltivec and -maltivec flags no longer silently include altivec.h on Power platforms.
 
+`RenderScript
+`_
+support added to the Frontend and enabled by the '-x renderscript' option or
+the '.rs' file extension.
+
 ...
 
 C11 Feature Support
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -734,7 +734,7 @@
 def RenderScriptKernel : Attr {
   let Spellings = [GNU<"kernel">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [RenderScriptKernelAttributeDocs];
   let LangOpts = [RenderScript];
 }
 
Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -2433,3 +2433,18 @@
 See :doc:`LTOVisibility`.
   }];
 }
+
+def RenderScriptKernelAttributeDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+``__attribute__((kernel))`` is used to mark a ``kernel`` function in
+RenderScript.
+
+In RenderScript, ``kernel`` functions are used to express data-parallel
+computations.  The RenderScript runtime efficiently parallelizes ``kernel``
+functions to run on computational resources such as multi-core CPUs and GPUs.
+See the RenderScript_ documentation for more information.
+
+.. _RenderScript: https://developer.android.com/guide/topics/renderscript/compute.html
+  }];
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21547: Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

A couple of small comments, otherwise looks good.



Comment at: lib/Tooling/Core/Replacement.cpp:284
@@ +283,3 @@
+  std::sort(Ranges.begin(), Ranges.end(),
+[](const Range &LHS, const Range &RHS) -> bool {
+  if (LHS.getOffset() != RHS.getOffset())

I don't think you need "-> bool".


Comment at: lib/Tooling/Core/Replacement.cpp:285
@@ +284,3 @@
+[](const Range &LHS, const Range &RHS) -> bool {
+  if (LHS.getOffset() != RHS.getOffset())
+return LHS.getOffset() < RHS.getOffset();

or std::tie(LHS.getOffset(), LHS.getLength()) < std::tie(RHS.getOffset(), 
RHS.getLength())?


Comment at: lib/Tooling/Core/Replacement.cpp:292
@@ +291,3 @@
+if (Result.empty() ||
+Result.back().getOffset() + Result.back().getLength() < R.getOffset()) 
{
+  Result.push_back(R);

Maybe pull out:
  unsigned CurrentEnd = Result.back().getOffset() + Result.back().getLength();

Will probably save a line or two :)


http://reviews.llvm.org/D21547



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


r273285 - clang-format: [JS] Add a Closure Compiler JSDoc tags to the default

2016-06-21 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Jun 21 12:00:20 2016
New Revision: 273285

URL: http://llvm.org/viewvc/llvm-project?rev=273285&view=rev
Log:
clang-format: [JS] Add a Closure Compiler JSDoc tags to the default
Google configuration so that it isn't line-wrapped.

Modified:
cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=273285&r1=273284&r2=273285&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Jun 21 12:00:20 2016
@@ -612,7 +612,7 @@ FormatStyle getGoogleStyle(FormatStyle::
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-GoogleStyle.CommentPragmas = "@(export|return|see|visibility) ";
+GoogleStyle.CommentPragmas = "@(export|requirecss|return|see|visibility) ";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;


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


Re: [PATCH] D21303: [clang-tidy] Adds performance-returning-type check.

2016-06-21 Thread Jakub Staroń via cfe-commits
staronj added inline comments.


Comment at: clang-tidy/performance/ReturningTypeCheck.cpp:132
@@ +131,3 @@
+  // "constructedType"
+  auto HasTypeSameAsConstructed = hasType(hasCanonicalType(
+  ignoringRefsAndConsts(equalsBoundNode("constructedType";

Prazek wrote:
> I am aware of LLVM style guide, but I think there is exception for the 
> matchers - they looks much more like a matchers when they starts with lower 
> case. I am not sure if it is not spoken rule, but I don't remember single 
> binded matcher that would start with capital case.
See UnnecessaryValueParamCheck.cpp line 33 or LoopConvertCheck.cpp lines 37-47. 
They all start with capital letter.


http://reviews.llvm.org/D21303



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


Re: [PATCH] D21303: [clang-tidy] Adds performance-returning-type check.

2016-06-21 Thread Jakub Staroń via cfe-commits
staronj removed rL LLVM as the repository for this revision.
staronj updated this revision to Diff 61402.
staronj marked 8 inline comments as done.
staronj added a comment.

1. Name changed to return-value-copy.
2. Changed warning message.
3. Fixed check description.


http://reviews.llvm.org/D21303

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tidy/performance/ReturnValueCopyCheck.cpp
  clang-tidy/performance/ReturnValueCopyCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/performance-return-value-copy.rst
  test/clang-tidy/performance-return-value-copy.cpp

Index: test/clang-tidy/performance-return-value-copy.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-return-value-copy.cpp
@@ -0,0 +1,305 @@
+// RUN: %check_clang_tidy %s performance-return-value-copy %t
+// CHECK-FIXES: {{^}}#include {{$}}
+
+// we need std::move mock
+namespace std {
+template 
+struct remove_reference { typedef _Tp type; };
+
+template 
+struct remove_reference<_Tp &> { typedef _Tp type; };
+
+template 
+struct remove_reference<_Tp &&> { typedef _Tp type; };
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&
+move(_Tp &&__t) noexcept { return static_cast::type &&>(__t); }
+}
+
+class SimpleClass {
+public:
+  SimpleClass() = default;
+  SimpleClass(const SimpleClass &) = default;
+  SimpleClass(SimpleClass &&) = default;
+
+  // We don't want to add std::move here because it will be added by compiler
+  SimpleClass foo(SimpleClass a, const SimpleClass b, SimpleClass &c, const SimpleClass &d, SimpleClass &&e, const SimpleClass &&f, char k) {
+switch (k) {
+case 'a':
+  return a;
+case 'b':
+  return b;
+case 'c':
+  return c;
+case 'd':
+  return d;
+case 'e':
+  return e;
+case 'f':
+  return f;
+default:
+  return SimpleClass();
+}
+  }
+};
+
+SimpleClass simpleClassFoo() {
+  return SimpleClass();
+}
+
+class FromValueClass {
+public:
+  FromValueClass(SimpleClass a) {}
+
+  FromValueClass foo(SimpleClass a, const SimpleClass b, SimpleClass &c, const SimpleClass &d, SimpleClass &&e, const SimpleClass &&f, char k) {
+switch (k) {
+case 'a':
+  // Because SimpleClass is move constructible
+  return a;
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: returned object is not moved; consider wrapping it with std::move or changing return type to avoid the copy [performance-return-value-copy]
+// CHECK-FIXES: {{^ *}}return FromValueClass(std::move(a));{{$}}
+case 'b':
+  return b;
+case 'c':
+  return c;
+case 'd':
+  return d;
+case 'e':
+  return e;
+case 'f':
+  return f;
+case 'g':
+  return simpleClassFoo();
+default:
+  return SimpleClass();
+}
+  }
+};
+
+class FromRRefClass {
+public:
+  FromRRefClass() = default;
+  FromRRefClass(const SimpleClass &a) {}
+  FromRRefClass(SimpleClass &&a) {}
+
+  FromRRefClass foo1(SimpleClass a, const SimpleClass b, SimpleClass &c, const SimpleClass &d, SimpleClass &&e, const SimpleClass &&f, char k) {
+switch (k) {
+case 'a':
+  return a;
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{..}}
+// CHECK-FIXES: {{^ *}}return FromRRefClass(std::move(a));{{$}}
+
+// We don't want to add std::move in cases 'b-f because
+case 'b':
+  return b;
+case 'c':
+  return c;
+case 'd':
+  return d;
+case 'e':
+  return e;
+case 'f':
+  return f;
+case 'g':
+  return simpleClassFoo();
+default:
+  return SimpleClass();
+}
+  }
+
+  FromRRefClass foo2(char k) {
+SimpleClass a;
+const SimpleClass &b = a;
+SimpleClass &c = a;
+SimpleClass *d = &a;
+const SimpleClass e;
+
+switch (k) {
+case 'a':
+  return a;
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{..}}
+// CHECK-FIXES: {{^ *}}return FromRRefClass(std::move(a));{{$}}
+case 'b':
+  return b;
+case 'c':
+  return c;
+case 'd':
+  return *d;
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{..}}
+// CHECK-FIXES: {{^ *}}return FromRRefClass(std::move(*d));{{$}}
+case 'e':
+  return e;
+case 'f':
+  return simpleClassFoo();
+case 'x':
+  return SimpleClass();
+case 'y':
+  return FromRRefClass(SimpleClass());
+}
+  }
+
+  FromRRefClass foo3(char k) {
+SimpleClass a;
+SimpleClass b;
+FromRRefClass c;
+switch (k) {
+case 'a':
+  return std::move(a);
+case 'b':
+  return FromRRefClass(std::move(a));
+case 'c':
+  return c;
+default:
+  return FromRRefClass();
+}
+  }
+};
+
+template 
+FromRRefClass justTemplateFunction(T &&t) {
+  return t;
+}
+
+void call_justTemplateFunction() {
+  justTemplateFunction(SimpleClass{});
+  SimpleClass a;
+  justTemplateFunction(a);
+  justTemplateFunction(FromRRefCl

Re: [PATCH] D20647: Add support for /Ob1 and -finline-hint-functions flags

2016-06-21 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

Another consequence of doing it this way is that the /Ob1 decision will survive 
through LTO, for better or worse.

In http://reviews.llvm.org/D20647#461135, @probinson wrote:

> I'm still bemused that Clang thinks of a defined-in-class method and a method 
> marked with 'inline' as significantly different things.  But given that it 
> does, a way to make them be treated the same will be nice.


If we want to treat them the same, IMO we should have an option to drop 
inlinehint. IMO the inliner shouldn't treat any of these any differently:

  inline void f() {} // explicitly inline
  struct Foo {
void f() {} // implicitly inline
  };
  template  struct Bar { void f(); };
  template  void Bar::f() {} // weak linkage but not inline


http://reviews.llvm.org/D20647



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


r273289 - [aarch64] Update datalayout for aarch64 tests

2016-06-21 Thread Artem Belevich via cfe-commits
Author: tra
Date: Tue Jun 21 12:35:31 2016
New Revision: 273289

URL: http://llvm.org/viewvc/llvm-project?rev=273289&view=rev
Log:
[aarch64] Update datalayout for aarch64 tests

This brings the tests in sync with the changes in r273280.

Modified:
cfe/trunk/test/CodeGen/aarch64-type-sizes.c
cfe/trunk/test/CodeGen/target-data.c

Modified: cfe/trunk/test/CodeGen/aarch64-type-sizes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-type-sizes.c?rev=273289&r1=273288&r2=273289&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-type-sizes.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-type-sizes.c Tue Jun 21 12:35:31 2016
@@ -1,8 +1,7 @@
-// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -emit-llvm -w -o - %s | 
FileCheck --check-prefix=CHECK --check-prefix=CHECK-BE %s
+// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -emit-llvm -w -o - %s | 
FileCheck --check-prefix=CHECK %s
 // char by definition has size 1
 
-// CHECK-LE: target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
-// CHECK-BE: target datalayout = "E-m:e-i64:64-i128:128-n32:64-S128"
+// CHECK: target datalayout = 
"E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
 int check_short() {
   return sizeof(short);
@@ -89,4 +88,3 @@ int foo() {
   return sizeof(enum Small);
 // CHECK: ret i32 4
 }
-

Modified: cfe/trunk/test/CodeGen/target-data.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-data.c?rev=273289&r1=273288&r2=273289&view=diff
==
--- cfe/trunk/test/CodeGen/target-data.c (original)
+++ cfe/trunk/test/CodeGen/target-data.c Tue Jun 21 12:35:31 2016
@@ -141,7 +141,7 @@
 
 // RUN: %clang_cc1 -triple arm64-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=AARCH64
-// AARCH64: target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
+// AARCH64: target datalayout = 
"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple thumb-unknown-gnueabi -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=THUMB


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


Re: [PATCH] D20647: Add support for /Ob1 and -finline-hint-functions flags

2016-06-21 Thread Hans Wennborg via cfe-commits
hans added inline comments.


Comment at: test/Driver/cl-options.c:283
@@ -282,3 +282,2 @@
 // RUN:/nologo \
-// RUN:/Ob1 \
 // RUN:/openmp- \

You're removing it from the ignored flags here, but I don't see any code change 
or test for how clang-cl's supposed to handle it. What am I missing?


http://reviews.llvm.org/D20647



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


Re: [PATCH] D21547: Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 61405.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- removed redundant return type in lambda function.


http://reviews.llvm.org/D21547

Files:
  include/clang/Tooling/Core/Replacement.h
  lib/Tooling/Core/Replacement.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -462,13 +462,96 @@
 
   std::vector Ranges = calculateChangedRanges(Replaces);
 
-  EXPECT_EQ(3ul, Ranges.size());
+  EXPECT_EQ(2ul, Ranges.size());
   EXPECT_TRUE(Ranges[0].getOffset() == 0);
   EXPECT_TRUE(Ranges[0].getLength() == 0);
   EXPECT_TRUE(Ranges[1].getOffset() == 6);
-  EXPECT_TRUE(Ranges[1].getLength() == 6);
-  EXPECT_TRUE(Ranges[2].getOffset() == 12);
-  EXPECT_TRUE(Ranges[2].getLength() == 16);
+  EXPECT_TRUE(Ranges[1].getLength() == 22);
+}
+
+TEST(Range, RangesAfterReplacements) {
+  std::vector Ranges = {Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 0, 2, "1234")};
+  std::vector Expected = {Range(0, 4), Range(7, 2), Range(12, 5)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesBeforeReplacements) {
+  std::vector Ranges = {Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 20, 2, "1234")};
+  std::vector Expected = {Range(5, 2), Range(10, 5), Range(20, 4)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, NotAffectedByReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 3, 2, "12"),
+   Replacement("foo", 12, 2, "12"),
+   Replacement("foo", 20, 5, "")};
+  std::vector Expected = {Range(0, 2), Range(3, 4), Range(10, 5),
+ Range(20, 0)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesWithNonOverlappingReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 3, 1, ""),
+   Replacement("foo", 6, 1, "123"),
+   Replacement("foo", 20, 2, "12345")};
+  std::vector Expected = {Range(0, 2), Range(3, 0), Range(4, 4),
+ Range(11, 5), Range(21, 5)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesWithOverlappingReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5),
+   Range(30, 5)};
+  Replacements Replaces = {
+  Replacement("foo", 1, 3, ""), Replacement("foo", 6, 1, "123"),
+  Replacement("foo", 13, 3, "1"), Replacement("foo", 25, 15, "")};
+  std::vector Expected = {Range(0, 1), Range(2, 4), Range(12, 5),
+ Range(22, 0)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, MergeIntoOneRange) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 1, 15, "1234567890")};
+  std::vector Expected = {Range(0, 15)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, ReplacementsStartingAtRangeOffsets) {
+  std::vector Ranges = {Range(0, 2), Range(5, 5), Range(15, 5)};
+  Replacements Replaces = {
+  Replacement("foo", 0, 2, "12"), Replacement("foo", 5, 1, "123"),
+  Replacement("foo", 7, 4, "12345"), Replacement("foo", 15, 10, "12")};
+  std::vector Expected = {Range(0, 2), Range(5, 9), Range(18, 2)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, ReplacementsEndingAtRangeEnds) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 6, 1, "123"),
+   Replacement("foo", 17, 3, "12")};
+  std::vector Expected = {Range(0, 2), Range(5, 4), Range(17, 4)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, AjacentReplacements) {
+  std::vector Ranges = {Range(0, 0), Range(15, 5)};
+  Replacements Replaces = {Replacement("foo", 1, 2, "123"),
+   Replacement("foo", 12, 3, "1234")};
+  std::vector Expected = {Range(0, 0), Range(1, 3), Range(13, 9)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, MergeRangesAfterReplacements) {
+  std::vector Ranges = {Range(8, 0), Range(5, 2), Range(9, 0), Range(0, 1)};
+  Replacements Replaces = {Replacement("foo", 1, 3, ""),
+   Replacement("foo", 7, 0, "12"), Replacement("foo", 9, 2, "")};
+  std::vector Expected = {Range(0, 1), Range(2, 4), Range(7, 0), Range(8, 0)};
+  EXPECT_EQ(Expected, calculateRa

Re: [PATCH] D21547: Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Tooling/Core/Replacement.cpp:285
@@ +284,3 @@
+[](const Range &LHS, const Range &RHS) -> bool {
+  if (LHS.getOffset() != RHS.getOffset())
+return LHS.getOffset() < RHS.getOffset();

djasper wrote:
> or std::tie(LHS.getOffset(), LHS.getLength()) < std::tie(RHS.getOffset(), 
> RHS.getLength())?
I tried std::tie(args...), but it takes references of args...and return values 
are temp values.


Comment at: lib/Tooling/Core/Replacement.cpp:292
@@ +291,3 @@
+if (Result.empty() ||
+Result.back().getOffset() + Result.back().getLength() < R.getOffset()) 
{
+  Result.push_back(R);

djasper wrote:
> Maybe pull out:
>   unsigned CurrentEnd = Result.back().getOffset() + Result.back().getLength();
> 
> Will probably save a line or two :)
But there is Result.empty()...?


http://reviews.llvm.org/D21547



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


r273290 - Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Jun 21 12:56:31 2016
New Revision: 273290

URL: http://llvm.org/viewvc/llvm-project?rev=273290&view=rev
Log:
Added calculateRangesAfterReplaments() to calculate affacted ranges in the new 
code.

Summary:
Added calculateRangesAfterReplaments() to calculate original ranges as well as
newly affacted ranges in the new code.

Reviewers: klimek, djasper

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/include/clang/Tooling/Core/Replacement.h
cfe/trunk/lib/Tooling/Core/Replacement.cpp
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=273290&r1=273289&r2=273290&view=diff
==
--- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Tue Jun 21 12:56:31 2016
@@ -57,6 +57,11 @@ public:
 return RHS.Offset >= Offset &&
(RHS.Offset + RHS.Length) <= (Offset + Length);
   }
+
+  /// \brief Whether this range equals to \p RHS or not.
+  bool operator==(const Range &RHS) const {
+return Offset == RHS.getOffset() && Length == RHS.getLength();
+  }
   /// @}
 
 private:
@@ -222,11 +227,25 @@ bool applyAllReplacements(const std::vec
 std::string applyAllReplacements(StringRef Code, const Replacements &Replaces);
 
 /// \brief Calculates the ranges in a single file that are affected by the
-/// Replacements.
+/// Replacements. Overlapping ranges will be merged.
 ///
 /// \pre Replacements must be for the same file.
+///
+/// \returns a non-overlapping and sorted ranges.
 std::vector calculateChangedRanges(const Replacements &Replaces);
 
+/// \brief Calculates the new ranges after \p Replaces are applied. These
+/// include both the original \p Ranges and the affected ranges of \p Replaces
+/// in the new code.
+///
+/// \pre Replacements must be for the same file.
+///
+/// \return The new ranges after \p Replaces are applied. The new ranges will 
be
+/// sorted and non-overlapping.
+std::vector
+calculateRangesAfterReplacements(const Replacements &Replaces,
+ const std::vector &Ranges);
+
 /// \brief Groups a random set of replacements by file path. Replacements
 /// related to the same file entry are put into the same vector.
 std::map

Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=273290&r1=273289&r2=273290&view=diff
==
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Tue Jun 21 12:56:31 2016
@@ -278,6 +278,30 @@ std::string applyAllReplacements(StringR
   return Result;
 }
 
+// Merge and sort overlapping ranges in \p Ranges.
+static std::vector mergeAndSortRanges(std::vector Ranges) {
+  std::sort(Ranges.begin(), Ranges.end(),
+[](const Range &LHS, const Range &RHS) {
+  if (LHS.getOffset() != RHS.getOffset())
+return LHS.getOffset() < RHS.getOffset();
+  return LHS.getLength() < RHS.getLength();
+});
+  std::vector Result;
+  for (const auto &R : Ranges) {
+if (Result.empty() ||
+Result.back().getOffset() + Result.back().getLength() < R.getOffset()) 
{
+  Result.push_back(R);
+} else {
+  unsigned NewEnd =
+  std::max(Result.back().getOffset() + Result.back().getLength(),
+   R.getOffset() + R.getLength());
+  Result[Result.size() - 1] =
+  Range(Result.back().getOffset(), NewEnd - Result.back().getOffset());
+}
+  }
+  return Result;
+}
+
 std::vector calculateChangedRanges(const Replacements &Replaces) {
   std::vector ChangedRanges;
   int Shift = 0;
@@ -287,7 +311,20 @@ std::vector calculateChangedRange
 Shift += Length - R.getLength();
 ChangedRanges.push_back(Range(Offset, Length));
   }
-  return ChangedRanges;
+  return mergeAndSortRanges(ChangedRanges);
+}
+
+std::vector
+calculateRangesAfterReplacements(const Replacements &Replaces,
+ const std::vector &Ranges) {
+  auto MergedRanges = mergeAndSortRanges(Ranges);
+  tooling::Replacements FakeReplaces;
+  for (const auto &R : MergedRanges)
+FakeReplaces.insert(Replacement(Replaces.begin()->getFilePath(),
+R.getOffset(), R.getLength(),
+std::string(" ", R.getLength(;
+  tooling::Replacements NewReplaces = mergeReplacements(FakeReplaces, 
Replaces);
+  return calculateChangedRanges(NewReplaces);
 }
 
 namespace {
@@ -434,4 +471,3 @@ Replacements mergeReplacements(const Rep
 
 } // end namespace tooling
 } // end namespace clang
-

Modified: cfe/trunk/unittests

Re: [PATCH] D21547: Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273290: Added calculateRangesAfterReplaments() to calculate 
affacted ranges in the… (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D21547?vs=61405&id=61407#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21547

Files:
  cfe/trunk/include/clang/Tooling/Core/Replacement.h
  cfe/trunk/lib/Tooling/Core/Replacement.cpp
  cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Index: cfe/trunk/lib/Tooling/Core/Replacement.cpp
===
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp
@@ -278,6 +278,30 @@
   return Result;
 }
 
+// Merge and sort overlapping ranges in \p Ranges.
+static std::vector mergeAndSortRanges(std::vector Ranges) {
+  std::sort(Ranges.begin(), Ranges.end(),
+[](const Range &LHS, const Range &RHS) {
+  if (LHS.getOffset() != RHS.getOffset())
+return LHS.getOffset() < RHS.getOffset();
+  return LHS.getLength() < RHS.getLength();
+});
+  std::vector Result;
+  for (const auto &R : Ranges) {
+if (Result.empty() ||
+Result.back().getOffset() + Result.back().getLength() < R.getOffset()) {
+  Result.push_back(R);
+} else {
+  unsigned NewEnd =
+  std::max(Result.back().getOffset() + Result.back().getLength(),
+   R.getOffset() + R.getLength());
+  Result[Result.size() - 1] =
+  Range(Result.back().getOffset(), NewEnd - Result.back().getOffset());
+}
+  }
+  return Result;
+}
+
 std::vector calculateChangedRanges(const Replacements &Replaces) {
   std::vector ChangedRanges;
   int Shift = 0;
@@ -287,7 +311,20 @@
 Shift += Length - R.getLength();
 ChangedRanges.push_back(Range(Offset, Length));
   }
-  return ChangedRanges;
+  return mergeAndSortRanges(ChangedRanges);
+}
+
+std::vector
+calculateRangesAfterReplacements(const Replacements &Replaces,
+ const std::vector &Ranges) {
+  auto MergedRanges = mergeAndSortRanges(Ranges);
+  tooling::Replacements FakeReplaces;
+  for (const auto &R : MergedRanges)
+FakeReplaces.insert(Replacement(Replaces.begin()->getFilePath(),
+R.getOffset(), R.getLength(),
+std::string(" ", R.getLength(;
+  tooling::Replacements NewReplaces = mergeReplacements(FakeReplaces, Replaces);
+  return calculateChangedRanges(NewReplaces);
 }
 
 namespace {
@@ -434,4 +471,3 @@
 
 } // end namespace tooling
 } // end namespace clang
-
Index: cfe/trunk/unittests/Tooling/RefactoringTest.cpp
===
--- cfe/trunk/unittests/Tooling/RefactoringTest.cpp
+++ cfe/trunk/unittests/Tooling/RefactoringTest.cpp
@@ -462,13 +462,96 @@
 
   std::vector Ranges = calculateChangedRanges(Replaces);
 
-  EXPECT_EQ(3ul, Ranges.size());
+  EXPECT_EQ(2ul, Ranges.size());
   EXPECT_TRUE(Ranges[0].getOffset() == 0);
   EXPECT_TRUE(Ranges[0].getLength() == 0);
   EXPECT_TRUE(Ranges[1].getOffset() == 6);
-  EXPECT_TRUE(Ranges[1].getLength() == 6);
-  EXPECT_TRUE(Ranges[2].getOffset() == 12);
-  EXPECT_TRUE(Ranges[2].getLength() == 16);
+  EXPECT_TRUE(Ranges[1].getLength() == 22);
+}
+
+TEST(Range, RangesAfterReplacements) {
+  std::vector Ranges = {Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 0, 2, "1234")};
+  std::vector Expected = {Range(0, 4), Range(7, 2), Range(12, 5)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesBeforeReplacements) {
+  std::vector Ranges = {Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 20, 2, "1234")};
+  std::vector Expected = {Range(5, 2), Range(10, 5), Range(20, 4)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, NotAffectedByReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 3, 2, "12"),
+   Replacement("foo", 12, 2, "12"),
+   Replacement("foo", 20, 5, "")};
+  std::vector Expected = {Range(0, 2), Range(3, 4), Range(10, 5),
+ Range(20, 0)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesWithNonOverlappingReplacements) {
+  std::vector Ranges = {Range(0, 2), Range(5, 2), Range(10, 5)};
+  Replacements Replaces = {Replacement("foo", 3, 1, ""),
+   Replacement("foo", 6, 1, "123"),
+   Replacement("foo", 20, 2, "12345")};
+  std::vector Expected = {Range(0, 2), Range(3, 0), Range(4, 4),
+ Range(11, 5), Range(21, 5)};
+  EXPECT_EQ(Expected, calculateRangesAfterReplacements(Replaces, Ranges));
+}
+
+TEST(Range, RangesWithO

Re: [PATCH] D5896: Emit minnum / maxnum for __builtin_fmin/fmax

2016-06-21 Thread Matt Arsenault via cfe-commits
arsenm added a comment.

ping


http://reviews.llvm.org/D5896



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


[clang-tools-extra] r273291 - [clang-apply-replacements] use Range::operator==() instead of self-defined operator.

2016-06-21 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Jun 21 12:59:57 2016
New Revision: 273291

URL: http://llvm.org/viewvc/llvm-project?rev=273291&view=rev
Log:
[clang-apply-replacements] use Range::operator==() instead of self-defined 
operator.

Modified:

clang-tools-extra/trunk/unittests/clang-apply-replacements/ReformattingTest.cpp

Modified: 
clang-tools-extra/trunk/unittests/clang-apply-replacements/ReformattingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-apply-replacements/ReformattingTest.cpp?rev=273291&r1=273290&r2=273291&view=diff
==
--- 
clang-tools-extra/trunk/unittests/clang-apply-replacements/ReformattingTest.cpp 
(original)
+++ 
clang-tools-extra/trunk/unittests/clang-apply-replacements/ReformattingTest.cpp 
Tue Jun 21 12:59:57 2016
@@ -40,13 +40,11 @@ static ReplacementsVec makeReplacements(
 // lookup finds these functions for the EXPECT_EQ macros below.
 namespace clang {
 namespace tooling {
-bool operator==(const Range &A, const Range &B) {
-  return A.getOffset() == B.getOffset() && A.getLength() == B.getLength();
-}
 
 std::ostream &operator<<(std::ostream &os, const Range &R) {
   return os << "Range(" << R.getOffset() << ", " << R.getLength() << ")";
 }
+
 } // namespace tooling
 } // namespace clang
 


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


Re: [PATCH] D21303: [clang-tidy] Adds performance-returning-type check.

2016-06-21 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: clang-tidy/performance/ReturnValueCopyCheck.cpp:107-108
@@ +106,4 @@
+   InnerMatcher) {
+  return hasDeclaration(
+  cxxRecordDecl(hasDescendant(cxxConstructorDecl(InnerMatcher;
+}

You have bug here, but it should not affect the check - 
hasDescendant(cxxConstructorDecl()) could possibly match to constructor of 
another class defined inside class.

Try
cxxRecordDecl(hasMethod(cxxConstructorDecl(InnerMatcher


http://reviews.llvm.org/D21303



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


Re: [PATCH] D20647: Add support for /Ob1 and -finline-hint-functions flags

2016-06-21 Thread Rudy Pons via cfe-commits
Ilod marked an inline comment as done.


Comment at: test/Driver/cl-options.c:283
@@ -282,3 +282,2 @@
 // RUN:/nologo \
-// RUN:/Ob1 \
 // RUN:/openmp- \

hans wrote:
> You're removing it from the ignored flags here, but I don't see any code 
> change or test for how clang-cl's supposed to handle it. What am I missing?
Removing it from the ignored flags make if fallback to the generic /0 
multi-param handling, in MSVCToolchain.cpp TranslateOptArg function.
However I just checked that I forgot to forward the argument from the clang 
driver to cc1 in ConstructJob. Will add this (and a test for the driver) and 
submit a new patch.


http://reviews.llvm.org/D20647



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


Re: [PATCH] D21303: [clang-tidy] Adds performance-returning-type check.

2016-06-21 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: clang-tidy/performance/ReturnValueCopyCheck.cpp:53
@@ +52,3 @@
+/// matches the given matcher.
+AST_MATCHER_P(QualType, ignoringRefsAndConsts,
+  ast_matchers::internal::Matcher, InnerMatcher) {

This one is usefull AF. Can you put into Traversal AST Matchers?


{meme, src=brilliant}




Comment at: clang-tidy/performance/ReturnValueCopyCheck.cpp:114
@@ +113,3 @@
+AST_MATCHER_FUNCTION_P(ast_matchers::internal::Matcher,
+   hasConstructorFromType,
+   ast_matchers::internal::Matcher,

maybe isConstructibleFromType? hasConstructorFromType seems like it would take 
cxxConstructorDecl or something.
BTW what about conversion operator? I don't see any test using it. If 
implementing this would be too much work, then just write FIXME for now. I 
guess this case would be very uncommon.


Comment at: clang-tidy/performance/ReturnValueCopyCheck.cpp:142
@@ +141,3 @@
+  // Matches to expression expression that have declaration with is reference 
or
+  // const
+  auto IsDeclaredAsRefOrConstType =

dot at the end


http://reviews.llvm.org/D21303



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


Re: [PATCH] D21306: [x86] AVX FP compare builtins should require AVX target feature (PR28112)

2016-06-21 Thread Simon Pilgrim via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM - the compile warning is clear and it could be a problem if we allow 
undefined values through on pre-AVX targets.

The only other thing we could do is handle these in CGBuiltin and 'accept' 0-7 
values through on sse/sse2 targets and assert on other values but I don't see 
how this would be better.


http://reviews.llvm.org/D21306



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


Re: [PATCH] D19770: Add FixedSizeStorage to TrailingObjects; NFC

2016-06-21 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added a comment.

Ping.


http://reviews.llvm.org/D19770



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


Re: [PATCH] D21517: clang-rename: add a -old-name option

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

LG


http://reviews.llvm.org/D21517



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-21 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp:34
@@ +33,3 @@
+  hasDeclaration(functionDecl(hasName("push_back"))),
+  on(hasType(cxxRecordDecl(hasAnyName("std::vector", "llvm::SmallVector",
+  "std::list", "std::deque");

We should not hard code this list. Specially not non-standard types like 
llvm::SmallVector.
This should come from an option string.
For example, like we do in performance/FasterStringFindCheck.cpp


Comment at: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp:42
@@ +41,3 @@
+  auto isCtorOfSmartPtr = hasDeclaration(cxxConstructorDecl(
+  ofClass(hasAnyName("std::shared_ptr", "std::unique_ptr", "std::auto_ptr",
+ "std::weak_ptr";

These are not the only smart pointers around.
It might be a good idea to make this list also configurable by the user.


Comment at: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp:45
@@ +44,3 @@
+
+  // Bitfields binds only to consts and emplace_back take it by universal ref.
+  auto bitFieldAsArgument = hasAnyArgument(ignoringParenImpCasts(

There are a few more things that can break here:
  - `NULL` can't be passed through perfect forwarding. Will be deduced as 
`long`.
  - Function references/pointers can't be passed through PF if they are 
overloaded.
  - Class scope static variables that have no definition can't be passed 
through PF because they will be ODR used.


Comment at: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp:92
@@ +91,3 @@
+  // Range for constructor name and opening brace.
+  auto CtorCallSourceRange = CharSourceRange::getCharRange(
+  InnerCtorCall->getExprLoc(),

You should avoid using offsets with locations.
For example, you are hardcoding `{` as one character, which might not be true 
in the case of digraphs.

This should be `getTokenRange(InnerCtorCall->getExprLoc(), 
CallParensRange.getBegin())`

Same thing for the other one, it should be:

`CharSourceRange::getTokenRange(CallParensRange.getEnd(), 
CallParensRange.getEnd())`


Comment at: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h:23
@@ +22,3 @@
+/// constructor of temporary object.
+///`
+/// For the user-facing documentation see:

runaway qoute


Comment at: clang-tools-extra/trunk/clang-tidy/utils/Matchers.h:48
@@ -47,1 +47,3 @@
 
+AST_MATCHER(FieldDecl, isBitfield) { return Node.isBitField(); }
+

This matcher is generic enough that it should go into main ASTMatchers.h file.


Comment at: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst:17
@@ +16,3 @@
+
+   std::vector > w;
+   w.push_back(std::make_pair(21, 37));

Don't add the space between the >>. This is not needed since we are in C++11.


Comment at: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst:52
@@ +51,3 @@
+   std::vector > v;
+   v.push_back(new int(5));
+   auto *ptr = int;

This doesn't compile. unique_ptr is not implicitly convertible from a pointer.


Comment at: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst:53
@@ +52,3 @@
+   v.push_back(new int(5));
+   auto *ptr = int;
+   v.push_back(ptr);

I think you meant `auto* ptr = new int(5)` ?


Comment at: clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp:76
@@ +75,3 @@
+};
+
+struct Convertable {

You should also try with a type that has a user-defined destructor.
It changes the AST enough to make a difference in many cases.

And you should fix all the std classes above to have user-defined constructors 
too.


Comment at: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp:209
@@ +208,3 @@
+  std::vector> v2;
+  v2.push_back(new int(42));
+  // This call can't be replaced with emplace_back.

This test is broken. `unique_ptr` should not have an implicit conversion 
from T*.


Comment at: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp:338
@@ +337,2 @@
+  // CHECK-FIXES: v.emplace_back(42, var);
+}

It is also missing tests with templates.
ie: the container being a dependent type, and the value_type being a dependent 
type.
We should not change the code in either of those cases.


Repository:
  rL LLVM

http://reviews.llvm.org/D20964



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


r273296 - [MS] Don't expect vftables to be provided for extern template instantiations

2016-06-21 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Jun 21 13:39:55 2016
New Revision: 273296

URL: http://llvm.org/viewvc/llvm-project?rev=273296&view=rev
Log:
[MS] Don't expect vftables to be provided for extern template instantiations

MSVC doesn't provide them. PR28223

I left behind the machinery in case we want to resurrect available_externally
vftable emission to support devirtualization.

Reviewers: majnemer

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

Modified:
cfe/trunk/lib/AST/VTableBuilder.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp

Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=273296&r1=273295&r2=273296&view=diff
==
--- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
+++ cfe/trunk/lib/AST/VTableBuilder.cpp Tue Jun 21 13:39:55 2016
@@ -2545,14 +2545,13 @@ public:
 MostDerivedClassLayout(Context.getASTRecordLayout(MostDerivedClass)),
 WhichVFPtr(*Which),
 Overriders(MostDerivedClass, CharUnits(), MostDerivedClass) {
-// Only include the RTTI component if we know that we will provide a
-// definition of the vftable.  We always provide the definition of
-// dllimported classes.
+// Provide the RTTI component if RTTIData is enabled. If the vftable would
+// be available externally, we should not provide the RTTI componenent. It
+// is currently impossible to get available externally vftables with either
+// dllimport or extern template instantiations, but eventually we may add a
+// flag to support additional devirtualization that needs this.
 if (Context.getLangOpts().RTTIData)
-  if (MostDerivedClass->hasAttr() ||
-  MostDerivedClass->getTemplateSpecializationKind() !=
-  TSK_ExplicitInstantiationDeclaration)
-HasRTTIComponent = true;
+  HasRTTIComponent = true;
 
 LayoutVFTable();
 

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=273296&r1=273295&r2=273296&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Tue Jun 21 13:39:55 2016
@@ -794,6 +794,10 @@ CodeGenModule::getVTableLinkage(const CX
   return DiscardableODRLinkage;
 
 case TSK_ExplicitInstantiationDeclaration:
+  // Explicit instantiations in MSVC do not provide vtables, so we must 
emit
+  // our own.
+  if (getTarget().getCXXABI().isMicrosoft())
+return DiscardableODRLinkage;
   return shouldEmitAvailableExternallyVTable(*this, RD)
  ? llvm::GlobalVariable::AvailableExternallyLinkage
  : llvm::GlobalVariable::ExternalLinkage;
@@ -839,9 +843,9 @@ CodeGenVTables::GenerateClassData(const
 bool CodeGenVTables::isVTableExternal(const CXXRecordDecl *RD) {
   assert(RD->isDynamicClass() && "Non-dynamic classes have no VTable.");
 
-  // We always synthesize vtables on the import side regardless of whether or
-  // not it is an explicit instantiation declaration.
-  if (CGM.getTarget().getCXXABI().isMicrosoft() && 
RD->hasAttr())
+  // We always synthesize vtables if they are needed in the MS ABI. MSVC 
doesn't
+  // emit them even if there is an explicit template instantiation.
+  if (CGM.getTarget().getCXXABI().isMicrosoft())
 return false;
 
   // If we have an explicit instantiation declaration (and not a

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp?rev=273296&r1=273295&r2=273296&view=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp Tue Jun 21 13:39:55 
2016
@@ -537,5 +537,5 @@ template  struct B : virtual A {
 
 extern template class B;
 template B::B();
-// CHECK-DAG: @"\01??_8?$B@H@Test30@@7B@" = external unnamed_addr constant [2 
x i32]{{$}}
+// CHECK-DAG: @"\01??_8?$B@H@Test30@@7B@" = linkonce_odr unnamed_addr constant 
[2 x i32] [i32 0, i32 4], comdat
 }

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp?rev=273296&r1=273295&r2=273296&view=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp Tue Jun 21 13:39:55 
2016
@@ -33,7 +33,7 @@ struct __declspec(dllexport) V {
 
 namespace {
 struct W {
-  virtual ~W();
+  virtual ~W() {}
 } w;
 }
 // RTTI-DAG: [[VTABLE_W:@.*]] = private unna

Re: [PATCH] D21544: [MS] Don't expect vftables to be provided for extern template instantiations

2016-06-21 Thread Reid Kleckner via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273296: [MS] Don't expect vftables to be provided for extern 
template instantiations (authored by rnk).

Changed prior to commit:
  http://reviews.llvm.org/D21544?vs=61331&id=61414#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21544

Files:
  cfe/trunk/lib/AST/VTableBuilder.cpp
  cfe/trunk/lib/CodeGen/CGVTables.cpp
  cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp
  cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp

Index: cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp
===
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp
@@ -33,7 +33,7 @@
 
 namespace {
 struct W {
-  virtual ~W();
+  virtual ~W() {}
 } w;
 }
 // RTTI-DAG: [[VTABLE_W:@.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast ({{.*}} @"\01??_R4W@?A@@6B@" to i8*), i8* bitcast ({{.*}} 
@"\01??_GW@?A@@UAEPAXI@Z" to i8*)]
@@ -49,5 +49,7 @@
 
 extern template class Y;
 template Y::Y();
-// RTTI-DAG: @"\01??_7?$Y@H@@6B@" = external unnamed_addr constant [1 x i8*]
-// NO-RTTI-DAG: @"\01??_7?$Y@H@@6B@" = external unnamed_addr constant [1 x i8*]
+// RTTI-DAG: [[VTABLE_Y:@.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast (%rtti.CompleteObjectLocator* @"\01??_R4?$Y@H@@6B@" to i8*), i8* 
bitcast (i8* (%struct.Y*, i32)* @"\01??_G?$Y@H@@UAEPAXI@Z" to i8*)], 
comdat($"\01??_7?$Y@H@@6B@")
+// RTTI-DAG: @"\01??_7?$Y@H@@6B@" = unnamed_addr alias i8*, getelementptr 
inbounds ([2 x i8*], [2 x i8*]* [[VTABLE_Y]], i32 0, i32 1)
+
+// NO-RTTI-DAG: @"\01??_7?$Y@H@@6B@" = linkonce_odr unnamed_addr constant [1 x 
i8*] [i8* bitcast (i8* (%struct.Y*, i32)* @"\01??_G?$Y@H@@UAEPAXI@Z" to i8*)], 
comdat
Index: cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp
===
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp
@@ -537,5 +537,5 @@
 
 extern template class B;
 template B::B();
-// CHECK-DAG: @"\01??_8?$B@H@Test30@@7B@" = external unnamed_addr constant [2 
x i32]{{$}}
+// CHECK-DAG: @"\01??_8?$B@H@Test30@@7B@" = linkonce_odr unnamed_addr constant 
[2 x i32] [i32 0, i32 4], comdat
 }
Index: cfe/trunk/lib/CodeGen/CGVTables.cpp
===
--- cfe/trunk/lib/CodeGen/CGVTables.cpp
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp
@@ -794,6 +794,10 @@
   return DiscardableODRLinkage;
 
 case TSK_ExplicitInstantiationDeclaration:
+  // Explicit instantiations in MSVC do not provide vtables, so we must 
emit
+  // our own.
+  if (getTarget().getCXXABI().isMicrosoft())
+return DiscardableODRLinkage;
   return shouldEmitAvailableExternallyVTable(*this, RD)
  ? llvm::GlobalVariable::AvailableExternallyLinkage
  : llvm::GlobalVariable::ExternalLinkage;
@@ -839,9 +843,9 @@
 bool CodeGenVTables::isVTableExternal(const CXXRecordDecl *RD) {
   assert(RD->isDynamicClass() && "Non-dynamic classes have no VTable.");
 
-  // We always synthesize vtables on the import side regardless of whether or
-  // not it is an explicit instantiation declaration.
-  if (CGM.getTarget().getCXXABI().isMicrosoft() && 
RD->hasAttr())
+  // We always synthesize vtables if they are needed in the MS ABI. MSVC 
doesn't
+  // emit them even if there is an explicit template instantiation.
+  if (CGM.getTarget().getCXXABI().isMicrosoft())
 return false;
 
   // If we have an explicit instantiation declaration (and not a
Index: cfe/trunk/lib/AST/VTableBuilder.cpp
===
--- cfe/trunk/lib/AST/VTableBuilder.cpp
+++ cfe/trunk/lib/AST/VTableBuilder.cpp
@@ -2545,14 +2545,13 @@
 MostDerivedClassLayout(Context.getASTRecordLayout(MostDerivedClass)),
 WhichVFPtr(*Which),
 Overriders(MostDerivedClass, CharUnits(), MostDerivedClass) {
-// Only include the RTTI component if we know that we will provide a
-// definition of the vftable.  We always provide the definition of
-// dllimported classes.
+// Provide the RTTI component if RTTIData is enabled. If the vftable would
+// be available externally, we should not provide the RTTI componenent. It
+// is currently impossible to get available externally vftables with either
+// dllimport or extern template instantiations, but eventually we may add a
+// flag to support additional devirtualization that needs this.
 if (Context.getLangOpts().RTTIData)
-  if (MostDerivedClass->hasAttr() ||
-  MostDerivedClass->getTemplateSpecializationKind() !=
-  TSK_ExplicitInstantiationDeclaration)
-HasRTTIComponent = true;
+  HasRTTIComponent = true;
 
 LayoutVFTable();
 


Index: cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp
=

Re: [PATCH] D20647: Add support for /Ob1 and -finline-hint-functions flags

2016-06-21 Thread Rudy Pons via cfe-commits
Ilod updated this revision to Diff 61418.
Ilod added a comment.

Fixed passing argument from clang driver to cc1.
Added driver tests.


http://reviews.llvm.org/D20647

Files:
  include/clang/Driver/CLCompatOptions.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/inline-optim.c
  test/CodeGenCXX/inline-hint.cpp
  test/Driver/cl-options.c
  test/Driver/finline.c

Index: test/Driver/finline.c
===
--- test/Driver/finline.c
+++ test/Driver/finline.c
@@ -0,0 +1,10 @@
+// Make sure the driver is correctly passing the -finline-functions family
+
+// RUN: %clang -target x86_64-apple-darwin10 -finline-functions -### -fsyntax-only %s 2>&1 | FileCheck -check-prefixes=INLINE,CHECK %s
+// RUN: %clang -target x86_64-apple-darwin10 -finline-hint-functions -### -fsyntax-only %s 2>&1 | FileCheck -check-prefixes=HINT,CHECK %s
+// RUN: %clang -target x86_64-apple-darwin10 -fno-inline-functions -### -fsyntax-only %s 2>&1 | FileCheck -check-prefixes=NOINLINE,CHECK %s
+
+// CHECK: clang
+// INLINE: "-finline-functions"
+// HINT: "-finline-hint-functions"
+// NOINLINE: "-fno-inline-functions"
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -113,6 +113,10 @@
 // Ob2-NOT: warning: argument unused during compilation: '/O2'
 // Ob2: -finline-functions
 
+// RUN: %clang_cl /Ob1 -### -- %s 2>&1 | FileCheck -check-prefix=Ob1 %s
+// RUN: %clang_cl /Odb1 -### -- %s 2>&1 | FileCheck -check-prefix=Ob1 %s
+// Ob1: -finline-hint-functions
+
 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
 // Od: -O0
 
@@ -280,7 +284,6 @@
 // RUN:/GS- \
 // RUN:/kernel- \
 // RUN:/nologo \
-// RUN:/Ob1 \
 // RUN:/openmp- \
 // RUN:/RTC1 \
 // RUN:/sdl \
Index: test/CodeGenCXX/inline-hint.cpp
===
--- test/CodeGenCXX/inline-hint.cpp
+++ test/CodeGenCXX/inline-hint.cpp
@@ -0,0 +1,96 @@
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -finline-functions -emit-llvm -disable-llvm-optzns -o - | FileCheck %s --check-prefix=CHECK --check-prefix=SUITABLE
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -finline-hint-functions -emit-llvm -disable-llvm-optzns -o - | FileCheck %s --check-prefix=CHECK --check-prefix=HINTED
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -fno-inline -emit-llvm -disable-llvm-optzns -o - | FileCheck %s --check-prefix=CHECK --check-prefix=NOINLINE
+
+// Force non-trivial implicit constructors/destructors/operators for B by having explicit ones for A
+struct A {
+  A() {}
+  A(const A&) {}
+  A& operator=(const A&) { return *this; }
+  ~A() {}
+};
+
+struct B {
+  A member;
+  int implicitFunction(int a) { return a + a; }
+  inline int explicitFunction(int a);
+  int noHintFunction(int a);
+  __attribute__((optnone)) int optNoneFunction(int a) { return a + a; }
+  template int implicitTplFunction(int a) { return N + a; }
+  template inline int explicitTplFunction(int a) { return N + a; }
+  template int noHintTplFunction(int a);
+  template int explicitRedeclTplFunction(int a);
+};
+
+int B::explicitFunction(int a) { return a + a; }
+// CHECK: @_ZN1B14noHintFunctionEi({{.*}}) [[NOHINT_ATTR:#[0-9]+]]
+int B::noHintFunction(int a) { return a + a; }
+
+// CHECK: @_ZN1B19implicitTplFunctionILi0EEEii({{.*}}) [[NOHINT_ATTR]]
+template<> int B::implicitTplFunction<0>(int a) { return a + a; }
+// CHECK: @_ZN1B19explicitTplFunctionILi0EEEii({{.*}}) [[NOHINT_ATTR]]
+template<> int B::explicitTplFunction<0>(int a) { return a + a; }
+// CHECK: @_ZN1B17noHintTplFunctionILi0EEEii({{.*}}) [[NOHINT_ATTR]]
+template<> int B::noHintTplFunction<0>(int a) { return a + a; }
+template<> inline int B::implicitTplFunction<1>(int a) { return a; }
+template<> inline int B::explicitTplFunction<1>(int a) { return a; }
+template<> inline int B::noHintTplFunction<1>(int a) { return a; }
+template int B::noHintTplFunction(int a) { return N + a; }
+template inline int B::explicitRedeclTplFunction(int a) { return N + a; }
+
+constexpr int constexprFunction(int a) { return a + a; }
+
+void foo()
+{
+// CHECK: @_ZN1BC1Ev({{.*}}) unnamed_addr [[IMPLICIT_CONSTR_ATTR:#[0-9]+]]
+  B b1;
+// CHECK: @_ZN1BC1ERKS_({{.*}}) unnamed_addr [[IMPLICIT_CONSTR_ATTR]]
+  B b2(b1);
+// CHECK: @_ZN1BaSERKS_({{.*}}) [[IMPLICIT_CONSTR_ATTR]]
+  b2 = b1;
+// CHECK: @_ZN1B16implicitFunctionEi({{.*}}) [[IMPLICIT_ATTR:#[0-9]+]]
+  b1.implicitFunction(1);
+// CHECK: @_ZN1B16explicitFunctionEi({{.*}}) [[EXPLICIT_ATTR:#[0-9]+]]
+  b1.explicitFunction(2);
+  b1.noHintFunction(3);
+// CHECK: @_ZN1B15optNoneFunctionEi({{.*}}) [[OPTNONE_ATTR:#[0-9]+]]
+  b1.optNoneFunction(4);
+// CHECK: @_Z17constexprFuncti

Re: [PATCH] D20647: Add support for /Ob1 and -finline-hint-functions flags

2016-06-21 Thread Rudy Pons via cfe-commits
Ilod marked 2 inline comments as done.
Ilod added a comment.

http://reviews.llvm.org/D20647



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


r273298 - Invoke PruneEH pass before Sample Profile pass.

2016-06-21 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Tue Jun 21 14:16:41 2016
New Revision: 273298

URL: http://llvm.org/viewvc/llvm-project?rev=273298&view=rev
Log:
Invoke PruneEH pass before Sample Profile pass.

Summary: We need to call PruneEH pass before AutoFDO pass so that some 
EH-related calls can get inlined in Sample Profile pass.

Reviewers: davidxl, dnovillo

Subscribers: junbuml, llvm-commits

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

Added:
cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof
cfe/trunk/test/CodeGen/pgo-sample.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=273298&r1=273297&r2=273298&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Jun 21 14:16:41 2016
@@ -488,6 +488,7 @@ void EmitAssemblyHelper::CreatePasses(Mo
 PMBuilder.PGOInstrUse = CodeGenOpts.ProfileInstrumentUsePath;
 
   if (!CodeGenOpts.SampleProfileFile.empty()) {
+MPM->add(createPruneEHPass());
 MPM->add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile));
 PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
addInstructionCombiningPass);

Added: cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof?rev=273298&view=auto
==
--- cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof (added)
+++ cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof Tue Jun 21 14:16:41 2016
@@ -0,0 +1,2 @@
+bar:100:100
+ 1: 2000

Added: cfe/trunk/test/CodeGen/pgo-sample.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pgo-sample.c?rev=273298&view=auto
==
--- cfe/trunk/test/CodeGen/pgo-sample.c (added)
+++ cfe/trunk/test/CodeGen/pgo-sample.c Tue Jun 21 14:16:41 2016
@@ -0,0 +1,6 @@
+// Test if PGO sample use passes are invoked.
+//
+// Ensure Pass PGOInstrumentationGenPass is invoked.
+// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s 
-mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s
+// CHECK: Remove unused exception handling info
+// CHECK: Sample profile pass


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


Re: [PATCH] D21031: [OpenCL] Allow -cl-std and other standard -cl- options in driver

2016-06-21 Thread Aaron En Ye Shi via cfe-commits
ashi1 updated this revision to Diff 61423.
ashi1 marked 2 inline comments as done.
ashi1 added a comment.

Revised based on Anastasia's comments. Also clang-test run passes, the 
testcases should be working correctly.


http://reviews.llvm.org/D21031

Files:
  include/clang/Basic/DiagnosticFrontendKinds.td
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/opencl.cl

Index: test/Driver/opencl.cl
===
--- test/Driver/opencl.cl
+++ test/Driver/opencl.cl
@@ -1,15 +1,39 @@
-// RUN: %clang -fsyntax-only %s
-// RUN: %clang -fsyntax-only -std=cl %s
-// RUN: %clang -fsyntax-only -std=cl1.1 %s
-// RUN: %clang -fsyntax-only -std=cl1.2 %s
-// RUN: %clang -fsyntax-only -std=cl2.0 %s
-// RUN: %clang -fsyntax-only -std=CL %s
-// RUN: %clang -fsyntax-only -std=CL1.1 %s
-// RUN: %clang -fsyntax-only -std=CL1.2 %s
-// RUN: %clang -fsyntax-only -std=CL2.0 %s
-// RUN: not %clang_cc1 -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
-// RUN: not %clang_cc1 -std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
-// CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'
-// CHECK-INVALID: error: invalid value 'invalid' in '-std=invalid'
+// RUN: %clang -S -### %s
+// RUN: %clang -S -### -cl-std=CL %s | FileCheck --check-prefix=CHECK-CL %s
+// RUN: %clang -S -### -cl-std=CL1.1 %s | FileCheck --check-prefix=CHECK-CL11 %s
+// RUN: %clang -S -### -cl-std=CL1.2 %s | FileCheck --check-prefix=CHECK-CL12 %s
+// RUN: %clang -S -### -cl-std=CL2.0 %s | FileCheck --check-prefix=CHECK-CL20 %s
+// RUN: %clang -S -### -cl-opt-disable %s | FileCheck --check-prefix=CHECK-OPT-DISABLE %s
+// RUN: %clang -S -### -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-STRICT-ALIASING %s
+// RUN: %clang -S -### -cl-std=CL1.1 -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
+// RUN: %clang -S -### -cl-std=CL1.2 -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
+// RUN: %clang -S -### -cl-std=CL2.0 -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
+// RUN: %clang -S -### -cl-single-precision-constant %s | FileCheck --check-prefix=CHECK-SINGLE-PRECISION-CONST %s
+// RUN: %clang -S -### -cl-finite-math-only %s | FileCheck --check-prefix=CHECK-FINITE-MATH-ONLY %s
+// RUN: %clang -S -### -cl-kernel-arg-info %s | FileCheck --check-prefix=CHECK-KERNEL-ARG-INFO %s
+// RUN: %clang -S -### -cl-unsafe-math-optimizations %s | FileCheck --check-prefix=CHECK-UNSAFE-MATH-OPT %s
+// RUN: %clang -S -### -cl-fast-relaxed-math %s | FileCheck --check-prefix=CHECK-FAST-RELAXED-MATH %s
+// RUN: %clang -S -### -cl-mad-enable %s | FileCheck --check-prefix=CHECK-MAD-ENABLE %s
+// RUN: %clang -S -### -cl-denorms-are-zero %s | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s
+// RUN: not %clang_cc1 -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
+// RUN: not %clang_cc1 -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
+// CHECK-C99: error: invalid argument '-cl-std=c99' not allowed with 'OpenCL'
+// CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
+// CHECK-INVALID-OPENCL-VERSION11: OpenCL version 1.1 does not support the option 'cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION12: OpenCL version 1.2 does not support the option 'cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION20: OpenCL version 2.0 does not support the option 'cl-strict-aliasing'
+// CHECK-CL: .*clang.* "-cc1" .* "-cl-std=CL"
+// CHECK-CL11: .*clang.* "-cc1" .* "-cl-std=CL1.1"
+// CHECK-CL12: .*clang.* "-cc1" .* "-cl-std=CL1.2"
+// CHECK-CL20: .*clang.* "-cc1" .* "-cl-std=CL2.0"
+// CHECK-OPT-DISABLE: .*clang.* "-cc1" .* "-cl-opt-disable"
+// CHECK-STRICT-ALIASING: .*clang.* "-cc1" .* "-cl-strict-aliasing"
+// CHECK-SINGLE-PRECISION-CONST: .*clang.* "-cc1" .* "-cl-single-precision-constant"
+// CHECK-FINITE-MATH-ONLY: .*clang.* "-cc1" .* "-cl-finite-math-only"
+// CHECK-KERNEL-ARG-INFO: .*clang.* "-cc1" .* "-cl-kernel-arg-info"
+// CHECK-UNSAFE-MATH-OPT: .*clang.* "-cc1" .* "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: .*clang.* "-cc1" .* "-cl-fast-relaxed-math"
+// CHECK-MAD-ENABLE: .*clang.* "-cc1" .* "-cl-mad-enable"
+// CHECK-DENORMS-ARE-ZERO: .*clang.* "-cc1" .* "-cl-denorms-are-zero"
 
 kernel void func(void);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -41,6 +41,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Target/TargetOptions.h"
+#include "llvm/Support/ScopedPrinter.h"
 #include 
 #include 
 #include 
@@ -1666,6 +1667,19 @@
   LangStd = OpenCLLangStd;
   }
 
+  // -cl-strict-aliasing needs to emit diagnostic in th

r273300 - Delete dead code.

2016-06-21 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Tue Jun 21 14:19:31 2016
New Revision: 273300

URL: http://llvm.org/viewvc/llvm-project?rev=273300&view=rev
Log:
Delete dead code.

Found by gcc 6.

Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=273300&r1=273299&r2=273300&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Jun 21 14:19:31 2016
@@ -316,7 +316,6 @@ private:
   bool mangleSubstitution(TemplateName Template);
   bool mangleSubstitution(uintptr_t Ptr);
 
-  void mangleExistingSubstitution(QualType type);
   void mangleExistingSubstitution(TemplateName name);
 
   bool mangleStandardSubstitution(const NamedDecl *ND);
@@ -3875,12 +3874,6 @@ void CXXNameMangler::mangleSeqID(unsigne
   Out << '_';
 }
 
-void CXXNameMangler::mangleExistingSubstitution(QualType type) {
-  bool result = mangleSubstitution(type);
-  assert(result && "no existing substitution for type");
-  (void) result;
-}
-
 void CXXNameMangler::mangleExistingSubstitution(TemplateName tname) {
   bool result = mangleSubstitution(tname);
   assert(result && "no existing substitution for template name");

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=273300&r1=273299&r2=273300&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Jun 21 14:19:31 2016
@@ -2374,59 +2374,6 @@ bool CompilerInvocation::CreateFromArgs(
   return Success;
 }
 
-namespace {
-
-  class ModuleSignature {
-SmallVector Data;
-unsigned CurBit;
-uint64_t CurValue;
-
-  public:
-ModuleSignature() : CurBit(0), CurValue(0) { }
-
-void add(uint64_t Value, unsigned Bits);
-void add(StringRef Value);
-void flush();
-
-llvm::APInt getAsInteger() const;
-  };
-}
-
-void ModuleSignature::add(uint64_t Value, unsigned int NumBits) {
-  CurValue |= Value << CurBit;
-  if (CurBit + NumBits < 64) {
-CurBit += NumBits;
-return;
-  }
-
-  // Add the current word.
-  Data.push_back(CurValue);
-
-  if (CurBit)
-CurValue = Value >> (64-CurBit);
-  else
-CurValue = 0;
-  CurBit = (CurBit+NumBits) & 63;
-}
-
-void ModuleSignature::flush() {
-  if (CurBit == 0)
-return;
-
-  Data.push_back(CurValue);
-  CurBit = 0;
-  CurValue = 0;
-}
-
-void ModuleSignature::add(StringRef Value) {
-  for (auto &c : Value)
-add(c, 8);
-}
-
-llvm::APInt ModuleSignature::getAsInteger() const {
-  return llvm::APInt(Data.size() * 64, Data);
-}
-
 std::string CompilerInvocation::getModuleHash() const {
   // Note: For QoI reasons, the things we use as a hash here should all be
   // dumped via the -module-info flag.


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


[clang-tools-extra] r273304 - clang-rename: add a -old-name option

2016-06-21 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Tue Jun 21 14:48:57 2016
New Revision: 273304

URL: http://llvm.org/viewvc/llvm-project?rev=273304&view=rev
Log:
clang-rename: add a -old-name option

This is similar to -offset with the following differences:

1) -offset can refer to local variables as well.

2) -old-name makes it easier to refer to e.g. ClassName::MemberName by
spelling out the fully qualified name, instead of having to use e.g.
grep to look up the exact offset.

In other words, -offset is great when clang-rename is invoked by e.g. an
IDE, but not really user-friendly when the tool is invoked by the user
from commandline.  That's the use case where -old-name is supposed to
improve the situation.

Reviewers: klimek

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

Added:
clang-tools-extra/trunk/test/clang-rename/ClassTestByName.cpp
Modified:
clang-tools-extra/trunk/clang-rename/USRFinder.cpp
clang-tools-extra/trunk/clang-rename/USRFinder.h
clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
clang-tools-extra/trunk/clang-rename/USRFindingAction.h
clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFinder.cpp?rev=273304&r1=273303&r2=273304&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp Tue Jun 21 14:48:57 2016
@@ -40,6 +40,14 @@ public:
 Point(Point) {
   }
 
+  // \brief Finds the NamedDecl for a name in the source.
+  // \param Name the fully qualified name.
+  explicit NamedDeclFindingASTVisitor(const SourceManager &SourceMgr,
+  const std::string &Name)
+  : Result(nullptr), SourceMgr(SourceMgr),
+Name(Name) {
+  }
+
   // Declaration visitors:
 
   // \brief Checks if the point falls within the NameDecl. This covers every
@@ -93,9 +101,17 @@ private:
   // \returns false on success.
   bool setResult(const NamedDecl *Decl, SourceLocation Start,
  SourceLocation End) {
-if (!Start.isValid() || !Start.isFileID() || !End.isValid() ||
-!End.isFileID() || !isPointWithin(Start, End)) {
-  return true;
+if (Name.empty()) {
+  // Offset is used to find the declaration.
+  if (!Start.isValid() || !Start.isFileID() || !End.isValid() ||
+  !End.isFileID() || !isPointWithin(Start, End)) {
+return true;
+  }
+} else {
+  // Fully qualified name is used to find the declaration.
+  if (Name != Decl->getQualifiedNameAsString()) {
+return true;
+  }
 }
 Result = Decl;
 return false;
@@ -121,6 +137,7 @@ private:
   const NamedDecl *Result;
   const SourceManager &SourceMgr;
   const SourceLocation Point; // The location to find the NamedDecl.
+  const std::string Name;
 };
 }
 
@@ -145,6 +162,22 @@ const NamedDecl *getNamedDeclAt(const AS
 }
   }
 
+  return nullptr;
+}
+
+const NamedDecl *getNamedDeclFor(const ASTContext &Context,
+ const std::string &Name) {
+  const auto &SourceMgr = Context.getSourceManager();
+  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name);
+  auto Decls = Context.getTranslationUnitDecl()->decls();
+
+  for (auto &CurrDecl : Decls) {
+Visitor.TraverseDecl(CurrDecl);
+if (const NamedDecl *Result = Visitor.getNamedDecl()) {
+  return Result;
+}
+  }
+
   return nullptr;
 }
 

Modified: clang-tools-extra/trunk/clang-rename/USRFinder.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFinder.h?rev=273304&r1=273303&r2=273304&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFinder.h (original)
+++ clang-tools-extra/trunk/clang-rename/USRFinder.h Tue Jun 21 14:48:57 2016
@@ -30,6 +30,12 @@ namespace rename {
 const NamedDecl *getNamedDeclAt(const ASTContext &Context,
 const SourceLocation Point);
 
+// Given an AST context and a fully qualified name, returns a NamedDecl
+// identifying the symbol with a matching name. Returns null if nothing is
+// found for the name.
+const NamedDecl *getNamedDeclFor(const ASTContext &Context,
+ const std::string &Name);
+
 // Converts a Decl into a USR.
 std::string getUSRForDecl(const Decl *Decl);
 

Modified: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp?rev=273304&r1=273303&r2=273304&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp Tue Jun 21 
14:48:57 2016
@@ -68,7 +

Re: [PATCH] D21517: clang-rename: add a -old-name option

2016-06-21 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273304: clang-rename: add a -old-name option (authored by 
vmiklos).

Changed prior to commit:
  http://reviews.llvm.org/D21517?vs=61255&id=61430#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21517

Files:
  clang-tools-extra/trunk/clang-rename/USRFinder.cpp
  clang-tools-extra/trunk/clang-rename/USRFinder.h
  clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
  clang-tools-extra/trunk/clang-rename/USRFindingAction.h
  clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
  clang-tools-extra/trunk/test/clang-rename/ClassTestByName.cpp

Index: clang-tools-extra/trunk/clang-rename/USRFindingAction.h
===
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.h
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.h
@@ -25,7 +25,7 @@
 namespace rename {
 
 struct USRFindingAction {
-  USRFindingAction(unsigned Offset) : SymbolOffset(Offset) {
+  USRFindingAction(unsigned Offset, const std::string &Name) : SymbolOffset(Offset), OldName(Name) {
   }
   std::unique_ptr newASTConsumer();
 
@@ -40,6 +40,7 @@
 
 private:
   unsigned SymbolOffset;
+  std::string OldName;
   std::string SpellingName;
   std::vector USRs;
 };
Index: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
@@ -68,7 +68,12 @@
 SourceMgr.getMainFileID()).getLocWithOffset(SymbolOffset);
 if (!Point.isValid())
   return;
-const NamedDecl *FoundDecl = getNamedDeclAt(Context, Point);
+const NamedDecl *FoundDecl = nullptr;
+if (OldName.empty()) {
+  FoundDecl = getNamedDeclAt(Context, Point);
+} else {
+  FoundDecl = getNamedDeclFor(Context, OldName);
+}
 if (FoundDecl == nullptr) {
   FullSourceLoc FullLoc(Point, SourceMgr);
   errs() << "clang-rename: could not find symbol at "
@@ -96,6 +101,7 @@
   }
 
   unsigned SymbolOffset;
+  std::string OldName;
   std::string *SpellingName;
   std::vector *USRs;
 };
@@ -106,6 +112,7 @@
   new NamedDeclFindingConsumer);
   SpellingName = "";
   Consumer->SymbolOffset = SymbolOffset;
+  Consumer->OldName = OldName;
   Consumer->USRs = &USRs;
   Consumer->SpellingName = &SpellingName;
   return std::move(Consumer);
Index: clang-tools-extra/trunk/clang-rename/USRFinder.h
===
--- clang-tools-extra/trunk/clang-rename/USRFinder.h
+++ clang-tools-extra/trunk/clang-rename/USRFinder.h
@@ -30,6 +30,12 @@
 const NamedDecl *getNamedDeclAt(const ASTContext &Context,
 const SourceLocation Point);
 
+// Given an AST context and a fully qualified name, returns a NamedDecl
+// identifying the symbol with a matching name. Returns null if nothing is
+// found for the name.
+const NamedDecl *getNamedDeclFor(const ASTContext &Context,
+ const std::string &Name);
+
 // Converts a Decl into a USR.
 std::string getUSRForDecl(const Decl *Decl);
 
Index: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp
@@ -40,6 +40,14 @@
 Point(Point) {
   }
 
+  // \brief Finds the NamedDecl for a name in the source.
+  // \param Name the fully qualified name.
+  explicit NamedDeclFindingASTVisitor(const SourceManager &SourceMgr,
+  const std::string &Name)
+  : Result(nullptr), SourceMgr(SourceMgr),
+Name(Name) {
+  }
+
   // Declaration visitors:
 
   // \brief Checks if the point falls within the NameDecl. This covers every
@@ -93,9 +101,17 @@
   // \returns false on success.
   bool setResult(const NamedDecl *Decl, SourceLocation Start,
  SourceLocation End) {
-if (!Start.isValid() || !Start.isFileID() || !End.isValid() ||
-!End.isFileID() || !isPointWithin(Start, End)) {
-  return true;
+if (Name.empty()) {
+  // Offset is used to find the declaration.
+  if (!Start.isValid() || !Start.isFileID() || !End.isValid() ||
+  !End.isFileID() || !isPointWithin(Start, End)) {
+return true;
+  }
+} else {
+  // Fully qualified name is used to find the declaration.
+  if (Name != Decl->getQualifiedNameAsString()) {
+return true;
+  }
 }
 Result = Decl;
 return false;
@@ -121,6 +137,7 @@
   const NamedDecl *Result;
   const SourceManager &SourceMgr;
   const SourceLocation Point; // The location to find the NamedDecl.
+  const std::string Name;
 };
 }
 
@@ -148,6 +165,22 @@
   return nullptr;
 }
 
+const NamedDecl *getNamedDeclFor(const ASTContext &Context,
+

[PATCH] D21566: Widen EHScope::ClenupBitFields::FixupDepth to avoid overflowing it (PR23490)

2016-06-21 Thread Hans Wennborg via cfe-commits
hans created this revision.
hans added a reviewer: rjmccall.
hans added a subscriber: cfe-commits.

It currently only takes 2048 gotos to overflow the FixupDepth bitfield, causing 
silent miscompilation. Apparently some parser generators run into this (see PR).

I don't know that that data structure is terribly size sensitive anyway, and 
since there's no room to widen the bitfield, let's just use a separate word for 
it.

http://reviews.llvm.org/D21566

Files:
  lib/CodeGen/CGCleanup.h
  test/CodeGen/fixup-depth-overflow.c

Index: test/CodeGen/fixup-depth-overflow.c
===
--- /dev/null
+++ test/CodeGen/fixup-depth-overflow.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -O1 -disable-llvm-optzns -emit-llvm -o - %s | FileCheck %s
+
+#define M if (x) goto L1;
+#define M10 M M M M M M M M M M
+#define M100 M10 M10 M10 M10 M10 M10 M10 M10 M10 M10
+#define M1000 M100 M100 M100 M100 M100 M100 M100 M100 M100 M100
+
+void f(int x) {
+  int h;
+
+  // Many gotos to not-yet-emitted labels would cause EHScope's FixupDepth
+  // to overflow (PR23490).
+  M1000 M1000 M1000
+
+  if (x == 5) {
+// This will cause us to emit a clean-up of the stack variable. If the
+// FixupDepths are broken, fixups will erroneously get threaded through it.
+int i;
+  }
+
+L1:
+  return;
+}
+
+// CHECK-LABEL: define void @f
+// CHECK-NOT: cleanup
Index: lib/CodeGen/CGCleanup.h
===
--- lib/CodeGen/CGCleanup.h
+++ lib/CodeGen/CGCleanup.h
@@ -58,7 +58,7 @@
 friend class EHCatchScope;
 unsigned : NumCommonBits;
 
-unsigned NumHandlers : 32 - NumCommonBits;
+unsigned NumHandlers;
   };
 
   class CleanupBitFields {
@@ -90,14 +90,14 @@
 /// The number of fixups required by enclosing scopes (not including
 /// this one).  If this is the top cleanup scope, all the fixups
 /// from this index onwards belong to this scope.
-unsigned FixupDepth : 32 - 18 - NumCommonBits; // currently 12
+unsigned FixupDepth;
   };
 
   class FilterBitFields {
 friend class EHFilterScope;
 unsigned : NumCommonBits;
 
-unsigned NumFilters : 32 - NumCommonBits;
+unsigned NumFilters;
   };
 
   union {
@@ -188,6 +188,7 @@
EHScopeStack::stable_iterator enclosingEHScope)
 : EHScope(Catch, enclosingEHScope) {
 CatchBits.NumHandlers = numHandlers;
+assert(CatchBits.NumHandlers == numHandlers && "NumHandlers overflow?");
   }
 
   unsigned getNumHandlers() const {
@@ -300,6 +301,7 @@
 CleanupBits.FixupDepth = fixupDepth;
 
 assert(CleanupBits.CleanupSize == cleanupSize && "cleanup size overflow");
+assert(CleanupBits.FixupDepth == fixupDepth && "fixup depth overflow");
   }
 
   void Destroy() {
@@ -451,6 +453,7 @@
   EHFilterScope(unsigned numFilters)
 : EHScope(Filter, EHScopeStack::stable_end()) {
 FilterBits.NumFilters = numFilters;
+assert(FilterBits.NumFilters == numFilters && "NumFilters overflow");
   }
 
   static size_t getSizeForNumFilters(unsigned numFilters) {


Index: test/CodeGen/fixup-depth-overflow.c
===
--- /dev/null
+++ test/CodeGen/fixup-depth-overflow.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -O1 -disable-llvm-optzns -emit-llvm -o - %s | FileCheck %s
+
+#define M if (x) goto L1;
+#define M10 M M M M M M M M M M
+#define M100 M10 M10 M10 M10 M10 M10 M10 M10 M10 M10
+#define M1000 M100 M100 M100 M100 M100 M100 M100 M100 M100 M100
+
+void f(int x) {
+  int h;
+
+  // Many gotos to not-yet-emitted labels would cause EHScope's FixupDepth
+  // to overflow (PR23490).
+  M1000 M1000 M1000
+
+  if (x == 5) {
+// This will cause us to emit a clean-up of the stack variable. If the
+// FixupDepths are broken, fixups will erroneously get threaded through it.
+int i;
+  }
+
+L1:
+  return;
+}
+
+// CHECK-LABEL: define void @f
+// CHECK-NOT: cleanup
Index: lib/CodeGen/CGCleanup.h
===
--- lib/CodeGen/CGCleanup.h
+++ lib/CodeGen/CGCleanup.h
@@ -58,7 +58,7 @@
 friend class EHCatchScope;
 unsigned : NumCommonBits;
 
-unsigned NumHandlers : 32 - NumCommonBits;
+unsigned NumHandlers;
   };
 
   class CleanupBitFields {
@@ -90,14 +90,14 @@
 /// The number of fixups required by enclosing scopes (not including
 /// this one).  If this is the top cleanup scope, all the fixups
 /// from this index onwards belong to this scope.
-unsigned FixupDepth : 32 - 18 - NumCommonBits; // currently 12
+unsigned FixupDepth;
   };
 
   class FilterBitFields {
 friend class EHFilterScope;
 unsigned : NumCommonBits;
 
-unsigned NumFilters : 32 - NumCommonBits;
+unsigned NumFilters;
   };
 
   union {
@@ -188,6 +188,7 @@
EHScopeStack::stable_iterator enclosingEHScope)
 : EHScope(Catch, enclosingEHScope) {
 CatchBits.NumHandlers = numHandlers;
+assert(Cat

r273305 - Revert "[MS] Don't expect vftables to be provided for extern template instantiations"

2016-06-21 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Jun 21 14:51:52 2016
New Revision: 273305

URL: http://llvm.org/viewvc/llvm-project?rev=273305&view=rev
Log:
Revert "[MS] Don't expect vftables to be provided for extern template 
instantiations"

This reverts commit r273296, it broke the Windows self-host.

Modified:
cfe/trunk/lib/AST/VTableBuilder.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp

Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=273305&r1=273304&r2=273305&view=diff
==
--- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
+++ cfe/trunk/lib/AST/VTableBuilder.cpp Tue Jun 21 14:51:52 2016
@@ -2545,13 +2545,14 @@ public:
 MostDerivedClassLayout(Context.getASTRecordLayout(MostDerivedClass)),
 WhichVFPtr(*Which),
 Overriders(MostDerivedClass, CharUnits(), MostDerivedClass) {
-// Provide the RTTI component if RTTIData is enabled. If the vftable would
-// be available externally, we should not provide the RTTI componenent. It
-// is currently impossible to get available externally vftables with either
-// dllimport or extern template instantiations, but eventually we may add a
-// flag to support additional devirtualization that needs this.
+// Only include the RTTI component if we know that we will provide a
+// definition of the vftable.  We always provide the definition of
+// dllimported classes.
 if (Context.getLangOpts().RTTIData)
-  HasRTTIComponent = true;
+  if (MostDerivedClass->hasAttr() ||
+  MostDerivedClass->getTemplateSpecializationKind() !=
+  TSK_ExplicitInstantiationDeclaration)
+HasRTTIComponent = true;
 
 LayoutVFTable();
 

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=273305&r1=273304&r2=273305&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Tue Jun 21 14:51:52 2016
@@ -794,10 +794,6 @@ CodeGenModule::getVTableLinkage(const CX
   return DiscardableODRLinkage;
 
 case TSK_ExplicitInstantiationDeclaration:
-  // Explicit instantiations in MSVC do not provide vtables, so we must 
emit
-  // our own.
-  if (getTarget().getCXXABI().isMicrosoft())
-return DiscardableODRLinkage;
   return shouldEmitAvailableExternallyVTable(*this, RD)
  ? llvm::GlobalVariable::AvailableExternallyLinkage
  : llvm::GlobalVariable::ExternalLinkage;
@@ -843,9 +839,9 @@ CodeGenVTables::GenerateClassData(const
 bool CodeGenVTables::isVTableExternal(const CXXRecordDecl *RD) {
   assert(RD->isDynamicClass() && "Non-dynamic classes have no VTable.");
 
-  // We always synthesize vtables if they are needed in the MS ABI. MSVC 
doesn't
-  // emit them even if there is an explicit template instantiation.
-  if (CGM.getTarget().getCXXABI().isMicrosoft())
+  // We always synthesize vtables on the import side regardless of whether or
+  // not it is an explicit instantiation declaration.
+  if (CGM.getTarget().getCXXABI().isMicrosoft() && 
RD->hasAttr())
 return false;
 
   // If we have an explicit instantiation declaration (and not a

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp?rev=273305&r1=273304&r2=273305&view=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-vbtables.cpp Tue Jun 21 14:51:52 
2016
@@ -537,5 +537,5 @@ template  struct B : virtual A {
 
 extern template class B;
 template B::B();
-// CHECK-DAG: @"\01??_8?$B@H@Test30@@7B@" = linkonce_odr unnamed_addr constant 
[2 x i32] [i32 0, i32 4], comdat
+// CHECK-DAG: @"\01??_8?$B@H@Test30@@7B@" = external unnamed_addr constant [2 
x i32]{{$}}
 }

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp?rev=273305&r1=273304&r2=273305&view=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp Tue Jun 21 14:51:52 
2016
@@ -33,7 +33,7 @@ struct __declspec(dllexport) V {
 
 namespace {
 struct W {
-  virtual ~W() {}
+  virtual ~W();
 } w;
 }
 // RTTI-DAG: [[VTABLE_W:@.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast ({{.*}} @"\01??_R4W@?A@@6B@" to i8*), i8* bitcast ({{.*}} 
@"\01??_GW@?A@@UAEPAXI@Z" to i8*)]
@@ -49,7 +49,5 @@ template  s

Re: [PATCH] D20647: Add support for /Ob1 and -finline-hint-functions flags

2016-06-21 Thread Hans Wennborg via cfe-commits
hans accepted this revision.
hans added a comment.

In http://reviews.llvm.org/D20647#463590, @Ilod wrote:

> Fixed passing argument from clang driver to cc1.
>  Added driver tests.


lgtm, thanks!


http://reviews.llvm.org/D20647



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


[PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-06-21 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, bader, pxli168.
yaxunl added subscribers: cfe-commits, tstellarAMD.

Currently Clang use int32 to represent sampler_t, which have been a source of 
issue for some backends, because in some backends sampler_t cannot be 
represented by int32. They have to depend on kernel argument metadata and use 
IPA to find the sampler arguments and global variables and transform them to 
target specific sampler type.

This patch uses opaque struct pointer type __sampler* for sampler_t. For each 
sampler constant, it generates a global var of struct type 
__sampler_initializer.  It also generates a function call 
__translate_sampler_initializer for each reference of global vars of 
__sampler_initializer type. e.g.
 
  sampler_t s = ADDR | NORM | FILT;
 
  void f() {
g(s);
  }
 
 => Llvm bitcode equivalent to (assuming __sampler is the opaque struct type to 
represent sampler_t):
 
  // opaque struct type for sampler
  struct __sampler;
  // concrete sampler initializer struct type
  struct __sampler_initializer {
int addr;
int normalization;
int filter;
  };

  constant __sampler *__attribute__((always_inline)) 
__translate_sampler_initializer(struct __sampler_initializer); // a builtin 
function for translating sampler initializer
 
  constant struct __sampler_initializer _SI = {ADDR, NORM, FILT};
  void f() {
constant __sampler *_s = __translate_sampler_initializer(_SI);
g(_s);
  }

 Each builtin library can implement its own __initialize_sampler(). Since the 
real sampler type tends to be architecture dependent, allowing it to be 
initialized by a library function simplifies backend design. A typical 
implementation of __initialize_sampler could be a table lookup of real sampler 
literal values. Since its argument is always a literal, the returned pointer is 
known at compile time and easily optimized to finally become some literal 
values directly put into image read instructions.
 
The advantage of this representation is:

  # Robust - can be optimized without losing information
  # Easy to implement – can be implemented by library instead of pass

The implementation of the design is to introduce an internal sampler 
initializer type and translates each sampler variable to sampler initializer 
type in AST, and introduces cast from integer to sampler initializer and cast 
from sampler initializer to sampler. In codegen, sampler type is translated to 
opaque __sampler* type, sampler initializer type is translated to concrete 
__sampler_initializer type. The cast from sampler initializer to sampler is 
translated to function call __translate_sampler_initializer.

This patch is partly based on Alexey Sotkin's work in Khronos Clang 
(https://github.com/KhronosGroup/SPIR/commit/3d4eec61623502fc306e8c67c9868be2b136e42b).

http://reviews.llvm.org/D21567

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/OperationKinds.def
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Sema/Overload.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Index/USRGeneration.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaOverload.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/CodeGenOpenCL/sampler.cl
  test/SemaOpenCL/sampler_t.cl
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1466,6 +1466,7 @@
   case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
   case BuiltinType::OCLSampler:
+  case BuiltinType::OCLSamplerInit:
   case BuiltinType::OCLEvent:
   case BuiltinType::OCLClkEvent:
   case BuiltinType::OCLQueue:
Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -13,6 +13,7 @@
   const sampler_t const_smp = 7;
   foo(glb_smp);
   foo(const_smp);
+  foo(argsmp);
   foo(5); // expect

Re: [PATCH] D5896: Emit more intrinsics for builtin functions

2016-06-21 Thread Matt Arsenault via cfe-commits
arsenm updated this revision to Diff 61432.
arsenm added a comment.

Update for trunk


http://reviews.llvm.org/D5896

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtins.c

Index: test/CodeGen/builtins.c
===
--- test/CodeGen/builtins.c
+++ test/CodeGen/builtins.c
@@ -257,6 +257,98 @@
   // CHECK: call float @llvm.canonicalize.f32(float
   // CHECK: call double @llvm.canonicalize.f64(double
   // CHECK: call x86_fp80 @llvm.canonicalize.f80(x86_fp80
+
+  resf = __builtin_fminf(F, F);
+  // CHECK: call float @llvm.minnum.f32
+
+  resd = __builtin_fmin(D, D);
+  // CHECK: call double @llvm.minnum.f64
+
+  resld = __builtin_fminl(LD, LD);
+  // CHECK: call x86_fp80 @llvm.minnum.f80
+
+  resf = __builtin_fmaxf(F, F);
+  // CHECK: call float @llvm.maxnum.f32
+
+  resd = __builtin_fmax(D, D);
+  // CHECK: call double @llvm.maxnum.f64
+
+  resld = __builtin_fmaxl(LD, LD);
+  // CHECK: call x86_fp80 @llvm.maxnum.f80
+
+  resf = __builtin_fabsf(F);
+  // CHECK: call float @llvm.fabs.f32
+
+  resd = __builtin_fabs(D);
+  // CHECK: call double @llvm.fabs.f64
+
+  resld = __builtin_fabsl(LD);
+  // CHECK: call x86_fp80 @llvm.fabs.f80
+
+  resf = __builtin_copysignf(F, F);
+  // CHECK: call float @llvm.copysign.f32
+
+  resd = __builtin_copysign(D, D);
+  // CHECK: call double @llvm.copysign.f64
+
+  resld = __builtin_copysignl(LD, LD);
+  // CHECK: call x86_fp80 @llvm.copysign.f80
+
+
+  resf = __builtin_ceilf(F);
+  // CHECK: call float @llvm.ceil.f32
+
+  resd = __builtin_ceil(D);
+  // CHECK: call double @llvm.ceil.f64
+
+  resld = __builtin_ceill(LD);
+  // CHECK: call x86_fp80 @llvm.ceil.f80
+
+  resf = __builtin_floorf(F);
+  // CHECK: call float @llvm.floor.f32
+
+  resd = __builtin_floor(D);
+  // CHECK: call double @llvm.floor.f64
+
+  resld = __builtin_floorl(LD);
+  // CHECK: call x86_fp80 @llvm.floor.f80
+
+  resf = __builtin_truncf(F);
+  // CHECK: call float @llvm.trunc.f32
+
+  resd = __builtin_trunc(D);
+  // CHECK: call double @llvm.trunc.f64
+
+  resld = __builtin_truncl(LD);
+  // CHECK: call x86_fp80 @llvm.trunc.f80
+
+  resf = __builtin_rintf(F);
+  // CHECK: call float @llvm.rint.f32
+
+  resd = __builtin_rint(D);
+  // CHECK: call double @llvm.rint.f64
+
+  resld = __builtin_rintl(LD);
+  // CHECK: call x86_fp80 @llvm.rint.f80
+
+  resf = __builtin_nearbyintf(F);
+  // CHECK: call float @llvm.nearbyint.f32
+
+  resd = __builtin_nearbyint(D);
+  // CHECK: call double @llvm.nearbyint.f64
+
+  resld = __builtin_nearbyintl(LD);
+  // CHECK: call x86_fp80 @llvm.nearbyint.f80
+
+  resf = __builtin_roundf(F);
+  // CHECK: call float @llvm.round.f32
+
+  resd = __builtin_round(D);
+  // CHECK: call double @llvm.round.f64
+
+  resld = __builtin_roundl(LD);
+  // CHECK: call x86_fp80 @llvm.round.f80
+
 }
 
 // __builtin_longjmp isn't supported on all platforms, so only test it on X86.
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -217,6 +217,51 @@
ValueType);
 }
 
+// Emit a simple mangled intrinsic that has 1 argument and a return type
+// matching the argument type.
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF,
+   const CallExpr *E,
+   unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, Src0);
+}
+
+// Emit an intrinsic that has 2 operands of the same type as its result.
+static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
+const CallExpr *E,
+unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, { Src0, Src1 });
+}
+
+// Emit an intrinsic that has 3 operands of the same type as its result.
+static Value *emitTernaryBuiltin(CodeGenFunction &CGF,
+ const CallExpr *E,
+ unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+  llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 });
+}
+
+// Emit an intrinsic that has 1 float or double operand, and 1 integer.
+static Value *emitFPIntBuiltin(CodeGenFunction &CGF,
+   const CallExpr *E,
+   unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+
+  Value *F = CGF.CGM.

r273309 - Refactor scope building in JumpDiagnostics for simplicity. This fixes a

2016-06-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jun 21 15:10:11 2016
New Revision: 273309

URL: http://llvm.org/viewvc/llvm-project?rev=273309&view=rev
Log:
Refactor scope building in JumpDiagnostics for simplicity. This fixes a
(currently theoretical) bug where recursive calls to BuildScopeInformation
would do the wrong thing if the type of the statement is one of the kinds with
special handling, but this is not currently observable because the relevant
recursive calls happen to all be for CompoundStmts. (This becomes visible with
the C++17 'constexpr if' feature, where we get a protected scope for the 'then'
/ 'else' cases of some 'if's, and don't necessarily have a corresponding
compound statement.)

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

Modified: cfe/trunk/lib/Sema/JumpDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/JumpDiagnostics.cpp?rev=273309&r1=273308&r2=273309&view=diff
==
--- cfe/trunk/lib/Sema/JumpDiagnostics.cpp (original)
+++ cfe/trunk/lib/Sema/JumpDiagnostics.cpp Tue Jun 21 15:10:11 2016
@@ -270,7 +270,8 @@ void JumpScopeChecker::BuildScopeInforma
 /// coherent VLA scope with a specified parent node.  Walk through the
 /// statements, adding any labels or gotos to LabelAndGotoScopes and 
recursively
 /// walking the AST as needed.
-void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned 
&origParentScope) {
+void JumpScopeChecker::BuildScopeInformation(Stmt *S,
+ unsigned &origParentScope) {
   // If this is a statement, rather than an expression, scopes within it don't
   // propagate out into the enclosing scope.  Otherwise we have to worry
   // about block literals, which have the lifetime of their enclosing 
statement.
@@ -320,57 +321,186 @@ void JumpScopeChecker::BuildScopeInforma
 
   case Stmt::CXXTryStmtClass: {
 CXXTryStmt *TS = cast(S);
-unsigned newParentScope;
-Scopes.push_back(GotoScope(ParentScope,
-   diag::note_protected_by_cxx_try,
-   diag::note_exits_cxx_try,
-   TS->getSourceRange().getBegin()));
-if (Stmt *TryBlock = TS->getTryBlock())
-  BuildScopeInformation(TryBlock, (newParentScope = Scopes.size()-1));
+{
+  unsigned NewParentScope = Scopes.size();
+  Scopes.push_back(GotoScope(ParentScope,
+ diag::note_protected_by_cxx_try,
+ diag::note_exits_cxx_try,
+ TS->getSourceRange().getBegin()));
+  if (Stmt *TryBlock = TS->getTryBlock())
+BuildScopeInformation(TryBlock, NewParentScope);
+}
 
 // Jump from the catch into the try is not allowed either.
 for (unsigned I = 0, E = TS->getNumHandlers(); I != E; ++I) {
   CXXCatchStmt *CS = TS->getHandler(I);
+  unsigned NewParentScope = Scopes.size();
   Scopes.push_back(GotoScope(ParentScope,
  diag::note_protected_by_cxx_catch,
  diag::note_exits_cxx_catch,
  CS->getSourceRange().getBegin()));
-  BuildScopeInformation(CS->getHandlerBlock(),
-(newParentScope = Scopes.size()-1));
+  BuildScopeInformation(CS->getHandlerBlock(), NewParentScope);
 }
 return;
   }
 
   case Stmt::SEHTryStmtClass: {
 SEHTryStmt *TS = cast(S);
-unsigned newParentScope;
-Scopes.push_back(GotoScope(ParentScope,
-   diag::note_protected_by_seh_try,
-   diag::note_exits_seh_try,
-   TS->getSourceRange().getBegin()));
-if (Stmt *TryBlock = TS->getTryBlock())
-  BuildScopeInformation(TryBlock, (newParentScope = Scopes.size()-1));
+{
+  unsigned NewParentScope = Scopes.size();
+  Scopes.push_back(GotoScope(ParentScope,
+ diag::note_protected_by_seh_try,
+ diag::note_exits_seh_try,
+ TS->getSourceRange().getBegin()));
+  if (Stmt *TryBlock = TS->getTryBlock())
+BuildScopeInformation(TryBlock, NewParentScope);
+}
 
 // Jump from __except or __finally into the __try are not allowed either.
 if (SEHExceptStmt *Except = TS->getExceptHandler()) {
+  unsigned NewParentScope = Scopes.size();
   Scopes.push_back(GotoScope(ParentScope,
  diag::note_protected_by_seh_except,
  diag::note_exits_seh_except,
  Except->getSourceRange().getBegin()));
-  BuildScopeInformation(Except->getBlock(),
-(newParentScope = Scopes.size()-1));
+  BuildScopeInformation(Except->getBlock(), NewParentScope);
 } else if (SEHFinallyStmt *Finally = TS->getFinallyHandler()) {
+  unsigned New

Re: [PATCH] D21243: Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.

2016-06-21 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273310: Fix clang-tidy patterns to adapt to newly added 
ExprWithCleanups nodes. (authored by timshen).

Changed prior to commit:
  http://reviews.llvm.org/D21243?vs=60992&id=61434#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21243

Files:
  clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
@@ -156,7 +156,7 @@
 const Expr *digThroughConstructors(const Expr *E) {
   if (!E)
 return nullptr;
-  E = E->IgnoreParenImpCasts();
+  E = E->IgnoreImplicit();
   if (const auto *ConstructExpr = dyn_cast(E)) {
 // The initial constructor must take exactly one parameter, but base class
 // and deferred constructors can take more.
Index: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "LoopConvertCheck.h"
+#include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
@@ -141,10 +142,10 @@
   StatementMatcher IteratorComparisonMatcher = expr(
   ignoringParenImpCasts(declRefExpr(to(varDecl().bind(ConditionVarName);
 
-  StatementMatcher OverloadedNEQMatcher =
+  auto OverloadedNEQMatcher = matchers::ignoringImplicit(
   cxxOperatorCallExpr(hasOverloadedOperatorName("!="), argumentCountIs(2),
   hasArgument(0, IteratorComparisonMatcher),
-  hasArgument(1, IteratorBoundMatcher));
+  hasArgument(1, IteratorBoundMatcher)));
 
   // This matcher tests that a declaration is a CXXRecordDecl that has an
   // overloaded operator*(). If the operator*() returns by value instead of by
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
@@ -42,6 +42,8 @@
   if (!Init)
 return false;
 
+  Init = Init->IgnoreImplicit();
+
   // The following test is based on DeclPrinter::VisitVarDecl() to find if an
   // initializer is implicit or not.
   if (const auto *Construct = dyn_cast(Init)) {
Index: clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
@@ -8,11 +8,13 @@
 //===--===//
 
 #include "DanglingHandleCheck.h"
+#include "../utils/Matchers.h"
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
 using namespace clang::ast_matchers;
+using namespace clang::tidy::matchers;
 
 namespace clang {
 namespace tidy {
@@ -135,7 +137,7 @@
   //   1. Value to Handle conversion.
   //   2. Handle copy construction.
   // We have to match both.
-  has(ignoringParenImpCasts(handleFrom(
+  has(ignoringImplicit(handleFrom(
   IsAHandle,
   handleFrom(IsAHandle, declRefExpr(to(varDecl(
 // Is function scope ...
Index: clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -39,21 +39,21 @@
  stringLiteral(hasSize(0);
 
   const auto EmptyStringCtorExprWithTemporaries =
-  expr(ignoringImplicit(
-  cxxConstructExpr(StringConstructorExpr,
-  hasArgument(0, ignoringImplicit(EmptyStringCtorExpr);
+  cxxConstructExpr(StringConstructorExpr,
+   hasArgument(0, ignoringImplicit(EmptyStringCtorExpr)));
 
   // Match a variable declaration with an empty string literal as in

[clang-tools-extra] r273310 - Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.

2016-06-21 Thread Tim Shen via cfe-commits
Author: timshen
Date: Tue Jun 21 15:11:20 2016
New Revision: 273310

URL: http://llvm.org/viewvc/llvm-project?rev=273310&view=rev
Log:
Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.

Summary: This is a fix for the new ExprWithCleanups introduced by clang's 
temporary variable lifetime marks change.

Reviewers: bkramer, sbenza, angelgarcia, alexth

Subscribers: rsmith, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp?rev=273310&r1=273309&r2=273310&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp Tue Jun 21 
15:11:20 2016
@@ -33,7 +33,8 @@ void TwineLocalCheck::check(const MatchF
   if (VD->hasInit()) {
 // Peel away implicit constructors and casts so we can see the actual type
 // of the initializer.
-const Expr *C = VD->getInit();
+const Expr *C = VD->getInit()->IgnoreImplicit();
+
 while (isa(C))
   C = cast(C)->getArg(0)->IgnoreParenImpCasts();
 

Modified: clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp?rev=273310&r1=273309&r2=273310&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp Tue Jun 21 
15:11:20 2016
@@ -8,11 +8,13 @@
 
//===--===//
 
 #include "DanglingHandleCheck.h"
+#include "../utils/Matchers.h"
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
 using namespace clang::ast_matchers;
+using namespace clang::tidy::matchers;
 
 namespace clang {
 namespace tidy {
@@ -135,7 +137,7 @@ void DanglingHandleCheck::registerMatche
   //   1. Value to Handle conversion.
   //   2. Handle copy construction.
   // We have to match both.
-  has(ignoringParenImpCasts(handleFrom(
+  has(ignoringImplicit(handleFrom(
   IsAHandle,
   handleFrom(IsAHandle, declRefExpr(to(varDecl(
 // Is function scope ...

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=273310&r1=273309&r2=273310&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Tue Jun 
21 15:11:20 2016
@@ -8,6 +8,7 @@
 
//===--===//
 
 #include "LoopConvertCheck.h"
+#include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
@@ -141,10 +142,10 @@ StatementMatcher makeIteratorLoopMatcher
   StatementMatcher IteratorComparisonMatcher = expr(
   
ignoringParenImpCasts(declRefExpr(to(varDecl().bind(ConditionVarName);
 
-  StatementMatcher OverloadedNEQMatcher =
+  auto OverloadedNEQMatcher = matchers::ignoringImplicit(
   cxxOperatorCallExpr(hasOverloadedOperatorName("!="), argumentCountIs(2),
   hasArgument(0, IteratorComparisonMatcher),
-  hasArgument(1, IteratorBoundMatcher));
+  hasArgument(1, IteratorBoundMatcher)));
 
   // This matcher tests that a declaration is a CXXRecordDecl that has an
   // overloaded operator*(). If the operator*() returns by value instead of by

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp?rev=273310&r1=273309&r2=273310&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp Tue Jun 
21 15:11:20 2016
@@ -156,7 +156,7 @

Re: [PATCH] D20498: [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr

2016-06-21 Thread Tim Shen via cfe-commits
timshen added a comment.

http://reviews.llvm.org/D21243 is committed. Let's do this again.


Repository:
  rL LLVM

http://reviews.llvm.org/D20498



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


r273311 - [x86] AVX FP compare builtins should require AVX target feature (PR28112)

2016-06-21 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Tue Jun 21 15:22:55 2016
New Revision: 273311

URL: http://llvm.org/viewvc/llvm-project?rev=273311&view=rev
Log:
[x86] AVX FP compare builtins should require AVX target feature (PR28112)

This is a fix for PR28112:
https://llvm.org/bugs/show_bug.cgi?id=28112

The FP comparison intrinsics that take an immediate parameter (rather than 
specifying
a comparison predicate in the function name) were added with AVX; these are 
macros in
avxintrin.h. This patch makes clang behavior match gcc (error if a program 
tries to use 
these without -mavx) and matches the Intel documentation, eg:
VCMPPS: m128 _mm_cmp_ps(m128 a, __m128 b, const int imm)

'V' means this is intended to only work with the AVX form of the instruction.

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/test/CodeGen/target-features-error-2.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=273311&r1=273310&r2=273311&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Jun 21 15:22:55 2016
@@ -219,7 +219,6 @@ TARGET_BUILTIN(__builtin_ia32_ucomisdgt,
 TARGET_BUILTIN(__builtin_ia32_ucomisdge, "iV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_ucomisdneq, "iV2dV2d", "", "sse2")
 
-TARGET_BUILTIN(__builtin_ia32_cmpps, "V4fV4fV4fIc", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpeqps, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpltps, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpleps, "V4fV4fV4f", "", "sse")
@@ -228,7 +227,6 @@ TARGET_BUILTIN(__builtin_ia32_cmpneqps,
 TARGET_BUILTIN(__builtin_ia32_cmpnltps, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpnleps, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpordps, "V4fV4fV4f", "", "sse")
-TARGET_BUILTIN(__builtin_ia32_cmpss, "V4fV4fV4fIc", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpeqss, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpltss, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpless, "V4fV4fV4f", "", "sse")
@@ -242,7 +240,6 @@ TARGET_BUILTIN(__builtin_ia32_maxps, "V4
 TARGET_BUILTIN(__builtin_ia32_minss, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_maxss, "V4fV4fV4f", "", "sse")
 
-TARGET_BUILTIN(__builtin_ia32_cmppd, "V2dV2dV2dIc", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpeqpd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpltpd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmplepd, "V2dV2dV2d", "", "sse2")
@@ -251,7 +248,6 @@ TARGET_BUILTIN(__builtin_ia32_cmpneqpd,
 TARGET_BUILTIN(__builtin_ia32_cmpnltpd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpnlepd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpordpd, "V2dV2dV2d", "", "sse2")
-TARGET_BUILTIN(__builtin_ia32_cmpsd, "V2dV2dV2dIc", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpeqsd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpltsd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmplesd, "V2dV2dV2d", "", "sse2")
@@ -453,8 +449,12 @@ TARGET_BUILTIN(__builtin_ia32_vpermilvar
 TARGET_BUILTIN(__builtin_ia32_blendvpd256, "V4dV4dV4dV4d", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_blendvps256, "V8fV8fV8fV8f", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_dpps256, "V8fV8fV8fIc", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_cmppd, "V2dV2dV2dIc", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cmppd256, "V4dV4dV4dIc", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_cmpps, "V4fV4fV4fIc", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cmpps256, "V8fV8fV8fIc", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_cmpsd, "V2dV2dV2dIc", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_cmpss, "V4fV4fV4fIc", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtdq2ps256, "V8fV8i", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtpd2ps256, "V4fV4d", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtps2dq256, "V8iV8f", "", "avx")

Modified: cfe/trunk/test/CodeGen/target-features-error-2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-features-error-2.c?rev=273311&r1=273310&r2=273311&view=diff
==
--- cfe/trunk/test/CodeGen/target-features-error-2.c (original)
+++ cfe/trunk/test/CodeGen/target-features-error-2.c Tue Jun 21 15:22:55 2016
@@ -1,7 +1,38 @@
-// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o -
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_SSE42
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_1
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_2
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_3
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_4
+
 #define __MM_MALL

Re: [PATCH] D21306: [x86] AVX FP compare builtins should require AVX target feature (PR28112)

2016-06-21 Thread Sanjay Patel via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273311: [x86] AVX FP compare builtins should require AVX 
target feature (PR28112) (authored by spatel).

Changed prior to commit:
  http://reviews.llvm.org/D21306?vs=60596&id=61437#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21306

Files:
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/test/CodeGen/target-features-error-2.c

Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -219,16 +219,14 @@
 TARGET_BUILTIN(__builtin_ia32_ucomisdge, "iV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_ucomisdneq, "iV2dV2d", "", "sse2")
 
-TARGET_BUILTIN(__builtin_ia32_cmpps, "V4fV4fV4fIc", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpeqps, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpltps, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpleps, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpunordps, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpneqps, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpnltps, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpnleps, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpordps, "V4fV4fV4f", "", "sse")
-TARGET_BUILTIN(__builtin_ia32_cmpss, "V4fV4fV4fIc", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpeqss, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpltss, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cmpless, "V4fV4fV4f", "", "sse")
@@ -242,16 +240,14 @@
 TARGET_BUILTIN(__builtin_ia32_minss, "V4fV4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_maxss, "V4fV4fV4f", "", "sse")
 
-TARGET_BUILTIN(__builtin_ia32_cmppd, "V2dV2dV2dIc", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpeqpd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpltpd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmplepd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpunordpd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpneqpd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpnltpd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpnlepd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpordpd, "V2dV2dV2d", "", "sse2")
-TARGET_BUILTIN(__builtin_ia32_cmpsd, "V2dV2dV2dIc", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpeqsd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmpltsd, "V2dV2dV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cmplesd, "V2dV2dV2d", "", "sse2")
@@ -453,8 +449,12 @@
 TARGET_BUILTIN(__builtin_ia32_blendvpd256, "V4dV4dV4dV4d", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_blendvps256, "V8fV8fV8fV8f", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_dpps256, "V8fV8fV8fIc", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_cmppd, "V2dV2dV2dIc", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cmppd256, "V4dV4dV4dIc", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_cmpps, "V4fV4fV4fIc", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cmpps256, "V8fV8fV8fIc", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_cmpsd, "V2dV2dV2dIc", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_cmpss, "V4fV4fV4fIc", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtdq2ps256, "V8fV8i", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtpd2ps256, "V4fV4d", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtps2dq256, "V8iV8f", "", "avx")
Index: cfe/trunk/test/CodeGen/target-features-error-2.c
===
--- cfe/trunk/test/CodeGen/target-features-error-2.c
+++ cfe/trunk/test/CodeGen/target-features-error-2.c
@@ -1,7 +1,38 @@
-// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o -
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_SSE42
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_1
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_2
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_3
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_4
+
 #define __MM_MALLOC_H
 #include 
 
+#if NEED_SSE42
 int baz(__m256i a) {
   return _mm256_extract_epi32(a, 3); // expected-error {{always_inline 
function '_mm256_extract_epi32' requires target feature 'sse4.2', but would be 
inlined into function 'baz' that is compiled without support for 'sse4.2'}}
 }
+#endif
+
+#if NEED_AVX_1
+__m128 need_avx(__m128 a, __m128 b) {
+  return _mm_cmp_ps(a, b, 0); // expected-error {{'__builtin_ia32_cmpps' needs 
target feature avx}}
+}
+#endif
+
+#if NEED_AVX_2
+__m128 need_avx(__m128 a, __m128 b) {
+  return _mm_cmp_ss(a, b, 0); // expected-error {{'__builtin_ia32_cmpss' needs 
target feature avx}}
+}
+#endif
+
+#if NEED_AVX_3
+__m128d need_avx(__m128d a, __m128d b) {
+  return _mm_cmp_pd(a, b, 0); // expected-error {{'__builtin_ia32_cmppd' needs 
target feature avx}}
+}
+#endi

Re: [PATCH] D21241: Add an ASTMatcher for ignoring ExprWithCleanups.

2016-06-21 Thread Tim Shen via cfe-commits
timshen abandoned this revision.
timshen added a comment.

> I was wondering why we didn't created that Matcher: IgnoreImplicit


Actually you are right. There already exists a IgnoreImplict in clang-tidy and 
I just switched to that.

Abandoning this patch.

Thanks!


http://reviews.llvm.org/D21241



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


r273312 - Re-commit "[Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr."

2016-06-21 Thread Tim Shen via cfe-commits
Author: timshen
Date: Tue Jun 21 15:29:17 2016
New Revision: 273312

URL: http://llvm.org/viewvc/llvm-project?rev=273312&view=rev
Log:
Re-commit "[Temporary] Add an ExprWithCleanups for each C++ 
MaterializeTemporaryExpr."

Since D21243 fixes relative clang-tidy tests.

This reverts commit a71d9fbd41e99def9159af2b01ef6509394eaeed.

Added:
cfe/trunk/include/clang/Sema/CleanupInfo.h
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Analysis/Consumed.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaCoroutine.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=273312&r1=273311&r2=273312&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Tue Jun 21 15:29:17 2016
@@ -2872,7 +2872,8 @@ private:
   Stmt *SubExpr;
 
   ExprWithCleanups(EmptyShell, unsigned NumObjects);
-  ExprWithCleanups(Expr *SubExpr, ArrayRef Objects);
+  ExprWithCleanups(Expr *SubExpr, bool CleanupsHaveSideEffects,
+   ArrayRef Objects);
 
   friend TrailingObjects;
   friend class ASTStmtReader;
@@ -2882,6 +2883,7 @@ public:
   unsigned numObjects);
 
   static ExprWithCleanups *Create(const ASTContext &C, Expr *subexpr,
+  bool CleanupsHaveSideEffects,
   ArrayRef objects);
 
   ArrayRef getObjects() const {
@@ -2898,6 +2900,9 @@ public:
 
   Expr *getSubExpr() { return cast(SubExpr); }
   const Expr *getSubExpr() const { return cast(SubExpr); }
+  bool cleanupsHaveSideEffects() const {
+return ExprWithCleanupsBits.CleanupsHaveSideEffects;
+  }
 
   /// As with any mutator of the AST, be very careful
   /// when modifying an existing AST to preserve its invariants.

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=273312&r1=273311&r2=273312&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Tue Jun 21 15:29:17 2016
@@ -192,7 +192,10 @@ protected:
 
 unsigned : NumExprBits;
 
-unsigned NumObjects : 32 - NumExprBits;
+// When false, it must not have side effects.
+bool CleanupsHaveSideEffects : 1;
+
+unsigned NumObjects : 32 - 1 - NumExprBits;
   };
 
   class PseudoObjectExprBitfields {

Added: cfe/trunk/include/clang/Sema/CleanupInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CleanupInfo.h?rev=273312&view=auto
==
--- cfe/trunk/include/clang/Sema/CleanupInfo.h (added)
+++ cfe/trunk/include/clang/Sema/CleanupInfo.h Tue Jun 21 15:29:17 2016
@@ -0,0 +1,47 @@
+//===--- CleanupInfo.cpp - Cleanup Control in Sema 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file implements a set of operations on whether generating an
+//  ExprWithCleanups in a full expression.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_SEMA_CLEANUP_INFO_H
+#define LLVM_CLANG_SEMA_CLEANUP_INFO_H
+
+namespace clang {
+
+class CleanupInfo {
+  bool ExprNeedsCleanups = false;
+  bool CleanupsHaveSideEffects = false;
+
+public:
+  bool exprNeedsCleanups() const { return ExprNeedsCleanups; }
+
+  bool cleanupsHaveSideEffects() const { return CleanupsHaveSideEffects; }
+
+  void setExprNeedsCleanups(bool SideEffects) {
+ExprNeedsCleanups = true;
+CleanupsHaveSideEffects |= SideEffects;
+  }
+
+  void reset() {
+ExprNeedsCleanups = false;
+CleanupsHaveSideEffects = false;
+  }
+
+  void mergeFrom(CleanupInfo Rhs) {
+ExprNeedsCleanups |= Rhs.ExprNeedsCleanups;
+CleanupsHaveSideEffects |= Rhs.CleanupsHaveSideEffects;
+  }
+};
+
+} // end nam

[clang-tools-extra] r273314 - Fix build of ClangRenameTests

2016-06-21 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Tue Jun 21 15:30:40 2016
New Revision: 273314

URL: http://llvm.org/viewvc/llvm-project?rev=273314&view=rev
Log:
Fix build of ClangRenameTests

Adapt the test to the code change introduced in r273304.

Modified:
clang-tools-extra/trunk/unittests/clang-rename/USRLocFindingTest.cpp

Modified: clang-tools-extra/trunk/unittests/clang-rename/USRLocFindingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-rename/USRLocFindingTest.cpp?rev=273314&r1=273313&r2=273314&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-rename/USRLocFindingTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/clang-rename/USRLocFindingTest.cpp Tue 
Jun 21 15:30:40 2016
@@ -23,7 +23,7 @@ static void testOffsetGroups(const char
 // useful.
 std::string USR;
 for (const auto &Offset : Group) {
-  USRFindingAction Action(Offset);
+  USRFindingAction Action(Offset, std::string());
   auto Factory = tooling::newFrontendActionFactory(&Action);
   EXPECT_TRUE(tooling::runToolOnCode(Factory->create(), Code));
   const auto &USRs = Action.getUSRs();


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


Re: [PATCH] D20498: [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr

2016-06-21 Thread Tim Shen via cfe-commits
timshen added a comment.

Committed as r273312.


Repository:
  rL LLVM

http://reviews.llvm.org/D20498



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-21 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

Thank you Samuel, that it is valuable review!
I wanted to add the functionality of specifing stuff by options later.

should we revert this patch? It seems that those bugs are not so critical (at 
least on llvm http://reviews.llvm.org/D21507).
Anyway, I will fix it in one week.


Repository:
  rL LLVM

http://reviews.llvm.org/D20964



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


Re: r273290 - Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Mike Aizatsky via cfe-commits
I think this change has buffer overflow. It breaks asan build:

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/13946

FAIL: Clang-Unit ::
Tooling/ToolingTests/Range.RangesWithNonOverlappingReplacements (9361
of 9474)
 TEST 'Clang-Unit ::
Tooling/ToolingTests/Range.RangesWithNonOverlappingReplacements'
FAILED 
Note: Google Test filter = Range.RangesWithNonOverlappingReplacements
[==] Running 1 test from 1 test case.
[--] Global test environment set-up.
[--] 1 test from Range
[ RUN  ] Range.RangesWithNonOverlappingReplacements
=
==32475==ERROR: AddressSanitizer: global-buffer-overflow on address
0x078a4b02 at pc 0x00540095 bp 0x7ffcd9799a10 sp
0x7ffcd97991c0
READ of size 5 at 0x078a4b02 thread T0
#0 0x540094 in __asan_memcpy
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:393
#1 0x7f6e902e6dc1 in copy
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/libcxx/include/string:655:50
#2 0x7f6e902e6dc1 in std::__1::basic_string, std::__1::allocator >::__init(char
const*, unsigned long)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/libcxx/include/string:2054
#3 0x30b45e3 in basic_string
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/string:2086:5
#4 0x30b45e3 in
clang::tooling::calculateRangesAfterReplacements(std::__1::set,
std::__1::allocator > const&,
std::__1::vector > const&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Tooling/Core/Replacement.cpp:325
#5 0xaa1a6c in
clang::tooling::Range_RangesWithNonOverlappingReplacements_Test::TestBody()
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/unittests/Tooling/RefactoringTest.cpp:503:3
#6 0x241400a in HandleExceptionsInMethodIfSupported 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2145:12
#7 0x241400a in testing::Test::Run()
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2161
#8 0x2415426 in testing::TestInfo::Run()
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2309:5
#9 0x241636a in testing::TestCase::Run()
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2416:5
#10 0x242c6fc in testing::internal::UnitTestImpl::RunAllTests()
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4207:11
#11 0x242b808 in
HandleExceptionsInMethodIfSupported 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2145:12
#12 0x242b808 in testing::UnitTest::Run()
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:3841
#13 0x24000dd in main
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:48:10
#14 0x7f6e8fcdcf44 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
#15 0x4aeb02 in _start
(/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_asan/tools/clang/unittests/Tooling/ToolingTests+0x4aeb02)

0x078a4b02 is located 62 bytes to the left of global variable
'' defined in
'/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/ADT/SmallVector.h:150:5'
(0x78a4b40) of size 13
  '' is ascii string 'idx < size()'
0x078a4b02 is located 0 bytes to the right of global variable
'' defined in
'/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Tooling/Core/Replacement.cpp:325:49'
(0x78a4b00) of size 2
  '' is ascii string ' '
SUMMARY: AddressSanitizer: global-buffer-overflow
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:393
in __asan_memcpy
Shadow bytes around the buggy address:
  0x80f0c910: 00 00 00 00 00 00 00 00 00 07 f9 f9 f9 f9 f9 f9
  0x80f0c920: 00 00 00 00 00 00 00 00 01 f9 f9 f9 f9 f9 f9 f9
  0x80f0c930: 03 f9 f9 f9 f9 f9 f9 f9 03 f9 f9 f9 f9 f9 f9 f9
  0x80f0c940: 03 f9 f9 f9 f9 f9 f9 f9 02 f9 f9 f9 f9 f9 f9 f9
  0x80f0c950: 00 f9 f9 f9 f9 f9 f9 f9 01 f9 f9 f9 f9 f9 f9 f9
=>0x80f0c960:[02]f9 f9 f9 f9 f9 f9 f9 00 05 f9 f9 f9 f9 f9 f9
  0x80f0c970: 00 00 00 00 00 00 00 00 00 00 00 00 01 f9 f9 f9
  0x80f0c980: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
  0x80f0c990: 00 00 00 00 00 04 f9 f9 f9 f9 f9 f9 00 00 00 00
0x80f0c9a0: 00 02 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x80f0c9b0: 00 00 00 00 00 00 02 f9 f9 f9 f9 f9 00 00 00 00
Shadow byte legend (one shadow byte represents 8 

Re: r273290 - Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Eric Liu via cfe-commits
Thanks Mike! I am working on a fix.

On Tue, Jun 21, 2016 at 10:44 PM Mike Aizatsky  wrote:

> I think this change has buffer overflow. It breaks asan build:
>
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/13946
>
> FAIL: Clang-Unit :: 
> Tooling/ToolingTests/Range.RangesWithNonOverlappingReplacements (9361 of 9474)
>  TEST 'Clang-Unit :: 
> Tooling/ToolingTests/Range.RangesWithNonOverlappingReplacements' FAILED 
> 
> Note: Google Test filter = Range.RangesWithNonOverlappingReplacements
> [==] Running 1 test from 1 test case.
> [--] Global test environment set-up.
> [--] 1 test from Range
> [ RUN  ] Range.RangesWithNonOverlappingReplacements
> =
> ==32475==ERROR: AddressSanitizer: global-buffer-overflow on address 
> 0x078a4b02 at pc 0x00540095 bp 0x7ffcd9799a10 sp 0x7ffcd97991c0
> READ of size 5 at 0x078a4b02 thread T0
> #0 0x540094 in __asan_memcpy 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:393
> #1 0x7f6e902e6dc1 in copy 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/libcxx/include/string:655:50
> #2 0x7f6e902e6dc1 in std::__1::basic_string std::__1::char_traits, std::__1::allocator >::__init(char const*, 
> unsigned long) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/libcxx/include/string:2054
> #3 0x30b45e3 in basic_string 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/string:2086:5
> #4 0x30b45e3 in 
> clang::tooling::calculateRangesAfterReplacements(std::__1::set  std::__1::less, 
> std::__1::allocator > const&, 
> std::__1::vector std::__1::allocator > const&) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Tooling/Core/Replacement.cpp:325
> #5 0xaa1a6c in 
> clang::tooling::Range_RangesWithNonOverlappingReplacements_Test::TestBody() 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/unittests/Tooling/RefactoringTest.cpp:503:3
> #6 0x241400a in HandleExceptionsInMethodIfSupported 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2145:12
> #7 0x241400a in testing::Test::Run() 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2161
> #8 0x2415426 in testing::TestInfo::Run() 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2309:5
> #9 0x241636a in testing::TestCase::Run() 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2416:5
> #10 0x242c6fc in testing::internal::UnitTestImpl::RunAllTests() 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4207:11
> #11 0x242b808 in 
> HandleExceptionsInMethodIfSupported 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2145:12
> #12 0x242b808 in testing::UnitTest::Run() 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:3841
> #13 0x24000dd in main 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:48:10
> #14 0x7f6e8fcdcf44 in __libc_start_main 
> (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
> #15 0x4aeb02 in _start 
> (/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_asan/tools/clang/unittests/Tooling/ToolingTests+0x4aeb02)
>
> 0x078a4b02 is located 62 bytes to the left of global variable ' literal>' defined in 
> '/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/ADT/SmallVector.h:150:5'
>  (0x78a4b40) of size 13
>   '' is ascii string 'idx < size()'
> 0x078a4b02 is located 0 bytes to the right of global variable ' literal>' defined in 
> '/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Tooling/Core/Replacement.cpp:325:49'
>  (0x78a4b00) of size 2
>   '' is ascii string ' '
> SUMMARY: AddressSanitizer: global-buffer-overflow 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:393
>  in __asan_memcpy
> Shadow bytes around the buggy address:
>   0x80f0c910: 00 00 00 00 00 00 00 00 00 07 f9 f9 f9 f9 f9 f9
>   0x80f0c920: 00 00 00 00 00 00 00 00 01 f9 f9 f9 f9 f9 f9 f9
>   0x80f0c930: 03 f9 f9 f9 f9 f9 f9 f9 03 f9 f9 f9 f9 f9 f9 f9
>   0x80f0c940: 03 f9 f9 f9 f9 f9 f9 f9 02 f9 f9 f9 f9 f9 f9 f9
>   0x80f0c950: 00 f9 f9 f9 f9 f9 f9 f9 01 f9 f9 f9 f9 f9 f9 f9
> =>0x80f0c960:[02]f9 f9 f9 f9 f9 f9 f9 00 05 f9 f9 f9 f9 f9 f9
>   0x80f0c970: 00 00 00 00

r273319 - Trying to fix a buffer overflow that broke buildbot sanitizer-x86_64-linux-fast/builds/13946.

2016-06-21 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Jun 21 15:49:50 2016
New Revision: 273319

URL: http://llvm.org/viewvc/llvm-project?rev=273319&view=rev
Log:
Trying to fix a buffer overflow that broke buildbot 
sanitizer-x86_64-linux-fast/builds/13946.

Modified:
cfe/trunk/lib/Tooling/Core/Replacement.cpp

Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=273319&r1=273318&r2=273319&view=diff
==
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Tue Jun 21 15:49:50 2016
@@ -322,7 +322,7 @@ calculateRangesAfterReplacements(const R
   for (const auto &R : MergedRanges)
 FakeReplaces.insert(Replacement(Replaces.begin()->getFilePath(),
 R.getOffset(), R.getLength(),
-std::string(" ", R.getLength(;
+std::string(R.getLength(), ' ')));
   tooling::Replacements NewReplaces = mergeReplacements(FakeReplaces, 
Replaces);
   return calculateChangedRanges(NewReplaces);
 }


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


Re: r273290 - Added calculateRangesAfterReplaments() to calculate affacted ranges in the new code.

2016-06-21 Thread Eric Liu via cfe-commits
Sent a patch trying to fix this. http://reviews.llvm.org/rL273319

On Tue, Jun 21, 2016 at 10:52 PM Eric Liu  wrote:

> Thanks Mike! I am working on a fix.
>
> On Tue, Jun 21, 2016 at 10:44 PM Mike Aizatsky 
> wrote:
>
>> I think this change has buffer overflow. It breaks asan build:
>>
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/13946
>>
>> FAIL: Clang-Unit :: 
>> Tooling/ToolingTests/Range.RangesWithNonOverlappingReplacements (9361 of 
>> 9474)
>>  TEST 'Clang-Unit :: 
>> Tooling/ToolingTests/Range.RangesWithNonOverlappingReplacements' FAILED 
>> 
>> Note: Google Test filter = Range.RangesWithNonOverlappingReplacements
>> [==] Running 1 test from 1 test case.
>> [--] Global test environment set-up.
>> [--] 1 test from Range
>> [ RUN  ] Range.RangesWithNonOverlappingReplacements
>> =
>> ==32475==ERROR: AddressSanitizer: global-buffer-overflow on address 
>> 0x078a4b02 at pc 0x00540095 bp 0x7ffcd9799a10 sp 0x7ffcd97991c0
>> READ of size 5 at 0x078a4b02 thread T0
>> #0 0x540094 in __asan_memcpy 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:393
>> #1 0x7f6e902e6dc1 in copy 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/libcxx/include/string:655:50
>> #2 0x7f6e902e6dc1 in std::__1::basic_string> std::__1::char_traits, std::__1::allocator >::__init(char 
>> const*, unsigned long) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/libcxx/include/string:2054
>> #3 0x30b45e3 in basic_string 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/string:2086:5
>> #4 0x30b45e3 in 
>> clang::tooling::calculateRangesAfterReplacements(std::__1::set>  std::__1::less, 
>> std::__1::allocator > const&, 
>> std::__1::vector> std::__1::allocator > const&) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Tooling/Core/Replacement.cpp:325
>> #5 0xaa1a6c in 
>> clang::tooling::Range_RangesWithNonOverlappingReplacements_Test::TestBody() 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/unittests/Tooling/RefactoringTest.cpp:503:3
>> #6 0x241400a in HandleExceptionsInMethodIfSupported 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2145:12
>> #7 0x241400a in testing::Test::Run() 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2161
>> #8 0x2415426 in testing::TestInfo::Run() 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2309:5
>> #9 0x241636a in testing::TestCase::Run() 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2416:5
>> #10 0x242c6fc in testing::internal::UnitTestImpl::RunAllTests() 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4207:11
>> #11 0x242b808 in 
>> HandleExceptionsInMethodIfSupported 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2145:12
>> #12 0x242b808 in testing::UnitTest::Run() 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:3841
>> #13 0x24000dd in main 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:48:10
>> #14 0x7f6e8fcdcf44 in __libc_start_main 
>> (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
>> #15 0x4aeb02 in _start 
>> (/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_asan/tools/clang/unittests/Tooling/ToolingTests+0x4aeb02)
>>
>> 0x078a4b02 is located 62 bytes to the left of global variable '> literal>' defined in 
>> '/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/ADT/SmallVector.h:150:5'
>>  (0x78a4b40) of size 13
>>   '' is ascii string 'idx < size()'
>> 0x078a4b02 is located 0 bytes to the right of global variable '> literal>' defined in 
>> '/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Tooling/Core/Replacement.cpp:325:49'
>>  (0x78a4b00) of size 2
>>   '' is ascii string ' '
>> SUMMARY: AddressSanitizer: global-buffer-overflow 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:393
>>  in __asan_memcpy
>> Shadow bytes around the buggy address:
>>   0x80f0c910: 00 00 00 00 00 00 00 00 00 07 f9 f9 f9 f9 f9 f9
>>   0x80f0c920: 00 00 00 00 00 00 00 00 01 f9 f9 f9 f9 f9 f9 f9
>>   0x80f0c930: 03 f9 f9 f9 f9 f9 f9 f9 03 f9 f9 f9 f9 f9 f9 f9
>>   0x80f0c940: 03 f9 f

Re: [PATCH] D20811: [analyzer] Model some library functions

2016-06-21 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Thanks for the patch! Here are the comments, most of which are nits.

Could you add the high level description of what we are doing somewhere or 
maybe just describe the meaning of FunctionSpec since it encodes how functions 
are modeled.

Also, we should explain why we are not using BodyFarm somewhere in the comment.



Comment at: lib/StaticAnalyzer/Checkers/LibraryFunctionsChecker.cpp:10
@@ +9,3 @@
+//
+// This checker improves modeling of a few simple library functions.
+// It does not throw warnings.

Please, list the functions.


Comment at: lib/StaticAnalyzer/Checkers/LibraryFunctionsChecker.cpp:27
@@ +26,3 @@
+  static const uint32_t Ret = std::numeric_limits::max();
+  enum ValueRangeKindTy { Outside, Inside, ComparesToArgument };
+  enum InvalidationKindTy { Normal, Pure };

Naming looks odd: maybe "OutOfRange" and "WithinRange"?


Comment at: lib/StaticAnalyzer/Checkers/LibraryFunctionsChecker.cpp:33
@@ +32,3 @@
+  private:
+// ArgNo in CallExpr and CallEvent is defined is Unsigned, but
+// obviously uint32_t should be enough for most practical purposes.

nit: "is Unsigned" -> "as Unsigned"
Please, use a typedef for the type as you are using it below in getArgType.


Comment at: lib/StaticAnalyzer/Checkers/LibraryFunctionsChecker.cpp:83
@@ +82,3 @@
+  static QualType getArgType(const FunctionSpec &Spec, uint32_t ArgNo) {
+return ArgNo == Ret ? Spec.RetType : Spec.ArgTypes[ArgNo];
+  }

Are the types in FunctionSpec already canonical? If so, please, add a comment.


Comment at: lib/StaticAnalyzer/Checkers/LibraryFunctionsChecker.cpp:178
@@ +177,3 @@
+if (auto N = V.getAs()) {
+  const IntRangeVector &R = VR.getRanges();
+  size_t E = R.size();

nit: If you could factor these out into separate helper functions, it would be 
easier to read. Lot's of nesting..


Comment at: lib/StaticAnalyzer/Checkers/LibraryFunctionsChecker.cpp:219
@@ +218,3 @@
+
+if (NewState)
+  C.addTransition(NewState);

What happens when NewState == State? I guess addTransition would just not do 
anything, but maybe we should just make the intent explicit and not call it at 
all.


Comment at: lib/StaticAnalyzer/Checkers/LibraryFunctionsChecker.cpp:245
@@ +244,3 @@
+  }
+  case Normal:
+return false;

Replace "Normal" with a more descriptive name.


Comment at: lib/StaticAnalyzer/Checkers/LibraryFunctionsChecker.cpp:273
@@ +272,3 @@
+
+  // Verify that function signature matches the spec in advance,
+  // so that we didn't have to roll back if anything goes wrong.

Looks like you might want to have the checking code as a member on FunctionSpec.


Comment at: lib/StaticAnalyzer/Checkers/LibraryFunctionsChecker.cpp:322
@@ +321,3 @@
+
+  // NOTE: The signature needs to have the correct number of arguments.
+  // NOTE: However, insert Irrelevant when the type is insignificant.

Let's explain what we are doing next. For example, "Let's initialize the 
FunctionSpec for the functions we are modeling."

Remove "NOTE:"


Comment at: lib/StaticAnalyzer/Checkers/LibraryFunctionsChecker.cpp:326
@@ +325,3 @@
+  //   is completely unknown, omit it from the respective range set.
+  // NOTE: Upon comparing to another argument, the other argument is casted
+  //   to the current argument's type. This avoids proper promotion but

not clear where this is used or if it is used in the initialization at all.


Comment at: lib/StaticAnalyzer/Checkers/LibraryFunctionsChecker.cpp:337
@@ +336,3 @@
+  //  { ranges list:
+  //{ argument index, inside or outside, {{from, to}, ...} },
+  //{ argument index, compares to argument, {{how, which}} },

Is every item in the range set used to bifurcate the state?


http://reviews.llvm.org/D20811



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


Re: [PATCH] D20709: For RenderScript, set alignment and width of long to 64-bits

2016-06-21 Thread Pirama Arumuga Nainar via cfe-commits
pirama abandoned this revision.
pirama added a comment.

Abandoning this revision.  Patches for an alternative approach are listed above.


http://reviews.llvm.org/D20709



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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-06-21 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 61443.
yaxunl added a comment.

Add test deleted by accident.


http://reviews.llvm.org/D21567

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/OperationKinds.def
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Sema/Overload.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Index/USRGeneration.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaOverload.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/CodeGenOpenCL/sampler.cl
  test/SemaOpenCL/sampler_t.cl
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1466,6 +1466,7 @@
   case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
   case BuiltinType::OCLSampler:
+  case BuiltinType::OCLSamplerInit:
   case BuiltinType::OCLEvent:
   case BuiltinType::OCLClkEvent:
   case BuiltinType::OCLQueue:
Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -13,6 +13,7 @@
   const sampler_t const_smp = 7;
   foo(glb_smp);
   foo(const_smp);
+  foo(argsmp);
   foo(5); // expected-error {{sampler_t variable required - got 'int'}}
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
 }
Index: test/CodeGenOpenCL/sampler.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/sampler.cl
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -O0 -cl-sampler-type i32 | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -O0 | FileCheck -check-prefix CHECK-SAMPLER-TYPE %s
+
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+// CHECK: @glb_smp = global i32 35
+
+// CHECK-SAMPLER-TYPE: %__sampler_initializer = type { i32, i32, i32 }
+// CHECK-SAMPLER-TYPE: %__sampler = type opaque
+// CHECK-SAMPLER-TYPE: [[glb_smp_init:@[-a-zA-Z$._][-a-zA-Z$._0-9]*]] = internal addrspace(2) constant %__sampler_initializer { i32 1, i32 1, i32 1 }
+// CHECK-SAMPLER-TYPE: @glb_smp = global %__sampler_initializer addrspace(2)* [[glb_smp_init]]
+// CHECK-SAMPLER-TYPE: [[smp_init:@[-a-zA-Z$._][-a-zA-Z$._0-9]*]] = internal addrspace(2) constant %__sampler_initializer { i32 1, i32 1, i32 0 }
+
+void fnc4smp(sampler_t s) {}
+// CHECK: define spir_func void @fnc4smp(i32
+// CHECK-SAMPLER-TYPE: define spir_func void @fnc4smp(%__sampler addrspace(2)* %
+
+kernel void foo() {
+  sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST;
+  // CHECK-LABEL: define spir_kernel void @foo()
+  // CHECK: alloca i32
+  // CHECK-SAMPLER-TYPE-LABEL: define spir_kernel void @foo()
+  // CHECK-SAMPLER-TYPE: [[smp_ptr:%[A-Za-z0-9_\.]+]] = alloca %__sampler_initializer addrspace(2)*
+  // CHECK-SAMPLER-TYPE: store %__sampler_initializer addrspace(2)* [[smp_init]], %__sampler_initializer addrspace(2)** [[smp_ptr]]
+
+  fnc4smp(smp);
+  // CHECK: store i32 19,
+  // CHECK: call spir_func void @fnc4smp(i32
+  // CHECK-SAMPLER-TYPE: [[SINIT:%[0-9]+]] = load %__sampler_initializer addrspace(2)*, %__sampler_initializer addrspace(2)** [[smp_ptr]]
+  // CHECK-SAMPLER-TYPE: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* @__translate_sampler_initializer(%__sampler_initializer addrspace(2)* [[SINIT]])
+  // CHECK-SAMPLER-TYPE: call spir_func void @fnc4smp(%__sampler addrspace(2)* [[SAMP]])
+
+  fnc4smp(glb_smp);
+  // CHECK: call spir_func void @fnc4smp(i32
+  // CHECK-SAMPLER-TYPE: [[SINIT:%[0-9]+]] = load %__sampler_initializer addrspace(2)*, %__sampler_initializer addrspace(2)** @glb_smp
+  //

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

2016-06-21 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added a comment.

Ping.


http://reviews.llvm.org/D19322



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


Re: r273312 - Re-commit "[Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr."

2016-06-21 Thread Rafael Espíndola via cfe-commits
I think this broke the build on windows:

 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/7421/steps/build/logs/stdio

Cheers,
Rafael


On 21 June 2016 at 16:29, Tim Shen via cfe-commits
 wrote:
> Author: timshen
> Date: Tue Jun 21 15:29:17 2016
> New Revision: 273312
>
> URL: http://llvm.org/viewvc/llvm-project?rev=273312&view=rev
> Log:
> Re-commit "[Temporary] Add an ExprWithCleanups for each C++ 
> MaterializeTemporaryExpr."
>
> Since D21243 fixes relative clang-tidy tests.
>
> This reverts commit a71d9fbd41e99def9159af2b01ef6509394eaeed.
>
> Added:
> cfe/trunk/include/clang/Sema/CleanupInfo.h
> Modified:
> cfe/trunk/include/clang/AST/ExprCXX.h
> cfe/trunk/include/clang/AST/Stmt.h
> cfe/trunk/include/clang/Sema/ScopeInfo.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/AST/Expr.cpp
> cfe/trunk/lib/AST/ExprCXX.cpp
> cfe/trunk/lib/Analysis/Consumed.cpp
> cfe/trunk/lib/CodeGen/CGExprConstant.cpp
> cfe/trunk/lib/Sema/Sema.cpp
> cfe/trunk/lib/Sema/SemaCast.cpp
> cfe/trunk/lib/Sema/SemaCoroutine.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
> cfe/trunk/lib/Sema/SemaExprObjC.cpp
> cfe/trunk/lib/Sema/SemaInit.cpp
> cfe/trunk/lib/Sema/SemaLambda.cpp
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/lib/Sema/SemaStmt.cpp
> cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
> cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
> cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
>
> Modified: cfe/trunk/include/clang/AST/ExprCXX.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=273312&r1=273311&r2=273312&view=diff
> ==
> --- cfe/trunk/include/clang/AST/ExprCXX.h (original)
> +++ cfe/trunk/include/clang/AST/ExprCXX.h Tue Jun 21 15:29:17 2016
> @@ -2872,7 +2872,8 @@ private:
>Stmt *SubExpr;
>
>ExprWithCleanups(EmptyShell, unsigned NumObjects);
> -  ExprWithCleanups(Expr *SubExpr, ArrayRef Objects);
> +  ExprWithCleanups(Expr *SubExpr, bool CleanupsHaveSideEffects,
> +   ArrayRef Objects);
>
>friend TrailingObjects;
>friend class ASTStmtReader;
> @@ -2882,6 +2883,7 @@ public:
>unsigned numObjects);
>
>static ExprWithCleanups *Create(const ASTContext &C, Expr *subexpr,
> +  bool CleanupsHaveSideEffects,
>ArrayRef objects);
>
>ArrayRef getObjects() const {
> @@ -2898,6 +2900,9 @@ public:
>
>Expr *getSubExpr() { return cast(SubExpr); }
>const Expr *getSubExpr() const { return cast(SubExpr); }
> +  bool cleanupsHaveSideEffects() const {
> +return ExprWithCleanupsBits.CleanupsHaveSideEffects;
> +  }
>
>/// As with any mutator of the AST, be very careful
>/// when modifying an existing AST to preserve its invariants.
>
> Modified: cfe/trunk/include/clang/AST/Stmt.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=273312&r1=273311&r2=273312&view=diff
> ==
> --- cfe/trunk/include/clang/AST/Stmt.h (original)
> +++ cfe/trunk/include/clang/AST/Stmt.h Tue Jun 21 15:29:17 2016
> @@ -192,7 +192,10 @@ protected:
>
>  unsigned : NumExprBits;
>
> -unsigned NumObjects : 32 - NumExprBits;
> +// When false, it must not have side effects.
> +bool CleanupsHaveSideEffects : 1;
> +
> +unsigned NumObjects : 32 - 1 - NumExprBits;
>};
>
>class PseudoObjectExprBitfields {
>
> Added: cfe/trunk/include/clang/Sema/CleanupInfo.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CleanupInfo.h?rev=273312&view=auto
> ==
> --- cfe/trunk/include/clang/Sema/CleanupInfo.h (added)
> +++ cfe/trunk/include/clang/Sema/CleanupInfo.h Tue Jun 21 15:29:17 2016
> @@ -0,0 +1,47 @@
> +//===--- CleanupInfo.cpp - Cleanup Control in Sema 
> ===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
> +//===--===//
> +//
> +//  This file implements a set of operations on whether generating an
> +//  ExprWithCleanups in a full expression.
> +//
> +//===--===//
> +
> +#ifndef LLVM_CLANG_SEMA_CLEANUP_INFO_H
> +#define LLVM_CLANG_SEMA_CLEANUP_INFO_H
> +
> +namespace clang {
> +
> +class CleanupInfo {
> +  bool ExprNeedsCleanups = false;
> +  bool CleanupsHaveSideEffects = false;
> +
> +public:
> +  bool exprNeedsCleanups() const { return ExprNeedsCleanups; }
> +
> +  boo

r273321 - Emit the DWARF tag for the RenderScript language

2016-06-21 Thread Pirama Arumuga Nainar via cfe-commits
Author: pirama
Date: Tue Jun 21 16:35:11 2016
New Revision: 273321

URL: http://llvm.org/viewvc/llvm-project?rev=273321&view=rev
Log:
Emit the DWARF tag for the RenderScript language

Summary:
If the RenderScript LangOpt is set, either via '-x renderscript' or the '.rs'
file extension, set the DWARF language tag to be that of RenderScript.

Reviewers: rsmith

Subscribers: cfe-commits, srhines

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

Added:
cfe/trunk/test/CodeGen/debug-info-renderscript-tag.rs
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=273321&r1=273320&r2=273321&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Jun 21 16:35:11 2016
@@ -377,6 +377,8 @@ void CGDebugInfo::CreateCompileUnit() {
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
   } else if (LO.ObjC1) {
 LangTag = llvm::dwarf::DW_LANG_ObjC;
+  } else if (LO.RenderScript) {
+LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript;
   } else if (LO.C99) {
 LangTag = llvm::dwarf::DW_LANG_C99;
   } else {

Added: cfe/trunk/test/CodeGen/debug-info-renderscript-tag.rs
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-renderscript-tag.rs?rev=273321&view=auto
==
--- cfe/trunk/test/CodeGen/debug-info-renderscript-tag.rs (added)
+++ cfe/trunk/test/CodeGen/debug-info-renderscript-tag.rs Tue Jun 21 16:35:11 
2016
@@ -0,0 +1,3 @@
+// RUN: %clang -emit-llvm -S -g %s -o - | FileCheck %s
+
+// CHECK: !DICompileUnit(language: DW_LANG_GOOGLE_RenderScript{{.*}})


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


Re: [PATCH] D21451: Emit the DWARF tag for the RenderScript language

2016-06-21 Thread Pirama Arumuga Nainar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273321: Emit the DWARF tag for the RenderScript language 
(authored by pirama).

Changed prior to commit:
  http://reviews.llvm.org/D21451?vs=61038&id=61452#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21451

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/test/CodeGen/debug-info-renderscript-tag.rs

Index: cfe/trunk/test/CodeGen/debug-info-renderscript-tag.rs
===
--- cfe/trunk/test/CodeGen/debug-info-renderscript-tag.rs
+++ cfe/trunk/test/CodeGen/debug-info-renderscript-tag.rs
@@ -0,0 +1,3 @@
+// RUN: %clang -emit-llvm -S -g %s -o - | FileCheck %s
+
+// CHECK: !DICompileUnit(language: DW_LANG_GOOGLE_RenderScript{{.*}})
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -377,6 +377,8 @@
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
   } else if (LO.ObjC1) {
 LangTag = llvm::dwarf::DW_LANG_ObjC;
+  } else if (LO.RenderScript) {
+LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript;
   } else if (LO.C99) {
 LangTag = llvm::dwarf::DW_LANG_C99;
   } else {


Index: cfe/trunk/test/CodeGen/debug-info-renderscript-tag.rs
===
--- cfe/trunk/test/CodeGen/debug-info-renderscript-tag.rs
+++ cfe/trunk/test/CodeGen/debug-info-renderscript-tag.rs
@@ -0,0 +1,3 @@
+// RUN: %clang -emit-llvm -S -g %s -o - | FileCheck %s
+
+// CHECK: !DICompileUnit(language: DW_LANG_GOOGLE_RenderScript{{.*}})
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -377,6 +377,8 @@
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
   } else if (LO.ObjC1) {
 LangTag = llvm::dwarf::DW_LANG_ObjC;
+  } else if (LO.RenderScript) {
+LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript;
   } else if (LO.C99) {
 LangTag = llvm::dwarf::DW_LANG_C99;
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r273323 - Allow the libc++ build/source paths to contain symlinks.

2016-06-21 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jun 21 16:54:23 2016
New Revision: 273323

URL: http://llvm.org/viewvc/llvm-project?rev=273323&view=rev
Log:
Allow the libc++ build/source paths to contain symlinks.

The filesystem tests were expecting the paths to the build/source directories
did not contain any symlinks. This patch resolves those symlinks before running
the test suite.


Modified:
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/support/filesystem_test_helper.hpp

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=273323&r1=273322&r2=273323&view=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Tue Jun 21 16:54:23 2016
@@ -439,11 +439,13 @@ class Configuration(object):
 self.config.available_features.add('c++filesystem')
 static_env = os.path.join(self.libcxx_src_root, 'test', 'std',
   'experimental', 'filesystem', 'Inputs', 
'static_test_env')
+static_env = os.path.realpath(static_env)
 assert os.path.isdir(static_env)
 self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="%s"' 
% static_env]
 
 dynamic_env = os.path.join(self.libcxx_obj_root, 'test',
'filesystem', 'Output', 'dynamic_env')
+dynamic_env = os.path.realpath(dynamic_env)
 if not os.path.isdir(dynamic_env):
 os.makedirs(dynamic_env)
 self.cxx.compile_flags += 
['-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="%s"' % dynamic_env]

Modified: libcxx/trunk/test/support/filesystem_test_helper.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/filesystem_test_helper.hpp?rev=273323&r1=273322&r2=273323&view=diff
==
--- libcxx/trunk/test/support/filesystem_test_helper.hpp (original)
+++ libcxx/trunk/test/support/filesystem_test_helper.hpp Tue Jun 21 16:54:23 
2016
@@ -20,6 +20,7 @@ namespace fs = std::experimental::filesy
 namespace StaticEnv {
 
 inline fs::path makePath(fs::path const& p) {
+// env_path is expected not to contain symlinks.
 static const fs::path env_path = LIBCXX_FILESYSTEM_STATIC_TEST_ROOT;
 return env_path / p;
 }
@@ -236,6 +237,7 @@ private:
 }
 
 static bool checkDynamicTestRoot() {
+// LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT is expected not to contain 
symlinks.
 char* fs_root = std::getenv("LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT");
 if (!fs_root) {
 std::printf("ERROR: LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT must be a 
defined "


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


Re: [libcxx] r273034 - Add Filesystem TS -- Complete

2016-06-21 Thread Eric Fiselier via cfe-commits
The issue should be fixed in r273323.

Thanks for the report and for your patience.

/Eric

On Mon, Jun 20, 2016 at 11:27 PM, Eric Fiselier  wrote:

> Hi Artem,
>
> Sorry for the delay, I've been busy with school all day.
> I'll check in a fix tomorrow morning.
>
> Sorry again,
>
> /Eric
>
> On Mon, Jun 20, 2016 at 2:31 PM, Eric Fiselier  wrote:
>
>> Oh shoot, I definitely didn't take that into account. I'll put together a
>> fix.
>>
>> /Eric
>>
>>
>>
>> On Mon, Jun 20, 2016 at 2:27 PM, Artem Belevich  wrote:
>>
>>> Eric,
>>>
>>> Some tests appear to fail if the path to the tests' current directory
>>> has some symlinks in it.
>>> In my case source and build tree are in directory 'work' that's
>>> symlinked to from my home directory:
>>> /usr/local/home/tra/work -> /work/tra
>>>
>>> This causes multiple failures in libcxx tests. One example:
>>>
>>>
>>> projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.rename/rename.pass.cpp:121
>>> 121TEST_CHECK(read_symlink(bad_sym_dest) == dne);
>>>
>>> dne:
>>>
>>> /usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/dne
>>> bad_sym_dest:
>>>
>>> /usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/bad_sym2
>>>
>>> These are the paths that traverse the 'work' symlink in my home
>>> directory. However, the symlink that we're reading contains physical path
>>> to the directory. While it does link to the right place, it's not the path
>>> the test expects.
>>>
>>> #readlink
>>> /usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/bad_sym2
>>>
>>> /work/tra/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/dne
>>>
>>> I think we need to normalize paths before we compare them.
>>>
>>> --Artem
>>>
>>>
>>> On Sat, Jun 18, 2016 at 12:03 PM, Eric Fiselier via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 > I assume the correct way to fix this is to disable
 -Wcovered-switch-default while compiling libcxx/src/experimental/
 filesystem/operations.cpp

 Agreed. Disabled in r273092.

 Thanks for your patience with this latest change,

 /Eric

 On Sat, Jun 18, 2016 at 12:54 PM, Adrian Prantl 
 wrote:

> Hello Eric,
>
> this commit causes new warnings on our bots:
>
> clang/src/projects/libcxx/include/fstream:816:5: warning: default
> label in switch which covers all enumeration values
> [-Wcovered-switch-default]
> default:
>
> The problem is with this defensive default statement in fstream:
>
>
>  template 
> 0792 typename basic_filebuf<_CharT, _Traits>::pos_type
> 0793 basic_filebuf<_CharT, _Traits>::seekoff(off_type __off,
> ios_base::seekdir __way,
> 0794 ios_base::openmode)
> 0795 {
> 0796 #ifndef _LIBCPP_NO_EXCEPTIONS
> 0797 if (!__cv_)
> 0798 throw bad_cast();
> 0799 #endif
> 0800 int __width = __cv_->encoding();
> 0801 if (__file_ == 0 || (__width <= 0 && __off != 0) || sync())
> 0802 return pos_type(off_type(-1));
> 0803 // __width > 0 || __off == 0
> 0804 int __whence;
> 0805 switch (__way)
> 0806 {
> 0807 case ios_base::beg:
> 0808 __whence = SEEK_SET;
> 0809 break;
> 0810 case ios_base::cur:
> 0811 __whence = SEEK_CUR;
> 0812 break;
> 0813 case ios_base::end:
> 0814 __whence = SEEK_END;
> 0815 break;
> 0816 default:
> 0817 return pos_type(off_type(-1));
> 0818 }
>
>
> I assume the correct way to fix this is to disable
> -Wcovered-switch-default while compiling
> libcxx/src/experimental/filesystem/operations.cpp
>
> Could you please investigate?
>
> thanks,
> Adrian



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


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


Re: [PATCH] D21229: [Analyzer] Don't cache report generation ExplodedNodes

2016-06-21 Thread Anna Zaks via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

LGTM. Please, measure that this does not regress memory consumption just to be 
sure.

Thanks!
Anna.


http://reviews.llvm.org/D21229



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


[libcxx] r273325 - Implement LWG issue 2725. The issue should move this meeting

2016-06-21 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jun 21 17:11:16 2016
New Revision: 273325

URL: http://llvm.org/viewvc/llvm-project?rev=273325&view=rev
Log:
Implement LWG issue 2725. The issue should move this meeting

Modified:
libcxx/trunk/include/experimental/filesystem

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=273325&r1=273324&r2=273325&view=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Tue Jun 21 17:11:16 2016
@@ -1393,7 +1393,9 @@ bool exists(const path& __p) {
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool exists(const path& __p, error_code& __ec) _NOEXCEPT {
-return exists(__status(__p, &__ec));
+auto __s = __status(__p, &__ec);
+if (status_known(__s)) __ec.clear();
+return exists(__s);
 }
 
 inline _LIBCPP_INLINE_VISIBILITY

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp?rev=273325&r1=273324&r2=273325&view=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp
 Tue Jun 21 17:11:16 2016
@@ -65,6 +65,10 @@ TEST_CASE(test_exist_not_found)
 {
 const path p = StaticEnv::DNE;
 TEST_CHECK(exists(p) == false);
+
+std::error_code ec = GetTestEC();
+TEST_CHECK(exists(p, ec) == false);
+TEST_CHECK(!ec);
 }
 
 TEST_CASE(test_exists_fails)


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


r273327 - Delete dead code.

2016-06-21 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Tue Jun 21 17:24:45 2016
New Revision: 273327

URL: http://llvm.org/viewvc/llvm-project?rev=273327&view=rev
Log:
Delete dead code.

Found by gcc 6.

Modified:
cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp

Modified: cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp?rev=273327&r1=273326&r2=273327&view=diff
==
--- cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp Tue Jun 21 17:24:45 
2016
@@ -366,7 +366,6 @@ namespace {
 Stmt *RewriteContinueStmt(ContinueStmt *S);
 void RewriteCastExpr(CStyleCastExpr *CE);
 void RewriteImplicitCastObjCExpr(CastExpr *IE);
-void RewriteLinkageSpec(LinkageSpecDecl *LSD);
 
 // Computes ivar bitfield group no.
 unsigned ObjCIvarBitfieldGroupNo(ObjCIvarDecl *IV);
@@ -447,9 +446,6 @@ namespace {
 std::string &Result);
 void RewriteObjCProtocolMetaData(ObjCProtocolDecl *Protocol,
  std::string &Result);
-void RewriteObjCProtocolListMetaData(
-   const ObjCList &Prots,
-   StringRef prefix, StringRef ClassName, std::string &Result);
 void RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
   std::string &Result);
 void RewriteClassSetupInitHook(std::string &Result);
@@ -522,7 +518,6 @@ namespace {
 QualType getSuperStructType();
 QualType getConstantStringStructType();
 QualType convertFunctionTypeOfBlocks(const FunctionType *FT);
-bool BufferContainsPPDirectives(const char *startBuf, const char *endBuf);
 
 void convertToUnqualifiedObjCType(QualType &T) {
   if (T->isObjCQualifiedIdType()) {
@@ -742,10 +737,6 @@ void RewriteModernObjC::HandleTopLevelSi
 if (PD->isThisDeclarationADefinition())
   RewriteProtocolDecl(PD);
   } else if (LinkageSpecDecl *LSD = dyn_cast(D)) {
-// FIXME. This will not work in all situations and leaving it out
-// is harmless.
-// RewriteLinkageSpec(LSD);
-
 // Recurse into linkage specifications
 for (DeclContext::decl_iterator DI = LSD->decls_begin(),
  DIEnd = LSD->decls_end();
@@ -1210,22 +1201,6 @@ RewriteModernObjC::RewriteForwardProtoco
   ReplaceText(LocStart, 0, "// ");
 }
 
-void 
-RewriteModernObjC::RewriteLinkageSpec(LinkageSpecDecl *LSD) {
-  SourceLocation LocStart = LSD->getExternLoc();
-  if (LocStart.isInvalid())
-llvm_unreachable("Invalid extern SourceLocation");
-  
-  ReplaceText(LocStart, 0, "// ");
-  if (!LSD->hasBraces())
-return;
-  // FIXME. We don't rewrite well if '{' is not on same line as 'extern'.
-  SourceLocation LocRBrace = LSD->getRBraceLoc();
-  if (LocRBrace.isInvalid())
-llvm_unreachable("Invalid rbrace SourceLocation");
-  ReplaceText(LocRBrace, 0, "// ");
-}
-
 void RewriteModernObjC::RewriteTypeIntoString(QualType T, std::string 
&ResultStr,
 const FunctionType *&FPRetType) {
   if (T->isObjCQualifiedIdType())
@@ -3629,32 +3604,6 @@ Stmt *RewriteModernObjC::RewriteObjCProt
   return castExpr;
 }
 
-bool RewriteModernObjC::BufferContainsPPDirectives(const char *startBuf,
- const char *endBuf) {
-  while (startBuf < endBuf) {
-if (*startBuf == '#') {
-  // Skip whitespace.
-  for (++startBuf; startBuf[0] == ' ' || startBuf[0] == '\t'; ++startBuf)
-;
-  if (!strncmp(startBuf, "if", strlen("if")) ||
-  !strncmp(startBuf, "ifdef", strlen("ifdef")) ||
-  !strncmp(startBuf, "ifndef", strlen("ifndef")) ||
-  !strncmp(startBuf, "define", strlen("define")) ||
-  !strncmp(startBuf, "undef", strlen("undef")) ||
-  !strncmp(startBuf, "else", strlen("else")) ||
-  !strncmp(startBuf, "elif", strlen("elif")) ||
-  !strncmp(startBuf, "endif", strlen("endif")) ||
-  !strncmp(startBuf, "pragma", strlen("pragma")) ||
-  !strncmp(startBuf, "include", strlen("include")) ||
-  !strncmp(startBuf, "import", strlen("import")) ||
-  !strncmp(startBuf, "include_next", strlen("include_next")))
-return true;
-}
-startBuf++;
-  }
-  return false;
-}
-
 /// IsTagDefinedInsideClass - This routine checks that a named tagged type 
 /// is defined inside an objective-c class. If so, it returns true. 
 bool RewriteModernObjC::IsTagDefinedInsideClass(ObjCContainerDecl *IDecl, 
@@ -7048,51 +6997,6 @@ void RewriteModernObjC::RewriteObjCProto
 llvm_unreachable("protocol already synthesized");
 }
 
-void RewriteModernObjC::RewriteObjCProtocolListMetaData(
-const ObjCList &Protocols,
-StringRef prefix, StringRef ClassNa

[libcxx] r273328 - Implement LWG issue 2720. Replace perms::resolve_symlinks with perms::symlink_nofollow.

2016-06-21 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jun 21 17:42:42 2016
New Revision: 273328

URL: http://llvm.org/viewvc/llvm-project?rev=273328&view=rev
Log:
Implement LWG issue 2720. Replace perms::resolve_symlinks with 
perms::symlink_nofollow.

This changes how filesystem::permissions(p, perms) handles symlinks. Previously
symlinks were not resolved by default instead only getting resolved when
"perms::resolve_symlinks" was used. After this change symlinks are resolved
by default and perms::symlink_nofollow must be given to change this.

This issue has not yet been moved to Ready status, and I will revert if it
doesn't get moved at the current meeting. However I feel confident that it
will and it's nice to have implementations when moving issues.

Modified:
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/src/experimental/filesystem/operations.cpp
libcxx/trunk/test/std/experimental/filesystem/fs.enum/enum.perms.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.permissions/permissions.pass.cpp

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=273328&r1=273327&r2=273328&view=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Tue Jun 21 17:42:42 2016
@@ -292,7 +292,7 @@ enum class _LIBCPP_TYPE_VIS perms : unsi
 
 add_perms= 0x1,
 remove_perms = 0x2,
-resolve_symlinks = 0x4
+symlink_nofollow = 0x4
 };
 
 _LIBCPP_INLINE_VISIBILITY

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=273328&r1=273327&r2=273328&view=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Tue Jun 21 17:42:42 
2016
@@ -594,7 +594,7 @@ void __last_write_time(const path& p, fi
 void __permissions(const path& p, perms prms, std::error_code *ec)
 {
 
-const bool resolve_symlinks = bool(perms::resolve_symlinks & prms);
+const bool resolve_symlinks = !bool(perms::symlink_nofollow & prms);
 const bool add_perms = bool(perms::add_perms & prms);
 const bool remove_perms = bool(perms::remove_perms & prms);
 
@@ -605,6 +605,8 @@ void __permissions(const path& p, perms
 file_status st = detail::posix_lstat(p, &m_ec);
 if (m_ec) return set_or_throw(m_ec, ec, "permissions", p);
 
+// AT_SYMLINK_NOFOLLOW can only be used on symlinks, using it on a regular
+// file will cause fchmodat to report an error on some systems.
 const bool set_sym_perms = is_symlink(st) && !resolve_symlinks;
 
 if ((resolve_symlinks && is_symlink(st)) && (add_perms || remove_perms)) {
@@ -622,14 +624,16 @@ void __permissions(const path& p, perms
 # if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_FDCWD)
 const int flags = set_sym_perms ? AT_SYMLINK_NOFOLLOW : 0;
 if (::fchmodat(AT_FDCWD, p.c_str(), real_perms, flags) == -1) {
+return set_or_throw(ec, "permissions", p);
+}
 # else
 if (set_sym_perms)
 return set_or_throw(make_error_code(errc::operation_not_supported),
 ec, "permissions", p);
 if (::chmod(p.c_str(), real_perms) == -1) {
-# endif
 return set_or_throw(ec, "permissions", p);
 }
+# endif
 if (ec) ec->clear();
 }
 

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.enum/enum.perms.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.enum/enum.perms.pass.cpp?rev=273328&r1=273327&r2=273328&view=diff
==
--- libcxx/trunk/test/std/experimental/filesystem/fs.enum/enum.perms.pass.cpp 
(original)
+++ libcxx/trunk/test/std/experimental/filesystem/fs.enum/enum.perms.pass.cpp 
Tue Jun 21 17:42:42 2016
@@ -63,6 +63,6 @@ int main() {
 E::unknown  == ME(0x) &&
 E::add_perms== ME(0x1) &&
 E::remove_perms == ME(0x2) &&
-E::resolve_symlinks == ME(0x4),
+E::symlink_nofollow == ME(0x4),
 "Expected enumeration values do not match");
 }

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.permissions/permissions.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.permissions/permissions.pass.cpp?rev=273328&r1=273327&r2=273328&view=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.permissions/permissions.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.per

[PATCH] Restructure the propagation of -fPIC/-fPIE.

2016-06-21 Thread Rafael Espíndola via cfe-commits
The PIC and PIE levels are not independent. In fact, if PIE is defined
it is always the same as PIC.

This is clear in the driver where ParsePICArgs returns a PIC level and
a IsPIE boolean. Unfortunately that is currently lost and we pass two
redundant levels down the pipeline.

This patch keeps a bool and a PIC level all the way down to codegen. I
intend to send a patch for LLVM tomorrow so that CodeGen too can be
simplified.

Cheers,
Rafael
From e36fea8d8fb20a549da60c22a1cd0751fa6ea70d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?=
 
Date: Tue, 21 Jun 2016 18:46:31 -0400
Subject: [PATCH] Restructure the propagation of -fPIC/-fPIE.

The PIC and PIE levels are not independent. In fact, if PIE is defined
it is always the same as PIC.

This is clear in the driver where ParsePICArgs returns a PIC level and
a IsPIE boolean. Unfortunately that is currently lost and we pass two
redundant levels down the pipeline.

This patch keeps a bool and a PIC level all the way down to codegen. I
intend to send a patch for LLVM tomorrow so that CodeGen too can be
simplified.
---
 include/clang/Basic/LangOptions.def   |  2 +-
 include/clang/Driver/CC1Options.td|  2 --
 include/clang/Driver/Options.td   |  2 +-
 lib/CodeGen/CGObjCGNU.cpp |  2 +-
 lib/CodeGen/CodeGenModule.cpp |  7 ++-
 lib/Driver/Tools.cpp  |  6 ++
 lib/Frontend/CompilerInvocation.cpp   |  4 ++--
 lib/Frontend/InitPreprocessor.cpp |  8 
 test/Driver/fsanitize.c   |  2 +-
 test/Driver/pic.c | 10 +-
 test/Driver/ps4-pic.c |  4 ++--
 test/Modules/explicit-build-flags.cpp |  2 +-
 test/Preprocessor/pic.c   | 12 ++--
 13 files changed, 28 insertions(+), 35 deletions(-)

diff --git a/include/clang/Basic/LangOptions.def b/include/clang/Basic/LangOptions.def
index 3fb4e97..0356196 100644
--- a/include/clang/Basic/LangOptions.def
+++ b/include/clang/Basic/LangOptions.def
@@ -158,7 +158,7 @@ VALUE_LANGOPT(MaxTypeAlign  , 32, 0,
   "default maximum alignment for types")
 VALUE_LANGOPT(AlignDouble, 1, 0, "Controls if doubles should be aligned to 8 bytes (x86 only)")
 COMPATIBLE_VALUE_LANGOPT(PICLevel, 2, 0, "__PIC__ level")
-COMPATIBLE_VALUE_LANGOPT(PIELevel, 2, 0, "__PIE__ level")
+COMPATIBLE_VALUE_LANGOPT(PIE , 1, 0, "is pie")
 COMPATIBLE_LANGOPT(GNUInline , 1, 0, "GNU inline semantics")
 COMPATIBLE_LANGOPT(NoInlineDefine, 1, 0, "__NO_INLINE__ predefined macro")
 COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED predefined macro")
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index f816844..d1dbda8 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -546,8 +546,6 @@ def fencode_extended_block_signature : Flag<["-"], "fencode-extended-block-signa
   HelpText<"enable extended encoding of block type signature">;
 def pic_level : Separate<["-"], "pic-level">,
   HelpText<"Value for __PIC__">;
-def pie_level : Separate<["-"], "pie-level">,
-  HelpText<"Value for __PIE__">;
 def fno_validate_pch : Flag<["-"], "fno-validate-pch">,
   HelpText<"Disable validation of precompiled headers">;
 def dump_deserialized_pch_decls : Flag<["-"], "dump-deserialized-decls">,
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index 9928758..d4c82bf 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -1034,7 +1034,7 @@ def fpcc_struct_return : Flag<["-"], "fpcc-struct-return">, Group, Flag
 def fpch_preprocess : Flag<["-"], "fpch-preprocess">, Group;
 def fpic : Flag<["-"], "fpic">, Group;
 def fno_pic : Flag<["-"], "fno-pic">, Group;
-def fpie : Flag<["-"], "fpie">, Group;
+def fpie : Flag<["-"], "fpie">, Group, Flags<[CC1Option]>;
 def fno_pie : Flag<["-"], "fno-pie">, Group;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group, Flags<[DriverOption]>, MetaVarName<"">,
   HelpText<"Load the named plugin (dynamic shared object)">;
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index bbe1b8b..f9f48c8 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -2830,7 +2830,7 @@ llvm::GlobalVariable *CGObjCGNU::ObjCIvarOffsetVariable(
 // to replace it with the real version for a library.  In non-PIC code you
 // must compile with the fragile ABI if you want to use ivars from a
 // GCC-compiled class.
-if (CGM.getLangOpts().PICLevel || CGM.getLangOpts().PIELevel) {
+if (CGM.getLangOpts().PICLevel) {
   llvm::GlobalVariable *IvarOffsetGV = new llvm::GlobalVariable(TheModule,
 Int32Ty, false,
 llvm::GlobalValue::PrivateLinkage, OffsetGuess, Name+".guess");
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index a8abe72..5077727 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -480,11 +480

Re: [PATCH] D5896: Emit more intrinsics for builtin functions

2016-06-21 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

Why are you removing 'F' from all of the builtin definitions? And if you need 
to, why are you not removing them from copysign?


http://reviews.llvm.org/D5896



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


Re: [PATCH] Restructure the propagation of -fPIC/-fPIE.

2016-06-21 Thread Joerg Sonnenberger via cfe-commits
On Tue, Jun 21, 2016 at 06:53:03PM -0400, Rafael Espíndola via cfe-commits 
wrote:
> diff --git a/lib/Frontend/InitPreprocessor.cpp 
> b/lib/Frontend/InitPreprocessor.cpp
> index 27ef59a..6b93c69 100644
> --- a/lib/Frontend/InitPreprocessor.cpp
> +++ b/lib/Frontend/InitPreprocessor.cpp
> @@ -873,10 +873,10 @@ static void InitializePredefinedMacros(const TargetInfo 
> &TI,
>if (unsigned PICLevel = LangOpts.PICLevel) {
>  Builder.defineMacro("__PIC__", Twine(PICLevel));
>  Builder.defineMacro("__pic__", Twine(PICLevel));
> -  }
> -  if (unsigned PIELevel = LangOpts.PIELevel) {
> -Builder.defineMacro("__PIE__", Twine(PIELevel));
> -Builder.defineMacro("__pie__", Twine(PIELevel));
> +if (LangOpts.PIE) {
> +  Builder.defineMacro("__PIE__", Twine(PICLevel));
> +  Builder.defineMacro("__pie__", Twine(PICLevel));
> +}
>}
>  
>// Macros to control C99 numerics and 

This is the only part that I am somewhat nervous about, since it changes
behavior in an externally visible way. I'm not sure what the code
expectations are in the wild world right now.

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


Re: [PATCH] D20352: Add XRay flags to Clang

2016-06-21 Thread Eric Christopher via cfe-commits
echristo added a reviewer: aaron.ballman.
echristo added a comment.

Couple of inline comments. Also adding Aaron since he normally reviews the 
attributes :)

-eric



Comment at: include/clang/Driver/Options.td:753
@@ +752,3 @@
+  HelpText<"Generate XRay instrumentation sleds on function entry and exit">;
+def fnoxray_instrument : Flag<["-"], "fnoxray-instrument">, Group,
+  Flags<[CC1Option]>;

fno-xray-instrument


Comment at: include/clang/Frontend/CodeGenOptions.def:74
@@ -73,3 +73,3 @@
 CODEGENOPT(FunctionSections  , 1, 0) ///< Set when -ffunction-sections is 
enabled.
 CODEGENOPT(InstrumentFunctions , 1, 0) ///< Set when -finstrument-functions is
///< enabled.

Would it make sense to turn -finstrument-functions to 
-finstrument-functions= to avoid tons of instrumentation type arguments? 
If we want to keep -fxray-instrument still it can then just be an alias.


http://reviews.llvm.org/D20352



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


[libcxx] r273334 - Fix PR27684 - std::tuple no longer accepts reference to incomplete type in some cases.

2016-06-21 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jun 21 18:19:13 2016
New Revision: 273334

URL: http://llvm.org/viewvc/llvm-project?rev=273334&view=rev
Log:
Fix PR27684 - std::tuple no longer accepts reference to incomplete type in some 
cases.

Libc++ has to deduce the 'allocator_arg_t' parameter as 'AllocArgT' for the
following constructor:

  template  tuple(allocator_arg_t, Alloc const&)

Previously libc++ has tried to support tags derived from 'allocator_arg_t' by
using 'is_base_of'. However this breaks whenever a
2-tuple contains a reference to an incomplete type as its first parameter.

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

Added:

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR27684_contains_ref_to_incomplete_type.pass.cpp
Modified:
libcxx/trunk/include/tuple
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=273334&r1=27&r2=273334&view=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Tue Jun 21 18:19:13 2016
@@ -662,7 +662,7 @@ public:
 
 template ,
+is_same,
 __lazy_all<__dependent_type, 
_Dummy>...>
>::value
 >::type>

Added: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR27684_contains_ref_to_incomplete_type.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR27684_contains_ref_to_incomplete_type.pass.cpp?rev=273334&view=auto
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR27684_contains_ref_to_incomplete_type.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR27684_contains_ref_to_incomplete_type.pass.cpp
 Tue Jun 21 18:19:13 2016
@@ -0,0 +1,51 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// template  class tuple;
+
+// template  tuple(allocator_arg_t, Alloc const&)
+
+// Libc++ has to deduce the 'allocator_arg_t' parameter for this constructor
+// as 'AllocArgT'. Previously libc++ has tried to support tags derived from
+// 'allocator_arg_t' by using 'is_base_of'.
+// However this breaks whenever a 2-tuple contains a reference to an incomplete
+// type as its first parameter. See PR27684.
+
+#include 
+#include 
+
+struct IncompleteType;
+extern IncompleteType inc1;
+extern IncompleteType inc2;
+IncompleteType const& cinc1 = inc1;
+IncompleteType const& cinc2 = inc2;
+
+int main() {
+using IT = IncompleteType;
+{ // try calling tuple(Tp const&...)
+using Tup = std::tuple;
+Tup t(cinc1, cinc2);
+assert(&std::get<0>(t) == &inc1);
+assert(&std::get<1>(t) == &inc2);
+}
+{ // try calling tuple(Up&&...)
+using Tup = std::tuple;
+Tup t(inc1, inc2);
+assert(&std::get<0>(t) == &inc1);
+assert(&std::get<1>(t) == &inc2);
+}
+}
+
+struct IncompleteType {};
+IncompleteType inc1;
+IncompleteType inc2;

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp?rev=273334&r1=27&r2=273334&view=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp 
Tue Jun 21 18:19:13 2016
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+
 // 
 
 // template  class tuple;
@@ -14,7 +16,9 @@
 // template 
 //   tuple(allocator_arg_t, const Alloc& a);
 
-// UNSUPPORTED: c++98, c++03
+// NOTE: this constructor does not currently support tags derived from
+// allocator_arg_t because libc++ has to deduce the parameter as a template
+// argument. See PR27684 (https://llvm.org/bugs/show_bug.cgi?id=27684)
 
 #include 
 #include 
@@ -42,10 +46,6 @@ int main()
 std::tuple<> t(std::allocator_arg, A1());
 }
 {
-DerivedFromAllocArgT tag;
-std::tuple<> t(tag, A1());
-}
-{
 std::tuple t(std::allocator_arg, A1());
 assert(std::get<0>(t) == 0);
 }
@@ -95,21 +95,6 @@ int main()
 assert(std::get<2>(t) == alloc_last());
 }
 {
-// Test that allocator construction is selected 

Re: [PATCH] D5896: Emit more intrinsics for builtin functions

2016-06-21 Thread Matt Arsenault via cfe-commits
arsenm added a comment.

In http://reviews.llvm.org/D5896#463883, @hfinkel wrote:

> Why are you removing 'F' from all of the builtin definitions? And if you need 
> to, why are you not removing them from copysign?


That marks them as emitting a libcall. It should also be removed from copysign


http://reviews.llvm.org/D5896



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


Re: [PATCH] D5896: Emit more intrinsics for builtin functions

2016-06-21 Thread Matt Arsenault via cfe-commits
arsenm updated this revision to Diff 61468.
arsenm added a comment.

It appears removing the F isn't actually necessary, unremove it


http://reviews.llvm.org/D5896

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtins.c

Index: test/CodeGen/builtins.c
===
--- test/CodeGen/builtins.c
+++ test/CodeGen/builtins.c
@@ -257,6 +257,98 @@
   // CHECK: call float @llvm.canonicalize.f32(float
   // CHECK: call double @llvm.canonicalize.f64(double
   // CHECK: call x86_fp80 @llvm.canonicalize.f80(x86_fp80
+
+  resf = __builtin_fminf(F, F);
+  // CHECK: call float @llvm.minnum.f32
+
+  resd = __builtin_fmin(D, D);
+  // CHECK: call double @llvm.minnum.f64
+
+  resld = __builtin_fminl(LD, LD);
+  // CHECK: call x86_fp80 @llvm.minnum.f80
+
+  resf = __builtin_fmaxf(F, F);
+  // CHECK: call float @llvm.maxnum.f32
+
+  resd = __builtin_fmax(D, D);
+  // CHECK: call double @llvm.maxnum.f64
+
+  resld = __builtin_fmaxl(LD, LD);
+  // CHECK: call x86_fp80 @llvm.maxnum.f80
+
+  resf = __builtin_fabsf(F);
+  // CHECK: call float @llvm.fabs.f32
+
+  resd = __builtin_fabs(D);
+  // CHECK: call double @llvm.fabs.f64
+
+  resld = __builtin_fabsl(LD);
+  // CHECK: call x86_fp80 @llvm.fabs.f80
+
+  resf = __builtin_copysignf(F, F);
+  // CHECK: call float @llvm.copysign.f32
+
+  resd = __builtin_copysign(D, D);
+  // CHECK: call double @llvm.copysign.f64
+
+  resld = __builtin_copysignl(LD, LD);
+  // CHECK: call x86_fp80 @llvm.copysign.f80
+
+
+  resf = __builtin_ceilf(F);
+  // CHECK: call float @llvm.ceil.f32
+
+  resd = __builtin_ceil(D);
+  // CHECK: call double @llvm.ceil.f64
+
+  resld = __builtin_ceill(LD);
+  // CHECK: call x86_fp80 @llvm.ceil.f80
+
+  resf = __builtin_floorf(F);
+  // CHECK: call float @llvm.floor.f32
+
+  resd = __builtin_floor(D);
+  // CHECK: call double @llvm.floor.f64
+
+  resld = __builtin_floorl(LD);
+  // CHECK: call x86_fp80 @llvm.floor.f80
+
+  resf = __builtin_truncf(F);
+  // CHECK: call float @llvm.trunc.f32
+
+  resd = __builtin_trunc(D);
+  // CHECK: call double @llvm.trunc.f64
+
+  resld = __builtin_truncl(LD);
+  // CHECK: call x86_fp80 @llvm.trunc.f80
+
+  resf = __builtin_rintf(F);
+  // CHECK: call float @llvm.rint.f32
+
+  resd = __builtin_rint(D);
+  // CHECK: call double @llvm.rint.f64
+
+  resld = __builtin_rintl(LD);
+  // CHECK: call x86_fp80 @llvm.rint.f80
+
+  resf = __builtin_nearbyintf(F);
+  // CHECK: call float @llvm.nearbyint.f32
+
+  resd = __builtin_nearbyint(D);
+  // CHECK: call double @llvm.nearbyint.f64
+
+  resld = __builtin_nearbyintl(LD);
+  // CHECK: call x86_fp80 @llvm.nearbyint.f80
+
+  resf = __builtin_roundf(F);
+  // CHECK: call float @llvm.round.f32
+
+  resd = __builtin_round(D);
+  // CHECK: call double @llvm.round.f64
+
+  resld = __builtin_roundl(LD);
+  // CHECK: call x86_fp80 @llvm.round.f80
+
 }
 
 // __builtin_longjmp isn't supported on all platforms, so only test it on X86.
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -217,6 +217,51 @@
ValueType);
 }
 
+// Emit a simple mangled intrinsic that has 1 argument and a return type
+// matching the argument type.
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF,
+   const CallExpr *E,
+   unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, Src0);
+}
+
+// Emit an intrinsic that has 2 operands of the same type as its result.
+static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
+const CallExpr *E,
+unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, { Src0, Src1 });
+}
+
+// Emit an intrinsic that has 3 operands of the same type as its result.
+static Value *emitTernaryBuiltin(CodeGenFunction &CGF,
+ const CallExpr *E,
+ unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+  llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 });
+}
+
+// Emit an intrinsic that has 1 float or double operand, and 1 integer.
+static Value *emitFPIntBuiltin(CodeGenFunction &CGF,
+   const CallExpr *E,
+   unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitSca

r273340 - [analyzer] Teach trackNullOrUndefValue() about class property accessors.

2016-06-21 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Tue Jun 21 19:20:00 2016
New Revision: 273340

URL: http://llvm.org/viewvc/llvm-project?rev=273340&view=rev
Log:
[analyzer] Teach trackNullOrUndefValue() about class property accessors.

Teach trackNullOrUndefValue() how to properly look through PseudoObjectExprs
to find the underlying semantic method call for property getters. This fixes a
crash when looking through class property getters that I introduced in r265839.

rdar://problem/2679

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/inlining/false-positive-suppression.m

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=273340&r1=273339&r2=273340&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Tue Jun 21 
19:20:00 2016
@@ -914,7 +914,10 @@ static const Expr *peelOffOuterExpr(cons
   if (auto *POE = dyn_cast(Ex)) {
 auto *PropRef = dyn_cast(POE->getSyntacticForm());
 if (PropRef && PropRef->isMessagingGetter()) {
-  return peelOffOuterExpr(POE->getSemanticExpr(1), N);
+  const Expr *GetterMessageSend =
+  POE->getSemanticExpr(POE->getNumSemanticExprs() - 1);
+  assert(isa(GetterMessageSend));
+  return peelOffOuterExpr(GetterMessageSend, N);
 }
   }
 

Modified: cfe/trunk/test/Analysis/inlining/false-positive-suppression.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/false-positive-suppression.m?rev=273340&r1=273339&r2=273340&view=diff
==
--- cfe/trunk/test/Analysis/inlining/false-positive-suppression.m (original)
+++ cfe/trunk/test/Analysis/inlining/false-positive-suppression.m Tue Jun 21 
19:20:00 2016
@@ -49,6 +49,12 @@ __attribute__((objc_root_class))
 
 @end
 
+@interface SubOfSomeClass : SomeClass
+@end
+
+@implementation SubOfSomeClass
+@end
+
 @implementation SomeClass
 -(int *)methodReturningNull {
   return 0;
@@ -57,6 +63,10 @@ __attribute__((objc_root_class))
 -(int *)propertyReturningNull {
   return 0;
 }
+
++(int *)classPropertyReturningNull {
+  return 0;
+}
 @end
 
 void testMethodReturningNull(SomeClass *sc) {
@@ -72,6 +82,24 @@ void testPropertyReturningNull(SomeClass
   *result = 1;
 #ifndef SUPPRESSED
   // expected-warning@-2 {{Dereference of null pointer}}
+#endif
+}
+
+@implementation SubOfSomeClass (ForTestOfSuperProperty)
+-(void)testSuperPropertyReturningNull {
+  int *result = super.propertyReturningNull;
+  *result = 1;
+#ifndef SUPPRESSED
+  // expected-warning@-2 {{Dereference of null pointer}}
+#endif
+}
+@end
+
+void testClassPropertyReturningNull() {
+  int *result = SomeClass.classPropertyReturningNull;
+  *result = 1;
+#ifndef SUPPRESSED
+  // expected-warning@-2 {{Dereference of null pointer}}
 #endif
 }
 


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


[libcxx] r273341 - Move native_handle thread tests to test/libcxx

2016-06-21 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jun 21 19:21:50 2016
New Revision: 273341

URL: http://llvm.org/viewvc/llvm-project?rev=273341&view=rev
Log:
Move native_handle thread tests to test/libcxx

Added:
libcxx/trunk/test/libcxx/thread/thread.condition/
libcxx/trunk/test/libcxx/thread/thread.condition/thread.condition.condvar/

libcxx/trunk/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/

libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/

libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/

libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/

libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
libcxx/trunk/test/libcxx/thread/thread.threads/
libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/

libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/

libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
Removed:

libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp

libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp

libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/types.pass.cpp

Added: 
libcxx/trunk/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp?rev=273341&view=auto
==
--- 
libcxx/trunk/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
 (added)
+++ 
libcxx/trunk/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
 Tue Jun 21 19:21:50 2016
@@ -0,0 +1,29 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// 
+
+// class condition_variable;
+
+// typedef pthread_cond_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include 
+#include 
+
+int main()
+{
+static_assert((std::is_same::value), "");
+std::condition_variable cv;
+std::condition_variable::native_handle_type h = cv.native_handle();
+assert(h != nullptr);
+}

Added: 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp?rev=273341&view=auto
==
--- 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
 (added)
+++ 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
 Tue Jun 21 19:21:50 2016
@@ -0,0 +1,27 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// 
+
+// class mutex;
+
+// typedef pthread_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include 
+#include 
+
+int main()
+{
+std::mutex m;
+pthread_mutex_t* h = m.native_handle();
+assert(h);
+}

[libcxx] r273342 - Allow placement new array test to consume extra bytes as specified by the standard.

2016-06-21 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jun 21 19:32:28 2016
New Revision: 273342

URL: http://llvm.org/viewvc/llvm-project?rev=273342&view=rev
Log:
Allow placement new array test to consume extra bytes as specified by the 
standard.

Modified:

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp?rev=273342&r1=273341&r2=273342&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp
 Tue Jun 21 19:32:28 2016
@@ -22,9 +22,13 @@ struct A
 
 int main()
 {
-char buf[3*sizeof(A)];
+const std::size_t Size = 3;
+// placement new might require additional space.
+const std::size_t ExtraSize = 64;
+char buf[Size*sizeof(A) + ExtraSize];
 
-A* ap = new(buf) A[3];
-assert((char*)ap == buf);
-assert(A_constructed == 3);
+A* ap = new(buf) A[Size];
+assert((char*)ap >= buf);
+assert((char*)ap < (buf + ExtraSize));
+assert(A_constructed == Size);
 }


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


Re: [PATCH] D5896: Emit more intrinsics for builtin functions

2016-06-21 Thread Matt Arsenault via cfe-commits
arsenm updated this revision to Diff 61472.
arsenm added a comment.

Attach right diff


http://reviews.llvm.org/D5896

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtins.c

Index: test/CodeGen/builtins.c
===
--- test/CodeGen/builtins.c
+++ test/CodeGen/builtins.c
@@ -257,6 +257,98 @@
   // CHECK: call float @llvm.canonicalize.f32(float
   // CHECK: call double @llvm.canonicalize.f64(double
   // CHECK: call x86_fp80 @llvm.canonicalize.f80(x86_fp80
+
+  resf = __builtin_fminf(F, F);
+  // CHECK: call float @llvm.minnum.f32
+
+  resd = __builtin_fmin(D, D);
+  // CHECK: call double @llvm.minnum.f64
+
+  resld = __builtin_fminl(LD, LD);
+  // CHECK: call x86_fp80 @llvm.minnum.f80
+
+  resf = __builtin_fmaxf(F, F);
+  // CHECK: call float @llvm.maxnum.f32
+
+  resd = __builtin_fmax(D, D);
+  // CHECK: call double @llvm.maxnum.f64
+
+  resld = __builtin_fmaxl(LD, LD);
+  // CHECK: call x86_fp80 @llvm.maxnum.f80
+
+  resf = __builtin_fabsf(F);
+  // CHECK: call float @llvm.fabs.f32
+
+  resd = __builtin_fabs(D);
+  // CHECK: call double @llvm.fabs.f64
+
+  resld = __builtin_fabsl(LD);
+  // CHECK: call x86_fp80 @llvm.fabs.f80
+
+  resf = __builtin_copysignf(F, F);
+  // CHECK: call float @llvm.copysign.f32
+
+  resd = __builtin_copysign(D, D);
+  // CHECK: call double @llvm.copysign.f64
+
+  resld = __builtin_copysignl(LD, LD);
+  // CHECK: call x86_fp80 @llvm.copysign.f80
+
+
+  resf = __builtin_ceilf(F);
+  // CHECK: call float @llvm.ceil.f32
+
+  resd = __builtin_ceil(D);
+  // CHECK: call double @llvm.ceil.f64
+
+  resld = __builtin_ceill(LD);
+  // CHECK: call x86_fp80 @llvm.ceil.f80
+
+  resf = __builtin_floorf(F);
+  // CHECK: call float @llvm.floor.f32
+
+  resd = __builtin_floor(D);
+  // CHECK: call double @llvm.floor.f64
+
+  resld = __builtin_floorl(LD);
+  // CHECK: call x86_fp80 @llvm.floor.f80
+
+  resf = __builtin_truncf(F);
+  // CHECK: call float @llvm.trunc.f32
+
+  resd = __builtin_trunc(D);
+  // CHECK: call double @llvm.trunc.f64
+
+  resld = __builtin_truncl(LD);
+  // CHECK: call x86_fp80 @llvm.trunc.f80
+
+  resf = __builtin_rintf(F);
+  // CHECK: call float @llvm.rint.f32
+
+  resd = __builtin_rint(D);
+  // CHECK: call double @llvm.rint.f64
+
+  resld = __builtin_rintl(LD);
+  // CHECK: call x86_fp80 @llvm.rint.f80
+
+  resf = __builtin_nearbyintf(F);
+  // CHECK: call float @llvm.nearbyint.f32
+
+  resd = __builtin_nearbyint(D);
+  // CHECK: call double @llvm.nearbyint.f64
+
+  resld = __builtin_nearbyintl(LD);
+  // CHECK: call x86_fp80 @llvm.nearbyint.f80
+
+  resf = __builtin_roundf(F);
+  // CHECK: call float @llvm.round.f32
+
+  resd = __builtin_round(D);
+  // CHECK: call double @llvm.round.f64
+
+  resld = __builtin_roundl(LD);
+  // CHECK: call x86_fp80 @llvm.round.f80
+
 }
 
 // __builtin_longjmp isn't supported on all platforms, so only test it on X86.
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -217,6 +217,51 @@
ValueType);
 }
 
+// Emit a simple mangled intrinsic that has 1 argument and a return type
+// matching the argument type.
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF,
+   const CallExpr *E,
+   unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, Src0);
+}
+
+// Emit an intrinsic that has 2 operands of the same type as its result.
+static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
+const CallExpr *E,
+unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, { Src0, Src1 });
+}
+
+// Emit an intrinsic that has 3 operands of the same type as its result.
+static Value *emitTernaryBuiltin(CodeGenFunction &CGF,
+ const CallExpr *E,
+ unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+  llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 });
+}
+
+// Emit an intrinsic that has 1 float or double operand, and 1 integer.
+static Value *emitFPIntBuiltin(CodeGenFunction &CGF,
+   const CallExpr *E,
+   unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->ge

[PATCH] D21581: [libcxx] [test] Silence unused variable warnings in invoke.pass.cpp.

2016-06-21 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

Silence unused variable warnings in invoke.pass.cpp.

Fixes MSVC warning C4101 "unreferenced local variable".

http://reviews.llvm.org/D21581

Files:
  test/std/utilities/function.objects/func.invoke/invoke.pass.cpp

Index: test/std/utilities/function.objects/func.invoke/invoke.pass.cpp
===
--- test/std/utilities/function.objects/func.invoke/invoke.pass.cpp
+++ test/std/utilities/function.objects/func.invoke/invoke.pass.cpp
@@ -326,13 +326,15 @@
 void noexcept_test() {
 {
 NoThrowCallable obj;
+((void)obj); // Prevent unused warning
 CopyThrows arg;
 static_assert(noexcept(std::invoke(obj)), "");
 static_assert(!noexcept(std::invoke(obj, arg)), "");
 static_assert(noexcept(std::invoke(obj, std::move(arg))), "");
 }
 {
 ThrowsCallable obj;
+((void)obj); // Prevent unused warning
 static_assert(!noexcept(std::invoke(obj)), "");
 }
 {


Index: test/std/utilities/function.objects/func.invoke/invoke.pass.cpp
===
--- test/std/utilities/function.objects/func.invoke/invoke.pass.cpp
+++ test/std/utilities/function.objects/func.invoke/invoke.pass.cpp
@@ -326,13 +326,15 @@
 void noexcept_test() {
 {
 NoThrowCallable obj;
+((void)obj); // Prevent unused warning
 CopyThrows arg;
 static_assert(noexcept(std::invoke(obj)), "");
 static_assert(!noexcept(std::invoke(obj, arg)), "");
 static_assert(noexcept(std::invoke(obj, std::move(arg))), "");
 }
 {
 ThrowsCallable obj;
+((void)obj); // Prevent unused warning
 static_assert(!noexcept(std::invoke(obj)), "");
 }
 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >