Re: r272247 - [Sema] Don't crash when a field w/ a mem-initializer clashes with a record name

2016-06-09 Thread Kim Gräsman via cfe-commits
On Thu, Jun 9, 2016 at 7:26 AM, David Majnemer via cfe-commits
 wrote:
> Author: majnemer
> Date: Thu Jun  9 00:26:56 2016
> New Revision: 272247
>
> URL: http://llvm.org/viewvc/llvm-project?rev=272247&view=rev
> Log:
> [Sema] Don't crash when a field w/ a mem-initializer clashes with a record 
> name
>
> It is possible for a field and a class to have the same name.  In such
> cases, performing lookup for the field might return a result set with
> more than one entry.  An overzealous assertion fired, causing us to
> crash instead of using the non-class lookup result.
>
> This fixes PR28060.
>
> Modified:
> cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
> cfe/trunk/test/SemaCXX/member-init.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=272247&r1=272246&r2=272247&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Thu Jun  9 00:26:56 2016
> @@ -2637,8 +2637,7 @@ Sema::InstantiateClassMembers(SourceLoca
>  Instantiation->getTemplateInstantiationPattern();
>  DeclContext::lookup_result Lookup =
>  ClassPattern->lookup(Field->getDeclName());
> -assert(Lookup.size() == 1);
> -FieldDecl *Pattern = cast(Lookup[0]);
> +FieldDecl *Pattern = cast(Lookup.front());
>  InstantiateInClassInitializer(PointOfInstantiation, Field, Pattern,
>TemplateArgs);
>}

Now what if there is no match? Or is that guaranteed (given the prior assert)?

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


[PATCH] D21175: [include-fixer] do not index friend function declaration.

2016-06-09 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: bkramer.
ioeric added a subscriber: cfe-commits.

we want to exclude friend declaration, but the `DeclContext` of a
friend function declaration is not the class in which it is declared, so we need
to explicitly check if the parent is a `friendDecl`.

http://reviews.llvm.org/D21175

Files:
  include-fixer/find-all-symbols/FindAllSymbols.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
@@ -433,5 +433,26 @@
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, NoFriendTest) {
+  static const char Code[] = R"(
+class WorstFriend {
+  friend void Friend();
+  friend class BestFriend;
+};
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol = SymbolInfo("WorstFriend", SymbolInfo::SymbolKind::Class,
+ HeaderName, 2, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("Friend", SymbolInfo::SymbolKind::Function, HeaderName,
+  3, {});
+  EXPECT_FALSE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("BestFriend", SymbolInfo::SymbolKind::Class, HeaderName,
+  4, {});
+  EXPECT_FALSE(hasSymbol(Symbol));
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Index: include-fixer/find-all-symbols/FindAllSymbols.cpp
===
--- include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -161,9 +161,14 @@
   MatchFinder->addMatcher(CxxRecordDecl.bind("decl"), this);
 
   // Matchers for function declarations.
-  MatchFinder->addMatcher(
-  functionDecl(CommonFilter, anyOf(ExternCMatcher, 
CCMatcher)).bind("decl"),
-  this);
+  // We want to exclude friend declaration, but the `DeclContext` of a friend
+  // function declaration is not the class in which it is declared, so we need
+  // to explicitly check if the parent is a `friendDecl`.
+  MatchFinder->addMatcher(functionDecl(CommonFilter,
+   unless(hasParent(friendDecl())),
+   anyOf(ExternCMatcher, CCMatcher))
+  .bind("decl"),
+  this);
 
   // Matcher for typedef and type alias declarations.
   //


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
@@ -433,5 +433,26 @@
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, NoFriendTest) {
+  static const char Code[] = R"(
+class WorstFriend {
+  friend void Friend();
+  friend class BestFriend;
+};
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol = SymbolInfo("WorstFriend", SymbolInfo::SymbolKind::Class,
+ HeaderName, 2, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("Friend", SymbolInfo::SymbolKind::Function, HeaderName,
+  3, {});
+  EXPECT_FALSE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("BestFriend", SymbolInfo::SymbolKind::Class, HeaderName,
+  4, {});
+  EXPECT_FALSE(hasSymbol(Symbol));
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Index: include-fixer/find-all-symbols/FindAllSymbols.cpp
===
--- include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -161,9 +161,14 @@
   MatchFinder->addMatcher(CxxRecordDecl.bind("decl"), this);
 
   // Matchers for function declarations.
-  MatchFinder->addMatcher(
-  functionDecl(CommonFilter, anyOf(ExternCMatcher, CCMatcher)).bind("decl"),
-  this);
+  // We want to exclude friend declaration, but the `DeclContext` of a friend
+  // function declaration is not the class in which it is declared, so we need
+  // to explicitly check if the parent is a `friendDecl`.
+  MatchFinder->addMatcher(functionDecl(CommonFilter,
+   unless(hasParent(friendDecl())),
+   anyOf(ExternCMatcher, CCMatcher))
+  .bind("decl"),
+  this);
 
   // Matcher for typedef and type alias declarations.
   //
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r272253 - clang/test/CodeGenCXX/debug-info-method.cpp: Tweak for thiscall, for targeting Win32 x86.

2016-06-09 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Thu Jun  9 05:06:13 2016
New Revision: 272253

URL: http://llvm.org/viewvc/llvm-project?rev=272253&view=rev
Log:
clang/test/CodeGenCXX/debug-info-method.cpp: Tweak for thiscall, for targeting 
Win32 x86.

Modified:
cfe/trunk/test/CodeGenCXX/debug-info-method.cpp

Modified: cfe/trunk/test/CodeGenCXX/debug-info-method.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-method.cpp?rev=272253&r1=272252&r2=272253&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-method.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-method.cpp Thu Jun  9 05:06:13 2016
@@ -6,7 +6,7 @@
 // CHECK-SAME:  DIFlagArtificial
 // CHECK: !DIDerivedType(tag: DW_TAG_ptr_to_member_type
 // CHECK: !DIDerivedType(tag: DW_TAG_ptr_to_member_type, baseType: 
![[MEMFUNTYPE:[0-9]+]]
-// CHECK: ![[MEMFUNTYPE]] = !DISubroutineType(types: ![[MEMFUNARGS:[0-9]+]])
+// CHECK: ![[MEMFUNTYPE]] = !DISubroutineType({{(cc: DW_CC_BORLAND_thiscall, 
)?}}types: ![[MEMFUNARGS:[0-9]+]])
 // CHECK: ![[MEMFUNARGS]] = {{.*}}, ![[THISTYPE]],
 // CHECK: !DILocalVariable(name: "this", arg: 1
 // CHECK: !DILocalVariable(arg: 2


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


Re: r271918 - Add a release note about the --build-id change.

2016-06-09 Thread Sean Silva via cfe-commits
On Mon, Jun 6, 2016 at 11:23 AM, Rafael Espindola via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rafael
> Date: Mon Jun  6 13:23:11 2016
> New Revision: 271918
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271918&view=rev
> Log:
> Add a release note about the --build-id change.
>
> Modified:
> cfe/trunk/docs/ReleaseNotes.rst
>
> Modified: cfe/trunk/docs/ReleaseNotes.rst
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=271918&r1=271917&r2=271918&view=diff
>
> ==
> --- cfe/trunk/docs/ReleaseNotes.rst (original)
> +++ cfe/trunk/docs/ReleaseNotes.rst Mon Jun  6 13:23:11 2016
> @@ -47,7 +47,10 @@ sections with improvements to Clang's su
>  Major New Features
>  --
>
> -- Feature1...
> +- Clang will no longer passes --build-id by default to the linker. In
> modern
> +  linkers that is a relatively expensive option. It can be passed
> explicitly
> +  with -Wl,--build-id. To have clang always pass it, build it with
>

nit: the second "it" here seems slightly ambiguous to my reading. Can you
say "build clang with" to avoid ambiguity about the "it"?

-- Sean Silva


> +  -DENABLE_LINKER_BUILD_ID.
>
>  Improvements to Clang's diagnostics
>  ^^^
>
>
> ___
> 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] D21176: Mark invalid RecordDecls as completed.

2016-06-09 Thread Erik Verbruggen via cfe-commits
erikjv created this revision.
erikjv added a reviewer: rsmith.
erikjv added a subscriber: cfe-commits.

Sema::ActOnTag creates TagDecls for records. However, if those record
declarations are invalid, and the parser is in C++ mode, it would
silently drop the TagDecl (and leave it as "beingDefined"). The problem
is that other code (e.g. the ASTWriter) will serialize all types, and
expects them to be complete. So, leaving them open would result in
failing asserts.

Fixes PR20320


http://reviews.llvm.org/D21176

Files:
  lib/Sema/SemaDecl.cpp
  test/Index/pr20320.cpp
  test/Index/pr20320.h
  test/SemaCXX/conversion-function.cpp

Index: test/SemaCXX/conversion-function.cpp
===
--- test/SemaCXX/conversion-function.cpp
+++ test/SemaCXX/conversion-function.cpp
@@ -434,8 +434,12 @@
   struct A {
 operator enum E { e } (); // expected-error {{'PR18234::A::E' cannot be 
defined in a type specifier}}
 operator struct S { int n; } (); // expected-error {{'PR18234::A::S' 
cannot be defined in a type specifier}}
+// expected-note@-1 {{candidate constructor (the implicit copy 
constructor) not viable: no known conversion from 'struct A' to 'const 
PR18234::A::S &' for 1st argument}}
+#if __cplusplus >= 201103L
+  // expected-note@-3 {{candidate constructor (the implicit move constructor) 
not viable: no known conversion from 'struct A' to 'PR18234::A::S &&' for 1st 
argument}}
+#endif
   } a;
-  A::S s = a;
+  A::S s = a; // expected-error {{no viable conversion from 'struct A' to 
'A::S'}}
   A::E e = a; // expected-note {{here}}
   bool k1 = e == A::e; // expected-error {{no member named 'e'}}
   bool k2 = e.n == 0;
Index: test/Index/pr20320.h
===
--- /dev/null
+++ test/Index/pr20320.h
@@ -0,0 +1,14 @@
+#ifndef pr20320_h
+#define pr20320_h
+
+template<>
+struct S< ::Number::One>
+{
+};
+
+template<>
+struct S< ::Number::Two>
+{
+};
+
+#endif
Index: test/Index/pr20320.cpp
===
--- /dev/null
+++ test/Index/pr20320.cpp
@@ -0,0 +1,2 @@
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 
local -x c++ %s
+#include "pr20320.h"
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13065,7 +13065,14 @@
   OwnedDecl = true;
   // In C++, don't return an invalid declaration. We can't recover well from
   // the cases where we make the type anonymous.
-  return (Invalid && getLangOpts().CPlusPlus) ? nullptr : New;
+  if (Invalid && getLangOpts().CPlusPlus) {
+if (New->isBeingDefined())
+  if (auto RD = dyn_cast(New))
+RD->completeDefinition();
+return nullptr;
+  } else {
+return New;
+  }
 }
 
 void Sema::ActOnTagStartDefinition(Scope *S, Decl *TagD) {


Index: test/SemaCXX/conversion-function.cpp
===
--- test/SemaCXX/conversion-function.cpp
+++ test/SemaCXX/conversion-function.cpp
@@ -434,8 +434,12 @@
   struct A {
 operator enum E { e } (); // expected-error {{'PR18234::A::E' cannot be defined in a type specifier}}
 operator struct S { int n; } (); // expected-error {{'PR18234::A::S' cannot be defined in a type specifier}}
+// expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'struct A' to 'const PR18234::A::S &' for 1st argument}}
+#if __cplusplus >= 201103L
+  // expected-note@-3 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'struct A' to 'PR18234::A::S &&' for 1st argument}}
+#endif
   } a;
-  A::S s = a;
+  A::S s = a; // expected-error {{no viable conversion from 'struct A' to 'A::S'}}
   A::E e = a; // expected-note {{here}}
   bool k1 = e == A::e; // expected-error {{no member named 'e'}}
   bool k2 = e.n == 0;
Index: test/Index/pr20320.h
===
--- /dev/null
+++ test/Index/pr20320.h
@@ -0,0 +1,14 @@
+#ifndef pr20320_h
+#define pr20320_h
+
+template<>
+struct S< ::Number::One>
+{
+};
+
+template<>
+struct S< ::Number::Two>
+{
+};
+
+#endif
Index: test/Index/pr20320.cpp
===
--- /dev/null
+++ test/Index/pr20320.cpp
@@ -0,0 +1,2 @@
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local -x c++ %s
+#include "pr20320.h"
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13065,7 +13065,14 @@
   OwnedDecl = true;
   // In C++, don't return an invalid declaration. We can't recover well from
   // the cases where we make the type anonymous.
-  return (Invalid && getLangOpts().CPlusPlus) ? nullptr : New;
+  if (Invalid && getLangOpts().CPlusPlus) {
+if (New

Re: [PATCH] D18080: CIndex: add support for static_assert

2016-06-09 Thread Olivier Goffart via cfe-commits
ogoffart added a comment.

Ping 2.


http://reviews.llvm.org/D18080



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


Re: [PATCH] D18081: Make sizeof and alignof a CXCursor_UnaryExpr

2016-06-09 Thread Olivier Goffart via cfe-commits
ogoffart added a comment.

Ping 2.


http://reviews.llvm.org/D18081



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


Re: [PATCH] D19763: Functions declared in a scope should not hide previous declaration in earlier scopes

2016-06-09 Thread Olivier Goffart via cfe-commits
ogoffart added a comment.

Ping.
This would be required for http://reviews.llvm.org/D19764


http://reviews.llvm.org/D19763



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


Re: [PATCH] D21162: [CUDA] Implement __shfl* intrinsics in clang headers.

2016-06-09 Thread Justin Holewinski via cfe-commits
jholewinski added a comment.

Looks reasonable to me.


http://reviews.llvm.org/D21162



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


[PATCH] D21179: Add mrrc/mrrc2 intrinsics and update existing mcrr/mcrr2 intrinsics to accept a single uint64 type instead of 2 uint32 types

2016-06-09 Thread Ranjeet Singh via cfe-commits
rs created this revision.
rs added reviewers: t.p.northover, rengolin.
rs added a subscriber: cfe-commits.

Patch adds support for the intrinsics mrrc/mrrc2 and updates the existing 
mcrr/mcrr2 intrinsic definition to accept a single uint64 type as the input 
value instead of 2 uint32's as I think this makes the definition more compact.

http://reviews.llvm.org/D21179

Files:
  include/clang/Basic/BuiltinsARM.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtins-arm.c
  test/Sema/builtins-arm.c

Index: test/Sema/builtins-arm.c
===
--- test/Sema/builtins-arm.c
+++ test/Sema/builtins-arm.c
@@ -116,11 +116,23 @@
   __builtin_arm_mcr2(15, 0, b, 13, a, 3); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
   __builtin_arm_mcr2(15, 0, b, 13, 0, a); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
 
-  __builtin_arm_mcrr( a, 0, b, c, 0); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
-  __builtin_arm_mcrr(15, a, b, c, 0); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
-  __builtin_arm_mcrr(15, 0, b, c, a); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
-
-  __builtin_arm_mcrr2( a, 0, b, c, 0); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
-  __builtin_arm_mcrr2(15, a, b, c, 0); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
-  __builtin_arm_mcrr2(15, 0, b, c, a); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
+  __builtin_arm_mcrr(15, 0, b, 0);
+  __builtin_arm_mcrr( a, 0, b, 0); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
+  __builtin_arm_mcrr(15, a, b, 0); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
+  __builtin_arm_mcrr(15, 0, b, a); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
+
+  __builtin_arm_mcrr2(15, 0, b, 0);
+  __builtin_arm_mcrr2( a, 0, b, 0); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
+  __builtin_arm_mcrr2(15, a, b, 0); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
+  __builtin_arm_mcrr2(15, 0, b, a); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
+
+  __builtin_arm_mrrc(15, 0, 0);
+  __builtin_arm_mrrc( a, 0, 0); // expected-error {{argument to '__builtin_arm_mrrc' must be a constant integer}}
+  __builtin_arm_mrrc(15, a, 0); // expected-error {{argument to '__builtin_arm_mrrc' must be a constant integer}}
+  __builtin_arm_mrrc(15, 0, a); // expected-error {{argument to '__builtin_arm_mrrc' must be a constant integer}}
+
+  __builtin_arm_mrrc2(15, 0, 0);
+  __builtin_arm_mrrc2( a, 0, 0); // expected-error {{argument to '__builtin_arm_mrrc2' must be a constant integer}}
+  __builtin_arm_mrrc2(15, a, 0); // expected-error {{argument to '__builtin_arm_mrrc2' must be a constant integer}}
+  __builtin_arm_mrrc2(15, 0, a); // expected-error {{argument to '__builtin_arm_mrrc2' must be a constant integer}}
 }
Index: test/CodeGen/builtins-arm.c
===
--- test/CodeGen/builtins-arm.c
+++ test/CodeGen/builtins-arm.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -Wall -Werror -triple thumbv7-eabi -target-cpu cortex-a8 -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
 
+#include 
+
 void *f0()
 {
   return __builtin_thread_pointer();
@@ -180,16 +182,28 @@
   __builtin_arm_mcr2(15, 0, a, 13, 0, 3);
 }
 
-void mcrr(unsigned a, unsigned b) {
-  // CHECK: define void @mcrr(i32 [[A:%.*]], i32 [[B:%.*]])
-  // CHECK: call void @llvm.arm.mcrr(i32 15, i32 0, i32 [[A]], i32 [[B]], i32 0)
-  __builtin_arm_mcrr(15, 0, a, b, 0);
+void mcrr(uint64_t a) {
+  // CHECK: define void @mcrr(i64 %{{.*}})
+  // CHECK: call void @llvm.arm.mcrr(i32 15, i32 0, i32 %{{[0-9]+}}, i32 %{{[0-9]+}}, i32 0)
+  __builtin_arm_mcrr(15, 0, a, 0);
+}
+
+void mcrr2(uint64_t a) {
+  // CHECK: define void @mcrr2(i64 %{{.*}})
+  // CHECK: call void @llvm.arm.mcrr2(i32 15, i32 0, i32 %{{[0-9]+}}, i32 %{{[0-9]+}}, i32 0)
+  __builtin_arm_mcrr2(15, 0, a, 0);
+}
+
+uint64_t mrrc() {
+  // CHECK: define i64 @mrrc()
+  // CHECK: call { i32, i32 } @llvm.arm.mrrc(i32 15, i32 0, i32 0)
+  return __builtin_arm_mrrc(15, 0, 0);
 }
 
-void mcrr2(unsigned a, unsigned b) {
-  // CHECK: define void @mcrr2(i32 [[A:%.*]], i32 [[B:%.*]])
-  // CHECK: call void @llvm.arm.mcrr2(i32 15, i32 0, i32 [[A]], i32 [[B]], i32 0)
-  __builtin_arm_mcrr2(15, 0, a, b, 0);
+uint64_t mrrc2() {
+  // CHECK: define i64 @mrrc2()
+  // CHECK: call { i32, i32 } @llvm.arm.mrrc2(i32 15, i32 0, i32 0)
+  return __builtin_arm_mrrc2(15, 0, 0);
 }
 
 unsigned rsr() {
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/

Re: [PATCH] D21179: Add mrrc/mrrc2 intrinsics and update existing mcrr/mcrr2 intrinsics to accept a single uint64 type instead of 2 uint32 types

2016-06-09 Thread Ranjeet Singh via cfe-commits
rs added a comment.

LLVM part of the patch is here http://reviews.llvm.org/D21178


http://reviews.llvm.org/D21179



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


Re: [PATCH] D20821: Fix a few issues while skipping function bodies

2016-06-09 Thread Olivier Goffart via cfe-commits
ogoffart added a comment.

The idea is that when we see a ") {"  or "} {"  in the ctor-initializers, 
(optionally with "..."), it is necessarily the start of the body.

Unless there might be lambda expressions within a template aregument, as in:


  A::A() : Base<[](){return 42; }()>(){}

But this is not valid because lambda expression cannot appear in this context 
as far as i know since lambda expression cannot appear in template argument


http://reviews.llvm.org/D20821



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


[PATCH] D21173: [X86] _MM_ALIGN16 attribute support for non-windows targets

2016-06-09 Thread Zvi Rackover via cfe-commits
zvi created this revision.
zvi added reviewers: aaboud, mkuper, echristo, cfe-commits.
zvi set the repository for this revision to rL LLVM.
zvi added a project: clang-c.
Herald added a subscriber: mehdi_amini.

This patch adds support for the _MM_ALIGN16 attribute on non-windows targets. 
This aligns Clang with ICC which supports the attribute on all targets.

Fixes PR28056

Repository:
  rL LLVM

http://reviews.llvm.org/D21173

Files:
  lib/Headers/xmmintrin.h
  test/Headers/xmmintrin.c

Index: test/Headers/xmmintrin.c
===
--- test/Headers/xmmintrin.c
+++ test/Headers/xmmintrin.c
@@ -7,6 +7,9 @@
 // REQUIRES: x86-registered-target
 #include 
 
+// CHECK: @c = common global i8 0, align 16
+_MM_ALIGN16 char c;
+
 // Make sure the last step of _mm_cvtps_pi16 converts <4 x i32> to <4 x i16> by
 // checking that clang emits PACKSSDW instead of PACKSSWB.
 
Index: lib/Headers/xmmintrin.h
===
--- lib/Headers/xmmintrin.h
+++ lib/Headers/xmmintrin.h
@@ -2823,6 +2823,8 @@
 
 #ifdef _MSC_VER
 #define _MM_ALIGN16 __declspec(align(16))
+#else
+#define _MM_ALIGN16 __attribute__((aligned(16)))
 #endif
 
 #define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w))


Index: test/Headers/xmmintrin.c
===
--- test/Headers/xmmintrin.c
+++ test/Headers/xmmintrin.c
@@ -7,6 +7,9 @@
 // REQUIRES: x86-registered-target
 #include 
 
+// CHECK: @c = common global i8 0, align 16
+_MM_ALIGN16 char c;
+
 // Make sure the last step of _mm_cvtps_pi16 converts <4 x i32> to <4 x i16> by
 // checking that clang emits PACKSSDW instead of PACKSSWB.
 
Index: lib/Headers/xmmintrin.h
===
--- lib/Headers/xmmintrin.h
+++ lib/Headers/xmmintrin.h
@@ -2823,6 +2823,8 @@
 
 #ifdef _MSC_VER
 #define _MM_ALIGN16 __declspec(align(16))
+#else
+#define _MM_ALIGN16 __attribute__((aligned(16)))
 #endif
 
 #define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18081: Make sizeof and alignof a CXCursor_UnaryExpr

2016-06-09 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D18081



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


Re: [PATCH] D18080: CIndex: add support for static_assert

2016-06-09 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

This is fine


http://reviews.llvm.org/D18080



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


Re: [PATCH] D21175: [include-fixer] do not index friend function declaration.

2016-06-09 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

Makes sense.


http://reviews.llvm.org/D21175



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


r272260 - Replace an ambiguous "it"

2016-06-09 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Thu Jun  9 08:35:55 2016
New Revision: 272260

URL: http://llvm.org/viewvc/llvm-project?rev=272260&view=rev
Log:
Replace an ambiguous "it"

Thanks to Sean for the suggestion.

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=272260&r1=272259&r2=272260&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu Jun  9 08:35:55 2016
@@ -49,7 +49,7 @@ Major New Features
 
 - Clang will no longer passes --build-id by default to the linker. In modern
   linkers that is a relatively expensive option. It can be passed explicitly
-  with -Wl,--build-id. To have clang always pass it, build it with
+  with -Wl,--build-id. To have clang always pass it, build clang with
   -DENABLE_LINKER_BUILD_ID.
 
 Improvements to Clang's diagnostics


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


[PATCH] D21181: [include-fixer] give users an option to show N more headers in case there are too many candidates.

2016-06-09 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: bkramer.
ioeric added a subscriber: cfe-commits.

give users an option to show N more headers in case there are too many 
candidates.

http://reviews.llvm.org/D21181

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

Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -34,14 +34,22 @@
   1,
   vim.eval('g:clang_include_fixer_maximum_suggested_headers'))
 
+increment_num=5
+if vim.eval('exists("g:clang_include_fixer_increment_num")') == "1":
+  increment_num = max(
+  1,
+  vim.eval('g:clang_include_fixer_increment_num'))
 
 def GetUserSelection(message, headers, maximum_suggested_headers):
   eval_message = message + '\n'
   for idx, header in enumerate(headers[0:maximum_suggested_headers]):
 eval_message += "({0}). {1}\n".format(idx+1, header)
   eval_message += "Enter (q) to quit;"
   if maximum_suggested_headers < len(headers):
-eval_message += " (a) to show all candidates.";
+eval_message += " (a) to show all {0} candidates;".format(len(headers))
+if len(headers) - maximum_suggested_headers > increment_num:
+  eval_message += " (m) to show {0} more candidates.".format(increment_num)
+
   eval_message += "\nSelect (default 1): "
   res = vim.eval("input('{0}')".format(eval_message))
   if res == '':
@@ -51,6 +59,9 @@
 raise Exception('   Insertion cancelled...')
   elif res == 'a' and maximum_suggested_headers < len(headers):
 return GetUserSelection(message, headers, len(headers))
+  elif res == 'm':
+return GetUserSelection(message,
+headers, maximum_suggested_headers + increment_num)
   else:
 try:
   idx = int(res)


Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -34,14 +34,22 @@
   1,
   vim.eval('g:clang_include_fixer_maximum_suggested_headers'))
 
+increment_num=5
+if vim.eval('exists("g:clang_include_fixer_increment_num")') == "1":
+  increment_num = max(
+  1,
+  vim.eval('g:clang_include_fixer_increment_num'))
 
 def GetUserSelection(message, headers, maximum_suggested_headers):
   eval_message = message + '\n'
   for idx, header in enumerate(headers[0:maximum_suggested_headers]):
 eval_message += "({0}). {1}\n".format(idx+1, header)
   eval_message += "Enter (q) to quit;"
   if maximum_suggested_headers < len(headers):
-eval_message += " (a) to show all candidates.";
+eval_message += " (a) to show all {0} candidates;".format(len(headers))
+if len(headers) - maximum_suggested_headers > increment_num:
+  eval_message += " (m) to show {0} more candidates.".format(increment_num)
+
   eval_message += "\nSelect (default 1): "
   res = vim.eval("input('{0}')".format(eval_message))
   if res == '':
@@ -51,6 +59,9 @@
 raise Exception('   Insertion cancelled...')
   elif res == 'a' and maximum_suggested_headers < len(headers):
 return GetUserSelection(message, headers, len(headers))
+  elif res == 'm':
+return GetUserSelection(message,
+headers, maximum_suggested_headers + increment_num)
   else:
 try:
   idx = int(res)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21175: [include-fixer] do not index friend function declaration.

2016-06-09 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272261: [include-fixer] do not index friend function 
declaration. (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D21175?vs=60147&id=60168#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21175

Files:
  clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.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
@@ -433,5 +433,26 @@
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, NoFriendTest) {
+  static const char Code[] = R"(
+class WorstFriend {
+  friend void Friend();
+  friend class BestFriend;
+};
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol = SymbolInfo("WorstFriend", SymbolInfo::SymbolKind::Class,
+ HeaderName, 2, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("Friend", SymbolInfo::SymbolKind::Function, HeaderName,
+  3, {});
+  EXPECT_FALSE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("BestFriend", SymbolInfo::SymbolKind::Class, HeaderName,
+  4, {});
+  EXPECT_FALSE(hasSymbol(Symbol));
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -161,9 +161,14 @@
   MatchFinder->addMatcher(CxxRecordDecl.bind("decl"), this);
 
   // Matchers for function declarations.
-  MatchFinder->addMatcher(
-  functionDecl(CommonFilter, anyOf(ExternCMatcher, 
CCMatcher)).bind("decl"),
-  this);
+  // We want to exclude friend declaration, but the `DeclContext` of a friend
+  // function declaration is not the class in which it is declared, so we need
+  // to explicitly check if the parent is a `friendDecl`.
+  MatchFinder->addMatcher(functionDecl(CommonFilter,
+   unless(hasParent(friendDecl())),
+   anyOf(ExternCMatcher, CCMatcher))
+  .bind("decl"),
+  this);
 
   // Matcher for typedef and type alias declarations.
   //


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
@@ -433,5 +433,26 @@
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, NoFriendTest) {
+  static const char Code[] = R"(
+class WorstFriend {
+  friend void Friend();
+  friend class BestFriend;
+};
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol = SymbolInfo("WorstFriend", SymbolInfo::SymbolKind::Class,
+ HeaderName, 2, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("Friend", SymbolInfo::SymbolKind::Function, HeaderName,
+  3, {});
+  EXPECT_FALSE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("BestFriend", SymbolInfo::SymbolKind::Class, HeaderName,
+  4, {});
+  EXPECT_FALSE(hasSymbol(Symbol));
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -161,9 +161,14 @@
   MatchFinder->addMatcher(CxxRecordDecl.bind("decl"), this);
 
   // Matchers for function declarations.
-  MatchFinder->addMatcher(
-  functionDecl(CommonFilter, anyOf(ExternCMatcher, CCMatcher)).bind("decl"),
-  this);
+  // We want to exclude friend declaration, but the `DeclContext` of a friend
+  // function declaration is not the class in which it is declared, so we need
+  // to explicitly check if the parent is a `friendDecl`.
+  MatchFinder->addMatcher(functionDecl(CommonFilter,
+   unless(hasParent(friendDecl())),
+   anyOf(ExternCMatcher, CCMatcher))
+  .bind("decl"),
+  this);
 
   // Matcher for typedef and type 

[clang-tools-extra] r272261 - [include-fixer] do not index friend function declaration.

2016-06-09 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Jun  9 09:18:40 2016
New Revision: 272261

URL: http://llvm.org/viewvc/llvm-project?rev=272261&view=rev
Log:
[include-fixer] do not index friend function declaration.

Summary:
we want to exclude friend declaration, but the `DeclContext` of a
friend function declaration is not the class in which it is declared, so we need
to explicitly check if the parent is a `friendDecl`.

Reviewers: bkramer

Subscribers: cfe-commits

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

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=272261&r1=272260&r2=272261&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 
Thu Jun  9 09:18:40 2016
@@ -161,9 +161,14 @@ void FindAllSymbols::registerMatchers(Ma
   MatchFinder->addMatcher(CxxRecordDecl.bind("decl"), this);
 
   // Matchers for function declarations.
-  MatchFinder->addMatcher(
-  functionDecl(CommonFilter, anyOf(ExternCMatcher, 
CCMatcher)).bind("decl"),
-  this);
+  // We want to exclude friend declaration, but the `DeclContext` of a friend
+  // function declaration is not the class in which it is declared, so we need
+  // to explicitly check if the parent is a `friendDecl`.
+  MatchFinder->addMatcher(functionDecl(CommonFilter,
+   unless(hasParent(friendDecl())),
+   anyOf(ExternCMatcher, CCMatcher))
+  .bind("decl"),
+  this);
 
   // Matcher for typedef and type alias declarations.
   //

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=272261&r1=272260&r2=272261&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
 Thu Jun  9 09:18:40 2016
@@ -433,5 +433,26 @@ TEST_F(FindAllSymbolsTest, MacroTestWith
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, NoFriendTest) {
+  static const char Code[] = R"(
+class WorstFriend {
+  friend void Friend();
+  friend class BestFriend;
+};
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol = SymbolInfo("WorstFriend", SymbolInfo::SymbolKind::Class,
+ HeaderName, 2, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("Friend", SymbolInfo::SymbolKind::Function, HeaderName,
+  3, {});
+  EXPECT_FALSE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("BestFriend", SymbolInfo::SymbolKind::Class, HeaderName,
+  4, {});
+  EXPECT_FALSE(hasSymbol(Symbol));
+}
+
 } // namespace find_all_symbols
 } // namespace clang


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


Re: [PATCH] D20933: Preallocate ExplodedNode hash table

2016-06-09 Thread Ben Craig via cfe-commits
bcraig added a comment.

In http://reviews.llvm.org/D20933#452854, @dcoughlin wrote:

> A 6% speed improvement could be a big win! Do we have a sense of what the 
> expected increased memory cost (as a % of average use over the lifetime of 
> the process) is? My guess is it would be relatively low. I suspect most 
> analyzer users run relatively few concurrent 'clang' processes -- so this 
> might be well worth it.


If the underlying allocator that does a poor job at reusing freed memory, then 
trivial functions will use about 1 MB more than before, then free the memory 
immediately.  On the other hand, functions that hit the max step count will use 
about 1 MB less memory than before.  The thought experiments get difficult when 
the underlying allocator is good at reusing freed memory.

I got some memory numbers for the .C file that saw the 6% speedup and has 37% 
of its functions hitting the step count.
From /usr/bin/time -v,
Before: Maximum resident set size (kbytes): 498688
After: Maximum resident set size (kbytes): 497872

Valgrind's massif tool reported the peak usage as 14696448 (0xE04000) bytes for 
both the before and after.

> I do think we should make sure the user can't shoot themselves in the foot by 
> pre-reserving space for an absurdly high maximum step count. We might want to 
> to clamp this reservation to something that is not outrageous even when the 
> maximum step count is huge.


Sure.  I'll switch to reserving the smaller of Steps and 4 million.  That means 
the most memory we will pre-reserve will be 32MB.


http://reviews.llvm.org/D20933



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


Re: [PATCH] D21173: [X86] _MM_ALIGN16 attribute support for non-windows targets

2016-06-09 Thread David Majnemer via cfe-commits
On Thursday, June 9, 2016, Zvi Rackover via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> zvi created this revision.
> zvi added reviewers: aaboud, mkuper, echristo, cfe-commits.
> zvi set the repository for this revision to rL LLVM.
> zvi added a project: clang-c.
> Herald added a subscriber: mehdi_amini.
>
> This patch adds support for the _MM_ALIGN16 attribute on non-windows
> targets. This aligns Clang with ICC which supports the attribute on all
> targets.
>
> Fixes PR28056
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D21173
>
> Files:
>   lib/Headers/xmmintrin.h
>   test/Headers/xmmintrin.c
>
> Index: test/Headers/xmmintrin.c
> ===
> --- test/Headers/xmmintrin.c
> +++ test/Headers/xmmintrin.c
> @@ -7,6 +7,9 @@
>  // REQUIRES: x86-registered-target
>  #include 
>
> +// CHECK: @c = common global i8 0, align 16
> +_MM_ALIGN16 char c;
> +
>  // Make sure the last step of _mm_cvtps_pi16 converts <4 x i32> to <4 x
> i16> by
>  // checking that clang emits PACKSSDW instead of PACKSSWB.
>
> Index: lib/Headers/xmmintrin.h
> ===
> --- lib/Headers/xmmintrin.h
> +++ lib/Headers/xmmintrin.h
> @@ -2823,6 +2823,8 @@
>
>  #ifdef _MSC_VER
>  #define _MM_ALIGN16 __declspec(align(16))
> +#else
> +#define _MM_ALIGN16 __attribute__((aligned(16)))
>  #endif


I would just use the __attribute__ spelling, no need for two definitions


>
>  #define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) |
> (w))
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r272247 - [Sema] Don't crash when a field w/ a mem-initializer clashes with a record name

2016-06-09 Thread David Majnemer via cfe-commits
It would mean that the instantiation of the class template gained a field
which should be impossible.

On Thursday, June 9, 2016, Kim Gräsman  wrote:

> On Thu, Jun 9, 2016 at 7:26 AM, David Majnemer via cfe-commits
> > wrote:
> > Author: majnemer
> > Date: Thu Jun  9 00:26:56 2016
> > New Revision: 272247
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=272247&view=rev
> > Log:
> > [Sema] Don't crash when a field w/ a mem-initializer clashes with a
> record name
> >
> > It is possible for a field and a class to have the same name.  In such
> > cases, performing lookup for the field might return a result set with
> > more than one entry.  An overzealous assertion fired, causing us to
> > crash instead of using the non-class lookup result.
> >
> > This fixes PR28060.
> >
> > Modified:
> > cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
> > cfe/trunk/test/SemaCXX/member-init.cpp
> >
> > Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=272247&r1=272246&r2=272247&view=diff
> >
> ==
> > --- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Thu Jun  9 00:26:56
> 2016
> > @@ -2637,8 +2637,7 @@ Sema::InstantiateClassMembers(SourceLoca
> >  Instantiation->getTemplateInstantiationPattern();
> >  DeclContext::lookup_result Lookup =
> >  ClassPattern->lookup(Field->getDeclName());
> > -assert(Lookup.size() == 1);
> > -FieldDecl *Pattern = cast(Lookup[0]);
> > +FieldDecl *Pattern = cast(Lookup.front());
> >  InstantiateInClassInitializer(PointOfInstantiation, Field,
> Pattern,
> >TemplateArgs);
> >}
>
> Now what if there is no match? Or is that guaranteed (given the prior
> assert)?
>
> - Kim
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20382: Add postorder support to RecursiveASTVisitor

2016-06-09 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 60176.
teemperor added a comment.

Reduced executable size bloat. Made postorder and preorder mutually exclusive 
and postorder also uses the normal Visit* methods for callbacks.


http://reviews.llvm.org/D20382

Files:
  include/clang/AST/RecursiveASTVisitor.h
  unittests/AST/CMakeLists.txt
  unittests/AST/PostOrderASTVisitor.cpp

Index: unittests/AST/PostOrderASTVisitor.cpp
===
--- /dev/null
+++ unittests/AST/PostOrderASTVisitor.cpp
@@ -0,0 +1,118 @@
+//===- unittests/AST/PostOrderASTVisitor.cpp - Declaration printer tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains tests for the post-order traversing functionality
+// of RecursiveASTVisitor.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Tooling/Tooling.h"
+
+using namespace clang;
+
+namespace {
+
+  class RecordingVisitor
+: public RecursiveASTVisitor {
+
+bool VisitPostOrder;
+  public:
+explicit RecordingVisitor(bool VisitPostOrder)
+  : VisitPostOrder(VisitPostOrder) {
+}
+
+// List of visited nodes during traversal.
+std::vector VisitedNodes;
+
+bool shouldTraversePostOrder() const { return VisitPostOrder; }
+
+bool VisitBinaryOperator(BinaryOperator *Op) {
+  VisitedNodes.push_back(Op->getOpcodeStr());
+  return true;
+}
+
+bool VisitIntegerLiteral(IntegerLiteral *Lit) {
+  VisitedNodes.push_back(Lit->getValue().toString(10, false));
+  return true;
+}
+
+bool VisitCXXMethodDecl(CXXMethodDecl *D) {
+  VisitedNodes.push_back(D->getQualifiedNameAsString());
+  return true;
+}
+
+bool VisitReturnStmt(Stmt *S) {
+  VisitedNodes.push_back("return");
+  return true;
+}
+
+bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) {
+  VisitedNodes.push_back(Declaration->getQualifiedNameAsString());
+  return true;
+}
+
+bool VisitTemplateTypeParmType(TemplateTypeParmType *T) {
+  VisitedNodes.push_back(T->getDecl()->getQualifiedNameAsString());
+  return true;
+}
+  };
+
+}
+
+TEST(RecursiveASTVisitor, PostOrderTraversal) {
+  auto ASTUnit = tooling::buildASTFromCode(
+"template  class A {"
+"  class B {"
+"int foo() { return 1 + 2; }"
+"  };"
+"};"
+  );
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+  // We traverse the translation unit and store all
+  // visited nodes.
+  RecordingVisitor Visitor(true);
+  Visitor.TraverseTranslationUnitDecl(TU);
+
+  std::vector expected = {
+"1", "2", "+", "return", "A::B::foo", "A::B", "A", "A::T"
+  };
+  // Compare the list of actually visited nodes
+  // with the expected list of visited nodes.
+  ASSERT_EQ(expected.size(), Visitor.VisitedNodes.size());
+  for (std::size_t I = 0; I < expected.size(); I++) {
+ASSERT_EQ(expected[I], Visitor.VisitedNodes[I]);
+  }
+}
+
+TEST(RecursiveASTVisitor, NoPostOrderTraversal) {
+  auto ASTUnit = tooling::buildASTFromCode(
+"template  class A {"
+"  class B {"
+"int foo() { return 1 + 2; }"
+"  };"
+"};"
+  );
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+  // We traverse the translation unit and store all
+  // visited nodes.
+  RecordingVisitor Visitor(false);
+  Visitor.TraverseTranslationUnitDecl(TU);
+
+  std::vector expected = {
+"A", "A::B", "A::B::foo", "return", "+", "1", "2", "A::T"
+  };
+  // Compare the list of actually visited nodes
+  // with the expected list of visited nodes.
+  ASSERT_EQ(expected.size(), Visitor.VisitedNodes.size());
+  for (std::size_t I = 0; I < expected.size(); I++) {
+ASSERT_EQ(expected[I], Visitor.VisitedNodes[I]);
+  }
+}
Index: unittests/AST/CMakeLists.txt
===
--- unittests/AST/CMakeLists.txt
+++ unittests/AST/CMakeLists.txt
@@ -14,6 +14,7 @@
   EvaluateAsRValueTest.cpp
   ExternalASTSourceTest.cpp
   NamedDeclPrinterTest.cpp
+  PostOrderASTVisitor.cpp
   SourceLocationTest.cpp
   StmtPrinterTest.cpp
   )
Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -72,8 +72,8 @@
   return false;\
   } while (0)
 
-/// \brief A class that does preorder depth-first traversal on the
-/// entire Clang AST and visits each node.
+/// \brief A class that does preordor or postorder
+/// depth-first traversal on the entire Clang AST and visits each node.
 ///
 /// This cla

Re: [PATCH] D20382: Add postorder support to RecursiveASTVisitor

2016-06-09 Thread Raphael Isemann via cfe-commits
teemperor added a comment.

Agreed. The new patch is now reusing the Visit methods so that the executable 
size stays the same.
The downside is that you can no longer create a Visitor that is both post- and 
preorder traversing,
but I don't think there is any major use case for that.


http://reviews.llvm.org/D20382



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


Re: r272247 - [Sema] Don't crash when a field w/ a mem-initializer clashes with a record name

2016-06-09 Thread Kim Gräsman via cfe-commits
On Thu, Jun 9, 2016 at 4:51 PM, David Majnemer  wrote:
> It would mean that the instantiation of the class template gained a field
> which should be impossible.

OK, so assert(Lookup.size() > 0) always holds? Makes sense, thanks.

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


[libcxx] r272263 - Two more issues w/patches

2016-06-09 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Jun  9 09:50:38 2016
New Revision: 272263

URL: http://llvm.org/viewvc/llvm-project?rev=272263&view=rev
Log:
Two more issues w/patches

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=272263&r1=272262&r2=272263&view=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Thu Jun  9 09:50:38 2016
@@ -61,7 +61,7 @@
 
http://wg21.link/LWG2181";>2181Exceptions 
from seed sequence operationsOulu
http://wg21.link/LWG2309";>2309mutex::lock() should not throw 
device_or_resource_busyOuluComplete
-   http://wg21.link/LWG2310";>2310Public 
exposition only member in std::arrayOulu
+   http://wg21.link/LWG2310";>2310Public 
exposition only member in std::arrayOuluPatch Ready
http://wg21.link/LWG2328";>2328Rvalue 
stream extraction should use perfect forwardingOulu
http://wg21.link/LWG2393";>2393std::function's Callable 
definition is brokenOulu
http://wg21.link/LWG2426";>2426Issue about 
compare_exchangeOulu
@@ -76,7 +76,7 @@
http://wg21.link/LWG2551";>2551[fund.ts.v2] "Exception 
safety" cleanup in library fundamentals 
requiredOuluComplete
http://wg21.link/LWG2555";>2555[fund.ts.v2] No handling for 
over-aligned types in optionalOuluComplete
http://wg21.link/LWG2573";>2573[fund.ts.v2] 
std::hash> does not work for 
arraysOulu
-   http://wg21.link/LWG2596";>2596vector::data() should use 
addressofOulu
+   http://wg21.link/LWG2596";>2596vector::data() should use 
addressofOuluPatch Ready
http://wg21.link/LWG2667";>2667path::root_directory() 
description is confusingOulu
http://wg21.link/LWG2669";>2669recursive_directory_iterator 
effects refers to non-existent functionsOulu
http://wg21.link/LWG2670";>2670system_complete refers to 
undefined variable 'base'Oulu
@@ -113,7 +113,7 @@
 2551 - Wording cleanup; no code change needed.
 2555 - Wording clarification; no code change needed.
 2573 - 
-2596 - Easy.
+2596 - Turns out we do this already. Needs tests, though.
 2667 - 
 2669 - 
 2670 - 


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


Re: r272253 - clang/test/CodeGenCXX/debug-info-method.cpp: Tweak for thiscall, for targeting Win32 x86.

2016-06-09 Thread David Blaikie via cfe-commits
Reid - is this intended fallout? (seems plausible, but just checking)

Is MinGW a good analogy for any of this work? (does it produce DWARF? Does
it use the Windows ABI? Does it emit Calling Convention attributes?)

On Thu, Jun 9, 2016 at 3:06 AM, NAKAMURA Takumi via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: chapuni
> Date: Thu Jun  9 05:06:13 2016
> New Revision: 272253
>
> URL: http://llvm.org/viewvc/llvm-project?rev=272253&view=rev
> Log:
> clang/test/CodeGenCXX/debug-info-method.cpp: Tweak for thiscall, for
> targeting Win32 x86.
>
> Modified:
> cfe/trunk/test/CodeGenCXX/debug-info-method.cpp
>
> Modified: cfe/trunk/test/CodeGenCXX/debug-info-method.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-method.cpp?rev=272253&r1=272252&r2=272253&view=diff
>
> ==
> --- cfe/trunk/test/CodeGenCXX/debug-info-method.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-method.cpp Thu Jun  9 05:06:13
> 2016
> @@ -6,7 +6,7 @@
>  // CHECK-SAME:  DIFlagArtificial
>  // CHECK: !DIDerivedType(tag: DW_TAG_ptr_to_member_type
>  // CHECK: !DIDerivedType(tag: DW_TAG_ptr_to_member_type, baseType:
> ![[MEMFUNTYPE:[0-9]+]]
> -// CHECK: ![[MEMFUNTYPE]] = !DISubroutineType(types:
> ![[MEMFUNARGS:[0-9]+]])
> +// CHECK: ![[MEMFUNTYPE]] = !DISubroutineType({{(cc:
> DW_CC_BORLAND_thiscall, )?}}types: ![[MEMFUNARGS:[0-9]+]])
>  // CHECK: ![[MEMFUNARGS]] = {{.*}}, ![[THISTYPE]],
>  // CHECK: !DILocalVariable(name: "this", arg: 1
>  // CHECK: !DILocalVariable(arg: 2
>
>
> ___
> 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: [A fix related to closing C++ header file descriptors on windows]

2016-06-09 Thread jean-yves desbree via cfe-commits
Hi Manuel,

I had forgotten this point and I see your mail only now...
Thanks for your interest.

I did not evaluate this issue with a newer release of clang (issue seen in
3.6.2)

However, it seems that other people still have this kind of issue for
several months.
https://bugreports.qt.io/browse/QTCREATORBUG-15449
So I imagine it would be worth seeing if it is related.

Since I did this patch, I never had again the lock on the H files.
And I use qtcreator with clang as my everyday c++ IDE.
So it seems to be a good candidate.

An IDE is more sensitive to leaks than a compiler / analyzer as it keeps
the files open on a longer duration.
So it may explain why nobody else complains.

Thanks,
Jean-Yves



On Wed, Apr 27, 2016 at 1:54 PM, Manuel Klimek  wrote:

> Stumbling over this (much too late, of course), is this still a problem
> for you?
>
> On Thu, Nov 26, 2015 at 5:01 PM jean-yves desbree via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> I use clang 3.6.2 with qt creator 3.5.1 on windows 7 for parsing code in
>> this IDE.
>> It works well.
>>
>> However, I can see that clang keeps a few times some file descriptors
>> opened on c++ header files (h files) after having parsed a cpp file (that
>> includes these h files).
>> The effect is that we cannot save these h files, what is quite
>> frustrating when using an IDE.
>>
>> After debugging clang, I remarked that there was a file descriptor leak
>> in the method Preprocessor::HandleIncludeDirective
>> (file tools/clang/lib/Lex/PPDirectives.cpp)
>>
>> The object 'FileEntry *File' is created (for a given h file) and after
>> some checks, the regular treatment calls EnterSourceFile.
>> The File object is detroyed during this call (quite deeply in the stack)
>>
>> However, when some errors occur, the execution path goes through early
>> returns and other code pathes.
>> In this case, the file descriptor associated to File is not closed and
>> the file descriptor remains open.
>>
>> So I did a correction that uses RAII in order to have the file descriptor
>> closed.
>> So I wrapped 'FileEntry *File' in a dedicated 'FileEntryCloser
>> fileEntryCloser(File)'
>>
>> On regular treatment, the closer is released:
>>   // If all is good, enter the new file!
>>   if (EnterSourceFile(FID, CurDir, FilenameTok.getLocation()))
>>   {
>>  fileEntryCloser.release();
>>  return;
>>   }
>>
>> Otherwise, the file descriptor is closed
>>~FileEntryCloser()
>>{
>>   if(m_File)
>>  m_File->closeFile();
>>}
>>
>>
>> Now, I have no more remaining file descriptors ...
>> Would it be possible to have an evaluation on that?
>>
>> Thanks in advance.
>> ___
>> 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] D21185: [clang-tidy] Add performance-emplace-into-containers

2016-06-09 Thread Vedant Kumar via cfe-commits
vsk created this revision.
vsk added reviewers: aaron.ballman, alexfh.
vsk added a subscriber: cfe-commits.

Introduce a check which suggests when it might be helpful to use "emplace" 
methods. The initial version only works with std::vector and push_back (e.g 
`V.push_back(T(1, 2))` -> `V.emplace_back(1, 2)`). It could be extended to work 
with other containers and methods.

http://reviews.llvm.org/D21185

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/EmplaceCheck.cpp
  clang-tidy/performance/EmplaceCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  test/clang-tidy/performance-emplace-into-containers.cpp

Index: test/clang-tidy/performance-emplace-into-containers.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-emplace-into-containers.cpp
@@ -0,0 +1,46 @@
+// RUN: %check_clang_tidy %s performance-emplace-into-containers %t -- -- -std=c++11
+
+namespace std {
+
+template 
+struct vector {
+  void push_back(const T &x);
+  void push_back(T &&x);
+
+  template 
+  void emplace_back(Args &&... args);
+};
+
+} // std
+
+struct X {
+  int x;
+  X() : x(0) {}
+  X(int x) : x(x) {}
+  X(int x, int y) : x(x + y) {}
+  X(const X &Obj) : x(Obj.x) {}
+};
+
+void f1() {
+  std::vector v1;
+
+  v1.push_back(X());
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: Avoid a copy {{.*}}
+  // CHECK-FIXES: v1.emplace_back()
+
+  v1.push_back(X(0, 0));
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: Avoid a copy {{.*}}
+  // CHECK-FIXES: v1.emplace_back(0, 0)
+
+  v1/*a*/./*b*/push_back(/*c*/X(/*d*/0,/*e*/0/*f*/)/*g*/)/*h*/ ;
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: Avoid a copy {{.*}}
+  // CHECK-FIXES: v1/*a*/./*b*/emplace_back(/*c*//*d*/0,/*e*/0/*f*//*g*/)/*h*/ ;
+
+  // Do not try to deal with initializer lists.
+  v1.push_back({0, 0});
+
+  // Do not try to deal with functional casts. FIXME?
+  X x{0, 0};
+  v1.push_back(X(x));
+  v1.push_back(X(0));
+}
Index: clang-tidy/performance/PerformanceTidyModule.cpp
===
--- clang-tidy/performance/PerformanceTidyModule.cpp
+++ clang-tidy/performance/PerformanceTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 
+#include "EmplaceCheck.h"
 #include "FasterStringFindCheck.h"
 #include "ForRangeCopyCheck.h"
 #include "ImplicitCastInLoopCheck.h"
@@ -24,6 +25,8 @@
 class PerformanceModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"performance-emplace-into-containers");
 CheckFactories.registerCheck(
 "performance-faster-string-find");
 CheckFactories.registerCheck(
Index: clang-tidy/performance/EmplaceCheck.h
===
--- /dev/null
+++ clang-tidy/performance/EmplaceCheck.h
@@ -0,0 +1,30 @@
+//===--- EmplaceCheck.h - clang-tidy --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_EMPLACE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_EMPLACE_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace performance {
+
+class EmplaceCheck : public ClangTidyCheck {
+public:
+  EmplaceCheck(StringRef Name, ClangTidyContext *Context);
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace performance
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_EMPLACE_H
Index: clang-tidy/performance/EmplaceCheck.cpp
===
--- /dev/null
+++ clang-tidy/performance/EmplaceCheck.cpp
@@ -0,0 +1,98 @@
+//===--- EmplaceCheck.cpp - clang-tidy ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "EmplaceCheck.h"
+#include "clang/Lex/Lexer.h"
+
+namespace clang {
+namespace tidy {
+namespace performance {
+
+using namespace ast_matchers;
+
+EmplaceCheck::EmplaceCheck(StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context) {}
+
+void EmplaceCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  cxxMemberCallExpr(
+  on(expr(hasType(cxxRecordDecl(hasName("std::vector"),
+  callee(functionDecl(hasName("push_back"))

[PATCH] D21186: clang-rename: mark the DynamicCastExpr test unsupported on ps4

2016-06-09 Thread Miklos Vajna via cfe-commits
vmiklos created this revision.
vmiklos added a reviewer: klimek.
vmiklos added a subscriber: cfe-commits.

It has no RTTI, so the test would always fail in a non-interesting way.

http://reviews.llvm.org/D21186

Files:
  test/clang-rename/DynamicCastExpr.cpp

Index: test/clang-rename/DynamicCastExpr.cpp
===
--- test/clang-rename/DynamicCastExpr.cpp
+++ test/clang-rename/DynamicCastExpr.cpp
@@ -1,5 +1,6 @@
+// UNSUPPORTED: x86_64-scei-ps4
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=186 -new-name=X %t.cpp -i --
+// RUN: clang-rename -offset=218 -new-name=X %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Base {
   virtual int getValue() const = 0;


Index: test/clang-rename/DynamicCastExpr.cpp
===
--- test/clang-rename/DynamicCastExpr.cpp
+++ test/clang-rename/DynamicCastExpr.cpp
@@ -1,5 +1,6 @@
+// UNSUPPORTED: x86_64-scei-ps4
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=186 -new-name=X %t.cpp -i --
+// RUN: clang-rename -offset=218 -new-name=X %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Base {
   virtual int getValue() const = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21120: clang-rename: implement renaming of classes inside dynamic_cast

2016-06-09 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Possible solution posted as http://reviews.llvm.org/D21186.


Repository:
  rL LLVM

http://reviews.llvm.org/D21120



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


r272273 - CIndex: add support for static_assert

2016-06-09 Thread Olivier Goffart via cfe-commits
Author: ogoffart
Date: Thu Jun  9 11:15:55 2016
New Revision: 272273

URL: http://llvm.org/viewvc/llvm-project?rev=272273&view=rev
Log:
CIndex: add support for static_assert

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

Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CursorVisitor.h

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=272273&r1=272272&r2=272273&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Thu Jun  9 11:15:55 2016
@@ -2359,8 +2359,12 @@ enum CXCursorKind {
*/
   CXCursor_ModuleImportDecl  = 600,
   CXCursor_TypeAliasTemplateDecl = 601,
+  /**
+   * \brief A static_assert or _Static_assert node
+   */
+  CXCursor_StaticAssert  = 602,
   CXCursor_FirstExtraDecl= CXCursor_ModuleImportDecl,
-  CXCursor_LastExtraDecl = CXCursor_TypeAliasTemplateDecl,
+  CXCursor_LastExtraDecl = CXCursor_StaticAssert,
 
   /**
* \brief A code completion overload candidate.

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=272273&r1=272272&r2=272273&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Jun  9 11:15:55 2016
@@ -3044,6 +3044,7 @@ CXCursorKind clang::getCursorKindForDecl
 case Decl::ClassTemplatePartialSpecialization:
   return CXCursor_ClassTemplatePartialSpecialization;
 case Decl::UsingDirective: return CXCursor_UsingDirective;
+case Decl::StaticAssert:   return CXCursor_StaticAssert;
 case Decl::TranslationUnit:return CXCursor_TranslationUnit;
   
 case Decl::Using:

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=272273&r1=272272&r2=272273&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Jun  9 11:15:55 2016
@@ -1230,6 +1230,14 @@ bool CursorVisitor::VisitUnresolvedUsing
   return false;
 }
 
+bool CursorVisitor::VisitStaticAssertDecl(StaticAssertDecl *D) {
+  if (Visit(MakeCXCursor(D->getAssertExpr(), StmtParent, TU, 
RegionOfInterest)))
+return true;
+  if (Visit(MakeCXCursor(D->getMessage(), StmtParent, TU, RegionOfInterest)))
+return true;
+  return false;
+}
+
 bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
   switch (Name.getName().getNameKind()) {
   case clang::DeclarationName::Identifier:
@@ -4822,6 +4830,8 @@ CXString clang_getCursorKindSpelling(enu
   return cxstring::createRef("OverloadCandidate");
   case CXCursor_TypeAliasTemplateDecl:
   return cxstring::createRef("TypeAliasTemplateDecl");
+  case CXCursor_StaticAssert:
+  return cxstring::createRef("StaticAssert");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");

Modified: cfe/trunk/tools/libclang/CursorVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CursorVisitor.h?rev=272273&r1=272272&r2=272273&view=diff
==
--- cfe/trunk/tools/libclang/CursorVisitor.h (original)
+++ cfe/trunk/tools/libclang/CursorVisitor.h Thu Jun  9 11:15:55 2016
@@ -238,6 +238,7 @@ public:
   bool VisitUsingDecl(UsingDecl *D);
   bool VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
   bool VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
+  bool VisitStaticAssertDecl(StaticAssertDecl *D);
   
   // Name visitor
   bool VisitDeclarationNameInfo(DeclarationNameInfo Name);


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


r272274 - Make sizeof and alignof a CXCursor_UnaryExpr

2016-06-09 Thread Olivier Goffart via cfe-commits
Author: ogoffart
Date: Thu Jun  9 11:16:06 2016
New Revision: 272274

URL: http://llvm.org/viewvc/llvm-project?rev=272274&view=rev
Log:
Make sizeof and alignof a CXCursor_UnaryExpr

So we can match sizeof expressions more accurately than with UnexposedExpr

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

Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/annotate-tokens.c
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=272274&r1=272273&r2=272274&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Thu Jun  9 11:16:06 2016
@@ -1932,7 +1932,7 @@ enum CXCursorKind {
*/
   CXCursor_CXXDeleteExpr = 135,
 
-  /** \brief A unary expression.
+  /** \brief A unary expression. (noexcept, sizeof, or other traits)
*/
   CXCursor_UnaryExpr = 136,
 

Modified: cfe/trunk/test/Index/annotate-tokens.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.c?rev=272274&r1=272273&r2=272274&view=diff
==
--- cfe/trunk/test/Index/annotate-tokens.c (original)
+++ cfe/trunk/test/Index/annotate-tokens.c Thu Jun  9 11:16:06 2016
@@ -80,10 +80,10 @@ void test() {
 // CHECK: Punctuation: "(" [5:3 - 5:4] CStyleCastExpr=
 // CHECK: Keyword: "void" [5:4 - 5:8] CStyleCastExpr=
 // CHECK: Punctuation: ")" [5:8 - 5:9] CStyleCastExpr=
-// CHECK: Keyword: "sizeof" [5:9 - 5:15] UnexposedExpr=
-// CHECK: Punctuation: "(" [5:15 - 5:16] UnexposedExpr=
+// CHECK: Keyword: "sizeof" [5:9 - 5:15] UnaryExpr=
+// CHECK: Punctuation: "(" [5:15 - 5:16] UnaryExpr=
 // CHECK: Identifier: "T" [5:16 - 5:17] TypeRef=T:1:13
-// CHECK: Punctuation: ")" [5:17 - 5:18] UnexposedExpr=
+// CHECK: Punctuation: ")" [5:17 - 5:18] UnaryExpr=
 // CHECK: Punctuation: ";" [5:18 - 5:19] CompoundStmt=
 // CHECK: Keyword: "struct" [7:3 - 7:9] VarDecl=x:7:12 (Definition)
 // CHECK: Identifier: "X" [7:10 - 7:11] TypeRef=struct X:2:8

Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=272274&r1=272273&r2=272274&view=diff
==
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Thu Jun  9 11:16:06 2016
@@ -256,7 +256,6 @@ CXCursor cxcursor::MakeCXCursor(const St
   case Stmt::PredefinedExprClass:
   case Stmt::ShuffleVectorExprClass:
   case Stmt::ConvertVectorExprClass:
-  case Stmt::UnaryExprOrTypeTraitExprClass:
   case Stmt::VAArgExprClass:
   case Stmt::ObjCArrayLiteralClass:
   case Stmt::ObjCDictionaryLiteralClass:
@@ -327,6 +326,7 @@ CXCursor cxcursor::MakeCXCursor(const St
 K = CXCursor_UnaryOperator;
 break;
 
+  case Stmt::UnaryExprOrTypeTraitExprClass:
   case Stmt::CXXNoexceptExprClass:
 K = CXCursor_UnaryExpr;
 break;


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


Re: [PATCH] D18081: Make sizeof and alignof a CXCursor_UnaryExpr

2016-06-09 Thread Olivier Goffart via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272274: Make sizeof and alignof a CXCursor_UnaryExpr 
(authored by ogoffart).

Changed prior to commit:
  http://reviews.llvm.org/D18081?vs=50408&id=60187#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18081

Files:
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/test/Index/annotate-tokens.c
  cfe/trunk/tools/libclang/CXCursor.cpp

Index: cfe/trunk/tools/libclang/CXCursor.cpp
===
--- cfe/trunk/tools/libclang/CXCursor.cpp
+++ cfe/trunk/tools/libclang/CXCursor.cpp
@@ -256,7 +256,6 @@
   case Stmt::PredefinedExprClass:
   case Stmt::ShuffleVectorExprClass:
   case Stmt::ConvertVectorExprClass:
-  case Stmt::UnaryExprOrTypeTraitExprClass:
   case Stmt::VAArgExprClass:
   case Stmt::ObjCArrayLiteralClass:
   case Stmt::ObjCDictionaryLiteralClass:
@@ -327,6 +326,7 @@
 K = CXCursor_UnaryOperator;
 break;
 
+  case Stmt::UnaryExprOrTypeTraitExprClass:
   case Stmt::CXXNoexceptExprClass:
 K = CXCursor_UnaryExpr;
 break;
Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -1932,7 +1932,7 @@
*/
   CXCursor_CXXDeleteExpr = 135,
 
-  /** \brief A unary expression.
+  /** \brief A unary expression. (noexcept, sizeof, or other traits)
*/
   CXCursor_UnaryExpr = 136,
 
Index: cfe/trunk/test/Index/annotate-tokens.c
===
--- cfe/trunk/test/Index/annotate-tokens.c
+++ cfe/trunk/test/Index/annotate-tokens.c
@@ -80,10 +80,10 @@
 // CHECK: Punctuation: "(" [5:3 - 5:4] CStyleCastExpr=
 // CHECK: Keyword: "void" [5:4 - 5:8] CStyleCastExpr=
 // CHECK: Punctuation: ")" [5:8 - 5:9] CStyleCastExpr=
-// CHECK: Keyword: "sizeof" [5:9 - 5:15] UnexposedExpr=
-// CHECK: Punctuation: "(" [5:15 - 5:16] UnexposedExpr=
+// CHECK: Keyword: "sizeof" [5:9 - 5:15] UnaryExpr=
+// CHECK: Punctuation: "(" [5:15 - 5:16] UnaryExpr=
 // CHECK: Identifier: "T" [5:16 - 5:17] TypeRef=T:1:13
-// CHECK: Punctuation: ")" [5:17 - 5:18] UnexposedExpr=
+// CHECK: Punctuation: ")" [5:17 - 5:18] UnaryExpr=
 // CHECK: Punctuation: ";" [5:18 - 5:19] CompoundStmt=
 // CHECK: Keyword: "struct" [7:3 - 7:9] VarDecl=x:7:12 (Definition)
 // CHECK: Identifier: "X" [7:10 - 7:11] TypeRef=struct X:2:8


Index: cfe/trunk/tools/libclang/CXCursor.cpp
===
--- cfe/trunk/tools/libclang/CXCursor.cpp
+++ cfe/trunk/tools/libclang/CXCursor.cpp
@@ -256,7 +256,6 @@
   case Stmt::PredefinedExprClass:
   case Stmt::ShuffleVectorExprClass:
   case Stmt::ConvertVectorExprClass:
-  case Stmt::UnaryExprOrTypeTraitExprClass:
   case Stmt::VAArgExprClass:
   case Stmt::ObjCArrayLiteralClass:
   case Stmt::ObjCDictionaryLiteralClass:
@@ -327,6 +326,7 @@
 K = CXCursor_UnaryOperator;
 break;
 
+  case Stmt::UnaryExprOrTypeTraitExprClass:
   case Stmt::CXXNoexceptExprClass:
 K = CXCursor_UnaryExpr;
 break;
Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -1932,7 +1932,7 @@
*/
   CXCursor_CXXDeleteExpr = 135,
 
-  /** \brief A unary expression.
+  /** \brief A unary expression. (noexcept, sizeof, or other traits)
*/
   CXCursor_UnaryExpr = 136,
 
Index: cfe/trunk/test/Index/annotate-tokens.c
===
--- cfe/trunk/test/Index/annotate-tokens.c
+++ cfe/trunk/test/Index/annotate-tokens.c
@@ -80,10 +80,10 @@
 // CHECK: Punctuation: "(" [5:3 - 5:4] CStyleCastExpr=
 // CHECK: Keyword: "void" [5:4 - 5:8] CStyleCastExpr=
 // CHECK: Punctuation: ")" [5:8 - 5:9] CStyleCastExpr=
-// CHECK: Keyword: "sizeof" [5:9 - 5:15] UnexposedExpr=
-// CHECK: Punctuation: "(" [5:15 - 5:16] UnexposedExpr=
+// CHECK: Keyword: "sizeof" [5:9 - 5:15] UnaryExpr=
+// CHECK: Punctuation: "(" [5:15 - 5:16] UnaryExpr=
 // CHECK: Identifier: "T" [5:16 - 5:17] TypeRef=T:1:13
-// CHECK: Punctuation: ")" [5:17 - 5:18] UnexposedExpr=
+// CHECK: Punctuation: ")" [5:17 - 5:18] UnaryExpr=
 // CHECK: Punctuation: ";" [5:18 - 5:19] CompoundStmt=
 // CHECK: Keyword: "struct" [7:3 - 7:9] VarDecl=x:7:12 (Definition)
 // CHECK: Identifier: "X" [7:10 - 7:11] TypeRef=struct X:2:8
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18080: CIndex: add support for static_assert

2016-06-09 Thread Olivier Goffart via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272273: CIndex: add support for static_assert (authored by 
ogoffart).

Changed prior to commit:
  http://reviews.llvm.org/D18080?vs=50407&id=60186#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18080

Files:
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/tools/libclang/CIndex.cpp
  cfe/trunk/tools/libclang/CursorVisitor.h

Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -3044,6 +3044,7 @@
 case Decl::ClassTemplatePartialSpecialization:
   return CXCursor_ClassTemplatePartialSpecialization;
 case Decl::UsingDirective: return CXCursor_UsingDirective;
+case Decl::StaticAssert:   return CXCursor_StaticAssert;
 case Decl::TranslationUnit:return CXCursor_TranslationUnit;
   
 case Decl::Using:
Index: cfe/trunk/tools/libclang/CursorVisitor.h
===
--- cfe/trunk/tools/libclang/CursorVisitor.h
+++ cfe/trunk/tools/libclang/CursorVisitor.h
@@ -238,6 +238,7 @@
   bool VisitUsingDecl(UsingDecl *D);
   bool VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
   bool VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
+  bool VisitStaticAssertDecl(StaticAssertDecl *D);
   
   // Name visitor
   bool VisitDeclarationNameInfo(DeclarationNameInfo Name);
Index: cfe/trunk/tools/libclang/CIndex.cpp
===
--- cfe/trunk/tools/libclang/CIndex.cpp
+++ cfe/trunk/tools/libclang/CIndex.cpp
@@ -1230,6 +1230,14 @@
   return false;
 }
 
+bool CursorVisitor::VisitStaticAssertDecl(StaticAssertDecl *D) {
+  if (Visit(MakeCXCursor(D->getAssertExpr(), StmtParent, TU, 
RegionOfInterest)))
+return true;
+  if (Visit(MakeCXCursor(D->getMessage(), StmtParent, TU, RegionOfInterest)))
+return true;
+  return false;
+}
+
 bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
   switch (Name.getName().getNameKind()) {
   case clang::DeclarationName::Identifier:
@@ -4822,6 +4830,8 @@
   return cxstring::createRef("OverloadCandidate");
   case CXCursor_TypeAliasTemplateDecl:
   return cxstring::createRef("TypeAliasTemplateDecl");
+  case CXCursor_StaticAssert:
+  return cxstring::createRef("StaticAssert");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");
Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -2359,8 +2359,12 @@
*/
   CXCursor_ModuleImportDecl  = 600,
   CXCursor_TypeAliasTemplateDecl = 601,
+  /**
+   * \brief A static_assert or _Static_assert node
+   */
+  CXCursor_StaticAssert  = 602,
   CXCursor_FirstExtraDecl= CXCursor_ModuleImportDecl,
-  CXCursor_LastExtraDecl = CXCursor_TypeAliasTemplateDecl,
+  CXCursor_LastExtraDecl = CXCursor_StaticAssert,
 
   /**
* \brief A code completion overload candidate.


Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -3044,6 +3044,7 @@
 case Decl::ClassTemplatePartialSpecialization:
   return CXCursor_ClassTemplatePartialSpecialization;
 case Decl::UsingDirective: return CXCursor_UsingDirective;
+case Decl::StaticAssert:   return CXCursor_StaticAssert;
 case Decl::TranslationUnit:return CXCursor_TranslationUnit;
   
 case Decl::Using:
Index: cfe/trunk/tools/libclang/CursorVisitor.h
===
--- cfe/trunk/tools/libclang/CursorVisitor.h
+++ cfe/trunk/tools/libclang/CursorVisitor.h
@@ -238,6 +238,7 @@
   bool VisitUsingDecl(UsingDecl *D);
   bool VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
   bool VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
+  bool VisitStaticAssertDecl(StaticAssertDecl *D);
   
   // Name visitor
   bool VisitDeclarationNameInfo(DeclarationNameInfo Name);
Index: cfe/trunk/tools/libclang/CIndex.cpp
===
--- cfe/trunk/tools/libclang/CIndex.cpp
+++ cfe/trunk/tools/libclang/CIndex.cpp
@@ -1230,6 +1230,14 @@
   return false;
 }
 
+bool CursorVisitor::VisitStaticAssertDecl(StaticAssertDecl *D) {
+  if (Visit(MakeCXCursor(D->getAssertExpr(), StmtParent, TU, RegionOfInterest)))
+return true;
+  if (Visit(MakeCXCursor(D->getMessage(), StmtParent, TU, RegionOfInterest)))
+return true;
+  return false;
+}
+
 bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
   switch (Na

r272275 - [CMake] Fix an issue building out-of-tree introduced in r272200

2016-06-09 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Thu Jun  9 11:21:10 2016
New Revision: 272275

URL: http://llvm.org/viewvc/llvm-project?rev=272275&view=rev
Log:
[CMake] Fix an issue building out-of-tree introduced in r272200

The out-of-tree build needs to read LLVM_TOOLS_INSTALL_DIR out of 
TOOLS_BINARY_DIR because LLVM_TOOLS_INSTALL_DIR is used by AddLLVM.cmake

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=272275&r1=272274&r2=272275&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Thu Jun  9 11:21:10 2016
@@ -56,6 +56,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
   list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
 
+  get_filename_component(LLVM_TOOLS_INSTALL_DIR ${TOOLS_BINARY_DIR} NAME)
+
   if(NOT MSVC_IDE)
 set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
   CACHE BOOL "Enable assertions")


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


Re: [PATCH] D21163: Strip Android version when looking up toolchain paths.

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

This could do with a test in test/Driver.


http://reviews.llvm.org/D21163



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


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

2016-06-09 Thread Tim Shen via cfe-commits
timshen marked an inline comment as done.
timshen added a comment.

Ping? :)


http://reviews.llvm.org/D20498



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


Re: [PATCH] D21162: [CUDA] Implement __shfl* intrinsics in clang headers.

2016-06-09 Thread Justin Lebar via cfe-commits
jlebar added a comment.

(Art, I would appreciate a second set of eyes on this one, as the last time I 
did this -- with ldg -- I messed up pretty badly.)


http://reviews.llvm.org/D21162



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


Re: [clang-tools-extra] r272188 - clang-rename: implement renaming of classes inside dynamic_cast

2016-06-09 Thread Galina Kistanova via cfe-commits
Hi Miklos,

This revision broke tests on one of builders:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/14332

Please have a look at this?

Thanks

Galina


On Wed, Jun 8, 2016 at 11:38 AM, Miklos Vajna via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: vmiklos
> Date: Wed Jun  8 13:38:23 2016
> New Revision: 272188
>
> URL: http://llvm.org/viewvc/llvm-project?rev=272188&view=rev
> Log:
> clang-rename: implement renaming of classes inside dynamic_cast
>
> Refactor to do the same as what is done already for static_cast.
>
> Reviewers: klimek
>
> Differential Revision: http://reviews.llvm.org/D21120
>
> Added:
> clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp
> 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=272188&r1=272187&r2=272188&view=diff
>
> ==
> --- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
> +++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Wed Jun  8
> 13:38:23 2016
> @@ -124,20 +124,11 @@ public:
>}
>
>bool VisitCXXStaticCastExpr(clang::CXXStaticCastExpr *Expr) {
> -clang::QualType Type = Expr->getType();
> -// See if this a cast of a pointer.
> -const RecordDecl* Decl = Type->getPointeeCXXRecordDecl();
> -if (!Decl) {
> -  // See if this is a cast of a reference.
> -  Decl = Type->getAsCXXRecordDecl();
> -}
> -
> -if (Decl && getUSRForDecl(Decl) == USR) {
> -  SourceLocation Location =
> Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc();
> -  LocationsFound.push_back(Location);
> -}
> +return handleCXXNamedCastExpr(Expr);
> +  }
>
> -return true;
> +  bool VisitCXXDynamicCastExpr(clang::CXXDynamicCastExpr *Expr) {
> +return handleCXXNamedCastExpr(Expr);
>}
>
>// Non-visitors:
> @@ -159,6 +150,23 @@ private:
>  }
>}
>
> +  bool handleCXXNamedCastExpr(clang::CXXNamedCastExpr *Expr) {
> +clang::QualType Type = Expr->getType();
> +// See if this a cast of a pointer.
> +const RecordDecl* Decl = Type->getPointeeCXXRecordDecl();
> +if (!Decl) {
> +  // See if this is a cast of a reference.
> +  Decl = Type->getAsCXXRecordDecl();
> +}
> +
> +if (Decl && getUSRForDecl(Decl) == USR) {
> +  SourceLocation Location =
> Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc();
> +  LocationsFound.push_back(Location);
> +}
> +
> +return true;
> +  }
> +
>// All the locations of the USR were found.
>const std::string USR;
>// Old name that is renamed.
>
> Added: clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp?rev=272188&view=auto
>
> ==
> --- clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp (added)
> +++ clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp Wed Jun
> 8 13:38:23 2016
> @@ -0,0 +1,25 @@
> +// RUN: cat %s > %t.cpp
> +// RUN: clang-rename -offset=186 -new-name=X %t.cpp -i --
> +// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
> +class Base {
> +  virtual int getValue() const = 0;
> +};
> +
> +class Derived : public Base {
> +public:
> +  int getValue() const {
> +return 0;
> +  }
> +};
> +
> +int main() {
> +  Derived D;
> +  const Base &Reference = D;
> +  const Base *Pointer = &D;
> +
> +  dynamic_cast(Reference).getValue(); // CHECK:
> dynamic_cast
> +  dynamic_cast(Pointer)->getValue();  // CHECK:
> dynamic_cast
> +}
> +
> +// Use grep -FUbo 'Derived'  to get the correct offset of foo when
> changing
> +// this file.
>
>
> ___
> 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] D21162: [CUDA] Implement __shfl* intrinsics in clang headers.

2016-06-09 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Thank you for the reviews, Justin!


http://reviews.llvm.org/D21162



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


[PATCH] D21187: Allow use of lambda expressions in array bounds

2016-06-09 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added a subscriber: cfe-commits.

clang currently errors out when a lambda expression is used to compute the size 
of an array even though clang supports variable-length arrays as a C99 
extension. For example,

$ cat vla1.cpp

```
int foo3();

struct S1 {
  virtual ~S1();
};

struct S2 : S1 {
};

void foo(S1 *s1) {
  unsigned char a1[([](int a) {return a; })(1)];
  unsigned char a2[foo3()]; // This is OK.
  unsigned char a3[!dynamic_cast(s1) + 1];  // This is OK.
}
```

$ clang++ vla1.cpp -c -std=c++11
vla1.cpp:11:21: error: a lambda expression may not appear inside of a constant 
expression
  unsigned char a1[([](int a) {return a; })(1)];
^
1 error generated.

To handle VLAs in a more consistent way, this patch makes changes to allow 
lambda expressions to be used for array bounds if it is in a BlockContext.

http://reviews.llvm.org/D21187

Files:
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/lambda-expressions.cpp

Index: test/SemaCXX/lambda-expressions.cpp
===
--- test/SemaCXX/lambda-expressions.cpp
+++ test/SemaCXX/lambda-expressions.cpp
@@ -499,3 +499,12 @@
   };
 }
 }
+
+namespace array_bound {
+void foo() {
+  int a0[([](){ return 4; })()];
+  int a2[([](int n){ return n; })(4)];
+}
+
+int a2[([](){ return 4; })()]; // expected-error {{a lambda expression may not appear inside of a constant expression}} expected-error {{variable length array declaration not allowed at file scope}}
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -12791,10 +12791,10 @@
 void
 Sema::PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext,
   Decl *LambdaContextDecl,
-  bool IsDecltype) {
+  bool IsDecltype, bool IsArrayBound) {
   ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(),
 ExprNeedsCleanups, LambdaContextDecl,
-IsDecltype);
+IsDecltype, IsArrayBound);
   ExprNeedsCleanups = false;
   if (!MaybeODRUseExprs.empty())
 std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
@@ -12814,21 +12814,22 @@
 
   if (!Rec.Lambdas.empty()) {
 if (Rec.isUnevaluated() || Rec.Context == ConstantEvaluated) {
-  unsigned D;
   if (Rec.isUnevaluated()) {
 // C++11 [expr.prim.lambda]p2:
 //   A lambda-expression shall not appear in an unevaluated operand
 //   (Clause 5).
-D = diag::err_lambda_unevaluated_operand;
-  } else {
+for (const auto *L : Rec.Lambdas)
+  Diag(L->getLocStart(), diag::err_lambda_unevaluated_operand);
+  // Don't error out on lambdas used to compute array size in a
+  // BlockContext.
+  } else if (!Rec.IsArrayBound) {
 // C++1y [expr.const]p2:
 //   A conditional-expression e is a core constant expression unless the
 //   evaluation of e, following the rules of the abstract machine, would
 //   evaluate [...] a lambda-expression.
-D = diag::err_lambda_in_constant_expression;
+for (const auto *L : Rec.Lambdas)
+  Diag(L->getLocStart(), diag::err_lambda_in_constant_expression);
   }
-  for (const auto *L : Rec.Lambdas)
-Diag(L->getLocStart(), D);
 } else {
   // Mark the capture expressions odr-used. This was deferred
   // during lambda expression creation.
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -124,7 +124,8 @@
   // Tell diagnostics how to render things from the AST library.
   Diags.SetArgToStringFn(&FormatASTNodeDiagnosticArgument, &Context);
 
-  ExprEvalContexts.emplace_back(PotentiallyEvaluated, 0, false, nullptr, false);
+  ExprEvalContexts.emplace_back(PotentiallyEvaluated, 0, false, nullptr, false,
+false);
 
   FunctionScopes.push_back(new FunctionScopeInfo(Diags));
 
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -194,13 +194,14 @@
 }
 
 
-ExprResult Parser::ParseConstantExpression(TypeCastState isTypeCast) {
+ExprResult Parser::ParseConstantExpression(TypeCastState isTypeCast,
+   bool IsArrayBound) {
   // C++03 [basic.def.odr]p2:
   //   An expression is potentially evaluated unless it appears where an
   //   integral constant expression is required (see 5.19) [...].
   // C++98 and C++11 have no such rule, but this is only a defect in C++98.
-  Enter

Re: [clang-tools-extra] r272188 - clang-rename: implement renaming of classes inside dynamic_cast

2016-06-09 Thread Miklos Vajna via cfe-commits
Hi Galina,

On Thu, Jun 09, 2016 at 10:15:27AM -0700, Galina Kistanova 
 wrote:
> This revision broke tests on one of builders:
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/14332

Please accept  if it's the correct fix.
It fixed the problem for me.

Regards,

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


Re: [PATCH] D21185: [clang-tidy] Add performance-emplace-into-containers

2016-06-09 Thread Vedant Kumar via cfe-commits
vsk added a reviewer: flx.
vsk updated this revision to Diff 60194.
vsk added a comment.

- Fix handling of push_back(X(/* comment */)).
- Don't try to emit a warning when the callee comes from a macro expansion.
- Get rid of a weird/wrong comment about checking for "default constructors".

As a side note, I'd appreciate advice on how to apply this check to the llvm 
codebase (via some kind of cmake invocation?) and gather numbers.


http://reviews.llvm.org/D21185

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/EmplaceCheck.cpp
  clang-tidy/performance/EmplaceCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  test/clang-tidy/performance-emplace-into-containers.cpp

Index: test/clang-tidy/performance-emplace-into-containers.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-emplace-into-containers.cpp
@@ -0,0 +1,57 @@
+// RUN: %check_clang_tidy %s performance-emplace-into-containers %t -- -- -std=c++11
+
+namespace std {
+
+template 
+struct vector {
+  void push_back(const T &x);
+  void push_back(T &&x);
+
+  template 
+  void emplace_back(Args &&... args);
+};
+
+} // std
+
+struct X {
+  int x;
+  X() : x(0) {}
+  X(int x) : x(x) {}
+  X(int x, int y) : x(x + y) {}
+  X(const X &Obj) : x(Obj.x) {}
+};
+
+void f1() {
+  std::vector v1;
+
+  v1.push_back(X());
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: Avoid a copy {{.*}}
+  // CHECK-FIXES: v1.emplace_back()
+
+  v1.push_back(X(/*a*/));
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: Avoid a copy {{.*}}
+  // CHECK-FIXES: v1.emplace_back(/*a*/)
+
+  v1.push_back(X(0, 0));
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: Avoid a copy {{.*}}
+  // CHECK-FIXES: v1.emplace_back(0, 0)
+
+  v1/*a*/./*b*/push_back(/*c*/X(/*d*/0,/*e*/0/*f*/)/*g*/)/*h*/ ;
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: Avoid a copy {{.*}}
+  // CHECK-FIXES: v1/*a*/./*b*/emplace_back(/*c*//*d*/0,/*e*/0/*f*//*g*/)/*h*/ ;
+
+  // Do not try to deal with initializer lists.
+  v1.push_back({0, 0});
+
+  // Do not try to deal with functional casts. FIXME?
+  X x{0, 0};
+  v1.push_back(X(x));
+  v1.push_back(X(0));
+
+  // Do not try to deal with weird expansions.
+#define M1 X(0, 0)
+#define M2 push_back
+  v1.push_back(M1);
+  v1.M2(X(0, 0));
+  v1.M2(M1);
+}
Index: clang-tidy/performance/PerformanceTidyModule.cpp
===
--- clang-tidy/performance/PerformanceTidyModule.cpp
+++ clang-tidy/performance/PerformanceTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 
+#include "EmplaceCheck.h"
 #include "FasterStringFindCheck.h"
 #include "ForRangeCopyCheck.h"
 #include "ImplicitCastInLoopCheck.h"
@@ -24,6 +25,8 @@
 class PerformanceModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"performance-emplace-into-containers");
 CheckFactories.registerCheck(
 "performance-faster-string-find");
 CheckFactories.registerCheck(
Index: clang-tidy/performance/EmplaceCheck.h
===
--- /dev/null
+++ clang-tidy/performance/EmplaceCheck.h
@@ -0,0 +1,30 @@
+//===--- EmplaceCheck.h - clang-tidy --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_EMPLACE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_EMPLACE_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace performance {
+
+class EmplaceCheck : public ClangTidyCheck {
+public:
+  EmplaceCheck(StringRef Name, ClangTidyContext *Context);
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace performance
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_EMPLACE_H
Index: clang-tidy/performance/EmplaceCheck.cpp
===
--- /dev/null
+++ clang-tidy/performance/EmplaceCheck.cpp
@@ -0,0 +1,98 @@
+//===--- EmplaceCheck.cpp - clang-tidy ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "EmplaceCheck.h"
+#include "clang/Lex/Lexer.h"
+
+namespace clang {
+namespace tidy {
+namespace performance {
+
+using namespace ast_matchers;
+
+

r272280 - Revert "[CMake] Fix an issue building out-of-tree introduced in r272200"

2016-06-09 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Thu Jun  9 12:24:16 2016
New Revision: 272280

URL: http://llvm.org/viewvc/llvm-project?rev=272280&view=rev
Log:
Revert "[CMake] Fix an issue building out-of-tree introduced in r272200"

This reverts r272275. This actually wasn't the right way to fix the problem. 
The correct solution is in r272279.

Applying the fix to LLVM as done in r272279, means this fix will get picked up 
by all projects building out of tree using LLVM's CMake modules. As opposed to 
the fix I had in r272275, which would require each project to change.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=272280&r1=272279&r2=272280&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Thu Jun  9 12:24:16 2016
@@ -56,8 +56,6 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
   list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
 
-  get_filename_component(LLVM_TOOLS_INSTALL_DIR ${TOOLS_BINARY_DIR} NAME)
-
   if(NOT MSVC_IDE)
 set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
   CACHE BOOL "Enable assertions")


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


Java Interface for clang

2016-06-09 Thread Maryam Mehraban via cfe-commits
Hello everybody,

I want to use clang and its facilities to parse c and c++ . but I need to
use it in java.
In my searches , saw jClang or Clang bindings for java, checking the date
of pages returned to me was before 2015.
so I know what is the status of jclang or is there any solution to use
clang and libraries in java.
thanks very much.
Mary.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21162: [CUDA] Implement __shfl* intrinsics in clang headers.

2016-06-09 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: lib/Headers/__clang_cuda_intrinsics.h:77-80
@@ +76,6 @@
+_Static_assert(sizeof(__tmp) == sizeof(__in)); 
\
+memcpy(&__tmp, &__in, sizeof(__in));   
\
+__tmp = ::__FnName(__tmp, __offset, __width);  
\
+double __out;  
\
+memcpy(&__out, &__tmp, sizeof(__out)); 
\
+return __out;  
\

Could we use a union instead?


Comment at: lib/Headers/__clang_cuda_intrinsics.h:87
@@ +86,3 @@
+__MAKE_SHUFFLES(__shfl_up, __builtin_ptx_shfl_up_i32, 
__builtin_ptx_shfl_up_f32,
+0);
+__MAKE_SHUFFLES(__shfl_down, __builtin_ptx_shfl_down_i32,

Ugh. Took me a while to figure out why 0 is used here.
Unlike other variants shfl.up apparently applies to lanes >= maxLane. Who would 
have thought.
Might add a comment here so it's not mistaken for a typo.


http://reviews.llvm.org/D21162



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


Re: [PATCH] D21185: [clang-tidy] Add performance-emplace-into-containers

2016-06-09 Thread Vedant Kumar via cfe-commits
vsk updated this revision to Diff 60206.
vsk added a comment.

- Fix the diagnostic message. Suggested by Erik Pilkington.


http://reviews.llvm.org/D21185

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/EmplaceCheck.cpp
  clang-tidy/performance/EmplaceCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  test/clang-tidy/performance-emplace-into-containers.cpp

Index: test/clang-tidy/performance-emplace-into-containers.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-emplace-into-containers.cpp
@@ -0,0 +1,57 @@
+// RUN: %check_clang_tidy %s performance-emplace-into-containers %t -- -- -std=c++11
+
+namespace std {
+
+template 
+struct vector {
+  void push_back(const T &x);
+  void push_back(T &&x);
+
+  template 
+  void emplace_back(Args &&... args);
+};
+
+} // std
+
+struct X {
+  int x;
+  X() : x(0) {}
+  X(int x) : x(x) {}
+  X(int x, int y) : x(x + y) {}
+  X(const X &Obj) : x(Obj.x) {}
+};
+
+void f1() {
+  std::vector v1;
+
+  v1.push_back(X());
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: Consider constructing {{.*}}
+  // CHECK-FIXES: v1.emplace_back()
+
+  v1.push_back(X(/*a*/));
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: Consider constructing {{.*}}
+  // CHECK-FIXES: v1.emplace_back(/*a*/)
+
+  v1.push_back(X(0, 0));
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: Consider constructing {{.*}}
+  // CHECK-FIXES: v1.emplace_back(0, 0)
+
+  v1/*a*/./*b*/push_back(/*c*/X(/*d*/0,/*e*/0/*f*/)/*g*/)/*h*/ ;
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: Consider constructing {{.*}}
+  // CHECK-FIXES: v1/*a*/./*b*/emplace_back(/*c*//*d*/0,/*e*/0/*f*//*g*/)/*h*/ ;
+
+  // Do not try to deal with initializer lists.
+  v1.push_back({0, 0});
+
+  // Do not try to deal with functional casts. FIXME?
+  X x{0, 0};
+  v1.push_back(X(x));
+  v1.push_back(X(0));
+
+  // Do not try to deal with weird expansions.
+#define M1 X(0, 0)
+#define M2 push_back
+  v1.push_back(M1);
+  v1.M2(X(0, 0));
+  v1.M2(M1);
+}
Index: clang-tidy/performance/PerformanceTidyModule.cpp
===
--- clang-tidy/performance/PerformanceTidyModule.cpp
+++ clang-tidy/performance/PerformanceTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 
+#include "EmplaceCheck.h"
 #include "FasterStringFindCheck.h"
 #include "ForRangeCopyCheck.h"
 #include "ImplicitCastInLoopCheck.h"
@@ -24,6 +25,8 @@
 class PerformanceModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"performance-emplace-into-containers");
 CheckFactories.registerCheck(
 "performance-faster-string-find");
 CheckFactories.registerCheck(
Index: clang-tidy/performance/EmplaceCheck.h
===
--- /dev/null
+++ clang-tidy/performance/EmplaceCheck.h
@@ -0,0 +1,30 @@
+//===--- EmplaceCheck.h - clang-tidy --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_EMPLACE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_EMPLACE_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace performance {
+
+class EmplaceCheck : public ClangTidyCheck {
+public:
+  EmplaceCheck(StringRef Name, ClangTidyContext *Context);
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace performance
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_EMPLACE_H
Index: clang-tidy/performance/EmplaceCheck.cpp
===
--- /dev/null
+++ clang-tidy/performance/EmplaceCheck.cpp
@@ -0,0 +1,98 @@
+//===--- EmplaceCheck.cpp - clang-tidy ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "EmplaceCheck.h"
+#include "clang/Lex/Lexer.h"
+
+namespace clang {
+namespace tidy {
+namespace performance {
+
+using namespace ast_matchers;
+
+EmplaceCheck::EmplaceCheck(StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context) {}
+
+void EmplaceCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  cxxMemberCallExpr(
+  on(expr(hasType(cxxRecordDecl(hasName("std::v

Re: [PATCH] D20444: [OpenCL] Include opencl-c.h by default as a clang module

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


Comment at: test/Headers/opencl-c-header.cl:70
@@ +69,3 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -cl-std=CL2.0 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck --check-prefix=CHECK20 %s
+// RUN: %clang_cc1 -triple amdgcn--amdhsa -emit-llvm -o - -cl-std=CL2.0  
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck --check-prefix=CHECK20 %s

yaxunl wrote:
> I added check to the second compilation to make sure module is read, also 
> changed the modules to be read only so that they won't be created again.
Ok, now I see what you are testing here. :)

Do you think we could add:
  CHECK-NOT: Reading modules

For the cases the modules are regenerated new?


http://reviews.llvm.org/D20444



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


Re: [PATCH] D20979: [OpenCL] Use function attribute/metadata to represent kernel attributes

2016-06-09 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

In http://reviews.llvm.org/D20979#452616, @yaxunl wrote:

> In http://reviews.llvm.org/D20979#452463, @Anastasia wrote:
>
> > Looking good generally, I am just not sure about mixing two different 
> > representations.
>
>
> If we choose only one form of representation, would you suggest to use 
> function metadata or function attribute?


I am still not sure if this is the intended use of target-dependent attributes 
to be honest. So I would prefer metadata representation.

Also if we use metadata could we avoid parsing values from strings potentially 
in contrast to attributes that represent all values as strings?

Related to your earlier comments about inflexibility of metadata, would it be 
possible to extend MDNode to be able to insert new operands?


http://reviews.llvm.org/D20979



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


Re: [PATCH] D20347: Add support to clang-cl driver for /GS switch

2016-06-09 Thread Hans Wennborg via cfe-commits
hans added a comment.

Is this waiting for anything more now that http://reviews.llvm.org/D20346 has 
landed?


http://reviews.llvm.org/D20347



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


[libcxx] r272288 - Make the comparison objects that we pass in for various tests look more like actual comparison objects. No functional change.

2016-06-09 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Jun  9 13:34:38 2016
New Revision: 272288

URL: http://llvm.org/viewvc/llvm-project?rev=272288&view=rev
Log:
Make the comparison objects that we pass in for various tests look more like 
actual comparison objects. No functional change.

Modified:

libcxx/trunk/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp?rev=272288&r1=272287&r2=272288&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp
 Thu Jun  9 13:34:38 2016
@@ -28,6 +28,7 @@ struct some_comp
 {
 typedef T value_type;
 some_comp();
+bool operator()(const T&, const T&) const { return false; }
 };
 
 int main()

Modified: 
libcxx/trunk/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-projec

Re: [PATCH] D20132: [libclang] Add clang_getAllSkippedRanges function

2016-06-09 Thread Cameron via cfe-commits
cameron314 added a comment.

Can someone have a look at this now that there's a test?


http://reviews.llvm.org/D20132



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


Re: [PATCH] D20338: [PCH] Fixed overridden files always invalidating preamble even when unchanged

2016-06-09 Thread Cameron via cfe-commits
cameron314 added a comment.

This is a fairly important bug for anyone hosting clang as a library (e.g. 
IDEs).
Can someone have a look at this patch when they have a free moment?


http://reviews.llvm.org/D20338



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


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

2016-06-09 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

@mclow.lists, @EricWF: Gentle (and shameless) ping!


http://reviews.llvm.org/D20328



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


RE: [PATCH] D21173: [X86] _MM_ALIGN16 attribute support for non-windows targets

2016-06-09 Thread Rackover, Zvi via cfe-commits
Thanks the suggestion, David. I did not realize __attribute__ is supported by 
Windows targets.

Zvi

From: David Majnemer [mailto:david.majne...@gmail.com]
Sent: Thursday, June 09, 2016 17:48
To: reviews+d21173+public+9a6e31402e430...@reviews.llvm.org; Rackover, Zvi 

Cc: Aboud, Amjad ; mku...@google.com; 
echri...@gmail.com; cfe-commits@lists.llvm.org
Subject: Re: [PATCH] D21173: [X86] _MM_ALIGN16 attribute support for 
non-windows targets



On Thursday, June 9, 2016, Zvi Rackover via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
zvi created this revision.
zvi added reviewers: aaboud, mkuper, echristo, cfe-commits.
zvi set the repository for this revision to rL LLVM.
zvi added a project: clang-c.
Herald added a subscriber: mehdi_amini.

This patch adds support for the _MM_ALIGN16 attribute on non-windows targets. 
This aligns Clang with ICC which supports the attribute on all targets.

Fixes PR28056

Repository:
  rL LLVM

http://reviews.llvm.org/D21173

Files:
  lib/Headers/xmmintrin.h
  test/Headers/xmmintrin.c

Index: test/Headers/xmmintrin.c
===
--- test/Headers/xmmintrin.c
+++ test/Headers/xmmintrin.c
@@ -7,6 +7,9 @@
 // REQUIRES: x86-registered-target
 #include 

+// CHECK: @c = common global i8 0, align 16
+_MM_ALIGN16 char c;
+
 // Make sure the last step of _mm_cvtps_pi16 converts <4 x i32> to <4 x i16> by
 // checking that clang emits PACKSSDW instead of PACKSSWB.

Index: lib/Headers/xmmintrin.h
===
--- lib/Headers/xmmintrin.h
+++ lib/Headers/xmmintrin.h
@@ -2823,6 +2823,8 @@

 #ifdef _MSC_VER
 #define _MM_ALIGN16 __declspec(align(16))
+#else
+#define _MM_ALIGN16 __attribute__((aligned(16)))
 #endif

I would just use the __attribute__ spelling, no need for two definitions


 #define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w))

-
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] D21173: [X86] _MM_ALIGN16 attribute support for non-windows targets

2016-06-09 Thread Zvi Rackover via cfe-commits
zvi updated this revision to Diff 60217.
zvi added a comment.

Following David Majnemer's suggestion on cfe-commits: I would just use the 
__attribute__ spelling, no need for two definitions


Repository:
  rL LLVM

http://reviews.llvm.org/D21173

Files:
  lib/Headers/xmmintrin.h
  test/Headers/xmmintrin.c

Index: test/Headers/xmmintrin.c
===
--- test/Headers/xmmintrin.c
+++ test/Headers/xmmintrin.c
@@ -7,6 +7,9 @@
 // REQUIRES: x86-registered-target
 #include 
 
+// CHECK: @c = common global i8 0, align 16
+_MM_ALIGN16 char c;
+
 // Make sure the last step of _mm_cvtps_pi16 converts <4 x i32> to <4 x i16> by
 // checking that clang emits PACKSSDW instead of PACKSSWB.
 
Index: lib/Headers/xmmintrin.h
===
--- lib/Headers/xmmintrin.h
+++ lib/Headers/xmmintrin.h
@@ -2821,9 +2821,7 @@
 }
 
 
-#ifdef _MSC_VER
-#define _MM_ALIGN16 __declspec(align(16))
-#endif
+#define _MM_ALIGN16 __attribute__((aligned(16)))
 
 #define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w))
 


Index: test/Headers/xmmintrin.c
===
--- test/Headers/xmmintrin.c
+++ test/Headers/xmmintrin.c
@@ -7,6 +7,9 @@
 // REQUIRES: x86-registered-target
 #include 
 
+// CHECK: @c = common global i8 0, align 16
+_MM_ALIGN16 char c;
+
 // Make sure the last step of _mm_cvtps_pi16 converts <4 x i32> to <4 x i16> by
 // checking that clang emits PACKSSDW instead of PACKSSWB.
 
Index: lib/Headers/xmmintrin.h
===
--- lib/Headers/xmmintrin.h
+++ lib/Headers/xmmintrin.h
@@ -2821,9 +2821,7 @@
 }
 
 
-#ifdef _MSC_VER
-#define _MM_ALIGN16 __declspec(align(16))
-#endif
+#define _MM_ALIGN16 __attribute__((aligned(16)))
 
 #define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w))
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21113: Add support for case-insensitive header lookup

2016-06-09 Thread Hans Wennborg via cfe-commits
hans updated this revision to Diff 60220.
hans added a comment.

Adding the version that caches directory contents.

This has the problem the it doesn't play with modules, the rewriter, and 
possibly others, because they write to the file system without any way for the 
vfs to find out. I've tried to find a good way to fix that, but didn't come up 
with anything. One way would be to maintain a global counter like 
llvm::sys::fileSystemChangeCount which when changed would invalidate the maps, 
but I don't know if that would be acceptable.


http://reviews.llvm.org/D21113

Files:
  include/clang/Basic/VirtualFileSystem.h
  include/clang/Driver/Options.td
  include/clang/Lex/HeaderSearchOptions.h
  lib/Basic/VirtualFileSystem.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/cl-options.c
  test/Frontend/Inputs/case-insensitive-paths.h
  test/Frontend/case-insensitive-paths.c
  unittests/Basic/VirtualFileSystemTest.cpp

Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -107,8 +107,15 @@
 
   vfs::directory_iterator dir_begin(const Twine &Dir,
 std::error_code &EC) override {
-return vfs::directory_iterator(
+auto I = vfs::directory_iterator(
 std::make_shared(FilesAndDirs, Dir));
+
+// Even if there is no entry for /foo, /foo/bar may exist, so only set the
+// error code if /foo returns an empty iterator.
+if (I == vfs::directory_iterator())
+  EC = status(Dir).getError();
+
+return I;
   }
 
   void addEntry(StringRef Path, const vfs::Status &Status) {
@@ -1164,3 +1171,52 @@
   }
   EXPECT_EQ(I, E);
 }
+
+class CaseInsensitiveFileSystemTest : public ::testing::Test {
+private:
+  IntrusiveRefCntPtr Base;
+
+protected:
+  IntrusiveRefCntPtr FS;
+
+  CaseInsensitiveFileSystemTest()
+  : Base(new DummyFileSystem()),
+FS(new clang::vfs::CaseInsensitiveFileSystem(Base)) {
+Base->addRegularFile("/foo");
+Base->addDirectory("/bar");
+Base->addRegularFile("/bar/baz");
+  }
+};
+
+TEST_F(CaseInsensitiveFileSystemTest, Basic) {
+  // Not just accepting anything.
+  auto Status = FS->status("/F00");
+  ASSERT_EQ(llvm::errc::no_such_file_or_directory, Status.getError());
+
+  // Case-insensitive file is found.
+  Status = FS->status("/FoO");
+  ASSERT_FALSE(Status.getError());
+
+  // Case-insensitive dir works too.
+  Status = FS->status("/bAr/baZ");
+  ASSERT_FALSE(Status.getError());
+
+  // Test openFileForRead.
+  auto File = FS->openFileForRead("/F00");
+  ASSERT_EQ(llvm::errc::no_such_file_or_directory, File.getError());
+  File = FS->openFileForRead("/Foo");
+  ASSERT_FALSE(File.getError());
+  File = FS->openFileForRead("/Bar/Baz");
+  ASSERT_FALSE(File.getError());
+
+  // Test directory listing.
+  std::error_code EC;
+  auto Dir = FS->dir_begin("/b4r", EC);
+  ASSERT_EQ(llvm::errc::no_such_file_or_directory, EC);
+  Dir = FS->dir_begin("/bAr", EC);
+  ASSERT_FALSE(EC);
+  ASSERT_EQ("/bar/baz", Dir->getName());
+  Dir.increment(EC);
+  ASSERT_FALSE(EC);
+  ASSERT_EQ(vfs::directory_iterator(), Dir);
+}
Index: test/Frontend/case-insensitive-paths.c
===
--- /dev/null
+++ test/Frontend/case-insensitive-paths.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -fcase-insensitive-paths -verify %s
+// RUN: %clang_cc1 -fsyntax-only --show-includes -fcase-insensitive-paths %s | FileCheck %s
+
+#include "InpUts/CasE-InsensitivE-Paths.h" // expected-no-diagnostics
+
+// Make sure the real filename is used when printing header dependencies.
+// CHECK: including file: {{.*}}case-insensitive-paths.h
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -466,6 +466,7 @@
 // RUN: -mllvm -disable-llvm-optzns \
 // RUN: -Wunused-variable \
 // RUN: -fmacro-backtrace-limit=0 \
+// RUN: -fcase-insensitive-paths \
 // RUN: -Werror /Zs -- %s 2>&1
 
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1447,6 +1447,8 @@
 
   for (const Arg *A : Args.filtered(OPT_ivfsoverlay))
 Opts.AddVFSOverlayFile(A->getValue());
+
+  Opts.CaseInsensitive = Args.hasArg(OPT_fcase_insensitive_paths);
 }
 
 void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
@@ -2538,12 +2540,8 @@
   GraveYard[Idx] = Ptr;
 }
 
-IntrusiveRefCntPtr
-createVFSFromCompilerInvocation(const CompilerInvocation &CI,
-DiagnosticsEngine &Diags) {
-  if (CI.getHeaderSearchOpts().VFSOverlayFiles.empty())
-return vfs::getRealFileSystem();
-
+static IntrusiveRefCntPtr
+getOverlayFS(const CompilerInvocation &CI,

Fwd: Java Interface for clang

2016-06-09 Thread Maryam Mehraban via cfe-commits
Hello everybody,

I want to use clang and its facilities to parse c and c++ . but I need to
use it in java.
In my searches , saw jClang or Clang bindings for java, checking the date
of pages returned to me was before 2015.
so I know what is the status of jclang or is there any solution to use
clang and libraries in java.
thanks very much.
Mary.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20347: Add support to clang-cl driver for /GS switch

2016-06-09 Thread Nico Weber via cfe-commits
thakis added a comment.

probably at least the "the XOR with RSP/EBP/ESP" bit still (and maybe EH 
function upgrades instead of bailing)



Comment at: lib/Driver/Tools.cpp:9990
@@ +9989,3 @@
+   /*default=*/false))
+CmdArgs.push_back("/GS-");
+

To pass on /GS- to the fallback compiler when needed, I suppose.


http://reviews.llvm.org/D20347



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


Re: [PATCH] D19854: Define Contiki OS toolchain

2016-06-09 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

This needs a driver test.


http://reviews.llvm.org/D19854



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


Re: [PATCH] D21185: [clang-tidy] Add performance-emplace-into-containers

2016-06-09 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

See also http://reviews.llvm.org/D20964. I think modernize is better place for 
such check.


http://reviews.llvm.org/D21185



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


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

2016-06-09 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

There are alternative implementation in http://reviews.llvm.org/D21185. Will be 
good idea to how one which take the best from both :-)


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20933: Preallocate ExplodedNode hash table

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

> If the underlying allocator that does a poor job at reusing freed memory, 
> then trivial 

>  functions will use about 1 MB more than before, then free the memory 
> immediately.


You could probably flag some of those functions, especially the ones that do 
not contain inlinable calls. (Ex: Has low complexity (CFG::getNumBlockIDs()) 
and does not call anything that can be inlined.) Said that, it's "a nice to 
have".


http://reviews.llvm.org/D20933



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


Re: [PATCH] D21162: [CUDA] Implement __shfl* intrinsics in clang headers.

2016-06-09 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 60223.
jlebar marked 2 inline comments as done.
jlebar added a comment.

Update after tra's review.


http://reviews.llvm.org/D21162

Files:
  include/clang/Basic/BuiltinsNVPTX.def
  lib/Headers/__clang_cuda_intrinsics.h
  lib/Headers/__clang_cuda_runtime_wrapper.h

Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -198,13 +198,14 @@
 #include "sm_20_atomic_functions.hpp"
 #include "sm_20_intrinsics.hpp"
 #include "sm_32_atomic_functions.hpp"
-// sm_30_intrinsics.h has declarations that use default argument, so
-// we have to include it and it will in turn include .hpp
-#include "sm_30_intrinsics.h"
 
-// Don't include sm_32_intrinsics.h.  That header defines __ldg using inline
-// asm, but we want to define it using builtins, because we can't use the
-// [addr+imm] addressing mode if we use the inline asm in the header.
+// Don't include sm_30_intrinsics.h and sm_32_intrinsics.h.  These define the
+// __shfl and __ldg intrinsics using inline (volatile) asm, but we want to
+// define them using builtins so that the optimizer can reason about and across
+// these instructions.  In particular, using intrinsics for ldg gets us the
+// [addr+imm] addressing mode, which, although it doesn't actually exist in the
+// hardware, seems to generate faster machine code because ptxas can more easily
+// reason about our code.
 
 #undef __MATH_FUNCTIONS_HPP__
 
Index: lib/Headers/__clang_cuda_intrinsics.h
===
--- lib/Headers/__clang_cuda_intrinsics.h
+++ lib/Headers/__clang_cuda_intrinsics.h
@@ -26,6 +26,76 @@
 #error "This file is for CUDA compilation only."
 #endif
 
+// sm_30 intrinsics: __shfl_{up,down,xor}.
+
+#define __SM_30_INTRINSICS_H__
+#define __SM_30_INTRINSICS_HPP__
+
+#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300
+
+#pragma push_macro("__MAKE_SHUFFLES")
+#define __MAKE_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, __Mask)\
+  inline __device__ int __FnName(int __in, int __offset,   \
+ int __width = warpSize) { \
+return __IntIntrinsic(__in, __offset,  \
+  ((warpSize - __width) << 8) | (__Mask)); \
+  }\
+  inline __device__ float __FnName(float __in, int __offset,   \
+   int __width = warpSize) {   \
+return __FloatIntrinsic(__in, __offset,\
+((warpSize - __width) << 8) | (__Mask));   \
+  }\
+  inline __device__ unsigned int __FnName(unsigned int __in, int __offset, \
+  int __width = warpSize) {\
+return static_cast(  \
+::__FnName(static_cast(__in), __offset, __width));\
+  }\
+  inline __device__ long long __FnName(long long __in, int __offset,   \
+   int __width = warpSize) {   \
+struct __Bits {\
+  int __a, __b;\
+}; \
+_Static_assert(sizeof(__in) == sizeof(__Bits));\
+_Static_assert(sizeof(__Bits) == 2 * sizeof(int)); \
+__Bits __tmp;  \
+memcpy(&__in, &__tmp, sizeof(__in));   \
+__tmp.__a = ::__FnName(__tmp.__a, __offset, __width);  \
+__tmp.__b = ::__FnName(__tmp.__b, __offset, __width);  \
+long long __out;   \
+memcpy(&__out, &__tmp, sizeof(__tmp)); \
+return __out;  \
+  }\
+  inline __device__ unsigned long long __FnName(   \
+  unsigned long long __in, int __offset, int __width = warpSize) { \
+return static_cast(\
+::__FnName(static_cast(__in), __offset, __width)); \
+  }\
+  inline __device__ double __FnName(double __in,

Re: [PATCH] D21162: [CUDA] Implement __shfl* intrinsics in clang headers.

2016-06-09 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: lib/Headers/__clang_cuda_intrinsics.h:77-80
@@ +76,6 @@
+_Static_assert(sizeof(__tmp) == sizeof(__in)); 
\
+memcpy(&__tmp, &__in, sizeof(__in));   
\
+__tmp = ::__FnName(__tmp, __offset, __width);  
\
+double __out;  
\
+memcpy(&__out, &__tmp, sizeof(__out)); 
\
+return __out;  
\

tra wrote:
> Could we use a union instead?
I'm pretty sure using a union for this purpose is UB in C++.  "[9.5.1] In a 
union, at most one of the non-static data members can be active at any time, 
that is, the value of at most one of the non-static data members can be stored 
in a union at any time"  Although apparently it's fine in C11, 
http://stackoverflow.com/questions/25664848/unions-and-type-punning


Comment at: lib/Headers/__clang_cuda_intrinsics.h:87
@@ +86,3 @@
+__MAKE_SHUFFLES(__shfl_up, __builtin_ptx_shfl_up_i32, 
__builtin_ptx_shfl_up_f32,
+0);
+__MAKE_SHUFFLES(__shfl_down, __builtin_ptx_shfl_down_i32,

tra wrote:
> Ugh. Took me a while to figure out why 0 is used here.
> Unlike other variants shfl.up apparently applies to lanes >= maxLane. Who 
> would have thought.
> Might add a comment here so it's not mistaken for a typo.
Done, thanks.


http://reviews.llvm.org/D21162



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


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

2016-06-09 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D20498



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


Re: [PATCH] D20490: [Parser] Fix a crash on invalid where a delayed TypoExpr was corrected twice

2016-06-09 Thread Erik Pilkington via cfe-commits
erik.pilkington added a comment.

Pong!!


http://reviews.llvm.org/D20490



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


r272296 - [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr.

2016-06-09 Thread Tim Shen via cfe-commits
Author: timshen
Date: Thu Jun  9 14:54:46 2016
New Revision: 272296

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

These ExprWithCleanups are added for holding a RunCleanupsScope not
for destructor calls; rather, they are for lifetime marks. This requires
ExprWithCleanups to keep a bit to indicate whether it have cleanups with
side effects (e.g. dtor calls).

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

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

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=272296&r1=272295&r2=272296&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Thu Jun  9 14:54:46 2016
@@ -2877,7 +2877,8 @@ private:
   Stmt *SubExpr;
 
   ExprWithCleanups(EmptyShell, unsigned NumObjects);
-  ExprWithCleanups(Expr *SubExpr, ArrayRef Objects);
+  ExprWithCleanups(Expr *SubExpr, bool CleanupsHaveSideEffects,
+   ArrayRef Objects);
 
   friend TrailingObjects;
   friend class ASTStmtReader;
@@ -2887,6 +2888,7 @@ public:
   unsigned numObjects);
 
   static ExprWithCleanups *Create(const ASTContext &C, Expr *subexpr,
+  bool CleanupsHaveSideEffects,
   ArrayRef objects);
 
   ArrayRef getObjects() const {
@@ -2903,6 +2905,9 @@ public:
 
   Expr *getSubExpr() { return cast(SubExpr); }
   const Expr *getSubExpr() const { return cast(SubExpr); }
+  bool cleanupsHaveSideEffects() const {
+return ExprWithCleanupsBits.CleanupsHaveSideEffects;
+  }
 
   /// As with any mutator of the AST, be very careful
   /// when modifying an existing AST to preserve its invariants.

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

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

Re: [PATCH] D20389: NVPTX: Add supported CL features

2016-06-09 Thread Jan Vesely via cfe-commits
jvesely updated this revision to Diff 60226.
jvesely added a comment.

Test all known extensions against expected nvptx outcome (add negative tests)


Repository:
  rL LLVM

http://reviews.llvm.org/D20389

Files:
  lib/Basic/Targets.cpp
  test/Misc/nvptx.languageOptsOpenCL.cl

Index: test/Misc/nvptx.languageOptsOpenCL.cl
===
--- /dev/null
+++ test/Misc/nvptx.languageOptsOpenCL.cl
@@ -0,0 +1,210 @@
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple nvptx-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple nvptx-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple nvptx-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple nvptx-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple nvptx-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple nvptx-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple nvptx-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple nvptx-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple nvptx64-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple nvptx64-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple nvptx64-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple nvptx64-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple nvptx64-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple nvptx64-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple nvptx64-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple nvptx64-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+
+// Extensions in all versions
+#ifndef cl_clang_storage_class_specifiers
+#error "Missing cl_clang_storage_class_specifiers define"
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+
+#ifdef cl_khr_fp16
+#error "Incorrect cl_khr_fp16 define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_fp16: enable
+// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_fp16' - ignoring}}
+
+#ifdef cl_khr_int64_base_atomics
+#error "Incorrect cl_khr_int64_base_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_base_atomics: enable
+// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_int64_base_atomics' - ignoring}}
+
+#ifdef cl_khr_int64_extended_atomics
+#error "Incorrect cl_khr_int64_extended_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics: enable
+// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_int64_extended_atomics' - ignoring}}
+
+#ifndef cl_khr_gl_sharing
+#error "Missing cl_khr_gl_sharing define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_gl_sharing: enable
+
+#ifndef cl_khr_icd
+#error "Missing cl_khr_icd define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_icd: enable
+
+// Core features in CL 1.1
+
+#ifndef cl_khr_byte_addressable_store
+#error "Missing cl_khr_byte_addressable_store define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_byte_addressable_store: enable
+#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
+// expected-warning@-2{{OpenCL extension 'cl_khr_byte_addressable_store' is core feature or supported optional core feature - ignoring}}
+#endif
+
+#ifndef cl_khr_global_int32_base_atomics
+#error "Missing cl_khr_global_int32_base_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics: enable
+#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
+// expected-warning@-2{{OpenCL extension 'cl_khr_global_int32_base_atomics' is core feature or supported optional core feature - ignoring}}
+#endif
+
+#ifndef cl_khr_global_int32_extended_atomics
+#error "Missing cl_khr_global_int32_extended_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics: enable
+#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
+// expected-warning@-2{{OpenCL extension 'cl_khr_global_int32_extended_atomics' is core feature or supported optional core feature - ignoring}}
+#endif
+
+#ifndef cl_khr_local_int32_base_atomics
+#error "Missing cl_khr_local_int32_base_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics: enable
+#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES
+// expected-warning@-2{{OpenCL extension 'cl_khr_local_int32_base_atomics' is core feature or supported optional core feature - ignoring}}
+#endif
+
+#ifndef cl_khr_local_int32_extended_atomics
+#error "Missing cl_khr_local_int32_extended_atomics de

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

2016-06-09 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272296: [Temporary] Add an ExprWithCleanups for each C++ 
MaterializeTemporaryExpr. (authored by timshen).

Changed prior to commit:
  http://reviews.llvm.org/D20498?vs=58694&id=60227#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20498

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

Index: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp
@@ -764,6 +764,12 @@
 return Visit(DIE->getExpr());
   }
 
+  llvm::Constant *VisitExprWithCleanups(ExprWithCleanups *E) {
+if (!E->cleanupsHaveSideEffects())
+  return Visit(E->getSubExpr());
+return nullptr;
+  }
+
   llvm::Constant *VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
 return Visit(E->GetTemporaryExpr());
   }
Index: cfe/trunk/lib/AST/ExprCXX.cpp
===
--- cfe/trunk/lib/AST/ExprCXX.cpp
+++ cfe/trunk/lib/AST/ExprCXX.cpp
@@ -1039,23 +1039,27 @@
 }
 
 ExprWithCleanups::ExprWithCleanups(Expr *subexpr,
+   bool CleanupsHaveSideEffects,
ArrayRef objects)
   : Expr(ExprWithCleanupsClass, subexpr->getType(),
  subexpr->getValueKind(), subexpr->getObjectKind(),
  subexpr->isTypeDependent(), subexpr->isValueDependent(),
  subexpr->isInstantiationDependent(),
  subexpr->containsUnexpandedParameterPack()),
 SubExpr(subexpr) {
+  ExprWithCleanupsBits.CleanupsHaveSideEffects = CleanupsHaveSideEffects;
   ExprWithCleanupsBits.NumObjects = objects.size();
   for (unsigned i = 0, e = objects.size(); i != e; ++i)
 getTrailingObjects()[i] = objects[i];
 }
 
 ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C, Expr *subexpr,
+   bool CleanupsHaveSideEffects,
ArrayRef objects) {
   void *buffer = C.Allocate(totalSizeToAlloc(objects.size()),
 llvm::alignOf());
-  return new (buffer) ExprWithCleanups(subexpr, objects);
+  return new (buffer)
+  ExprWithCleanups(subexpr, CleanupsHaveSideEffects, objects);
 }
 
 ExprWithCleanups::ExprWithCleanups(EmptyShell empty, unsigned numObjects)
Index: cfe/trunk/lib/AST/Expr.cpp
===
--- cfe/trunk/lib/AST/Expr.cpp
+++ cfe/trunk/lib/AST/Expr.cpp
@@ -2890,7 +2890,6 @@
   case CXXThrowExprClass:
   case CXXNewExprClass:
   case CXXDeleteExprClass:
-  case ExprWithCleanupsClass:
   case CoawaitExprClass:
   case CoyieldExprClass:
 // These always have a side-effect.
@@ -2903,6 +2902,12 @@
 return Finder.hasSideEffects();
   }
 
+  case ExprWithCleanupsClass:
+if (IncludePossibleEffects)
+  if (cast(this)->cleanupsHaveSideEffects())
+return true;
+break;
+
   case ParenExprClass:
   case ArraySubscriptExprClass:
   case OMPArraySectionExprClass:
Index: cfe/trunk/lib/Sema/SemaStmt.cpp
===
--- cfe/trunk/lib/Sema/SemaStmt.cpp
+++ cfe/trunk/lib/Sema/SemaStmt.cpp
@@ -1518,6 +1518,10 @@
   // variables Increment and DRE.
   bool ProcessIterationStmt(Sema &S, Stmt* Statement, bool &Increment,
 DeclRefExpr *&DRE) {
+if (auto Cleanups = dyn_cast(Statement))
+  if (!Cleanups->cleanupsHaveSideEffects())
+Statement = Cleanups->getSubExpr();
+
 if (UnaryOperator *UO = dyn_cast(Statement)) {
   switch (UO->getOpcode()) {
 default: return false;
@@ -2472,6 +2476,10 @@
 
   QualType VariableType = VD->getType();
 
+  if (auto Cleanups = dyn_cast(InitExpr))
+if (!Cleanups->cleanupsHaveSideEffects())
+  InitExpr = Cleanups->getSubExpr();
+
   const MaterializeTemporaryExpr *MTE =
   dyn_cast(InitExpr);
 
Index: cfe/trunk/lib/Sema/SemaLambda.cpp
===
--- cfe/trunk/lib/Sema/SemaLambda

Re: [PATCH] D20389: NVPTX: Add supported CL features

2016-06-09 Thread Jan Vesely via cfe-commits
jvesely marked 2 inline comments as done.
jvesely added a comment.

Repository:
  rL LLVM

http://reviews.llvm.org/D20389



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


r272299 - [CUDA] Implement __shfl* intrinsics in clang headers.

2016-06-09 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jun  9 15:04:57 2016
New Revision: 272299

URL: http://llvm.org/viewvc/llvm-project?rev=272299&view=rev
Log:
[CUDA] Implement __shfl* intrinsics in clang headers.

Summary: Clang changes to make use of the LLVM intrinsics added in D21160.

Reviewers: tra

Subscribers: jholewinski, cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=272299&r1=272298&r2=272299&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Thu Jun  9 15:04:57 2016
@@ -402,6 +402,17 @@ BUILTIN(__nvvm_bar0_popc, "ii", "")
 BUILTIN(__nvvm_bar0_and, "ii", "")
 BUILTIN(__nvvm_bar0_or, "ii", "")
 
+// Shuffle
+
+BUILTIN(__builtin_ptx_shfl_down_i32, "", "")
+BUILTIN(__builtin_ptx_shfl_down_f32, "ffii", "")
+BUILTIN(__builtin_ptx_shfl_up_i32, "", "")
+BUILTIN(__builtin_ptx_shfl_up_f32, "ffii", "")
+BUILTIN(__builtin_ptx_shfl_bfly_i32, "", "")
+BUILTIN(__builtin_ptx_shfl_bfly_f32, "ffii", "")
+BUILTIN(__builtin_ptx_shfl_idx_i32, "", "")
+BUILTIN(__builtin_ptx_shfl_idx_f32, "ffii", "")
+
 // Membar
 
 BUILTIN(__nvvm_membar_cta, "v", "")

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=272299&r1=272298&r2=272299&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Thu Jun  9 15:04:57 2016
@@ -26,6 +26,76 @@
 #error "This file is for CUDA compilation only."
 #endif
 
+// sm_30 intrinsics: __shfl_{up,down,xor}.
+
+#define __SM_30_INTRINSICS_H__
+#define __SM_30_INTRINSICS_HPP__
+
+#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300
+
+#pragma push_macro("__MAKE_SHUFFLES")
+#define __MAKE_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, __Mask)
\
+  inline __device__ int __FnName(int __in, int __offset,   
\
+ int __width = warpSize) { 
\
+return __IntIntrinsic(__in, __offset,  
\
+  ((warpSize - __width) << 8) | (__Mask)); 
\
+  }
\
+  inline __device__ float __FnName(float __in, int __offset,   
\
+   int __width = warpSize) {   
\
+return __FloatIntrinsic(__in, __offset,
\
+((warpSize - __width) << 8) | (__Mask));   
\
+  }
\
+  inline __device__ unsigned int __FnName(unsigned int __in, int __offset, 
\
+  int __width = warpSize) {
\
+return static_cast(  
\
+::__FnName(static_cast(__in), __offset, __width));
\
+  }
\
+  inline __device__ long long __FnName(long long __in, int __offset,   
\
+   int __width = warpSize) {   
\
+struct __Bits {
\
+  int __a, __b;
\
+}; 
\
+_Static_assert(sizeof(__in) == sizeof(__Bits));
\
+_Static_assert(sizeof(__Bits) == 2 * sizeof(int)); 
\
+__Bits __tmp;  
\
+memcpy(&__in, &__tmp, sizeof(__in));   
\
+__tmp.__a = ::__FnName(__tmp.__a, __offset, __width);  
\
+__tmp.__b = ::__FnName(__tmp.__b, __offset, __width);  
\
+long long __out;   
\
+memcpy(&__out, &__tmp, sizeof(__tmp)); 
\
+return __out;  
\
+  }
\
+  inline __device__ unsigned long long __FnName(   
\
+  unsigned long long __in, int __offset, int __width = warpSize) { 
\
+return static_cast(  

Re: [PATCH] D21162: [CUDA] Implement __shfl* intrinsics in clang headers.

2016-06-09 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272299: [CUDA] Implement __shfl* intrinsics in clang 
headers. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D21162?vs=60223&id=60230#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21162

Files:
  cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
  cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
  cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
@@ -402,6 +402,17 @@
 BUILTIN(__nvvm_bar0_and, "ii", "")
 BUILTIN(__nvvm_bar0_or, "ii", "")
 
+// Shuffle
+
+BUILTIN(__builtin_ptx_shfl_down_i32, "", "")
+BUILTIN(__builtin_ptx_shfl_down_f32, "ffii", "")
+BUILTIN(__builtin_ptx_shfl_up_i32, "", "")
+BUILTIN(__builtin_ptx_shfl_up_f32, "ffii", "")
+BUILTIN(__builtin_ptx_shfl_bfly_i32, "", "")
+BUILTIN(__builtin_ptx_shfl_bfly_f32, "ffii", "")
+BUILTIN(__builtin_ptx_shfl_idx_i32, "", "")
+BUILTIN(__builtin_ptx_shfl_idx_f32, "ffii", "")
+
 // Membar
 
 BUILTIN(__nvvm_membar_cta, "v", "")
Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -198,13 +198,14 @@
 #include "sm_20_atomic_functions.hpp"
 #include "sm_20_intrinsics.hpp"
 #include "sm_32_atomic_functions.hpp"
-// sm_30_intrinsics.h has declarations that use default argument, so
-// we have to include it and it will in turn include .hpp
-#include "sm_30_intrinsics.h"
-
-// Don't include sm_32_intrinsics.h.  That header defines __ldg using inline
-// asm, but we want to define it using builtins, because we can't use the
-// [addr+imm] addressing mode if we use the inline asm in the header.
+
+// Don't include sm_30_intrinsics.h and sm_32_intrinsics.h.  These define the
+// __shfl and __ldg intrinsics using inline (volatile) asm, but we want to
+// define them using builtins so that the optimizer can reason about and across
+// these instructions.  In particular, using intrinsics for ldg gets us the
+// [addr+imm] addressing mode, which, although it doesn't actually exist in the
+// hardware, seems to generate faster machine code because ptxas can more easily
+// reason about our code.
 
 #undef __MATH_FUNCTIONS_HPP__
 
Index: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
@@ -26,6 +26,76 @@
 #error "This file is for CUDA compilation only."
 #endif
 
+// sm_30 intrinsics: __shfl_{up,down,xor}.
+
+#define __SM_30_INTRINSICS_H__
+#define __SM_30_INTRINSICS_HPP__
+
+#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300
+
+#pragma push_macro("__MAKE_SHUFFLES")
+#define __MAKE_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, __Mask)\
+  inline __device__ int __FnName(int __in, int __offset,   \
+ int __width = warpSize) { \
+return __IntIntrinsic(__in, __offset,  \
+  ((warpSize - __width) << 8) | (__Mask)); \
+  }\
+  inline __device__ float __FnName(float __in, int __offset,   \
+   int __width = warpSize) {   \
+return __FloatIntrinsic(__in, __offset,\
+((warpSize - __width) << 8) | (__Mask));   \
+  }\
+  inline __device__ unsigned int __FnName(unsigned int __in, int __offset, \
+  int __width = warpSize) {\
+return static_cast(  \
+::__FnName(static_cast(__in), __offset, __width));\
+  }\
+  inline __device__ long long __FnName(long long __in, int __offset,   \
+   int __width = warpSize) {   \
+struct __Bits {\
+  int __a, __b;\
+}; \
+_Static_assert(sizeof(__in) == sizeof(__Bits));\
+_Static_assert(sizeof(__Bits) == 2 * sizeof(int)); \
+__Bits __tmp;

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

2016-06-09 Thread Vedant Kumar via cfe-commits
vsk added a subscriber: vsk.
vsk added a comment.

@Eugene.Zelenko thanks for pointing this out, I had totally missed this patch! 
Once we get this reviewed I'm willing to abandon my version. Some comments 
inline --



Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:26
@@ +25,3 @@
+  // + add handling of `push` for std::stack, std::queue, std::priority_queue
+  // + add handling of `insert` for stl associative container, but be cerfull
+  // because this requires special treatment (it could cause performance

cerfull -> careful


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:37
@@ +36,3 @@
+
+  // We can't replace push_backs of smart pointer becase
+  // if emplacement will fail (f.e. bad_alloc in vector) we will have leak of

becase -> because


Comment at: test/clang-tidy/modernize-use-emplace.cpp:147
@@ +146,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+  v.push_back(S   {1, 2});

I don't think this is correct. Comments immediately before/after `S` or 
immediately before/after the second right parenthesis should be preserved. C.f 
the implementation in D21185.


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20933: Preallocate ExplodedNode hash table

2016-06-09 Thread Ben Craig via cfe-commits
bcraig updated this revision to Diff 60177.
bcraig added a comment.

Capping the pre-reserve space


http://reviews.llvm.org/D20933

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
  lib/StaticAnalyzer/Core/CoreEngine.cpp

Index: lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -208,6 +208,9 @@
 
   // Check if we have a steps limit
   bool UnlimitedSteps = Steps == 0;
+  const unsigned PreReservationCap = 400;
+  if(!UnlimitedSteps)
+G.reserve(std::min(Steps,PreReservationCap));
 
   while (WList->hasWork()) {
 if (!UnlimitedSteps) {
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
@@ -321,6 +321,8 @@
   bool empty() const { return NumNodes == 0; }
   unsigned size() const { return NumNodes; }
 
+  void reserve(unsigned NodeCount) { Nodes.reserve(NodeCount); }
+
   // Iterators.
   typedef ExplodedNodeNodeTy;
   typedef llvm::FoldingSet  AllNodesTy;


Index: lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -208,6 +208,9 @@
 
   // Check if we have a steps limit
   bool UnlimitedSteps = Steps == 0;
+  const unsigned PreReservationCap = 400;
+  if(!UnlimitedSteps)
+G.reserve(std::min(Steps,PreReservationCap));
 
   while (WList->hasWork()) {
 if (!UnlimitedSteps) {
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
@@ -321,6 +321,8 @@
   bool empty() const { return NumNodes == 0; }
   unsigned size() const { return NumNodes; }
 
+  void reserve(unsigned NodeCount) { Nodes.reserve(NodeCount); }
+
   // Iterators.
   typedef ExplodedNodeNodeTy;
   typedef llvm::FoldingSet  AllNodesTy;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20933: Preallocate ExplodedNode hash table

2016-06-09 Thread Ben Craig via cfe-commits
bcraig added a comment.

I got better valgrind numbers (symbols are important).
Before: 106,131,538
After: 106,657,666
Diff: 526,128 larger.

Note that this is sampled peaks for heap usage.  They may not be accurate.  
Regardless, the peak usage increased by less than .5%.


http://reviews.llvm.org/D20933



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


Re: [PATCH] D20490: [Parser] Fix a crash on invalid where a delayed TypoExpr was corrected twice

2016-06-09 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Parse/ParseExpr.cpp:450-452
@@ -449,1 +449,5 @@
+
+// In this case, ActOnBinOp performed the CorrectDelayedTyposInExpr 
check.
+if (!getLangOpts().CPlusPlus)
+  continue;
   } else {

The inconsistent behavior of `ActOnBinOp` seems somewhere between an 
implementation detail and a bug; it doesn't seem reasonable for the parser to 
rely on that. I'm not particularly happy about making changes like this without 
some documentation of the overall design that shows whose responsibility it is 
to correct typos in which cases.


Before we introduced `TypoExpr`, the parser was permitted to simply discard 
`Expr` nodes that it didn't use (because it'd hit a parse error). Ideally, I'd 
like to return to that state of affairs, by removing the relevant 
`CorrectDelayedTyposInExpr` calls from the parser and having Sema automatically 
diagnose them when we get to the end of the relevant context, if we've not 
already done so.

Another reasonable-seeming option would be to add a 
`Sema::ActOnDiscardedExpr(Expr*)` that the parser can call (which calls 
`CorrectDelayedTyposInExpr`), and make it clear that the parser is responsible 
for passing each Expr that it receives from Sema to exactly one ActOn* function 
(unless otherwise specified) -- that way, at least the responsibilities will be 
clear, but it doesn't help us avoid bugs where `TypoExpr`s are accidentally 
discarded.


http://reviews.llvm.org/D20490



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


Re: [PATCH] D21187: Allow use of lambda expressions in array bounds

2016-06-09 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.


Comment at: lib/Sema/SemaExpr.cpp:12825
@@ -12824,1 +12824,3 @@
+  // BlockContext.
+  } else if (!Rec.IsArrayBound) {
 // C++1y [expr.const]p2:

This isn't correct; you still need to produce the diagnostic even if we're in 
an array bound, but it should be an `ExtWarn` controlled by `-Wvla`. A case like

void f() {
  int arr[ true ? 1 : []{return 0}() ];
}

is ill-formed in standard C++, but as we can evaluate the array bound as a 
constant, Clang will no longer diagnose it with this change in place.


Comment at: lib/Sema/SemaExpr.cpp:12834-12839
@@ -12832,8 +12833,8 @@
 } else {
   // Mark the capture expressions odr-used. This was deferred
   // during lambda expression creation.
   for (auto *Lambda : Rec.Lambdas) {
 for (auto *C : Lambda->capture_inits())
   MarkDeclarationsReferencedInExpr(C);
   }
 }

If you accept lambdas inside VLA bounds, you need to do this step for them.


Comment at: lib/Sema/SemaExpr.cpp:12848-12853
@@ -12846,8 +12847,8 @@
   if (Rec.isUnevaluated() || Rec.Context == ConstantEvaluated) {
 ExprCleanupObjects.erase(ExprCleanupObjects.begin() + 
Rec.NumCleanupObjects,
  ExprCleanupObjects.end());
 ExprNeedsCleanups = Rec.ParentNeedsCleanups;
 CleanupVarDeclMarking();
 std::swap(MaybeODRUseExprs, Rec.SavedMaybeODRUseExprs);
   // Otherwise, merge the contexts together.
   } else {

This also looks wrong for your lambda-in-VLA-bound case.

Perhaps the best thing to do is to check whether we have a VLA *before* we pop 
the ExpressionEvaluationContextRecord, and if so, convert the context from 
ConstantEvaluated to Evaluated.


http://reviews.llvm.org/D21187



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


Re: [PATCH] D20821: Fix a few issues while skipping function bodies

2016-06-09 Thread Richard Smith via cfe-commits
rsmith added a comment.

Please call `Parser::ConsumeAndStoreFunctionPrologue` rather than trying to 
reinvent it. You're still getting a number of cases wrong that it handles 
properly.

You also need to handle the case where the code completion token appears within 
the constructor *mem-initializer*s.


http://reviews.llvm.org/D20821



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


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

2016-06-09 Thread Eric Niebler via cfe-commits
eric_niebler added a comment.

> Before this goes in again, I want to double check that this doesn't affect 
> compile time on darwin + frameworks.


@bruno, you're not likely to find a difference for darwin + frameworks since 
the frameworks headers like `Cocoa/Cocoa.h` don't exist on-disk with that path 
-- at least not on my machine. As a result, the attempt to get the "real path 
name" fails and no diagnostic is issued; the code path you want to measure will 
never be hit. This appears to be a shortcoming of the way I'm trying to get the 
true case of the files as they are opened. Correctly handing this would greatly 
increase the complexity of the patch. Apple == :-(


http://reviews.llvm.org/D19843



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


Re: [PATCH] D20338: [PCH] Fixed overridden files always invalidating preamble even when unchanged

2016-06-09 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Basic/FileManager.cpp:389
@@ -383,2 +388,3 @@
   UFE->File.reset();
+  UFE->IsVirtual = true;
   return UFE;

Yes. The `IsValid` flag is just supposed to mean that this file has actually 
been added to the `UniqueRealFiles` map rather than having been 
default-constructed by `operator[]`.


http://reviews.llvm.org/D20338



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


Re: [PATCH] D21054: CodeGen: Update Clang to use the new type metadata.

2016-06-09 Thread Evgeniy Stepanov via cfe-commits
eugenis accepted this revision.
eugenis added a reviewer: eugenis.
eugenis added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D21054



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


r272310 - Revert "[Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr."

2016-06-09 Thread Tim Shen via cfe-commits
Author: timshen
Date: Thu Jun  9 16:13:39 2016
New Revision: 272310

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

This reverts r272296, since there are clang-tidy failures that appear to
be caused by this change.

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

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=272310&r1=272309&r2=272310&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Thu Jun  9 16:13:39 2016
@@ -2877,8 +2877,7 @@ private:
   Stmt *SubExpr;
 
   ExprWithCleanups(EmptyShell, unsigned NumObjects);
-  ExprWithCleanups(Expr *SubExpr, bool CleanupsHaveSideEffects,
-   ArrayRef Objects);
+  ExprWithCleanups(Expr *SubExpr, ArrayRef Objects);
 
   friend TrailingObjects;
   friend class ASTStmtReader;
@@ -2888,7 +2887,6 @@ public:
   unsigned numObjects);
 
   static ExprWithCleanups *Create(const ASTContext &C, Expr *subexpr,
-  bool CleanupsHaveSideEffects,
   ArrayRef objects);
 
   ArrayRef getObjects() const {
@@ -2905,9 +2903,6 @@ public:
 
   Expr *getSubExpr() { return cast(SubExpr); }
   const Expr *getSubExpr() const { return cast(SubExpr); }
-  bool cleanupsHaveSideEffects() const {
-return ExprWithCleanupsBits.CleanupsHaveSideEffects;
-  }
 
   /// As with any mutator of the AST, be very careful
   /// when modifying an existing AST to preserve its invariants.

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

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

[PATCH] D21198: Add a RenderScript language type

2016-06-09 Thread Pirama Arumuga Nainar via cfe-commits
pirama created this revision.
pirama added a reviewer: rsmith.
pirama added subscribers: srhines, cfe-commits.

Add RenderScript language type and associate it with ".rs" extensions.
Test that the driver passes "-x renderscript" to the frontend for ".rs"
files.

(Also add '.rs' to the list of suffixes tested by lit).

http://reviews.llvm.org/D21198

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/LangOptions.def
  include/clang/Frontend/FrontendOptions.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/fp16-ops.c
  test/Sema/renderscript.rs

Index: test/Sema/renderscript.rs
===
--- /dev/null
+++ test/Sema/renderscript.rs
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -x renderscript -D__RENDERSCRIPT__ %s
+// RUN: %clang_cc1 -fsyntax-only -verify -x c %s
+
+#ifndef __RENDERSCRIPT__
+// expected-warning@+2 {{kernel attribute ignored}}
+#endif
+void __attribute__((kernel)) kernel();
+
+// expected-warning@+1 {{'kernel' attribute only applies to functions}}
+int __attribute__((kernel)) global;
+
+#ifndef __RENDERSCRIPT__
+// expected-error@+2 {{function return value cannot have __fp16 type; did you forget * ?}}
+#endif
+__fp16 fp16_return();
+
+#ifndef __RENDERSCRIPT__
+// expected-error@+2 {{parameters cannot have __fp16 type; did you forget * ?}}
+#endif
+void fp16_arg(__fp16 p);
Index: test/CodeGen/fp16-ops.c
===
--- test/CodeGen/fp16-ops.c
+++ test/CodeGen/fp16-ops.c
@@ -7,6 +7,8 @@
 // RUN:   | FileCheck %s --check-prefix=NATIVE-HALF
 // RUN: %clang_cc1 -emit-llvm -o - -triple aarch64-none-linux-gnueabi -fnative-half-type %s \
 // RUN:   | FileCheck %s --check-prefix=NATIVE-HALF
+// RUN: %clang_cc1 -emit-llvm -o - -x renderscript %s \
+// RUN:   | FileCheck %s --check-prefix=NATIVE-HALF
 typedef unsigned cond_t;
 
 volatile cond_t test;
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4185,6 +4185,17 @@
 Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleKernelAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  if (S.LangOpts.RenderScript) {
+D->addAttr(::new (S.Context)
+   KernelAttr(Attr.getRange(), S.Context,
+  Attr.getAttributeSpellingListIndex()));
+  } else {
+S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << "kernel";
+  }
+}
+
+
 //===--===//
 // Checker-specific attribute handlers.
 //===--===//
@@ -5914,6 +5925,10 @@
   case AttributeList::AT_TypeTagForDatatype:
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
+
+  case AttributeList::AT_Kernel:
+handleKernelAttr(S, D, Attr);
+break;
   }
 }
 
Index: lib/Frontend/FrontendActions.cpp
===
--- lib/Frontend/FrontendActions.cpp
+++ lib/Frontend/FrontendActions.cpp
@@ -735,6 +735,7 @@
   case IK_PreprocessedObjCXX:
   case IK_AST:
   case IK_LLVM_IR:
+  case IK_RenderScript:
 // We can't do anything with these.
 return;
   }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1292,6 +1292,7 @@
   .Case("objective-c++-header", IK_ObjCXX)
   .Cases("ast", "pcm", IK_AST)
   .Case("ir", IK_LLVM_IR)
+  .Case("renderscript", IK_RenderScript)
   .Default(IK_None);
 if (DashX == IK_None)
   Diags.Report(diag::err_drv_invalid_value)
@@ -1495,6 +1496,9 @@
 case IK_PreprocessedObjCXX:
   LangStd = LangStandard::lang_gnucxx98;
   break;
+case IK_RenderScript:
+  LangStd = LangStandard::lang_c99;
+  break;
 }
   }
 
@@ -1537,6 +1541,12 @@
   Opts.CUDA = IK == IK_CUDA || IK == IK_PreprocessedCuda ||
   LangStd == LangStandard::lang_cuda;
 
+  Opts.RenderScript = IK == IK_RenderScript;
+  if (Opts.RenderScript) {
+Opts.NativeHalfType = 1;
+Opts.NativeHalfArgsAndReturns = 1;
+  }
+
   // OpenCL and C++ both have bool, true, false keywords.
   Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;
 
Index: include/clang/Frontend/FrontendOptions.h
===
--- include/clang/Frontend/FrontendOptions.h
+++ include/clang/Frontend/FrontendOptions.h
@@ -75,7 +75,8 @@
   IK_CUDA,
   IK_PreprocessedCuda,
   IK_AST,
-  IK_LLVM_IR
+  IK_LLVM_IR,
+  IK_RenderScript
 };
 
   
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -1

[PATCH] D21199: Add a RenderScript language type

2016-06-09 Thread Pirama Arumuga Nainar via cfe-commits
pirama created this revision.
pirama added a reviewer: rsmith.
pirama added subscribers: srhines, cfe-commits.

Add RenderScript language type and associate it with ".rs" extensions.
Test that the driver passes "-x renderscript" to the frontend for ".rs"
files.

(Also add '.rs' to the list of suffixes tested by lit).

http://reviews.llvm.org/D21199

Files:
  include/clang/Driver/Types.def
  lib/Driver/Types.cpp
  test/Driver/lit.local.cfg
  test/Driver/renderscript.rs
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -44,7 +44,7 @@
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', 
'.modulemap', '.test']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', 
'.modulemap', '.test', '.rs']
 
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
 # subdirectories contain auxiliary inputs for various tests in their parent
Index: test/Driver/renderscript.rs
===
--- /dev/null
+++ test/Driver/renderscript.rs
@@ -0,0 +1,3 @@
+// RUN: %clang -### 2>&1 %s | FileCheck %s
+
+// CHECK: "-x" "renderscript"
Index: test/Driver/lit.local.cfg
===
--- test/Driver/lit.local.cfg
+++ test/Driver/lit.local.cfg
@@ -1,5 +1,5 @@
 config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', '.f95',
-   '.cu']
+   '.cu', '.rs']
 config.substitutions = list(config.substitutions)
 config.substitutions.insert(0,
 ('%clang_cc1',
Index: lib/Driver/Types.cpp
===
--- lib/Driver/Types.cpp
+++ lib/Driver/Types.cpp
@@ -204,6 +204,7 @@
.Case("pcm", TY_ModuleFile)
.Case("pch", TY_PCH)
.Case("gch", TY_PCH)
+   .Case("rs", TY_RenderScript)
.Default(TY_INVALID);
 }
 
Index: include/clang/Driver/Types.def
===
--- include/clang/Driver/Types.def
+++ include/clang/Driver/Types.def
@@ -53,6 +53,7 @@
 TYPE("objective-c++-cpp-output", PP_ObjCXX,INVALID, "mii",   "u")
 TYPE("objc++-cpp-output",PP_ObjCXX_Alias, INVALID,  "mii",   "u")
 TYPE("objective-c++",ObjCXX,   PP_ObjCXX,   "mm","u")
+TYPE("renderscript", RenderScript, PP_C,"rs","u")
 
 // C family input files to precompile.
 TYPE("c-header-cpp-output",  PP_CHeader,   INVALID, "i", "p")


Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -44,7 +44,7 @@
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap', '.test']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs']
 
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
 # subdirectories contain auxiliary inputs for various tests in their parent
Index: test/Driver/renderscript.rs
===
--- /dev/null
+++ test/Driver/renderscript.rs
@@ -0,0 +1,3 @@
+// RUN: %clang -### 2>&1 %s | FileCheck %s
+
+// CHECK: "-x" "renderscript"
Index: test/Driver/lit.local.cfg
===
--- test/Driver/lit.local.cfg
+++ test/Driver/lit.local.cfg
@@ -1,5 +1,5 @@
 config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', '.f95',
-   '.cu']
+   '.cu', '.rs']
 config.substitutions = list(config.substitutions)
 config.substitutions.insert(0,
 ('%clang_cc1',
Index: lib/Driver/Types.cpp
===
--- lib/Driver/Types.cpp
+++ lib/Driver/Types.cpp
@@ -204,6 +204,7 @@
.Case("pcm", TY_ModuleFile)
.Case("pch", TY_PCH)
.Case("gch", TY_PCH)
+   .Case("rs", TY_RenderScript)
.Default(TY_INVALID);
 }
 
Index: include/clang/Driver/Types.def
===
--- include/clang/Driver/Types.def
+++ include/clang/Driver/Types.def
@@ -53,6 +53,7 @@
 TYPE("objective-c++-cpp-output", PP_ObjCXX,INVALID, "mii",   "u")
 TYPE("objc++-cpp-output",PP_ObjCXX_Alias, INVALID,  "mii",   "u")
 TYPE("objective-c++",ObjCXX,   PP_ObjCXX,   "mm","u")
+TYPE("renderscript", RenderScript, PP_C,"rs","u")
 
 // C family input files to precompile.
 TYPE("c-header-cpp-o

Re: [PATCH] D20933: Preallocate ExplodedNode hash table

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

LGTM. Thanks!


http://reviews.llvm.org/D20933



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


Re: [PATCH] D20933: Preallocate ExplodedNode hash table

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

Ah, right, please, add a comment explaining what we are doing and why.


http://reviews.llvm.org/D20933



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


r272312 - [CMake] Cleaning up CMake feature gating on 2.8.12

2016-06-09 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Thu Jun  9 16:29:55 2016
New Revision: 272312

URL: http://llvm.org/viewvc/llvm-project?rev=272312&view=rev
Log:
[CMake] Cleaning up CMake feature gating on 2.8.12

CMake 2.8.12 introduced interface libraries and some related policies. This 
removes the conditional block because we're now past 2.8.12.

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt
cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt
cfe/trunk/examples/analyzer-plugin/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=272312&r1=272311&r2=272312&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Thu Jun  9 16:29:55 2016
@@ -1,19 +1,5 @@
 cmake_minimum_required(VERSION 3.4.3)
 
-# FIXME: It may be removed when we use 2.8.12.
-if(CMAKE_VERSION VERSION_LESS 2.8.12)
-  # Invalidate a couple of keywords.
-  set(cmake_2_8_12_INTERFACE)
-  set(cmake_2_8_12_PRIVATE)
-else()
-  # Use ${cmake_2_8_12_KEYWORD} intead of KEYWORD in target_link_libraries().
-  set(cmake_2_8_12_INTERFACE INTERFACE)
-  set(cmake_2_8_12_PRIVATE PRIVATE)
-  if(POLICY CMP0022)
-cmake_policy(SET CMP0022 NEW) # automatic when 2.8.12 is required
-  endif()
-endif()
-
 # If we are not building as a part of LLVM, build Clang as an
 # standalone project, using LLVM as an external library:
 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
@@ -421,7 +407,7 @@ macro(add_clang_library name)
   llvm_add_library(${name} ${ARG_ENABLE_SHARED} ${ARG_UNPARSED_ARGUMENTS} 
${srcs})
 
   if(TARGET ${name})
-target_link_libraries(${name} ${cmake_2_8_12_INTERFACE} 
${LLVM_COMMON_LIBS})
+target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang")
   install(TARGETS ${name}

Modified: cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt?rev=272312&r1=272311&r2=272312&view=diff
==
--- cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt (original)
+++ cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt Thu Jun  9 16:29:55 2016
@@ -1,7 +1,7 @@
 add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
-  target_link_libraries(AnnotateFunctions ${cmake_2_8_12_PRIVATE}
+  target_link_libraries(AnnotateFunctions PRIVATE
 clangAST
 clangBasic
 clangFrontend

Modified: cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt?rev=272312&r1=272311&r2=272312&view=diff
==
--- cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt (original)
+++ cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt Thu Jun  9 16:29:55 
2016
@@ -12,7 +12,7 @@ endif()
 add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
-  target_link_libraries(PrintFunctionNames ${cmake_2_8_12_PRIVATE}
+  target_link_libraries(PrintFunctionNames PRIVATE
 clangAST
 clangBasic
 clangFrontend

Modified: cfe/trunk/examples/analyzer-plugin/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/analyzer-plugin/CMakeLists.txt?rev=272312&r1=272311&r2=272312&view=diff
==
--- cfe/trunk/examples/analyzer-plugin/CMakeLists.txt (original)
+++ cfe/trunk/examples/analyzer-plugin/CMakeLists.txt Thu Jun  9 16:29:55 2016
@@ -1,7 +1,7 @@
 add_llvm_loadable_module(SampleAnalyzerPlugin MainCallChecker.cpp)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
-  target_link_libraries(SampleAnalyzerPlugin ${cmake_2_8_12_PRIVATE}
+  target_link_libraries(SampleAnalyzerPlugin PRIVATE
 clangAnalysis
 clangAST
 clangStaticAnalyzerCore


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


[PATCH] D21204: clang-format: [JS] post-fix non-null assertion operator.

2016-06-09 Thread Martin Probst via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Do not insert whitespace preceding the "!" postfix operator. This is an
incomplete fix, but should cover common usage.

http://reviews.llvm.org/D21204

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

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1291,5 +1291,12 @@
"var x   =  hello();");
 }
 
+TEST_F(FormatTestJS, NonNullAssertionOperator) {
+  verifyFormat("let x = foo!.bar();\n");
+  verifyFormat("let x = foo ? bar! : baz;\n");
+  verifyFormat("let x = !foo;\n");
+  verifyFormat("let x = foo!;\n");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2123,6 +2123,10 @@
   // locations that should have whitespace following are identified by the
   // above set of follower tokens.
   return false;
+// Postfix non-null assertion operator, as in `foo!.bar()`.
+if (Right.is(tok::exclaim) && Right.Next &&
+Right.Next->isNot(tok::identifier) && !Right.Next->Tok.isLiteral())
+  return false;
   } else if (Style.Language == FormatStyle::LK_Java) {
 if (Left.is(tok::r_square) && Right.is(tok::l_brace))
   return true;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1291,5 +1291,12 @@
"var x   =  hello();");
 }
 
+TEST_F(FormatTestJS, NonNullAssertionOperator) {
+  verifyFormat("let x = foo!.bar();\n");
+  verifyFormat("let x = foo ? bar! : baz;\n");
+  verifyFormat("let x = !foo;\n");
+  verifyFormat("let x = foo!;\n");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2123,6 +2123,10 @@
   // locations that should have whitespace following are identified by the
   // above set of follower tokens.
   return false;
+// Postfix non-null assertion operator, as in `foo!.bar()`.
+if (Right.is(tok::exclaim) && Right.Next &&
+Right.Next->isNot(tok::identifier) && !Right.Next->Tok.isLiteral())
+  return false;
   } else if (Style.Language == FormatStyle::LK_Java) {
 if (Left.is(tok::r_square) && Right.is(tok::l_brace))
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


LLVM buildmaster will be restarted tonight

2016-06-09 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 6 PM Pacific time
today.

Thanks

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


Re: [PATCH] D21198: RenderScript support in the Frontend

2016-06-09 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Please make sure that any relevant parts of our documentation are also updated. 
Given how small and self-contained this is, that we have a reasonable 
expectation of good support and maintainership, and that it's a reasonably 
well-established language variant, I don't have any problem with it living in 
upstream clang.



Comment at: include/clang/Frontend/FrontendOptions.h:77-79
@@ -76,4 +76,5 @@
   IK_PreprocessedCuda,
   IK_AST,
-  IK_LLVM_IR
+  IK_LLVM_IR,
+  IK_RenderScript
 };

Please reorder this before `IK_AST`, so that we keep the source languages 
before the somewhat-more clang-internal things.


http://reviews.llvm.org/D21198



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


Re: [PATCH] D20338: [PCH] Fixed overridden files always invalidating preamble even when unchanged

2016-06-09 Thread Cameron via cfe-commits
cameron314 added inline comments.


Comment at: lib/Basic/FileManager.cpp:389
@@ -383,2 +388,3 @@
   UFE->File.reset();
+  UFE->IsVirtual = true;
   return UFE;

rsmith wrote:
> Yes. The `IsValid` flag is just supposed to mean that this file has actually 
> been added to the `UniqueRealFiles` map rather than having been 
> default-constructed by `operator[]`.
Excellent then, I'll get rid of `IsVirtual` and use `IsValid` in place. This 
will condense things down to a one-line change plus a large diff for the test ^^


http://reviews.llvm.org/D20338



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


Re: Does anyone need these zorg modules?

2016-06-09 Thread Galina Kistanova via cfe-commits
Hello,

Last call for the next builder modules:

ChrootSetup.py
DragonEggBuilder.py
KLEEBuilder.py
ScriptedBuilder.py
gccSuiteBuilder.py

I am going to remove them.
If anyone have plans for any of them please speak up!

Thanks

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


Re: [PATCH] D21198: RenderScript support in the Frontend

2016-06-09 Thread Pirama Arumuga Nainar via cfe-commits
pirama updated this revision to Diff 60247.
pirama updated the summary for this revision.
pirama added a comment.

Re-ordered enum


http://reviews.llvm.org/D21198

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Types.def
  include/clang/Frontend/FrontendOptions.h
  lib/Driver/Types.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/fp16-ops.c
  test/Driver/lit.local.cfg
  test/Driver/renderscript.rs
  test/Sema/renderscript.rs
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -44,7 +44,7 @@
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap', '.test']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs']
 
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
 # subdirectories contain auxiliary inputs for various tests in their parent
Index: test/Sema/renderscript.rs
===
--- /dev/null
+++ test/Sema/renderscript.rs
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -x renderscript -D__RENDERSCRIPT__ %s
+// RUN: %clang_cc1 -fsyntax-only -verify -x c %s
+
+#ifndef __RENDERSCRIPT__
+// expected-warning@+2 {{kernel attribute ignored}}
+#endif
+void __attribute__((kernel)) kernel();
+
+// expected-warning@+1 {{'kernel' attribute only applies to functions}}
+int __attribute__((kernel)) global;
+
+#ifndef __RENDERSCRIPT__
+// expected-error@+2 {{function return value cannot have __fp16 type; did you forget * ?}}
+#endif
+__fp16 fp16_return();
+
+#ifndef __RENDERSCRIPT__
+// expected-error@+2 {{parameters cannot have __fp16 type; did you forget * ?}}
+#endif
+void fp16_arg(__fp16 p);
Index: test/Driver/renderscript.rs
===
--- /dev/null
+++ test/Driver/renderscript.rs
@@ -0,0 +1,3 @@
+// RUN: %clang -### 2>&1 %s | FileCheck %s
+
+// CHECK: "-x" "renderscript"
Index: test/Driver/lit.local.cfg
===
--- test/Driver/lit.local.cfg
+++ test/Driver/lit.local.cfg
@@ -1,5 +1,5 @@
 config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', '.f95',
-   '.cu']
+   '.cu', '.rs']
 config.substitutions = list(config.substitutions)
 config.substitutions.insert(0,
 ('%clang_cc1',
Index: test/CodeGen/fp16-ops.c
===
--- test/CodeGen/fp16-ops.c
+++ test/CodeGen/fp16-ops.c
@@ -7,6 +7,8 @@
 // RUN:   | FileCheck %s --check-prefix=NATIVE-HALF
 // RUN: %clang_cc1 -emit-llvm -o - -triple aarch64-none-linux-gnueabi -fnative-half-type %s \
 // RUN:   | FileCheck %s --check-prefix=NATIVE-HALF
+// RUN: %clang_cc1 -emit-llvm -o - -x renderscript %s \
+// RUN:   | FileCheck %s --check-prefix=NATIVE-HALF
 typedef unsigned cond_t;
 
 volatile cond_t test;
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4185,6 +4185,17 @@
 Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleKernelAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  if (S.LangOpts.RenderScript) {
+D->addAttr(::new (S.Context)
+   KernelAttr(Attr.getRange(), S.Context,
+  Attr.getAttributeSpellingListIndex()));
+  } else {
+S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << "kernel";
+  }
+}
+
+
 //===--===//
 // Checker-specific attribute handlers.
 //===--===//
@@ -5914,6 +5925,10 @@
   case AttributeList::AT_TypeTagForDatatype:
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
+
+  case AttributeList::AT_Kernel:
+handleKernelAttr(S, D, Attr);
+break;
   }
 }
 
Index: lib/Frontend/FrontendActions.cpp
===
--- lib/Frontend/FrontendActions.cpp
+++ lib/Frontend/FrontendActions.cpp
@@ -735,6 +735,7 @@
   case IK_PreprocessedObjCXX:
   case IK_AST:
   case IK_LLVM_IR:
+  case IK_RenderScript:
 // We can't do anything with these.
 return;
   }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1292,6 +1292,7 @@
   .Case("objective-c++-header", IK_ObjCXX)
   .Cases("ast", "pcm", IK_AST)
   .Case("ir", IK_LLVM_IR)
+  .Case("renderscript", IK_Render

Re: [PATCH] D21199: Add a RenderScript language type

2016-06-09 Thread Pirama Arumuga Nainar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272317: Add a RenderScript language type (authored by 
pirama).

Changed prior to commit:
  http://reviews.llvm.org/D21199?vs=60238&id=60249#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21199

Files:
  cfe/trunk/include/clang/Driver/Types.def
  cfe/trunk/lib/Driver/Types.cpp
  cfe/trunk/test/Driver/lit.local.cfg
  cfe/trunk/test/Driver/renderscript.rs
  cfe/trunk/test/lit.cfg

Index: cfe/trunk/include/clang/Driver/Types.def
===
--- cfe/trunk/include/clang/Driver/Types.def
+++ cfe/trunk/include/clang/Driver/Types.def
@@ -53,6 +53,7 @@
 TYPE("objective-c++-cpp-output", PP_ObjCXX,INVALID, "mii",   "u")
 TYPE("objc++-cpp-output",PP_ObjCXX_Alias, INVALID,  "mii",   "u")
 TYPE("objective-c++",ObjCXX,   PP_ObjCXX,   "mm","u")
+TYPE("renderscript", RenderScript, PP_C,"rs","u")
 
 // C family input files to precompile.
 TYPE("c-header-cpp-output",  PP_CHeader,   INVALID, "i", "p")
Index: cfe/trunk/test/lit.cfg
===
--- cfe/trunk/test/lit.cfg
+++ cfe/trunk/test/lit.cfg
@@ -44,7 +44,7 @@
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', 
'.modulemap', '.test']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', 
'.modulemap', '.test', '.rs']
 
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
 # subdirectories contain auxiliary inputs for various tests in their parent
Index: cfe/trunk/test/Driver/lit.local.cfg
===
--- cfe/trunk/test/Driver/lit.local.cfg
+++ cfe/trunk/test/Driver/lit.local.cfg
@@ -1,5 +1,5 @@
 config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', '.f95',
-   '.cu']
+   '.cu', '.rs']
 config.substitutions = list(config.substitutions)
 config.substitutions.insert(0,
 ('%clang_cc1',
Index: cfe/trunk/test/Driver/renderscript.rs
===
--- cfe/trunk/test/Driver/renderscript.rs
+++ cfe/trunk/test/Driver/renderscript.rs
@@ -0,0 +1,3 @@
+// RUN: %clang -### 2>&1 %s | FileCheck %s
+
+// CHECK: "-x" "renderscript"
Index: cfe/trunk/lib/Driver/Types.cpp
===
--- cfe/trunk/lib/Driver/Types.cpp
+++ cfe/trunk/lib/Driver/Types.cpp
@@ -204,6 +204,7 @@
.Case("pcm", TY_ModuleFile)
.Case("pch", TY_PCH)
.Case("gch", TY_PCH)
+   .Case("rs", TY_RenderScript)
.Default(TY_INVALID);
 }
 


Index: cfe/trunk/include/clang/Driver/Types.def
===
--- cfe/trunk/include/clang/Driver/Types.def
+++ cfe/trunk/include/clang/Driver/Types.def
@@ -53,6 +53,7 @@
 TYPE("objective-c++-cpp-output", PP_ObjCXX,INVALID, "mii",   "u")
 TYPE("objc++-cpp-output",PP_ObjCXX_Alias, INVALID,  "mii",   "u")
 TYPE("objective-c++",ObjCXX,   PP_ObjCXX,   "mm","u")
+TYPE("renderscript", RenderScript, PP_C,"rs","u")
 
 // C family input files to precompile.
 TYPE("c-header-cpp-output",  PP_CHeader,   INVALID, "i", "p")
Index: cfe/trunk/test/lit.cfg
===
--- cfe/trunk/test/lit.cfg
+++ cfe/trunk/test/lit.cfg
@@ -44,7 +44,7 @@
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap', '.test']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs']
 
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
 # subdirectories contain auxiliary inputs for various tests in their parent
Index: cfe/trunk/test/Driver/lit.local.cfg
===
--- cfe/trunk/test/Driver/lit.local.cfg
+++ cfe/trunk/test/Driver/lit.local.cfg
@@ -1,5 +1,5 @@
 config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', '.f95',
-   '.cu']
+   '.cu', '.rs']
 config.substitutions = list(config.substitutions)
 config.substitutions.insert(0,
 ('%clang_cc1',
Index: cfe/trunk/test/Driver/renderscript.rs
===
--- cfe/trunk/test/Driver/renderscript.rs
+++ cfe/trunk/test/Driver/renderscript.rs
@@ -0,0 +1,3 @@
+// RUN: %clang -### 2>&1 %s | FileCheck %s
+
+// CHECK: "-x" "renderscri

r272317 - Add a RenderScript language type

2016-06-09 Thread Pirama Arumuga Nainar via cfe-commits
Author: pirama
Date: Thu Jun  9 16:57:40 2016
New Revision: 272317

URL: http://llvm.org/viewvc/llvm-project?rev=272317&view=rev
Log:
Add a RenderScript language type

Summary:
Add RenderScript language type and associate it with ".rs" extensions.
Test that the driver passes "-x renderscript" to the frontend for ".rs"
files.

(Also add '.rs' to the list of suffixes tested by lit).

Reviewers: rsmith

Subscribers: cfe-commits, srhines

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

Added:
cfe/trunk/test/Driver/renderscript.rs
Modified:
cfe/trunk/include/clang/Driver/Types.def
cfe/trunk/lib/Driver/Types.cpp
cfe/trunk/test/Driver/lit.local.cfg
cfe/trunk/test/lit.cfg

Modified: cfe/trunk/include/clang/Driver/Types.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Types.def?rev=272317&r1=272316&r2=272317&view=diff
==
--- cfe/trunk/include/clang/Driver/Types.def (original)
+++ cfe/trunk/include/clang/Driver/Types.def Thu Jun  9 16:57:40 2016
@@ -53,6 +53,7 @@ TYPE("c++",  CXX,
 TYPE("objective-c++-cpp-output", PP_ObjCXX,INVALID, "mii",   "u")
 TYPE("objc++-cpp-output",PP_ObjCXX_Alias, INVALID,  "mii",   "u")
 TYPE("objective-c++",ObjCXX,   PP_ObjCXX,   "mm","u")
+TYPE("renderscript", RenderScript, PP_C,"rs","u")
 
 // C family input files to precompile.
 TYPE("c-header-cpp-output",  PP_CHeader,   INVALID, "i", "p")

Modified: cfe/trunk/lib/Driver/Types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Types.cpp?rev=272317&r1=272316&r2=272317&view=diff
==
--- cfe/trunk/lib/Driver/Types.cpp (original)
+++ cfe/trunk/lib/Driver/Types.cpp Thu Jun  9 16:57:40 2016
@@ -204,6 +204,7 @@ types::ID types::lookupTypeForExtension(
.Case("pcm", TY_ModuleFile)
.Case("pch", TY_PCH)
.Case("gch", TY_PCH)
+   .Case("rs", TY_RenderScript)
.Default(TY_INVALID);
 }
 

Modified: cfe/trunk/test/Driver/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/lit.local.cfg?rev=272317&r1=272316&r2=272317&view=diff
==
--- cfe/trunk/test/Driver/lit.local.cfg (original)
+++ cfe/trunk/test/Driver/lit.local.cfg Thu Jun  9 16:57:40 2016
@@ -1,5 +1,5 @@
 config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', '.f95',
-   '.cu']
+   '.cu', '.rs']
 config.substitutions = list(config.substitutions)
 config.substitutions.insert(0,
 ('%clang_cc1',

Added: cfe/trunk/test/Driver/renderscript.rs
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/renderscript.rs?rev=272317&view=auto
==
--- cfe/trunk/test/Driver/renderscript.rs (added)
+++ cfe/trunk/test/Driver/renderscript.rs Thu Jun  9 16:57:40 2016
@@ -0,0 +1,3 @@
+// RUN: %clang -### 2>&1 %s | FileCheck %s
+
+// CHECK: "-x" "renderscript"

Modified: cfe/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg?rev=272317&r1=272316&r2=272317&view=diff
==
--- cfe/trunk/test/lit.cfg (original)
+++ cfe/trunk/test/lit.cfg Thu Jun  9 16:57:40 2016
@@ -44,7 +44,7 @@ else:
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', 
'.modulemap', '.test']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', 
'.modulemap', '.test', '.rs']
 
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
 # subdirectories contain auxiliary inputs for various tests in their parent


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


Re: [PATCH] D21198: RenderScript support in the Frontend

2016-06-09 Thread Pirama Arumuga Nainar via cfe-commits
pirama added a comment.

Oops, this update merged changes from http://reviews.llvm.org/D21199 as well.  
Let me clean up and upload a new patch.


http://reviews.llvm.org/D21198



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


Re: [PATCH] D20338: [PCH] Fixed overridden files always invalidating preamble even when unchanged

2016-06-09 Thread Cameron via cfe-commits
cameron314 updated this revision to Diff 60250.
cameron314 added a comment.

Here's the final fix (it's the line in FileManager.cpp, plus a test).


http://reviews.llvm.org/D20338

Files:
  include/clang/Frontend/ASTUnit.h
  lib/Basic/FileManager.cpp
  lib/Frontend/ASTUnit.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/PchPreambleTest.cpp

Index: unittests/Frontend/PchPreambleTest.cpp
===
--- /dev/null
+++ unittests/Frontend/PchPreambleTest.cpp
@@ -0,0 +1,155 @@
+//-- unittests/Frontend/PchPreambleTest.cpp - FrontendAction tests ---//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Frontend/ASTUnit.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/FrontendOptions.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/FileManager.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace llvm;
+using namespace clang;
+
+namespace {
+
+class ReadCountingInMemoryFileSystem : public vfs::InMemoryFileSystem
+{
+  std::map ReadCounts;
+
+public:
+  ErrorOr> openFileForRead(const Twine &Path) override
+  {
+SmallVector PathVec;
+Path.toVector(PathVec);
+llvm::sys::path::remove_dots(PathVec, true);
+++ReadCounts[std::string(PathVec.begin(), PathVec.end())];
+return InMemoryFileSystem::openFileForRead(Path);
+  }
+
+  unsigned GetReadCount(const Twine &Path) const
+  {
+auto it = ReadCounts.find(Path.str());
+return it == ReadCounts.end() ? 0 : it->second;
+  }
+};
+
+class PchPreambleTest : public ::testing::Test {
+  IntrusiveRefCntPtr VFS;
+  StringMap RemappedFiles;
+  std::shared_ptr PCHContainerOpts;
+  FileSystemOptions FSOpts;
+
+public:
+  void SetUp() override {
+VFS = new ReadCountingInMemoryFileSystem();
+// We need the working directory to be set to something absolute,
+// otherwise it ends up being inadvertently set to the current
+// working directory in the real file system due to a series of
+// unfortunate conditions interacting badly.
+// What's more, this path *must* be absolute on all (real)
+// filesystems, so just '/' won't work (e.g. on Win32).
+VFS->setCurrentWorkingDirectory("//./");
+  }
+
+  void TearDown() override {
+  }
+
+  void AddFile(const std::string &Filename, const std::string &Contents) {
+::time_t now;
+::time(&now);
+VFS->addFile(Filename, now, MemoryBuffer::getMemBufferCopy(Contents, Filename));
+  }
+
+  void RemapFile(const std::string &Filename, const std::string &Contents) {
+RemappedFiles[Filename] = Contents;
+  }
+
+  std::unique_ptr ParseAST(const std::string &EntryFile) {
+PCHContainerOpts = std::make_shared();
+CompilerInvocation *CI = new CompilerInvocation;
+CI->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile(EntryFile, FrontendOptions::getInputKindForExtension(
+llvm::sys::path::extension(EntryFile).substr(1;
+
+CI->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+
+CI->getPreprocessorOpts().RemappedFileBuffers = GetRemappedFiles();
+
+PreprocessorOptions &PPOpts = CI->getPreprocessorOpts();
+PPOpts.RemappedFilesKeepOriginalName = true;
+
+IntrusiveRefCntPtr
+  Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
+
+FileManager *FileMgr = new FileManager(FSOpts, VFS);
+
+std::unique_ptr AST = ASTUnit::LoadFromCompilerInvocation(
+  CI, PCHContainerOpts, Diags, FileMgr, false, false,
+  /*PrecompilePreambleAfterNParses=*/1);
+return AST;
+  }
+
+  bool ReparseAST(const std::unique_ptr &AST) {
+FileManager *FileMgr = new FileManager(FSOpts, VFS);
+bool reparseFailed = AST->Reparse(PCHContainerOpts, GetRemappedFiles(), FileMgr);
+return reparseFailed;
+  }
+
+  unsigned GetFileReadCount(const std::string &Filename) const {
+return VFS->GetReadCount(Filename);
+  }
+
+private:
+  std::vector>
+  GetRemappedFiles() const {
+std::vector> Remapped;
+for (const auto &RemappedFile : RemappedFiles) {
+  std::unique_ptr buf = MemoryBuffer::getMemBufferCopy(
+RemappedFile.second, RemappedFile.first());
+  Remapped.emplace_back(RemappedFile.first(), buf.release());
+}
+return Remapped;
+  }
+};
+
+TEST_F(PchPreambleTest, ReparseWithOverriddenFileDoesNotInvalidatePreamble) {
+  std::string Header1 = "//./header1.h";
+  std::string Header2 = "//./header2.h";
+  std::string MainName = "//./main.cpp";
+  AddFile(Header1, "");
+  AddFile(Header2, "#pragma once");
+  AddFile(MainName,
+"#include \"//./foo/../header1.h\"\n"
+"#include \"

  1   2   >