Re: [PATCH] D20313: [Mips] Set mips32 as default CPU for MIPS32 Android

2016-05-17 Thread Simon Atanasyan via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D20313



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


Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-17 Thread Martin Probst via cfe-commits
mprobst marked an inline comment as done.


Comment at: lib/Format/SortJavaScriptImports.cpp:77
@@ +76,3 @@
+return false;
+  // NB: empty URLs sort *last* (for export {...};).
+  if (LHS.URL.empty() != RHS.URL.empty())

djasper wrote:
> NB?
"Nota bene". Seems to be uncommon in this code base, so removed.


Comment at: lib/Format/SortJavaScriptImports.cpp:255
@@ +254,3 @@
+// * as prefix from '...';
+if (Current->is(tok::star)) {
+  if (!nextToken())

djasper wrote:
> We probably should really have a variant of AnnotatedLine::startsWith() that 
> can start at an arbitrary token. But we can try that in a follow-up.
Maybe that should be a function on FormatToken itself, that searches the linked 
list rooted at it?

`Current->startsSequence(tok::star, Keywords.kw_as, tok::identifier)`?

I'll take a stab at that.


http://reviews.llvm.org/D20198



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


Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-17 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 57438.
mprobst marked an inline comment as done.
mprobst added a comment.

- extract TokenAnalyzer.h and SortJavaScriptImports.h/cpp
- clean up imports/
- includes
- address review comments
- pull out implementations from header files.
- support side effect imports, keep in relative order at top.
- Move getLanguageName to Format.h


http://reviews.llvm.org/D20198

Files:
  include/clang/Format/Format.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/SortJavaScriptImports.cpp
  lib/Format/SortJavaScriptImports.h
  lib/Format/TokenAnalyzer.cpp
  lib/Format/TokenAnalyzer.h
  unittests/Format/CMakeLists.txt
  unittests/Format/SortImportsTestJS.cpp

Index: unittests/Format/SortImportsTestJS.cpp
===
--- /dev/null
+++ unittests/Format/SortImportsTestJS.cpp
@@ -0,0 +1,137 @@
+//===- unittest/Format/SortImportsTestJS.cpp - JS import sort unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+namespace {
+
+class SortImportsTestJS : public ::testing::Test {
+protected:
+  std::vector GetCodeRange(StringRef Code) {
+return std::vector(1, tooling::Range(0, Code.size()));
+  }
+
+  std::string sort(StringRef Code, StringRef FileName = "input.js") {
+auto Ranges = GetCodeRange(Code);
+std::string Sorted =
+applyAllReplacements(Code, sortIncludes(Style, Code, Ranges, FileName));
+return applyAllReplacements(Sorted,
+reformat(Style, Sorted, Ranges, FileName));
+  }
+
+  void verifySort(llvm::StringRef Expected, llvm::StringRef Code) {
+std::string Result = sort(Code);
+EXPECT_EQ(Expected.str(), Result) << "Formatted:\n" << Result;
+  }
+
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+};
+
+TEST_F(SortImportsTestJS, BasicSorting) {
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;",
+ "import {sym} from 'a';\n"
+ "import {sym} from 'c';\n"
+ "import {sym} from 'b';\n"
+ "let x = 1;");
+}
+
+TEST_F(SortImportsTestJS, Comments) {
+  verifySort("/** @fileoverview This is a great file. */\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n"
+ "import {sym} from 'b'; // from //foo:bar\n",
+ "/** @fileoverview This is a great file. */\n"
+ "import {sym} from 'b'; // from //foo:bar\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n");
+}
+
+TEST_F(SortImportsTestJS, SortStar) {
+  verifySort("import * as foo from 'a';\n"
+ "import {sym} from 'a';\n"
+ "import * as bar from 'b';\n",
+ "import {sym} from 'a';\n"
+ "import * as foo from 'a';\n"
+ "import * as bar from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, AliasesSymbols) {
+  verifySort("import {sym1 as alias1} from 'b';\n"
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n",
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n"
+ "import {sym1 as alias1} from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, GroupImports) {
+  verifySort("import {a} from 'absolute';\n"
+ "\n"
+ "import {b} from '../parent';\n"
+ "import {b} from '../parent/nested';\n"
+ "\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from './relative/path/nested';\n"
+ "\n"
+ "let x = 1;\n",
+ "import {b} from './relative/path/nested';\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from '../parent/nested';\n"
+ "import {b} from '../parent';\n"
+ "import {a} from 'absolute';\n"
+ "let x = 1;\n");
+}
+
+TEST_F(SortImportsTestJS, Exports) {
+  verifySort("import {S} from 'bpath';\n"
+ "\n"
+ "import {T} from './cpath';\n"
+ "\n"
+ "export {A, B} from 'apath';\n"
+ "export {P} from '../parent';\n"
+ "export {R} from './relative';\n"
+ "export {S};\n"
+ "\n"
+ "let x = 1;\n"
+ "export y = 1;\n",
+ "export {R} from './relative';\n"
+ "import {T} from '.

Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-17 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 57440.
mprobst marked an inline comment as done.
mprobst added a comment.

- review comments


http://reviews.llvm.org/D20198

Files:
  include/clang/Format/Format.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/SortJavaScriptImports.cpp
  lib/Format/SortJavaScriptImports.h
  lib/Format/TokenAnalyzer.cpp
  lib/Format/TokenAnalyzer.h
  unittests/Format/CMakeLists.txt
  unittests/Format/SortImportsTestJS.cpp

Index: unittests/Format/SortImportsTestJS.cpp
===
--- /dev/null
+++ unittests/Format/SortImportsTestJS.cpp
@@ -0,0 +1,137 @@
+//===- unittest/Format/SortImportsTestJS.cpp - JS import sort unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+namespace {
+
+class SortImportsTestJS : public ::testing::Test {
+protected:
+  std::vector GetCodeRange(StringRef Code) {
+return std::vector(1, tooling::Range(0, Code.size()));
+  }
+
+  std::string sort(StringRef Code, StringRef FileName = "input.js") {
+auto Ranges = GetCodeRange(Code);
+std::string Sorted =
+applyAllReplacements(Code, sortIncludes(Style, Code, Ranges, FileName));
+return applyAllReplacements(Sorted,
+reformat(Style, Sorted, Ranges, FileName));
+  }
+
+  void verifySort(llvm::StringRef Expected, llvm::StringRef Code) {
+std::string Result = sort(Code);
+EXPECT_EQ(Expected.str(), Result) << "Formatted:\n" << Result;
+  }
+
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+};
+
+TEST_F(SortImportsTestJS, BasicSorting) {
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;",
+ "import {sym} from 'a';\n"
+ "import {sym} from 'c';\n"
+ "import {sym} from 'b';\n"
+ "let x = 1;");
+}
+
+TEST_F(SortImportsTestJS, Comments) {
+  verifySort("/** @fileoverview This is a great file. */\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n"
+ "import {sym} from 'b'; // from //foo:bar\n",
+ "/** @fileoverview This is a great file. */\n"
+ "import {sym} from 'b'; // from //foo:bar\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n");
+}
+
+TEST_F(SortImportsTestJS, SortStar) {
+  verifySort("import * as foo from 'a';\n"
+ "import {sym} from 'a';\n"
+ "import * as bar from 'b';\n",
+ "import {sym} from 'a';\n"
+ "import * as foo from 'a';\n"
+ "import * as bar from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, AliasesSymbols) {
+  verifySort("import {sym1 as alias1} from 'b';\n"
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n",
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n"
+ "import {sym1 as alias1} from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, GroupImports) {
+  verifySort("import {a} from 'absolute';\n"
+ "\n"
+ "import {b} from '../parent';\n"
+ "import {b} from '../parent/nested';\n"
+ "\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from './relative/path/nested';\n"
+ "\n"
+ "let x = 1;\n",
+ "import {b} from './relative/path/nested';\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from '../parent/nested';\n"
+ "import {b} from '../parent';\n"
+ "import {a} from 'absolute';\n"
+ "let x = 1;\n");
+}
+
+TEST_F(SortImportsTestJS, Exports) {
+  verifySort("import {S} from 'bpath';\n"
+ "\n"
+ "import {T} from './cpath';\n"
+ "\n"
+ "export {A, B} from 'apath';\n"
+ "export {P} from '../parent';\n"
+ "export {R} from './relative';\n"
+ "export {S};\n"
+ "\n"
+ "let x = 1;\n"
+ "export y = 1;\n",
+ "export {R} from './relative';\n"
+ "import {T} from './cpath';\n"
+ "export {S};\n"
+ "export {A, B} from 'apath';\n"
+ "import {S} from 'bpath';\n"
+ "export {P} from '../parent';\n"
+ "let x = 1;\n"
+ "export y = 1;\n");

RE: r269680 - [Clang][AVX512] completing missing intrinsics for [vpabs] instruction set

2016-05-17 Thread Zuckerman, Michael via cfe-commits
Hi ,
Yes, I saw the thread.
We have an internal discussion on this subject.

Regards,
Michael Zuckerman
From: tha...@google.com [mailto:tha...@google.com] On Behalf Of Nico Weber
Sent: Monday, May 16, 2016 22:06
To: Zuckerman, Michael 
Cc: cfe-commits 
Subject: Re: r269680 - [Clang][AVX512] completing missing intrinsics for 
[vpabs] instruction set

Hi Michael,

have you see then trhead "The intrinsics headers (especially avx512) are too 
big. What to do about it?"? Can you maybe comment on it?

Thanks,
Nico

On Mon, May 16, 2016 at 2:57 PM, Michael Zuckerman via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: mzuckerm
Date: Mon May 16 13:57:24 2016
New Revision: 269680

URL: http://llvm.org/viewvc/llvm-project?rev=269680&view=rev
Log:
[Clang][AVX512] completing missing intrinsics for [vpabs] instruction set

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

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=269680&r1=269679&r2=269680&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon May 16 13:57:24 2016
@@ -1631,6 +1631,23 @@ _mm512_abs_epi64(__m512i __A)
  (__mmask8) -1);
 }

+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_abs_epi64 (__m512i __W, __mmask8 __U, __m512i __A)
+{
+  return (__m512i) __builtin_ia32_pabsq512_mask ((__v8di) __A,
+  (__v8di) __W,
+  (__mmask8) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_abs_epi64 (__mmask8 __U, __m512i __A)
+{
+  return (__m512i) __builtin_ia32_pabsq512_mask ((__v8di) __A,
+  (__v8di)
+  _mm512_setzero_si512 (),
+  (__mmask8) __U);
+}
+
 static __inline __m512i __DEFAULT_FN_ATTRS
 _mm512_abs_epi32(__m512i __A)
 {
@@ -1640,6 +1657,23 @@ _mm512_abs_epi32(__m512i __A)
  (__mmask16) -1);
 }

+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_abs_epi32 (__m512i __W, __mmask16 __U, __m512i __A)
+{
+  return (__m512i) __builtin_ia32_pabsd512_mask ((__v16si) __A,
+  (__v16si) __W,
+  (__mmask16) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_abs_epi32 (__mmask16 __U, __m512i __A)
+{
+  return (__m512i) __builtin_ia32_pabsd512_mask ((__v16si) __A,
+  (__v16si)
+  _mm512_setzero_si512 (),
+  (__mmask16) __U);
+}
+
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_add_ss(__m128 __W, __mmask8 __U,__m128 __A, __m128 __B) {
   return (__m128) __builtin_ia32_addss_round_mask ((__v4sf) __A,

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=269680&r1=269679&r2=269680&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Mon May 16 13:57:24 2016
@@ -6574,3 +6574,30 @@ __m512 test_mm512_set_ps (float __A, flo
   __I, __J, __K, __L, __M, __N, __O, __P);
 }

+__m512i test_mm512_mask_abs_epi64 (__m512i __W, __mmask8 __U, __m512i __A)
+{
+  // CHECK-LABEL: @test_mm512_mask_abs_epi64
+  // CHECK: @llvm.x86.avx512.mask.pabs.q.512
+  return _mm512_mask_abs_epi64 (__W,__U,__A);
+}
+
+__m512i test_mm512_maskz_abs_epi64 (__mmask8 __U, __m512i __A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_abs_epi64
+  // CHECK: @llvm.x86.avx512.mask.pabs.q.512
+  return _mm512_maskz_abs_epi64 (__U,__A);
+}
+
+__m512i test_mm512_mask_abs_epi32 (__m512i __W, __mmask16 __U, __m512i __A)
+{
+  // CHECK-LABEL: @test_mm512_mask_abs_epi32
+  // CHECK: @llvm.x86.avx512.mask.pabs.d.512
+  return _mm512_mask_abs_epi32 (__W,__U,__A);
+}
+
+__m512i test_mm512_maskz_abs_epi32 (__mmask16 __U, __m512i __A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_abs_epi32
+  // CHECK: @llvm.x86.avx512.mask.pabs.d.512
+  return _mm512_maskz_abs_epi32 (__U,__A);
+}


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

-
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: Patch submission for bug 27400

2016-05-17 Thread Mads Ravn via cfe-commits
Hi guys,

I just wanted to check up on this patch. I heard I could just reply to this
mail and see if I could 'ping' anyone in this regard. Hope it's OK.

Best regards,
Mads Ravn

On Thu, May 12, 2016 at 6:11 PM Mads Ravn  wrote:

> Hi,
>
> I have fixed the things you mentioned now. I have attached the new patch
> to this email.
>
> Best regards,
> Mads Ravn
>
> On Wed, May 11, 2016 at 11:54 PM Vedant Kumar  wrote:
>
>> Hi,
>>
>> Thanks for the patch!
>>
>> This patch is missing a small, lit-style test case. You can find examples
>> of test cases here:
>>
>>   extra/test/clang-tidy/
>>
>> Apart from that, my only other nit-pick is that llvm uses 2-space
>> indents, and spaces between "if" and "(".
>>
>> If you reply to this list with an updated patch, someone would be happy
>> to commit it for you.
>>
>> best
>> vedant
>>
>> > On May 11, 2016, at 10:01 AM, Mads Ravn via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>> >
>> > Hi,
>> >
>> > I would like to submit a patch for
>> https://llvm.org/bugs/show_bug.cgi?id=27400 .
>> >
>> > Beside attaching the patch, is there anything I should be aware of? I
>> have not submitted a patch before.
>> >
>> > You can find the patch attached to this mail.
>> >
>> > Kind regards,
>> > Mads Ravn
>> >
>> ___
>> > cfe-commits mailing list
>> > cfe-commits@lists.llvm.org
>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20283: Add ras/noras flag to enable/disable RAS in clang

2016-05-17 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 57451.
rogfer01 added a comment.

Update test from mrasext to mras


http://reviews.llvm.org/D20283

Files:
  lib/Driver/Tools.cpp
  test/Driver/aarch64-ras.c
  test/Driver/arm-ras.c

Index: test/Driver/arm-ras.c
===
--- /dev/null
+++ test/Driver/arm-ras.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target arm-none-none-eabi -march=armv8a+ras -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-RAS %s
+// RUN: %clang -target arm-none-none-eabi -mcpu=generic+ras -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-RAS %s
+// CHECK-RAS: "-target-feature" "+ras"
+
+// RUN: %clang -target arm-none-none-eabi -march=armv8a+noras -### -c %s 2>&1 
| FileCheck --check-prefix=CHECK-NORAS %s
+// RUN: %clang -target arm-none-none-eabi -mcpu=generic+noras -### -c %s 2>&1 
| FileCheck --check-prefix=CHECK-NORAS %s
+// CHECK-NORAS: "-target-feature" "-ras"
Index: test/Driver/aarch64-ras.c
===
--- /dev/null
+++ test/Driver/aarch64-ras.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8a+ras -### -c %s 
2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=generic+ras -### -c %s 
2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// CHECK-RAS: "-target-feature" "+ras"
+
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8a+noras -### -c %s 
2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=generic+noras -### -c %s 
2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
+// CHECK-NORAS: "-target-feature" "-ras"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2223,12 +2223,14 @@
  .Case("crypto", "+crypto")
  .Case("fp16", "+fullfp16")
  .Case("profile", "+spe")
+ .Case("ras", "+ras")
  .Case("nofp", "-fp-armv8")
  .Case("nosimd", "-neon")
  .Case("nocrc", "-crc")
  .Case("nocrypto", "-crypto")
  .Case("nofp16", "-fullfp16")
  .Case("noprofile", "-spe")
+ .Case("noras", "-ras")
  .Default(nullptr);
 if (result)
   Features.push_back(result);


Index: test/Driver/arm-ras.c
===
--- /dev/null
+++ test/Driver/arm-ras.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target arm-none-none-eabi -march=armv8a+ras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// RUN: %clang -target arm-none-none-eabi -mcpu=generic+ras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// CHECK-RAS: "-target-feature" "+ras"
+
+// RUN: %clang -target arm-none-none-eabi -march=armv8a+noras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
+// RUN: %clang -target arm-none-none-eabi -mcpu=generic+noras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
+// CHECK-NORAS: "-target-feature" "-ras"
Index: test/Driver/aarch64-ras.c
===
--- /dev/null
+++ test/Driver/aarch64-ras.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8a+ras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=generic+ras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// CHECK-RAS: "-target-feature" "+ras"
+
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8a+noras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=generic+noras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
+// CHECK-NORAS: "-target-feature" "-ras"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2223,12 +2223,14 @@
  .Case("crypto", "+crypto")
  .Case("fp16", "+fullfp16")
  .Case("profile", "+spe")
+ .Case("ras", "+ras")
  .Case("nofp", "-fp-armv8")
  .Case("nosimd", "-neon")
  .Case("nocrc", "-crc")
  .Case("nocrypto", "-crypto")
  .Case("nofp16", "-fullfp16")
  .Case("noprofile", "-spe")
+ .Case("noras", "-ras")
  .Default(nullptr);
 if (result)
   Features.push_back(result);
___
cfe-commits mailing list
cfe-commits@lists.llvm.or

Re: [PATCH] D20313: [Mips] Set mips32 as default CPU for MIPS32 Android

2016-05-17 Thread Petar Jovanovic via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269754: [Mips] Set mips32 as default CPU for MIPS32 Android 
(authored by petarj).

Changed prior to commit:
  http://reviews.llvm.org/D20313?vs=57423&id=57454#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20313

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/clang-translation.c

Index: cfe/trunk/test/Driver/clang-translation.c
===
--- cfe/trunk/test/Driver/clang-translation.c
+++ cfe/trunk/test/Driver/clang-translation.c
@@ -245,7 +245,7 @@
 // RUN: FileCheck -check-prefix=MIPSEL-ANDROID %s
 // MIPSEL-ANDROID: clang
 // MIPSEL-ANDROID: "-cc1"
-// MIPSEL-ANDROID: "-target-cpu" "mips32r2"
+// MIPSEL-ANDROID: "-target-cpu" "mips32"
 // MIPSEL-ANDROID: "-mfloat-abi" "hard"
 
 // RUN: %clang -target mips64-linux-gnu -### -S %s 2>&1 | \
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -1183,8 +1183,10 @@
   }
 
   // MIPS64r6 is the default for Android MIPS64 (mips64el-linux-android).
-  if (Triple.isAndroid())
+  if (Triple.isAndroid()) {
+DefMips32CPU = "mips32";
 DefMips64CPU = "mips64r6";
+  }
 
   // MIPS3 is the default for mips64*-unknown-openbsd.
   if (Triple.getOS() == llvm::Triple::OpenBSD)


Index: cfe/trunk/test/Driver/clang-translation.c
===
--- cfe/trunk/test/Driver/clang-translation.c
+++ cfe/trunk/test/Driver/clang-translation.c
@@ -245,7 +245,7 @@
 // RUN: FileCheck -check-prefix=MIPSEL-ANDROID %s
 // MIPSEL-ANDROID: clang
 // MIPSEL-ANDROID: "-cc1"
-// MIPSEL-ANDROID: "-target-cpu" "mips32r2"
+// MIPSEL-ANDROID: "-target-cpu" "mips32"
 // MIPSEL-ANDROID: "-mfloat-abi" "hard"
 
 // RUN: %clang -target mips64-linux-gnu -### -S %s 2>&1 | \
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -1183,8 +1183,10 @@
   }
 
   // MIPS64r6 is the default for Android MIPS64 (mips64el-linux-android).
-  if (Triple.isAndroid())
+  if (Triple.isAndroid()) {
+DefMips32CPU = "mips32";
 DefMips64CPU = "mips64r6";
+  }
 
   // MIPS3 is the default for mips64*-unknown-openbsd.
   if (Triple.getOS() == llvm::Triple::OpenBSD)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r269754 - [Mips] Set mips32 as default CPU for MIPS32 Android

2016-05-17 Thread Petar Jovanovic via cfe-commits
Author: petarj
Date: Tue May 17 05:46:10 2016
New Revision: 269754

URL: http://llvm.org/viewvc/llvm-project?rev=269754&view=rev
Log:
[Mips] Set mips32 as default CPU for MIPS32 Android

Change default CPU for MIPS32 Android. Now it is mips32 (rev1).

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/clang-translation.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=269754&r1=269753&r2=269754&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue May 17 05:46:10 2016
@@ -1183,8 +1183,10 @@ void mips::getMipsCPUAndABI(const ArgLis
   }
 
   // MIPS64r6 is the default for Android MIPS64 (mips64el-linux-android).
-  if (Triple.isAndroid())
+  if (Triple.isAndroid()) {
+DefMips32CPU = "mips32";
 DefMips64CPU = "mips64r6";
+  }
 
   // MIPS3 is the default for mips64*-unknown-openbsd.
   if (Triple.getOS() == llvm::Triple::OpenBSD)

Modified: cfe/trunk/test/Driver/clang-translation.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-translation.c?rev=269754&r1=269753&r2=269754&view=diff
==
--- cfe/trunk/test/Driver/clang-translation.c (original)
+++ cfe/trunk/test/Driver/clang-translation.c Tue May 17 05:46:10 2016
@@ -245,7 +245,7 @@
 // RUN: FileCheck -check-prefix=MIPSEL-ANDROID %s
 // MIPSEL-ANDROID: clang
 // MIPSEL-ANDROID: "-cc1"
-// MIPSEL-ANDROID: "-target-cpu" "mips32r2"
+// MIPSEL-ANDROID: "-target-cpu" "mips32"
 // MIPSEL-ANDROID: "-mfloat-abi" "hard"
 
 // RUN: %clang -target mips64-linux-gnu -### -S %s 2>&1 | \


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


[PATCH] D20320: [libunwind] Improve unwinder stack usage - II

2016-05-17 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: jroelofs, bcraig.
rmaprath added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

This is a follow-up to D20119.

`unwind_phase1` and `unwind_phase2` allocate their own copies of `unw_cursor_t` 
buffers on the stack. This can blow-up stack usage of the unwinder depending on 
how these two functions get inlined into `_Unwind_RaiseException`. Clang seems 
to inline `unwind_phase1` into `_Unwind_RaiseException` but not 
`unwind_phase2`, thus creating two `unw_cursor_t` buffers on the stack. 

One way to work-around this problem is to mark both `unwind_phase1` and 
`unwind_phase2` as noinline. I chose to take the less macro-dependent approach 
and explicitly allocate a `unw_cursor_t` buffer and pass that into 
`unwind_phase1` and `unwind_phase2` functions.

This shaves off about ~1000 bytes of stack usage on ARM targets.

The current patch together with D20119, shaves off about roughly 2KB of stack 
usage.

http://reviews.llvm.org/D20320

Files:
  src/Unwind-EHABI.cpp

Index: src/Unwind-EHABI.cpp
===
--- src/Unwind-EHABI.cpp
+++ src/Unwind-EHABI.cpp
@@ -438,23 +438,22 @@
 }
 
 static _Unwind_Reason_Code
-unwind_phase1(unw_context_t *uc, _Unwind_Exception *exception_object) {
+unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
   // EHABI #7.3 discusses preserving the VRS in a "temporary VRS" during
   // phase 1 and then restoring it to the "primary VRS" for phase 2. The
   // effect is phase 2 doesn't see any of the VRS manipulations from phase 1.
   // In this implementation, the phases don't share the VRS backing store.
   // Instead, they are passed the original |uc| and they create a new VRS
   // from scratch thus achieving the same effect.
-  unw_cursor_t cursor1;
-  unw_init_local(&cursor1, uc);
+  unw_init_local(cursor, uc);
 
   // Walk each frame looking for a place to stop.
   for (bool handlerNotFound = true; handlerNotFound;) {
 
 #if !_LIBUNWIND_ARM_EHABI
 // Ask libuwind to get next frame (skip over first which is
 // _Unwind_RaiseException).
-int stepResult = unw_step(&cursor1);
+int stepResult = unw_step(cursor);
 if (stepResult == 0) {
   _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step() reached "
  "bottom => _URC_END_OF_STACK\n",
@@ -470,7 +469,7 @@
 
 // See if frame has code to run (has personality routine).
 unw_proc_info_t frameInfo;
-if (unw_get_proc_info(&cursor1, &frameInfo) != UNW_ESUCCESS) {
+if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
   _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_get_proc_info "
  "failed => _URC_FATAL_PHASE1_ERROR\n",
  static_cast(exception_object));
@@ -482,12 +481,12 @@
   char functionBuf[512];
   const char *functionName = functionBuf;
   unw_word_t offset;
-  if ((unw_get_proc_name(&cursor1, functionBuf, sizeof(functionBuf),
+  if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
  &offset) != UNW_ESUCCESS) ||
   (frameInfo.start_ip + offset > frameInfo.end_ip))
 functionName = ".anonymous.";
   unw_word_t pc;
-  unw_get_reg(&cursor1, UNW_REG_IP, &pc);
+  unw_get_reg(cursor, UNW_REG_IP, &pc);
   _LIBUNWIND_TRACE_UNWINDING(
   "unwind_phase1(ex_ojb=%p): pc=0x%llX, start_ip=0x%llX, func=%s, "
   "lsda=0x%llX, personality=0x%llX\n",
@@ -505,7 +504,7 @@
   "unwind_phase1(ex_ojb=%p): calling personality function %p\n",
   static_cast(exception_object),
   reinterpret_cast(reinterpret_cast(p)));
-  struct _Unwind_Context *context = (struct _Unwind_Context *)(&cursor1);
+  struct _Unwind_Context *context = (struct _Unwind_Context *)(cursor);
   exception_object->pr_cache.fnstart = frameInfo.start_ip;
   exception_object->pr_cache.ehtp =
   (_Unwind_EHT_Header *)frameInfo.unwind_info;
@@ -553,12 +552,11 @@
   return _URC_NO_REASON;
 }
 
-static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc,
+static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor,
  _Unwind_Exception *exception_object,
  bool resume) {
   // See comment at the start of unwind_phase1 regarding VRS integrity.
-  unw_cursor_t cursor2;
-  unw_init_local(&cursor2, uc);
+  unw_init_local(cursor, uc);
 
   _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)\n",
  static_cast(exception_object));
@@ -580,13 +578,13 @@
   // for. After this, continue unwinding as if normal.
   //
   // See #7.4.6 for details.
-  unw_set_reg(&cursor2, UNW_REG_IP,
+  unw_set_reg(cursor, UNW_REG_IP,
   exception_object->unwinder_cache.reser

[PATCH] D20321: [Clang][AVX512][intrinsics] Fix vperm intrinsics.

2016-05-17 Thread Igor Breger via cfe-commits
igorb created this revision.
igorb added reviewers: m_zuckerman, AsafBadouh, delena.
igorb added a subscriber: cfe-commits.
igorb set the repository for this revision to rL LLVM.

[Clang][AVX512][intrinsics]  Fix vperm{w|d|q|ps|pd}  intrinsics. Index is first 
argument to buildin function.

Repository:
  rL LLVM

http://reviews.llvm.org/D20321

Files:
  lib/Headers/avx512bwintrin.h
  lib/Headers/avx512fintrin.h
  lib/Headers/avx512vlbwintrin.h
  lib/Headers/avx512vlintrin.h

Index: lib/Headers/avx512vlintrin.h
===
--- lib/Headers/avx512vlintrin.h
+++ lib/Headers/avx512vlintrin.h
@@ -9100,111 +9100,111 @@
 static __inline__ __m256d __DEFAULT_FN_ATTRS
 _mm256_permutexvar_pd (__m256i __X, __m256d __Y)
 {
-  return (__m256d) __builtin_ia32_permvardf256_mask ((__v4df) __Y,
- (__v4di) __X,
+  return (__m256d) __builtin_ia32_permvardf256_mask ((__v4df) __X /* idx */,
+ (__v4di) __Y,
  (__v4df) _mm256_undefined_si256 (),
  (__mmask8) -1);
 }
 
 static __inline__ __m256d __DEFAULT_FN_ATTRS
 _mm256_mask_permutexvar_pd (__m256d __W, __mmask8 __U, __m256i __X,
   __m256d __Y)
 {
-  return (__m256d) __builtin_ia32_permvardf256_mask ((__v4df) __Y,
- (__v4di) __X,
+  return (__m256d) __builtin_ia32_permvardf256_mask ((__v4df) __X /* idx */,
+ (__v4di) __Y,
  (__v4df) __W,
  (__mmask8) __U);
 }
 
 static __inline__ __m256d __DEFAULT_FN_ATTRS
 _mm256_maskz_permutexvar_pd (__mmask8 __U, __m256i __X, __m256d __Y)
 {
-  return (__m256d) __builtin_ia32_permvardf256_mask ((__v4df) __Y,
- (__v4di) __X,
+  return (__m256d) __builtin_ia32_permvardf256_mask ((__v4df) __X /* idx */,
+ (__v4di) __Y,
  (__v4df) _mm256_setzero_pd (),
  (__mmask8) __U);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_maskz_permutexvar_epi64 (__mmask8 __M, __m256i __X, __m256i __Y)
 {
-  return (__m256i) __builtin_ia32_permvardi256_mask ((__v4di) __Y,
- (__v4di) __X,
+  return (__m256i) __builtin_ia32_permvardi256_mask ((__v4di) __X /* idx */,
+ (__v4di) __Y,
  (__v4di) _mm256_setzero_si256 (),
  (__mmask8) __M);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_permutexvar_epi64 (__mmask8 __M, __m256i __X, __m256i __Y)
 {
-  return (__m256i) __builtin_ia32_permvardi256_mask ((__v4di) __Y,
- (__v4di) __X,
+  return (__m256i) __builtin_ia32_permvardi256_mask ((__v4di) __X /* idx */,
+ (__v4di) __Y,
  (__v4di) _mm256_undefined_si256 (),
  (__mmask8) -1);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_mask_permutexvar_epi64 (__m256i __W, __mmask8 __M, __m256i __X,
  __m256i __Y)
 {
-  return (__m256i) __builtin_ia32_permvardi256_mask ((__v4di) __Y,
- (__v4di) __X,
+  return (__m256i) __builtin_ia32_permvardi256_mask ((__v4di) __X /* idx */,
+ (__v4di) __Y,
  (__v4di) __W,
  __M);
 }
 
 static __inline__ __m256 __DEFAULT_FN_ATTRS
 _mm256_mask_permutexvar_ps (__m256 __W, __mmask8 __U, __m256i __X,
   __m256 __Y)
 {
-  return (__m256) __builtin_ia32_permvarsf256_mask ((__v8sf) __Y,
-(__v8si) __X,
+  return (__m256) __builtin_ia32_permvarsf256_mask ((__v8sf) __X /* idx */,
+(__v8si) __Y,
 (__v8sf) __W,
 (__mmask8) __U);
 }
 
 static __inline__ __m256 __DEFAULT_FN_ATTRS
 _mm256_maskz_permutexvar_ps (__mmask8 __U, __m256i __X, __m256 __Y)
 {
-  return (__m256) __builtin_ia32_permvarsf256_mask ((__v8sf) __Y,
-(__v8si) __X,
+  return (__m256) __builtin_ia32_permvarsf256_mask ((__v8sf) __X /* idx */,
+(__v8si) __Y,
 (__v8sf) _mm256_setzero_ps (),
 (__mmask8) __U);
 }
 
 static __inline__ __m256 __DEFAULT_FN_ATTRS
 _mm256_permutexvar_ps (__m256i __X, __m256 __Y)
 {
-  return (__m256) __builtin_ia32_permvarsf256_mask ((__v8sf) __Y,
-(__v8si) __X,
+  return (__m256) __builtin_ia32_permvarsf256_mask ((__v8sf) __X /* idx */,
+(__v8si) __Y,
 (__v8sf) _mm256_undefined_si256 (),
 (__mmask8) -1);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_maskz_permutexvar_epi32 (__mmask8 __M, __m256i __X, __m256i __Y)
 {
-  return (__m256i) __builtin_ia32_permvarsi256_mask ((__v8si) __Y,
- (__v8si) __X,
+  return (__m256i) __builtin_ia32_permvarsi256_mask ((__v8si) __X /* idx */,
+ (__v8si) __Y,
  (__v8si) _mm256_setzero_si256 (),
  __M);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_mask_permutexvar_epi32 (__m256i __W, __mmask8 __M, __m256i __X,
  __m256i __Y)
 {
-  return (__m256i) __builtin_ia32_pe

Re: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

2016-05-17 Thread Jeroen Ketema via cfe-commits

Hi,

The below commit enables all OpenCL extensions for the SPIR target by default. 
This incorrect, as SPIR allows you to specify which extensions are 
enabled/disabled its metadata. This means that any SPIR generated by Clang may 
now be rejected by specific OpenCL platforms, because they might not support 
all extensions.

If possible I would like to see this commit reverted until that problem has 
been addressed.

Regards,

Jeroen

> On 16 May 2016, at 18:06, Yaxun Liu via cfe-commits  lists.llvm.org> wrote:
> 
> Author: yaxunl
> Date: Mon May 16 12:06:34 2016
> New Revision: 269670
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=269670&view=rev
> Log:
> [OpenCL] Add supported OpenCL extensions to target info.
> 
> Add supported OpenCL extensions to target info. It serves as default values 
> to save the users of the burden setting each supported extensions and 
> optional core features in command line.
> 
> Re-commit after fixing build error due to missing override attribute.
> 
> Differential Revision: http://reviews.llvm.org/D19484
> 
> Added:
>   cfe/trunk/include/clang/Basic/OpenCLOptions.h
>   cfe/trunk/test/SemaOpenCL/extensions.cl
> Removed:
>   cfe/trunk/test/SemaOpenCL/extension-fp64-cl1.1.cl
>   cfe/trunk/test/SemaOpenCL/extension-fp64.cl
>   cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl1.2.cl
>   cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl2.0.cl
> Modified:
>   cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
>   cfe/trunk/include/clang/Basic/LangOptions.h
>   cfe/trunk/include/clang/Basic/OpenCLExtensions.def
>   cfe/trunk/include/clang/Basic/TargetInfo.h
>   cfe/trunk/include/clang/Basic/TargetOptions.h
>   cfe/trunk/lib/Basic/Targets.cpp
>   cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>   cfe/trunk/lib/Parse/ParsePragma.cpp
>   cfe/trunk/lib/Sema/Sema.cpp
>   cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl
>   cfe/trunk/test/CodeGenOpenCL/fpmath.cl
>   cfe/trunk/test/CodeGenOpenCL/half.cl
>   cfe/trunk/test/Lexer/opencl-half-literal.cl
>   cfe/trunk/test/Misc/languageOptsOpenCL.cl
>   cfe/trunk/test/PCH/opencl-extensions.cl
>   cfe/trunk/test/Parser/opencl-astype.cl
>   cfe/trunk/test/Parser/opencl-atomics-cl20.cl
>   cfe/trunk/test/Parser/opencl-pragma.cl
>   cfe/trunk/test/Parser/opencl-storage-class.cl
>   cfe/trunk/test/SemaOpenCL/half.cl
>   cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl
>   cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl
> 
> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=269670&r1=269669&r2=269670&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon May 16 12:06:34 
> 2016
> @@ -926,6 +926,10 @@ def warn_pragma_expected_enable_disable
>  "expected 'enable' or 'disable' - ignoring">, InGroup;
> def warn_pragma_unknown_extension : Warning<
>  "unknown OpenCL extension %0 - ignoring">, InGroup;
> +def warn_pragma_unsupported_extension : Warning<
> +  "unsupported OpenCL extension %0 - ignoring">, InGroup;
> +def warn_pragma_extension_is_core : Warning<
> +  "OpenCL extension %0 is core feature or supported optional core feature - 
> ignoring">, InGroup;
> 
> // OpenCL errors.
> def err_opencl_taking_function_address_parser : Error<
> 
> Modified: cfe/trunk/include/clang/Basic/LangOptions.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=269670&r1=269669&r2=269670&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/LangOptions.h (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.h Mon May 16 12:06:34 2016
> @@ -160,18 +160,6 @@ public:
>fp_contract(LangOpts.DefaultFPContract) {}
> };
> 
> -/// \brief OpenCL volatile options
> -class OpenCLOptions {
> -public:
> -#define OPENCLEXT(nm)  unsigned nm : 1;
> -#include "clang/Basic/OpenCLExtensions.def"
> -
> -  OpenCLOptions() {
> -#define OPENCLEXT(nm)   nm = 0;
> -#include "clang/Basic/OpenCLExtensions.def"
> -  }
> -};
> -
> /// \brief Describes the kind of translation unit being processed.
> enum TranslationUnitKind {
>  /// \brief The translation unit is a complete translation unit.
> 
> Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLExtensions.def?rev=269670&r1=269669&r2=269670&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original)
> +++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Mon May 16 12:06:34 
> 2016
> @@ -11,25 +11,67 @@
> //
> //===--===//
> 
> +// Macro OPENCLEXT or OPENCLEXT_INTERNAL can be d

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

2016-05-17 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Looking good already! I just have one general concern about committing 16K 
lines of code with no tests. But perhaps testing all the declarations isn't an 
option actually.

Could we at least have a test that includes the header and makes sure it's 
compiled successfully. Any thought's on this?

Also I can see that other headers are added to lib/Headers/CMakeLists.txt.


http://reviews.llvm.org/D18369



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


Re: r263795 - Add -fnative-half-arguments-and-returns

2016-05-17 Thread Jeroen Ketema via cfe-commits
Hi,

The below commit is, as it enables half arguments and returns by default for 
OpenCL, while this is actually an extension that might not be supported on all 
platforms. I think that this part of the commit should be reverted:

> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Mar 18 11:58:36 2016
> @@ -1434,6 +1434,7 @@ void CompilerInvocation::setLangDefaults
> Opts.LaxVectorConversions = 0;
> Opts.DefaultFPContract = 1;
> Opts.NativeHalfType = 1;
> +Opts.NativeHalfArgsAndReturns = 1;
>   }


Best,

 Jeroen


> On 18 Mar 2016, at 16:58, Pirama Arumuga Nainar via cfe-commits  at lists.llvm.org> wrote:
> 
> Author: pirama
> Date: Fri Mar 18 11:58:36 2016
> New Revision: 263795
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=263795&view=rev
> Log:
> Add -fnative-half-arguments-and-returns
> 
> Summary:
> r246764 handled __fp16 arguments and returns for AAPCS, but skipped this
> handling for OpenCL.  Simlar to OpenCL, RenderScript also handles __fp16
> type natively.
> 
> This patch adds the -fnative-half-arguments-and-returns command line
> flag to allow such languages to skip this coercion of __fp16.
> 
> Reviewers: srhines, olista01
> 
> Subscribers: cfe-commits
> 
> Differential Revision: http://reviews.llvm.org/D18138
> 
> Modified:
>cfe/trunk/include/clang/Basic/LangOptions.def
>cfe/trunk/include/clang/Driver/CC1Options.td
>cfe/trunk/lib/CodeGen/TargetInfo.cpp
>cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>cfe/trunk/test/CodeGen/arm-fp16-arguments.c
> 
> Modified: cfe/trunk/include/clang/Basic/LangOptions.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=263795&r1=263794&r2=263795&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.def Fri Mar 18 11:58:36 2016
> @@ -163,6 +163,7 @@ LANGOPT(ShortEnums, 1, 0, "short
> LANGOPT(OpenCL, 1, 0, "OpenCL")
> LANGOPT(OpenCLVersion , 32, 0, "OpenCL version")
> LANGOPT(NativeHalfType, 1, 0, "Native half type support")
> +LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns")
> LANGOPT(HalfArgsAndReturns, 1, 0, "half args and returns")
> LANGOPT(CUDA  , 1, 0, "CUDA")
> LANGOPT(OpenMP, 1, 0, "OpenMP support")
> 
> Modified: cfe/trunk/include/clang/Driver/CC1Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=263795&r1=263794&r2=263795&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/CC1Options.td (original)
> +++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Mar 18 11:58:36 2016
> @@ -603,6 +603,8 @@ def fno_rtti_data : Flag<["-"], "fno-rtt
>   HelpText<"Control emission of RTTI data">;
> def fnative_half_type: Flag<["-"], "fnative-half-type">,
>   HelpText<"Use the native half type for __fp16 instead of promoting to 
> float">;
> +def fnative_half_arguments_and_returns : Flag<["-"], 
> "fnative-half-arguments-and-returns">,
> +  HelpText<"Use the native __fp16 type for arguments and returns (and skip 
> ABI-specific lowering)">;
> def fallow_half_arguments_and_returns : Flag<["-"], 
> "fallow-half-arguments-and-returns">,
>   HelpText<"Allow function arguments and returns of type half">;
> 
> 
> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=263795&r1=263794&r2=263795&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Mar 18 11:58:36 2016
> @@ -5106,7 +5106,7 @@ ABIArgInfo ARMABIInfo::classifyArgumentT
>   // __fp16 gets passed as if it were an int or float, but with the top 16 
> bits
>   // unspecified. This is not done for OpenCL as it handles the half type
>   // natively, and does not need to interwork with AAPCS code.
> -  if (Ty->isHalfType() && !getContext().getLangOpts().OpenCL) {
> +  if (Ty->isHalfType() && 
> !getContext().getLangOpts().NativeHalfArgsAndReturns) {
> llvm::Type *ResType = IsEffectivelyAAPCS_VFP ?
>   llvm::Type::getFloatTy(getVMContext()) :
>   llvm::Type::getInt32Ty(getVMContext());
> @@ -5298,7 +5298,7 @@ ABIArgInfo ARMABIInfo::classifyReturnTyp
>   // __fp16 gets returned as if it were an int or float, but with the top 16
>   // bits unspecified. This is not done for OpenCL as it handles the half type
>   // natively, and does not need to interwork with AAPCS code.
> -  if (RetTy->isHalfType() && !getContext().getLangOpts().OpenCL) {
> +  if (RetTy->isHalfType() && 
> !getContext().getLangOpts().NativeHalfArgsAndReturns) {
> llvm::Type *ResType = IsEffectivelyAAPCS_VFP ?
>   llvm::Typ

Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-05-17 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 57462.
courbet added a comment.

Use iterator_range instead of ArrayRef for overridden_methods


http://reviews.llvm.org/D19324

Files:
  docs/LibASTMatchersReference.html
  include/clang/AST/ASTContext.h
  include/clang/AST/DeclCXX.h
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTContext.cpp
  lib/AST/DeclCXX.cpp
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2085,6 +2085,50 @@
   notMatches("class X { virtual void f(); };", cxxMethodDecl(isFinal(;
 }
 
+TEST(Matcher, ForEachOverriden) {
+  const auto ForEachOverriddenInClass = [](const char *ClassName) {
+return cxxMethodDecl(ofClass(hasName(ClassName)), isVirtual(),
+ forEachOverridden(cxxMethodDecl().bind("overridden")))
+.bind("override");
+  };
+  constexpr const char Code1[] = "class A { virtual void f(); };"
+ "class B : public A { void f(); };"
+ "class C : public B { void f(); };";
+  // C::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // B::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // A::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code1, ForEachOverriddenInClass("A")));
+
+  constexpr const char Code2[] =
+  "class A1 { virtual void f(); };"
+  "class A2 { virtual void f(); };"
+  "class B : public A1, public A2 { void f(); };";
+  // B::f overrides A1::f and A2::f. This produces two matches.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  2)));
+  // A1::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code2, ForEachOverriddenInClass("A1")));
+}
+
 TEST(Matcher, MatchesVirtualMethod) {
   EXPECT_TRUE(matches("class X { virtual int f(); };",
   cxxMethodDecl(isVirtual(), hasName("::X::f";
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -182,6 +182,7 @@
   REGISTER_MATCHER(forEachArgumentWithParam);
   REGISTER_MATCHER(forEachConstructorInitializer);
   REGISTER_MATCHER(forEachDescendant);
+  REGISTER_MATCHER(forEachOverridden);
   REGISTER_MATCHER(forEachSwitchCase);
   REGISTER_MATCHER(forField);
   REGISTER_MATCHER(forFunction);
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1622,6 +1622,13 @@
   return getASTContext().overridden_methods_size(this);
 }
 
+CXXMethodDecl::overridden_method_range
+CXXMethodDecl::overridden_methods() const {
+  if (isa(this))
+return overridden_method_range(nullptr, nullptr);
+  return getASTContext().overridden_methods(this);
+}
+
 QualType CXXMethodDecl::getThisType(ASTContext &C) const {
   // C++ 9.3.2p1: The type of this in a member function of a class X is X*.
   // If the member function is declared const, the type of this is const X*,
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1260,33 +1260,36 @@
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_begin(const CXXMethodDecl *Method) const {
   llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
+  = OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
 return nullptr;
-
   return Pos->second.begin();
 }
 
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_end(const CXXMethodDecl *Method) const {
   llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
+  = OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
 return nullptr;
-
   return Pos->second.end();
 }
 
 unsigned
 

[clang-tools-extra] r269758 - [include-fixer] Make the "extend to the right" hack support typos without nested names in the front.

2016-05-17 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue May 17 07:35:18 2016
New Revision: 269758

URL: http://llvm.org/viewvc/llvm-project?rev=269758&view=rev
Log:
[include-fixer] Make the "extend to the right" hack support typos without 
nested names in the front.

This handles cases where the initial namespace is unknown.

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=269758&r1=269757&r2=269758&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Tue May 17 07:35:18 
2016
@@ -129,11 +129,7 @@ public:
   }
 }
 
-/// If we have a scope specification, use that to get more precise results.
-std::string QueryString;
-if (SS && SS->getRange().isValid()) {
-  auto Range = CharSourceRange::getTokenRange(SS->getRange().getBegin(),
-  Typo.getLoc());
+auto ExtendNestedNameSpecifier = [this](CharSourceRange Range) {
   StringRef Source =
   Lexer::getSourceText(Range, getCompilerInstance().getSourceManager(),
getCompilerInstance().getLangOpts());
@@ -158,7 +154,21 @@ public:
   while (isIdentifierBody(*End) || *End == ':')
 ++End;
 
-  QueryString = std::string(Source.begin(), End);
+  return std::string(Source.begin(), End);
+};
+
+/// If we have a scope specification, use that to get more precise results.
+std::string QueryString;
+if (SS && SS->getRange().isValid()) {
+  auto Range = CharSourceRange::getTokenRange(SS->getRange().getBegin(),
+  Typo.getLoc());
+
+  QueryString = ExtendNestedNameSpecifier(Range);
+} else if (Typo.getName().isIdentifier() && !Typo.getLoc().isMacroID()) {
+  auto Range =
+  CharSourceRange::getTokenRange(Typo.getBeginLoc(), Typo.getEndLoc());
+
+  QueryString = ExtendNestedNameSpecifier(Range);
 } else {
   QueryString = Typo.getAsString();
 }

Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=269758&r1=269757&r2=269758&view=diff
==
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Tue 
May 17 07:35:18 2016
@@ -126,10 +126,20 @@ TEST(IncludeFixer, MinimizeInclude) {
 runIncludeFixer("a::b::foo bar;\n", IncludePath));
 }
 
-#if 0
+#ifndef _WIN32
 // It doesn't pass for targeting win32. Investigating.
 TEST(IncludeFixer, NestedName) {
   EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n"
+"int x = a::b::foo(0);\n",
+runIncludeFixer("int x = a::b::foo(0);\n"));
+
+  // FIXME: Handle simple macros.
+  EXPECT_EQ("#define FOO a::b::foo\nint x = FOO;\n",
+runIncludeFixer("#define FOO a::b::foo\nint x = FOO;\n"));
+  EXPECT_EQ("#define FOO(x) a::##x\nint x = FOO(b::foo);\n",
+runIncludeFixer("#define FOO(x) a::##x\nint x = FOO(b::foo);\n"));
+
+  EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n"
 "namespace a {}\nint a = a::b::foo(0);\n",
 runIncludeFixer("namespace a {}\nint a = a::b::foo(0);\n"));
 }


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


Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-05-17 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 one minor nit. Thank you for working on this!



Comment at: include/clang/ASTMatchers/ASTMatchers.h:3724
@@ +3723,3 @@
+  bool Matched = false;
+  for (const auto* Overridden : Node.overridden_methods()) {
+BoundNodesTreeBuilder OverriddenBuilder(*Builder);

Nit: the * should bind to Overridden instead of auto. (May just want to 
clang-format the patch.)


http://reviews.llvm.org/D19324



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


Re: [PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications

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


Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:39
@@ +38,3 @@
+
+  // FIXME: Add paren matching so we can parse more complex throw statements,
+  // e.g., (examples provided by Aaron Ballman):

@alexfh, what are your feelings on this FIXME? I am a bit concerned because 
these examples will cause the replacement range to be incorrect, which will 
turn working code into ill-formed code. The alternative, as I see it, is to 
instead properly track the exception specification source range information as 
part of the FunctionDecl (akin to `FunctionDecl::getReturnTypeSourceRange()`).


Comment at: docs/clang-tidy/checks/modernize-use-noexcept.rst:40
@@ +39,3 @@
+``noexcept(false)`` not ``noexcept``, this check will detect, but not
+provide a FixItHint in that case.
+

This seems to run contrary to one of the examples below where a fixit is 
provided for ``throw(A, B)``. If I understood properly, this statement is only 
true when using a ReplacementString. Perhaps it should instead say, "this check 
will detect, but not
provide a FixItHint for this case when a :option:`ReplacementString` is 
provided."


http://reviews.llvm.org/D18575



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


Re: [PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0

2016-05-17 Thread Pekka Jääskeläinen via cfe-commits
pekka.jaaskelainen added a comment.

LGTM, FWIW.


http://reviews.llvm.org/D20249



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


[PATCH] D20328: [libcxx] Externally threaded libc++ variant

2016-05-17 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: mclow.lists, EricWF, bcraig.
rmaprath added a subscriber: cfe-commits.

This patch builds on the work done under D19412 where all `pthread` 
dependencies were refactored under a separate thread-support API.

The current patch enables building a new variant of libc++ where all the 
threading dependencies are exported into a runtime API. This allows platform 
vendors to  re-target these threading calls in a platform-defined manner (at 
runtime), paving the way for libc++ on non-pthread platforms.

For running the libc++ test suite, I've introduced a sample implementation of 
this external-thread-API using pthreads. This implementation should give an 
idea of what the end goal is.

This patch supersedes the sketch presented in D19415.

http://reviews.llvm.org/D20328

Files:
  CMakeLists.txt
  include/__config
  include/__config_site.in
  include/__threading_support
  include/thread
  lib/CMakeLists.txt
  src/algorithm.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp
  test/CMakeLists.txt
  test/libcxx/test/config.py
  test/lit.site.cfg.in
  
test/std/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
  
test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
  
test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
  test/std/thread/thread.threads/thread.thread.class/types.pass.cpp
  test/support/external_threads.cpp

Index: test/support/external_threads.cpp
===
--- /dev/null
+++ test/support/external_threads.cpp
@@ -0,0 +1,328 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+#ifndef SUPPORT_EXTERNAL_THREADS_HPP
+#define SUPPORT_EXTERNAL_THREADS_HPP
+
+#include <__threading_support>
+#include 
+#include 
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+/* In the pthread-based (or statically-threaded) libc++ variant, pthread
+   primitives (like pthread_mutex_t) become part of the internal states of the
+   corresponding C++ constructs (e.g. C++ mutex class holds an internal
+   pthread_mutex_t object). In contrast, in the externally-threaded libc++
+   variant, C++ constructs hold (opaque) pointers to the underlying platform-
+   defined threading primitives. The following macros are used to convert the
+   opaque pointer types held within the C++ constructs and cast them as pointers
+   to the appropriate platform-defined thread primitive type (in this case,
+   pthread types again).
+*/
+#define AS_PTHREAD_MUTPTR(x) reinterpret_cast(x)
+#define AS_PTHREAD_CONDPTR(x) reinterpret_cast(x)
+#define AS_PTHREAD_TPTR(x) reinterpret_cast(x)
+#define AS_PTHREAD_KPTR(x) reinterpret_cast(x)
+
+//-- Mutex --//
+
+/* This method is invoked from within the std::recursive_mutex constructor, as
+   such, it does not need to be thread-safe when initializing the *__m pointer.
+*/
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m)
+{
+// Populate the internal opaque pointer *__m
+pthread_mutex_t *mut = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t));
+if (mut == nullptr)
+return -1;
+*__m = reinterpret_cast<__libcpp_mutex_t> (mut);
+
+// Initialize the allocated pthread_mutex_t object as a recursive mutex
+pthread_mutexattr_t attr;
+int __ec = pthread_mutexattr_init(&attr);
+if (__ec)
+  goto fail;
+
+__ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+if (__ec)
+{
+pthread_mutexattr_destroy(&attr);
+goto fail;
+}
+
+__ec = pthread_mutex_init(AS_PTHREAD_MUTPTR(*__m), &attr);
+if (__ec)
+{
+pthread_mutexattr_destroy(&attr);
+goto fail;
+}
+
+__ec = pthread_mutexattr_destroy(&attr);
+if (__ec)
+{
+pthread_mutex_destroy(AS_PTHREAD_MUTPTR(*__m));
+goto fail;
+}
+
+return 0;
+
+fail:
+free(*__m);
+return __ec;
+}
+
+/* C++11 standard requires mutex and condition_variable constructors to be
+   constexpr qualifying. This prohibits any prospects of calling a runtime
+   initialization routine from within mutex / condition_varialbe constructors.
+   For this reason, the external thread API must adopt an initialize-on-first-
+   use policy for mutexes and condition variables. With this strategy, we need
+   to be especially careful when initializing the internal opaque pointer *__m,
+   as multiple threads could attempt to lock the same mutex at once. In the
+   following r

Re: [PATCH] D19415: [libcxx][rfc] Externalized threading support

2016-05-17 Thread Asiri Rathnayake via cfe-commits
rmaprath abandoned this revision.
rmaprath added a comment.

Superseded by http://reviews.llvm.org/D20328.


http://reviews.llvm.org/D19415



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


Re: [PATCH] D20325: Add ARM cdp intrinsics

2016-05-17 Thread Renato Golin via cfe-commits
rengolin requested changes to this revision.
rengolin added a comment.
This revision now requires changes to proceed.

Please, re-submit this change once the documents have been made public.

Feel free to submit the assembly test to LLVM, using llc, on their own.

cheers,
--renato



Comment at: include/clang/Basic/BuiltinsARM.def:55
@@ -54,3 +54,3 @@
 BUILTIN(__builtin_arm_mrc2, "UiUIiUIiUIiUIiUIi", "")
-BUILTIN(__builtin_arm_cdp, "vUiUiUiUiUiUi", "")
-BUILTIN(__builtin_arm_cdp2, "vUiUiUiUiUiUi", "")
+BUILTIN(__builtin_arm_cdp, "vUIiUIiUIiUIiUIiUIi", "")
+BUILTIN(__builtin_arm_cdp2, "vUIiUIiUIiUIiUIiUIi", "")

I wonder why the old signature was wrong... probably because the docs weren't 
public and no one could really check whether they were right or not. I don't 
want to repeat the same mistake.


Comment at: test/CodeGen/arm-coproc-intrinsics.c:1
@@ +1,2 @@
+// RUN: %clang_cc1 -Wall -triple thumbv7-eabi -target-cpu cortex-a8 -S -o - %s 
| FileCheck %s
+

Please, do not add assembly tests in Clang. This test should be in LLVM.


Repository:
  rL LLVM

http://reviews.llvm.org/D20325



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


[clang-tools-extra] r269762 - [find-all-symbols] Ignore anonymous enum declarations.

2016-05-17 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue May 17 08:38:18 2016
New Revision: 269762

URL: http://llvm.org/viewvc/llvm-project?rev=269762&view=rev
Log:
[find-all-symbols] Ignore anonymous enum declarations.

Modified:
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp

clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp?rev=269762&r1=269761&r2=269762&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp 
Tue May 17 08:38:18 2016
@@ -69,6 +69,9 @@ llvm::Optional CreateSymbolI
 Type = SymbolInfo::SymbolKind::EnumConstantDecl;
   } else if (llvm::isa(ND)) {
 Type = SymbolInfo::SymbolKind::EnumDecl;
+// Ignore anonymous enum declarations.
+if (ND->getName().empty())
+  return llvm::None;
   } else {
 assert(llvm::isa(ND) &&
"Matched decl must be one of VarDecl, "

Modified: 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp?rev=269762&r1=269761&r2=269762&view=diff
==
--- 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
 (original)
+++ 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
 Tue May 17 08:38:18 2016
@@ -316,6 +316,8 @@ TEST_F(FindAllSymbolsTest, EnumTest) {
   Symbol = SymbolInfo("A2", SymbolInfo::SymbolKind::EnumConstantDecl,
   HeaderName, 4, {{SymbolInfo::ContextType::EnumDecl, 
""}});
   EXPECT_TRUE(hasSymbol(Symbol));
+  Symbol = SymbolInfo("", SymbolInfo::SymbolKind::EnumDecl, HeaderName, 4, {});
+  EXPECT_FALSE(hasSymbol(Symbol));
 
   Symbol = SymbolInfo("A_ENUM", SymbolInfo::SymbolKind::EnumDecl, HeaderName, 
7,
   {{SymbolInfo::ContextType::Record, "A"}});


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


Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-17 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57472.
hokein added a comment.

Rebase.


http://reviews.llvm.org/D19816

Files:
  include-fixer/find-all-symbols/CMakeLists.txt
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/HeaderMapCollector.h
  include-fixer/find-all-symbols/PragmaCommentHandler.cpp
  include-fixer/find-all-symbols/PragmaCommentHandler.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -8,11 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -50,25 +53,58 @@
   std::vector Symbols;
 };
 
+class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
+  : MatchFinder(), Collector(), Handler(&Collector),
+Matcher(Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &Compiler,
+StringRef InFile) override {
+Compiler.getPreprocessor().addCommentHandler(&Handler);
+return MatchFinder.newASTConsumer();
+  }
+
+private:
+  ast_matchers::MatchFinder MatchFinder;
+  HeaderMapCollector Collector;
+  PragmaCommentHandler Handler;
+  FindAllSymbols Matcher;
+};
+
+class TestFindAllSymbolsActionFactory
+: public clang::tooling::FrontendActionFactory {
+public:
+  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  : Reporter(Reporter) {}
+  clang::FrontendAction *create() override {
+return new TestFindAllSymbolsAction(Reporter);
+  }
+
+private:
+  MockReporter *const Reporter;
+};
+
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
 return Reporter.hasSymbol(Symbol);
   }
 
   bool runFindAllSymbols(StringRef Code) {
-FindAllSymbols matcher(&Reporter);
-clang::ast_matchers::MatchFinder MatchFinder;
-matcher.registerMatchers(&MatchFinder);
-
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
 new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
 std::string FileName = "symbol.cc";
-std::unique_ptr Factory =
-clang::tooling::newFrontendActionFactory(&MatchFinder);
+
+std::unique_ptr Factory(
+new TestFindAllSymbolsActionFactory(&Reporter));
+
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
  std::string("-std=c++11"), FileName},
@@ -327,5 +363,18 @@
   EXPECT_FALSE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, IWYUPrivatePragmaTest) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+struct Bar {
+};
+  )";
+  runFindAllSymbols(Code);
+
+  SymbolInfo Symbol =
+  CreateSymbolInfo("Bar", SymbolInfo::Class, "bar.h", 3, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -8,8 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -82,6 +88,31 @@
   std::map> Symbols;
 };
 
+class FindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  FindAllSymbolsAction()
+  : Reporter(), MatchFinder(), Collector(), Handler(&Collector),
+Matcher(&Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+  std::

Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-05-17 Thread Clement Courbet via cfe-commits
courbet added a comment.

Thanks. Could please you submit this for me ?



Comment at: include/clang/ASTMatchers/ASTMatchers.h:3724
@@ +3723,3 @@
+  bool Matched = false;
+  for (const auto *Overridden : Node.overridden_methods()) {
+BoundNodesTreeBuilder OverriddenBuilder(*Builder);

Thanks for the catch. Unfortunately there are a lot of errors in the file that 
prevent me to run clang-format. Any hint to handle that efficiently ?


http://reviews.llvm.org/D19324



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


Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-05-17 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 57473.
courbet added a comment.

cometics


http://reviews.llvm.org/D19324

Files:
  docs/LibASTMatchersReference.html
  include/clang/AST/ASTContext.h
  include/clang/AST/DeclCXX.h
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTContext.cpp
  lib/AST/DeclCXX.cpp
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2085,6 +2085,50 @@
   notMatches("class X { virtual void f(); };", cxxMethodDecl(isFinal(;
 }
 
+TEST(Matcher, ForEachOverriden) {
+  const auto ForEachOverriddenInClass = [](const char *ClassName) {
+return cxxMethodDecl(ofClass(hasName(ClassName)), isVirtual(),
+ forEachOverridden(cxxMethodDecl().bind("overridden")))
+.bind("override");
+  };
+  constexpr const char Code1[] = "class A { virtual void f(); };"
+ "class B : public A { void f(); };"
+ "class C : public B { void f(); };";
+  // C::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // B::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // A::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code1, ForEachOverriddenInClass("A")));
+
+  constexpr const char Code2[] =
+  "class A1 { virtual void f(); };"
+  "class A2 { virtual void f(); };"
+  "class B : public A1, public A2 { void f(); };";
+  // B::f overrides A1::f and A2::f. This produces two matches.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  2)));
+  // A1::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code2, ForEachOverriddenInClass("A1")));
+}
+
 TEST(Matcher, MatchesVirtualMethod) {
   EXPECT_TRUE(matches("class X { virtual int f(); };",
   cxxMethodDecl(isVirtual(), hasName("::X::f";
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -182,6 +182,7 @@
   REGISTER_MATCHER(forEachArgumentWithParam);
   REGISTER_MATCHER(forEachConstructorInitializer);
   REGISTER_MATCHER(forEachDescendant);
+  REGISTER_MATCHER(forEachOverridden);
   REGISTER_MATCHER(forEachSwitchCase);
   REGISTER_MATCHER(forField);
   REGISTER_MATCHER(forFunction);
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1622,6 +1622,13 @@
   return getASTContext().overridden_methods_size(this);
 }
 
+CXXMethodDecl::overridden_method_range
+CXXMethodDecl::overridden_methods() const {
+  if (isa(this))
+return overridden_method_range(nullptr, nullptr);
+  return getASTContext().overridden_methods(this);
+}
+
 QualType CXXMethodDecl::getThisType(ASTContext &C) const {
   // C++ 9.3.2p1: The type of this in a member function of a class X is X*.
   // If the member function is declared const, the type of this is const X*,
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1260,33 +1260,36 @@
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_begin(const CXXMethodDecl *Method) const {
   llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
+  = OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
 return nullptr;
-
   return Pos->second.begin();
 }
 
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_end(const CXXMethodDecl *Method) const {
   llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
+  = OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
 return nullptr;
-
   return Pos->second.end();
 }
 
 unsigned
 ASTContext::overridden_methods_size(const CXXMethodDe

[PATCH] D20329: [clang-include-fixer] Added Vim integration for clang-include-fixer.

2016-05-17 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added reviewers: bkramer, hokein.
ioeric added a subscriber: cfe-commits.

[clang-include-fixer] Added Vim integration for clang-include-fixer.

http://reviews.llvm.org/D20329

Files:
  include-fixer/tool/ClangIncludeFixer.cpp
  include-fixer/tool/clang-include-fixer.py

Index: include-fixer/tool/clang-include-fixer.py
===
--- /dev/null
+++ include-fixer/tool/clang-include-fixer.py
@@ -0,0 +1,51 @@
+# This file is a minimal clang-include-fixer vim-integration. To install:
+# - Change 'binary' if clang-include-fixer is not on the path (see below).
+# - Add to your .vimrc:
+#
+#   map ,cf :pyf path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+#
+# This enables clang-include-fixer for NORMAL and VISUAL mode.
+#
+# To set up clang-include-fixer, see http://clang.llvm.org/extra/include-fixer.html
+#
+# With this integration you can press the bound key and clang-include-fixer will
+# be run on the current buffer.
+#
+# It operates on the current, potentially unsaved buffer and does not create
+# or save any files. To revert a fix, just undo.
+#
+# FIXME: in the current version, each invocation only fixes #include for one
+# unidentified symbol, and it simply inserts #include directive to the first
+# line.
+
+import subprocess
+import sys
+import vim
+
+# set g:clang_include_fixer_path to the path to clang-include-fixer if it is not
+# on the path.
+# Change this to the full path if clang-include-fixer is not on the path.
+binary = 'clang-include-fixer'
+if vim.eval('exists("g:clang_include_fixer_path")') == "1":
+  binary = vim.eval('g:clang_include_fixer_path')
+
+def main():
+  # Get the current text.
+  buf = vim.current.buffer
+  text = '\n'.join(buf)
+
+  # Call clang-include-fixer.
+  command = [binary, "-db=yaml", "-vim", vim.current.buffer.name]
+  p = subprocess.Popen(command,
+   stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+   stdin=subprocess.PIPE)
+  stdout, stderr = p.communicate(input=text)
+
+  # If successful, replace buffer contents.
+  if stderr:
+print stderr
+
+  if stdout:
+vim.current.buffer[0:0] = [stdout]
+
+main()
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -47,11 +47,36 @@
 cl::opt Quiet("q", cl::desc("Reduce terminal output"), cl::init(false),
 cl::cat(IncludeFixerCategory));
 
+cl::opt
+VimMode("vim",
+cl::desc("Run the tool on a potentially unsaved buffer from Vim"),
+cl::init(false), cl::cat(IncludeFixerCategory));
+
 int includeFixerMain(int argc, const char **argv) {
   tooling::CommonOptionsParser options(argc, argv, IncludeFixerCategory);
   tooling::ClangTool tool(options.getCompilations(),
   options.getSourcePathList());
 
+  // In VimMode, we override the file content with the vim buffer from .
+  // Since `tool.mapVirtualFile` takes `StringRef`, we define `Code` outside of
+  // the if-block so that `Code` is not released after the if-block.
+  std::unique_ptr Code;
+  if (VimMode) {
+assert(options.getSourcePathList().size() == 1 &&
+   "Expect exactly one file path from Vim.");
+llvm::ErrorOr> CodeOrErr =
+MemoryBuffer::getSTDIN();
+if (std::error_code EC = CodeOrErr.getError()) {
+  errs() << EC.message() << "\n";
+  return 1;
+}
+Code = std::move(CodeOrErr.get());
+if (Code->getBufferSize() == 0)
+  return 0;  // Skip empty files.
+
+tool.mapVirtualFile(options.getSourcePathList().front(), Code->getBuffer());
+  }
+
   // Set up data source.
   auto SymbolIndexMgr = llvm::make_unique();
   switch (DatabaseFormat) {
@@ -114,6 +139,12 @@
 for (const tooling::Replacement &Replacement : Replacements)
   llvm::errs() << "Added " << Replacement.getReplacementText();
 
+  if (VimMode) {
+for (const tooling::Replacement &Replacement : Replacements)
+  llvm::outs() << Replacement.getReplacementText();
+return 0;
+  }
+
   // Set up a new source manager for applying the resulting replacements.
   IntrusiveRefCntPtr DiagOpts(new DiagnosticOptions);
   DiagnosticsEngine Diagnostics(new DiagnosticIDs, &*DiagOpts);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20329: [clang-include-fixer] Added Vim integration for clang-include-fixer.

2016-05-17 Thread Benjamin Kramer via cfe-commits
bkramer added inline comments.


Comment at: include-fixer/tool/ClangIncludeFixer.cpp:51
@@ +50,3 @@
+cl::opt
+VimMode("vim",
+cl::desc("Run the tool on a potentially unsaved buffer from Vim"),

This isn't really specific to vim, we should name it differently. '-stdin' 
maybe? Then document what it really does.


Comment at: include-fixer/tool/clang-include-fixer.py:38
@@ +37,3 @@
+  # Call clang-include-fixer.
+  command = [binary, "-db=yaml", "-vim", vim.current.buffer.name]
+  p = subprocess.Popen(command,

yaml is the default, maybe we shouldn't specify it here? Or leave the user a 
way to configure it.


Comment at: include-fixer/tool/clang-include-fixer.py:49
@@ +48,3 @@
+  if stdout:
+vim.current.buffer[0:0] = [stdout]
+

This always inserts at the top. Can we emit the position where to insert from 
the tool and put it there?


http://reviews.llvm.org/D20329



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


r269765 - Revert "[X86] Add immediate range checks for many of the builtins."

2016-05-17 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Tue May 17 09:07:43 2016
New Revision: 269765

URL: http://llvm.org/viewvc/llvm-project?rev=269765&view=rev
Log:
Revert "[X86] Add immediate range checks for many of the builtins."

This reverts commit r269619.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=269765&r1=269764&r2=269765&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue May 17 09:07:43 2016
@@ -1323,52 +1323,23 @@ bool Sema::CheckX86BuiltinFunctionCall(u
 return SemaBuiltinCpuSupports(*this, TheCall);
   case X86::BI__builtin_ms_va_start:
 return SemaBuiltinMSVAStart(TheCall);
-  case X86::BI__builtin_ia32_extractf64x4_mask:
-  case X86::BI__builtin_ia32_extracti64x4_mask:
-  case X86::BI__builtin_ia32_extractf32x8_mask:
-  case X86::BI__builtin_ia32_extracti32x8_mask:
-  case X86::BI__builtin_ia32_extractf64x2_256_mask:
-  case X86::BI__builtin_ia32_extracti64x2_256_mask:
-  case X86::BI__builtin_ia32_extractf32x4_256_mask:
-  case X86::BI__builtin_ia32_extracti32x4_256_mask:
-i = 1; l = 0; u = 1;
-break;
   case X86::BI_mm_prefetch:
-  case X86::BI__builtin_ia32_extractf32x4_mask:
-  case X86::BI__builtin_ia32_extracti32x4_mask:
-  case X86::BI__builtin_ia32_vpermilpd_mask:
-  case X86::BI__builtin_ia32_vpermilps_mask:
-  case X86::BI__builtin_ia32_extractf64x2_512_mask:
-  case X86::BI__builtin_ia32_extracti64x2_512_mask:
-i = 1; l = 0; u = 3;
-break;
-  case X86::BI__builtin_ia32_insertf32x8_mask:
-  case X86::BI__builtin_ia32_inserti32x8_mask:
-  case X86::BI__builtin_ia32_insertf64x4_mask:
-  case X86::BI__builtin_ia32_inserti64x4_mask:
-  case X86::BI__builtin_ia32_insertf64x2_256_mask:
-  case X86::BI__builtin_ia32_inserti64x2_256_mask:
-  case X86::BI__builtin_ia32_insertf32x4_256_mask:
-  case X86::BI__builtin_ia32_inserti32x4_256_mask:
-i = 2; l = 0; u = 1;
+i = 1;
+l = 0;
+u = 3;
 break;
   case X86::BI__builtin_ia32_sha1rnds4:
-  case X86::BI__builtin_ia32_shuf_f32x4_256_mask:
-  case X86::BI__builtin_ia32_shuf_f64x2_256_mask:
-  case X86::BI__builtin_ia32_shuf_i32x4_256_mask:
-  case X86::BI__builtin_ia32_shuf_i64x2_256_mask:
-  case X86::BI__builtin_ia32_shufpd128_mask:
-  case X86::BI__builtin_ia32_insertf64x2_512_mask:
-  case X86::BI__builtin_ia32_inserti64x2_512_mask:
-  case X86::BI__builtin_ia32_insertf32x4_mask:
-  case X86::BI__builtin_ia32_inserti32x4_mask:
-i = 2; l = 0; u = 3;
+i = 2;
+l = 0;
+u = 3;
 break;
   case X86::BI__builtin_ia32_vpermil2pd:
   case X86::BI__builtin_ia32_vpermil2pd256:
   case X86::BI__builtin_ia32_vpermil2ps:
   case X86::BI__builtin_ia32_vpermil2ps256:
-i = 3; l = 0; u = 3;
+i = 3;
+l = 0;
+u = 3;
 break;
   case X86::BI__builtin_ia32_cmpb128_mask:
   case X86::BI__builtin_ia32_cmpw128_mask:
@@ -1394,36 +1365,23 @@ bool Sema::CheckX86BuiltinFunctionCall(u
   case X86::BI__builtin_ia32_ucmpw512_mask:
   case X86::BI__builtin_ia32_ucmpd512_mask:
   case X86::BI__builtin_ia32_ucmpq512_mask:
-  case X86::BI__builtin_ia32_vpcomub:
-  case X86::BI__builtin_ia32_vpcomuw:
-  case X86::BI__builtin_ia32_vpcomud:
-  case X86::BI__builtin_ia32_vpcomuq:
-  case X86::BI__builtin_ia32_vpcomb:
-  case X86::BI__builtin_ia32_vpcomw:
-  case X86::BI__builtin_ia32_vpcomd:
-  case X86::BI__builtin_ia32_vpcomq:
-i = 2; l = 0; u = 7;
+i = 2;
+l = 0;
+u = 7;
 break;
   case X86::BI__builtin_ia32_roundps:
   case X86::BI__builtin_ia32_roundpd:
   case X86::BI__builtin_ia32_roundps256:
   case X86::BI__builtin_ia32_roundpd256:
-  case X86::BI__builtin_ia32_vpermilpd256_mask:
-  case X86::BI__builtin_ia32_vpermilps256_mask:
-i = 1; l = 0; u = 15;
+i = 1;
+l = 0;
+u = 15;
 break;
   case X86::BI__builtin_ia32_roundss:
   case X86::BI__builtin_ia32_roundsd:
-  case X86::BI__builtin_ia32_rangepd128_mask:
-  case X86::BI__builtin_ia32_rangepd256_mask:
-  case X86::BI__builtin_ia32_rangepd512_mask:
-  case X86::BI__builtin_ia32_rangeps128_mask:
-  case X86::BI__builtin_ia32_rangeps256_mask:
-  case X86::BI__builtin_ia32_rangeps512_mask:
-  case X86::BI__builtin_ia32_getmantsd_round_mask:
-  case X86::BI__builtin_ia32_getmantss_round_mask:
-  case X86::BI__builtin_ia32_shufpd256_mask:
-i = 2; l = 0; u = 15;
+i = 2;
+l = 0;
+u = 15;
 break;
   case X86::BI__builtin_ia32_cmpps:
   case X86::BI__builtin_ia32_cmpss:
@@ -1431,183 +1389,23 @@ bool Sema::CheckX86BuiltinFunctionCall(u
   case X86::BI__builtin_ia32_cmpsd:
   case X86::BI__builtin_ia32_cmpps256:
   case X86::BI__builtin_ia32_cmppd256:
-  case X86::BI__builtin_ia32_cmpps128_mask:
-  case X86::BI__builtin_ia32_cmppd128_mask:
-  case X86::BI__builtin_ia32_cmpps256_mask:
-  case X86::BI__builtin_ia32_

Re: [PATCH] D20329: [clang-include-fixer] Added Vim integration for clang-include-fixer.

2016-05-17 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: include-fixer/tool/ClangIncludeFixer.cpp:51
@@ +50,3 @@
+cl::opt
+VimMode("vim",
+cl::desc("Run the tool on a potentially unsaved buffer from Vim"),

bkramer wrote:
> This isn't really specific to vim, we should name it differently. '-stdin' 
> maybe? Then document what it really does.
I think we can make the include-fixer accept stdin input by default if there is 
no command-line file path. In this case, there is no need to add a command-line 
option here.


Comment at: include-fixer/tool/clang-include-fixer.py:50
@@ +49,3 @@
+vim.current.buffer[0:0] = [stdout]
+
+main()

Add `if __name__ == '__main__':`.


http://reviews.llvm.org/D20329



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


Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-17 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include/clang/Format/Format.h:855
@@ -854,1 +854,3 @@
 
+// \brief Returns a string representation of ``Language`` for debugging.
+inline StringRef getLanguageName(FormatStyle::LanguageKind Language) {

s/for debugging/.
Or do you want to claim that we'll arbitrarily change the strings here?


Comment at: lib/Format/Format.cpp:1217-1224
@@ -1983,8 +1216,10 @@
 
 tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
   if (!Style.SortIncludes)
 return Replaces;
+  if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript)
+return sortJavaScriptImports(Style, Code, Ranges, FileName);
 

I'd make this symmetric by pulling out 2 functions instead of falling through 
into the function.


Comment at: lib/Format/SortJavaScriptImports.cpp:45
@@ +44,3 @@
+
+struct JsImportExport {
+  bool IsExport;

klimek wrote:
> This is really weird - a class called ImportExport that then has a bool 
> IsExport. Please explain in a comment why you're doing that instead of any of:
> a) managing a set of imports and exports on their own
> b) calling this something else
> c) having a class hierarchy
As not all of the members will be default initialized I'd prefer to have 
constructors.


Comment at: lib/Format/SortJavaScriptImports.cpp:45-46
@@ +44,4 @@
+
+struct JsImportExport {
+  bool IsExport;
+  // JS imports are sorted into these categories, in order.

This is really weird - a class called ImportExport that then has a bool 
IsExport. Please explain in a comment why you're doing that instead of any of:
a) managing a set of imports and exports on their own
b) calling this something else
c) having a class hierarchy


Comment at: lib/Format/SortJavaScriptImports.cpp:115
@@ +114,3 @@
+  LineEnd = Line->Last;
+  JsImportExport ImpExp;
+  skipComments();

When I see ImpExp I think "ImplicitExpression". I'd name this ImportExport.
Also, it seems like we now have an uninitialized bool and enum in the struct.


Comment at: lib/Format/SortJavaScriptImports.cpp:163
@@ +162,3 @@
+  return Result;
+
+// Replace all existing import/export statements.

If that's the case, please add a comment to that end.


Comment at: lib/Format/SortJavaScriptImports.cpp:207
@@ +206,3 @@
+
+  StringRef getSourceText(SourceLocation Start, SourceLocation End) {
+const SourceManager &SM = Env.getSourceManager();

Usually we call Lexer::getSourceText for that (don't we have a Lexer?)


Comment at: lib/Format/SortJavaScriptImports.cpp:252-253
@@ +251,4 @@
+
+  bool parseImportExportSpecifier(const AdditionalKeywords &Keywords,
+  JsImportExport &ImpExp) {
+// * as prefix from '...';

This function is really long - can we perhaps break out smaller syntactic 
options.


Comment at: lib/Format/SortJavaScriptImports.cpp:258
@@ +257,3 @@
+return false;
+  if (!Current->is(Keywords.kw_as) || !nextToken())
+return false;

Please don't put side-effects into an if (). This might be generally easier to 
read if nextToken() can't fail, and instead creates an invalid token.


http://reviews.llvm.org/D20198



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


Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

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

LG with nit to fix.



Comment at: include-fixer/find-all-symbols/FindAllSymbols.h:44-45
@@ -41,2 +43,4 @@
 
-  explicit FindAllSymbols(ResultReporter *Reporter) : Reporter(Reporter) {}
+  explicit FindAllSymbols(ResultReporter *Reporter,
+  HeaderMapCollector *Collector)
+  : Reporter(Reporter), Collector(Collector) {}

Add a comment describing what the Collector is for.


http://reviews.llvm.org/D19816



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


r269769 - [PCH] Fixed bug with preamble invalidation when overridden files change

2016-05-17 Thread Cameron Desrochers via cfe-commits
Author: cameron314
Date: Tue May 17 09:34:53 2016
New Revision: 269769

URL: http://llvm.org/viewvc/llvm-project?rev=269769&view=rev
Log:
[PCH] Fixed bug with preamble invalidation when overridden files change

When remapped files were changed, they would not always cause the preamble's 
PCH to be invalidated, because the remapped path didn't necessarily match the 
include path (e.g. slash direction -- this happens a lot on Windows). I fixed 
this by moving to a llvm::sys::fs::UniqueID-based map instead of comparing 
paths stringwise.

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

Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=269769&r1=269768&r2=269769&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Tue May 17 09:34:53 2016
@@ -1378,7 +1378,7 @@ ASTUnit::getMainBufferWithPrecompiledPre
   
   // First, make a record of those files that have been overridden via
   // remapping or unsaved_files.
-  llvm::StringMap OverriddenFiles;
+  std::map OverriddenFiles;
   for (const auto &R : PreprocessorOpts.RemappedFiles) {
 if (AnyFileChanged)
   break;
@@ -1391,24 +1391,38 @@ ASTUnit::getMainBufferWithPrecompiledPre
   break;
 }
 
-OverriddenFiles[R.first] = PreambleFileHash::createForFile(
+OverriddenFiles[Status.getUniqueID()] = 
PreambleFileHash::createForFile(
 Status.getSize(), Status.getLastModificationTime().toEpochTime());
   }
 
   for (const auto &RB : PreprocessorOpts.RemappedFileBuffers) {
 if (AnyFileChanged)
   break;
-OverriddenFiles[RB.first] =
+
+vfs::Status Status;
+if (FileMgr->getNoncachedStatValue(RB.first, Status)) {
+  AnyFileChanged = true;
+  break;
+}
+
+OverriddenFiles[Status.getUniqueID()] =
 PreambleFileHash::createForMemoryBuffer(RB.second);
   }

   // Check whether anything has changed.
-  for (llvm::StringMap::iterator 
+  for (llvm::StringMap::iterator
  F = FilesInPreamble.begin(), FEnd = FilesInPreamble.end();
!AnyFileChanged && F != FEnd; 
++F) {
-llvm::StringMap::iterator Overridden
-  = OverriddenFiles.find(F->first());
+vfs::Status Status;
+if (FileMgr->getNoncachedStatValue(F->first(), Status)) {
+  // If we can't stat the file, assume that something horrible 
happened.
+  AnyFileChanged = true;
+  break;
+}
+
+std::map::iterator 
Overridden
+  = OverriddenFiles.find(Status.getUniqueID());
 if (Overridden != OverriddenFiles.end()) {
   // This file was remapped; check whether the newly-mapped file 
   // matches up with the previous mapping.
@@ -1418,13 +1432,9 @@ ASTUnit::getMainBufferWithPrecompiledPre
 }
 
 // The file was not remapped; check whether it has changed on disk.
-vfs::Status Status;
-if (FileMgr->getNoncachedStatValue(F->first(), Status)) {
-  // If we can't stat the file, assume that something horrible 
happened.
-  AnyFileChanged = true;
-} else if (Status.getSize() != uint64_t(F->second.Size) ||
-   Status.getLastModificationTime().toEpochTime() !=
-   uint64_t(F->second.ModTime))
+if (Status.getSize() != uint64_t(F->second.Size) ||
+Status.getLastModificationTime().toEpochTime() !=
+uint64_t(F->second.ModTime))
   AnyFileChanged = true;
   }
   


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


Re: [PATCH] D20137: [PCH] Fixed bugs with preamble invalidation when files change (on Windows)

2016-05-17 Thread Cameron via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269769: [PCH] Fixed bug with preamble invalidation when 
overridden files change (authored by cameron314).

Changed prior to commit:
  http://reviews.llvm.org/D20137?vs=57367&id=57477#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20137

Files:
  cfe/trunk/lib/Frontend/ASTUnit.cpp

Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -1378,7 +1378,7 @@
   
   // First, make a record of those files that have been overridden via
   // remapping or unsaved_files.
-  llvm::StringMap OverriddenFiles;
+  std::map OverriddenFiles;
   for (const auto &R : PreprocessorOpts.RemappedFiles) {
 if (AnyFileChanged)
   break;
@@ -1391,24 +1391,38 @@
   break;
 }
 
-OverriddenFiles[R.first] = PreambleFileHash::createForFile(
+OverriddenFiles[Status.getUniqueID()] = 
PreambleFileHash::createForFile(
 Status.getSize(), Status.getLastModificationTime().toEpochTime());
   }
 
   for (const auto &RB : PreprocessorOpts.RemappedFileBuffers) {
 if (AnyFileChanged)
   break;
-OverriddenFiles[RB.first] =
+
+vfs::Status Status;
+if (FileMgr->getNoncachedStatValue(RB.first, Status)) {
+  AnyFileChanged = true;
+  break;
+}
+
+OverriddenFiles[Status.getUniqueID()] =
 PreambleFileHash::createForMemoryBuffer(RB.second);
   }

   // Check whether anything has changed.
-  for (llvm::StringMap::iterator 
+  for (llvm::StringMap::iterator
  F = FilesInPreamble.begin(), FEnd = FilesInPreamble.end();
!AnyFileChanged && F != FEnd; 
++F) {
-llvm::StringMap::iterator Overridden
-  = OverriddenFiles.find(F->first());
+vfs::Status Status;
+if (FileMgr->getNoncachedStatValue(F->first(), Status)) {
+  // If we can't stat the file, assume that something horrible 
happened.
+  AnyFileChanged = true;
+  break;
+}
+
+std::map::iterator 
Overridden
+  = OverriddenFiles.find(Status.getUniqueID());
 if (Overridden != OverriddenFiles.end()) {
   // This file was remapped; check whether the newly-mapped file 
   // matches up with the previous mapping.
@@ -1418,13 +1432,9 @@
 }
 
 // The file was not remapped; check whether it has changed on disk.
-vfs::Status Status;
-if (FileMgr->getNoncachedStatValue(F->first(), Status)) {
-  // If we can't stat the file, assume that something horrible 
happened.
-  AnyFileChanged = true;
-} else if (Status.getSize() != uint64_t(F->second.Size) ||
-   Status.getLastModificationTime().toEpochTime() !=
-   uint64_t(F->second.ModTime))
+if (Status.getSize() != uint64_t(F->second.Size) ||
+Status.getLastModificationTime().toEpochTime() !=
+uint64_t(F->second.ModTime))
   AnyFileChanged = true;
   }
   


Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -1378,7 +1378,7 @@
   
   // First, make a record of those files that have been overridden via
   // remapping or unsaved_files.
-  llvm::StringMap OverriddenFiles;
+  std::map OverriddenFiles;
   for (const auto &R : PreprocessorOpts.RemappedFiles) {
 if (AnyFileChanged)
   break;
@@ -1391,24 +1391,38 @@
   break;
 }
 
-OverriddenFiles[R.first] = PreambleFileHash::createForFile(
+OverriddenFiles[Status.getUniqueID()] = PreambleFileHash::createForFile(
 Status.getSize(), Status.getLastModificationTime().toEpochTime());
   }
 
   for (const auto &RB : PreprocessorOpts.RemappedFileBuffers) {
 if (AnyFileChanged)
   break;
-OverriddenFiles[RB.first] =
+
+vfs::Status Status;
+if (FileMgr->getNoncachedStatValue(RB.first, Status)) {
+  AnyFileChanged = true;
+  break;
+}
+
+OverriddenFiles[Status.getUniqueID()] =
 PreambleFileHash::createForMemoryBuffer(RB.second);
   }

   // Check whether anything has changed.
-  for (llvm::StringMap::iterator 
+  for (llvm::StringMap::iterator
  F = FilesInPreamble.begin(), FEnd = FilesInPreamble.end();
!AnyFileChanged && F != FEnd; 
++F) {
-llvm::StringMap::iterator Overridden
-  = OverriddenFiles.find(F->first());
+vfs::Status Status;
+if (FileMgr->getNoncachedStatValue(F->first(), Status)) {
+  // If we can'

Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.

2016-05-17 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 57478.
yaxunl marked 8 inline comments as done.
yaxunl added a comment.

Revised as Anastasia suggested.


http://reviews.llvm.org/D19932

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/to_addr_builtin.cl
  test/SemaOpenCL/to_addr_builtin.cl

Index: test/SemaOpenCL/to_addr_builtin.cl
===
--- /dev/null
+++ test/SemaOpenCL/to_addr_builtin.cl
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only -cl-std=CL2.0 %s
+
+void test(void) {
+  global int *glob;
+  local int *loc;
+  constant int *con;
+  typedef constant int const_int_ty;
+  const_int_ty *con_typedef;
+
+  glob = to_global(glob, loc);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid number of arguments to function: 'to_global'}}
+#endif
+
+  int x;
+  glob = to_global(x);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid argument x to function: 'to_global', expecting a generic pointer argument}}
+#endif
+
+  glob = to_global(con);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid argument con to function: 'to_global', expecting a generic pointer argument}}
+#endif
+
+  glob = to_global(con_typedef);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid argument con_typedef to function: 'to_global', expecting a generic pointer argument}}
+#endif
+
+  loc = to_global(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}}
+#endif
+
+  global char *glob_c = to_global(loc);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+#else
+  // expected-warning@-4{{incompatible pointer types initializing '__global char *' with an expression of type '__global int *'}}
+#endif
+
+}
Index: test/CodeGenOpenCL/to_addr_builtin.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/to_addr_builtin.cl
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+// CHECK: %[[A:.*]] = type { float, float, float }
+typedef struct {
+  float x,y,z;
+} A;
+typedef private A *PA;
+typedef global A *GA;
+
+void test(void) {
+  global int *glob;
+  local int *loc;
+  private int *priv;
+  generic int *gen;
+
+  //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
+  glob = to_global(glob);
+  
+  //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
+  glob = to_global(loc);
+ 
+  //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
+  glob = to_global(priv);
+ 
+  //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
+  glob = to_global(gen);
+  
+  //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)*
+  loc = to_local(glob);
+
+  //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)*
+  loc = to_local(loc);
+
+  //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)*
+  loc = to_local(priv);
+
+  //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{

Re: [PATCH] D20119: [libunwind] Improve unwinder stack usage

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

Just one question, otherwise LGTM:



Comment at: src/UnwindCursor.hpp:580
@@ -579,3 +605,1 @@
   _isSignalFrame(false) {
-  static_assert(sizeof(UnwindCursor) < sizeof(unw_cursor_t),
-"UnwindCursor<> does not fit in unw_cursor_t");

Is there a good reason to move this static assert out to libunwind.cpp? ISTM it 
serves its purpose better here.


http://reviews.llvm.org/D20119



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


[libcxx] r269772 - Implement P0030R1: Introduce a 3-Argument Overload to std::hypot

2016-05-17 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue May 17 09:52:19 2016
New Revision: 269772

URL: http://llvm.org/viewvc/llvm-project?rev=269772&view=rev
Log:
Implement P0030R1: Introduce a 3-Argument Overload to std::hypot

Modified:
libcxx/trunk/include/cmath
libcxx/trunk/test/std/numerics/c.math/cmath.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/cmath
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cmath?rev=269772&r1=269771&r2=269772&view=diff
==
--- libcxx/trunk/include/cmath (original)
+++ libcxx/trunk/include/cmath Tue May 17 09:52:19 2016
@@ -209,6 +209,10 @@ floating_point hypot (arithmetic x, arit
 float  hypotf(float x, float y);
 long doublehypotl(long double x, long double y);
 
+double   hypot(double x, double y, double z);// C++17
+floathypot(float x, float y, float z);   // C++17
+long double  hypot(long double x, long double y, long double z); // C++17
+
 int ilogb (arithmetic x);
 int ilogbf(float x);
 int ilogbl(long double x);
@@ -548,6 +552,30 @@ using ::lgamma;
 using ::lgammaf;
 #endif // __sun__
 
+#if _LIBCPP_STD_VER > 14
+inline _LIBCPP_INLINE_VISIBILITY float   hypot(   float x,   float 
y,   float z ) { return sqrt(x*x + y*y + z*z); }
+inline _LIBCPP_INLINE_VISIBILITY double  hypot(  double x,  double 
y,  double z ) { return sqrt(x*x + y*y + z*z); }
+inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double 
y, long double z ) { return sqrt(x*x + y*y + z*z); }
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::__lazy_enable_if
+<
+std::is_arithmetic<_A1>::value &&
+std::is_arithmetic<_A2>::value &&
+std::is_arithmetic<_A3>::value,
+std::__promote<_A1, _A2, _A3>
+>::type
+hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
+{
+typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
+static_assert((!(std::is_same<_A1, __result_type>::value &&
+ std::is_same<_A2, __result_type>::value &&
+ std::is_same<_A3, __result_type>::value)), "");
+return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, 
(__result_type)__lcpp_z);
+}
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_CMATH

Modified: libcxx/trunk/test/std/numerics/c.math/cmath.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/c.math/cmath.pass.cpp?rev=269772&r1=269771&r2=269772&view=diff
==
--- libcxx/trunk/test/std/numerics/c.math/cmath.pass.cpp (original)
+++ libcxx/trunk/test/std/numerics/c.math/cmath.pass.cpp Tue May 17 09:52:19 
2016
@@ -79,6 +79,7 @@ Ambiguous fma(Ambiguous, Ambiguous, Ambi
 Ambiguous fmax(Ambiguous, Ambiguous){ return Ambiguous(); }
 Ambiguous fmin(Ambiguous, Ambiguous){ return Ambiguous(); }
 Ambiguous hypot(Ambiguous, Ambiguous){ return Ambiguous(); }
+Ambiguous hypot(Ambiguous, Ambiguous, Ambiguous){ return Ambiguous(); }
 Ambiguous ilogb(Ambiguous){ return Ambiguous(); }
 Ambiguous lgamma(Ambiguous){ return Ambiguous(); }
 Ambiguous llrint(Ambiguous){ return Ambiguous(); }
@@ -1010,6 +1011,28 @@ void test_hypot()
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 assert(std::hypot(3,4) == 5);
+
+#if TEST_STD_VER > 14
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+
+assert(std::hypot(2,3,6) == 7);
+assert(std::hypot(1,4,8) == 9);
+#endif
 }
 
 void test_ilogb()

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=269772&r1=269771&r2=269772&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Tue May 17 09:52:19 2016
@@ -89,7 +89,7 @@
http://wg21.link/P0253R1";>P0253R1LWGFixing a design 
mistake in the searchers 
interfaceJacksonvilleComplete3.9
http://wg21.link/P0025R0";>P0025R0LWGAn algorithm to 
"clamp" a value between a pair of boundary 
valuesJacksonvilleComplete3.9
http://wg21.link/P0154R1";>P

Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

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


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:24
@@ +23,3 @@
+AST_MATCHER(CallExpr, hasUnresolvedLookupExpr) {
+  return isa(Node.getCallee());
+}

I think, we should use a node matcher for `UnresolvedLookupExpr` and instead 
use `callExpr(callee(unresolvedLookupExpr().bind("something")))`.

Also, I would create the new matcher in the ASTMatchers.h right away, together 
with a test and docs. But if you want this patch to be in soon, feel free to 
move the matcher to the matchers library in a follow up.


Repository:
  rL LLVM

http://reviews.llvm.org/D20326



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


[libcxx] r269773 - Add some checking so that the TEST_HAS_XXX macros match up with the _LIBCPP_NO_HAS_XXX macros. No functional change

2016-05-17 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue May 17 09:58:09 2016
New Revision: 269773

URL: http://llvm.org/viewvc/llvm-project?rev=269773&view=rev
Log:
Add some checking so that the TEST_HAS_XXX macros match up with the 
_LIBCPP_NO_HAS_XXX macros. No functional change

Modified:
libcxx/trunk/test/libcxx/selftest/test_macros.pass.cpp

Modified: libcxx/trunk/test/libcxx/selftest/test_macros.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/selftest/test_macros.pass.cpp?rev=269773&r1=269772&r2=269773&view=diff
==
--- libcxx/trunk/test/libcxx/selftest/test_macros.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/selftest/test_macros.pass.cpp Tue May 17 09:58:09 
2016
@@ -8,6 +8,7 @@
 
//===--===//
 //
 // Test the "test_macros.h" header.
+#include <__config>
 #include "test_macros.h"
 
 #ifndef TEST_STD_VER
@@ -30,7 +31,36 @@ void test_noexcept() TEST_NOEXCEPT
 {
 }
 
+void test_libcxx_macros()
+{
+//  = C++14 features =
+//  defined(TEST_HAS_EXTENDED_CONSTEXPR)  != 
defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#ifdef TEST_HAS_EXTENDED_CONSTEXPR
+# ifdef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
+#  error "TEST_EXTENDED_CONSTEXPR mismatch (1)"
+# endif
+#else
+# ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
+#  error "TEST_EXTENDED_CONSTEXPR mismatch (2)"
+# endif
+#endif
+
+//  defined(TEST_HAS_VARIABLE_TEMPLATES) != 
defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+#ifdef TEST_HAS_VARIABLE_TEMPLATES
+# ifdef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+#  error "TEST_VARIABLE_TEMPLATES mismatch (1)"
+# endif
+#else
+# ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+#  error "TEST_VARIABLE_TEMPLATES mismatch (2)"
+# endif
+#endif
+
+//  = C++1z features =
+}
+
 int main()
 {
 test_noexcept();
+test_libcxx_macros();
 }


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


Re: [PATCH] D20119: [libunwind] Improve unwinder stack usage

2016-05-17 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: src/UnwindCursor.hpp:580
@@ -579,3 +605,1 @@
   _isSignalFrame(false) {
-  static_assert(sizeof(UnwindCursor) < sizeof(unw_cursor_t),
-"UnwindCursor<> does not fit in unw_cursor_t");

jroelofs wrote:
> Is there a good reason to move this static assert out to libunwind.cpp? ISTM 
> it serves its purpose better here.
I removed this thinking there is already an assert in `libunwind.cpp` checking 
the same constraint. Didn't realize the latter assert was something I 
introduced in the patch!

Will fix.


http://reviews.llvm.org/D20119



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


Re: [Clang] Convergent Attribute

2016-05-17 Thread Ettore Speziale via cfe-commits
Hello,

>>> CUDA? In any case, I don't see how the restriction helps users, and the 
>>> attribute at the IR level has a well-defined meaning regardless. If a user 
>>> were to have a use case, they'd simply find the restriction arbitrary and 
>>> frustrating.
>> 
>> Yes, CUDA was already considered as well. I just think that compilers should 
>> help to reduce amount of erroneous or meaningless use cases. That's one of 
>> the reasons to have language options for the attributes. But I don't feel 
>> strongly about this particular case anyways. So let's make it language 
>> independent then. ;)
> 
> Is the patch OK now or you guys want to apply some other modifications?
> 
> 

Sorry guys, but on a second tough this patch might be completely useless. I 
guess I’d should be marking all function calls convergent at CodeGen time, and 
then rely on LLMV’s FunctionAttrs to remove the unnecessary ones.

Thank you for the good review and sorry for wasting your times,
Ettore Speziale

--
Ettore Speziale — Compiler Engineer
speziale.ett...@gmail.com
espezi...@apple.com
--

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


Re: [PATCH] D20329: [clang-include-fixer] Added Vim integration for clang-include-fixer.

2016-05-17 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 57484.
ioeric marked 4 inline comments as done.
ioeric added a comment.

- Changed VimMode to STDINMode, and made clang-include-fixer return insertion 
line number in this mode.
- Added -db, -input options into Vim integration.


http://reviews.llvm.org/D20329

Files:
  include-fixer/tool/ClangIncludeFixer.cpp
  include-fixer/tool/clang-include-fixer.py

Index: include-fixer/tool/clang-include-fixer.py
===
--- /dev/null
+++ include-fixer/tool/clang-include-fixer.py
@@ -0,0 +1,64 @@
+# This file is a minimal clang-include-fixer vim-integration. To install:
+# - Change 'binary' if clang-include-fixer is not on the path (see below).
+# - Add to your .vimrc:
+#
+#   map ,cf :pyf path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+#
+# This enables clang-include-fixer for NORMAL and VISUAL mode.
+#
+# To set up clang-include-fixer, see http://clang.llvm.org/extra/include-fixer.html
+#
+# With this integration you can press the bound key and clang-include-fixer will
+# be run on the current buffer.
+#
+# It operates on the current, potentially unsaved buffer and does not create
+# or save any files. To revert a fix, just undo.
+
+import argparse
+import subprocess
+import sys
+import vim
+
+# set g:clang_include_fixer_path to the path to clang-include-fixer if it is not
+# on the path.
+# Change this to the full path if clang-include-fixer is not on the path.
+binary = 'clang-include-fixer'
+if vim.eval('exists("g:clang_include_fixer_path")') == "1":
+  binary = vim.eval('g:clang_include_fixer_path')
+
+def main():
+  parser = argparse.ArgumentParser(
+  description='Vim integration for clang-include-fixer')
+  parser.add_argument('-db', default='yaml',
+  help='clang-include-fixer input format.')
+  parser.add_argument('-input', default='',
+  help='String to initialize the database.')
+  args = parser.parse_args()
+
+  # Get the current text.
+  buf = vim.current.buffer
+  text = '\n'.join(buf)
+
+  # Call clang-include-fixer.
+  command = [binary, "-stdin", "-db="+args.db, "-input="+args.input,
+ vim.current.buffer.name]
+  p = subprocess.Popen(command,
+   stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+   stdin=subprocess.PIPE)
+  stdout, stderr = p.communicate(input=text)
+
+  # If successful, replace buffer contents.
+  if stderr:
+print stderr
+
+  if stdout:
+lines = stdout.splitlines()
+for line in lines:
+  line_num, text = line.split(",")
+  # clang-include-fixer provides 1-based line number
+  line_num = int(line_num) - 1
+  print 'Inserting "{0}" at line {1}'.format(text, line_num)
+  vim.current.buffer[line_num:line_num] = [text]
+
+if __name__ == '__main__':
+  main()
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -47,11 +47,40 @@
 cl::opt Quiet("q", cl::desc("Reduce terminal output"), cl::init(false),
 cl::cat(IncludeFixerCategory));
 
+cl::opt
+STDINMode("stdin",
+  cl::desc("Override source file's content (in the overlaying\n"
+   "virtual file system) with input from  and run\n"
+   "the tool on the new content with the compilation\n"
+   "options of the source file. This mode is currently\n"
+   "used for editor integration."),
+  cl::init(false), cl::cat(IncludeFixerCategory));
+
 int includeFixerMain(int argc, const char **argv) {
   tooling::CommonOptionsParser options(argc, argv, IncludeFixerCategory);
   tooling::ClangTool tool(options.getCompilations(),
   options.getSourcePathList());
 
+  // In STDINMode, we override the file content with the  input.
+  // Since `tool.mapVirtualFile` takes `StringRef`, we define `Code` outside of
+  // the if-block so that `Code` is not released after the if-block.
+  std::unique_ptr Code;
+  if (STDINMode) {
+assert(options.getSourcePathList().size() == 1 &&
+   "Expect exactly one file path in STDINMode.");
+llvm::ErrorOr> CodeOrErr =
+MemoryBuffer::getSTDIN();
+if (std::error_code EC = CodeOrErr.getError()) {
+  errs() << EC.message() << "\n";
+  return 1;
+}
+Code = std::move(CodeOrErr.get());
+if (Code->getBufferSize() == 0)
+  return 0;  // Skip empty files.
+
+tool.mapVirtualFile(options.getSourcePathList().front(), Code->getBuffer());
+  }
+
   // Set up data source.
   auto SymbolIndexMgr = llvm::make_unique();
   switch (DatabaseFormat) {
@@ -121,6 +150,15 @@
   SourceManager SM(Diagnostics, tool.getFiles());
   Diagnostics.setClient(&DiagnosticPrinter, false);
 
+  if (STDINMode) {
+for (const tooling::Replacemen

Re: [PATCH] D20329: [clang-include-fixer] Added Vim integration for clang-include-fixer.

2016-05-17 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: include-fixer/tool/ClangIncludeFixer.cpp:51
@@ +50,3 @@
+cl::opt
+VimMode("vim",
+cl::desc("Run the tool on a potentially unsaved buffer from Vim"),

hokein wrote:
> bkramer wrote:
> > This isn't really specific to vim, we should name it differently. '-stdin' 
> > maybe? Then document what it really does.
> I think we can make the include-fixer accept stdin input by default if there 
> is no command-line file path. In this case, there is no need to add a 
> command-line option here.
We can't get the compile options for the code if we only accept  input 
(without the corresponding file path).


http://reviews.llvm.org/D20329



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


Re: [PATCH] D20296: clang-rename: avoid StringRef members in USRLocFindingASTVisitor

2016-05-17 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/D20296



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


Re: [PATCH] D20119: [libunwind] Improve unwinder stack usage

2016-05-17 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 57487.
rmaprath added a comment.

Addressing review comments from @jroelofs:

- Moved the assertion in `libunwind.cpp` back to `UnwindCursor.cpp` where it 
really belogs.

@jroelofs: I just realized that, with this new native-only build of 
`libunwind`, users of `libunwind.h` would have to explicitly `#define` the flag 
`_LIBUNWIND_IS_NATIVE_ONLY` in order to get the header in-sync with the 
library. I can't see an immediate problem if they don't define that flag 
though, it's just that they'll end up passing larger buffers than the library 
needs. Do you see a problem here?

'libc++' uses a `__config_site` mechanism to wire the cmake build options into 
the `__config` file. We can implement a similar mechanism in `libunwind`, not 
sure if that's necessary here.

WDYT?

Thanks.

/ Asiri


http://reviews.llvm.org/D20119

Files:
  CMakeLists.txt
  include/__libunwind_config.h
  include/libunwind.h
  src/CompactUnwinder.hpp
  src/Registers.hpp
  src/UnwindCursor.hpp
  src/config.h
  src/libunwind.cpp

Index: src/libunwind.cpp
===
--- src/libunwind.cpp
+++ src/libunwind.cpp
@@ -45,30 +45,27 @@
   _LIBUNWIND_TRACE_API("unw_init_local(cursor=%p, context=%p)\n",
static_cast(cursor),
static_cast(context));
-  // Use "placement new" to allocate UnwindCursor in the cursor buffer.
 #if defined(__i386__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_x86
 #elif defined(__x86_64__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_x86_64
 #elif defined(__ppc__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
-#elif defined(__arm64__) || defined(__aarch64__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_ppc
+#elif defined(__aarch64__)
+# define REGISTER_KIND Registers_arm64
 #elif _LIBUNWIND_ARM_EHABI
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_arm
 #elif defined(__or1k__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_or1k
 #elif defined(__mips__)
-#warning The MIPS architecture is not supported.
+# warning The MIPS architecture is not supported.
 #else
-#error Architecture not supported
+# error Architecture not supported
 #endif
+  // Use "placement new" to allocate UnwindCursor in the cursor buffer.
+  new ((void *)cursor) UnwindCursor(
+ context, LocalAddressSpace::sThisAddressSpace);
+#undef REGISTER_KIND
   AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
   co->setInfoBasedOnIPRegister();
 
Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -119,5 +119,25 @@
   #define _LIBUNWIND_TRACING_UNWINDING logUnwinding()
 #endif
 
+#ifdef __cplusplus
+// Used to fit UnwindCursor and Registers_xxx types against unw_context_t /
+// unw_cursor_t sized memory blocks.
+#if defined(_LIBUNWIND_IS_NATIVE_ONLY)
+# define COMP_OP ==
+#else
+# define COMP_OP <
+#endif
+template 
+struct check_fit {
+  template 
+  struct blk_count {
+static const uint32_t count =
+  (sizeof(T) + sizeof(uint64_t) - 1) / sizeof(uint64_t);
+  };
+  static const bool does_fit =
+(blk_count<_Type>::count COMP_OP blk_count<_Mem>::count);
+};
+#undef COMP_OP
+#endif // __cplusplus
 
 #endif // LIBUNWIND_CONFIG_H
Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -481,87 +481,113 @@
 return stepWithCompactEncoding(dummy);
   }
 
+#if defined(_LIBUNWIND_TARGET_X86_64)
   int stepWithCompactEncoding(Registers_x86_64 &) {
 return CompactUnwinder_x86_64::stepWithCompactEncoding(
 _info.format, _info.start_ip, _addressSpace, _registers);
   }
+#endif
 
+#if defined(_LIBUNWIND_TARGET_I386)
   int stepWithCompactEncoding(Registers_x86 &) {
 return CompactUnwinder_x86::stepWithCompactEncoding(
 _info.format, (uint32_t)_info.start_ip, _addressSpace, _registers);
   }
+#endif
 
+#if defined(_LIBUNWIND_TARGET_PPC)
   int stepWithCompactEncoding(Registers_ppc &) {
 return UNW_EINVAL;
   }
+#endif
 
+#if defined(_LIBUNWIND_TARGET_AARCH64)
   int stepWithCompactEncoding(Registers_arm64 &) {
 return CompactUnwinder_arm64::stepWithCompactEncoding(
 _info.format, _info.start_ip, _addressSpace, _registers);
   }
+#endif
 
   bool compactSaysUseDwarf(uint32_t *offse

Re: [PATCH] D19311: [analyzer] Self Assignment Checker

2016-05-17 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Thanks for the patch! This looks like it will catch some nasty bugs.

My comments (inline) are mostly nits. But two are more substantial: (1) you 
should add a path note where the self-assignment assumption is made explaining 
the assumption to the user and (2) the potential cost of the eager case split 
could be high -- can it be mitigated by changing the inlining mode?



Comment at: lib/StaticAnalyzer/Checkers/SelfAssignmentChecker.cpp:13
@@ +12,3 @@
+// where the parameter refers to the same location where the this pointer
+// points to.
+//

An interesting part of this checker is that it doesn't actually perform any 
checks itself. Instead, it helps other checkers finds bugs by causing the 
analyzer to explore copy and move assignment operators twice: once for when 
'this' aliases with the parameter and once for when it may not. 

I think it is worth mentioning this explicitly in the comment because it 
unusual. Most checkers don't work this way.


Comment at: lib/StaticAnalyzer/Checkers/SelfAssignmentChecker.cpp:26
@@ +25,3 @@
+
+class SelfAssignmentChecker : public Checker {
+public:

What do you think about renaming this class to something like 
"CXXSelfAssignmentChecker"? I think name is a bit confusing because in 
Objective-C there is a notion of assigning to `self` (which is the ObjC 
equivalent of `this`).


Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:435
@@ -434,1 +434,3 @@
 return false;
+  if (const auto *MD = dyn_cast(D)) {
+if(MD->isCopyAssignmentOperator()||MD->isMoveAssignmentOperator())

It would be good to add a comment explaining why we re-analyze these methods at 
the top level.


Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:436
@@ +435,3 @@
+  if (const auto *MD = dyn_cast(D)) {
+if(MD->isCopyAssignmentOperator()||MD->isMoveAssignmentOperator())
+  return false;

The LLVM style is to put spaces after `if` and around `||`. 
http://llvm.org/docs/CodingStandards.html#spaces-before-parentheses


Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:450
@@ -445,5 +449,3 @@
   // inlining when reanalyzing an already inlined function.
-  if (Visited.count(D)) {
-assert(isa(D) &&
-   "We are only reanalyzing ObjCMethods.");
+  if (Visited.count(D)&&isa(D)) {
 const ObjCMethodDecl *ObjCM = cast(D);


One thing I am concerned about is that this will introduce an eager case split, 
which can be quite expensive. We could potentially mitigate this cost by 
changing `getInliningModeForFunction()` to return `ExprEngine::Inline_Minimal` 
for the copy and move assignment operators when analyzing them at the top level 
after they have already been inlined elsewhere. Inline_Minimal would prevent 
most inlining in these methods and thus reduce cost, but would also reduce 
coverage (leading to false negatives). Do you have a sense of how often 
self-assignment issues arise in inlined calls vs. in the operators themselves?

(Also the spacing around `&&` doesn't match LLVM style here.)


Comment at: test/Analysis/self-assign-unused.cpp:21
@@ +20,3 @@
+
+String& String::operator=(const String &rhs) {
+  free(str);

I think it is important to add a path note saying something like "Assuming 
'*this' is equal to 'rhs'".

To do this, you can add a new BugReporterVisitor subclass to 
BugReporterVisitors.h that walks a error path backwards to add the note. There 
is an example of how to do this in NonLocalizedStringBRVisitor in 
LocalizationChecker.cpp. 

Unlike the localization checker, however, the path note for the self assignment 
checker will be added to errors generated by *other* checkers, so you should 
register the new bug report visitor for all reports in 
GRBugReporter::generatePathDiagnostic() (similar to NilReceiverBRVisitor).



Comment at: test/Analysis/self-assign-unused.cpp:22
@@ +21,3 @@
+String& String::operator=(const String &rhs) {
+  free(str);
+  str = strdup(rhs.str); // expected-warning{{Use of memory after it is freed}}

I think it would be good to add;

```
clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} 
expected-warning{{UNKNOWN}}

```
here to explicitly test for the case split. You'll need to add a prototype 
`void clang_analyzer_eval(int);` to use this.


Comment at: test/Analysis/self-assign-unused.cpp:26
@@ +25,3 @@
+}
+
+String::operator const char*() const {

It would be good to also test the move assignment operator.


Comment at: test/Analysis/self-assign-used.cpp:1
@@ +1,2 @@
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,cplusplus,unix.Malloc,debug.ExprInspection %s -verify
+

Can you combine these into one test file? This way someone updating the tests 
will know there is

Re: r269769 - [PCH] Fixed bug with preamble invalidation when overridden files change

2016-05-17 Thread Nico Weber via cfe-commits
Is it possible to write a test for this?

On Tue, May 17, 2016 at 10:34 AM, Cameron Desrochers via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: cameron314
> Date: Tue May 17 09:34:53 2016
> New Revision: 269769
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269769&view=rev
> Log:
> [PCH] Fixed bug with preamble invalidation when overridden files change
>
> When remapped files were changed, they would not always cause the
> preamble's PCH to be invalidated, because the remapped path didn't
> necessarily match the include path (e.g. slash direction -- this happens a
> lot on Windows). I fixed this by moving to a llvm::sys::fs::UniqueID-based
> map instead of comparing paths stringwise.
>
> Differential Revision: http://reviews.llvm.org/D20137
>
> Modified:
> cfe/trunk/lib/Frontend/ASTUnit.cpp
>
> Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=269769&r1=269768&r2=269769&view=diff
>
> ==
> --- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
> +++ cfe/trunk/lib/Frontend/ASTUnit.cpp Tue May 17 09:34:53 2016
> @@ -1378,7 +1378,7 @@ ASTUnit::getMainBufferWithPrecompiledPre
>
>// First, make a record of those files that have been overridden via
>// remapping or unsaved_files.
> -  llvm::StringMap OverriddenFiles;
> +  std::map OverriddenFiles;
>for (const auto &R : PreprocessorOpts.RemappedFiles) {
>  if (AnyFileChanged)
>break;
> @@ -1391,24 +1391,38 @@ ASTUnit::getMainBufferWithPrecompiledPre
>break;
>  }
>
> -OverriddenFiles[R.first] = PreambleFileHash::createForFile(
> +OverriddenFiles[Status.getUniqueID()] =
> PreambleFileHash::createForFile(
>  Status.getSize(),
> Status.getLastModificationTime().toEpochTime());
>}
>
>for (const auto &RB : PreprocessorOpts.RemappedFileBuffers) {
>  if (AnyFileChanged)
>break;
> -OverriddenFiles[RB.first] =
> +
> +vfs::Status Status;
> +if (FileMgr->getNoncachedStatValue(RB.first, Status)) {
> +  AnyFileChanged = true;
> +  break;
> +}
> +
> +OverriddenFiles[Status.getUniqueID()] =
>  PreambleFileHash::createForMemoryBuffer(RB.second);
>}
>
>// Check whether anything has changed.
> -  for (llvm::StringMap::iterator
> +  for (llvm::StringMap::iterator
>   F = FilesInPreamble.begin(), FEnd = FilesInPreamble.end();
> !AnyFileChanged && F != FEnd;
> ++F) {
> -llvm::StringMap::iterator Overridden
> -  = OverriddenFiles.find(F->first());
> +vfs::Status Status;
> +if (FileMgr->getNoncachedStatValue(F->first(), Status)) {
> +  // If we can't stat the file, assume that something horrible
> happened.
> +  AnyFileChanged = true;
> +  break;
> +}
> +
> +std::map::iterator
> Overridden
> +  = OverriddenFiles.find(Status.getUniqueID());
>  if (Overridden != OverriddenFiles.end()) {
>// This file was remapped; check whether the newly-mapped file
>// matches up with the previous mapping.
> @@ -1418,13 +1432,9 @@ ASTUnit::getMainBufferWithPrecompiledPre
>  }
>
>  // The file was not remapped; check whether it has changed on
> disk.
> -vfs::Status Status;
> -if (FileMgr->getNoncachedStatValue(F->first(), Status)) {
> -  // If we can't stat the file, assume that something horrible
> happened.
> -  AnyFileChanged = true;
> -} else if (Status.getSize() != uint64_t(F->second.Size) ||
> -   Status.getLastModificationTime().toEpochTime() !=
> -   uint64_t(F->second.ModTime))
> +if (Status.getSize() != uint64_t(F->second.Size) ||
> +Status.getLastModificationTime().toEpochTime() !=
> +uint64_t(F->second.ModTime))
>AnyFileChanged = true;
>}
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-17 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.
hokein added a comment.

http://reviews.llvm.org/D19816



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


Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-17 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57490.
hokein added a comment.

Add comments.


http://reviews.llvm.org/D19816

Files:
  include-fixer/find-all-symbols/CMakeLists.txt
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/HeaderMapCollector.h
  include-fixer/find-all-symbols/PragmaCommentHandler.cpp
  include-fixer/find-all-symbols/PragmaCommentHandler.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -8,11 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -50,25 +53,58 @@
   std::vector Symbols;
 };
 
+class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
+  : MatchFinder(), Collector(), Handler(&Collector),
+Matcher(Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &Compiler,
+StringRef InFile) override {
+Compiler.getPreprocessor().addCommentHandler(&Handler);
+return MatchFinder.newASTConsumer();
+  }
+
+private:
+  ast_matchers::MatchFinder MatchFinder;
+  HeaderMapCollector Collector;
+  PragmaCommentHandler Handler;
+  FindAllSymbols Matcher;
+};
+
+class TestFindAllSymbolsActionFactory
+: public clang::tooling::FrontendActionFactory {
+public:
+  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  : Reporter(Reporter) {}
+  clang::FrontendAction *create() override {
+return new TestFindAllSymbolsAction(Reporter);
+  }
+
+private:
+  MockReporter *const Reporter;
+};
+
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
 return Reporter.hasSymbol(Symbol);
   }
 
   bool runFindAllSymbols(StringRef Code) {
-FindAllSymbols matcher(&Reporter);
-clang::ast_matchers::MatchFinder MatchFinder;
-matcher.registerMatchers(&MatchFinder);
-
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
 new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
 std::string FileName = "symbol.cc";
-std::unique_ptr Factory =
-clang::tooling::newFrontendActionFactory(&MatchFinder);
+
+std::unique_ptr Factory(
+new TestFindAllSymbolsActionFactory(&Reporter));
+
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
  std::string("-std=c++11"), FileName},
@@ -327,5 +363,18 @@
   EXPECT_FALSE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, IWYUPrivatePragmaTest) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+struct Bar {
+};
+  )";
+  runFindAllSymbols(Code);
+
+  SymbolInfo Symbol =
+  CreateSymbolInfo("Bar", SymbolInfo::Class, "bar.h", 3, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -8,8 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -82,6 +88,31 @@
   std::map> Symbols;
 };
 
+class FindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  FindAllSymbolsAction()
+  : Reporter(), MatchFinder(), Collector(), Handler(&Collector),
+Matcher(&Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+ 

[clang-tools-extra] r269779 - [find-all-symbols] Add IWYU private pragma support.

2016-05-17 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue May 17 11:48:49 2016
New Revision: 269779

URL: http://llvm.org/viewvc/llvm-project?rev=269779&view=rev
Log:
[find-all-symbols] Add IWYU private pragma support.

Reviewers: djasper, klimek

Subscribers: kimgr, cfe-commits, bkramer, ioeric

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

Added:
clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.h

clang-tools-extra/trunk/include-fixer/find-all-symbols/PragmaCommentHandler.cpp

clang-tools-extra/trunk/include-fixer/find-all-symbols/PragmaCommentHandler.h
Modified:
clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.h

clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp

clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt?rev=269779&r1=269778&r2=269779&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt Tue 
May 17 11:48:49 2016
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(findAllSymbols
   FindAllSymbols.cpp
+  PragmaCommentHandler.cpp
   SymbolInfo.cpp
 
   LINK_LIBS

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp?rev=269779&r1=269778&r2=269779&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp 
Tue May 17 11:48:49 2016
@@ -8,6 +8,7 @@
 
//===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
 #include "SymbolInfo.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
@@ -56,8 +57,9 @@ std::vector GetCont
   return Contexts;
 }
 
-llvm::Optional CreateSymbolInfo(const NamedDecl *ND,
-const SourceManager &SM) {
+llvm::Optional
+CreateSymbolInfo(const NamedDecl *ND, const SourceManager &SM,
+ const HeaderMapCollector::HeaderMap &HeaderMappingTable) {
   SymbolInfo::SymbolKind Type;
   if (llvm::isa(ND)) {
 Type = SymbolInfo::SymbolKind::Variable;
@@ -94,6 +96,11 @@ llvm::Optional CreateSymbolI
   if (FilePath.empty())
 return llvm::None;
 
+  // Check pragma remapping header.
+  auto Iter = HeaderMappingTable.find(FilePath);
+  if (Iter != HeaderMappingTable.end())
+FilePath = Iter->second;
+
   return SymbolInfo(ND->getNameAsString(), Type, FilePath.str(),
 SM.getExpansionLineNumber(Loc), GetContexts(ND));
 }
@@ -207,7 +214,8 @@ void FindAllSymbols::run(const MatchFind
   assert(ND && "Matched declaration must be a NamedDecl!");
   const SourceManager *SM = Result.SourceManager;
 
-  llvm::Optional Symbol = CreateSymbolInfo(ND, *SM);
+  llvm::Optional Symbol =
+  CreateSymbolInfo(ND, *SM, Collector->getHeaderMappingTable());
   if (Symbol)
 Reporter->reportResult(
 SM->getFileEntryForID(SM->getMainFileID())->getName(), *Symbol);

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.h?rev=269779&r1=269778&r2=269779&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.h 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.h Tue 
May 17 11:48:49 2016
@@ -17,6 +17,8 @@
 namespace clang {
 namespace find_all_symbols {
 
+class HeaderMapCollector;
+
 /// \brief FindAllSymbols collects all classes, free standing functions and
 /// global variables with some extra information such as the path of the header
 /// file, the namespaces they are contained in, the type of variables and the
@@ -39,7 +41,9 @@ public:
   const SymbolInfo &Symbol) = 0;
   };
 
-  explicit FindAllSymbols(ResultReporter *Reporter) : Reporter(Reporter) {}
+  explicit FindAllSymbols(ResultReporter *Reporter,
+  HeaderMapCollector *Collector)
+  : Reporter(Reporter), Collector(Collector) {}
 
   void registerMatchers(clang::ast_matchers::MatchFinder *MatchFinder);
 
@@ -47,7 +51,11 @@ public:
   ru

Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-17 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269779: [find-all-symbols] Add IWYU private pragma support. 
(authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D19816?vs=57493&id=57495#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19816

Files:
  clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt
  clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.h
  clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.h
  
clang-tools-extra/trunk/include-fixer/find-all-symbols/PragmaCommentHandler.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/PragmaCommentHandler.h
  
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -8,11 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -50,25 +53,58 @@
   std::vector Symbols;
 };
 
+class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
+  : MatchFinder(), Collector(), Handler(&Collector),
+Matcher(Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &Compiler,
+StringRef InFile) override {
+Compiler.getPreprocessor().addCommentHandler(&Handler);
+return MatchFinder.newASTConsumer();
+  }
+
+private:
+  ast_matchers::MatchFinder MatchFinder;
+  HeaderMapCollector Collector;
+  PragmaCommentHandler Handler;
+  FindAllSymbols Matcher;
+};
+
+class TestFindAllSymbolsActionFactory
+: public clang::tooling::FrontendActionFactory {
+public:
+  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  : Reporter(Reporter) {}
+  clang::FrontendAction *create() override {
+return new TestFindAllSymbolsAction(Reporter);
+  }
+
+private:
+  MockReporter *const Reporter;
+};
+
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
 return Reporter.hasSymbol(Symbol);
   }
 
   bool runFindAllSymbols(StringRef Code) {
-FindAllSymbols matcher(&Reporter);
-clang::ast_matchers::MatchFinder MatchFinder;
-matcher.registerMatchers(&MatchFinder);
-
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
 new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
 std::string FileName = "symbol.cc";
-std::unique_ptr Factory =
-clang::tooling::newFrontendActionFactory(&MatchFinder);
+
+std::unique_ptr Factory(
+new TestFindAllSymbolsActionFactory(&Reporter));
+
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
  std::string("-std=c++11"), FileName},
@@ -329,5 +365,18 @@
   EXPECT_FALSE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, IWYUPrivatePragmaTest) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+struct Bar {
+};
+  )";
+  runFindAllSymbols(Code);
+
+  SymbolInfo Symbol =
+  SymbolInfo("Bar", SymbolInfo::SymbolKind::Class, "bar.h", 3, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/PragmaCommentHandler.h
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/PragmaCommentHandler.h
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/PragmaCommentHandler.h
@@ -0,0 +1,41 @@
+//===-- PragmaCommentHandler.h - find all symbols*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--

Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-17 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57493.
hokein added a comment.

Rebase.


http://reviews.llvm.org/D19816

Files:
  include-fixer/find-all-symbols/CMakeLists.txt
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/HeaderMapCollector.h
  include-fixer/find-all-symbols/PragmaCommentHandler.cpp
  include-fixer/find-all-symbols/PragmaCommentHandler.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -8,11 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -50,25 +53,58 @@
   std::vector Symbols;
 };
 
+class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
+  : MatchFinder(), Collector(), Handler(&Collector),
+Matcher(Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &Compiler,
+StringRef InFile) override {
+Compiler.getPreprocessor().addCommentHandler(&Handler);
+return MatchFinder.newASTConsumer();
+  }
+
+private:
+  ast_matchers::MatchFinder MatchFinder;
+  HeaderMapCollector Collector;
+  PragmaCommentHandler Handler;
+  FindAllSymbols Matcher;
+};
+
+class TestFindAllSymbolsActionFactory
+: public clang::tooling::FrontendActionFactory {
+public:
+  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  : Reporter(Reporter) {}
+  clang::FrontendAction *create() override {
+return new TestFindAllSymbolsAction(Reporter);
+  }
+
+private:
+  MockReporter *const Reporter;
+};
+
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
 return Reporter.hasSymbol(Symbol);
   }
 
   bool runFindAllSymbols(StringRef Code) {
-FindAllSymbols matcher(&Reporter);
-clang::ast_matchers::MatchFinder MatchFinder;
-matcher.registerMatchers(&MatchFinder);
-
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
 new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
 std::string FileName = "symbol.cc";
-std::unique_ptr Factory =
-clang::tooling::newFrontendActionFactory(&MatchFinder);
+
+std::unique_ptr Factory(
+new TestFindAllSymbolsActionFactory(&Reporter));
+
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
  std::string("-std=c++11"), FileName},
@@ -327,5 +363,18 @@
   EXPECT_FALSE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, IWYUPrivatePragmaTest) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+struct Bar {
+};
+  )";
+  runFindAllSymbols(Code);
+
+  SymbolInfo Symbol =
+  SymbolInfo("Bar", SymbolInfo::SymbolKind::Class, "bar.h", 3, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -8,8 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -82,6 +88,31 @@
   std::map> Symbols;
 };
 
+class FindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  FindAllSymbolsAction()
+  : Reporter(), MatchFinder(), Collector(), Handler(&Collector),
+Matcher(&Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+ 

r269780 - Tentatively enable -Wcast-calling-convention by default

2016-05-17 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue May 17 11:50:45 2016
New Revision: 269780

URL: http://llvm.org/viewvc/llvm-project?rev=269780&view=rev
Log:
Tentatively enable -Wcast-calling-convention by default

In Chrome, this would have found two true positives around CreateThread
if we hadn't already fixed them while rolling out ASan. We didn't get
any other hits in Chrome. I'm curious to hear if this warning finds
anything in other projects.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=269780&r1=269779&r2=269780&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 17 11:50:45 
2016
@@ -6639,7 +6639,7 @@ def warn_function_def_in_objc_container
 def warn_cast_calling_conv : Warning<
   "cast between incompatible calling conventions '%0' and '%1'; "
   "calls through this pointer may abort at runtime">,
-  InGroup>, DefaultIgnore;
+  InGroup>;
 def note_change_calling_conv_fixit : Note<
   "consider defining %0 with the '%1' calling convention">;
 def warn_bad_function_cast : Warning<


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


Re: r269214 - Relax -Wcalling-convention-cast when casting to the default convention (cdecl)

2016-05-17 Thread Reid Kleckner via cfe-commits
Cool, r269780. Let's see if anyone finds any bugs or false positives.

On Mon, May 16, 2016 at 4:10 PM, Nico Weber  wrote:
> After this tweak, Chromium builds cleanly with the new warning enabled.
> Maybe it's time to turn it on by default.
>
> On Wed, May 11, 2016 at 1:43 PM, Reid Kleckner via cfe-commits
>  wrote:
>>
>> Author: rnk
>> Date: Wed May 11 12:43:13 2016
>> New Revision: 269214
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=269214&view=rev
>> Log:
>> Relax -Wcalling-convention-cast when casting to the default convention
>> (cdecl)
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaCast.cpp
>> cfe/trunk/test/Sema/callingconv-cast.c
>>
>> Modified: cfe/trunk/lib/Sema/SemaCast.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=269214&r1=269213&r2=269214&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaCast.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaCast.cpp Wed May 11 12:43:13 2016
>> @@ -1760,7 +1760,15 @@ static void DiagnoseCallingConvCast(Sema
>>if (!FD || !FD->hasBody(Definition))
>>  return;
>>
>> -  // The source expression is a pointer to a known function defined in
>> this TU.
>> +  // Only warn if we are casting from the default convention to a
>> non-default
>> +  // convention. This can happen when the programmer forgot to apply the
>> calling
>> +  // convention to the function definition and then inserted this cast to
>> +  // satisfy the type system.
>> +  CallingConv DefaultCC =
>> Self.getASTContext().getDefaultCallingConvention(
>> +  FD->isVariadic(), FD->isCXXInstanceMember());
>> +  if (DstCC == DefaultCC || SrcCC != DefaultCC)
>> +return;
>> +
>>// Diagnose this cast, as it is probably bad.
>>StringRef SrcCCName = FunctionType::getNameForCallConv(SrcCC);
>>StringRef DstCCName = FunctionType::getNameForCallConv(DstCC);
>>
>> Modified: cfe/trunk/test/Sema/callingconv-cast.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/callingconv-cast.c?rev=269214&r1=269213&r2=269214&view=diff
>>
>> ==
>> --- cfe/trunk/test/Sema/callingconv-cast.c (original)
>> +++ cfe/trunk/test/Sema/callingconv-cast.c Wed May 11 12:43:13 2016
>> @@ -21,6 +21,10 @@ void mismatched(int x) {}
>>  typedef void (WINAPI *callback_t)(int);
>>  void take_callback(callback_t callback);
>>
>> +void WINAPI mismatched_stdcall(int x) {}
>> +
>> +void take_opaque_fn(void (*callback)(int));
>> +
>>  int main() {
>>// expected-warning@+1 {{cast between incompatible calling conventions
>> 'cdecl' and 'stdcall'}}
>>take_callback((callback_t)mismatched);
>> @@ -44,6 +48,11 @@ int main() {
>>
>>// Another way to suppress the warning.
>>take_callback((callback_t)(void*)mismatched);
>> +
>> +  // Don't warn, because we're casting from stdcall to cdecl. Usually
>> that means
>> +  // the programmer is rinsing the function pointer through some kind of
>> opaque
>> +  // API.
>> +  take_opaque_fn((void (*)(int))mismatched_stdcall);
>>  }
>>
>>  // MSFIXIT: fix-it:"{{.*}}callingconv-cast.c":{19:6-19:6}:"WINAPI "
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

2016-05-17 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57496.
hokein added a comment.

Address review comments.


http://reviews.llvm.org/D20326

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -16,6 +16,7 @@
  public:
   static int ii;
 };
+template  class J {};
 
 class Base {
  public:
@@ -29,6 +30,7 @@
 int UnusedFunc() { return 1; }
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
+template  int UsedInTemplateFunc() { return 1; }
 
 class ostream {
 public:
@@ -70,6 +72,13 @@
 using n::cout;
 using n::endl;
 
+using n::UsedInTemplateFunc;
+using n::J;
+template  void Callee() {
+  J j;
+  UsedInTemplateFunc();
+}
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,20 +10,29 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
+namespace {
+// FIXME: Add a node matcher for UnresolvedLookupExpr in ASTMatcher.
+AST_MATCHER(CallExpr, hasUnresolvedLookupExpr) {
+  return isa(Node.getCallee());
+}
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
   Finder->addMatcher(declRefExpr().bind("used"), this);
+  Finder->addMatcher(callExpr(hasUnresolvedLookupExpr()).bind("used"), this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -81,6 +90,14 @@
   removeFromFoundDecls(VD);
 }
   }
+  // Check the uninstantiated template function usage.
+  if (auto *CE = Result.Nodes.getNodeAs("used")) {
+auto *ULE = dyn_cast(CE->getCallee());
+for (auto I = ULE->decls_begin(), E = ULE->decls_end(); I != E; ++I) {
+  if (auto *USD = dyn_cast(I.getDecl()))
+removeFromFoundDecls(USD->getTargetDecl()->getCanonicalDecl());
+}
+  }
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {


Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -16,6 +16,7 @@
  public:
   static int ii;
 };
+template  class J {};
 
 class Base {
  public:
@@ -29,6 +30,7 @@
 int UnusedFunc() { return 1; }
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
+template  int UsedInTemplateFunc() { return 1; }
 
 class ostream {
 public:
@@ -70,6 +72,13 @@
 using n::cout;
 using n::endl;
 
+using n::UsedInTemplateFunc;
+using n::J;
+template  void Callee() {
+  J j;
+  UsedInTemplateFunc();
+}
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,20 +10,29 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
+namespace {
+// FIXME: Add a node matcher for UnresolvedLookupExpr in ASTMatcher.
+AST_MATCHER(CallExpr, hasUnresolvedLookupExpr) {
+  return isa(Node.getCallee());
+}
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
   Finder->addMatcher(declRefExpr().bind("used"), this);
+  Finder->addMatcher(callExpr(hasUnresolvedLookupExpr()).bind("used"), this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -81,6 +90,14 @@
   removeFromFoundDecls(VD);
 }
   }
+  // Check the uninstantiated template function usage.
+  if (auto *CE = Result.Nod

Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

2016-05-17 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:24
@@ +23,3 @@
+AST_MATCHER(CallExpr, hasUnresolvedLookupExpr) {
+  return isa(Node.getCallee());
+}

alexfh wrote:
> I think, we should use a node matcher for `UnresolvedLookupExpr` and instead 
> use `callExpr(callee(unresolvedLookupExpr().bind("something")))`.
> 
> Also, I would create the new matcher in the ASTMatchers.h right away, 
> together with a test and docs. But if you want this patch to be in soon, feel 
> free to move the matcher to the matchers library in a follow up.
Agree. I will add a node matcher for `UnresolvedLookupExpr` in a follow-up 
patch.


http://reviews.llvm.org/D20326



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


r269781 - Fix calling convention test

2016-05-17 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue May 17 11:54:40 2016
New Revision: 269781

URL: http://llvm.org/viewvc/llvm-project?rev=269781&view=rev
Log:
Fix calling convention test

Modified:
cfe/trunk/test/Sema/callingconv-cast.c

Modified: cfe/trunk/test/Sema/callingconv-cast.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/callingconv-cast.c?rev=269781&r1=269780&r2=269781&view=diff
==
--- cfe/trunk/test/Sema/callingconv-cast.c (original)
+++ cfe/trunk/test/Sema/callingconv-cast.c Tue May 17 11:54:40 2016
@@ -3,9 +3,6 @@
 // RUN: %clang_cc1 -fms-extensions -triple i686-pc-windows-msvc 
-Wcast-calling-convention -DMSVC -fdiagnostics-parseable-fixits %s 2>&1 | 
FileCheck %s --check-prefix=MSFIXIT
 // RUN: %clang_cc1 -triple i686-pc-windows-gnu -Wcast-calling-convention 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s --check-prefix=GNUFIXIT
 
-// Check that the warning is disabled by default:
-// RUN: %clang_cc1 -fms-extensions -triple i686-pc-windows-msvc -DMSVC -Werror 
-Wno-pointer-bool-conversion -x c %s
-
 // expected-note@+1 {{consider defining 'mismatched_before_winapi' with the 
'stdcall' calling convention}}
 void mismatched_before_winapi(int x) {}
 


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


Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-17 Thread Martin Probst via cfe-commits
mprobst added a comment.

PTAL.



Comment at: lib/Format/SortJavaScriptImports.cpp:45-46
@@ +44,4 @@
+
+struct JsImportExport {
+  bool IsExport;
+  // JS imports are sorted into these categories, in order.

klimek wrote:
> klimek wrote:
> > This is really weird - a class called ImportExport that then has a bool 
> > IsExport. Please explain in a comment why you're doing that instead of any 
> > of:
> > a) managing a set of imports and exports on their own
> > b) calling this something else
> > c) having a class hierarchy
> As not all of the members will be default initialized I'd prefer to have 
> constructors.
Discussed offline. I stand by this code. Yes, it has an odd boolean flag, but 
imports and exports in ES6 are essentially the same syntactical construct, with 
exports being syntactic sugar for import followed by export.

I've updated the comment on this struct substantially to explain that (I can 
tell how it's non-obvious).

Note that the boolean is never dispatched on in this code, except for the 
"empty line before exports" part. Exports are the same as imports wrt sorting 
them here.


Comment at: lib/Format/SortJavaScriptImports.cpp:115
@@ +114,3 @@
+  LineEnd = Line->Last;
+  JsImportExport ImpExp;
+  skipComments();

klimek wrote:
> When I see ImpExp I think "ImplicitExpression". I'd name this ImportExport.
> Also, it seems like we now have an uninitialized bool and enum in the struct.
Now called `Reference`.


Comment at: lib/Format/SortJavaScriptImports.cpp:207
@@ +206,3 @@
+
+  StringRef getSourceText(SourceLocation Start, SourceLocation End) {
+const SourceManager &SM = Env.getSourceManager();

klimek wrote:
> Usually we call Lexer::getSourceText for that (don't we have a Lexer?)
We don't, FormatTokenLexer doesn't expose the `Lexer`, and `TokenAnalyzer` 
doesn't export `FormatTokenLexer`.


Comment at: lib/Format/SortJavaScriptImports.cpp:258
@@ +257,3 @@
+return false;
+  if (!Current->is(Keywords.kw_as) || !nextToken())
+return false;

klimek wrote:
> Please don't put side-effects into an if (). This might be generally easier 
> to read if nextToken() can't fail, and instead creates an invalid token.
Done, much cleaner indeed. LLVM style guide says not to introduce new static 
globals with constructors, so I'm just using a field. Please advise if there's 
a better way.


http://reviews.llvm.org/D20198



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


Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-17 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 57497.
mprobst marked 8 inline comments as done.
mprobst added a comment.

- address review comments


http://reviews.llvm.org/D20198

Files:
  include/clang/Format/Format.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/SortJavaScriptImports.cpp
  lib/Format/SortJavaScriptImports.h
  lib/Format/TokenAnalyzer.cpp
  lib/Format/TokenAnalyzer.h
  unittests/Format/CMakeLists.txt
  unittests/Format/SortImportsTestJS.cpp

Index: unittests/Format/SortImportsTestJS.cpp
===
--- /dev/null
+++ unittests/Format/SortImportsTestJS.cpp
@@ -0,0 +1,137 @@
+//===- unittest/Format/SortImportsTestJS.cpp - JS import sort unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+namespace {
+
+class SortImportsTestJS : public ::testing::Test {
+protected:
+  std::vector GetCodeRange(StringRef Code) {
+return std::vector(1, tooling::Range(0, Code.size()));
+  }
+
+  std::string sort(StringRef Code, StringRef FileName = "input.js") {
+auto Ranges = GetCodeRange(Code);
+std::string Sorted =
+applyAllReplacements(Code, sortIncludes(Style, Code, Ranges, FileName));
+return applyAllReplacements(Sorted,
+reformat(Style, Sorted, Ranges, FileName));
+  }
+
+  void verifySort(llvm::StringRef Expected, llvm::StringRef Code) {
+std::string Result = sort(Code);
+EXPECT_EQ(Expected.str(), Result) << "Formatted:\n" << Result;
+  }
+
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+};
+
+TEST_F(SortImportsTestJS, BasicSorting) {
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;",
+ "import {sym} from 'a';\n"
+ "import {sym} from 'c';\n"
+ "import {sym} from 'b';\n"
+ "let x = 1;");
+}
+
+TEST_F(SortImportsTestJS, Comments) {
+  verifySort("/** @fileoverview This is a great file. */\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n"
+ "import {sym} from 'b'; // from //foo:bar\n",
+ "/** @fileoverview This is a great file. */\n"
+ "import {sym} from 'b'; // from //foo:bar\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n");
+}
+
+TEST_F(SortImportsTestJS, SortStar) {
+  verifySort("import * as foo from 'a';\n"
+ "import {sym} from 'a';\n"
+ "import * as bar from 'b';\n",
+ "import {sym} from 'a';\n"
+ "import * as foo from 'a';\n"
+ "import * as bar from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, AliasesSymbols) {
+  verifySort("import {sym1 as alias1} from 'b';\n"
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n",
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n"
+ "import {sym1 as alias1} from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, GroupImports) {
+  verifySort("import {a} from 'absolute';\n"
+ "\n"
+ "import {b} from '../parent';\n"
+ "import {b} from '../parent/nested';\n"
+ "\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from './relative/path/nested';\n"
+ "\n"
+ "let x = 1;\n",
+ "import {b} from './relative/path/nested';\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from '../parent/nested';\n"
+ "import {b} from '../parent';\n"
+ "import {a} from 'absolute';\n"
+ "let x = 1;\n");
+}
+
+TEST_F(SortImportsTestJS, Exports) {
+  verifySort("import {S} from 'bpath';\n"
+ "\n"
+ "import {T} from './cpath';\n"
+ "\n"
+ "export {A, B} from 'apath';\n"
+ "export {P} from '../parent';\n"
+ "export {R} from './relative';\n"
+ "export {S};\n"
+ "\n"
+ "let x = 1;\n"
+ "export y = 1;\n",
+ "export {R} from './relative';\n"
+ "import {T} from './cpath';\n"
+ "export {S};\n"
+ "export {A, B} from 'apath';\n"
+ "import {S} from 'bpath';\n"
+ "export {P} from '../parent';\n"
+ "let x = 1;\n"
+ "export y =

Re: r269717 - Switch from SmallVector to TinyPtrVector for the list of attributes on a declaration. This removes a memory allocation for the common case where the declaration has only one attribute.

2016-05-17 Thread David Blaikie via cfe-commits
On Mon, May 16, 2016 at 3:53 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Mon May 16 17:53:19 2016
> New Revision: 269717
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269717&view=rev
> Log:
> Switch from SmallVector to TinyPtrVector for the list of attributes on a
> declaration. This removes a memory allocation for the common case where the
> declaration has only one attribute.
>

Just out of curiosity - if the SmallVector had a small size of 2, why was
an allocation done for a single attribute?


>
> Modified:
> cfe/trunk/include/clang/AST/AttrIterator.h
>
> Modified: cfe/trunk/include/clang/AST/AttrIterator.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/AttrIterator.h?rev=269717&r1=269716&r2=269717&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/AttrIterator.h (original)
> +++ cfe/trunk/include/clang/AST/AttrIterator.h Mon May 16 17:53:19 2016
> @@ -15,6 +15,7 @@
>  #define LLVM_CLANG_AST_ATTRITERATOR_H
>
>  #include "clang/Basic/LLVM.h"
> +#include "llvm/ADT/TinyPtrVector.h"
>  #include 
>
>  namespace clang {
> @@ -39,8 +40,8 @@ void operator delete[](void *Ptr, const
>  namespace clang {
>
>  /// AttrVec - A vector of Attr, which is how they are stored on the AST.
> -typedef SmallVector AttrVec;
> -typedef SmallVector ConstAttrVec;
> +typedef llvm::TinyPtrVector AttrVec;
> +typedef llvm::TinyPtrVector ConstAttrVec;
>
>  /// specific_attr_iterator - Iterates over a subrange of an AttrVec, only
>  /// providing attributes that are of a specific type.
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20325: Add ARM cdp intrinsics

2016-05-17 Thread Tim Northover via cfe-commits
t.p.northover added a subscriber: t.p.northover.
t.p.northover added a comment.

I don't think we need to wait until the document is public, necessarily. The 
entire AArch64 backend went in before the encodings were public outside ARM 
(except maybe in binutils source?) and releasing specifications with no 
implementation yet is a bit annoying too.

We may discover bugs (though this seems fairly straightforward), but I think 
it's highly unlikely we'll have vocal and powerful enough users of such a niche 
feature to prevent us fixing them.

I agree about the asm tests though, they belong in LLVM.



Comment at: include/clang/Basic/BuiltinsARM.def:55
@@ -54,3 +54,3 @@
 BUILTIN(__builtin_arm_mrc2, "UiUIiUIiUIiUIiUIi", "")
-BUILTIN(__builtin_arm_cdp, "vUiUiUiUiUiUi", "")
-BUILTIN(__builtin_arm_cdp2, "vUiUiUiUiUiUi", "")
+BUILTIN(__builtin_arm_cdp, "vUIiUIiUIiUIiUIiUIi", "")
+BUILTIN(__builtin_arm_cdp2, "vUIiUIiUIiUIiUIiUIi", "")

rengolin wrote:
> I wonder why the old signature was wrong... probably because the docs weren't 
> public and no one could really check whether they were right or not. I don't 
> want to repeat the same mistake.
The difference between "UIi" and "Ui" is that the fix requires a constant. A 
pretty obvious restriction even without a specification.


Repository:
  rL LLVM

http://reviews.llvm.org/D20325



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


Re: [PATCH] D20325: Add ARM cdp intrinsics

2016-05-17 Thread Renato Golin via cfe-commits
rengolin added a comment.

In http://reviews.llvm.org/D20325#432086, @t.p.northover wrote:

> I don't think we need to wait until the document is public, necessarily. The 
> entire AArch64 backend went in before the encodings were public outside ARM 
> (except maybe in binutils source?) and releasing specifications with no 
> implementation yet is a bit annoying too.


I don't think a small future ACLE builtin is on the same league as a whole new 
back-end. :)

Nor I think that having this when the docs are public, rather than now, will 
affect users in any way.

It's been our stance for a long time to require docs to approve changes, 
however small. I don't want to relax that which I think is a good constraint, 
not for such a seemly irrelevant issue.

I also doubt this will be the only addition in the new ACLE, so why not release 
the document, and then submit all changes then?

Or, maybe I am mistaken, and this is really that important... is it?

cheers,
--renato


Repository:
  rL LLVM

http://reviews.llvm.org/D20325



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


[clang-tools-extra] r269786 - [clang-tidy] Skip misc-macro-parentheses for namespaces (Fix PR27400)

2016-05-17 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Tue May 17 12:26:02 2016
New Revision: 269786

URL: http://llvm.org/viewvc/llvm-project?rev=269786&view=rev
Log:
[clang-tidy] Skip misc-macro-parentheses for namespaces (Fix PR27400)

If a use of a macro argument is preceded by the `namespace` keyword, do
not warn that the use should be wrapped in parentheses.

Patch by Mads Ravn!

Modified:
clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp?rev=269786&r1=269785&r2=269786&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp Tue May 
17 12:26:02 2016
@@ -184,6 +184,10 @@ void MacroParenthesesPPCallbacks::argume
 Next.isOneOf(tok::comma, tok::greater))
   continue;
 
+// Namespaces.
+if (Prev.is(tok::kw_namespace))
+  continue;
+
 Check->diag(Tok.getLocation(), "macro argument should be enclosed in "
"parentheses")
 << FixItHint::CreateInsertion(Tok.getLocation(), "(")

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp?rev=269786&r1=269785&r2=269786&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp Tue May 
17 12:26:02 2016
@@ -36,6 +36,7 @@
 #define GOOD25(t) std::set s
 #define GOOD26(x) (a->*x)
 #define GOOD27(x) (a.*x)
+#define GOOD28(x) namespace x {int b;}
 
 // These are allowed for now..
 #define MAYBE1*12.34


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


Re: Patch submission for bug 27400

2016-05-17 Thread Vedant Kumar via cfe-commits

> On May 17, 2016, at 2:59 AM, Mads Ravn  wrote:
> 
> Hi guys,
> 
> I just wanted to check up on this patch. I heard I could just reply to this 
> mail and see if I could 'ping' anyone in this regard. Hope it's OK.

Sorry for the delay! This looks good. Committed as r269786.

thanks,
vedant

> 
> Best regards,
> Mads Ravn
> 
> On Thu, May 12, 2016 at 6:11 PM Mads Ravn  wrote:
> Hi,
> 
> I have fixed the things you mentioned now. I have attached the new patch to 
> this email.
> 
> Best regards,
> Mads Ravn
> 
> On Wed, May 11, 2016 at 11:54 PM Vedant Kumar  wrote:
> Hi,
> 
> Thanks for the patch!
> 
> This patch is missing a small, lit-style test case. You can find examples of 
> test cases here:
> 
>   extra/test/clang-tidy/
> 
> Apart from that, my only other nit-pick is that llvm uses 2-space indents, 
> and spaces between "if" and "(".
> 
> If you reply to this list with an updated patch, someone would be happy to 
> commit it for you.
> 
> best
> vedant
> 
> > On May 11, 2016, at 10:01 AM, Mads Ravn via cfe-commits 
> >  wrote:
> >
> > Hi,
> >
> > I would like to submit a patch for 
> > https://llvm.org/bugs/show_bug.cgi?id=27400 .
> >
> > Beside attaching the patch, is there anything I should be aware of? I have 
> > not submitted a patch before.
> >
> > You can find the patch attached to this mail.
> >
> > Kind regards,
> > Mads Ravn
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 

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


Re: [PATCH] D20325: Add ARM cdp intrinsics

2016-05-17 Thread Renato Golin via cfe-commits
rengolin added inline comments.


Comment at: include/clang/Basic/BuiltinsARM.def:55
@@ -54,3 +54,3 @@
 BUILTIN(__builtin_arm_mrc2, "UiUIiUIiUIiUIiUIi", "")
-BUILTIN(__builtin_arm_cdp, "vUiUiUiUiUiUi", "")
-BUILTIN(__builtin_arm_cdp2, "vUiUiUiUiUiUi", "")
+BUILTIN(__builtin_arm_cdp, "vUIiUIiUIiUIiUIiUIi", "")
+BUILTIN(__builtin_arm_cdp2, "vUIiUIiUIiUIiUIiUIi", "")

t.p.northover wrote:
> rengolin wrote:
> > I wonder why the old signature was wrong... probably because the docs 
> > weren't public and no one could really check whether they were right or 
> > not. I don't want to repeat the same mistake.
> The difference between "UIi" and "Ui" is that the fix requires a constant. A 
> pretty obvious restriction even without a specification.
Ah, this makes sense. Looks like a good change in its own.


Repository:
  rL LLVM

http://reviews.llvm.org/D20325



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


r269787 - Fix line numbers in calling convention test

2016-05-17 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue May 17 12:33:31 2016
New Revision: 269787

URL: http://llvm.org/viewvc/llvm-project?rev=269787&view=rev
Log:
Fix line numbers in calling convention test

Modified:
cfe/trunk/test/Sema/callingconv-cast.c

Modified: cfe/trunk/test/Sema/callingconv-cast.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/callingconv-cast.c?rev=269787&r1=269786&r2=269787&view=diff
==
--- cfe/trunk/test/Sema/callingconv-cast.c (original)
+++ cfe/trunk/test/Sema/callingconv-cast.c Tue May 17 12:33:31 2016
@@ -52,12 +52,12 @@ int main() {
   take_opaque_fn((void (*)(int))mismatched_stdcall);
 }
 
-// MSFIXIT: fix-it:"{{.*}}callingconv-cast.c":{19:6-19:6}:"WINAPI "
-// MSFIXIT: fix-it:"{{.*}}callingconv-cast.c":{19:6-19:6}:"WINAPI "
-// MSFIXIT: fix-it:"{{.*}}callingconv-cast.c":{19:6-19:6}:"WINAPI "
-// MSFIXIT: fix-it:"{{.*}}callingconv-cast.c":{10:6-10:6}:"__stdcall "
+// MSFIXIT: fix-it:"{{.*}}callingconv-cast.c":{16:6-16:6}:"WINAPI "
+// MSFIXIT: fix-it:"{{.*}}callingconv-cast.c":{16:6-16:6}:"WINAPI "
+// MSFIXIT: fix-it:"{{.*}}callingconv-cast.c":{16:6-16:6}:"WINAPI "
+// MSFIXIT: fix-it:"{{.*}}callingconv-cast.c":{7:6-7:6}:"__stdcall "
 
-// GNUFIXIT: fix-it:"{{.*}}callingconv-cast.c":{19:6-19:6}:"WINAPI "
-// GNUFIXIT: fix-it:"{{.*}}callingconv-cast.c":{19:6-19:6}:"WINAPI "
-// GNUFIXIT: fix-it:"{{.*}}callingconv-cast.c":{19:6-19:6}:"WINAPI "
-// GNUFIXIT: 
fix-it:"{{.*}}callingconv-cast.c":{10:6-10:6}:"__attribute__((stdcall)) "
+// GNUFIXIT: fix-it:"{{.*}}callingconv-cast.c":{16:6-16:6}:"WINAPI "
+// GNUFIXIT: fix-it:"{{.*}}callingconv-cast.c":{16:6-16:6}:"WINAPI "
+// GNUFIXIT: fix-it:"{{.*}}callingconv-cast.c":{16:6-16:6}:"WINAPI "
+// GNUFIXIT: 
fix-it:"{{.*}}callingconv-cast.c":{7:6-7:6}:"__attribute__((stdcall)) "


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


Re: [PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications

2016-05-17 Thread don hinton via cfe-commits
hintonda added inline comments.


Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:39
@@ +38,3 @@
+
+  // FIXME: Add paren matching so we can parse more complex throw statements,
+  // e.g., (examples provided by Aaron Ballman):

aaron.ballman wrote:
> @alexfh, what are your feelings on this FIXME? I am a bit concerned because 
> these examples will cause the replacement range to be incorrect, which will 
> turn working code into ill-formed code. The alternative, as I see it, is to 
> instead properly track the exception specification source range information 
> as part of the FunctionDecl (akin to 
> `FunctionDecl::getReturnTypeSourceRange()`).
Btw, I'm working on a fix I believe will handle all cases -- plan to checkin 
later today.  However, it won't be that efficient unless I can find a way to 
match params that contain dynamic exception specifications.  If they are only 
legal for function pointers -- which I think is the case -- that would make it 
easy and efficient, i.e., I wouldn't have to match all FunctionDecl's with one 
or more parameter and test them.

Is it possible to match a parameter that is a function pointer?


Comment at: docs/clang-tidy/checks/modernize-use-noexcept.rst:40
@@ +39,3 @@
+``noexcept(false)`` not ``noexcept``, this check will detect, but not
+provide a FixItHint in that case.
+

aaron.ballman wrote:
> This seems to run contrary to one of the examples below where a fixit is 
> provided for ``throw(A, B)``. If I understood properly, this statement is 
> only true when using a ReplacementString. Perhaps it should instead say, 
> "this check will detect, but not
> provide a FixItHint for this case when a :option:`ReplacementString` is 
> provided."
This is only applicable when the user provided a replacement string other than 
noexcept.  I'll try to make it clearer, however, there is a FIXME in the code 
concerning this.  Specifically, should we allow replacement options for both 
noexcept and noexcept(false).


http://reviews.llvm.org/D18575



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


Re: [PATCH] D19990: [CUDA] Implement __ldg using intrinsics.

2016-05-17 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Friendly ping.  This is a big help with some Tensorflow benchmarks.


http://reviews.llvm.org/D19990



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


[libcxx] r269789 - Implement LWG2576: istream_iterator and ostream_iterator should use std::addressof

2016-05-17 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue May 17 12:44:40 2016
New Revision: 269789

URL: http://llvm.org/viewvc/llvm-project?rev=269789&view=rev
Log:
Implement LWG2576: istream_iterator and ostream_iterator should use 
std::addressof

Modified:
libcxx/trunk/include/iterator
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/iterator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=269789&r1=269788&r2=269789&view=diff
==
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Tue May 17 12:44:40 2016
@@ -772,14 +772,14 @@ private:
 _Tp __value_;
 public:
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : 
__in_stream_(0), __value_() {}
-_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : 
__in_stream_(&__s)
+_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : 
__in_stream_(_VSTD::addressof(__s))
 {
 if (!(*__in_stream_ >> __value_))
 __in_stream_ = 0;
 }
 
 _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;}
-_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return 
&(operator*());}
+_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return 
_VSTD::addressof((operator*()));}
 _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
 {
 if (!(*__in_stream_ >> __value_))
@@ -811,9 +811,9 @@ private:
 const char_type* __delim_;
 public:
 _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s)
-: __out_stream_(&__s), __delim_(0) {}
+: __out_stream_(_VSTD::addressof(__s)), __delim_(0) {}
 _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const 
_CharT* __delimiter)
-: __out_stream_(&__s), __delim_(__delimiter) {}
+: __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}
 _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_)
 {
 *__out_stream_ << __value_;

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=269789&r1=269788&r2=269789&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Tue May 17 12:44:40 2016
@@ -222,7 +222,7 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2572";>2572The
 remarks for shared_ptr::operator* should apply to cv-qualified 
void as wellJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2574";>2574[fund.ts.v2]
 std::experimental::function::operator=(F&&) should be 
constrainedJacksonville
http://cplusplus.github.io/LWG/lwg-defects.html#2575";>2575[fund.ts.v2]
 experimental::function::assign should be 
removedJacksonville
-   http://cplusplus.github.io/LWG/lwg-defects.html#2576";>2576istream_iterator
 and ostream_iterator should use 
std::addressofJacksonville
+   http://cplusplus.github.io/LWG/lwg-defects.html#2576";>2576istream_iterator
 and ostream_iterator should use 
std::addressofJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2577";>2577{shared,unique}_lock
 should use 
std::addressofJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2579";>2579Inconsistency
 wrt Allocators in basic_string assignment vs. 
basic_string::assignJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2581";>2581Specialization
 of  variable templates should be 
prohibitedJacksonvilleComplete


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


Re: [PATCH] D19909: [Attr] Add support for the `ms_hook_prologue` attribute.

2016-05-17 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

The patch is missing semantic test cases. I would like to see tests of the 
attribute being accepted, as well as rejected because the subject was 
incorrect, args were provided, etc.

Also, I believe there are attributes which this attribute should not be 
combined with, such as `__declspec(naked)`. I think we should diagnose in that 
case (MSVC does not because the entire object file is hotpatched, not 
individual functions). e.g., `__declspec(naked) void f(void) 
__attribute__((ms_hook_prologue));`



Comment at: include/clang/Basic/Attr.td:2032
@@ -2031,1 +2031,3 @@
 
+def MSHookPrologue : InheritableAttr {
+  let Spellings = [GCC<"ms_hook_prologue">];

I am wondering whether we want this to be a target-specific attribute or not. 
Right now, this attribute will be silently accepted for CPUs that MSVC does not 
support, for instance. If we made the attribute target-specific, then users 
would get appropriate diagnostics for those architectures.


http://reviews.llvm.org/D19909



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


r269794 - NFC: simplify logic.

2016-05-17 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue May 17 13:04:38 2016
New Revision: 269794

URL: http://llvm.org/viewvc/llvm-project?rev=269794&view=rev
Log:
NFC: simplify logic.

Modified:
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=269794&r1=269793&r2=269794&view=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Tue May 17 13:04:38 2016
@@ -617,8 +617,8 @@ const FileEntry *HeaderSearch::LookupFil
   // from a module build. We should treat this as a system header if we're
   // building a [system] module.
   bool IncluderIsSystemHeader =
-  (Includer && getFileInfo(Includer).DirInfo != SrcMgr::C_User) ||
-  (!Includer && BuildSystemModule);
+  Includer ? getFileInfo(Includer).DirInfo != SrcMgr::C_User :
+  BuildSystemModule;
   if (const FileEntry *FE = getFileAndSuggestModule(
   TmpDir, IncluderAndDir.second, IncluderIsSystemHeader,
   RequestingModule, SuggestedModule)) {


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


Re: [PATCH] D20171: Support for MSVS default calling convention options (/Gd, /Gz, /Gv, /Gr)

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

Thanks, lgtm!


http://reviews.llvm.org/D20171



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


Re: [PATCH] D20296: clang-rename: avoid StringRef members in USRLocFindingASTVisitor

2016-05-17 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269796: clang-rename: avoid StringRef members in 
USRLocFindingASTVisitor (authored by vmiklos).

Changed prior to commit:
  http://reviews.llvm.org/D20296?vs=57385&id=57503#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20296

Files:
  clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp

Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -123,9 +123,9 @@
   }
 
   // All the locations of the USR were found.
-  StringRef USR;
+  const std::string USR;
   // Old name that is renamed.
-  StringRef PrevName;
+  const std::string PrevName;
   std::vector LocationsFound;
 };
 } // namespace


Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -123,9 +123,9 @@
   }
 
   // All the locations of the USR were found.
-  StringRef USR;
+  const std::string USR;
   // Old name that is renamed.
-  StringRef PrevName;
+  const std::string PrevName;
   std::vector LocationsFound;
 };
 } // namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r269796 - clang-rename: avoid StringRef members in USRLocFindingASTVisitor

2016-05-17 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Tue May 17 13:17:16 2016
New Revision: 269796

URL: http://llvm.org/viewvc/llvm-project?rev=269796&view=rev
Log:
clang-rename: avoid StringRef members in USRLocFindingASTVisitor

Even if this is defined in the .cpp file and only used as part of the
function (so here it's safe), usually storing StringRefs in the class is
dangerous, so don't do so.

Reviewers: cfe-commits, klimek

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

Modified:
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=269796&r1=269795&r2=269796&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Tue May 17 13:17:16 
2016
@@ -123,9 +123,9 @@ private:
   }
 
   // All the locations of the USR were found.
-  StringRef USR;
+  const std::string USR;
   // Old name that is renamed.
-  StringRef PrevName;
+  const std::string PrevName;
   std::vector LocationsFound;
 };
 } // namespace


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


Re: [PATCH] D17578: [OpenCL]Allowing explicit conversion of "0" to event_t type

2016-05-17 Thread Aaron En Ye Shi via cfe-commits
ashi1 added a comment.

Xiuli, are you OK with this patch?


http://reviews.llvm.org/D17578



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


Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

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


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:24
@@ +23,3 @@
+// FIXME: Add a node matcher for UnresolvedLookupExpr in ASTMatcher.
+AST_MATCHER(CallExpr, hasUnresolvedLookupExpr) {
+  return isa(Node.getCallee());

Sorry for being unclear. Please change this to the node matcher in this patch. 
You can move the matcher to the ASTMatchers.h as a follow-up. 
`hasUnresolvedLookupExpr` is not in line with the matchers design: the 
`CallExpr` node has no property `UnresolvedLookupExpr`. You'll also be able to 
bind the `UnresolvedLookupExpr` to an identifier and make the code in `check()` 
slightly shorter.


http://reviews.llvm.org/D20326



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


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

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

LG. Thank you!



Comment at: clang-tidy/utils/Matchers.h:20
@@ -19,1 +19,3 @@
 
+AST_MATCHER_P(Expr, ignoringImplicit,
+  ast_matchers::internal::Matcher, InnerMatcher) {

Consider moving this to ASTMatchers.h in a follow-up.


http://reviews.llvm.org/D19841



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


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

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


Comment at: clang-tidy/utils/Matchers.h:20
@@ -19,1 +19,3 @@
 
+AST_MATCHER_P(Expr, ignoringImplicit,
+  ast_matchers::internal::Matcher, InnerMatcher) {

alexfh wrote:
> Consider moving this to ASTMatchers.h in a follow-up.
Honestly, this one is a lot less interesting as a public AST matcher. I would 
avoid that unless there's a really solid case for it.


http://reviews.llvm.org/D19841



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


r269801 - Teach clang to look for libcxx in /usr/local/include/c++ on Linux

2016-05-17 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Tue May 17 14:01:16 2016
New Revision: 269801

URL: http://llvm.org/viewvc/llvm-project?rev=269801&view=rev
Log:
Teach clang to look for libcxx in /usr/local/include/c++ on Linux

As The default CMAKE install prefix is /usr/local ( 
https://cmake.org/cmake/help/v3.0/variable/CMAKE_INSTALL_PREFIX.html ),
sudo ninja install ends up installing clang, LLVM and libcxx under /usr/local.
In development scenario, when clang is run from the build location it will not
find libcxx at neither (build location)/../include/c++ nor /usr/include/c++.
This patch lets development clang find system installed libcxx without adding
-isystem /usr/local/include/c++. Also addresses the FIXME by explaining the 
use-case for these include paths.


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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=269801&r1=269800&r2=269801&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue May 17 14:01:16 2016
@@ -4130,11 +4130,11 @@ void Linux::AddClangCXXStdlibIncludeArgs
   if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) {
 const std::string LibCXXIncludePathCandidates[] = {
 DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
-
-// We also check the system as for a long time this is the only place
-// Clang looked.
-// FIXME: We should really remove this. It doesn't make any sense.
-DetectLibcxxIncludePath(getDriver().SysRoot + "/usr/include/c++")};
+// If this is a development, non-installed, clang, libcxx will
+// not be found at ../include/c++ but it likely to be found at
+// one of the following two locations:
+DetectLibcxxIncludePath(getDriver().SysRoot + 
"/usr/local/include/c++"),
+DetectLibcxxIncludePath(getDriver().SysRoot + "/usr/include/c++") };
 for (const auto &IncludePath : LibCXXIncludePathCandidates) {
   if (IncludePath.empty() || !getVFS().exists(IncludePath))
 continue;


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


Re: [PATCH] D18821: Add bugprone-bool-to-integer-conversion

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


Comment at: docs/clang-tidy/checks/bugprone-bool-to-integer-conversion.rst:43
@@ +42,3 @@
+
+This is because z and ``true`` will be implicitly converted to int by 
promotion.
+To get rid of this case use

This is a false positive and should be fixed regardless of whether we disable 
fixits or not. Just documenting it doesn't help much.


http://reviews.llvm.org/D18821



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


Re: [PATCH] D19990: [CUDA] Implement __ldg using intrinsics.

2016-05-17 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Basic/BuiltinsNVPTX.def:569-603
@@ -568,1 +568,37 @@
 
+// __ldg.  This is not implemented as a builtin by nvcc.
+BUILTIN(__nvvm_ldg_c, "ccC*", "")
+BUILTIN(__nvvm_ldg_s, "ssC*", "")
+BUILTIN(__nvvm_ldg_i, "iiC*", "")
+BUILTIN(__nvvm_ldg_l, "LiLiC*", "")
+BUILTIN(__nvvm_ldg_ll, "LLiLLiC*", "")
+
+BUILTIN(__nvvm_ldg_uc, "UcUcC*", "")
+BUILTIN(__nvvm_ldg_us, "UsUsC*", "")
+BUILTIN(__nvvm_ldg_ui, "UiUiC*", "")
+BUILTIN(__nvvm_ldg_ul, "ULiULiC*", "")
+BUILTIN(__nvvm_ldg_ull, "ULLiULLiC*", "")
+
+BUILTIN(__nvvm_ldg_f, "ffC*", "")
+BUILTIN(__nvvm_ldg_d, "ddC*", "")
+
+BUILTIN(__nvvm_ldg_c2, "E2cE2cC*", "")
+BUILTIN(__nvvm_ldg_c4, "E4cE4cC*", "")
+BUILTIN(__nvvm_ldg_s2, "E2sE2sC*", "")
+BUILTIN(__nvvm_ldg_s4, "E4sE4sC*", "")
+BUILTIN(__nvvm_ldg_i2, "E2iE2iC*", "")
+BUILTIN(__nvvm_ldg_i4, "E4iE4iC*", "")
+BUILTIN(__nvvm_ldg_ll2, "E2LLiE2LLiC*", "")
+
+BUILTIN(__nvvm_ldg_uc2, "E2UcE2UcC*", "")
+BUILTIN(__nvvm_ldg_uc4, "E4UcE4UcC*", "")
+BUILTIN(__nvvm_ldg_us2, "E2UsE2UsC*", "")
+BUILTIN(__nvvm_ldg_us4, "E4UsE4UsC*", "")
+BUILTIN(__nvvm_ldg_ui2, "E2UiE2UiC*", "")
+BUILTIN(__nvvm_ldg_ui4, "E4UiE4UiC*", "")
+BUILTIN(__nvvm_ldg_ull2, "E2ULLiE2ULLiC*", "")
+
+BUILTIN(__nvvm_ldg_f2, "E2fE2fC*", "")
+BUILTIN(__nvvm_ldg_f4, "E4fE4fC*", "")
+BUILTIN(__nvvm_ldg_d2, "E2dE2dC*", "")
+

It sounds like the combinatorial explosion will be unmanageable if we don't 
switch to using a generic builtin for the full suite of 'ld' operations, so it 
seems worthwhile to do that now. This would also be consistent with how we 
handle the somewhat-similar builtin `__builtin_nontemporal_load`.


http://reviews.llvm.org/D19990



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


[PATCH] D20334: [libcxx] Fix a bug in strstreambuf::overflow

2016-05-17 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: mclow.lists, EricWF, howard.hinnant.
ahatanak added a subscriber: cfe-commits.

The end pointer should point to one past the end of the newly allocated buffer.

Without this fix, asan reports an error when the following code is compiled and 
executed:

$ cat test.cpp

```
std::string stringOfLength(const size_t length) {
  std::string s("");

  std::string characters("abcdefghijklmnopqrstuvwxyz0123456789+-*/");
  for (size_t i = 0; i < length; ++i) {
s += characters[i % characters.size()];
  }

  return s;
}

int main(int, char const **argv) {
  std::ostrstream oss;

  oss << stringOfLength(atoi(argv[1])) << std::ends;
  std::cout << oss.str();
  oss.freeze(false);

  return 0;
}```

$ clang++  -fsanitize=address test.cpp && ./a.out 4096
==18970==ERROR: AddressSanitizer: heap-buffer-overflow on address 
0x6211dd00 at pc 0x00010277c45d bp 0x7fff5d4ce6e0 sp 0x7fff5d4cdea0
READ of size 4097 at 0x6211dd00 thread T0
#0 0x10277c45c in wrap_strlen (libclang_rt.asan_osx_dynamic.dylib+0x4345c)
#1 0x102733954 in std::__1::char_traits::length(char const*) 
(a.out+0x12954)
#2 0x10273390b in std::__1::basic_ostream 
>& std::__1::operator<< 
>(std::__1::basic_ostream >&, char const*) 
(a.out+0x1290b)
#3 0x102733346 in main (a.out+0x12346)
#4 0x7fff901905ac in start (libdyld.dylib+0x35ac)
#5 0x1  ()

0x6211dd00 is located 0 bytes to the right of 4096-byte region 
[0x6211cd00,0x6211dd00)
allocated by thread T0 here:
#0 0x10278d42b in wrap__Znam (libclang_rt.asan_osx_dynamic.dylib+0x5442b)
#1 0x7fff9bdc9fa1 in std::__1::strstreambuf::overflow(int) 
(libc++.1.dylib+0x44fa1)
#2 0x7fff9bd901cc in std::__1::basic_streambuf >::xsputn(char const*, long) (libc++.1.dylib+0xb1cc)
#3 0x10273547c in std::__1::ostreambuf_iterator > std::__1::__pad_and_output >(std::__1::ostreambuf_iterator >, char const*, char const*, char const*, 
std::__1::ios_base&, char) (a.out+0x1447c)
#4 0x102734312 in std::__1::basic_ostream 
>& std::__1::__put_character_sequence 
>(std::__1::basic_ostream >&, char const*, 
unsigned long) (a.out+0x13312)
#5 0x10273389d in std::__1::basic_ostream 
>& std::__1::operator<<, 
std::__1::allocator >(std::__1::basic_ostream >&, std::__1::basic_string, std::__1::allocator > const&) 
(a.out+0x1289d)
#6 0x1027332c4 in main (a.out+0x122c4)
#7 0x7fff901905ac in start (libdyld.dylib+0x35ac)
#8 0x1  ()

http://reviews.llvm.org/D20334

Files:
  src/strstream.cpp

Index: src/strstream.cpp
===
--- src/strstream.cpp
+++ src/strstream.cpp
@@ -180,7 +180,7 @@
 delete [] eback();
 }
 setg(buf, buf + ninp, buf + einp);
-setp(buf + einp, buf + einp + eout);
+setp(buf + einp, buf + new_size);
 pbump(static_cast(nout));
 __strmode_ |= __allocated;
 }


Index: src/strstream.cpp
===
--- src/strstream.cpp
+++ src/strstream.cpp
@@ -180,7 +180,7 @@
 delete [] eback();
 }
 setg(buf, buf + ninp, buf + einp);
-setp(buf + einp, buf + einp + eout);
+setp(buf + einp, buf + new_size);
 pbump(static_cast(nout));
 __strmode_ |= __allocated;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r269804 - [clang-tidy] Lift common matchers to utils namespace

2016-05-17 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Tue May 17 14:36:09 2016
New Revision: 269804

URL: http://llvm.org/viewvc/llvm-project?rev=269804&view=rev
Log:
[clang-tidy] Lift common matchers to utils namespace

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

Reviewers: aaron.ballman, alexfh

Subscribers: aaron.ballman, cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/trunk/clang-tidy/performance/FasterStringFindCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/utils/Matchers.h

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp?rev=269804&r1=269803&r2=269804&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp 
Tue May 17 14:36:09 2016
@@ -15,14 +15,6 @@ namespace clang {
 namespace tidy {
 namespace misc {
 
-namespace {
-
-AST_MATCHER(CastExpr, isPointerToBoolean) {
-  return Node.getCastKind() == CK_PointerToBoolean;
-}
-
-} // namespace
-
 void BoolPointerImplicitConversionCheck::registerMatchers(MatchFinder *Finder) 
{
   // Look for ifs that have an implicit bool* to bool conversion in the
   // condition. Filter negations.
@@ -32,7 +24,7 @@ void BoolPointerImplicitConversionCheck:
hasSourceExpression(expr(
hasType(pointerType(pointee(booleanType(,
ignoringParenImpCasts(declRefExpr().bind("expr",
-   isPointerToBoolean(),
+   hasCastKind(CK_PointerToBoolean),
  unless(isInTemplateInstantiation())).bind("if"),
   this);
 }

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=269804&r1=269803&r2=269804&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Tue May 17 
14:36:09 2016
@@ -24,20 +24,6 @@ namespace {
 
 const char CastSequence[] = "sequence";
 
-/// \brief Matches cast expressions that have a cast kind of CK_NullToPointer
-/// or CK_NullToMemberPointer.
-///
-/// Given
-/// \code
-///   int *p = 0;
-/// \endcode
-/// implicitCastExpr(isNullToPointer()) matches the implicit cast clang adds
-/// around \c 0.
-AST_MATCHER(CastExpr, isNullToPointer) {
-  return Node.getCastKind() == CK_NullToPointer ||
- Node.getCastKind() == CK_NullToMemberPointer;
-}
-
 AST_MATCHER(Type, sugaredNullptrType) {
   const Type *DesugaredType = Node.getUnqualifiedDesugaredType();
   if (const BuiltinType *BT = dyn_cast(DesugaredType))
@@ -52,7 +38,8 @@ AST_MATCHER(Type, sugaredNullptrType) {
 /// can be replaced instead of just the inner-most implicit cast.
 StatementMatcher makeCastSequenceMatcher() {
   StatementMatcher ImplicitCastToNull = implicitCastExpr(
-  isNullToPointer(),
+  anyOf(hasCastKind(CK_NullToPointer),
+hasCastKind(CK_NullToMemberPointer)),
   unless(hasSourceExpression(hasType(sugaredNullptrType();
 
   return castExpr(anyOf(ImplicitCastToNull,

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/FasterStringFindCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/FasterStringFindCheck.cpp?rev=269804&r1=269803&r2=269804&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/performance/FasterStringFindCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/performance/FasterStringFindCheck.cpp 
Tue May 17 14:36:09 2016
@@ -38,8 +38,6 @@ llvm::Optional MakeCharacte
   return Result;
 }
 
-AST_MATCHER(StringLiteral, lengthIsOne) { return Node.getLength() == 1; }
-
 AST_MATCHER_FUNCTION(ast_matchers::internal::Matcher,
  hasSubstitutedType) {
   return hasType(qualType(anyOf(substTemplateTypeParmType(),
@@ -65,7 +63,7 @@ void FasterStringFindCheck::registerMatc
 return;
 
   const auto SingleChar =
-  expr(ignoringParenCasts(stringLiteral(lengthIsOne()).bind("literal")));
+  expr(ignoringParenCasts(stringLiteral(hasSize(1)).bind("literal")));
 
   const auto StringFindFunctions =
   anyOf(h

[libclc] r269807 - math: Use single precision fmax in sp path

2016-05-17 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Tue May 17 14:44:01 2016
New Revision: 269807

URL: http://llvm.org/viewvc/llvm-project?rev=269807&view=rev
Log:
math: Use single precision fmax in sp path

Fixes fdim piglit on Turks

v2: use CL fmax instead of __builtin

Signed-off-by: Jan Vesely 
Reviewed-by: Tom Stellard 

Modified:
libclc/trunk/generic/lib/math/fdim.inc

Modified: libclc/trunk/generic/lib/math/fdim.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/fdim.inc?rev=269807&r1=269806&r2=269807&view=diff
==
--- libclc/trunk/generic/lib/math/fdim.inc (original)
+++ libclc/trunk/generic/lib/math/fdim.inc Tue May 17 14:44:01 2016
@@ -25,7 +25,7 @@
 _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE fdim(__CLC_GENTYPE x, __CLC_GENTYPE y) {
 if (__builtin_isnan(x) || __builtin_isnan(y))
 return as_float(QNANBITPATT_SP32);
-return __builtin_fmax(x - y, 0);
+return fmax(x - y, 0.0f);
 }
 #define __CLC_FDIM_VEC(width) \
 _CLC_OVERLOAD _CLC_DEF float##width fdim(float##width x, float##width y) { \


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


Re: [libcxx] r269789 - Implement LWG2576: istream_iterator and ostream_iterator should use std::addressof

2016-05-17 Thread David Blaikie via cfe-commits
Test coverage?

On Tue, May 17, 2016 at 10:44 AM, Marshall Clow via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: marshall
> Date: Tue May 17 12:44:40 2016
> New Revision: 269789
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269789&view=rev
> Log:
> Implement LWG2576: istream_iterator and ostream_iterator should use
> std::addressof
>
> Modified:
> libcxx/trunk/include/iterator
> libcxx/trunk/www/cxx1z_status.html
>
> Modified: libcxx/trunk/include/iterator
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=269789&r1=269788&r2=269789&view=diff
>
> ==
> --- libcxx/trunk/include/iterator (original)
> +++ libcxx/trunk/include/iterator Tue May 17 12:44:40 2016
> @@ -772,14 +772,14 @@ private:
>  _Tp __value_;
>  public:
>  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() :
> __in_stream_(0), __value_() {}
> -_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
> __in_stream_(&__s)
> +_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
> __in_stream_(_VSTD::addressof(__s))
>  {
>  if (!(*__in_stream_ >> __value_))
>  __in_stream_ = 0;
>  }
>
>  _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return
> __value_;}
> -_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
> &(operator*());}
> +_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
> _VSTD::addressof((operator*()));}
>  _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
>  {
>  if (!(*__in_stream_ >> __value_))
> @@ -811,9 +811,9 @@ private:
>  const char_type* __delim_;
>  public:
>  _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s)
> -: __out_stream_(&__s), __delim_(0) {}
> +: __out_stream_(_VSTD::addressof(__s)), __delim_(0) {}
>  _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const
> _CharT* __delimiter)
> -: __out_stream_(&__s), __delim_(__delimiter) {}
> +: __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}
>  _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp&
> __value_)
>  {
>  *__out_stream_ << __value_;
>
> Modified: libcxx/trunk/www/cxx1z_status.html
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=269789&r1=269788&r2=269789&view=diff
>
> ==
> --- libcxx/trunk/www/cxx1z_status.html (original)
> +++ libcxx/trunk/www/cxx1z_status.html Tue May 17 12:44:40 2016
> @@ -222,7 +222,7 @@
> http://cplusplus.github.io/LWG/lwg-defects.html#2572";>2572The
> remarks for shared_ptr::operator* should apply to
> cv-qualified void as
> wellJacksonvilleComplete
> http://cplusplus.github.io/LWG/lwg-defects.html#2574";>2574[fund.ts.v2]
> std::experimental::function::operator=(F&&) should be
> constrainedJacksonville
> http://cplusplus.github.io/LWG/lwg-defects.html#2575";>2575[fund.ts.v2]
> experimental::function::assign should be
> removedJacksonville
> -   http://cplusplus.github.io/LWG/lwg-defects.html#2576";>2576istream_iterator
> and ostream_iterator should use
> std::addressofJacksonville
> +   http://cplusplus.github.io/LWG/lwg-defects.html#2576";>2576istream_iterator
> and ostream_iterator should use
> std::addressofJacksonvilleComplete
> http://cplusplus.github.io/LWG/lwg-defects.html#2577";>2577{shared,unique}_lock
> should use
> std::addressofJacksonvilleComplete
> http://cplusplus.github.io/LWG/lwg-defects.html#2579";>2579Inconsistency
> wrt Allocators in basic_string assignment vs.
> basic_string::assignJacksonvilleComplete
> http://cplusplus.github.io/LWG/lwg-defects.html#2581";>2581Specialization
> of  variable templates should be
> prohibitedJacksonvilleComplete
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r269812 - Add test for r269789

2016-05-17 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May 17 14:52:32 2016
New Revision: 269812

URL: http://llvm.org/viewvc/llvm-project?rev=269812&view=rev
Log:
Add test for r269789

Modified:

libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp?rev=269812&r1=269811&r2=269812&view=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp
 Tue May 17 14:52:32 2016
@@ -23,6 +23,8 @@ struct A
 int i_;
 };
 
+void operator&(A const&) {}
+
 std::istream& operator>>(std::istream& is, A& a)
 {
 return is >> a.d_ >> a.i_;


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


Re: [libcxx] r269789 - Implement LWG2576: istream_iterator and ostream_iterator should use std::addressof

2016-05-17 Thread Eric Fiselier via cfe-commits
I added a test for operator->() in r269812. Marshall and I discussed
offline about how not all parts of this change are testable (and hence not
meaningful) but that's what the standard says to do.


On Tue, May 17, 2016 at 1:51 PM, David Blaikie via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Test coverage?
>
> On Tue, May 17, 2016 at 10:44 AM, Marshall Clow via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: marshall
>> Date: Tue May 17 12:44:40 2016
>> New Revision: 269789
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=269789&view=rev
>> Log:
>> Implement LWG2576: istream_iterator and ostream_iterator should use
>> std::addressof
>>
>> Modified:
>> libcxx/trunk/include/iterator
>> libcxx/trunk/www/cxx1z_status.html
>>
>> Modified: libcxx/trunk/include/iterator
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=269789&r1=269788&r2=269789&view=diff
>>
>> ==
>> --- libcxx/trunk/include/iterator (original)
>> +++ libcxx/trunk/include/iterator Tue May 17 12:44:40 2016
>> @@ -772,14 +772,14 @@ private:
>>  _Tp __value_;
>>  public:
>>  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() :
>> __in_stream_(0), __value_() {}
>> -_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
>> __in_stream_(&__s)
>> +_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
>> __in_stream_(_VSTD::addressof(__s))
>>  {
>>  if (!(*__in_stream_ >> __value_))
>>  __in_stream_ = 0;
>>  }
>>
>>  _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return
>> __value_;}
>> -_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
>> &(operator*());}
>> +_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
>> _VSTD::addressof((operator*()));}
>>  _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
>>  {
>>  if (!(*__in_stream_ >> __value_))
>> @@ -811,9 +811,9 @@ private:
>>  const char_type* __delim_;
>>  public:
>>  _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s)
>> -: __out_stream_(&__s), __delim_(0) {}
>> +: __out_stream_(_VSTD::addressof(__s)), __delim_(0) {}
>>  _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const
>> _CharT* __delimiter)
>> -: __out_stream_(&__s), __delim_(__delimiter) {}
>> +: __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}
>>  _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp&
>> __value_)
>>  {
>>  *__out_stream_ << __value_;
>>
>> Modified: libcxx/trunk/www/cxx1z_status.html
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=269789&r1=269788&r2=269789&view=diff
>>
>> ==
>> --- libcxx/trunk/www/cxx1z_status.html (original)
>> +++ libcxx/trunk/www/cxx1z_status.html Tue May 17 12:44:40 2016
>> @@ -222,7 +222,7 @@
>> http://cplusplus.github.io/LWG/lwg-defects.html#2572";>2572The
>> remarks for shared_ptr::operator* should apply to
>> cv-qualified void as
>> wellJacksonvilleComplete
>> http://cplusplus.github.io/LWG/lwg-defects.html#2574";>2574[fund.ts.v2]
>> std::experimental::function::operator=(F&&) should be
>> constrainedJacksonville
>> http://cplusplus.github.io/LWG/lwg-defects.html#2575";>2575[fund.ts.v2]
>> experimental::function::assign should be
>> removedJacksonville
>> -   http://cplusplus.github.io/LWG/lwg-defects.html#2576";>2576istream_iterator
>> and ostream_iterator should use
>> std::addressofJacksonville
>> +   http://cplusplus.github.io/LWG/lwg-defects.html#2576";>2576istream_iterator
>> and ostream_iterator should use
>> std::addressofJacksonvilleComplete
>> http://cplusplus.github.io/LWG/lwg-defects.html#2577";>2577{shared,unique}_lock
>> should use
>> std::addressofJacksonvilleComplete
>> http://cplusplus.github.io/LWG/lwg-defects.html#2579";>2579Inconsistency
>> wrt Allocators in basic_string assignment vs.
>> basic_string::assignJacksonvilleComplete
>> http://cplusplus.github.io/LWG/lwg-defects.html#2581";>2581Specialization
>> of  variable templates should be
>> prohibitedJacksonvilleComplete
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r269789 - Implement LWG2576: istream_iterator and ostream_iterator should use std::addressof

2016-05-17 Thread David Blaikie via cfe-commits
If some parts are not testable & as you say, not meaningful, then it seems
OK to just not implement them & file a DR on the standard, no?

On Tue, May 17, 2016 at 1:00 PM, Eric Fiselier  wrote:

> I added a test for operator->() in r269812. Marshall and I discussed
> offline about how not all parts of this change are testable (and hence not
> meaningful) but that's what the standard says to do.
>
>
> On Tue, May 17, 2016 at 1:51 PM, David Blaikie via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Test coverage?
>>
>> On Tue, May 17, 2016 at 10:44 AM, Marshall Clow via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: marshall
>>> Date: Tue May 17 12:44:40 2016
>>> New Revision: 269789
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=269789&view=rev
>>> Log:
>>> Implement LWG2576: istream_iterator and ostream_iterator should use
>>> std::addressof
>>>
>>> Modified:
>>> libcxx/trunk/include/iterator
>>> libcxx/trunk/www/cxx1z_status.html
>>>
>>> Modified: libcxx/trunk/include/iterator
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=269789&r1=269788&r2=269789&view=diff
>>>
>>> ==
>>> --- libcxx/trunk/include/iterator (original)
>>> +++ libcxx/trunk/include/iterator Tue May 17 12:44:40 2016
>>> @@ -772,14 +772,14 @@ private:
>>>  _Tp __value_;
>>>  public:
>>>  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() :
>>> __in_stream_(0), __value_() {}
>>> -_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
>>> __in_stream_(&__s)
>>> +_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
>>> __in_stream_(_VSTD::addressof(__s))
>>>  {
>>>  if (!(*__in_stream_ >> __value_))
>>>  __in_stream_ = 0;
>>>  }
>>>
>>>  _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return
>>> __value_;}
>>> -_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
>>> &(operator*());}
>>> +_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
>>> _VSTD::addressof((operator*()));}
>>>  _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
>>>  {
>>>  if (!(*__in_stream_ >> __value_))
>>> @@ -811,9 +811,9 @@ private:
>>>  const char_type* __delim_;
>>>  public:
>>>  _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s)
>>> -: __out_stream_(&__s), __delim_(0) {}
>>> +: __out_stream_(_VSTD::addressof(__s)), __delim_(0) {}
>>>  _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const
>>> _CharT* __delimiter)
>>> -: __out_stream_(&__s), __delim_(__delimiter) {}
>>> +: __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}
>>>  _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp&
>>> __value_)
>>>  {
>>>  *__out_stream_ << __value_;
>>>
>>> Modified: libcxx/trunk/www/cxx1z_status.html
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=269789&r1=269788&r2=269789&view=diff
>>>
>>> ==
>>> --- libcxx/trunk/www/cxx1z_status.html (original)
>>> +++ libcxx/trunk/www/cxx1z_status.html Tue May 17 12:44:40 2016
>>> @@ -222,7 +222,7 @@
>>> http://cplusplus.github.io/LWG/lwg-defects.html#2572";>2572The
>>> remarks for shared_ptr::operator* should apply to
>>> cv-qualified void as
>>> wellJacksonvilleComplete
>>> http://cplusplus.github.io/LWG/lwg-defects.html#2574";>2574[fund.ts.v2]
>>> std::experimental::function::operator=(F&&) should be
>>> constrainedJacksonville
>>> http://cplusplus.github.io/LWG/lwg-defects.html#2575";>2575[fund.ts.v2]
>>> experimental::function::assign should be
>>> removedJacksonville
>>> -   http://cplusplus.github.io/LWG/lwg-defects.html#2576";>2576istream_iterator
>>> and ostream_iterator should use
>>> std::addressofJacksonville
>>> +   http://cplusplus.github.io/LWG/lwg-defects.html#2576";>2576istream_iterator
>>> and ostream_iterator should use
>>> std::addressofJacksonvilleComplete
>>> http://cplusplus.github.io/LWG/lwg-defects.html#2577";>2577{shared,unique}_lock
>>> should use
>>> std::addressofJacksonvilleComplete
>>> http://cplusplus.github.io/LWG/lwg-defects.html#2579";>2579Inconsistency
>>> wrt Allocators in basic_string assignment vs.
>>> basic_string::assignJacksonvilleComplete
>>> http://cplusplus.github.io/LWG/lwg-defects.html#2581";>2581Specialization
>>> of  variable templates should be
>>> prohibitedJacksonvilleComplete
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://li

Re: [libcxx] r269789 - Implement LWG2576: istream_iterator and ostream_iterator should use std::addressof

2016-05-17 Thread Eric Fiselier via cfe-commits
The difference between "operator&" and "addressof"  is inconsequential when
user defined overloads of "operator&" can't be found, which is the case for
the changes in the stream iterator constructors. We might as well keep it
consistent though. I don't see any value changing it back to use
"operator&" in either the library or the standard.

/Eric

On Tue, May 17, 2016 at 2:02 PM, David Blaikie  wrote:

> If some parts are not testable & as you say, not meaningful, then it seems
> OK to just not implement them & file a DR on the standard, no?
>
> On Tue, May 17, 2016 at 1:00 PM, Eric Fiselier  wrote:
>
>> I added a test for operator->() in r269812. Marshall and I discussed
>> offline about how not all parts of this change are testable (and hence not
>> meaningful) but that's what the standard says to do.
>>
>>
>> On Tue, May 17, 2016 at 1:51 PM, David Blaikie via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Test coverage?
>>>
>>> On Tue, May 17, 2016 at 10:44 AM, Marshall Clow via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: marshall
 Date: Tue May 17 12:44:40 2016
 New Revision: 269789

 URL: http://llvm.org/viewvc/llvm-project?rev=269789&view=rev
 Log:
 Implement LWG2576: istream_iterator and ostream_iterator should use
 std::addressof

 Modified:
 libcxx/trunk/include/iterator
 libcxx/trunk/www/cxx1z_status.html

 Modified: libcxx/trunk/include/iterator
 URL:
 http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=269789&r1=269788&r2=269789&view=diff

 ==
 --- libcxx/trunk/include/iterator (original)
 +++ libcxx/trunk/include/iterator Tue May 17 12:44:40 2016
 @@ -772,14 +772,14 @@ private:
  _Tp __value_;
  public:
  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() :
 __in_stream_(0), __value_() {}
 -_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
 __in_stream_(&__s)
 +_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
 __in_stream_(_VSTD::addressof(__s))
  {
  if (!(*__in_stream_ >> __value_))
  __in_stream_ = 0;
  }

  _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return
 __value_;}
 -_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
 &(operator*());}
 +_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
 _VSTD::addressof((operator*()));}
  _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
  {
  if (!(*__in_stream_ >> __value_))
 @@ -811,9 +811,9 @@ private:
  const char_type* __delim_;
  public:
  _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s)
 -: __out_stream_(&__s), __delim_(0) {}
 +: __out_stream_(_VSTD::addressof(__s)), __delim_(0) {}
  _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s,
 const _CharT* __delimiter)
 -: __out_stream_(&__s), __delim_(__delimiter) {}
 +: __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter)
 {}
  _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp&
 __value_)
  {
  *__out_stream_ << __value_;

 Modified: libcxx/trunk/www/cxx1z_status.html
 URL:
 http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=269789&r1=269788&r2=269789&view=diff

 ==
 --- libcxx/trunk/www/cxx1z_status.html (original)
 +++ libcxx/trunk/www/cxx1z_status.html Tue May 17 12:44:40 2016
 @@ -222,7 +222,7 @@
 http://cplusplus.github.io/LWG/lwg-defects.html#2572";>2572The
 remarks for shared_ptr::operator* should apply to
 cv-qualified void as
 wellJacksonvilleComplete
 http://cplusplus.github.io/LWG/lwg-defects.html#2574";>2574[fund.ts.v2]
 std::experimental::function::operator=(F&&) should be
 constrainedJacksonville
 http://cplusplus.github.io/LWG/lwg-defects.html#2575";>2575[fund.ts.v2]
 experimental::function::assign should be
 removedJacksonville
 -   http://cplusplus.github.io/LWG/lwg-defects.html#2576";>2576istream_iterator
 and ostream_iterator should use
 std::addressofJacksonville
 +   http://cplusplus.github.io/LWG/lwg-defects.html#2576";>2576istream_iterator
 and ostream_iterator should use
 std::addressofJacksonvilleComplete
 http://cplusplus.github.io/LWG/lwg-defects.html#2577";>2577{shared,unique}_lock
 should use
 std::addressofJacksonvilleComplete
 http://cplusplus.github.io/LWG/lwg-defects.html#2579";>2579Inconsistency
 wrt Allocators in basic_string assignment vs.
 basic_

Re: [PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0

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


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7820
@@ +7819,3 @@
+def err_opencl_function_not_supported : Error<
+  "this function is not supported in this version of CL">;
+def err_opencl_enqueue_kernel_incorrect_args : Error<

Anastasia wrote:
> This diagnostic should follow the latest version reporting style.
Is it better to move this msg to the generic msg part for OpenCL?


Comment at: lib/CodeGen/CGBuiltin.cpp:2150
@@ +2149,3 @@
+
+if (NumArgs == 4) {
+  // The most basic form of the call with parameters:

Can we remove the non-vararg version and keep only the vararg version? The 
vararg can be empty, so the non-vararg version is redundant.


Comment at: lib/CodeGen/CGBuiltin.cpp:2174
@@ +2173,3 @@
+// express to the runtime the number of variadic arguments.
+std::vector Args{Queue, Flags, Range, Block,
+ConstantInt::get(IntTy, NumVaargs)};

Can we drop NumVaargs? It seem redundant.


Comment at: lib/Sema/SemaChecking.cpp:80
@@ +79,3 @@
+/// void*,
+/// which is a requirement of device side enqueue.
+static bool checkBlockArgs(Sema &S, Expr *BlockArg) {

joint with the previous line?


Comment at: lib/Sema/SemaChecking.cpp:150
@@ +149,3 @@
+/// void*'
+/// parameter of passed block.
+static bool checkEnqueueVariadicArgs(Sema &S, CallExpr *TheCall, Expr 
*BlockArg,

joint with previous line?


Comment at: lib/Sema/SemaChecking.cpp:201
@@ +200,3 @@
+///uint size0, ...)
+static bool SemaBuiltinOpenCLEnqueueKernel(Sema &S, CallExpr *TheCall) {
+  unsigned NumArgs = TheCall->getNumArgs();

rename to SemaOpenCLBuiltin... to be consistent with others?


http://reviews.llvm.org/D20249



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


Re: r269717 - Switch from SmallVector to TinyPtrVector for the list of attributes on a declaration. This removes a memory allocation for the common case where the declaration has only one attribute.

2016-05-17 Thread Richard Smith via cfe-commits
On Tue, May 17, 2016 at 10:17 AM, David Blaikie via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Mon, May 16, 2016 at 3:53 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Mon May 16 17:53:19 2016
>> New Revision: 269717
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=269717&view=rev
>> Log:
>> Switch from SmallVector to TinyPtrVector for the list of attributes on a
>> declaration. This removes a memory allocation for the common case where the
>> declaration has only one attribute.
>>
>
> Just out of curiosity - if the SmallVector had a small size of 2, why was
> an allocation done for a single attribute?
>

Err, good question. Turns out I forgot to make the actual allocation-saving
change here -- switching ASTContext::DeclAttrs from storing an allocated
AttrVec* to storing an AttrVec. And that in turn is quite painful because
we expose the AttrVec object to people who might cause DeclAttrs to be
resized. I'll see if it's practical to finish this change, and revert if
not.

Modified:
>> cfe/trunk/include/clang/AST/AttrIterator.h
>>
>> Modified: cfe/trunk/include/clang/AST/AttrIterator.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/AttrIterator.h?rev=269717&r1=269716&r2=269717&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/AttrIterator.h (original)
>> +++ cfe/trunk/include/clang/AST/AttrIterator.h Mon May 16 17:53:19 2016
>> @@ -15,6 +15,7 @@
>>  #define LLVM_CLANG_AST_ATTRITERATOR_H
>>
>>  #include "clang/Basic/LLVM.h"
>> +#include "llvm/ADT/TinyPtrVector.h"
>>  #include 
>>
>>  namespace clang {
>> @@ -39,8 +40,8 @@ void operator delete[](void *Ptr, const
>>  namespace clang {
>>
>>  /// AttrVec - A vector of Attr, which is how they are stored on the AST.
>> -typedef SmallVector AttrVec;
>> -typedef SmallVector ConstAttrVec;
>> +typedef llvm::TinyPtrVector AttrVec;
>> +typedef llvm::TinyPtrVector ConstAttrVec;
>>
>>  /// specific_attr_iterator - Iterates over a subrange of an AttrVec, only
>>  /// providing attributes that are of a specific type.
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r269789 - Implement LWG2576: istream_iterator and ostream_iterator should use std::addressof

2016-05-17 Thread Eric Fiselier via cfe-commits
Woops. I was incorrect. It seems that user defined "operator&" overloads
can be found in the constructor. From the LWG issue:

> Note that {i,o}stream_type are specializations of basic_{i,o}stream, but
the constructors might still pick up an overloaded & via the traits
template parameter.

At least that also tells us how to test it.

/Eric

On Tue, May 17, 2016 at 2:08 PM, Eric Fiselier  wrote:

> The difference between "operator&" and "addressof"  is inconsequential
> when user defined overloads of "operator&" can't be found, which is the
> case for the changes in the stream iterator constructors. We might as well
> keep it consistent though. I don't see any value changing it back to use
> "operator&" in either the library or the standard.
>
> /Eric
>
> On Tue, May 17, 2016 at 2:02 PM, David Blaikie  wrote:
>
>> If some parts are not testable & as you say, not meaningful, then it
>> seems OK to just not implement them & file a DR on the standard, no?
>>
>> On Tue, May 17, 2016 at 1:00 PM, Eric Fiselier  wrote:
>>
>>> I added a test for operator->() in r269812. Marshall and I discussed
>>> offline about how not all parts of this change are testable (and hence not
>>> meaningful) but that's what the standard says to do.
>>>
>>>
>>> On Tue, May 17, 2016 at 1:51 PM, David Blaikie via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Test coverage?

 On Tue, May 17, 2016 at 10:44 AM, Marshall Clow via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: marshall
> Date: Tue May 17 12:44:40 2016
> New Revision: 269789
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269789&view=rev
> Log:
> Implement LWG2576: istream_iterator and ostream_iterator should use
> std::addressof
>
> Modified:
> libcxx/trunk/include/iterator
> libcxx/trunk/www/cxx1z_status.html
>
> Modified: libcxx/trunk/include/iterator
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=269789&r1=269788&r2=269789&view=diff
>
> ==
> --- libcxx/trunk/include/iterator (original)
> +++ libcxx/trunk/include/iterator Tue May 17 12:44:40 2016
> @@ -772,14 +772,14 @@ private:
>  _Tp __value_;
>  public:
>  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() :
> __in_stream_(0), __value_() {}
> -_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
> __in_stream_(&__s)
> +_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
> __in_stream_(_VSTD::addressof(__s))
>  {
>  if (!(*__in_stream_ >> __value_))
>  __in_stream_ = 0;
>  }
>
>  _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return
> __value_;}
> -_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
> &(operator*());}
> +_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
> _VSTD::addressof((operator*()));}
>  _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
>  {
>  if (!(*__in_stream_ >> __value_))
> @@ -811,9 +811,9 @@ private:
>  const char_type* __delim_;
>  public:
>  _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s)
> -: __out_stream_(&__s), __delim_(0) {}
> +: __out_stream_(_VSTD::addressof(__s)), __delim_(0) {}
>  _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s,
> const _CharT* __delimiter)
> -: __out_stream_(&__s), __delim_(__delimiter) {}
> +: __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter)
> {}
>  _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp&
> __value_)
>  {
>  *__out_stream_ << __value_;
>
> Modified: libcxx/trunk/www/cxx1z_status.html
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=269789&r1=269788&r2=269789&view=diff
>
> ==
> --- libcxx/trunk/www/cxx1z_status.html (original)
> +++ libcxx/trunk/www/cxx1z_status.html Tue May 17 12:44:40 2016
> @@ -222,7 +222,7 @@
> http://cplusplus.github.io/LWG/lwg-defects.html#2572";>2572The
> remarks for shared_ptr::operator* should apply to
> cv-qualified void as
> wellJacksonvilleComplete
> http://cplusplus.github.io/LWG/lwg-defects.html#2574";>2574[fund.ts.v2]
> std::experimental::function::operator=(F&&) should be
> constrainedJacksonville
> http://cplusplus.github.io/LWG/lwg-defects.html#2575";>2575[fund.ts.v2]
> experimental::function::assign should be
> removedJacksonville
> -   http://cplusplus.github.io/LWG/lwg-defects.html#2576";>2576istream_iterator
> and ostream_it

Re: [libcxx] r269789 - Implement LWG2576: istream_iterator and ostream_iterator should use std::addressof

2016-05-17 Thread Eric Fiselier via cfe-commits
Or maybe I'm still wrong. I tried using a custom traits class to hijack ADL
for "operator&" but it doesn't seem to work.

Sorry for the spam.

/Eric

On Tue, May 17, 2016 at 2:25 PM, Eric Fiselier  wrote:

> Woops. I was incorrect. It seems that user defined "operator&" overloads
> can be found in the constructor. From the LWG issue:
>
> > Note that {i,o}stream_type are specializations of basic_{i,o}stream, but
> the constructors might still pick up an overloaded & via the traits
> template parameter.
>
> At least that also tells us how to test it.
>
> /Eric
>
> On Tue, May 17, 2016 at 2:08 PM, Eric Fiselier  wrote:
>
>> The difference between "operator&" and "addressof"  is inconsequential
>> when user defined overloads of "operator&" can't be found, which is the
>> case for the changes in the stream iterator constructors. We might as well
>> keep it consistent though. I don't see any value changing it back to use
>> "operator&" in either the library or the standard.
>>
>> /Eric
>>
>> On Tue, May 17, 2016 at 2:02 PM, David Blaikie 
>> wrote:
>>
>>> If some parts are not testable & as you say, not meaningful, then it
>>> seems OK to just not implement them & file a DR on the standard, no?
>>>
>>> On Tue, May 17, 2016 at 1:00 PM, Eric Fiselier  wrote:
>>>
 I added a test for operator->() in r269812. Marshall and I discussed
 offline about how not all parts of this change are testable (and hence not
 meaningful) but that's what the standard says to do.


 On Tue, May 17, 2016 at 1:51 PM, David Blaikie via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Test coverage?
>
> On Tue, May 17, 2016 at 10:44 AM, Marshall Clow via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: marshall
>> Date: Tue May 17 12:44:40 2016
>> New Revision: 269789
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=269789&view=rev
>> Log:
>> Implement LWG2576: istream_iterator and ostream_iterator should use
>> std::addressof
>>
>> Modified:
>> libcxx/trunk/include/iterator
>> libcxx/trunk/www/cxx1z_status.html
>>
>> Modified: libcxx/trunk/include/iterator
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=269789&r1=269788&r2=269789&view=diff
>>
>> ==
>> --- libcxx/trunk/include/iterator (original)
>> +++ libcxx/trunk/include/iterator Tue May 17 12:44:40 2016
>> @@ -772,14 +772,14 @@ private:
>>  _Tp __value_;
>>  public:
>>  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() :
>> __in_stream_(0), __value_() {}
>> -_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
>> __in_stream_(&__s)
>> +_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
>> __in_stream_(_VSTD::addressof(__s))
>>  {
>>  if (!(*__in_stream_ >> __value_))
>>  __in_stream_ = 0;
>>  }
>>
>>  _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return
>> __value_;}
>> -_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
>> &(operator*());}
>> +_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
>> _VSTD::addressof((operator*()));}
>>  _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
>>  {
>>  if (!(*__in_stream_ >> __value_))
>> @@ -811,9 +811,9 @@ private:
>>  const char_type* __delim_;
>>  public:
>>  _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s)
>> -: __out_stream_(&__s), __delim_(0) {}
>> +: __out_stream_(_VSTD::addressof(__s)), __delim_(0) {}
>>  _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s,
>> const _CharT* __delimiter)
>> -: __out_stream_(&__s), __delim_(__delimiter) {}
>> +: __out_stream_(_VSTD::addressof(__s)),
>> __delim_(__delimiter) {}
>>  _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp&
>> __value_)
>>  {
>>  *__out_stream_ << __value_;
>>
>> Modified: libcxx/trunk/www/cxx1z_status.html
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=269789&r1=269788&r2=269789&view=diff
>>
>> ==
>> --- libcxx/trunk/www/cxx1z_status.html (original)
>> +++ libcxx/trunk/www/cxx1z_status.html Tue May 17 12:44:40 2016
>> @@ -222,7 +222,7 @@
>> http://cplusplus.github.io/LWG/lwg-defects.html#2572";>2572The
>> remarks for shared_ptr::operator* should apply to
>> cv-qualified void as
>> wellJacksonvilleComplete
>> http://cplusplus.github.io/LWG/lwg-defects.html#2574";>2574[fund.ts.v2]
>> std::experimental::fun

Re: [PATCH] D16989: Change interpretation of function definition in friend declaration of template class.

2016-05-17 Thread Richard Smith via cfe-commits
rsmith added a comment.

Please also add some testcases for the corresponding case for a friend function 
template:

  template void f();
  template struct A {
template void f() {}
  };
  template struct B {
template void f() {}
  };
  A a;
  B b; // ill-formed



Comment at: test/SemaCXX/PR25848.cpp:4
@@ +3,3 @@
+struct A;
+typedef int A::* P;
+

Maybe use `int` instead of a pointer to member type here? May as well keep the 
parts that aren't relevant to the test as simple as possible.


Comment at: test/SemaCXX/friend2.cpp:77
@@ +76,3 @@
+// Even if clases are not instantiated and hence friend functions defined in 
them are not
+// available, their declarations must be checked.
+

"must be" -> "can be" (or maybe "should be")

We're not required to diagnose this; it's a QoI issue.


http://reviews.llvm.org/D16989



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


Re: Patch submission for bug 27400

2016-05-17 Thread Mads Ravn via cfe-commits
Cool :) don't the sweat the time. I was just a little excited. Small patch
but it's nice to get started somewhere.

Best regards,
Mads Ravn

> On May 17, 2016, at 2:59 AM, Mads Ravn  wrote:
>
> Hi guys,
>
> I just wanted to check up on this patch. I heard I could just reply to
this mail and see if I could 'ping' anyone in this regard. Hope it's OK.

Sorry for the delay! This looks good. Committed as r269786.

thanks,
vedant

>
> Best regards,
> Mads Ravn
>
> On Thu, May 12, 2016 at 6:11 PM Mads Ravn  wrote:
> Hi,
>
> I have fixed the things you mentioned now. I have attached the new patch
to this email.
>
> Best regards,
> Mads Ravn
>
> On Wed, May 11, 2016 at 11:54 PM Vedant Kumar  wrote:
> Hi,
>
> Thanks for the patch!
>
> This patch is missing a small, lit-style test case. You can find examples
of test cases here:
>
>   extra/test/clang-tidy/
>
> Apart from that, my only other nit-pick is that llvm uses 2-space
indents, and spaces between "if" and "(".
>
> If you reply to this list with an updated patch, someone would be happy
to commit it for you.
>
> best
> vedant
>
> > On May 11, 2016, at 10:01 AM, Mads Ravn via cfe-commits <
cfe-commits@lists.llvm.org> wrote:
> >
> > Hi,
> >
> > I would like to submit a patch for
https://llvm.org/bugs/show_bug.cgi?id=27400 .
> >
> > Beside attaching the patch, is there anything I should be aware of? I
have not submitted a patch before.
> >
> > You can find the patch attached to this mail.
> >
> > Kind regards,
> > Mads Ravn
> >
___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D20336: [AMDGPU] Remove individual debugger options

2016-05-17 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl created this revision.
kzhuravl added a reviewer: arsenm.
kzhuravl added subscribers: whchung, cfe-commits.
Herald added a reviewer: tstellarAMD.
Herald added a subscriber: kzhuravl.

http://reviews.llvm.org/D20336

Files:
  include/clang/Driver/Options.td
  test/Driver/amdgpu-features.c

Index: test/Driver/amdgpu-features.c
===
--- test/Driver/amdgpu-features.c
+++ test/Driver/amdgpu-features.c
@@ -9,13 +9,3 @@
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-abi=1.0 %s -o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-1-0 %s
 // CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" 
"+amdgpu-debugger-insert-nops" "-target-feature" 
"+amdgpu-debugger-reserve-trap-regs"
-//
-// -mamdgpu-debugger-insert-nops
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-insert-nops %s -o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-INSERT-NOPS %s
-// CHECK-MAMDGPU-DEBUGGER-INSERT-NOPS: "-target-feature" 
"+amdgpu-debugger-insert-nops"
-//
-// -mamdgpu-debugger-reserve-trap-regs
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-reserve-trap-regs %s -o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-RESERVE-TRAP-REGS 
%s
-// CHECK-MAMDGPU-DEBUGGER-RESERVE-TRAP-REGS: "-target-feature" 
"+amdgpu-debugger-reserve-trap-regs"
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1472,10 +1472,6 @@
   Group,
   HelpText<"Generate additional code for specified  of debugger ABI 
(AMDGPU only)">,
   MetaVarName<"">;
-def mamdgpu_debugger_insert_nops : Flag<["-"], "mamdgpu-debugger-insert-nops">,
-  Group;
-def mamdgpu_debugger_reserve_trap_regs : Flag<["-"], 
"mamdgpu-debugger-reserve-trap-regs">,
-  Group;
 
 def mvsx : Flag<["-"], "mvsx">, Group;
 def mno_vsx : Flag<["-"], "mno-vsx">, Group;


Index: test/Driver/amdgpu-features.c
===
--- test/Driver/amdgpu-features.c
+++ test/Driver/amdgpu-features.c
@@ -9,13 +9,3 @@
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-abi=1.0 %s -o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-1-0 %s
 // CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" "+amdgpu-debugger-insert-nops" "-target-feature" "+amdgpu-debugger-reserve-trap-regs"
-//
-// -mamdgpu-debugger-insert-nops
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-insert-nops %s -o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-INSERT-NOPS %s
-// CHECK-MAMDGPU-DEBUGGER-INSERT-NOPS: "-target-feature" "+amdgpu-debugger-insert-nops"
-//
-// -mamdgpu-debugger-reserve-trap-regs
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-reserve-trap-regs %s -o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-RESERVE-TRAP-REGS %s
-// CHECK-MAMDGPU-DEBUGGER-RESERVE-TRAP-REGS: "-target-feature" "+amdgpu-debugger-reserve-trap-regs"
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1472,10 +1472,6 @@
   Group,
   HelpText<"Generate additional code for specified  of debugger ABI (AMDGPU only)">,
   MetaVarName<"">;
-def mamdgpu_debugger_insert_nops : Flag<["-"], "mamdgpu-debugger-insert-nops">,
-  Group;
-def mamdgpu_debugger_reserve_trap_regs : Flag<["-"], "mamdgpu-debugger-reserve-trap-regs">,
-  Group;
 
 def mvsx : Flag<["-"], "mvsx">, Group;
 def mno_vsx : Flag<["-"], "mno-vsx">, Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r269838 - Test hijacking ADL for operator& in the stream iterator constructors.

2016-05-17 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May 17 16:01:20 2016
New Revision: 269838

URL: http://llvm.org/viewvc/llvm-project?rev=269838&view=rev
Log:
Test hijacking ADL for operator& in the stream iterator constructors.

Modified:

libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp

libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delim.pass.cpp

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp?rev=269838&r1=269837&r2=269838&view=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp
 Tue May 17 16:01:20 2016
@@ -17,9 +17,23 @@
 #include 
 #include 
 
+struct MyTraits : std::char_traits {};
+
+typedef std::basic_ostringstream StringStream;
+typedef std::basic_ostream BasicStream;
+
+void operator&(BasicStream const&) {}
+
 int main()
 {
-std::ostringstream outf;
-std::ostream_iterator i(outf);
-assert(outf.good());
+{
+std::ostringstream outf;
+std::ostream_iterator i(outf);
+assert(outf.good());
+}
+{
+StringStream outf;
+std::ostream_iterator i(outf);
+assert(outf.good());
+}
 }

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delim.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delim.pass.cpp?rev=269838&r1=269837&r2=269838&view=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delim.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delim.pass.cpp
 Tue May 17 16:01:20 2016
@@ -17,6 +17,14 @@
 #include 
 #include 
 
+
+struct MyTraits : std::char_traits {};
+
+typedef std::basic_ostringstream StringStream;
+typedef std::basic_ostream BasicStream;
+
+void operator&(BasicStream const&) {}
+
 int main()
 {
 {
@@ -29,4 +37,9 @@ int main()
 std::ostream_iterator i(outf, L", ");
 assert(outf.good());
 }
+{
+StringStream outf;
+std::ostream_iterator i(outf, ", ");
+assert(outf.good());
+}
 }


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


Re: [libcxx] r269789 - Implement LWG2576: istream_iterator and ostream_iterator should use std::addressof

2016-05-17 Thread Eric Fiselier via cfe-commits
OK, I think I figured it out. I added tests for the ostream_iterator
constructors in r269838.
I'll follow that up with tests for the istream_iterator constructors, but
my current test is failing for reasons beyond me.

/Eric

On Tue, May 17, 2016 at 2:36 PM, Eric Fiselier  wrote:

> Or maybe I'm still wrong. I tried using a custom traits class to hijack
> ADL for "operator&" but it doesn't seem to work.
>
> Sorry for the spam.
>
> /Eric
>
> On Tue, May 17, 2016 at 2:25 PM, Eric Fiselier  wrote:
>
>> Woops. I was incorrect. It seems that user defined "operator&" overloads
>> can be found in the constructor. From the LWG issue:
>>
>> > Note that {i,o}stream_type are specializations of basic_{i,o}stream,
>> but the constructors might still pick up an overloaded & via the traits
>> template parameter.
>>
>> At least that also tells us how to test it.
>>
>> /Eric
>>
>> On Tue, May 17, 2016 at 2:08 PM, Eric Fiselier  wrote:
>>
>>> The difference between "operator&" and "addressof"  is inconsequential
>>> when user defined overloads of "operator&" can't be found, which is the
>>> case for the changes in the stream iterator constructors. We might as well
>>> keep it consistent though. I don't see any value changing it back to use
>>> "operator&" in either the library or the standard.
>>>
>>> /Eric
>>>
>>> On Tue, May 17, 2016 at 2:02 PM, David Blaikie 
>>> wrote:
>>>
 If some parts are not testable & as you say, not meaningful, then it
 seems OK to just not implement them & file a DR on the standard, no?

 On Tue, May 17, 2016 at 1:00 PM, Eric Fiselier  wrote:

> I added a test for operator->() in r269812. Marshall and I discussed
> offline about how not all parts of this change are testable (and hence not
> meaningful) but that's what the standard says to do.
>
>
> On Tue, May 17, 2016 at 1:51 PM, David Blaikie via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Test coverage?
>>
>> On Tue, May 17, 2016 at 10:44 AM, Marshall Clow via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: marshall
>>> Date: Tue May 17 12:44:40 2016
>>> New Revision: 269789
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=269789&view=rev
>>> Log:
>>> Implement LWG2576: istream_iterator and ostream_iterator should use
>>> std::addressof
>>>
>>> Modified:
>>> libcxx/trunk/include/iterator
>>> libcxx/trunk/www/cxx1z_status.html
>>>
>>> Modified: libcxx/trunk/include/iterator
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=269789&r1=269788&r2=269789&view=diff
>>>
>>> ==
>>> --- libcxx/trunk/include/iterator (original)
>>> +++ libcxx/trunk/include/iterator Tue May 17 12:44:40 2016
>>> @@ -772,14 +772,14 @@ private:
>>>  _Tp __value_;
>>>  public:
>>>  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator()
>>> : __in_stream_(0), __value_() {}
>>> -_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
>>> __in_stream_(&__s)
>>> +_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
>>> __in_stream_(_VSTD::addressof(__s))
>>>  {
>>>  if (!(*__in_stream_ >> __value_))
>>>  __in_stream_ = 0;
>>>  }
>>>
>>>  _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return
>>> __value_;}
>>> -_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
>>> &(operator*());}
>>> +_LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
>>> _VSTD::addressof((operator*()));}
>>>  _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
>>>  {
>>>  if (!(*__in_stream_ >> __value_))
>>> @@ -811,9 +811,9 @@ private:
>>>  const char_type* __delim_;
>>>  public:
>>>  _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s)
>>> -: __out_stream_(&__s), __delim_(0) {}
>>> +: __out_stream_(_VSTD::addressof(__s)), __delim_(0) {}
>>>  _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s,
>>> const _CharT* __delimiter)
>>> -: __out_stream_(&__s), __delim_(__delimiter) {}
>>> +: __out_stream_(_VSTD::addressof(__s)),
>>> __delim_(__delimiter) {}
>>>  _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const
>>> _Tp& __value_)
>>>  {
>>>  *__out_stream_ << __value_;
>>>
>>> Modified: libcxx/trunk/www/cxx1z_status.html
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=269789&r1=269788&r2=269789&view=diff
>>>
>>> ==
>>> --- libcxx/trunk/www/cxx1z_status.html (original)
>>

Re: [PATCH] D19105: Changes in clang after running http://reviews.llvm.org/D18821

2016-05-17 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D19105#427046, @Prazek wrote:

> In http://reviews.llvm.org/D19105#426903, @alexfh wrote:
>
> > returning a bool from a function that is declared to return a typedef to an 
> > integral type that contains `bool` in its name (e.g. `LLVMBool`), and maybe 
> > some other cases.
>
>
> Isn't it LLVMBool issue?
>
> I won't have enough time to fix it, so I would prefer to comment fixit and 
> only push warnings.


Whether we disable fixits or not, there seem to be too many false positives for 
the check to be useful. We should fix at least cases like `bool b; ... if (b == 
true) ...` and `bool b; ... b ^= true;`.


http://reviews.llvm.org/D19105



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


Re: [PATCH] D20336: [AMDGPU] Remove individual debugger options + update features

2016-05-17 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl retitled this revision from "[AMDGPU] Remove individual debugger 
options" to "[AMDGPU] Remove individual debugger options + update features".
kzhuravl updated this revision to Diff 57518.
kzhuravl added a comment.

Update features


http://reviews.llvm.org/D20336

Files:
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  test/Driver/amdgpu-features.c

Index: test/Driver/amdgpu-features.c
===
--- test/Driver/amdgpu-features.c
+++ test/Driver/amdgpu-features.c
@@ -8,14 +8,4 @@
 // -mamdgpu-debugger-abi=1.0
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-abi=1.0 %s -o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-1-0 %s
-// CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" 
"+amdgpu-debugger-insert-nops" "-target-feature" 
"+amdgpu-debugger-reserve-trap-regs"
-//
-// -mamdgpu-debugger-insert-nops
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-insert-nops %s -o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-INSERT-NOPS %s
-// CHECK-MAMDGPU-DEBUGGER-INSERT-NOPS: "-target-feature" 
"+amdgpu-debugger-insert-nops"
-//
-// -mamdgpu-debugger-reserve-trap-regs
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-reserve-trap-regs %s -o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-RESERVE-TRAP-REGS 
%s
-// CHECK-MAMDGPU-DEBUGGER-RESERVE-TRAP-REGS: "-target-feature" 
"+amdgpu-debugger-reserve-trap-regs"
+// CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" 
"+amdgpu-debugger-insert-nops" "-target-feature" 
"+amdgpu-debugger-reserve-regs" "-target-feature" 
"+amdgpu-debugger-emit-prologue"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2419,7 +2419,8 @@
 StringRef value = dAbi->getValue();
 if (value == "1.0") {
   Features.push_back("+amdgpu-debugger-insert-nops");
-  Features.push_back("+amdgpu-debugger-reserve-trap-regs");
+  Features.push_back("+amdgpu-debugger-reserve-regs");
+  Features.push_back("+amdgpu-debugger-emit-prologue");
 } else {
   D.Diag(diag::err_drv_clang_unsupported) << dAbi->getAsString(Args);
 }
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1472,10 +1472,6 @@
   Group,
   HelpText<"Generate additional code for specified  of debugger ABI 
(AMDGPU only)">,
   MetaVarName<"">;
-def mamdgpu_debugger_insert_nops : Flag<["-"], "mamdgpu-debugger-insert-nops">,
-  Group;
-def mamdgpu_debugger_reserve_trap_regs : Flag<["-"], 
"mamdgpu-debugger-reserve-trap-regs">,
-  Group;
 
 def mvsx : Flag<["-"], "mvsx">, Group;
 def mno_vsx : Flag<["-"], "mno-vsx">, Group;


Index: test/Driver/amdgpu-features.c
===
--- test/Driver/amdgpu-features.c
+++ test/Driver/amdgpu-features.c
@@ -8,14 +8,4 @@
 // -mamdgpu-debugger-abi=1.0
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-abi=1.0 %s -o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-1-0 %s
-// CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" "+amdgpu-debugger-insert-nops" "-target-feature" "+amdgpu-debugger-reserve-trap-regs"
-//
-// -mamdgpu-debugger-insert-nops
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-insert-nops %s -o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-INSERT-NOPS %s
-// CHECK-MAMDGPU-DEBUGGER-INSERT-NOPS: "-target-feature" "+amdgpu-debugger-insert-nops"
-//
-// -mamdgpu-debugger-reserve-trap-regs
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-reserve-trap-regs %s -o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-RESERVE-TRAP-REGS %s
-// CHECK-MAMDGPU-DEBUGGER-RESERVE-TRAP-REGS: "-target-feature" "+amdgpu-debugger-reserve-trap-regs"
+// CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" "+amdgpu-debugger-insert-nops" "-target-feature" "+amdgpu-debugger-reserve-regs" "-target-feature" "+amdgpu-debugger-emit-prologue"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2419,7 +2419,8 @@
 StringRef value = dAbi->getValue();
 if (value == "1.0") {
   Features.push_back("+amdgpu-debugger-insert-nops");
-  Features.push_back("+amdgpu-debugger-reserve-trap-regs");
+  Features.push_back("+amdgpu-debugger-reserve-regs");
+  Features.push_back("+amdgpu-debugger-emit-prologue");
 } else {
   D.Diag(diag::err_drv_clang_unsupported) << dAbi->getAsString(Args);
 }
Index: include/clang/Driver/Options.td
===

  1   2   >