[PATCH] D25001: [Module] Merge function prototype with a non-prototype function declaration

2016-09-27 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: doug.gregor, rsmith.
ahatanak added a subscriber: cfe-commits.

This patch fixes a crash that occurs when a non-prototype function is declared 
before a header containing a prototype of the same function is included. This 
caused Sema::LookupName to find both function declarations, which eventually 
caused clang to crash in Sema::AddOverloadCandidate.

https://reviews.llvm.org/D25001

Files:
  lib/Serialization/ASTReaderDecl.cpp
  test/Modules/Inputs/merge-non-prototype-fn/header2.h
  test/Modules/Inputs/merge-non-prototype-fn/module.map
  test/Modules/merge-non-prototype-fn.c

Index: test/Modules/merge-non-prototype-fn.c
===
--- /dev/null
+++ test/Modules/merge-non-prototype-fn.c
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -I%S/Inputs/merge-non-prototype-fn -fmodules 
-fimplicit-module-maps -x c -fmodules-cache-path=%t -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+char *func1();
+
+#include "header2.h"
+
+void foo1(void) {
+  func1("abc", 12);
+}
Index: test/Modules/Inputs/merge-non-prototype-fn/module.map
===
--- /dev/null
+++ test/Modules/Inputs/merge-non-prototype-fn/module.map
@@ -0,0 +1,5 @@
+module header2 {
+  header "header2.h"
+  export *
+}
+
Index: test/Modules/Inputs/merge-non-prototype-fn/header2.h
===
--- /dev/null
+++ test/Modules/Inputs/merge-non-prototype-fn/header2.h
@@ -0,0 +1,6 @@
+#ifndef FUNC1
+#define FUNC1
+
+char *func1(const char *, int);
+
+#endif
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -2699,10 +2699,11 @@
   }
 
   // Functions with the same type and linkage match.
-  // FIXME: This needs to cope with merging of prototyped/non-prototyped
-  // functions, etc.
   if (FunctionDecl *FuncX = dyn_cast(X)) {
 FunctionDecl *FuncY = cast(Y);
+// Return true if either function is a non-prototyped declaration.
+if (!FuncX->hasWrittenPrototype() || !FuncY->hasWrittenPrototype())
+  return true;
 if (CXXConstructorDecl *CtorX = dyn_cast(X)) {
   CXXConstructorDecl *CtorY = cast(Y);
   if (CtorX->getInheritedConstructor() &&


Index: test/Modules/merge-non-prototype-fn.c
===
--- /dev/null
+++ test/Modules/merge-non-prototype-fn.c
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -I%S/Inputs/merge-non-prototype-fn -fmodules -fimplicit-module-maps -x c -fmodules-cache-path=%t -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+char *func1();
+
+#include "header2.h"
+
+void foo1(void) {
+  func1("abc", 12);
+}
Index: test/Modules/Inputs/merge-non-prototype-fn/module.map
===
--- /dev/null
+++ test/Modules/Inputs/merge-non-prototype-fn/module.map
@@ -0,0 +1,5 @@
+module header2 {
+  header "header2.h"
+  export *
+}
+
Index: test/Modules/Inputs/merge-non-prototype-fn/header2.h
===
--- /dev/null
+++ test/Modules/Inputs/merge-non-prototype-fn/header2.h
@@ -0,0 +1,6 @@
+#ifndef FUNC1
+#define FUNC1
+
+char *func1(const char *, int);
+
+#endif
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -2699,10 +2699,11 @@
   }
 
   // Functions with the same type and linkage match.
-  // FIXME: This needs to cope with merging of prototyped/non-prototyped
-  // functions, etc.
   if (FunctionDecl *FuncX = dyn_cast(X)) {
 FunctionDecl *FuncY = cast(Y);
+// Return true if either function is a non-prototyped declaration.
+if (!FuncX->hasWrittenPrototype() || !FuncY->hasWrittenPrototype())
+  return true;
 if (CXXConstructorDecl *CtorX = dyn_cast(X)) {
   CXXConstructorDecl *CtorY = cast(Y);
   if (CtorX->getInheritedConstructor() &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24998: Add a new optimization option -Og

2016-09-27 Thread Sylvestre Ledru via cfe-commits
sylvestre.ledru updated this revision to Diff 72759.
sylvestre.ledru added a comment.

with the full context + clang format


https://reviews.llvm.org/D24998

Files:
  docs/CommandGuide/clang.rst
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/debug-options.c
  test/Preprocessor/init.c

Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -226,7 +226,7 @@
 Code Generation Options
 ~~~
 
-.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -O, -O4
+.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -Og, -O, -O4
 
   Specify which optimization level to use:
 
@@ -252,6 +252,8 @@
 :option:`-Oz` Like :option:`-Os` (and thus :option:`-O2`), but reduces code
 size further.
 
+:option:`-Og` Like :option:`-O1`.
+
 :option:`-O` Equivalent to :option:`-O2`.
 
 :option:`-O4` and higher
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -98,6 +98,9 @@
 if (S == "s" || S == "z" || S.empty())
   return 2;
 
+if (S == "g")
+  return 1;
+
 return getLastArgIntValue(Args, OPT_O, DefaultOpt, Diags);
   }
 
Index: test/Driver/debug-options.c
===
--- test/Driver/debug-options.c
+++ test/Driver/debug-options.c
@@ -18,6 +18,9 @@
 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
 
+// RUN: %clang -### -c -Og -g %s -target x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s
+
 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
 // RUN: | FileCheck -check-prefix=G_DARWIN -check-prefix=G_LLDB %s
 // RUN: %clang -### -c -g2 %s -target x86_64-apple-darwin 2>&1 \
Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -205,6 +205,12 @@
 // O1:#define __OPTIMIZE__ 1
 //
 //
+// RUN: %clang_cc1 -Og -E -dM < /dev/null | FileCheck -match-full-lines 
-check-prefix O1 %s
+//
+// Og-NOT:#define __OPTIMIZE_SIZE__
+// Og:#define __OPTIMIZE__ 1
+//
+//
 // RUN: %clang_cc1 -Os -E -dM < /dev/null | FileCheck -match-full-lines 
-check-prefix Os %s
 //
 // Os:#define __OPTIMIZE_SIZE__ 1


Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -226,7 +226,7 @@
 Code Generation Options
 ~~~
 
-.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -O, -O4
+.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -Og, -O, -O4
 
   Specify which optimization level to use:
 
@@ -252,6 +252,8 @@
 :option:`-Oz` Like :option:`-Os` (and thus :option:`-O2`), but reduces code
 size further.
 
+:option:`-Og` Like :option:`-O1`.
+
 :option:`-O` Equivalent to :option:`-O2`.
 
 :option:`-O4` and higher
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -98,6 +98,9 @@
 if (S == "s" || S == "z" || S.empty())
   return 2;
 
+if (S == "g")
+  return 1;
+
 return getLastArgIntValue(Args, OPT_O, DefaultOpt, Diags);
   }
 
Index: test/Driver/debug-options.c
===
--- test/Driver/debug-options.c
+++ test/Driver/debug-options.c
@@ -18,6 +18,9 @@
 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
 
+// RUN: %clang -### -c -Og -g %s -target x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s
+
 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
 // RUN: | FileCheck -check-prefix=G_DARWIN -check-prefix=G_LLDB %s
 // RUN: %clang -### -c -g2 %s -target x86_64-apple-darwin 2>&1 \
Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -205,6 +205,12 @@
 // O1:#define __OPTIMIZE__ 1
 //
 //
+// RUN: %clang_cc1 -Og -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix O1 %s
+//
+// Og-NOT:#define __OPTIMIZE_SIZE__
+// Og:#define __OPTIMIZE__ 1
+//
+//
 // RUN: %clang_cc1 -Os -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix Os %s
 //
 // Os:#define __OPTIMIZE_SIZE__ 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24998: Add a new optimization option -Og

2016-09-27 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.
majnemer added a comment.

Please include full context with your diff.



Comment at: lib/Frontend/CompilerInvocation.cpp:101-103
@@ -100,1 +100,5 @@
 
+if (S == "g") {
+return 1;
+}
+

Please clang-format this.


https://reviews.llvm.org/D24998



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


[PATCH] D24999: [Sema] Only relax array-at-end-of-object checks in __builtin_object_size when -fno-strict-aliasing is given.

2016-09-27 Thread George Burgess IV via cfe-commits
george.burgess.iv created this revision.
george.burgess.iv added reviewers: joerg, rsmith.
george.burgess.iv added a subscriber: cfe-commits.

Mostly asking for a review to verify that you guys are happy with this approach.

Given that Hal said struct-path-tbaa doesn't really deal with arrays (yet), I 
decided to ignore -fno-struct-path-tbaa. If that changes in the future, we can 
relax this when that flag is given, too.

https://reviews.llvm.org/D24999

Files:
  include/clang/Basic/LangOptions.def
  lib/AST/ExprConstant.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/object-size.c
  test/CodeGen/pass-object-size.c

Index: test/CodeGen/pass-object-size.c
===
--- test/CodeGen/pass-object-size.c
+++ test/CodeGen/pass-object-size.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -O0 %s -o - 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -O0 %s -o - 2>&1 | FileCheck %s --check-prefixes STRICT,CHECK
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -O0 %s -o - -relaxed-aliasing 2>&1 | FileCheck %s --check-prefixes NOSTRICT,CHECK
 
 typedef unsigned long size_t;
 
@@ -59,8 +60,10 @@
 
 // CHECK-LABEL: define void @test2
 void test2(struct Foo *t) {
-  // CHECK: [[VAR:%[0-9]+]] = call i64 @llvm.objectsize
-  // CHECK: call i32 @ObjectSize1(i8* %{{.*}}, i64 [[VAR]])
+  // NOSTRICT: [[VAR:%[0-9]+]] = call i64 @llvm.objectsize
+  // NOSTRICT: call i32 @ObjectSize1(i8* %{{.*}}, i64 [[VAR]])
+  //
+  // STRICT: call i32 @ObjectSize1(i8* %{{.*}}, i64 36)
   gi = ObjectSize1(>t[1]);
   // CHECK: call i32 @ObjectSize3(i8* %{{.*}}, i64 36)
   gi = ObjectSize3(>t[1]);
@@ -169,8 +172,10 @@
 
   // CHECK: call i32 @_Z27NoViableOverloadObjectSize0PvU17pass_object_size0(i8* %{{.*}}, i64 %{{.*}})
   gi = NoViableOverloadObjectSize0([1].t[1]);
-  // CHECK: [[VAR:%[0-9]+]] = call i64 @llvm.objectsize
-  // CHECK: call i32 @_Z27NoViableOverloadObjectSize1PvU17pass_object_size1(i8* %{{.*}}, i64 [[VAR]])
+  // NOSTRICT: [[VAR:%[0-9]+]] = call i64 @llvm.objectsize
+  // NOSTRICT: call i32 @_Z27NoViableOverloadObjectSize1PvU17pass_object_size1(i8* %{{.*}}, i64 [[VAR]])
+  //
+  // STRICT: call i32 @_Z27NoViableOverloadObjectSize1PvU17pass_object_size1(i8* %{{.*}}, i64 36)
   gi = NoViableOverloadObjectSize1([1].t[1]);
   // CHECK: call i32 @_Z27NoViableOverloadObjectSize2PvU17pass_object_size2(i8* %{{.*}}, i64 %{{.*}})
   gi = NoViableOverloadObjectSize2([1].t[1]);
@@ -276,8 +281,10 @@
 
 // CHECK-LABEL: define void @test8
 void test8(struct Foo *t) {
-  // CHECK: [[VAR:%[0-9]+]] = call i64 @llvm.objectsize
-  // CHECK: call i32 @"\01Identity"(i8* %{{.*}}, i64 [[VAR]])
+  // NOSTRICT: [[VAR:%[0-9]+]] = call i64 @llvm.objectsize
+  // NOSTRICT: call i32 @"\01Identity"(i8* %{{.*}}, i64 [[VAR]])
+  //
+  // STRICT: call i32 @"\01Identity"(i8* %{{.*}}, i64 36)
   gi = AsmObjectSize1([1].t[1]);
   // CHECK: call i32 @"\01Identity"(i8* %{{.*}}, i64 36)
   gi = AsmObjectSize3([1].t[1]);
Index: test/CodeGen/object-size.c
===
--- test/CodeGen/object-size.c
+++ test/CodeGen/object-size.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefixes=STRICT,CHECK
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - 2>&1 -relaxed-aliasing | FileCheck %s --check-prefixes=NOSTRICT,CHECK
 
 #define strcpy(dest, src) \
   ((__builtin_object_size(dest, 0) != -1ULL) \
@@ -276,7 +277,8 @@
 
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
   gi = __builtin_object_size(>t[5], 0);
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  // NOSTRICT: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  // STRICT: store i32 20
   gi = __builtin_object_size(>t[5], 1);
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
   gi = __builtin_object_size(>t[5], 2);
@@ -444,7 +446,8 @@
 
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
   gi = __builtin_object_size(ss->snd, 0);
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  // NOSTRICT: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  // STRICT: store i32 2
   gi = __builtin_object_size(ss->snd, 1);
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
   gi = __builtin_object_size(ss->snd, 2);
@@ -505,7 +508,8 @@
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
   gi = __builtin_object_size(ds1[9].snd, 1);
 
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  // NOSTRICT: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  // STRICT: store i32 2
   gi = __builtin_object_size([9].snd[0], 1);
 
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
@@ 

[PATCH] D24998: Add a new optimization option -Og

2016-09-27 Thread Sylvestre Ledru via cfe-commits
sylvestre.ledru created this revision.
sylvestre.ledru added a reviewer: rengolin.
sylvestre.ledru added a subscriber: cfe-commits.

Just like gcc, we should have the -Og option as more and more software are 
using it:
https://llvm.org/bugs/show_bug.cgi?id=20765

https://reviews.llvm.org/D24998

Files:
  docs/CommandGuide/clang.rst
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/debug-options.c
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -205,6 +205,12 @@
 // O1:#define __OPTIMIZE__ 1
 //
 //
+// RUN: %clang_cc1 -Og -E -dM < /dev/null | FileCheck -match-full-lines 
-check-prefix O1 %s
+//
+// Og-NOT:#define __OPTIMIZE_SIZE__
+// Og:#define __OPTIMIZE__ 1
+//
+//
 // RUN: %clang_cc1 -Os -E -dM < /dev/null | FileCheck -match-full-lines 
-check-prefix Os %s
 //
 // Os:#define __OPTIMIZE_SIZE__ 1
Index: test/Driver/debug-options.c
===
--- test/Driver/debug-options.c
+++ test/Driver/debug-options.c
@@ -18,6 +18,9 @@
 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
 
+// RUN: %clang -### -c -Og -g %s -target x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s
+
 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
 // RUN: | FileCheck -check-prefix=G_DARWIN -check-prefix=G_LLDB %s
 // RUN: %clang -### -c -g2 %s -target x86_64-apple-darwin 2>&1 \
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -98,6 +98,10 @@
 if (S == "s" || S == "z" || S.empty())
   return 2;
 
+if (S == "g") {
+return 1;
+}
+
 return getLastArgIntValue(Args, OPT_O, DefaultOpt, Diags);
   }
 
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -226,7 +226,7 @@
 Code Generation Options
 ~~~
 
-.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -O, -O4
+.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -Og, -O, -O4
 
   Specify which optimization level to use:
 
@@ -252,6 +252,8 @@
 :option:`-Oz` Like :option:`-Os` (and thus :option:`-O2`), but reduces code
 size further.
 
+:option:`-Og` Like :option:`-O1`.
+
 :option:`-O` Equivalent to :option:`-O2`.
 
 :option:`-O4` and higher


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -205,6 +205,12 @@
 // O1:#define __OPTIMIZE__ 1
 //
 //
+// RUN: %clang_cc1 -Og -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix O1 %s
+//
+// Og-NOT:#define __OPTIMIZE_SIZE__
+// Og:#define __OPTIMIZE__ 1
+//
+//
 // RUN: %clang_cc1 -Os -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix Os %s
 //
 // Os:#define __OPTIMIZE_SIZE__ 1
Index: test/Driver/debug-options.c
===
--- test/Driver/debug-options.c
+++ test/Driver/debug-options.c
@@ -18,6 +18,9 @@
 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
 
+// RUN: %clang -### -c -Og -g %s -target x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s
+
 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
 // RUN: | FileCheck -check-prefix=G_DARWIN -check-prefix=G_LLDB %s
 // RUN: %clang -### -c -g2 %s -target x86_64-apple-darwin 2>&1 \
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -98,6 +98,10 @@
 if (S == "s" || S == "z" || S.empty())
   return 2;
 
+if (S == "g") {
+return 1;
+}
+
 return getLastArgIntValue(Args, OPT_O, DefaultOpt, Diags);
   }
 
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -226,7 +226,7 @@
 Code Generation Options
 ~~~
 
-.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -O, -O4
+.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -Og, -O, -O4
 
   Specify which optimization level to use:
 
@@ -252,6 +252,8 @@
 :option:`-Oz` Like :option:`-Os` (and thus :option:`-O2`), but reduces code
 size further.
 
+:option:`-Og` Like :option:`-O1`.
+
 :option:`-O` Equivalent to :option:`-O2`.
 
 :option:`-O4` and higher
___
cfe-commits mailing list

Re: [PATCH] D23236: When ARC is enabled, no warning will be generated when a method1. Returns 'nil' in a method that is attributed to return a 'nonnull'2. The return-statement is a ConditionalOperator

2016-09-27 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

@parallaxe Do you need someone to commit this for you?


https://reviews.llvm.org/D23236



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


r282564 - Revert r282556. This change made several bots unhappy.

2016-09-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Sep 27 21:20:06 2016
New Revision: 282564

URL: http://llvm.org/viewvc/llvm-project?rev=282564=rev
Log:
Revert r282556. This change made several bots unhappy.

Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/cxx1z-eval-order.cpp
cfe/trunk/test/CodeGenObjCXX/property-object-reference-2.mm
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=282564=282563=282564=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Tue Sep 27 21:20:06 2016
@@ -76,16 +76,6 @@ public:
   /// expression refers to.
   OverloadedOperatorKind getOperator() const { return Operator; }
 
-  static bool isAssignmentOp(OverloadedOperatorKind Opc) {
-return Opc == OO_Equal || Opc == OO_StarEqual ||
-   Opc == OO_SlashEqual || Opc == OO_PercentEqual ||
-   Opc == OO_PlusEqual || Opc == OO_MinusEqual ||
-   Opc == OO_LessLessEqual || Opc == OO_GreaterGreaterEqual ||
-   Opc == OO_AmpEqual || Opc == OO_CaretEqual ||
-   Opc == OO_PipeEqual;
-  }
-  bool isAssignmentOp() const { return isAssignmentOp(getOperator()); }
-
   /// \brief Returns the location of the operator symbol in the expression.
   ///
   /// When \c getOperator()==OO_Call, this is the location of the right

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=282564=282563=282564=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Sep 27 21:20:06 2016
@@ -3172,8 +3172,7 @@ void CodeGenFunction::EmitNonNullArgChec
 void CodeGenFunction::EmitCallArgs(
 CallArgList , ArrayRef ArgTypes,
 llvm::iterator_range ArgRange,
-const FunctionDecl *CalleeDecl, unsigned ParamsToSkip,
-bool ForceRightToLeftEvaluation) {
+const FunctionDecl *CalleeDecl, unsigned ParamsToSkip) {
   assert((int)ArgTypes.size() == (ArgRange.end() - ArgRange.begin()));
 
   auto MaybeEmitImplicitObjectSize = [&](unsigned I, const Expr *Arg) {
@@ -3192,8 +3191,7 @@ void CodeGenFunction::EmitCallArgs(
 
   // We *have* to evaluate arguments from right to left in the MS C++ ABI,
   // because arguments are destroyed left to right in the callee.
-  if (CGM.getTarget().getCXXABI().areArgsDestroyedLeftToRightInCallee() ||
-  ForceRightToLeftEvaluation) {
+  if (CGM.getTarget().getCXXABI().areArgsDestroyedLeftToRightInCallee()) {
 // Insert a stack save if we're going to need any inalloca args.
 bool HasInAllocaArgs = false;
 for (ArrayRef::iterator I = ArgTypes.begin(), E = ArgTypes.end();

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=282564=282563=282564=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Sep 27 21:20:06 2016
@@ -4121,17 +4121,8 @@ RValue CodeGenFunction::EmitCall(QualTyp
   if (Chain)
 Args.add(RValue::get(Builder.CreateBitCast(Chain, CGM.VoidPtrTy)),
  CGM.getContext().VoidPtrTy);
-
-  // C++17 requires that we evaluate arguments to a call using assignment 
syntax
-  // right-to-left. It also requires that we evaluate arguments to operators
-  // <<, >>, and ->* left-to-right, but that is not possible under the MS ABI,
-  // so there is no corresponding "force left-to-right" case.
-  bool ForceRightToLeft = false;
-  if (auto *OCE = dyn_cast(E))
-ForceRightToLeft = OCE->isAssignmentOp();
-
   EmitCallArgs(Args, dyn_cast(FnType), E->arguments(),
-   E->getDirectCallee(), /*ParamsToSkip*/ 0, ForceRightToLeft);
+   E->getDirectCallee(), /*ParamsToSkip*/ 0);
 
   const CGFunctionInfo  = CGM.getTypes().arrangeFreeFunctionCall(
   Args, FnType, /*isChainCall=*/Chain);

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=282564=282563=282564=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Tue Sep 27 21:20:06 2016
@@ -28,7 +28,7 @@ static RequiredArgs
 commonEmitCXXMemberOrOperatorCall(CodeGenFunction , const CXXMethodDecl 
*MD,
   llvm::Value *This, llvm::Value 
*ImplicitParam,
   QualType ImplicitParamTy, const CallExpr *CE,
-  

Re: [PATCH] D9127: PR23175 (fix) - Infinite loop iterating Objective-C method declarations in categories when the AST was deserialized from an .ast file

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

Looks like patch was not committed.


Repository:
  rL LLVM

https://reviews.llvm.org/D9127



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


[PATCH] D24997: [ClangTidy] Add UsingInserter and NamespaceAliaser

2016-09-27 Thread Julian Bangert via cfe-commits
jbangert created this revision.
jbangert added a reviewer: alexfh.
jbangert added a subscriber: cfe-commits.
jbangert added a project: clang-tools-extra.

This adds helper classes to add using declaractions and namespace aliases to 
function bodies. These help making function calls to deeply nested functions 
concise (e.g. when calling helpers in a refactoring)

https://reviews.llvm.org/D24997

Files:
  clang-tidy/utils/ASTUtils.cpp
  clang-tidy/utils/ASTUtils.h
  clang-tidy/utils/NamespaceAliaser.cpp
  clang-tidy/utils/NamespaceAliaser.h
  clang-tidy/utils/UsingInserter.cpp
  clang-tidy/utils/UsingInserter.h
  unittests/clang-tidy/NamespaceAliaserTest.cpp
  unittests/clang-tidy/UsingInserterTest.cpp

Index: unittests/clang-tidy/UsingInserterTest.cpp
===
--- /dev/null
+++ unittests/clang-tidy/UsingInserterTest.cpp
@@ -0,0 +1,115 @@
+//=== UsingInserterTest.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 "../clang-tidy/utils/UsingInserter.h"
+
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+// Replace all function calls with calls to foo::func. Inserts using
+// declarations as necessary. This checker is for testing only. It
+// can only run on one test case (e.g. wih one SourceManager).
+class InsertUsingCheck : public clang::tidy::ClangTidyCheck {
+public:
+  using clang::tidy::ClangTidyCheck::ClangTidyCheck;
+  void registerMatchers(clang::ast_matchers::MatchFinder *Finder) override {
+Finder->addMatcher(clang::ast_matchers::callExpr().bind("foo"), this);
+  }
+  void
+  check(const clang::ast_matchers::MatchFinder::MatchResult ) override {
+if (!Inserter)
+  Inserter.reset(new UsingInserter(*Result.SourceManager,
+   Result.Context->getLangOpts()));
+
+const clang::CallExpr *Call =
+Result.Nodes.getNodeAs("foo");
+assert(Call != nullptr && "Did not find node \"foo\"");
+auto Hint =
+Inserter->createUsingDeclaration(*Result.Context, *Call, "::foo::func");
+
+if (Hint.hasValue())
+  diag(Call->getLocStart(), "Fix for testing") << Hint.getValue();
+
+diag(Call->getLocStart(), "insert call")
+<< clang::FixItHint::CreateReplacement(
+   Call->getCallee()->getSourceRange(),
+   Inserter->getShortName(*Result.Context, *Call, "::foo::func"));
+  }
+
+private:
+  std::unique_ptr Inserter;
+};
+
+template 
+std::string runChecker(StringRef Code, int ExpectedWarningCount) {
+  std::map AdditionalFileContents = {{"foo.h",
+"namespace foo {\n"
+"namespace bar {\n"
+"}\n"
+"void func() { }\n"
+"}"}};
+  std::vector errors;
+
+  std::string result =
+  test::runCheckOnCode(Code, , "foo.cc", None,
+  ClangTidyOptions(), AdditionalFileContents);
+
+  EXPECT_EQ(ExpectedWarningCount, errors.size());
+  return result;
+}
+
+TEST(UsingInserterTest, ReusesExisting) {
+  EXPECT_EQ("#include \"foo.h\"\n"
+"namespace {"
+"using ::foo::func;\n"
+"void f() { func(); }"
+"}",
+runChecker("#include \"foo.h\"\n"
+ "namespace {"
+ "using ::foo::func;\n"
+ "void f() { f(); }"
+ "}",
+ 1));
+}
+
+TEST(UsingInserterTest, ReusesExistingGlobal) {
+  EXPECT_EQ("#include \"foo.h\"\n"
+"using ::foo::func;\n"
+"namespace {"
+"void f() { func(); }"
+"}",
+runChecker("#include \"foo.h\"\n"
+ "using ::foo::func;\n"
+ "namespace {"
+ "void f() { f(); }"
+ "}",
+ 1));
+}
+
+TEST(UsingInserterTest, AvoidsConflict) {
+  EXPECT_EQ("#include \"foo.h\"\n"
+"namespace {"
+"void f() { int func; ::foo::func(); }"
+"}",
+runChecker("#include \"foo.h\"\n"
+ "namespace {"
+  

Re: [PATCH] D24975: [CUDA] Add #pragma clang force_cuda_host_device_{begin, end} pragmas.

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

> What happens if there are trailing tokens after the pragma?


Added code to make this an error.


https://reviews.llvm.org/D24975



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


Re: [PATCH] D24975: [CUDA] Add #pragma clang force_cuda_host_device_{begin, end} pragmas.

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

Address Richard's comments.

I'm fairly neutral on whether we want to make it an error not to match all of
your "begin" pragmas with "end"s.  I checked pragma push_macro, and it looks
like it's not an error to pop those, so with that prior art, and since it was
simpler not to check for matching begin/ends, I did the same.  But like I say,
I don't feel strongly either way (or even if we wanted to make these new
pragmas not-nestable).


https://reviews.llvm.org/D24975

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Parser/cuda-force-host-device-templates.cu
  clang/test/Parser/cuda-force-host-device.cu

Index: clang/test/Parser/cuda-force-host-device.cu
===
--- /dev/null
+++ clang/test/Parser/cuda-force-host-device.cu
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the force_cuda_host_device pragma.
+
+#pragma clang force_cuda_host_device begin
+void f();
+#pragma clang force_cuda_host_device begin
+void g();
+#pragma clang force_cuda_host_device end
+void h();
+#pragma clang force_cuda_host_device end
+
+void i(); // expected-note {{not viable}}
+
+void host() {
+  f();
+  g();
+  h();
+  i();
+}
+
+__attribute__((device)) void device() {
+  f();
+  g();
+  h();
+  i(); // expected-error {{no matching function}}
+}
+
+#pragma clang force_cuda_host_device foo
+// expected-warning@-1 {{incorrect use of #pragma clang force_cuda_host_device begin|end}}
+
+#pragma clang force_cuda_host_device
+// expected-warning@-1 {{incorrect use of #pragma clang force_cuda_host_device begin|end}}
+
+#pragma clang force_cuda_host_device begin foo
+// expected-warning@-1 {{incorrect use of #pragma clang force_cuda_host_device begin|end}}
Index: clang/test/Parser/cuda-force-host-device-templates.cu
===
--- /dev/null
+++ clang/test/Parser/cuda-force-host-device-templates.cu
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++14 -S -verify -fcuda-is-device %s -o /dev/null
+
+// Check how the force_cuda_host_device pragma interacts with template
+// instantiations.  The errors here are emitted at codegen, so we can't do
+// -fsyntax-only.
+
+template 
+auto foo() {  // expected-note {{declared here}}
+  return T();
+}
+
+template 
+struct X {
+  void foo(); // expected-note {{declared here}}
+};
+
+#pragma clang force_cuda_host_device begin
+__attribute__((host)) __attribute__((device)) void test() {
+  int n = foo();  // expected-error {{reference to __host__ function 'foo'}}
+  X().foo();  // expected-error {{reference to __host__ function 'foo'}}
+}
+#pragma clang force_cuda_host_device end
+
+// Same thing as above, but within a force_cuda_host_device block without a
+// corresponding end.
+
+template 
+T bar() {  // expected-note {{declared here}}
+  return T();
+}
+
+template 
+struct Y {
+  void bar(); // expected-note {{declared here}}
+};
+
+#pragma clang force_cuda_host_device begin
+__attribute__((host)) __attribute__((device)) void test2() {
+  int n = bar();  // expected-error {{reference to __host__ function 'bar'}}
+  Y().bar();  // expected-error {{reference to __host__ function 'bar'}}
+}
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1069,6 +1069,7 @@
   RECORD(POINTERS_TO_MEMBERS_PRAGMA_OPTIONS);
   RECORD(UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES);
   RECORD(DELETE_EXPRS_TO_ANALYZE);
+  RECORD(CUDA_PRAGMA_FORCE_HOST_DEVICE_DEPTH);
 
   // SourceManager Block.
   BLOCK(SOURCE_MANAGER_BLOCK);
@@ -3943,6 +3944,13 @@
   Stream.EmitRecord(OPENCL_EXTENSIONS, Record);
 }
 
+void ASTWriter::WriteCUDAPragmas(Sema ) {
+  if (SemaRef.ForceCUDAHostDeviceDepth > 0) {
+RecordData::value_type Record[] = {SemaRef.ForceCUDAHostDeviceDepth};
+Stream.EmitRecord(CUDA_PRAGMA_FORCE_HOST_DEVICE_DEPTH, Record);
+  }
+}
+
 void ASTWriter::WriteObjCCategories() {
   SmallVector CategoriesMap;
   RecordData Categories;
@@ -4618,6 +4626,7 @@
   WriteIdentifierTable(PP, SemaRef.IdResolver, isModule);
   WriteFPPragmaOptions(SemaRef.getFPOptions());
   WriteOpenCLExtensions(SemaRef);
+  WriteCUDAPragmas(SemaRef);
   WritePragmaDiagnosticMappings(Context.getDiagnostics(), isModule);
 
   // If we're emitting a module, write out the submodule information.  
Index: 

Re: r282547 - Fix defaulted member functions for templated classes.

2016-09-27 Thread Richard Trieu via cfe-commits
Reverted in r282555.

On Tue, Sep 27, 2016 at 3:44 PM, Richard Smith 
wrote:

> It looks like this will reject valid code, such as:
>
> template struct X {
>   using T = typename std::conditional::type;
>   X();
>   X(T) = default; // either copyable or moveable, depending on B
> };
>
> On Tue, Sep 27, 2016 at 3:28 PM, Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Tue Sep 27 17:28:59 2016
>> New Revision: 282547
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=282547=rev
>> Log:
>> Fix defaulted member functions for templated classes.
>>
>> In some cases, non-special member functions were being marked as being
>> defaulted
>> in templated classes.  This can cause interactions with later code that
>> expects
>> the default function to be one of the specific member functions.
>
>
> If later code is assuming that a defaulted member of a dependent class is
> a specific special member function, it is wrong; we should put the fix
> there instead of here.
>
>
>> Fix the check
>> so that templated class members are checked the same way as non-templated
>> class
>> members are.
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaD
>> eclCXX.cpp?rev=282547=282546=282547=diff
>> 
>> ==
>> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Sep 27 17:28:59 2016
>> @@ -13850,12 +13850,6 @@ void Sema::SetDeclDefaulted(Decl *Dcl, S
>>CXXMethodDecl *MD = dyn_cast_or_null(Dcl);
>>
>>if (MD) {
>> -if (MD->getParent()->isDependentType()) {
>> -  MD->setDefaulted();
>> -  MD->setExplicitlyDefaulted();
>> -  return;
>> -}
>> -
>>  CXXSpecialMember Member = getSpecialMember(MD);
>>  if (Member == CXXInvalid) {
>>if (!MD->isInvalidDecl())
>> @@ -13866,6 +13860,8 @@ void Sema::SetDeclDefaulted(Decl *Dcl, S
>>  MD->setDefaulted();
>>  MD->setExplicitlyDefaulted();
>>
>> +if (MD->getParent()->isDependentType()) return;
>> +
>>  // If this definition appears within the record, do the checking when
>>  // the record is complete.
>>  const FunctionDecl *Primary = MD;
>>
>> Modified: cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/
>> cxx0x-defaulted-functions.cpp?rev=282547=282546=282547=diff
>> 
>> ==
>> --- cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp Tue Sep 27
>> 17:28:59 2016
>> @@ -208,3 +208,31 @@ int fn() {
>>t = true;
>>  }
>>  }
>> +
>> +namespace templated_class {
>> +template 
>> +class X {
>> +X() = default;
>> +X(const X&) = default;
>> +X(X&&) = default;
>> +X =(const X&) = default;
>> +X =(X&&) = default;
>> +~X() = default;
>> +
>> +X(T) = default;  // expected-error {{only special member functions
>> may be defaulted}}
>> +void Run() = default;  // expected-error {{only special member
>> functions may be defaulted}}
>> +
>> +  };
>> +  template 
>> +  X::X() = default; // expected-error {{definition of explicitly
>> defaulted}}
>> +  template 
>> +  X::X(const X&) = default; // expected-error {{definition of
>> explicitly defaulted}}
>> +  template 
>> +  X::X(X&&) = default; // expected-error {{definition of
>> explicitly defaulted}}
>> +  template 
>> +  X ::operator=(const X&) = default; // expected-error
>> {{definition of explicitly defaulted}}
>> +  template 
>> +  X ::operator=(X&&) = default; // expected-error
>> {{definition of explicitly defaulted}}
>> +  template 
>> +  X::~X() = default; // expected-error {{definition of explicitly
>> defaulted}}
>> +}
>>
>>
>> ___
>> 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


r282557 - Put new warning in a diagnostic group.

2016-09-27 Thread Matthias Braun via cfe-commits
Author: matze
Date: Tue Sep 27 18:44:38 2016
New Revision: 282557

URL: http://llvm.org/viewvc/llvm-project?rev=282557=rev
Log:
Put new warning in a diagnostic group.

The warning I added in r282426 should be a diagnostic group.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/test/Misc/warning-flags.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=282557=282556=282557=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Tue Sep 27 
18:44:38 2016
@@ -108,7 +108,8 @@ def warn_fe_cc_print_header_failure : Wa
 def warn_fe_cc_log_diagnostics_failure : Warning<
 "unable to open CC_LOG_DIAGNOSTICS file: %0 (using stderr)">;
 def warn_fe_unable_to_open_stats_file : Warning<
-"unable to open statistics output file '%0': '%1'">;
+"unable to open statistics output file '%0': '%1'">,
+InGroup>;
 def err_fe_no_pch_in_dir : Error<
 "no suitable precompiled header file found in directory '%0'">;
 def err_fe_action_not_available : Error<

Modified: cfe/trunk/test/Misc/warning-flags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags.c?rev=282557=282556=282557=diff
==
--- cfe/trunk/test/Misc/warning-flags.c (original)
+++ cfe/trunk/test/Misc/warning-flags.c Tue Sep 27 18:44:38 2016
@@ -18,7 +18,7 @@ This test serves two purposes:
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (85):
+CHECK: Warnings without flags (84):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -66,7 +66,6 @@ CHECK-NEXT:   warn_extraneous_char_const
 CHECK-NEXT:   warn_fe_cc_log_diagnostics_failure
 CHECK-NEXT:   warn_fe_cc_print_header_failure
 CHECK-NEXT:   warn_fe_macro_contains_embedded_newline
-CHECK-NEXT:   warn_fe_unable_to_open_stats_file
 CHECK-NEXT:   warn_file_asm_volatile
 CHECK-NEXT:   warn_ignoring_ftabstop_value
 CHECK-NEXT:   warn_implements_nscopying


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


r282555 - Revert r282547 and add test to show correct behavior.

2016-09-27 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Sep 27 18:44:07 2016
New Revision: 282555

URL: http://llvm.org/viewvc/llvm-project?rev=282555=rev
Log:
Revert r282547 and add test to show correct behavior.

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=282555=282554=282555=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Sep 27 18:44:07 2016
@@ -13850,6 +13850,12 @@ void Sema::SetDeclDefaulted(Decl *Dcl, S
   CXXMethodDecl *MD = dyn_cast_or_null(Dcl);
 
   if (MD) {
+if (MD->getParent()->isDependentType()) {
+  MD->setDefaulted();
+  MD->setExplicitlyDefaulted();
+  return;
+}
+
 CXXSpecialMember Member = getSpecialMember(MD);
 if (Member == CXXInvalid) {
   if (!MD->isInvalidDecl())
@@ -13860,8 +13866,6 @@ void Sema::SetDeclDefaulted(Decl *Dcl, S
 MD->setDefaulted();
 MD->setExplicitlyDefaulted();
 
-if (MD->getParent()->isDependentType()) return;
-
 // If this definition appears within the record, do the checking when
 // the record is complete.
 const FunctionDecl *Primary = MD;

Modified: cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp?rev=282555=282554=282555=diff
==
--- cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp Tue Sep 27 18:44:07 
2016
@@ -209,30 +209,29 @@ int fn() {
 }
 }
 
-namespace templated_class {
-template 
-class X {
-X() = default;
-X(const X&) = default;
-X(X&&) = default;
-X =(const X&) = default;
-X =(X&&) = default;
-~X() = default;
-
-X(T) = default;  // expected-error {{only special member functions may be 
defaulted}}
-void Run() = default;  // expected-error {{only special member functions 
may be defaulted}}
-
-  };
-  template 
-  X::X() = default; // expected-error {{definition of explicitly defaulted}}
-  template 
-  X::X(const X&) = default; // expected-error {{definition of explicitly 
defaulted}}
-  template 
-  X::X(X&&) = default; // expected-error {{definition of explicitly 
defaulted}}
-  template 
-  X ::operator=(const X&) = default; // expected-error {{definition 
of explicitly defaulted}}
-  template 
-  X ::operator=(X&&) = default; // expected-error {{definition of 
explicitly defaulted}}
-  template 
-  X::~X() = default; // expected-error {{definition of explicitly 
defaulted}}
+namespace dependent_classes {
+template 
+struct conditional;
+
+template 
+struct conditional { typedef X type; };
+
+template 
+struct conditional { typedef Y type; };
+
+template struct X {
+  X();
+
+  // B == false triggers error for = default.
+  using T = typename conditional::type;
+  X(T) = default;  // expected-error {{only special member functions}}
+
+  // Either value of B creates a constructor that can be default
+  using U = typename conditional::type;
+  X(U) = default;
+};
+
+X x1;
+X x2; // expected-note {{in instantiation}}
+
 }


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


r282556 - P0145R3 (C++17 evaluation order tweaks): evaluate the right-hand side of

2016-09-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Sep 27 18:44:22 2016
New Revision: 282556

URL: http://llvm.org/viewvc/llvm-project?rev=282556=rev
Log:
P0145R3 (C++17 evaluation order tweaks): evaluate the right-hand side of
assignment and compound-assignment operators before the left-hand side. (Even
if it's an overloaded operator.)

This completes the implementation of P0145R3 + P0400R0 for all targets except
Windows, where the evaluation order guarantees for <<, >>, and ->* are
unimplementable as the ABI requires the function arguments are evaluated from
right to left (because parameter destructors are run from left to right in the
callee).

Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/cxx1z-eval-order.cpp
cfe/trunk/test/CodeGenObjCXX/property-object-reference-2.mm
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=282556=282555=282556=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Tue Sep 27 18:44:22 2016
@@ -76,6 +76,16 @@ public:
   /// expression refers to.
   OverloadedOperatorKind getOperator() const { return Operator; }
 
+  static bool isAssignmentOp(OverloadedOperatorKind Opc) {
+return Opc == OO_Equal || Opc == OO_StarEqual ||
+   Opc == OO_SlashEqual || Opc == OO_PercentEqual ||
+   Opc == OO_PlusEqual || Opc == OO_MinusEqual ||
+   Opc == OO_LessLessEqual || Opc == OO_GreaterGreaterEqual ||
+   Opc == OO_AmpEqual || Opc == OO_CaretEqual ||
+   Opc == OO_PipeEqual;
+  }
+  bool isAssignmentOp() const { return isAssignmentOp(getOperator()); }
+
   /// \brief Returns the location of the operator symbol in the expression.
   ///
   /// When \c getOperator()==OO_Call, this is the location of the right

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=282556=282555=282556=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Sep 27 18:44:22 2016
@@ -3172,7 +3172,8 @@ void CodeGenFunction::EmitNonNullArgChec
 void CodeGenFunction::EmitCallArgs(
 CallArgList , ArrayRef ArgTypes,
 llvm::iterator_range ArgRange,
-const FunctionDecl *CalleeDecl, unsigned ParamsToSkip) {
+const FunctionDecl *CalleeDecl, unsigned ParamsToSkip,
+bool ForceRightToLeftEvaluation) {
   assert((int)ArgTypes.size() == (ArgRange.end() - ArgRange.begin()));
 
   auto MaybeEmitImplicitObjectSize = [&](unsigned I, const Expr *Arg) {
@@ -3191,7 +3192,8 @@ void CodeGenFunction::EmitCallArgs(
 
   // We *have* to evaluate arguments from right to left in the MS C++ ABI,
   // because arguments are destroyed left to right in the callee.
-  if (CGM.getTarget().getCXXABI().areArgsDestroyedLeftToRightInCallee()) {
+  if (CGM.getTarget().getCXXABI().areArgsDestroyedLeftToRightInCallee() ||
+  ForceRightToLeftEvaluation) {
 // Insert a stack save if we're going to need any inalloca args.
 bool HasInAllocaArgs = false;
 for (ArrayRef::iterator I = ArgTypes.begin(), E = ArgTypes.end();

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=282556=282555=282556=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Sep 27 18:44:22 2016
@@ -4121,8 +4121,17 @@ RValue CodeGenFunction::EmitCall(QualTyp
   if (Chain)
 Args.add(RValue::get(Builder.CreateBitCast(Chain, CGM.VoidPtrTy)),
  CGM.getContext().VoidPtrTy);
+
+  // C++17 requires that we evaluate arguments to a call using assignment 
syntax
+  // right-to-left. It also requires that we evaluate arguments to operators
+  // <<, >>, and ->* left-to-right, but that is not possible under the MS ABI,
+  // so there is no corresponding "force left-to-right" case.
+  bool ForceRightToLeft = false;
+  if (auto *OCE = dyn_cast(E))
+ForceRightToLeft = OCE->isAssignmentOp();
+
   EmitCallArgs(Args, dyn_cast(FnType), E->arguments(),
-   E->getDirectCallee(), /*ParamsToSkip*/ 0);
+   E->getDirectCallee(), /*ParamsToSkip*/ 0, ForceRightToLeft);
 
   const CGFunctionInfo  = CGM.getTypes().arrangeFreeFunctionCall(
   Args, FnType, /*isChainCall=*/Chain);

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=282556=282555=282556=diff

Re: [PATCH] D24373: [Coroutines] Adding builtins for coroutine intrinsics and backendutil support.

2016-09-27 Thread Gor Nishanov via cfe-commits
GorNishanov marked an inline comment as done.


Comment at: include/clang/Basic/Builtins.def:1293
@@ +1292,3 @@
+
+BUILTIN(__builtin_coro_id, "v*Iiv*v*v*", "n")
+BUILTIN(__builtin_coro_alloc, "bv*", "n")

rsmith wrote:
> I don't really like having builtins which will result in errors from the 
> middle-end in some cases; there are a bunch of side-conditions on 
> llvm.coro.id that aren't being enforced here. In particular, this call must 
> be present in any function that also calls coro.alloc and friends, and must 
> dominate those other calls.
> 
> Modeling the 'token' value as a `void*` also seems problematic. If the user 
> uses that value for anything other than the argument to a builtin that wants 
> the token, bad things are going to happen.
> 
> (From dinner discussion:) one possible way to deal with this would be to 
> generate the call to @llvm.coro.id implicitly in the entry block, in a 
> function that uses the other builtins. The challenge then is communicating 
> the promise object to the intrinsic, which is problematic if we allow an 
> arbitrary pointer value to be passed in.
> 
> However, we're only interested in supporting a stack variable as the promise 
> object, so here's one possible approach:
> 
> - add an attribute that can be applied to a local variable to mark it as the 
> promise object for the current function
> - remove the `__builtin_coro_id` builtin, and instead implicitly generate the 
> `llvm.coro.id` intrinsic call in the entry block when we need its token or 
> see a promise object
> - when we emit a local variable with the promise-object attribute, update the 
> `llvm.coro.id` call to pass its alloca as the promise object
> - remove the 'token' parameter from `__builtin_coro_alloc` etc, and instead 
> implicitly provide it from the result of the implicit `llvm.coro.id` call
I added clarification to the documentation that all but four builtins are for 
internal compiler use and for the use as development tools for the coroutine 
feature, so, possibly we should not worry too much about people misusing them.

Alternatively, I can get rid of most of the coroutine builtins, apart from the 
ones that are intended to be used to implement coroutine standard library 
facilities.

At the moment, I think, we should prioritize getting C++ Coroutines online. We 
can polish C coroutine story later.


Comment at: test/Coroutines/coro.c:1
@@ +1,2 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines -emit-llvm %s 
-o - -O3 | FileCheck %s
+#include "Inputs/coro.h"

rsmith wrote:
> Please just check the IR generated by the frontend is correct for each of the 
> intrinsics rather than using an end-to-end test that depends on the LLVM IR 
> optimizations. You can use `-disable-llvm-optzns` to see the IR coming out of 
> clang before the mandatory coroutine passes monkey with it.
I added two tests to check that builtins are lowered to coro intrinsics 
correctly. I would like to keep a small number of "-O2" tests as a sanity 
end-to-end testing. 


https://reviews.llvm.org/D24373



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


Re: [PATCH] D24373: [Coroutines] Adding builtins for coroutine intrinsics and backendutil support.

2016-09-27 Thread Gor Nishanov via cfe-commits
GorNishanov updated the summary for this revision.
GorNishanov removed a reviewer: majnemer.
GorNishanov updated this revision to Diff 72732.
GorNishanov added a comment.
Herald added a subscriber: mgorny.

1. Added documentation for builtins
2. Added a couple of tests with -disable-llvm-passes to check that builtins are 
emitted correctly


https://reviews.llvm.org/D24373

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/Builtins.def
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCoroutine.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCoroutines/Inputs/coro.h
  test/CodeGenCoroutines/O2-coro.c
  test/CodeGenCoroutines/coro-builtins-err.c
  test/CodeGenCoroutines/coro-builtins.c

Index: test/CodeGenCoroutines/coro-builtins.c
===
--- /dev/null
+++ test/CodeGenCoroutines/coro-builtins.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc18.0.0 -fcoroutines -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
+
+// CHECK-LABEL: f( 
+void f() {
+  // CHECK: %0 = call token @llvm.coro.id(i32 32, i8* null, i8* null, i8* null)
+  __builtin_coro_id(32, 0, 0, 0);
+  // CHECK-NEXT: %1 = call i1 @llvm.coro.alloc(token %0)
+  __builtin_coro_alloc();
+  // CHECK-NEXT: %2 = call i64 @llvm.coro.size.i64()
+  __builtin_coro_size();
+  // CHECK-NEXT: %3 = call i8* @llvm.coro.begin(token %0, i8* null)
+  __builtin_coro_begin(0);
+  // CHECK-NEXT: %4 = call i8* @llvm.coro.frame() 
+  __builtin_coro_frame();
+  // CHECK-NEXT: call void @llvm.coro.resume(i8* null)
+  __builtin_coro_resume(0);
+  // CHECK-NEXT: call void @llvm.coro.destroy(i8* null)
+  __builtin_coro_destroy(0);
+  // CHECK-NEXT: %5 = call i1 @llvm.coro.done(i8* null)
+  __builtin_coro_done(0);
+  // CHECK-NEXT: %6 = call i8* @llvm.coro.promise(i8* null, i32 32, i1 false)
+  __builtin_coro_promise(0, 32, 0);
+  // CHECK-NEXT: %7 = call i8* @llvm.coro.free(token %0, i8* null)
+  __builtin_coro_free(0);
+  // CHECK-NEXT: call void @llvm.coro.end(i8* null, i1 false)
+  __builtin_coro_end(0, 0);
+  // CHECK-NEXT: %8 = call i8 @llvm.coro.suspend(token none, i1 false)
+  __builtin_coro_suspend(0);
+  // CHECK-NEXT: %9 = call i1 @llvm.coro.param(i8* null, i8* null)
+  __builtin_coro_param(0, 0);
+}
Index: test/CodeGenCoroutines/coro-builtins-err.c
===
--- /dev/null
+++ test/CodeGenCoroutines/coro-builtins-err.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc18.0.0 -fcoroutines -emit-llvm %s -o - -verify
+
+void f() {
+  __builtin_coro_alloc(); // expected-error {{this builtin expect that __builtin_coro_id}}
+  __builtin_coro_begin(0); // expected-error {{this builtin expect that __builtin_coro_id}}
+  __builtin_coro_free(0); // expected-error {{this builtin expect that __builtin_coro_id}}
+
+  __builtin_coro_id(32, 0, 0, 0);
+  __builtin_coro_id(32, 0, 0, 0); // expected-error {{only one __builtin_coro_id}}
+}
Index: test/CodeGenCoroutines/O2-coro.c
===
--- /dev/null
+++ test/CodeGenCoroutines/O2-coro.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines -emit-llvm %s -o - -O3 | FileCheck %s
+#include "Inputs/coro.h"
+void print(int);
+
+void* f() {
+  CORO_BEGIN(malloc);
+
+  for (int i = 0;; ++i) {
+print(i);
+CORO_SUSPEND();
+  }
+
+  CORO_END(free);
+}
+
+// CHECK-LABEL: @main
+int main() {
+  void* coro = f();
+  CORO_RESUME(coro);
+  CORO_RESUME(coro);
+  CORO_DESTROY(coro);
+// CHECK: call void @print(i32 0)
+// CHECK: call void @print(i32 1)
+// CHECK: call void @print(i32 2)
+}
Index: test/CodeGenCoroutines/Inputs/coro.h
===
--- /dev/null
+++ test/CodeGenCoroutines/Inputs/coro.h
@@ -0,0 +1,37 @@
+void free(void *ptr);
+void *malloc(unsigned int);
+
+#define CORO_SUSPEND_IMPL(IsFinal) \
+  switch (__builtin_coro_suspend(IsFinal)) {   \
+  case 0:  \
+if (IsFinal)   \
+  __builtin_trap();\
+break; \
+  case 1:  \
+goto coro_Cleanup; \
+  default: \
+goto coro_Suspend; \
+  }
+
+#define CORO_SUSPEND() CORO_SUSPEND_IMPL(0)
+#define CORO_FINAL_SUSPEND() CORO_SUSPEND_IMPL(1)
+
+#define CORO_BEGIN(AllocFunc)  \
+  void *coro_hdl = 

Re: [PATCH] D24981: [Coverage] The coverage region for a switch should cover the code after the switch

2016-09-27 Thread Alex Lorenz via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282554: [Coverage] The coverage region for switch covers the 
code after the switch. (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D24981?vs=72692=72733#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24981

Files:
  cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
  cfe/trunk/test/CoverageMapping/switch.c
  cfe/trunk/test/CoverageMapping/switchmacro.c

Index: cfe/trunk/test/CoverageMapping/switch.c
===
--- cfe/trunk/test/CoverageMapping/switch.c
+++ cfe/trunk/test/CoverageMapping/switch.c
@@ -1,44 +1,44 @@
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name switch.c %s | FileCheck %s
 // CHECK: foo
 void foo(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+5]]:4 = #1
+  switch(i) {
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #2
 return;
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
 break;
   }
-  int x = 0;
+  int x = 0;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
 }
 
 void nop() {}
 
 // CHECK: bar
 void bar(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+20]]:2 = #0
-  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:6 = #1
+  switch (i)
 ;   // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:6 = 0
 
-  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:4 = #2
+  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+16]]:2 = #1
   }
 
-  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
+  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+13]]:2 = #2
 nop();  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:10 = 0
 
-  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #4
+  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+10]]:2 = #3
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #5
 nop();
 
-  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:4 = #6
+  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:2 = #4
 nop();  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:10 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #7
 nop();
   }
-  nop();
+  nop();// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #6
 }
 
 // CHECK-NEXT: main
 int main() {// CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+34]]:2 = #0
   int i = 0;
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+9]]:4 = #1
+  switch(i) {
   case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+7]]:10 = #2
 i = 1;
 break;
@@ -48,7 +48,7 @@
   default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #4
 break;
   }
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+8]]:4 = #5
+  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+22]]:2 = #1
   case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:10 = #6
 i = 1;
 break;
@@ -58,16 +58,16 @@
 break;
   }
 
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+7]]:4 = #9
+  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+12]]:2 = #5
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+5]]:11 = #10
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:11 = (#10 + #11)
 i = 11;
   case 3:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:11 = ((#10 + #11) + #12)
   case 4:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11 = (((#10 + #11) + #12) + #13)
 i = 99;
   }
 
-  foo(1);
+  foo(1);   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:11 = #9
   bar(1);
   return 0;
 }
Index: cfe/trunk/test/CoverageMapping/switchmacro.c
===
--- cfe/trunk/test/CoverageMapping/switchmacro.c
+++ cfe/trunk/test/CoverageMapping/switchmacro.c
@@ -4,7 +4,7 @@
 
 // CHECK: foo
 int foo(int i) { // CHECK-NEXT: File 0, [[@LINE]]:16 -> {{[0-9]+}}:2 = #0
-  switch (i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> {{[0-9]+}}:4 = #1
+  switch (i) {
   default:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> {{[0-9]+}}:11 = #2
 if (i == 1)  // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:15 = #2
   return 0;  // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:15 = #3
Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
===
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
@@ 

r282554 - [Coverage] The coverage region for switch covers the code after the switch.

2016-09-27 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Sep 27 18:30:36 2016
New Revision: 282554

URL: http://llvm.org/viewvc/llvm-project?rev=282554=rev
Log:
[Coverage] The coverage region for switch covers the code after the switch.

This patch fixes a regression introduced in r262697 that changed the way the
coverage regions for switches are constructed. The PGO instrumentation counter
for a switch statement refers to the counter at the exit of the switch.
Therefore, the coverage region for the switch statement should cover the code
that comes after the switch, and not the switch statement itself.

rdar://28480997

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

Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/test/CoverageMapping/switch.c
cfe/trunk/test/CoverageMapping/switchmacro.c

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=282554=282553=282554=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Tue Sep 27 18:30:36 2016
@@ -842,7 +842,11 @@ struct CounterCoverageMappingBuilder
 
 Counter ExitCount = getRegionCounter(S);
 SourceLocation ExitLoc = getEnd(S);
-pushRegion(ExitCount, getStart(S), ExitLoc);
+pushRegion(ExitCount);
+
+// Ensure that handleFileExit recognizes when the end location is located
+// in a different file.
+MostRecentLocation = getStart(S);
 handleFileExit(ExitLoc);
   }
 

Modified: cfe/trunk/test/CoverageMapping/switch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/switch.c?rev=282554=282553=282554=diff
==
--- cfe/trunk/test/CoverageMapping/switch.c (original)
+++ cfe/trunk/test/CoverageMapping/switch.c Tue Sep 27 18:30:36 2016
@@ -1,44 +1,44 @@
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name switch.c %s | FileCheck 
%s
 // CHECK: foo
 void foo(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+5]]:4 = #1
+  switch(i) {
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #2
 return;
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
 break;
   }
-  int x = 0;
+  int x = 0;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
 }
 
 void nop() {}
 
 // CHECK: bar
 void bar(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+20]]:2 = #0
-  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:6 = #1
+  switch (i)
 ;   // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:6 = 0
 
-  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:4 = #2
+  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+16]]:2 = #1
   }
 
-  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
+  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+13]]:2 = #2
 nop();  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:10 = 0
 
-  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #4
+  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+10]]:2 = #3
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #5
 nop();
 
-  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:4 = #6
+  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:2 = #4
 nop();  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:10 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #7
 nop();
   }
-  nop();
+  nop();// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #6
 }
 
 // CHECK-NEXT: main
 int main() {// CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+34]]:2 = #0
   int i = 0;
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+9]]:4 = #1
+  switch(i) {
   case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+7]]:10 = #2
 i = 1;
 break;
@@ -48,7 +48,7 @@ int main() {// CHECK-NEXT: File
   default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #4
 break;
   }
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+8]]:4 = #5
+  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+22]]:2 = #1
   case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:10 = #6
 i = 1;
 break;
@@ -58,7 +58,7 @@ int main() {// CHECK-NEXT: File
 break;
   }
 
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+7]]:4 = #9
+  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+12]]:2 = #5
   case 1:  

Re: [PATCH] D24682: [PR30341] Alias must point to a definition

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


Comment at: clang/lib/CodeGen/CGCXX.cpp:137-138
@@ -136,1 +136,4 @@
 
+  // Disallow aliases to available_externally because available_externally
+  // will not be there in the end to allow the creation of the alias (PR30341).
+  // FIXME: An extern template instantiation will create functions with

Instead of this, I'd just say:

> available_externally definitions aren't real definitions, so we cannot create 
> an alias to one.

or similar. It doesn't seem necessary or relevant to reference a particular PR 
here.


Comment at: clang/lib/CodeGen/CGCXX.cpp:140-142
@@ +139,5 @@
+  // FIXME: An extern template instantiation will create functions with
+  // linkage "AvailableExternally". In libc++, some classes also define
+  // members with attribute "AlwaysInline" and expect no reference to
+  // be generated. It is desirable to reenable this optimisation after
+  // corresponding LLVM changes.

It's not clear what this comment about `AlwaysInline` is referring to, since 
the code does not mention that.


Comment at: clang/lib/CodeGen/CGCXX.cpp:142-143
@@ +141,4 @@
+  // members with attribute "AlwaysInline" and expect no reference to
+  // be generated. It is desirable to reenable this optimisation after
+  // corresponding LLVM changes.
+  if (TargetLinkage == llvm::GlobalValue::AvailableExternallyLinkage)

What "corresponding LLVM changes" are you expecting here? It seems to be 
fundamental to aliases that they can only denote definitions.


Comment at: clang/lib/CodeGen/CGCXX.cpp:170
@@ -159,9 +169,3 @@
   if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
- (TargetLinkage != llvm::GlobalValue::AvailableExternallyLinkage ||
-  !TargetDecl.getDecl()->hasAttr())) {
-// FIXME: An extern template instantiation will create functions with
-// linkage "AvailableExternally". In libc++, some classes also define
-// members with attribute "AlwaysInline" and expect no reference to
-// be generated. It is desirable to reenable this optimisation after
-// corresponding LLVM changes.
+  !TargetDecl.getDecl()->hasAttr()) {
 addReplacement(MangledName, Aliasee);

Did you mean to change the behavior here? For non-`available_externally` 
functions, we never used to care whether they're `always_inline`. Why do we 
care now?


https://reviews.llvm.org/D24682



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


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

2016-09-27 Thread Kevin Hu via cfe-commits
hxy9243 created this revision.
hxy9243 added reviewers: sebpop, hiraditya, wmi.
hxy9243 added a subscriber: cfe-commits.
hxy9243 set the repository for this revision to rL LLVM.

This patch moves some existing functions from the memory.cpp to the memory 
header file, so that they could be properly inlined, which gives potential 
optimization opportunities and performance benefits.

Repository:
  rL LLVM

https://reviews.llvm.org/D24991

Files:
  libcxx/include/atomic_support.h
  libcxx/include/memory
  libcxx/src/include/atomic_support.h
  libcxx/src/memory.cpp
  libcxx/src/mutex.cpp

Index: libcxx/src/mutex.cpp
===
--- libcxx/src/mutex.cpp
+++ libcxx/src/mutex.cpp
@@ -12,7 +12,7 @@
 #include "limits"
 #include "system_error"
 #include "cassert"
-#include "include/atomic_support.h"
+#include "atomic_support.h"
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 #ifndef _LIBCPP_HAS_NO_THREADS
Index: libcxx/src/memory.cpp
===
--- libcxx/src/memory.cpp
+++ libcxx/src/memory.cpp
@@ -13,85 +13,17 @@
 #include "mutex"
 #include "thread"
 #endif
-#include "include/atomic_support.h"
+#include "atomic_support.h"
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-namespace
-{
-
-// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
-// should be sufficient for thread safety.
-// See https://llvm.org/bugs/show_bug.cgi?id=22803
-template 
-inline T
-increment(T& t) _NOEXCEPT
-{
-return __libcpp_atomic_add(, 1, _AO_Relaxed);
-}
-
-template 
-inline T
-decrement(T& t) _NOEXCEPT
-{
-return __libcpp_atomic_add(, -1, _AO_Acq_Rel);
-}
-
-}  // namespace
-
 const allocator_arg_t allocator_arg = allocator_arg_t();
 
 bad_weak_ptr::~bad_weak_ptr() _NOEXCEPT {}
 
-const char*
-bad_weak_ptr::what() const _NOEXCEPT
-{
-return "bad_weak_ptr";
-}
+__shared_count::~__shared_count() {}
 
-__shared_count::~__shared_count()
-{
-}
-
-void
-__shared_count::__add_shared() _NOEXCEPT
-{
-increment(__shared_owners_);
-}
-
-bool
-__shared_count::__release_shared() _NOEXCEPT
-{
-if (decrement(__shared_owners_) == -1)
-{
-__on_zero_shared();
-return true;
-}
-return false;
-}
-
-__shared_weak_count::~__shared_weak_count()
-{
-}
-
-void
-__shared_weak_count::__add_shared() _NOEXCEPT
-{
-__shared_count::__add_shared();
-}
-
-void
-__shared_weak_count::__add_weak() _NOEXCEPT
-{
-increment(__shared_weak_owners_);
-}
-
-void
-__shared_weak_count::__release_shared() _NOEXCEPT
-{
-if (__shared_count::__release_shared())
-__release_weak();
-}
+__shared_weak_count::~__shared_weak_count() {}
 
 void
 __shared_weak_count::__release_weak() _NOEXCEPT
Index: libcxx/src/include/atomic_support.h
===
--- libcxx/src/include/atomic_support.h
+++ /dev/null
@@ -1,158 +0,0 @@
-//===--===
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===
-
-#ifndef ATOMIC_SUPPORT_H
-#define ATOMIC_SUPPORT_H
-
-#include "__config"
-#include "memory" // for __libcpp_relaxed_load
-
-#if defined(__clang__) && __has_builtin(__atomic_load_n) \
-   && __has_builtin(__atomic_store_n)\
-   && __has_builtin(__atomic_add_fetch)  \
-   && __has_builtin(__atomic_compare_exchange_n) \
-   && defined(__ATOMIC_RELAXED)  \
-   && defined(__ATOMIC_CONSUME)  \
-   && defined(__ATOMIC_ACQUIRE)  \
-   && defined(__ATOMIC_RELEASE)  \
-   && defined(__ATOMIC_ACQ_REL)  \
-   && defined(__ATOMIC_SEQ_CST)
-#   define _LIBCPP_HAS_ATOMIC_BUILTINS
-#elif !defined(__clang__) && defined(_GNUC_VER) && _GNUC_VER >= 407
-#   define _LIBCPP_HAS_ATOMIC_BUILTINS
-#endif
-
-#if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
-# if defined(_MSC_VER) && !defined(__clang__)
-_LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported")
-# else
-#   warning Building libc++ without __atomic builtins is unsupported
-# endif
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-namespace {
-
-#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
-
-enum __libcpp_atomic_order {
-_AO_Relaxed = __ATOMIC_RELAXED,
-_AO_Consume = __ATOMIC_CONSUME,
-_AO_Acquire = __ATOMIC_ACQUIRE,
-_AO_Release = __ATOMIC_RELEASE,
-_AO_Acq_Rel = __ATOMIC_ACQ_REL,
-_AO_Seq = __ATOMIC_SEQ_CST
-};
-
-template 
-inline 

Re: r282547 - Fix defaulted member functions for templated classes.

2016-09-27 Thread Richard Smith via cfe-commits
It looks like this will reject valid code, such as:

template struct X {
  using T = typename std::conditional::type;
  X();
  X(T) = default; // either copyable or moveable, depending on B
};

On Tue, Sep 27, 2016 at 3:28 PM, Richard Trieu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rtrieu
> Date: Tue Sep 27 17:28:59 2016
> New Revision: 282547
>
> URL: http://llvm.org/viewvc/llvm-project?rev=282547=rev
> Log:
> Fix defaulted member functions for templated classes.
>
> In some cases, non-special member functions were being marked as being
> defaulted
> in templated classes.  This can cause interactions with later code that
> expects
> the default function to be one of the specific member functions.


If later code is assuming that a defaulted member of a dependent class is a
specific special member function, it is wrong; we should put the fix there
instead of here.


> Fix the check
> so that templated class members are checked the same way as non-templated
> class
> members are.
>
> Modified:
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaDeclCXX.cpp?rev=282547=282546=282547=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Sep 27 17:28:59 2016
> @@ -13850,12 +13850,6 @@ void Sema::SetDeclDefaulted(Decl *Dcl, S
>CXXMethodDecl *MD = dyn_cast_or_null(Dcl);
>
>if (MD) {
> -if (MD->getParent()->isDependentType()) {
> -  MD->setDefaulted();
> -  MD->setExplicitlyDefaulted();
> -  return;
> -}
> -
>  CXXSpecialMember Member = getSpecialMember(MD);
>  if (Member == CXXInvalid) {
>if (!MD->isInvalidDecl())
> @@ -13866,6 +13860,8 @@ void Sema::SetDeclDefaulted(Decl *Dcl, S
>  MD->setDefaulted();
>  MD->setExplicitlyDefaulted();
>
> +if (MD->getParent()->isDependentType()) return;
> +
>  // If this definition appears within the record, do the checking when
>  // the record is complete.
>  const FunctionDecl *Primary = MD;
>
> Modified: cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/cxx0x-defaulted-functions.cpp?rev=282547=
> 282546=282547=diff
> 
> ==
> --- cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp (original)
> +++ cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp Tue Sep 27
> 17:28:59 2016
> @@ -208,3 +208,31 @@ int fn() {
>t = true;
>  }
>  }
> +
> +namespace templated_class {
> +template 
> +class X {
> +X() = default;
> +X(const X&) = default;
> +X(X&&) = default;
> +X =(const X&) = default;
> +X =(X&&) = default;
> +~X() = default;
> +
> +X(T) = default;  // expected-error {{only special member functions
> may be defaulted}}
> +void Run() = default;  // expected-error {{only special member
> functions may be defaulted}}
> +
> +  };
> +  template 
> +  X::X() = default; // expected-error {{definition of explicitly
> defaulted}}
> +  template 
> +  X::X(const X&) = default; // expected-error {{definition of
> explicitly defaulted}}
> +  template 
> +  X::X(X&&) = default; // expected-error {{definition of explicitly
> defaulted}}
> +  template 
> +  X ::operator=(const X&) = default; // expected-error
> {{definition of explicitly defaulted}}
> +  template 
> +  X ::operator=(X&&) = default; // expected-error {{definition
> of explicitly defaulted}}
> +  template 
> +  X::~X() = default; // expected-error {{definition of explicitly
> defaulted}}
> +}
>
>
> ___
> 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] D24975: [CUDA] Add #pragma clang force_cuda_host_device_{begin, end} pragmas.

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

Please add serialisation code for the push count for PCH. Should it be an error 
if the count is nonzero at the end of the TU?

What happens if there are trailing tokens after the pragma?



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1027
@@ +1026,3 @@
+def warn_pragma_force_cuda_host_device_bad_arg : Warning<
+  "Incorrect use of #pragma clang force_cuda_host_device begin|end">;
+

Diagnostics should start with a lowercase letter.


Comment at: clang/test/Parser/cuda-force-host-device-templates.cu:8
@@ +7,3 @@
+template 
+T foo() {  // expected-note {{declared here}}
+  return T();

You need this to return `auto` to trigger the eager instantiation codepath I 
was concerned about.


https://reviews.llvm.org/D24975



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


Re: [PATCH] D10370: clang-format: Implement AlwaysBreakAfterDeclarationReturnType.

2016-09-27 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko closed this revision.
Eugene.Zelenko added a comment.

Committed in https://reviews.llvm.org/rL256046.


https://reviews.llvm.org/D10370



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


r282547 - Fix defaulted member functions for templated classes.

2016-09-27 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Sep 27 17:28:59 2016
New Revision: 282547

URL: http://llvm.org/viewvc/llvm-project?rev=282547=rev
Log:
Fix defaulted member functions for templated classes.

In some cases, non-special member functions were being marked as being defaulted
in templated classes.  This can cause interactions with later code that expects
the default function to be one of the specific member functions.  Fix the check
so that templated class members are checked the same way as non-templated class
members are.

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=282547=282546=282547=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Sep 27 17:28:59 2016
@@ -13850,12 +13850,6 @@ void Sema::SetDeclDefaulted(Decl *Dcl, S
   CXXMethodDecl *MD = dyn_cast_or_null(Dcl);
 
   if (MD) {
-if (MD->getParent()->isDependentType()) {
-  MD->setDefaulted();
-  MD->setExplicitlyDefaulted();
-  return;
-}
-
 CXXSpecialMember Member = getSpecialMember(MD);
 if (Member == CXXInvalid) {
   if (!MD->isInvalidDecl())
@@ -13866,6 +13860,8 @@ void Sema::SetDeclDefaulted(Decl *Dcl, S
 MD->setDefaulted();
 MD->setExplicitlyDefaulted();
 
+if (MD->getParent()->isDependentType()) return;
+
 // If this definition appears within the record, do the checking when
 // the record is complete.
 const FunctionDecl *Primary = MD;

Modified: cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp?rev=282547=282546=282547=diff
==
--- cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp Tue Sep 27 17:28:59 
2016
@@ -208,3 +208,31 @@ int fn() {
   t = true;
 }
 }
+
+namespace templated_class {
+template 
+class X {
+X() = default;
+X(const X&) = default;
+X(X&&) = default;
+X =(const X&) = default;
+X =(X&&) = default;
+~X() = default;
+
+X(T) = default;  // expected-error {{only special member functions may be 
defaulted}}
+void Run() = default;  // expected-error {{only special member functions 
may be defaulted}}
+
+  };
+  template 
+  X::X() = default; // expected-error {{definition of explicitly defaulted}}
+  template 
+  X::X(const X&) = default; // expected-error {{definition of explicitly 
defaulted}}
+  template 
+  X::X(X&&) = default; // expected-error {{definition of explicitly 
defaulted}}
+  template 
+  X ::operator=(const X&) = default; // expected-error {{definition 
of explicitly defaulted}}
+  template 
+  X ::operator=(X&&) = default; // expected-error {{definition of 
explicitly defaulted}}
+  template 
+  X::~X() = default; // expected-error {{definition of explicitly 
defaulted}}
+}


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


r282545 - Shorten DiagnosticInfoOptimizationRemark* to OptimizationRemark*. NFC

2016-09-27 Thread Adam Nemet via cfe-commits
Author: anemet
Date: Tue Sep 27 17:19:29 2016
New Revision: 282545

URL: http://llvm.org/viewvc/llvm-project?rev=282545=rev
Log:
Shorten DiagnosticInfoOptimizationRemark* to OptimizationRemark*. NFC

With the new streaming interface in LLVM, these class names need to be
typed a lot and it's way too looong.

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

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=282545=282544=282545=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Tue Sep 27 17:19:29 2016
@@ -260,16 +260,13 @@ namespace clang {
 /// them.
 void EmitOptimizationMessage(const llvm::DiagnosticInfoOptimizationBase ,
  unsigned DiagID);
-void
-OptimizationRemarkHandler(const llvm::DiagnosticInfoOptimizationRemark );
+void OptimizationRemarkHandler(const llvm::OptimizationRemark );
+void OptimizationRemarkHandler(const llvm::OptimizationRemarkMissed );
+void OptimizationRemarkHandler(const llvm::OptimizationRemarkAnalysis );
 void OptimizationRemarkHandler(
-const llvm::DiagnosticInfoOptimizationRemarkMissed );
+const llvm::OptimizationRemarkAnalysisFPCommute );
 void OptimizationRemarkHandler(
-const llvm::DiagnosticInfoOptimizationRemarkAnalysis );
-void OptimizationRemarkHandler(
-const llvm::DiagnosticInfoOptimizationRemarkAnalysisFPCommute );
-void OptimizationRemarkHandler(
-const llvm::DiagnosticInfoOptimizationRemarkAnalysisAliasing );
+const llvm::OptimizationRemarkAnalysisAliasing );
 void OptimizationFailureHandler(
 const llvm::DiagnosticInfoOptimizationFailure );
   };
@@ -533,7 +530,7 @@ void BackendConsumer::EmitOptimizationMe
 }
 
 void BackendConsumer::OptimizationRemarkHandler(
-const llvm::DiagnosticInfoOptimizationRemark ) {
+const llvm::OptimizationRemark ) {
   // Optimization remarks are active only if the -Rpass flag has a regular
   // expression that matches the name of the pass name in \p D.
   if (CodeGenOpts.OptimizationRemarkPattern &&
@@ -542,7 +539,7 @@ void BackendConsumer::OptimizationRemark
 }
 
 void BackendConsumer::OptimizationRemarkHandler(
-const llvm::DiagnosticInfoOptimizationRemarkMissed ) {
+const llvm::OptimizationRemarkMissed ) {
   // Missed optimization remarks are active only if the -Rpass-missed
   // flag has a regular expression that matches the name of the pass
   // name in \p D.
@@ -553,7 +550,7 @@ void BackendConsumer::OptimizationRemark
 }
 
 void BackendConsumer::OptimizationRemarkHandler(
-const llvm::DiagnosticInfoOptimizationRemarkAnalysis ) {
+const llvm::OptimizationRemarkAnalysis ) {
   // Optimization analysis remarks are active if the pass name is set to
   // llvm::DiagnosticInfo::AlwasyPrint or if the -Rpass-analysis flag has a
   // regular expression that matches the name of the pass name in \p D.
@@ -566,7 +563,7 @@ void BackendConsumer::OptimizationRemark
 }
 
 void BackendConsumer::OptimizationRemarkHandler(
-const llvm::DiagnosticInfoOptimizationRemarkAnalysisFPCommute ) {
+const llvm::OptimizationRemarkAnalysisFPCommute ) {
   // Optimization analysis remarks are active if the pass name is set to
   // llvm::DiagnosticInfo::AlwasyPrint or if the -Rpass-analysis flag has a
   // regular expression that matches the name of the pass name in \p D.
@@ -579,7 +576,7 @@ void BackendConsumer::OptimizationRemark
 }
 
 void BackendConsumer::OptimizationRemarkHandler(
-const llvm::DiagnosticInfoOptimizationRemarkAnalysisAliasing ) {
+const llvm::OptimizationRemarkAnalysisAliasing ) {
   // Optimization analysis remarks are active if the pass name is set to
   // llvm::DiagnosticInfo::AlwasyPrint or if the -Rpass-analysis flag has a
   // regular expression that matches the name of the pass name in \p D.
@@ -623,30 +620,27 @@ void BackendConsumer::DiagnosticHandlerI
   case llvm::DK_OptimizationRemark:
 // Optimization remarks are always handled completely by this
 // handler. There is no generic way of emitting them.
-OptimizationRemarkHandler(cast(DI));
+OptimizationRemarkHandler(cast(DI));
 return;
   case llvm::DK_OptimizationRemarkMissed:
 // Optimization remarks are always handled completely by this
 // handler. There is no generic way of emitting them.
-
OptimizationRemarkHandler(cast(DI));
+OptimizationRemarkHandler(cast(DI));
 return;
   case llvm::DK_OptimizationRemarkAnalysis:
 // Optimization remarks are always handled completely by this
 // handler. There is no generic way of emitting them.
-OptimizationRemarkHandler(
-cast(DI));
+OptimizationRemarkHandler(cast(DI));
 return;
   case llvm::DK_OptimizationRemarkAnalysisFPCommute:
 // Optimization remarks are 

Re: [PATCH] D11235: clang-format: Fix breaking before nested 'operator' in function declarations

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

Looks like patch was not committed.


https://reviews.llvm.org/D11235



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


Re: [PATCH] D24979: [CUDA] Support and std::min/max on the device.

2016-09-27 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 72719.
jlebar added a comment.
Herald added a subscriber: mehdi_amini.

s/libgcc/runtime/


https://reviews.llvm.org/D24979

Files:
  clang/lib/Driver/ToolChains.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_complex_builtins.h
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h
  clang/lib/Headers/cuda_wrappers/algorithm
  clang/lib/Headers/cuda_wrappers/complex

Index: clang/lib/Headers/cuda_wrappers/complex
===
--- /dev/null
+++ clang/lib/Headers/cuda_wrappers/complex
@@ -0,0 +1,79 @@
+/*=== complex - CUDA wrapper for  --===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+#pragma once
+
+// Wrapper around  that forces its functions to be __host__
+// __device__.
+
+// First, include host-only headers we think are likely to be included by
+// , so that the pragma below only applies to  itself.
+#if __cplusplus >= 201103L
+#include 
+#endif
+#include 
+#include 
+#include 
+
+// Next, include our  wrapper, to ensure that device overloads of
+// std::min/max are available.
+#include 
+
+#pragma clang force_cuda_host_device_begin
+
+// When compiling for device, ask libstdc++ to use its own implements of
+// complex functions, rather than calling builtins (which resolve to library
+// functions that don't exist when compiling CUDA device code).
+//
+// This is a little dicey, because it causes libstdc++ to define a different
+// set of overloads on host and device.
+//
+//   // Present only when compiling for host.
+//   __host__ __device__ void complex sin(const complex& x) {
+// return __builtin_csinf(x);
+//   }
+//
+//   // Present when compiling for host and for device.
+//   template 
+//   void __host__ __device__ complex sin(const complex& x) {
+// return complex(sin(x.real()) * cosh(x.imag()),
+//   cos(x.real()), sinh(x.imag()));
+//   }
+//
+// This is safe because when compiling for device, all function calls in
+// __host__ code to sin() will still resolve to *something*, even if they don't
+// resolve to the same function as they resolve to when compiling for host.  We
+// don't care that they don't resolve to the right function because we won't
+// codegen this host code when compiling for device.
+
+#pragma push_macro("_GLIBCXX_USE_C99_COMPLEX")
+#pragma push_macro("_GLIBCXX_USE_C99_COMPLEX_TR1")
+#define _GLIBCXX_USE_C99_COMPLEX 0
+#define _GLIBCXX_USE_C99_COMPLEX_TR1 0
+
+#include_next 
+
+#pragma pop_macro("_GLIBCXX_USE_C99_COMPLEX_TR1")
+#pragma pop_macro("_GLIBCXX_USE_C99_COMPLEX")
+
+#pragma clang force_cuda_host_device_end
Index: clang/lib/Headers/cuda_wrappers/algorithm
===
--- /dev/null
+++ clang/lib/Headers/cuda_wrappers/algorithm
@@ -0,0 +1,96 @@
+/*=== complex - CUDA wrapper for  ===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * 

Re: [PATCH] D24975: [CUDA] Add #pragma clang force_cuda_host_device_{begin, end} pragmas.

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

Address Richard Smith's review comments:

- Change macro format.
- Add tests (these Just Worked).


https://reviews.llvm.org/D24975

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/test/Parser/cuda-force-host-device-templates.cu
  clang/test/Parser/cuda-force-host-device.cu

Index: clang/test/Parser/cuda-force-host-device.cu
===
--- /dev/null
+++ clang/test/Parser/cuda-force-host-device.cu
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the force_cuda_host_device pragma.
+
+#pragma clang force_cuda_host_device begin
+void f();
+#pragma clang force_cuda_host_device begin
+void g();
+#pragma clang force_cuda_host_device end
+void h();
+#pragma clang force_cuda_host_device end
+
+void i(); // expected-note {{not viable}}
+
+void host() {
+  f();
+  g();
+  h();
+  i();
+}
+
+__attribute__((device)) void device() {
+  f();
+  g();
+  h();
+  i(); // expected-error {{no matching function}}
+}
+
+#pragma clang force_cuda_host_device foo
+// expected-warning@-1 {{Incorrect use of #pragma clang force_cuda_host_device begin|end}}
+
+#pragma clang force_cuda_host_device
+// expected-warning@-1 {{Incorrect use of #pragma clang force_cuda_host_device begin|end}}
Index: clang/test/Parser/cuda-force-host-device-templates.cu
===
--- /dev/null
+++ clang/test/Parser/cuda-force-host-device-templates.cu
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -S -verify -fcuda-is-device %s -o /dev/null
+
+// Check how the force_cuda_host_device pragma interacts with template
+// instantiations.  The errors here are emitted at codegen, so we can't do
+// -fsyntax-only.
+
+template 
+T foo() {  // expected-note {{declared here}}
+  return T();
+}
+
+template 
+struct X {
+  void foo(); // expected-note {{declared here}}
+};
+
+#pragma clang force_cuda_host_device begin
+__attribute__((host)) __attribute__((device)) void test() {
+  int n = foo();  // expected-error {{reference to __host__ function 'foo'}}
+  X().foo();  // expected-error {{reference to __host__ function 'foo'}}
+}
+#pragma clang force_cuda_host_device end
+
+// Same thing as above, but within a force_cuda_host_device block without a
+// corresponding end.
+
+template 
+T bar() {  // expected-note {{declared here}}
+  return T();
+}
+
+template 
+struct Y {
+  void bar(); // expected-note {{declared here}}
+};
+
+#pragma clang force_cuda_host_device begin
+__attribute__((host)) __attribute__((device)) void test2() {
+  int n = bar();  // expected-error {{reference to __host__ function 'bar'}}
+  Y().bar();  // expected-error {{reference to __host__ function 'bar'}}
+}
Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -23,6 +23,19 @@
 #include "llvm/ADT/SmallVector.h"
 using namespace clang;
 
+void Sema::PushForceCUDAHostDevice() {
+  assert(getLangOpts().CUDA && "May be called only for CUDA compilations.");
+  ForceCUDAHostDeviceDepth++;
+}
+
+bool Sema::PopForceCUDAHostDevice() {
+  assert(getLangOpts().CUDA && "May be called only for CUDA compilations.");
+  if (ForceCUDAHostDeviceDepth == 0)
+return false;
+  ForceCUDAHostDeviceDepth--;
+  return true;
+}
+
 ExprResult Sema::ActOnCUDAExecConfigExpr(Scope *S, SourceLocation oc,
  MultiExprArg ExecConfig,
  SourceLocation GGGLoc) {
@@ -441,9 +454,23 @@
 //  * a __device__ function with this signature was already declared, in which
 //case in which case we output an error, unless the __device__ decl is in a
 //system header, in which case we leave the constexpr function unattributed.
+//
+// In addition, all function decls are treated as __host__ __device__ when
+// ForceCUDAHostDeviceDepth > 0 (corresponding to code within a
+//   #pragma clang force_cuda_host_device_begin/end
+// pair).
 void Sema::maybeAddCUDAHostDeviceAttrs(Scope *S, FunctionDecl *NewD,
const LookupResult ) {
   assert(getLangOpts().CUDA && "May be called only for CUDA compilations.");
+
+  if (ForceCUDAHostDeviceDepth > 0) {
+if (!NewD->hasAttr())
+  NewD->addAttr(CUDAHostAttr::CreateImplicit(Context));
+if (!NewD->hasAttr())
+  NewD->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+return;
+  }
+
   if (!getLangOpts().CUDAHostDeviceConstexpr || !NewD->isConstexpr() ||
   NewD->isVariadic() || NewD->hasAttr() ||
   NewD->hasAttr() || NewD->hasAttr())
Index: clang/lib/Parse/ParsePragma.cpp
===
--- 

Re: [PATCH] D24861: [Sema] extend Wshift-op-parentheses so it warns for multiplicative operators

2016-09-27 Thread Joerg Sonnenberger via cfe-commits
joerg added a subscriber: joerg.
joerg added a comment.

I think the comment from Daniel shows the crux of the issue. A left shift is by 
nature a multiplication operation, so I don't see why it should get the 
warning. A right shift works like a division and order is quite significant for 
that.


Repository:
  rL LLVM

https://reviews.llvm.org/D24861



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


Re: [PATCH] D24372: [libcxx] Sprinkle constexpr over compressed_pair

2016-09-27 Thread Keno Fischer via cfe-commits
loladiro updated this revision to Diff 72712.
loladiro added a comment.

Some extra _AFTER_CXX11 that may be necessary - please double check me here, 
C++11 constexpr rules are not exactly my specialty ;).


Repository:
  rL LLVM

https://reviews.llvm.org/D24372

Files:
  include/memory
  test/std/utilities/memory/unique.ptr/unique.ptr.runtime/constinit.pass.cpp
  test/std/utilities/memory/unique.ptr/unique.ptr.single/constinit.pass.cpp

Index: test/std/utilities/memory/unique.ptr/unique.ptr.single/constinit.pass.cpp
===
--- /dev/null
+++ test/std/utilities/memory/unique.ptr/unique.ptr.single/constinit.pass.cpp
@@ -0,0 +1,70 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+#include 
+#include 
+
+#ifndef _LIBCPP_SAFE_STATIC
+#define _LIBCPP_SAFE_STATIC
+#endif
+
+// This is basically std::default delete, except that it is not empty such that
+// we test a different code path in the implementation
+template  struct nonempty_delete {
+  uint32_t sentinel;
+  inline constexpr nonempty_delete() noexcept : sentinel(0xDEADBEEF) {}
+  template 
+  constexpr inline nonempty_delete(
+  const nonempty_delete &,
+  typename std::enable_if::type * =
+  0) noexcept : sentinel(0xBAADF00D) {}
+  inline void operator()(Tp *ptr) const noexcept {
+assert(sentinel == 0xDEADBEEF || sentinel == 0xBAADF00D);
+delete ptr;
+  }
+};
+
+extern std::unique_ptr a;
+extern std::unique_ptr b;
+extern std::unique_ptr c;
+extern std::unique_ptr d;
+void *tramplea = std::memset(, 0xab, sizeof(a));
+void *trampleb = std::memset(, 0xab, sizeof(b));
+void *tramplec = std::memset(, 0xab, sizeof(c));
+void *trampled = std::memset(, 0xab, sizeof(d));
+_LIBCPP_SAFE_STATIC std::unique_ptr a;
+_LIBCPP_SAFE_STATIC std::unique_ptr b(nullptr);
+_LIBCPP_SAFE_STATIC std::unique_ptr c;
+_LIBCPP_SAFE_STATIC std::unique_ptr d(nullptr);
+
+int main() {
+  // Check that the initialization of 'a' was performed before the
+  // initialization of 'tramplea'.
+  for (size_t n = 0; n != sizeof(a); ++n)
+assert(reinterpret_cast(tramplea)[n] == 0xab);
+  // Check that the initialization of 'b' was performed before the
+  // initialization of 'trampleb'.
+  for (size_t n = 0; n != sizeof(b); ++n)
+assert(reinterpret_cast(trampleb)[n] == 0xab);
+  // Check that the initialization of 'c' was performed before the
+  // initialization of 'tramplec'.
+  for (size_t n = 0; n != sizeof(c); ++n)
+assert(reinterpret_cast(tramplec)[n] == 0xab);
+  // Check that the initialization of 'd' was performed before the
+  // initialization of 'trampled'.
+  for (size_t n = 0; n != sizeof(d); ++n)
+assert(reinterpret_cast(trampled)[n] == 0xab);
+  // Put a unique_ptr object back so that the global dtor is valid.
+  new () std::unique_ptr;
+  new () std::unique_ptr;
+  new () std::unique_ptr;
+  new () std::unique_ptr;
+}
Index: test/std/utilities/memory/unique.ptr/unique.ptr.runtime/constinit.pass.cpp
===
--- /dev/null
+++ test/std/utilities/memory/unique.ptr/unique.ptr.runtime/constinit.pass.cpp
@@ -0,0 +1,70 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+#include 
+#include 
+
+#ifndef _LIBCPP_SAFE_STATIC
+#define _LIBCPP_SAFE_STATIC
+#endif
+
+// This is basically std::default delete, except that it is not empty such that
+// we test a different code path in the implementation
+template  struct nonempty_delete {
+  uint32_t sentinel;
+  inline constexpr nonempty_delete() noexcept : sentinel(0xDEADBEEF) {}
+  template 
+  constexpr inline nonempty_delete(
+  const nonempty_delete &,
+  typename std::enable_if::type * =
+  0) noexcept : sentinel(0xBAADF00D) {}
+  inline void operator()(Tp *ptr) const noexcept {
+assert(sentinel == 0xDEADBEEF || sentinel == 0xBAADF00D);
+delete[] ptr;
+  }
+};
+
+extern std::unique_ptr a;
+extern std::unique_ptr b;
+extern std::unique_ptr c;
+extern std::unique_ptr d;
+void *tramplea = std::memset(, 0xab, sizeof(a));

Re: [PATCH] D24915: [analyzer] Extend bug reports with extra notes - ObjCDeallocChecker

2016-09-27 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 and Devin's comments have been addressed.


https://reviews.llvm.org/D24915



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


Re: [PATCH] D24986: Headers: Add iso_volatile load/store intrinsics

2016-09-27 Thread David Majnemer via cfe-commits
majnemer added a comment.

IMO, this should be implemented in clang CodeGen so that we don't get extra 
acquire/release barriers with /volatile:ms but that might be overkill; feel 
free to disregard this.


https://reviews.llvm.org/D24986



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


Re: [PATCH] D24372: [libcxx] Sprinkle constexpr over compressed_pair

2016-09-27 Thread Keno Fischer via cfe-commits
loladiro added a comment.

Before I commit this, I just realized

  __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& 
__p)
  _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
 is_nothrow_copy_assignable<_T2>::value)
  {
  _T1::operator=(__p.first());
  __second_ = __p.second();
  return *this;
  }

is only constexpr in C++14, right?


Repository:
  rL LLVM

https://reviews.llvm.org/D24372



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


Re: [PATCH] D24682: [PR30341] Alias must point to a definition

2016-09-27 Thread Aditya Kumar via cfe-commits
hiraditya added a comment.

ping!


https://reviews.llvm.org/D24682



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


Re: [PATCH] D24946: [CUDA] Added support for CUDA-8

2016-09-27 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 72707.
tra added a comment.

addressed Justin's comments.


https://reviews.llvm.org/D24946

Files:
  lib/Driver/ToolChains.cpp
  lib/Headers/__clang_cuda_runtime_wrapper.h
  
test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/libdevice.compute_20.10.bc
  
test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/libdevice.compute_30.10.bc
  
test/Driver/Inputs/CUDA_80/usr/local/cuda/nvvm/libdevice/libdevice.compute_50.10.bc
  test/Driver/cuda-detect.cu

Index: test/Driver/cuda-detect.cu
===
--- test/Driver/cuda-detect.cu
+++ test/Driver/cuda-detect.cu
@@ -22,13 +22,14 @@
 // RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON \
 // RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE20
-// sm_30, sm_5x and sm_6x map to compute_30
+// sm_30, sm_6x map to compute_30.
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_30 \
 // RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON \
 // RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE30
+// sm_5x is a special case. Maps to compute_30 for cuda-7.x only.
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_50 \
-// RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
+// RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON \
 // RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE30
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_60 \
@@ -44,6 +45,12 @@
 // RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix CUDAINC \
 // RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE35
+// sm_5x -> compute_50 for CUDA-8.0 and newer.
+// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_50 \
+// RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix COMMON \
+// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE50
+
 
 // Verify that -nocudainc prevents adding include path to CUDA headers.
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
@@ -56,8 +63,8 @@
 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC
 
 // Verify that we get an error if there's no libdevice library to link with.
-// NOTE: Inputs/CUDA deliberately does *not* have libdevice.compute_30  for this purpose.
-// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_30 \
+// NOTE: Inputs/CUDA deliberately does *not* have libdevice.compute_20  for this purpose.
+// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_20 \
 // RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix MISSINGLIBDEVICE
 
@@ -81,15 +88,16 @@
 // CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda
 // NOCUDA-NOT: Found CUDA installation:
 
-// MISSINGLIBDEVICE: error: cannot find libdevice for sm_30.
+// MISSINGLIBDEVICE: error: cannot find libdevice for sm_20.
 
 // COMMON: "-triple" "nvptx-nvidia-cuda"
 // COMMON-SAME: "-fcuda-is-device"
 // LIBDEVICE-SAME: "-mlink-cuda-bitcode"
 // NOLIBDEVICE-NOT: "-mlink-cuda-bitcode"
 // LIBDEVICE20-SAME: libdevice.compute_20.10.bc
 // LIBDEVICE30-SAME: libdevice.compute_30.10.bc
 // LIBDEVICE35-SAME: libdevice.compute_35.10.bc
+// LIBDEVICE50-SAME: libdevice.compute_50.10.bc
 // NOLIBDEVICE-NOT: libdevice.compute_{{.*}}.bc
 // LIBDEVICE-SAME: "-target-feature" "+ptx42"
 // NOLIBDEVICE-NOT: "-target-feature" "+ptx42"
Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -62,7 +62,7 @@
 #include "cuda.h"
 #if !defined(CUDA_VERSION)
 #error "cuda.h did not define CUDA_VERSION"
-#elif CUDA_VERSION < 7000 || CUDA_VERSION > 7050
+#elif CUDA_VERSION < 7000 || CUDA_VERSION > 8000
 #error "Unsupported CUDA version!"
 #endif
 
@@ -113,6 +113,7 @@
 #undef __cxa_vec_ctor
 #undef __cxa_vec_cctor
 #undef __cxa_vec_dtor
+#undef __cxa_vec_new
 #undef __cxa_vec_new2
 #undef __cxa_vec_new3
 #undef __cxa_vec_delete2
@@ -135,6 +136,21 @@
 // the headers we're about to include.
 #define __host__ UNEXPECTED_HOST_ATTRIBUTE
 
+// CUDA 8.0.41 relies on __USE_FAST_MATH__ and __CUDA_PREC_DIV's values.
+// Previous versions used to check whether they are defined or not.
+// CU_DEVICE_INVALID macro is only defined in 8.0.41, so we use it
+// here to detect the switch.
+
+#if defined(CU_DEVICE_INVALID)
+#if !defined(__USE_FAST_MATH__)
+#define __USE_FAST_MATH__ 0
+#endif
+
+#if !defined(__CUDA_PREC_DIV)
+#define __CUDA_PREC_DIV 0
+#endif
+#endif
+
 // device_functions.hpp and math_functions*.hpp use 'static
 // __forceinline__' 

Re: [PATCH] D24861: [Sema] extend Wshift-op-parentheses so it warns for multiplicative operators

2016-09-27 Thread David Blaikie via cfe-commits
I'd still wonder if this meets the bar for false positives (generally we
try to only add warnings that would be enabled by default, even in new
codebases - where most of what they find in a newcodebase are latent bugs,
not noise (so the cleanup is at least fairly justified as being beneficial
in itself rather than only as a means to enable the warning to catch some
bugs in the future))

But I know we made some exception for the &&/|| version of -Wparentheses,
so maybe this variation meets that same bar. (if Richard Trieu doesn't have
enough context to make that call, I'd probably rope in Richard Smith (&
possibly Chandler Carruth - I recall him commenting on the &&/||
-Wparentheses form on more than one occasion))

On Tue, Sep 27, 2016 at 10:01 AM Bruno Cardoso Lopes <
bruno.card...@gmail.com> wrote:

> bruno added a subscriber: bruno.
> bruno added a comment.
>
> Hi Daniel,
>
> This is very nice.
>
> In https://reviews.llvm.org/D24861#553606, @danielmarjamaki wrote:
>
> > Compiling 2064 projects resulted in 904 warnings
> >
> > Here are the results:
> >
> https://drive.google.com/file/d/0BykPmWrCOxt2N04tYl8zVHA3MXc/view?usp=sharing
> >
> > The results looks acceptable imho. The code looks intentional in many
> cases so I believe there are users that will disable this warning. Probably
> there are true positives where the evaluation order is not really known.
> There were many warnings about macro arguments where the macro bitshifts
> the argument - these macros look very shaky to me.
> >
> > I saw some warnings about such code:
> >
> >   a * b << c
> >
> >
> > Maybe we should not warn about this. As far as I see, the result will be
> the same if (a*b) or (b< overflow or signedness issues. What do you think? I'll keep these warnings
> for now.
>
>
> Any idea on how expensive would be to reason about these false positives
> and avoid them?
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D24861
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24946: [CUDA] Added support for CUDA-8

2016-09-27 Thread Artem Belevich via cfe-commits
tra marked an inline comment as done.


Comment at: lib/Headers/__clang_cuda_runtime_wrapper.h:156
@@ +155,3 @@
+#endif
+#endif
+

jlebar wrote:
> I don't understand what we are doing here...
> 
> We're saying, if __USE_FAST_MATH__ is defined, and if it's not equal to 0, 
> then redefine it equal to 1?  Isn't that a compile error?
Not if it happens in system headers.
That said, I can eliminate true branch of the conditional and only set those 
macros to 0 if they are undefined.
It will be up to whoever sets those macros to set them correctly otherwise.


https://reviews.llvm.org/D24946



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


r282540 - Adapt to LLVM optimization remark interface change. NFC

2016-09-27 Thread Adam Nemet via cfe-commits
Author: anemet
Date: Tue Sep 27 15:55:12 2016
New Revision: 282540

URL: http://llvm.org/viewvc/llvm-project?rev=282540=rev
Log:
Adapt to LLVM optimization remark interface change. NFC

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

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=282540=282539=282540=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Tue Sep 27 15:55:12 2016
@@ -514,7 +514,7 @@ void BackendConsumer::EmitOptimizationMe
 
   std::string Msg;
   raw_string_ostream MsgStream(Msg);
-  MsgStream << D.getMsg().str();
+  MsgStream << D.getMsg();
 
   if (D.getHotness())
 MsgStream << " (hotness: " << *D.getHotness() << ")";


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


Re: [PATCH] D11472: [ARM] Pass subtarget feature "+strict-align" instead of backend option "arm-strict-align"

2016-09-27 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko closed this revision.
Eugene.Zelenko added a comment.

Committed in https://reviews.llvm.org/rL243489.


https://reviews.llvm.org/D11472



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


Re: [PATCH] D24372: [libcxx] Sprinkle constexpr over compressed_pair

2016-09-27 Thread Marshall Clow via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

This looks good to me.

I appreciate the cleverness in the tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D24372



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


Re: [PATCH] D12505: [X86] Set MaxVectorAlign for non-Darwin targets as well.

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

Looks like patch was not committed.


https://reviews.llvm.org/D12505



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


Re: [PATCH] D24979: [CUDA] Support and std::min/max on the device.

2016-09-27 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D24979#554378, @jlebar wrote:

> > I' personally would prefer to force-include these files. I suspect it will 
> > not change things much as we already include a lot.
>
>
> We have already had bugs filed by users whose root cause was that we 
> #included more things than nvcc #includes.  I know exact compatibility with 
> nvcc is not our goal, but unless we have a good reason I don't think we 
> should break compatibility with nvcc *and* the C++ standard by 
> force-including additional system headers.
>
> > This looks like fix-includes and it may be somewhat shaky if users start 
> > messing with include paths.
>
>
> We add this include path first, so I think it should be OK?  What do you 
> think, @echristo?


It is very similar to fixincludes, but in this case I think it's probably the 
right thing.

If nothing else it's very easy to change our minds later.

One small wording change requested.

Thanks!

-eric



Comment at: clang/lib/Headers/__clang_cuda_complex_builtins.h:1
@@ +1,2 @@
+/*===-- __clang_cuda_complex_builtins - CUDA impls of libgcc complex fns 
===
+ *

Would swap libgcc for "runtime"


https://reviews.llvm.org/D24979



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


[PATCH] D24986: Headers: Add iso_volatile load/store intrinsics

2016-09-27 Thread Martin Storsjö via cfe-commits
mstorsjo created this revision.
mstorsjo added a reviewer: majnemer.
mstorsjo added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

This implements what is missing for PR30394, making it possible to compile C++ 
for ARM in MSVC mode with MSVC headers.

https://reviews.llvm.org/D24986

Files:
  lib/Headers/intrin.h

Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -1248,6 +1248,42 @@
 }
 #endif
 
+#if defined(__arm__) || defined(__aarch64__)
+static __inline__ char __DEFAULT_FN_ATTRS
+__iso_volatile_load8(const char volatile *_Src) {
+  return *_Src;
+}
+static __inline__ short __DEFAULT_FN_ATTRS
+__iso_volatile_load16(const short volatile *_Src) {
+  return *_Src;
+}
+static __inline__ int __DEFAULT_FN_ATTRS
+__iso_volatile_load32(const int volatile *_Src) {
+  return *_Src;
+}
+static __inline__ __int64 __DEFAULT_FN_ATTRS
+__iso_volatile_load64(const __int64 volatile *_Src) {
+  return *_Src;
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
+__iso_volatile_store8(char volatile *_Dest, char _Value) {
+  *_Dest = _Value;
+}
+static __inline__ void __DEFAULT_FN_ATTRS
+__iso_volatile_store16(short volatile *_Dest, short _Value) {
+  *_Dest = _Value;
+}
+static __inline__ void __DEFAULT_FN_ATTRS
+__iso_volatile_store32(int volatile *_Dest, int _Value) {
+  *_Dest = _Value;
+}
+static __inline__ void __DEFAULT_FN_ATTRS
+__iso_volatile_store64(__int64 volatile *_Dest, __int64 _Value) {
+  *_Dest = _Value;
+}
+#endif
+
 #ifdef __cplusplus
 }
 #endif


Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -1248,6 +1248,42 @@
 }
 #endif
 
+#if defined(__arm__) || defined(__aarch64__)
+static __inline__ char __DEFAULT_FN_ATTRS
+__iso_volatile_load8(const char volatile *_Src) {
+  return *_Src;
+}
+static __inline__ short __DEFAULT_FN_ATTRS
+__iso_volatile_load16(const short volatile *_Src) {
+  return *_Src;
+}
+static __inline__ int __DEFAULT_FN_ATTRS
+__iso_volatile_load32(const int volatile *_Src) {
+  return *_Src;
+}
+static __inline__ __int64 __DEFAULT_FN_ATTRS
+__iso_volatile_load64(const __int64 volatile *_Src) {
+  return *_Src;
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
+__iso_volatile_store8(char volatile *_Dest, char _Value) {
+  *_Dest = _Value;
+}
+static __inline__ void __DEFAULT_FN_ATTRS
+__iso_volatile_store16(short volatile *_Dest, short _Value) {
+  *_Dest = _Value;
+}
+static __inline__ void __DEFAULT_FN_ATTRS
+__iso_volatile_store32(int volatile *_Dest, int _Value) {
+  *_Dest = _Value;
+}
+static __inline__ void __DEFAULT_FN_ATTRS
+__iso_volatile_store64(__int64 volatile *_Dest, __int64 _Value) {
+  *_Dest = _Value;
+}
+#endif
+
 #ifdef __cplusplus
 }
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24946: [CUDA] Added support for CUDA-8

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


Comment at: lib/Headers/__clang_cuda_runtime_wrapper.h:139
@@ -137,1 +138,3 @@
 
+// CUDA 8.0.41 relies on __USE_FAST_MATH__ and __CUDA_PREC_DIV's values
+// Previous versions used to check thether they are defined or not.

Nit, missing period.


Comment at: lib/Headers/__clang_cuda_runtime_wrapper.h:140
@@ +139,3 @@
+// CUDA 8.0.41 relies on __USE_FAST_MATH__ and __CUDA_PREC_DIV's values
+// Previous versions used to check thether they are defined or not.
+// CU_DEVICE_INVALID macro is only defined in 8.0.41, so we use it

typo


Comment at: lib/Headers/__clang_cuda_runtime_wrapper.h:156
@@ +155,3 @@
+#endif
+#endif
+

I don't understand what we are doing here...

We're saying, if __USE_FAST_MATH__ is defined, and if it's not equal to 0, then 
redefine it equal to 1?  Isn't that a compile error?


https://reviews.llvm.org/D24946



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


Re: [PATCH] D24979: [CUDA] Support and std::min/max on the device.

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

> I' personally would prefer to force-include these files. I suspect it will 
> not change things much as we already include a lot.


We have already had bugs filed by users whose root cause was that we #included 
more things than nvcc #includes.  I know exact compatibility with nvcc is not 
our goal, but unless we have a good reason I don't think we should break 
compatibility with nvcc *and* the C++ standard by force-including additional 
system headers.

> This looks like fix-includes and it may be somewhat shaky if users start 
> messing with include paths.


We add this include path first, so I think it should be OK?  What do you think, 
@echristo.


https://reviews.llvm.org/D24979



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


Re: [PATCH] D24981: [Coverage] The coverage region for a switch should cover the code after the switch

2016-09-27 Thread Vedant Kumar via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!

It makes sense to inherit the current region's counter when we see a new 
switch. That should fix the 0 execution count we see on the condition.


Repository:
  rL LLVM

https://reviews.llvm.org/D24981



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


Re: [PATCH] D24977: [CUDA] Declare our __device__ math functions in the same inline namespace as our standard library.

2016-09-27 Thread Artem Belevich via cfe-commits
tra added a comment.

OK.


https://reviews.llvm.org/D24977



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


Re: [PATCH] D24979: [CUDA] Support and std::min/max on the device.

2016-09-27 Thread Artem Belevich via cfe-commits
tra added a subscriber: echristo.
tra added a comment.

This looks like fix-includes and it may be somewhat shaky if users start 
messing with include paths. You may want to get @echristo's input on that. I' 
personally would prefer to force-include these files. I suspect it will not 
change things much as we already include a lot.



Comment at: clang/lib/Driver/ToolChains.cpp:4704
@@ +4703,3 @@
+llvm::sys::path::append(P, "include");
+llvm::sys::path::append(P, "cuda_wrappers");
+addSystemInclude(DriverArgs, CC1Args, P);

path::append accepts multiple path parts so you can construct path in one call.


https://reviews.llvm.org/D24979



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


Re: [PATCH] D24977: [CUDA] Declare our __device__ math functions in the same inline namespace as our standard library.

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

> That is way too much knowledge about details of standard library 
> implementation.


Honestly I think this looks a lot scarier than it is.  Or, to be specific, I 
think we are already relying on implementation details much more implicit and 
fragile than what is explicit here.  See the git log of all of the changes I've 
had to make to this file before now to make us compatible with all of the 
standard libraries we want to support.

> If it changes, I suspect users will end up with a rather uninformative error.


You mean, if the standard libraries change the macro they're using here?  If 
so, we'll fall back to plain "namespace std", which is what we had before, so 
it should work fine.  In fact the only way I think this can affect things one 
way or another is if the standard library does

  namespace std {
  inline namespace foo {
  void some_fn(std::complex);
  
  void test() {
some_fn(std::complex());
  }
  } // inline namespace foo
  }  // namespace std

ADL on some_fn will prefer the some_fn inside std::foo, so if we declare an 
overload of some_fn inside plain namespace std, it won't match.

> We could whitelist libc++/libstdc++ version we've tested with and produce 
> #warning "Unsupported standard library version" if we see something else.


In practice, we are testing with versions of libstdc++ that are so much newer 
than what anyone has on their systems, I am not exactly worried about this.

But I think more generally these questions are probably better handled in a 
separate patch?  Like I say, we are already rather tightly-coupled to the 
standard libraries -- I don't think this patch changes that reality too much.


https://reviews.llvm.org/D24977



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


[PATCH] D24984: [libunwind] Add support for a single-threaded libunwind build

2016-09-27 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: jroelofs, compnerd, logan.
rmaprath added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

The EHABI unwinder is thread-agnostic, SJLJ unwinder and the DWARF unwinder 
have a couple of `pthread` dependencies.

This patch makes it possible to build the whole of `libunwind` for a 
single-threaded environment.

https://reviews.llvm.org/D24984

Files:
  CMakeLists.txt
  src/CMakeLists.txt
  src/UnwindCursor.hpp
  src/Unwind_AppleExtras.cpp
  src/config.h

Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -85,13 +85,20 @@
   } while (0)
 #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
 
+#if defined(_LIBUNWIND_HAS_NO_THREADS)
+  // only used with pthread calls, not needed for the single-threaded builds
+  #define _LIBUNWIND_LOG_NON_ZERO(x)
+#endif
+
 // Macros that define away in non-Debug builds
 #ifdef NDEBUG
   #define _LIBUNWIND_DEBUG_LOG(msg, ...)
   #define _LIBUNWIND_TRACE_API(msg, ...)
   #define _LIBUNWIND_TRACING_UNWINDING 0
   #define _LIBUNWIND_TRACE_UNWINDING(msg, ...)
-  #define _LIBUNWIND_LOG_NON_ZERO(x) x
+  #ifndef _LIBUNWIND_LOG_NON_ZERO
+#define _LIBUNWIND_LOG_NON_ZERO(x) x
+  #endif
 #else
   #ifdef __cplusplus
 extern "C" {
@@ -102,12 +109,14 @@
 }
   #endif
   #define _LIBUNWIND_DEBUG_LOG(msg, ...)  _LIBUNWIND_LOG(msg, __VA_ARGS__)
-  #define _LIBUNWIND_LOG_NON_ZERO(x) \
-do { \
-  int _err = x; \
-  if ( _err != 0 ) \
-_LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__); \
- } while (0)
+  #ifndef _LIBUNWIND_LOG_NON_ZERO
+#define _LIBUNWIND_LOG_NON_ZERO(x) \
+  do { \
+int _err = x; \
+if ( _err != 0 ) \
+  _LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__); \
+   } while (0)
+  #endif
   #define _LIBUNWIND_TRACE_API(msg, ...) \
 do { \
   if ( logAPIs() ) _LIBUNWIND_LOG(msg, __VA_ARGS__); \
Index: src/Unwind_AppleExtras.cpp
===
--- src/Unwind_AppleExtras.cpp
+++ src/Unwind_AppleExtras.cpp
@@ -185,21 +185,29 @@
 
 #if !defined(FOR_DYLD) && _LIBUNWIND_BUILD_SJLJ_APIS
 
-#include 
+#ifndef _LIBUNWIND_HAS_NO_THREADS
+  #include 
+#else
+  _Unwind_FunctionContext *fc_ = nullptr;
+#endif
 
 // Accessors to get get/set linked list of frames for sjlj based execeptions.
 _LIBUNWIND_HIDDEN
 struct _Unwind_FunctionContext *__Unwind_SjLj_GetTopOfFunctionStack() {
+#ifndef _LIBUNWIND_HAS_NO_THREADS
   return (struct _Unwind_FunctionContext *)
 _pthread_getspecific_direct(__PTK_LIBC_DYLD_Unwind_SjLj_Key);
+#else
+  return fc_;
+#endif
 }
 
 _LIBUNWIND_HIDDEN
 void __Unwind_SjLj_SetTopOfFunctionStack(struct _Unwind_FunctionContext *fc) {
+#ifndef _LIBUNWIND_HAS_NO_THREADS
   _pthread_setspecific_direct(__PTK_LIBC_DYLD_Unwind_SjLj_Key, fc);
+#else
+  fc_ = fc;
+#endif
 }
 #endif
-
-
-
-
Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -16,7 +16,9 @@
 #include 
 #include 
 #include 
-#include 
+#ifndef _LIBUNWIND_HAS_NO_THREADS
+  #include 
+#endif
 #include 
 
 #ifdef __APPLE__
@@ -60,7 +62,9 @@
 
   // These fields are all static to avoid needing an initializer.
   // There is only one instance of this class per process.
+#ifndef _LIBUNWIND_HAS_NO_THREADS
   static pthread_rwlock_t _lock;
+#endif
 #ifdef __APPLE__
   static void dyldUnloadHook(const struct mach_header *mh, intptr_t slide);
   static bool _registeredForDyldUnloads;
@@ -87,8 +91,10 @@
 template 
 typename DwarfFDECache::entry DwarfFDECache::_initialBuffer[64];
 
+#ifndef _LIBUNWIND_HAS_NO_THREADS
 template 
 pthread_rwlock_t DwarfFDECache::_lock = PTHREAD_RWLOCK_INITIALIZER;
+#endif
 
 #ifdef __APPLE__
 template 
Index: src/CMakeLists.txt
===
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -53,7 +53,9 @@
 set(libraries ${LIBUNWINDCXX_ABI_LIBRARIES})
 append_if(libraries LIBUNWIND_HAS_C_LIB c)
 append_if(libraries LIBUNWIND_HAS_DL_LIB dl)
-append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)
+if (LIBUNWIND_ENABLE_THREADS)
+  append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)
+endif()
 
 # Setup flags.
 append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_FPIC_FLAG -fPIC)
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -107,6 +107,7 @@
 option(LIBUNWIND_ENABLE_STATIC "Build libunwind as a static library." ON)
 option(LIBUNWIND_ENABLE_CROSS_UNWINDING "Enable cross-platform unwinding support." OFF)
 option(LIBUNWIND_ENABLE_ARM_WMMX "Enable unwinding support for ARM WMMX registers." OFF)
+option(LIBUNWIND_ENABLE_THREADS "Build libunwind with threading support." ON)
 

Re: [PATCH] D24977: [CUDA] Declare our __device__ math functions in the same inline namespace as our standard library.

2016-09-27 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

That is way too much knowledge about details of standard library implementation.
If it changes, I suspect users will end up with a rather uninformative error.
Is there a way to produce somewhat more sensible error if/when our assumptions 
about namespaces are violated?
We could whitelist libc++/libstdc++ version we've tested with and produce 
#warning "Unsupported standard library version" if we see something else.


https://reviews.llvm.org/D24977



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


[PATCH] D24981: [Coverage] The coverage region for a switch should cover the code after the switch

2016-09-27 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added a reviewer: vsk.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch fixes a regression introduced in r262697 that changed the way the 
coverage regions for switch are constructed. The PGO instrumentation counter 
for switch statements refers to a counter at the exit of the switch, and thus 
the coverage region for the switch statement should cover the code that comes 
after the switch, and not the switch statement itself.

This patch should fix the issue exposed by the new coverage bot where the 
switches with all cases returning get zero coverage:  
http://lab.llvm.org:8080/coverage/coverage-reports/clang/coverage/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp.html#L520.

Repository:
  rL LLVM

https://reviews.llvm.org/D24981

Files:
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/switch.c
  test/CoverageMapping/switchmacro.c

Index: test/CoverageMapping/switchmacro.c
===
--- test/CoverageMapping/switchmacro.c
+++ test/CoverageMapping/switchmacro.c
@@ -4,7 +4,7 @@
 
 // CHECK: foo
 int foo(int i) { // CHECK-NEXT: File 0, [[@LINE]]:16 -> {{[0-9]+}}:2 = #0
-  switch (i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> {{[0-9]+}}:4 = #1
+  switch (i) {
   default:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> {{[0-9]+}}:11 = #2
 if (i == 1)  // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:15 = #2
   return 0;  // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:15 = #3
Index: test/CoverageMapping/switch.c
===
--- test/CoverageMapping/switch.c
+++ test/CoverageMapping/switch.c
@@ -1,44 +1,44 @@
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name switch.c %s | FileCheck %s
 // CHECK: foo
 void foo(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+5]]:4 = #1
+  switch(i) {
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #2
 return;
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
 break;
   }
-  int x = 0;
+  int x = 0;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
 }
 
 void nop() {}
 
 // CHECK: bar
 void bar(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+20]]:2 = #0
-  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:6 = #1
+  switch (i)
 ;   // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:6 = 0
 
-  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:4 = #2
+  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+16]]:2 = #1
   }
 
-  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
+  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+13]]:2 = #2
 nop();  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:10 = 0
 
-  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #4
+  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+10]]:2 = #3
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #5
 nop();
 
-  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:4 = #6
+  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:2 = #4
 nop();  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:10 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #7
 nop();
   }
-  nop();
+  nop();// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #6
 }
 
 // CHECK-NEXT: main
 int main() {// CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+34]]:2 = #0
   int i = 0;
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+9]]:4 = #1
+  switch(i) {
   case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+7]]:10 = #2
 i = 1;
 break;
@@ -48,7 +48,7 @@
   default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #4
 break;
   }
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+8]]:4 = #5
+  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+22]]:2 = #1
   case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:10 = #6
 i = 1;
 break;
@@ -58,16 +58,16 @@
 break;
   }
 
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+7]]:4 = #9
+  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+12]]:2 = #5
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+5]]:11 = #10
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:11 = (#10 + #11)
 i = 11;
   case 3:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:11 = ((#10 + 

Re: [PATCH] D24119: [libc++] add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Michał Górny via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D24119#554251, @rmaprath wrote:

> Doesn't `-DLIBCXXABI_USE_LLVM_UNWINDER=ON` make it possible to build without 
> `libgcc_s`? Or is this something else?


It's supposed to but it doesn't add the necessary libraries when linking 
libc++.so.


Repository:
  rL LLVM

https://reviews.llvm.org/D24119



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


r282533 - Adapt to LLVM EnableStatistics() change.

2016-09-27 Thread Matthias Braun via cfe-commits
Author: matze
Date: Tue Sep 27 14:38:59 2016
New Revision: 282533

URL: http://llvm.org/viewvc/llvm-project?rev=282533=rev
Log:
Adapt to LLVM EnableStatistics() change.

Modified:
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=282533=282532=282533=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue Sep 27 14:38:59 2016
@@ -859,7 +859,7 @@ bool CompilerInstance::ExecuteAction(Fro
 createFrontendTimer();
 
   if (getFrontendOpts().ShowStats || !getFrontendOpts().StatsFile.empty())
-llvm::EnableStatistics();
+llvm::EnableStatistics(false);
 
   for (const FrontendInputFile  : getFrontendOpts().Inputs) {
 // Reset the ID tables if we are reusing the SourceManager and parsing

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=282533=282532=282533=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Tue Sep 27 
14:38:59 2016
@@ -188,7 +188,7 @@ public:
 Injector(injector) {
 DigestAnalyzerOptions();
 if (Opts->PrintStats) {
-  llvm::EnableStatistics();
+  llvm::EnableStatistics(false);
   TUTotalTimer = new llvm::Timer("Analyzer Total Time");
 }
   }


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


Re: [PATCH] D24975: [CUDA] Add #pragma clang force_cuda_host_device_{begin, end} pragmas.

2016-09-27 Thread Artem Belevich via cfe-commits
tra added a comment.

LGTM. Should we add new pragma description to docs/LanguageExtensions.rst ?


https://reviews.llvm.org/D24975



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


Re: [PATCH] D24914: [clang-rename] Do not print out error message upon encountering multiple replacements in the same SourceLocation.

2016-09-27 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.


Comment at: clang-rename/RenamingAction.cpp:74
@@ +73,3 @@
+  // FIXME: An error might happen here if USRLocFinder finds the symbol
+  // twice or if the symbol happens to be in a header included multiple
+  // times independently. Such error doesn't mean clang-rename failure and

alexshap wrote:
> My concerns were about wording, the new version looks good to me.
> I think the long-term fix would be to improve the interface of the class 
> Replacements,
> but it's clearly not in the scope of this patch (the other tools have the 
> same issue), 
> so to me your diff is OK.
Eric actually has a patch for that: https://reviews.llvm.org/D24800


https://reviews.llvm.org/D24914



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


Re: [PATCH] D24914: [clang-rename] Do not print out error message upon encountering multiple replacements in the same SourceLocation.

2016-09-27 Thread Alexander Shaposhnikov via cfe-commits
alexshap added inline comments.


Comment at: clang-rename/RenamingAction.cpp:74
@@ +73,3 @@
+  // FIXME: An error might happen here if USRLocFinder finds the symbol
+  // twice or if the symbol happens to be in a header included multiple
+  // times independently. Such error doesn't mean clang-rename failure and

My concerns were about wording, the new version looks good to me.
I think the long-term fix would be to improve the interface of the class 
Replacements,
but it's clearly not in the scope of this patch (the other tools have the same 
issue), 
so to me your diff is OK.


https://reviews.llvm.org/D24914



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


Re: [PATCH] D24848: [clang-tidy] fix false-positive for cppcoreguidelines-pro-type-member-init with in-class initializers

2016-09-27 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D24848#554145, @mgehre wrote:

> Rename the struct that was introduced in the test. Note that I need to keep 
> the function Bug30487,
>  because that is where the false-positive warning was emitted.


https://reviews.llvm.org/D24965 will allow you to write a positive test instead:

  struct PositivePartiallyInClassInitialized {
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize 
these fields: G
int F = 0;
int G;
// CHECK-FIXES: int G{};
  };


https://reviews.llvm.org/D24848



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


Re: [PATCH] D24119: [libc++] add linker option "-Wl, -z, defs" in standalone build

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

In https://reviews.llvm.org/D24119#554234, @mgorny wrote:

> I'm starting to regret that I've committed this. It breaks horribly any 
> pure-LLVM build, i.e. without linking to libgcc_s. It seems that the build 
> system is completely unprepared to link to compiler-rt or libunwind when 
> linking the shared library, and with -DLIBCXX_HAS_GCC_S_LIB=OFF, it fails due 
> to a lot of missing symbols. I am going to revert this until we get the build 
> system working completely.


Doesn't `-DLIBCXXABI_USE_LLVM_UNWINDER=ON` make it possible to build without 
`libgcc_s`? Or is this something else?


Repository:
  rL LLVM

https://reviews.llvm.org/D24119



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


Re: [PATCH] D24886: Add [[clang::suppress(rule, ...)]] attribute

2016-09-27 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a subscriber: malcolm.parsons.
malcolm.parsons added a comment.

In https://reviews.llvm.org/D24886#554130, @mgehre wrote:

> 2. Also, I suspect we will want this attribute to also be written on types I 
> was thinking about a case were that was useful, and didn't find any. Which of 
> course doesn't mean that there is none. I will add this.


I would like to suppress cppcoreguidelines-pro-type-union-access for all member 
functions of a class.
It might be useful to suppress cppcoreguidelines-pro-type-member-init for all 
constructors of a class.


https://reviews.llvm.org/D24886



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


[libcxx] r282524 - Revert r282483 - [cmake] Add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Tue Sep 27 13:54:02 2016
New Revision: 282524

URL: http://llvm.org/viewvc/llvm-project?rev=282524=rev
Log:
Revert r282483 - [cmake] Add linker option "-Wl,-z,defs" in standalone build

Revert r282483 as it causes build failures due to missing symbols when
not linking to -lgcc_s (i.e. doing pure LLVM stack build). The patch can
be reintroduced when the build system is fixed to add all needed
libraries (libunwind, compiler-rt).

Modified:
libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=282524=282523=282524=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Tue Sep 27 13:54:02 2016
@@ -319,18 +319,6 @@ remove_flags(-stdlib=libc++ -stdlib=libs
 # so they don't get transformed into -Wno and -errors respectivly.
 remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
 
-# FIXME: this is cribbed from HandleLLVMOptions.cmake.
-if(LIBCXX_STANDALONE_BUILD)
-  # Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO
-  # build might work on ELF but fail on MachO/COFF.
-  if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32 OR CYGWIN OR
-  ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
-  ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND
- NOT LLVM_USE_SANITIZER)
-set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
-  endif()
-endif()
-
 # Required flags ==
 set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build 
dialect")
 add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER})


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


Re: [PATCH] D24119: [libc++] add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Michał Górny via cfe-commits
mgorny reopened this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

I'm starting to regret that I've committed this. It breaks horribly any 
pure-LLVM build, i.e. without linking to libgcc_s. It seems that the build 
system is completely unprepared to link to compiler-rt or libunwind when 
linking the shared library, and with -DLIBCXX_HAS_GCC_S_LIB=OFF, it fails due 
to a lot of missing symbols. I am going to revert this until we get the build 
system working completely.


Repository:
  rL LLVM

https://reviews.llvm.org/D24119



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


[PATCH] D24979: [CUDA] Support and std::min/max on the device.

2016-09-27 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: cfe-commits, jhen.
Herald added subscribers: mgorny, beanz.

We do this by wrapping  and .

Tests are in the test-suite.   support to come separately.

https://reviews.llvm.org/D24979

Files:
  clang/lib/Driver/ToolChains.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_complex_builtins.h
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h
  clang/lib/Headers/cuda_wrappers/algorithm
  clang/lib/Headers/cuda_wrappers/complex

Index: clang/lib/Headers/cuda_wrappers/complex
===
--- /dev/null
+++ clang/lib/Headers/cuda_wrappers/complex
@@ -0,0 +1,79 @@
+/*=== complex - CUDA wrapper for  --===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+#pragma once
+
+// Wrapper around  that forces its functions to be __host__
+// __device__.
+
+// First, include host-only headers we think are likely to be included by
+// , so that the pragma below only applies to  itself.
+#if __cplusplus >= 201103L
+#include 
+#endif
+#include 
+#include 
+#include 
+
+// Next, include our  wrapper, to ensure that device overloads of
+// std::min/max are available.
+#include 
+
+#pragma clang force_cuda_host_device_begin
+
+// When compiling for device, ask libstdc++ to use its own implements of
+// complex functions, rather than calling builtins (which resolve to library
+// functions that don't exist when compiling CUDA device code).
+//
+// This is a little dicey, because it causes libstdc++ to define a different
+// set of overloads on host and device.
+//
+//   // Present only when compiling for host.
+//   __host__ __device__ void complex sin(const complex& x) {
+// return __builtin_csinf(x);
+//   }
+//
+//   // Present when compiling for host and for device.
+//   template 
+//   void __host__ __device__ complex sin(const complex& x) {
+// return complex(sin(x.real()) * cosh(x.imag()),
+//   cos(x.real()), sinh(x.imag()));
+//   }
+//
+// This is safe because when compiling for device, all function calls in
+// __host__ code to sin() will still resolve to *something*, even if they don't
+// resolve to the same function as they resolve to when compiling for host.  We
+// don't care that they don't resolve to the right function because we won't
+// codegen this host code when compiling for device.
+
+#pragma push_macro("_GLIBCXX_USE_C99_COMPLEX")
+#pragma push_macro("_GLIBCXX_USE_C99_COMPLEX_TR1")
+#define _GLIBCXX_USE_C99_COMPLEX 0
+#define _GLIBCXX_USE_C99_COMPLEX_TR1 0
+
+#include_next 
+
+#pragma pop_macro("_GLIBCXX_USE_C99_COMPLEX_TR1")
+#pragma pop_macro("_GLIBCXX_USE_C99_COMPLEX")
+
+#pragma clang force_cuda_host_device_end
Index: clang/lib/Headers/cuda_wrappers/algorithm
===
--- /dev/null
+++ clang/lib/Headers/cuda_wrappers/algorithm
@@ -0,0 +1,96 @@
+/*=== complex - CUDA wrapper for  ===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND 

[PATCH] D24977: [CUDA] Declare our __device__ math functions in the same inline namespace as our standard library.

2016-09-27 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: jhen, cfe-commits.

Currently we declare our inline __device__ math functions in namespace
std.  But libstdc++ and libc++ declare these functions in an inline
namespace inside namespace std.  We need to match this because, in a
later patch, we want to get e.g.  to use our device overloads,
and it only will if those overloads are in the right inline namespace.

https://reviews.llvm.org/D24977

Files:
  clang/lib/Headers/__clang_cuda_cmath.h
  clang/lib/Headers/__clang_cuda_math_forward_declares.h

Index: clang/lib/Headers/__clang_cuda_math_forward_declares.h
===
--- clang/lib/Headers/__clang_cuda_math_forward_declares.h
+++ clang/lib/Headers/__clang_cuda_math_forward_declares.h
@@ -185,7 +185,19 @@
 __DEVICE__ double trunc(double);
 __DEVICE__ float trunc(float);
 
+// We need to define these overloads in exactly the namespace our standard
+// library uses (including the right inline namespace), otherwise they won't be
+// picked up by other functions in the standard library (e.g. functions in
+// ).  Thus the ugliness below.
+#ifdef _LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_BEGIN_NAMESPACE_STD
+#else
 namespace std {
+#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+#endif
+#endif
+
 using ::abs;
 using ::acos;
 using ::acosh;
@@ -259,7 +271,15 @@
 using ::tanh;
 using ::tgamma;
 using ::trunc;
+
+#ifdef _LIBCPP_END_NAMESPACE_STD
+_LIBCPP_END_NAMESPACE_STD
+#else
+#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
+_GLIBCXX_END_NAMESPACE_VERSION
+#endif
 } // namespace std
+#endif
 
 #pragma pop_macro("__DEVICE__")
 
Index: clang/lib/Headers/__clang_cuda_cmath.h
===
--- clang/lib/Headers/__clang_cuda_cmath.h
+++ clang/lib/Headers/__clang_cuda_cmath.h
@@ -316,7 +316,19 @@
   return std::scalbn((double)__x, __exp);
 }
 
+// We need to define these overloads in exactly the namespace our standard
+// library uses (including the right inline namespace), otherwise they won't be
+// picked up by other functions in the standard library (e.g. functions in
+// ).  Thus the ugliness below.
+#ifdef _LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_BEGIN_NAMESPACE_STD
+#else
 namespace std {
+#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+#endif
+#endif
+
 // Pull the new overloads we defined above into namespace std.
 using ::acos;
 using ::acosh;
@@ -451,7 +463,15 @@
 using ::tanhf;
 using ::tgammaf;
 using ::truncf;
-}
+
+#ifdef _LIBCPP_END_NAMESPACE_STD
+_LIBCPP_END_NAMESPACE_STD
+#else
+#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
+_GLIBCXX_END_NAMESPACE_VERSION
+#endif
+} // namespace std
+#endif
 
 #undef __DEVICE__
 


Index: clang/lib/Headers/__clang_cuda_math_forward_declares.h
===
--- clang/lib/Headers/__clang_cuda_math_forward_declares.h
+++ clang/lib/Headers/__clang_cuda_math_forward_declares.h
@@ -185,7 +185,19 @@
 __DEVICE__ double trunc(double);
 __DEVICE__ float trunc(float);
 
+// We need to define these overloads in exactly the namespace our standard
+// library uses (including the right inline namespace), otherwise they won't be
+// picked up by other functions in the standard library (e.g. functions in
+// ).  Thus the ugliness below.
+#ifdef _LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_BEGIN_NAMESPACE_STD
+#else
 namespace std {
+#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+#endif
+#endif
+
 using ::abs;
 using ::acos;
 using ::acosh;
@@ -259,7 +271,15 @@
 using ::tanh;
 using ::tgamma;
 using ::trunc;
+
+#ifdef _LIBCPP_END_NAMESPACE_STD
+_LIBCPP_END_NAMESPACE_STD
+#else
+#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
+_GLIBCXX_END_NAMESPACE_VERSION
+#endif
 } // namespace std
+#endif
 
 #pragma pop_macro("__DEVICE__")
 
Index: clang/lib/Headers/__clang_cuda_cmath.h
===
--- clang/lib/Headers/__clang_cuda_cmath.h
+++ clang/lib/Headers/__clang_cuda_cmath.h
@@ -316,7 +316,19 @@
   return std::scalbn((double)__x, __exp);
 }
 
+// We need to define these overloads in exactly the namespace our standard
+// library uses (including the right inline namespace), otherwise they won't be
+// picked up by other functions in the standard library (e.g. functions in
+// ).  Thus the ugliness below.
+#ifdef _LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_BEGIN_NAMESPACE_STD
+#else
 namespace std {
+#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+#endif
+#endif
+
 // Pull the new overloads we defined above into namespace std.
 using ::acos;
 using ::acosh;
@@ -451,7 +463,15 @@
 using ::tanhf;
 using ::tgammaf;
 using ::truncf;
-}
+
+#ifdef _LIBCPP_END_NAMESPACE_STD
+_LIBCPP_END_NAMESPACE_STD
+#else
+#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
+_GLIBCXX_END_NAMESPACE_VERSION
+#endif
+} // namespace std
+#endif
 
 #undef __DEVICE__
 

[PATCH] D24978: [CUDA] Rename cuda_builtin_vars.h to __clang_cuda_builtin_vars.h.

2016-09-27 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

This matches the idiom we use for our other CUDA wrapper headers.

https://reviews.llvm.org/D24978

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_builtin_vars.h
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h
  clang/lib/Headers/cuda_builtin_vars.h
  clang/test/CodeGenCUDA/cuda-builtin-vars.cu
  clang/test/SemaCUDA/cuda-builtin-vars.cu

Index: clang/test/SemaCUDA/cuda-builtin-vars.cu
===
--- clang/test/SemaCUDA/cuda-builtin-vars.cu
+++ clang/test/SemaCUDA/cuda-builtin-vars.cu
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 "-triple" "nvptx-nvidia-cuda" -fcuda-is-device -fsyntax-only -verify %s
 
-#include "cuda_builtin_vars.h"
+#include "__clang_cuda_builtin_vars.h"
 __attribute__((global))
 void kernel(int *out) {
   int i = 0;
@@ -34,20 +34,20 @@
 
   out[i++] = warpSize;
   warpSize = 0; // expected-error {{cannot assign to variable 'warpSize' with const-qualified type 'const int'}}
-  // expected-note@cuda_builtin_vars.h:* {{variable 'warpSize' declared const here}}
+  // expected-note@__clang_cuda_builtin_vars.h:* {{variable 'warpSize' declared const here}}
 
   // Make sure we can't construct or assign to the special variables.
   __cuda_builtin_threadIdx_t x; // expected-error {{calling a private constructor of class '__cuda_builtin_threadIdx_t'}}
-  // expected-note@cuda_builtin_vars.h:* {{declared private here}}
+  // expected-note@__clang_cuda_builtin_vars.h:* {{declared private here}}
 
   __cuda_builtin_threadIdx_t y = threadIdx; // expected-error {{calling a private constructor of class '__cuda_builtin_threadIdx_t'}}
-  // expected-note@cuda_builtin_vars.h:* {{declared private here}}
+  // expected-note@__clang_cuda_builtin_vars.h:* {{declared private here}}
 
   threadIdx = threadIdx; // expected-error {{'operator=' is a private member of '__cuda_builtin_threadIdx_t'}}
-  // expected-note@cuda_builtin_vars.h:* {{declared private here}}
+  // expected-note@__clang_cuda_builtin_vars.h:* {{declared private here}}
 
   void *ptr =  // expected-error {{'operator&' is a private member of '__cuda_builtin_threadIdx_t'}}
-  // expected-note@cuda_builtin_vars.h:* {{declared private here}}
+  // expected-note@__clang_cuda_builtin_vars.h:* {{declared private here}}
 
   // Following line should've caused an error as one is not allowed to
   // take address of a built-in variable in CUDA. Alas there's no way
Index: clang/test/CodeGenCUDA/cuda-builtin-vars.cu
===
--- clang/test/CodeGenCUDA/cuda-builtin-vars.cu
+++ clang/test/CodeGenCUDA/cuda-builtin-vars.cu
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 "-triple" "nvptx-nvidia-cuda" -emit-llvm -fcuda-is-device -o - %s | FileCheck %s
 
-#include "cuda_builtin_vars.h"
+#include "__clang_cuda_builtin_vars.h"
 
 // CHECK: define void @_Z6kernelPi(i32* %out)
 __attribute__((global))
Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -72,9 +72,9 @@
 #define __CUDA_ARCH__ 350
 #endif
 
-#include "cuda_builtin_vars.h"
+#include "__clang_cuda_builtin_vars.h"
 
-// No need for device_launch_parameters.h as cuda_builtin_vars.h above
+// No need for device_launch_parameters.h as __clang_cuda_builtin_vars.h above
 // has taken care of builtin variables declared in the file.
 #define __DEVICE_LAUNCH_PARAMETERS_H__
 
@@ -267,8 +267,8 @@
 }
 } // namespace std
 
-// Out-of-line implementations from cuda_builtin_vars.h.  These need to come
-// after we've pulled in the definition of uint3 and dim3.
+// Out-of-line implementations from __clang_cuda_builtin_vars.h.  These need to
+// come after we've pulled in the definition of uint3 and dim3.
 
 __device__ inline __cuda_builtin_threadIdx_t::operator uint3() const {
   uint3 ret;
@@ -299,10 +299,10 @@
 
 // curand_mtgp32_kernel helpfully redeclares blockDim and threadIdx in host
 // mode, giving them their "proper" types of dim3 and uint3.  This is
-// incompatible with the types we give in cuda_builtin_vars.h.  As as hack,
-// force-include the header (nvcc doesn't include it by default) but redefine
-// dim3 and uint3 to our builtin types.  (Thankfully dim3 and uint3 are only
-// used here for the redeclarations of blockDim and threadIdx.)
+// incompatible with the types we give in __clang_cuda_builtin_vars.h.  As as
+// hack, force-include the header (nvcc doesn't include it by default) but
+// redefine dim3 and uint3 to our builtin types.  (Thankfully dim3 and uint3 are
+// only used here for the redeclarations of blockDim and threadIdx.)
 #pragma push_macro("dim3")
 #pragma push_macro("uint3")
 #define dim3 

[PATCH] D24975: [CUDA] Add #pragma clang force_cuda_host_device_{begin, end} pragmas.

2016-09-27 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rsmith.
jlebar added subscribers: cfe-commits, jhen, tra.

These cause us to consider all functions in-between to be __host__
__device__.

You can nest these pragmas; you just can't have more 'end's than
'begin's.

https://reviews.llvm.org/D24975

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/test/Parser/cuda-force-host-device.cu

Index: clang/test/Parser/cuda-force-host-device.cu
===
--- /dev/null
+++ clang/test/Parser/cuda-force-host-device.cu
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the force_cuda_host_device_{begin,end} pragmas.
+
+#pragma clang force_cuda_host_device_begin
+void f();
+#pragma clang force_cuda_host_device_begin
+void g();
+#pragma clang force_cuda_host_device_end
+void h();
+#pragma clang force_cuda_host_device_end
+
+void i(); // expected-note {{not viable}}
+
+void host() {
+  f();
+  g();
+  h();
+  i();
+}
+
+__attribute__((device)) void device() {
+  f();
+  g();
+  h();
+  i(); // expected-error {{no matching function}}
+}
Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -23,6 +23,19 @@
 #include "llvm/ADT/SmallVector.h"
 using namespace clang;
 
+void Sema::PushForceCUDAHostDevice() {
+  assert(getLangOpts().CUDA && "May be called only for CUDA compilations.");
+  ForceCUDAHostDeviceDepth++;
+}
+
+bool Sema::PopForceCUDAHostDevice() {
+  assert(getLangOpts().CUDA && "May be called only for CUDA compilations.");
+  if (ForceCUDAHostDeviceDepth == 0)
+return false;
+  ForceCUDAHostDeviceDepth--;
+  return true;
+}
+
 ExprResult Sema::ActOnCUDAExecConfigExpr(Scope *S, SourceLocation oc,
  MultiExprArg ExecConfig,
  SourceLocation GGGLoc) {
@@ -441,9 +454,23 @@
 //  * a __device__ function with this signature was already declared, in which
 //case in which case we output an error, unless the __device__ decl is in a
 //system header, in which case we leave the constexpr function unattributed.
+//
+// In addition, all function decls are treated as __host__ __device__ when
+// ForceCUDAHostDeviceDepth > 0 (corresponding to code within a
+//   #pragma clang force_cuda_host_device_begin/end
+// pair).
 void Sema::maybeAddCUDAHostDeviceAttrs(Scope *S, FunctionDecl *NewD,
const LookupResult ) {
   assert(getLangOpts().CUDA && "May be called only for CUDA compilations.");
+
+  if (ForceCUDAHostDeviceDepth > 0) {
+if (!NewD->hasAttr())
+  NewD->addAttr(CUDAHostAttr::CreateImplicit(Context));
+if (!NewD->hasAttr())
+  NewD->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+return;
+  }
+
   if (!getLangOpts().CUDAHostDeviceConstexpr || !NewD->isConstexpr() ||
   NewD->isVariadic() || NewD->hasAttr() ||
   NewD->hasAttr() || NewD->hasAttr())
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -167,6 +167,26 @@
 Token ) override;
 };
 
+struct PragmaForceCUDAHostDeviceStartHandler : public PragmaHandler {
+  PragmaForceCUDAHostDeviceStartHandler(Sema )
+  : PragmaHandler("force_cuda_host_device_begin"), Actions(Actions) {}
+  void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+Token ) override;
+
+private:
+  Sema 
+};
+
+struct PragmaForceCUDAHostDeviceEndHandler : public PragmaHandler {
+  PragmaForceCUDAHostDeviceEndHandler(Sema )
+  : PragmaHandler("force_cuda_host_device_end"), Actions(Actions) {}
+  void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+Token ) override;
+
+private:
+  Sema 
+};
+
 }  // end namespace
 
 void Parser::initializePragmaHandlers() {
@@ -239,6 +259,15 @@
 PP.AddPragmaHandler(MSIntrinsic.get());
   }
 
+  if (getLangOpts().CUDA) {
+CUDAForceHostDeviceStartHandler.reset(
+new PragmaForceCUDAHostDeviceStartHandler(Actions));
+PP.AddPragmaHandler("clang", CUDAForceHostDeviceStartHandler.get());
+CUDAForceHostDeviceEndHandler.reset(
+new PragmaForceCUDAHostDeviceEndHandler(Actions));
+PP.AddPragmaHandler("clang", CUDAForceHostDeviceEndHandler.get());
+  }
+
   OptimizeHandler.reset(new PragmaOptimizeHandler(Actions));
   PP.AddPragmaHandler("clang", OptimizeHandler.get());
 
@@ -309,6 +338,13 @@
 MSIntrinsic.reset();
   }
 
+  if (getLangOpts().CUDA) {
+PP.RemovePragmaHandler("clang", CUDAForceHostDeviceStartHandler.get());
+CUDAForceHostDeviceStartHandler.reset();
+PP.RemovePragmaHandler("clang", 

Re: [PATCH] D24886: Add [[clang::suppress(rule, ...)]] attribute

2016-09-27 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D24886#554130, @mgehre wrote:

> Thank your very much for your comments!
>  Let me try to give me reasoning for those points:
>
> 1. But it's missing some pieces, like test cases I though about how to test 
> this, having no semantic meaning itself. I could look at the AST dump, but it 
> does not even show the rules that were passed, only that a "SuppressAttr" 
> exists. Would that be enough?


That's a good start. Other tests that are required: the attribute appertains to 
the proper syntactic constructs and is diagnosed otherwise, attribute has the 
correct number and kind of arguments, the arguments are sane, etc.

> 2. Also, I suspect we will want this attribute to also be written on types I 
> was thinking about a case were that was useful, and didn't find any. Which of 
> course doesn't mean that there is none. I will add this.


If there are no use cases for it, then I guess we don't need to support it.

> 3. No new undocumented attributes, please. I completely agree that it cannot 
> be merged like this. This depends a bit on how our discussion turns out: Will 
> this be specific to C++ Core Guidelines, or clang-tidy or both or none? Then, 
> should the clang documentation mention clang-tidy? (or does that violate 
> layering?)


I agree, we want to make sure the docs reflect our intended design. I don't 
think it's a problem for the clang docs to mention clang-tidy. Certainly we 
have LLVM documentation that mentions clang.

> 4. Should we diagnose if asked to suppress a diagnostic that we don't 
> support? I image that the users workflow would be like this: Run clang-tidy 
> (e.g. by build server); get a warning; add [[suppress]], run clang-tidy 
> again; see that the warning is gone. I don't see a big risk in not diagnosing 
> a wrongly spelled suppression, because the user will notice right away that 
> the warning is not suppressed. There is not other implicit side-effect.


I think that's definitely a reasonable use case, but I don't think it's a 
compelling explanation of why we should not warn the user "I have no idea what 
you're talking about", either. The same could be said of many diagnostics we 
give -- the user will notice that their code doesn't work properly. However, I 
tend to be in the camp of "warn on suspicious activity" camp.

> As an ad-don, diagnosing if the spelling is just slightly off seems like a 
> bonus to me, but I hope

>  that this could be deferred to another patch.


Certainly!

> 5. I'd suggest asking the editors of the core guidelines what attribute 
> namespace they'd like used. I followed your advice and asked here: 
> https://github.com/isocpp/CppCoreGuidelines/issues/742 I will post updates to 
> that issue here.


Thanks!

> 6. I believe this attribute should be used to silence diagnostics for more 
> than just the C++ Core Guidelines, so I don't think it makes sense to let 
> them dictate what attribute namespace should be used. Maybe I wanted to much 
> here. There are two conflicting goals:

> 7. Suppress C++ Core Guidelines rules in a vendor-neutral way

> 8. Suppress specific clang(-tidy) warnings I'm getting the feeling that we 
> cannot have both in the same attribute.


I think we do our users a major disservice by not trying to do both with the 
same attribute. As a user, I do not want to have to remember which way to spell 
an attribute to silence warnings. This is especially important were we ever to 
allow triggering clang-tidy diagnostics through the clang frontend.

> For example, the C++ Core Guidelines say that the "No reinterpret_cast" rules 
> shall be suppressed either by

>  saying "type" (also suppresses all other type related rules) or by saying 
> "type.1" or by saying

>  "type1-dont-use-reinterpret_cast".

>  When we want to suppress other clang(-tidy) warnings, it would make sense 
> from a usability point of view

>  to take the warning ids that clang(-tidy) outputs. For that particular C++ 
> Core Guideline rule, it would be

>  "cppcoreguidelines-pro-type-reinterpret-cast".

>  So even if we had the same attribute name for both goals, the rule names 
> would have to differ.

> 

> What are your opinions on this point? (Should I put this on the mailing list?)


I guess I fail to see what the technical issue is (and perhaps I'm just 
obtuse), but I think that getting a wider audience is not a bad idea.


https://reviews.llvm.org/D24886



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


Re: [PATCH] D23712: [OpenCL] Override supported OpenCL extensions with -cl-ext option

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


Comment at: include/clang/Basic/OpenCLOptions.h:39
@@ +38,3 @@
+
+  void set(llvm::StringRef Ext, bool Enable = true) {
+assert(!Ext.empty() && "Extension is empty.");

yaxunl wrote:
> Better add a comments for this function about its semantics, i.e., if Ext 
> does not starts with +/-, it is enabled/disabled by \p Enable, otherwise +/- 
> overrides \p Enable, since this is not obvious.
Indeed, generally it would be nice to add a comment explaining the purpose of 
this functions. I don't think the name is descriptive enough.


Comment at: include/clang/Driver/Options.td:394
@@ -393,1 +393,3 @@
   HelpText<"OpenCL only. Specify that single precision floating-point divide 
and sqrt used in the program source are correctly rounded.">;
+def cl_ext_EQ : CommaJoined<["-"], "cl-ext=">, Group, 
Flags<[CC1Option]>,
+  HelpText<"OpenCL only. Enable or disable specific OpenCL extensions 
separated by comma. Use 'all' for all extensions.">;

I would see it as cc1 option instead to avoid confusions on its intension.


Comment at: include/clang/Driver/Options.td:395
@@ -394,1 +394,3 @@
+def cl_ext_EQ : CommaJoined<["-"], "cl-ext=">, Group, 
Flags<[CC1Option]>,
+  HelpText<"OpenCL only. Enable or disable specific OpenCL extensions 
separated by comma. Use 'all' for all extensions.">;
 def client__name : JoinedOrSeparate<["-"], "client_name">;

Could we also add a short statement, that +/- are used to turn the extesions on 
and off. 


Comment at: lib/Basic/Targets.cpp:1882
@@ -1881,1 +1881,3 @@
+
+setOpenCLExtensionOpts();
   }

Is this really target specific? I feel this should rather go into common code.


https://reviews.llvm.org/D23712



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


Re: [PATCH] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-09-27 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: test/Analysis/copypaste/functions.cpp:7
@@ -6,3 +6,3 @@
 
-int max(int a, int b) { // expected-warning{{Detected code clone.}}
+int max(int a, int b) { // expected-warning{{Clone of this code was detected}}
   log();

"was" -> "is"?
Do we use past or present elsewhere?


Comment at: test/Analysis/copypaste/suspicious-clones.cpp:61
@@ -60,3 +60,3 @@
   b /= a + b;
-  c -= b * a; // expected-warning{{suspicious code clone detected; did you 
mean to use 'a'?}}
+  c -= b * a; // expected-warning{{Suspicious code clone detected; did you 
mean to use 'a'?}}
   return c;

The error message seems too verbose and focused on the implementation rather 
than user (ex: "suspicious code clone" and "suggestion is based").

Maybe we could say something like this:

- Did you mean to use 'a'?
- Similar code snippet here




https://reviews.llvm.org/D24916



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


Re: [PATCH] D24848: [clang-tidy] fix false-positive for cppcoreguidelines-pro-type-member-init with in-class initializers

2016-09-27 Thread Aaron Ballman via cfe-commits
On Tue, Sep 27, 2016 at 2:05 PM, Matthias Gehre  wrote:
> mgehre updated this revision to Diff 72677.
> mgehre added a comment.
>
> Rename the struct that was introduced in the test. Note that I need to keep 
> the function Bug30487,
> because that is where the false-positive warning was emitted.

We usually use namespaces for this when working with C++ code, where
the namespace identifier is pr30487 (e.g.).

~Aaron

>
>
> https://reviews.llvm.org/D24848
>
> Files:
>   clang-tidy/utils/TypeTraits.cpp
>   test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
>
> Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
> ===
> --- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
> +++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
> @@ -73,6 +73,11 @@
>NegativeInClassInitialized() {}
>  };
>
> +struct NegativeInClassInitializedDefaulted {
> +  int F = 0;
> +  NegativeInClassInitializedDefaulted() = default;
> +};
> +
>  struct NegativeConstructorDelegated {
>int F;
>
> @@ -367,3 +372,8 @@
>PositiveIndirectMember() {}
>// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not 
> initialize these fields: A
>  };
> +
> +void Bug30487()
> +{
> +  NegativeInClassInitializedDefaulted s;
> +}
> Index: clang-tidy/utils/TypeTraits.cpp
> ===
> --- clang-tidy/utils/TypeTraits.cpp
> +++ clang-tidy/utils/TypeTraits.cpp
> @@ -62,8 +62,10 @@
>if (ClassDecl->hasTrivialDefaultConstructor())
>  return true;
>
> -  // If all its fields are trivially constructible.
> +  // If all its fields are trivially constructible and have no default 
> initializers.
>for (const FieldDecl *Field : ClassDecl->fields()) {
> +if (Field->hasInClassInitializer())
> +  return false;
>  if (!isTriviallyDefaultConstructible(Field->getType(), Context))
>return false;
>}
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24848: [clang-tidy] fix false-positive for cppcoreguidelines-pro-type-member-init with in-class initializers

2016-09-27 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 72677.
mgehre added a comment.

Rename the struct that was introduced in the test. Note that I need to keep the 
function Bug30487,
because that is where the false-positive warning was emitted.


https://reviews.llvm.org/D24848

Files:
  clang-tidy/utils/TypeTraits.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -73,6 +73,11 @@
   NegativeInClassInitialized() {}
 };
 
+struct NegativeInClassInitializedDefaulted {
+  int F = 0;
+  NegativeInClassInitializedDefaulted() = default;
+};
+
 struct NegativeConstructorDelegated {
   int F;
 
@@ -367,3 +372,8 @@
   PositiveIndirectMember() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these fields: A
 };
+
+void Bug30487()
+{
+  NegativeInClassInitializedDefaulted s;
+}
Index: clang-tidy/utils/TypeTraits.cpp
===
--- clang-tidy/utils/TypeTraits.cpp
+++ clang-tidy/utils/TypeTraits.cpp
@@ -62,8 +62,10 @@
   if (ClassDecl->hasTrivialDefaultConstructor())
 return true;
 
-  // If all its fields are trivially constructible.
+  // If all its fields are trivially constructible and have no default 
initializers.
   for (const FieldDecl *Field : ClassDecl->fields()) {
+if (Field->hasInClassInitializer())
+  return false;
 if (!isTriviallyDefaultConstructible(Field->getType(), Context))
   return false;
   }


Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -73,6 +73,11 @@
   NegativeInClassInitialized() {}
 };
 
+struct NegativeInClassInitializedDefaulted {
+  int F = 0;
+  NegativeInClassInitializedDefaulted() = default;
+};
+
 struct NegativeConstructorDelegated {
   int F;
 
@@ -367,3 +372,8 @@
   PositiveIndirectMember() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields: A
 };
+
+void Bug30487()
+{
+  NegativeInClassInitializedDefaulted s;
+}
Index: clang-tidy/utils/TypeTraits.cpp
===
--- clang-tidy/utils/TypeTraits.cpp
+++ clang-tidy/utils/TypeTraits.cpp
@@ -62,8 +62,10 @@
   if (ClassDecl->hasTrivialDefaultConstructor())
 return true;
 
-  // If all its fields are trivially constructible.
+  // If all its fields are trivially constructible and have no default initializers.
   for (const FieldDecl *Field : ClassDecl->fields()) {
+if (Field->hasInClassInitializer())
+  return false;
 if (!isTriviallyDefaultConstructible(Field->getType(), Context))
   return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24278: [analyzer] Extend bug reports with extra notes.

2016-09-27 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.

I have no further comments.


https://reviews.llvm.org/D24278



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


Re: [PATCH] D24886: Add [[clang::suppress(rule, ...)]] attribute

2016-09-27 Thread Matthias Gehre via cfe-commits
mgehre added a comment.

Thank your very much for your comments!
Let me try to give me reasoning for those points:

1. But it's missing some pieces, like test cases

I though about how to test this, having no semantic meaning itself.
I could look at the AST dump, but it does not even show the
rules that were passed, only that a "SuppressAttr" exists. Would that be enough?

2. Also, I suspect we will want this attribute to also be written on types

I was thinking about a case were that was useful, and didn't find any. 
Which of course doesn't mean that there is none. I will add this.

3. No new undocumented attributes, please.

I completely agree that it cannot be merged like this. This depends a bit
on how our discussion turns out: Will this be specific to C++ Core Guidelines, 
or
clang-tidy or both or none? Then, should the clang documentation mention 
clang-tidy?
(or does that violate layering?)

4. Should we diagnose if asked to suppress a diagnostic that we don't support?

I image that the users workflow would be like this: Run clang-tidy (e.g. by 
build server);
get a warning; add [[suppress]], run clang-tidy again; see that the warning is 
gone. I don't see a big
risk in not diagnosing a wrongly spelled suppression, because the user will 
notice right away
that the warning is not suppressed. There is not other implicit side-effect.
As an ad-don, diagnosing if the spelling is just slightly off seems like a 
bonus to me, but I hope
that this could be deferred to another patch.

5. I'd suggest asking the editors of the core guidelines what attribute 
namespace they'd like used.

I followed your advice and asked here:
https://github.com/isocpp/CppCoreGuidelines/issues/742
I will post updates to that issue here.

6. I believe this attribute should be used to silence diagnostics for more than 
just the C++ Core Guidelines,

so I don't think it makes sense to let them dictate what attribute namespace 
should be used.
Maybe I wanted to much here. There are two conflicting goals:

1. Suppress C++ Core Guidelines rules in a vendor-neutral way
2. Suppress specific clang(-tidy) warnings

I'm getting the feeling that we cannot have both in the same attribute.
For example, the C++ Core Guidelines say that the "No reinterpret_cast" rules 
shall be suppressed either by
saying "type" (also suppresses all other type related rules) or by saying 
"type.1" or by saying
"type1-dont-use-reinterpret_cast".
When we want to suppress other clang(-tidy) warnings, it would make sense from 
a usability point of view
to take the warning ids that clang(-tidy) outputs. For that particular C++ Core 
Guideline rule, it would be
"cppcoreguidelines-pro-type-reinterpret-cast".
So even if we had the same attribute name for both goals, the rule names would 
have to differ.

What are your opinions on this point? (Should I put this on the mailing list?)


https://reviews.llvm.org/D24886



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


Re: [PATCH] D24861: [Sema] extend Wshift-op-parentheses so it warns for multiplicative operators

2016-09-27 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a subscriber: bruno.
bruno added a comment.

Hi Daniel,

This is very nice.

In https://reviews.llvm.org/D24861#553606, @danielmarjamaki wrote:

> Compiling 2064 projects resulted in 904 warnings
>
> Here are the results:
>  https://drive.google.com/file/d/0BykPmWrCOxt2N04tYl8zVHA3MXc/view?usp=sharing
>
> The results looks acceptable imho. The code looks intentional in many cases 
> so I believe there are users that will disable this warning. Probably there 
> are true positives where the evaluation order is not really known. There were 
> many warnings about macro arguments where the macro bitshifts the argument - 
> these macros look very shaky to me.
>
> I saw some warnings about such code:
>
>   a * b << c
>   
>
> Maybe we should not warn about this. As far as I see, the result will be the 
> same if (a*b) or (b< signedness issues. What do you think? I'll keep these warnings for now.


Any idea on how expensive would be to reason about these false positives and 
avoid them?


Repository:
  rL LLVM

https://reviews.llvm.org/D24861



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


Re: [PATCH] D24752: [Modules] Add missing dependencies to clang builtins modulemap

2016-09-27 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a subscriber: bruno.


Comment at: lib/Headers/module.modulemap:133
@@ -131,2 +132,3 @@
 explicit module aes {
+  export sse2
   header "__wmmintrin_aes.h"

The mmx case above makes sense to me, but I find conceptually odd that we need 
to re-export sse2 in aes module, why not explicitly #include  in 
the source file?


https://reviews.llvm.org/D24752



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


r282504 - Revert "Adapt to LLVM optimization remark interface change. NFC"

2016-09-27 Thread Adam Nemet via cfe-commits
Author: anemet
Date: Tue Sep 27 11:39:27 2016
New Revision: 282504

URL: http://llvm.org/viewvc/llvm-project?rev=282504=rev
Log:
Revert "Adapt to LLVM optimization remark interface change. NFC"

This reverts commit r282500.

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

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=282504=282503=282504=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Tue Sep 27 11:39:27 2016
@@ -514,7 +514,7 @@ void BackendConsumer::EmitOptimizationMe
 
   std::string Msg;
   raw_string_ostream MsgStream(Msg);
-  MsgStream << D.getMsg();
+  MsgStream << D.getMsg().str();
 
   if (D.getHotness())
 MsgStream << " (hotness: " << *D.getHotness() << ")";


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


r282500 - Adapt to LLVM optimization remark interface change. NFC

2016-09-27 Thread Adam Nemet via cfe-commits
Author: anemet
Date: Tue Sep 27 11:15:21 2016
New Revision: 282500

URL: http://llvm.org/viewvc/llvm-project?rev=282500=rev
Log:
Adapt to LLVM optimization remark interface change. NFC

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

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=282500=282499=282500=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Tue Sep 27 11:15:21 2016
@@ -514,7 +514,7 @@ void BackendConsumer::EmitOptimizationMe
 
   std::string Msg;
   raw_string_ostream MsgStream(Msg);
-  MsgStream << D.getMsg().str();
+  MsgStream << D.getMsg();
 
   if (D.getHotness())
 MsgStream << " (hotness: " << *D.getHotness() << ")";


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


[PATCH] D24969: [Sema] Use the instantiated name of destructors in FindInstantiatedDecl and RebuildMemberExpr

2016-09-27 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: doug.gregor, rsmith.
ahatanak added a subscriber: cfe-commits.

This fixes PR30361.

clang was failing to compile the test case because it was passing "~C1" 
instead of "~C1" to FindInstantiatedDecl and RebuildMemberExpr.

https://reviews.llvm.org/D24969

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/destructor.cpp

Index: test/SemaCXX/destructor.cpp
===
--- test/SemaCXX/destructor.cpp
+++ test/SemaCXX/destructor.cpp
@@ -431,3 +431,21 @@
 
 // The constructor definition should not have errors
 Invalid::~Invalid() {}
+
+namespace PR30361 {
+template 
+struct C1 {
+  ~C1() {}
+  void foo1();
+};
+
+template
+void C1::foo1() {
+  C1::~C1();
+}
+
+void foo1() {
+  C1 x;
+  x.foo1();
+}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -2122,6 +2122,11 @@
NamedDecl *FirstQualifierInScope) {
 ExprResult BaseResult = getSema().PerformMemberExprBaseConversion(Base,
   isArrow);
+DeclarationNameInfo DNI = MemberNameInfo;
+
+if (isa(FoundDecl))
+  DNI = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
+
 if (!Member->getDeclName()) {
   // We have a reference to an unnamed field.  This is always the
   // base of an anonymous struct/union member access, i.e. the
@@ -2139,7 +2144,7 @@
   Base = BaseResult.get();
   ExprValueKind VK = isArrow ? VK_LValue : Base->getValueKind();
   MemberExpr *ME = new (getSema().Context)
-  MemberExpr(Base, isArrow, OpLoc, Member, MemberNameInfo,
+  MemberExpr(Base, isArrow, OpLoc, Member, DNI,
  cast(Member)->getType(), VK, OK_Ordinary);
   return ME;
 }
@@ -2152,7 +2157,7 @@
 
 // FIXME: this involves duplicating earlier analysis in a lot of
 // cases; we should avoid this when possible.
-LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
+LookupResult R(getSema(), DNI, Sema::LookupMemberName);
 R.addDecl(FoundDecl);
 R.resolveKind();
 
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4845,7 +4845,11 @@
 
 NamedDecl *Result = nullptr;
 if (D->getDeclName()) {
-  DeclContext::lookup_result Found = ParentDC->lookup(D->getDeclName());
+  DeclarationName Name = D->getDeclName();
+  if (auto *DD = dyn_cast(D))
+Name =
+SubstDeclarationNameInfo(DD->getNameInfo(), 
TemplateArgs).getName();
+  DeclContext::lookup_result Found = ParentDC->lookup(Name);
   Result = findInstantiationOf(Context, D, Found.begin(), Found.end());
 } else {
   // Since we don't have a name for the entity we're looking for,


Index: test/SemaCXX/destructor.cpp
===
--- test/SemaCXX/destructor.cpp
+++ test/SemaCXX/destructor.cpp
@@ -431,3 +431,21 @@
 
 // The constructor definition should not have errors
 Invalid::~Invalid() {}
+
+namespace PR30361 {
+template 
+struct C1 {
+  ~C1() {}
+  void foo1();
+};
+
+template
+void C1::foo1() {
+  C1::~C1();
+}
+
+void foo1() {
+  C1 x;
+  x.foo1();
+}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -2122,6 +2122,11 @@
NamedDecl *FirstQualifierInScope) {
 ExprResult BaseResult = getSema().PerformMemberExprBaseConversion(Base,
   isArrow);
+DeclarationNameInfo DNI = MemberNameInfo;
+
+if (isa(FoundDecl))
+  DNI = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
+
 if (!Member->getDeclName()) {
   // We have a reference to an unnamed field.  This is always the
   // base of an anonymous struct/union member access, i.e. the
@@ -2139,7 +2144,7 @@
   Base = BaseResult.get();
   ExprValueKind VK = isArrow ? VK_LValue : Base->getValueKind();
   MemberExpr *ME = new (getSema().Context)
-  MemberExpr(Base, isArrow, OpLoc, Member, MemberNameInfo,
+  MemberExpr(Base, isArrow, OpLoc, Member, DNI,
  cast(Member)->getType(), VK, OK_Ordinary);
   return ME;
 }
@@ -2152,7 +2157,7 @@
 
 // FIXME: this involves duplicating earlier analysis in a lot of
 // cases; we should avoid this when possible.
-LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
+LookupResult R(getSema(), DNI, Sema::LookupMemberName);
 R.addDecl(FoundDecl);
 R.resolveKind();
 
Index: 

Re: [PATCH] D24800: Merge conflicting replacements when they are order-independent.

2016-09-27 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 72666.
ioeric marked 3 inline comments as done.
ioeric added a comment.

- Addressed review comments.


https://reviews.llvm.org/D24800

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

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -101,18 +101,56 @@
 
 TEST_F(ReplacementTest, FailAddReplacements) {
   Replacements Replaces;
-  auto Err = Replaces.add(Replacement("x.cc", 0, 10, "3"));
+  Replacement Deletion("x.cc", 0, 10, "3");
+  auto Err = Replaces.add(Deletion);
   EXPECT_TRUE(!Err);
   llvm::consumeError(std::move(Err));
-  Err = Replaces.add(Replacement("x.cc", 0, 2, ""));
+  Err = Replaces.add(Replacement("x.cc", 0, 2, "a"));
   EXPECT_TRUE((bool)Err);
   llvm::consumeError(std::move(Err));
-  Err = Replaces.add(Replacement("x.cc", 2, 2, ""));
+  Err = Replaces.add(Replacement("x.cc", 2, 2, "a"));
   EXPECT_TRUE((bool)Err);
   llvm::consumeError(std::move(Err));
   Err = Replaces.add(Replacement("y.cc", 20, 2, ""));
   EXPECT_TRUE((bool)Err);
   llvm::consumeError(std::move(Err));
+  EXPECT_EQ(1u, Replaces.size());
+  EXPECT_EQ(Deletion, *Replaces.begin());
+}
+
+TEST_F(ReplacementTest, DeletionInReplacements) {
+  Replacements Replaces;
+  Replacement R("x.cc", 0, 10, "3");
+  auto Err = Replaces.add(R);
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("x.cc", 0, 2, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("x.cc", 2, 2, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+  EXPECT_EQ(1u, Replaces.size());
+  EXPECT_EQ(R, *Replaces.begin());
+}
+
+TEST_F(ReplacementTest, OverlappingReplacements) {
+  Replacements Replaces;
+  auto Err = Replaces.add(Replacement("x.cc", 0, 3, "345"));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("x.cc", 2, 3, "543"));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  EXPECT_EQ(1u, Replaces.size());
+  EXPECT_EQ(Replacement("x.cc", 0, 5, "34543"), *Replaces.begin());
+
+  Err = Replaces.add(Replacement("x.cc", 2, 1, "5"));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+  EXPECT_EQ(1u, Replaces.size());
+  EXPECT_EQ(Replacement("x.cc", 0, 5, "34543"), *Replaces.begin());
 }
 
 TEST_F(ReplacementTest, AddAdjacentInsertionAndReplacement) {
@@ -137,6 +175,116 @@
   EXPECT_EQ(Replaces.size(), 2u);
 }
 
+TEST_F(ReplacementTest, MergeNewDeletions) {
+  Replacements Replaces;
+  Replacement ContainingReplacement("x.cc", 0, 10, "");
+  auto Err = Replaces.add(ContainingReplacement);
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Err = Replaces.add(Replacement("x.cc", 5, 3, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Err = Replaces.add(Replacement("x.cc", 0, 10, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Err = Replaces.add(Replacement("x.cc", 5, 5, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  EXPECT_EQ(1u, Replaces.size());
+  EXPECT_EQ(*Replaces.begin(), ContainingReplacement);
+}
+
+TEST_F(ReplacementTest, MergeOverlappingButNotAdjacentReplacement) {
+  Replacements Replaces;
+  auto Err = Replaces.add(Replacement("x.cc", 0, 2, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Err = Replaces.add(Replacement("x.cc", 5, 5, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Replacement After = Replacement("x.cc", 10, 5, "");
+  Err = Replaces.add(After);
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Replacement ContainingReplacement("x.cc", 0, 10, "");
+  Err = Replaces.add(ContainingReplacement);
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  EXPECT_EQ(2u, Replaces.size());
+  EXPECT_EQ(*Replaces.begin(), ContainingReplacement);
+  EXPECT_EQ(*(++Replaces.begin()), After);
+}
+
+TEST_F(ReplacementTest, InsertionBeforeMergedDeletions) {
+  Replacements Replaces;
+
+  Replacement Insertion("x.cc", 0, 0, "123");
+  auto Err = Replaces.add(Insertion);
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Err = Replaces.add(Replacement("x.cc", 5, 5, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Replacement Deletion("x.cc", 0, 10, "");
+  Err = Replaces.add(Deletion);
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  EXPECT_EQ(2u, Replaces.size());
+  EXPECT_EQ(*Replaces.begin(), Insertion);
+  EXPECT_EQ(*(++Replaces.begin()), Deletion);
+}
+
+TEST_F(ReplacementTest, MergeOverlappingDeletions) {
+  Replacements Replaces;
+  auto Err = Replaces.add(Replacement("x.cc", 0, 2, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Err = Replaces.add(Replacement("x.cc", 0, 5, 

Re: [PATCH] D24800: Merge conflicting replacements when they are order-independent.

2016-09-27 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Tooling/Core/Replacement.cpp:179-181
@@ +178,5 @@
+llvm::Expected
+Replacements::mergeIfOrderIndependent(const Replacement ) const {
+  Replacements Rs(R);
+  Replacements RsShiftedByReplaces(getReplacementInChangedCode(R));
+  Replacements ReplacesShiftedByRs;

klimek wrote:
> I think this is a bit subtle and needs a lot more comments to guide me along 
> what is happening and why ...
Ahh, right! Should've done that...

Comments added.


https://reviews.llvm.org/D24800



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


Re: [PATCH] D24800: Merge conflicting replacements when they are order-independent.

2016-09-27 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: lib/Tooling/Core/Replacement.cpp:179-181
@@ +178,5 @@
+llvm::Expected
+Replacements::mergeIfOrderIndependent(const Replacement ) const {
+  Replacements Rs(R);
+  Replacements RsShiftedByReplaces(getReplacementInChangedCode(R));
+  Replacements ReplacesShiftedByRs;

I think this is a bit subtle and needs a lot more comments to guide me along 
what is happening and why ...


https://reviews.llvm.org/D24800



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


r282492 - Update to commit r282488, fix the buildboot failure.

2016-09-27 Thread Ayman Musa via cfe-commits
Author: aymanmus
Date: Tue Sep 27 10:37:31 2016
New Revision: 282492

URL: http://llvm.org/viewvc/llvm-project?rev=282492=rev
Log:
Update to commit r282488, fix the buildboot failure.

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=282492=282491=282492=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Tue Sep 27 10:37:31 2016
@@ -9381,13 +9381,13 @@ _mm512_maskz_cvtps_pd (__mmask8 __U, __m
 }
 
 static __inline__ __m512 __DEFAULT_FN_ATTRS
-_mm512_cvtpslo_pd (__m512d __A)
+_mm512_cvtpslo_pd (__m512 __A)
 {
   return (__m512) _mm512_cvtps_pd(_mm512_castps512_ps256(__A));
 }
 
 static __inline__ __m512 __DEFAULT_FN_ATTRS
-_mm512_mask_cvtpslo_pd (__m512d __W, __mmask8 __U, __m512d __A)
+_mm512_mask_cvtpslo_pd (__m512d __W, __mmask8 __U, __m512 __A)
 {
   return (__m512) _mm512_mask_cvtps_pd(__W, __U, _mm512_castps512_ps256(__A));
 }


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


Re: [libcxx] r282483 - [cmake] Add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Joerg Sonnenberger via cfe-commits
On Tue, Sep 27, 2016 at 12:15:35PM -, Michal Gorny via cfe-commits wrote:
> Author: mgorny
> Date: Tue Sep 27 07:15:35 2016
> New Revision: 282483
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=282483=rev
> Log:
> [cmake] Add linker option "-Wl,-z,defs" in standalone build
> 
> Add the "-Wl,-z,defs" linker option that is used to prevent
> underlinking. It is already used by LLVM itself but does not get
> propagated into stand-alone build of libc++. This patch ensures
> that the option is passed in independently of whether libc++ is built
> in-tree or out-of-tree.

Can we turn this into a positive list on platforms where it is known to
work? While I generally find it useful, linker and (GCC) spec stupidity
can easily break it.

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


Re: [PATCH] D14326: ASTImporter: expressions, pt.2

2016-09-27 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM with two minor nits.



Comment at: lib/AST/ASTImporter.cpp:5563-5564
@@ +5562,4 @@
+const TemplateArgumentLoc *FromArgArray = E->getTemplateArgs();
+for (unsigned i = 0, e = E->getNumTemplateArgs(); i < e; i++) {
+  const TemplateArgumentLoc  = FromArgArray[i];
+  bool Error = false;

Any particular reason not to use a range-based for loop over 
`template_arguments()`?


Comment at: lib/AST/ASTImporter.cpp:6283
@@ +6282,3 @@
+
+
+Expr *ASTNodeImporter::VisitCXXNewExpr(CXXNewExpr *CE) {

Spurious newline.


https://reviews.llvm.org/D14326



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


Re: [PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-27 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 72653.
rmaprath added a comment.
Herald added subscribers: mgorny, beanz.

Address review comments from @compnerd and @EricWF.


https://reviews.llvm.org/D24864

Files:
  CMakeLists.txt
  src/config.h
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/fallback_malloc.ipp
  src/threading_support.h
  test/test_fallback_malloc.pass.cpp

Index: test/test_fallback_malloc.pass.cpp
===
--- test/test_fallback_malloc.pass.cpp
+++ test/test_fallback_malloc.pass.cpp
@@ -10,7 +10,7 @@
 #include 
 #include 
 
-#include 
+#include "../src/threading_support.h"
 
 typedef std::deque container;
 
Index: src/threading_support.h
===
--- /dev/null
+++ src/threading_support.h
@@ -0,0 +1,82 @@
+//=== threading_support.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCXXABI_THREADING_SUPPORT_H
+#define _LIBCXXABI_THREADING_SUPPORT_H
+
+#include "__cxxabi_config.h"
+#include "config.h"
+
+#ifndef _LIBCXXABI_HAS_NO_THREADS
+
+#if defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
+#include 
+
+#define _LIBCXXABI_THREAD_ABI_VISIBILITY inline _LIBCXXABI_INLINE_VISIBILITY
+
+// Mutex
+typedef pthread_mutex_t __libcxxabi_mutex_t;
+#define _LIBCXXABI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_lock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_lock(mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_unlock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_unlock(mutex);
+}
+
+// Condition variable
+typedef pthread_cond_t __libcxxabi_condvar_t;
+#define _LIBCXXABI_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_wait(__libcxxabi_condvar_t *cv,
+ __libcxxabi_mutex_t *mutex) {
+  return pthread_cond_wait(cv, mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_broadcast(__libcxxabi_condvar_t *cv) {
+  return pthread_cond_broadcast(cv);
+}
+
+// Execute once
+typedef pthread_once_t __libcxxabi_exec_once_flag;
+#define _LIBCXXABI_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_execute_once(__libcxxabi_exec_once_flag *flag,
+ void (*init_routine)(void)) {
+  return pthread_once(flag, init_routine);
+}
+
+// TLS
+typedef pthread_key_t __libcxxabi_tls_key;
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_tls_create(__libcxxabi_tls_key *key,
+   void (*destructor)(void *)) {
+  return pthread_key_create(key, destructor);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+void *__libcxxabi_tls_get(__libcxxabi_tls_key key) {
+  return pthread_getspecific(key);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_tls_set(__libcxxabi_tls_key key, void *value) {
+  return pthread_setspecific(key, value);
+}
+#endif // _LIBCXXABI_USE_THREAD_API_PTHREAD
+#endif // !_LIBCXXABI_HAS_NO_THREADS
+#endif // _LIBCXXABI_THREADING_SUPPORT_H
Index: src/fallback_malloc.ipp
===
--- src/fallback_malloc.ipp
+++ src/fallback_malloc.ipp
@@ -27,25 +27,25 @@
 
 // When POSIX threads are not available, make the mutex operations a nop
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER;
+static __libcxxabi_mutex_t heap_mutex = _LIBCXXABI_MUTEX_INITIALIZER;
 #else
 static void * heap_mutex = 0;
 #endif
 
 class mutexor {
 public:
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-mutexor ( pthread_mutex_t *m ) : mtx_(m) { pthread_mutex_lock ( mtx_ ); }
-~mutexor () { pthread_mutex_unlock ( mtx_ ); }
+mutexor ( __libcxxabi_mutex_t *m ) : mtx_(m) { __libcxxabi_mutex_lock ( mtx_ ); }
+~mutexor () { __libcxxabi_mutex_unlock ( mtx_ ); }
 #else
 mutexor ( void * ) {}
 ~mutexor () {}
 #endif
 private:
 mutexor ( const mutexor  );
 mutexor & operator = ( const mutexor  );
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-pthread_mutex_t *mtx_;
+__libcxxabi_mutex_t *mtx_;
 #endif
 };
 
Index: src/cxa_guard.cpp
===
--- src/cxa_guard.cpp
+++ src/cxa_guard.cpp
@@ -11,20 +11,18 @@
 
 #include "abort_message.h"
 #include "config.h"
+#include "threading_support.h"
 
-#ifndef _LIBCXXABI_HAS_NO_THREADS
-#  include 
-#endif
 #include 
 
 /*
 This implementation must be careful to not call code external to this file
 which will turn around and try to call __cxa_guard_acquire reentrantly.
 For this reason, the headers of this 

[PATCH] D24965: [clang-tidy] Fix cppcoreguidelines-pro-type-member-init false negatives

2016-09-27 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: alexfh, aaron.ballman, omtcyfz.
malcolm.parsons added subscribers: cfe-commits, mgehre.
Herald added a subscriber: nemanjai.

Handle classes with default constructors that are defaulted or are not
present in the AST.
Classes with virtual methods or virtual bases are not trivially
default constructible, so their members and bases need to be initialized.

https://reviews.llvm.org/D24965

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
  clang-tidy/utils/TypeTraits.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -367,3 +367,25 @@
   PositiveIndirectMember() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields: A
 };
+
+struct PositiveVirtualMethod {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize these fields: F
+  int F;
+  // CHECK-FIXES: int F{};
+  virtual int f() = 0;
+};
+
+struct PositiveVirtualDestructor {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize these fields: F
+  PositiveVirtualDestructor() = default;
+  int F;
+  // CHECK-FIXES: int F{};
+  virtual ~PositiveVirtualDestructor() {}
+};
+
+struct PositiveVirtualBase : public virtual NegativeAggregateType {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize these bases: NegativeAggregateType
+  // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: constructor does not initialize these fields: F
+  int F;
+  // CHECK-FIXES: int F{};
+};
Index: clang-tidy/utils/TypeTraits.cpp
===
--- clang-tidy/utils/TypeTraits.cpp
+++ clang-tidy/utils/TypeTraits.cpp
@@ -58,6 +58,9 @@
   // constructible.
   if (ClassDecl->hasUserProvidedDefaultConstructor())
 return false;
+  // A polymorphic class is not trivially constructible
+  if (ClassDecl->isPolymorphic())
+return false;
   // A class is trivially constructible if it has a trivial default constructor.
   if (ClassDecl->hasTrivialDefaultConstructor())
 return true;
@@ -71,6 +74,8 @@
   for (const CXXBaseSpecifier  : ClassDecl->bases()) {
 if (!isTriviallyDefaultConstructible(Base.getType(), Context))
   return false;
+if (Base.isVirtual())
+  return false;
   }
 
   return true;
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
@@ -46,11 +46,13 @@
   // To fix: Write a data member initializer, or mention it in the member
   // initializer list.
   void checkMissingMemberInitializer(ASTContext ,
+ const CXXRecordDecl *ClassDecl,
  const CXXConstructorDecl *Ctor);
 
   // A subtle side effect of Type.6 part 2:
   // Make sure to initialize trivially constructible base classes.
   void checkMissingBaseClassInitializer(const ASTContext ,
+const CXXRecordDecl *ClassDecl,
 const CXXConstructorDecl *Ctor);
 
   // Checks Type.6 part 2:
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -269,6 +269,19 @@
IsNonTrivialDefaultConstructor))
   .bind("ctor"),
   this);
+
+  // Match classes with a default constructor that is defaulted or is not in the
+  // AST.
+  Finder->addMatcher(
+  cxxRecordDecl(
+  isDefinition(),
+  anyOf(has(cxxConstructorDecl(isDefaultConstructor(), isDefaulted(),
+   unless(isImplicit(,
+unless(has(cxxConstructorDecl(,
+  unless(isTriviallyDefaultConstructible()))
+  .bind("record"),
+  this);
+
   auto HasDefaultConstructor = hasInitializer(
   cxxConstructExpr(unless(requiresZeroInitialization()),
hasDeclaration(cxxConstructorDecl(
@@ -287,8 +300,13 @@
 // Skip declarations delayed by late template parsing without a body.
 if (!Ctor->getBody())
   return;
-checkMissingMemberInitializer(*Result.Context, Ctor);
-checkMissingBaseClassInitializer(*Result.Context, Ctor);
+checkMissingMemberInitializer(*Result.Context, Ctor->getParent(), Ctor);
+checkMissingBaseClassInitializer(*Result.Context, Ctor->getParent(), Ctor);
+  } else if 

Re: [PATCH] D24119: [libc++] add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: libcxx/trunk/CMakeLists.txt:329
@@ +328,3 @@
+  ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND
+ NOT LLVM_USE_SANITIZER)
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")

zlei wrote:
> rmaprath wrote:
> > Perhaps we should exclude `LIBCXX_HAS_EXTERNAL_THREAD_API` as well? Because 
> > there we explicitly strip off these flags.
> I agree. Could you prepare a patch for it?
> 
> BTW, I really don't like duplicating code snippet from llvm. Is there any 
> better solution for that?
Sure, I'll do a patch.

Btw, I think this configuration is better placed in `HandleOutOfTreeLLVM.cmake` 
module.

I'll see if I can find a better way to do this.


Repository:
  rL LLVM

https://reviews.llvm.org/D24119



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


Re: [PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-27 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: src/config.h:22
@@ +21,3 @@
+
+#if defined(__GNUC__) || defined(__clang__)
+#define _LIBCXXABI_PRAGMA(_parameter_) _Pragma(#_parameter_)

EricWF wrote:
> What's the point of defining `_LIBCXXABI_WARNING`? It's unused and seems 
> unneeded.
Good catch. I have copy-pasted this lot without checking.


Comment at: src/config.h:41
@@ +40,3 @@
+defined(__CloudABI__) || \
+defined(__sun__)
+#  define _LIBCXXABI_HAS_THREAD_API_PTHREAD

compnerd wrote:
> Can you change this to `defined(__sun__) && defined(_POSIX_THREADS)` at the 
> very least?  There is no reason to assume pthreads on Solaris.  Solaris 
> Threads are a valid threading model.
Not sure if I understand completely, `libcxxabi` currently either supports 
`pthread` or no-threads, either of which can be explicitly configured through a 
cmake option. So I don't see the point in checking for `_POSIX_THREADS` here as 
the only current threading option is `pthread`. When we add another threading 
system into the mix (like external threading), that too will be configurable 
with a cmake option, the defaulting to `pthread` is only when no particular 
threading system is selected.

Or is it that `pthread.h` et. al can be provided by Solaris Threads as well? 
So, the pthread API has two implementations on Solaris?


Comment at: src/config.h:42
@@ +41,3 @@
+defined(__sun__)
+#  define _LIBCXXABI_HAS_THREAD_API_PTHREAD
+# else

compnerd wrote:
> Can we use `_LIBCXXABI_USE_THREAD_API_PTHREAD` instead?  You can have more 
> than one threading API on a platform, and wish to use a specific one.
Makes sense. Need to change the convention used in `libcxx` too, but that can 
be done later.


Comment at: src/config.h:46
@@ +45,3 @@
+# endif
+#endif
+

compnerd wrote:
> I really think that we should use `_POSIX_THREADS` macro rather than this 
> enumeration approach.
`_LIBCXXABI_USE_THREAD_API_` allows us to be consistent with naming of the 
different threading variants (e.g. I'm going to add 
`_LIBCXXABI_USE_THREAD_API_EXTENRAL` soon). Is there some functional benefit to 
using `_POSIX_THREADS` for the pthread variant?


Comment at: src/fallback_malloc.ipp:30
@@ -29,3 +29,3 @@
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER;
+static __libcxxabi_mutex_t heap_mutex = _LIBCXXABI_MUTEX_INITIALIZER;
 #else

Thanks for the catch.


https://reviews.llvm.org/D24864



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


Re: [PATCH] D24717: Merge deletions that are contained in a larger deletion.

2016-09-27 Thread Eric Liu via cfe-commits
ioeric abandoned this revision.
ioeric added a comment.

Abandon in favor of https://reviews.llvm.org/D24800


https://reviews.llvm.org/D24717



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


Re: [PATCH] D24119: [libc++] add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Lei Zhang via cfe-commits
zlei added inline comments.


Comment at: libcxx/trunk/CMakeLists.txt:329
@@ +328,3 @@
+  ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND
+ NOT LLVM_USE_SANITIZER)
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")

rmaprath wrote:
> Perhaps we should exclude `LIBCXX_HAS_EXTERNAL_THREAD_API` as well? Because 
> there we explicitly strip off these flags.
I agree. Could you prepare a patch for it?

BTW, I really don't like duplicating code snippet from llvm. Is there any 
better solution for that?


Repository:
  rL LLVM

https://reviews.llvm.org/D24119



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


[PATCH] D24963: [change-namespace] fix namespace specifier of global variables.

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

https://reviews.llvm.org/D24963

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -447,6 +447,72 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, MoveAndFixGlobalVariables) {
+  std::string Code = "namespace na {\n"
+ "int GlobA;\n"
+ "static int GlobAStatic = 0;\n"
+ "namespace nc { int GlobC; }\n"
+ "namespace nb {\n"
+ "int GlobB;\n"
+ "void f() {\n"
+ "  int a = GlobA;\n"
+ "  int b = GlobAStatic;\n"
+ "  int c = nc::GlobC;\n"
+ "}\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+
+  std::string Expected = "namespace na {\n"
+ "int GlobA;\n"
+ "static int GlobAStatic = 0;\n"
+ "namespace nc { int GlobC; }\n"
+ "\n"
+ "} // namespace na\n"
+ "namespace x {\n"
+ "namespace y {\n"
+ "int GlobB;\n"
+ "void f() {\n"
+ "  int a = na::GlobA;\n"
+ "  int b = na::GlobAStatic;\n"
+ "  int c = na::nc::GlobC;\n"
+ "}\n"
+ "}  // namespace y\n"
+ "}  // namespace x\n";
+
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, DoNotFixStaticVariableOfClass) {
+  std::string Code = "namespace na {\n"
+ "class A {\n"
+ "public:\n"
+ "static int A1;\n"
+ "static int A2;\n"
+ "}\n"
+ "static int A::A1 = 0;\n"
+ "namespace nb {\n"
+ "void f() { int a = A::A1; int b = A::A2; }"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+
+  std::string Expected = "namespace na {\n"
+ "class A {\n"
+ "public:\n"
+ "static int A1;\n"
+ "static int A2;\n"
+ "}\n"
+ "static int A::A1 = 0;\n"
+ "\n"
+ "} // namespace na\n"
+ "namespace x {\n"
+ "namespace y {\n"
+ "void f() { int a = na::A::A1; int b = na::A::A2; }"
+ "}  // namespace y\n"
+ "}  // namespace x\n";
+
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -230,8 +230,6 @@
   DiffNewNamespace = joinNamespaces(NewNsSplitted);
 }
 
-// FIXME: handle the following symbols:
-//   - Variable references.
 void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
   // Match old namespace blocks.
   std::string FullOldNs = "::" + OldNamespace;
@@ -303,6 +301,14 @@
IsInMovedNs, unless(isImplicit()))
   .bind("dc"),
   this);
+
+  auto GlobalVarMatcher = varDecl(
+  hasGlobalStorage(), hasParent(namespaceDecl()),
+  unless(anyOf(IsInMovedNs, hasAncestor(namespaceDecl(isAnonymous());
+  Finder->addMatcher(declRefExpr(IsInMovedNs, hasAncestor(decl().bind("dc")),
+ to(GlobalVarMatcher.bind("var_decl")))
+ .bind("var_ref"),
+ this);
 }
 
 void ChangeNamespaceTool::run(
@@ -324,8 +330,19 @@
   } else if (const auto *TLoc = Result.Nodes.getNodeAs("type")) {
 fixTypeLoc(Result, startLocationForType(*TLoc), EndLocationForType(*TLoc),
*TLoc);
+  } else if (const auto *VarRef = Result.Nodes.getNodeAs("var_ref")){
+const auto *Var = Result.Nodes.getNodeAs("var_decl");
+assert(Var);
+if (Var->getCanonicalDecl()->isStaticDataMember())
+  return;
+std::string Name = Var->getQualifiedNameAsString();
+const clang::Decl *Context = Result.Nodes.getNodeAs("dc");
+assert(Context && "Empty decl context.");
+clang::SourceRange VarRefRange = 

r282488 - [avx512] Add aliases to some missing avx512 intrinsics.

2016-09-27 Thread Ayman Musa via cfe-commits
Author: aymanmus
Date: Tue Sep 27 09:06:32 2016
New Revision: 282488

URL: http://llvm.org/viewvc/llvm-project?rev=282488=rev
Log:
[avx512] Add aliases to some missing avx512 intrinsics.

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

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

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=282488=282487=282488=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Tue Sep 27 09:06:32 2016
@@ -3555,10 +3555,49 @@ _mm512_mask_blend_epi32(__mmask16 __U, _
 
 #define _mm512_cmp_ps_mask(A, B, P) \
   _mm512_cmp_round_ps_mask((A), (B), (P), _MM_FROUND_CUR_DIRECTION)
-
 #define _mm512_mask_cmp_ps_mask(U, A, B, P) \
   _mm512_mask_cmp_round_ps_mask((U), (A), (B), (P), _MM_FROUND_CUR_DIRECTION)
 
+#define _mm512_cmpeq_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_EQ_OQ)
+#define _mm512_mask_cmpeq_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_EQ_OQ)
+
+#define _mm512_cmplt_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_LT_OS)
+#define _mm512_mask_cmplt_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_LT_OS)
+
+#define _mm512_cmple_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_LE_OS)
+#define _mm512_mask_cmple_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_LE_OS)
+
+#define _mm512_cmpunord_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_UNORD_Q)
+#define _mm512_mask_cmpunord_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_UNORD_Q)
+
+#define _mm512_cmpneq_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_NEQ_UQ)
+#define _mm512_mask_cmpneq_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_NEQ_UQ)
+
+#define _mm512_cmpnlt_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_NLT_US)
+#define _mm512_mask_cmpnlt_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_NLT_US)
+
+#define _mm512_cmpnle_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_NLE_US)
+#define _mm512_mask_cmpnle_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_NLE_US)
+
+#define _mm512_cmpord_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_ORD_Q)
+#define _mm512_mask_cmpord_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_ORD_Q)
+
 #define _mm512_cmp_round_pd_mask(A, B, P, R) __extension__ ({ \
   (__mmask8)__builtin_ia32_cmppd512_mask((__v8df)(__m512d)(A), \
  (__v8df)(__m512d)(B), (int)(P), \
@@ -3571,10 +3610,49 @@ _mm512_mask_blend_epi32(__mmask16 __U, _
 
 #define _mm512_cmp_pd_mask(A, B, P) \
   _mm512_cmp_round_pd_mask((A), (B), (P), _MM_FROUND_CUR_DIRECTION)
-
 #define _mm512_mask_cmp_pd_mask(U, A, B, P) \
   _mm512_mask_cmp_round_pd_mask((U), (A), (B), (P), _MM_FROUND_CUR_DIRECTION)
 
+#define _mm512_cmpeq_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_EQ_OQ)
+#define _mm512_mask_cmpeq_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_EQ_OQ)
+
+#define _mm512_cmplt_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_LT_OS)
+#define _mm512_mask_cmplt_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_LT_OS)
+
+#define _mm512_cmple_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_LE_OS)
+#define _mm512_mask_cmple_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_LE_OS)
+
+#define _mm512_cmpunord_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_UNORD_Q)
+#define _mm512_mask_cmpunord_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_UNORD_Q)
+
+#define _mm512_cmpneq_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_NEQ_UQ)
+#define _mm512_mask_cmpneq_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_NEQ_UQ)
+
+#define _mm512_cmpnlt_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_NLT_US)
+#define _mm512_mask_cmpnlt_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_NLT_US)
+
+#define _mm512_cmpnle_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_NLE_US)
+#define _mm512_mask_cmpnle_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_NLE_US)
+
+#define _mm512_cmpord_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_ORD_Q)
+#define _mm512_mask_cmpord_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_ORD_Q)
+
 /* Conversion */
 
 #define _mm512_cvtt_roundps_epu32(A, R) __extension__ ({ \
@@ -3703,6 +3781,18 @@ _mm512_maskz_cvtepi32_pd (__mmask8 __U,
 (__mmask8) __U);
 }
 
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_cvtepi32lo_pd(__m512i __A)
+{
+  return (__m512d) _mm512_cvtepi32_pd(_mm512_castsi512_si256(__A));
+}
+
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_mask_cvtepi32lo_pd(__m512d __W, 

Re: [PATCH] D24962: [ASTMatchers] Let registerMatcher() take a const char * instead of a StringRef

2016-09-27 Thread Martin Böhme via cfe-commits
mboehme abandoned this revision.
mboehme added a comment.

Abandoning after discussion with klimek.


https://reviews.llvm.org/D24962



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


Re: [PATCH] D24119: [libc++] add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Asiri Rathnayake via cfe-commits
rmaprath added a subscriber: rmaprath.


Comment at: libcxx/trunk/CMakeLists.txt:329
@@ +328,3 @@
+  ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND
+ NOT LLVM_USE_SANITIZER)
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")

Perhaps we should exclude `LIBCXX_HAS_EXTERNAL_THREAD_API` as well? Because 
there we explicitly strip off these flags.


Repository:
  rL LLVM

https://reviews.llvm.org/D24119



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


[PATCH] D24962: [ASTMatchers] Let registerMatcher() take a const char * instead of a StringRef

2016-09-27 Thread Martin Böhme via cfe-commits
mboehme created this revision.
mboehme added a reviewer: klimek.
mboehme added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

r282433 added LLVM_ATTRIBUTE_ALWAYS_INLINE to the StringRef(const char *)
constructor. This causes the size of the stack frame for
RegistryMaps::RegistryMaps() to become excessive when compiling with gcc. This
change avoids inlining the StringRef constructor for every REGISTER_MATCHER
line.

https://reviews.llvm.org/D24962

Files:
  lib/ASTMatchers/Dynamic/Registry.cpp

Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -40,11 +40,11 @@
   const ConstructorMap () const { return Constructors; }
 
 private:
-  void registerMatcher(StringRef MatcherName, MatcherDescriptor *Callback);
+  void registerMatcher(const char *MatcherName, MatcherDescriptor *Callback);
   ConstructorMap Constructors;
 };
 
-void RegistryMaps::registerMatcher(StringRef MatcherName,
+void RegistryMaps::registerMatcher(const char *MatcherName,
MatcherDescriptor *Callback) {
   assert(Constructors.find(MatcherName) == Constructors.end());
   Constructors[MatcherName] = Callback;


Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -40,11 +40,11 @@
   const ConstructorMap () const { return Constructors; }
 
 private:
-  void registerMatcher(StringRef MatcherName, MatcherDescriptor *Callback);
+  void registerMatcher(const char *MatcherName, MatcherDescriptor *Callback);
   ConstructorMap Constructors;
 };
 
-void RegistryMaps::registerMatcher(StringRef MatcherName,
+void RegistryMaps::registerMatcher(const char *MatcherName,
MatcherDescriptor *Callback) {
   assert(Constructors.find(MatcherName) == Constructors.end());
   Constructors[MatcherName] = Callback;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24961: [avx512] Add aliases to some missing avx512 intrinsics.

2016-09-27 Thread Igor Breger via cfe-commits
igorb accepted this revision.
igorb added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D24961



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


Re: [PATCH] D24800: Merge conflicting replacements when they are order-independent.

2016-09-27 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Tooling/Core/Replacement.cpp:179-181
@@ +178,5 @@
+Replacements::mergeIfOrderIndependent(const Replacement ) const {
+  Replacements Rs(R);
+  Replacements ShiftedRs(getReplacementInChangedCode(R));
+  Replacements ShiftedReplaces;
+  for (const auto  : Replaces)

klimek wrote:
> These names are confusing me...
> 
Trying to make names less confusing... any better now? 


Comment at: lib/Tooling/Core/Replacement.cpp:184
@@ +183,3 @@
+ShiftedReplaces.Replaces.insert(Rs.getReplacementInChangedCode(Replace));
+  auto MergeRs = merge(ShiftedRs);
+  auto MergeReplaces = Rs.merge(ShiftedReplaces);

klimek wrote:
> This comes from a single replacement - why do we need to call merge?
Because it refers to code after `Replaces` are applied?


https://reviews.llvm.org/D24800



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


Re: [PATCH] D24800: Merge conflicting replacements when they are order-independent.

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

- Addressed review comments.


https://reviews.llvm.org/D24800

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

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -101,18 +101,56 @@
 
 TEST_F(ReplacementTest, FailAddReplacements) {
   Replacements Replaces;
-  auto Err = Replaces.add(Replacement("x.cc", 0, 10, "3"));
+  Replacement Deletion("x.cc", 0, 10, "3");
+  auto Err = Replaces.add(Deletion);
   EXPECT_TRUE(!Err);
   llvm::consumeError(std::move(Err));
-  Err = Replaces.add(Replacement("x.cc", 0, 2, ""));
+  Err = Replaces.add(Replacement("x.cc", 0, 2, "a"));
   EXPECT_TRUE((bool)Err);
   llvm::consumeError(std::move(Err));
-  Err = Replaces.add(Replacement("x.cc", 2, 2, ""));
+  Err = Replaces.add(Replacement("x.cc", 2, 2, "a"));
   EXPECT_TRUE((bool)Err);
   llvm::consumeError(std::move(Err));
   Err = Replaces.add(Replacement("y.cc", 20, 2, ""));
   EXPECT_TRUE((bool)Err);
   llvm::consumeError(std::move(Err));
+  EXPECT_EQ(1u, Replaces.size());
+  EXPECT_EQ(Deletion, *Replaces.begin());
+}
+
+TEST_F(ReplacementTest, DeletionInReplacements) {
+  Replacements Replaces;
+  Replacement R("x.cc", 0, 10, "3");
+  auto Err = Replaces.add(R);
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("x.cc", 0, 2, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("x.cc", 2, 2, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+  EXPECT_EQ(1u, Replaces.size());
+  EXPECT_EQ(R, *Replaces.begin());
+}
+
+TEST_F(ReplacementTest, OverlappingReplacements) {
+  Replacements Replaces;
+  auto Err = Replaces.add(Replacement("x.cc", 0, 3, "345"));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("x.cc", 2, 3, "543"));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  EXPECT_EQ(1u, Replaces.size());
+  EXPECT_EQ(Replacement("x.cc", 0, 5, "34543"), *Replaces.begin());
+
+  Err = Replaces.add(Replacement("x.cc", 2, 1, "5"));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+  EXPECT_EQ(1u, Replaces.size());
+  EXPECT_EQ(Replacement("x.cc", 0, 5, "34543"), *Replaces.begin());
 }
 
 TEST_F(ReplacementTest, AddAdjacentInsertionAndReplacement) {
@@ -137,6 +175,116 @@
   EXPECT_EQ(Replaces.size(), 2u);
 }
 
+TEST_F(ReplacementTest, MergeNewDeletions) {
+  Replacements Replaces;
+  Replacement ContainingReplacement("x.cc", 0, 10, "");
+  auto Err = Replaces.add(ContainingReplacement);
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Err = Replaces.add(Replacement("x.cc", 5, 3, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Err = Replaces.add(Replacement("x.cc", 0, 10, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Err = Replaces.add(Replacement("x.cc", 5, 5, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  EXPECT_EQ(1u, Replaces.size());
+  EXPECT_EQ(*Replaces.begin(), ContainingReplacement);
+}
+
+TEST_F(ReplacementTest, MergeOverlappingButNotAdjacentReplacement) {
+  Replacements Replaces;
+  auto Err = Replaces.add(Replacement("x.cc", 0, 2, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Err = Replaces.add(Replacement("x.cc", 5, 5, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Replacement After = Replacement("x.cc", 10, 5, "");
+  Err = Replaces.add(After);
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Replacement ContainingReplacement("x.cc", 0, 10, "");
+  Err = Replaces.add(ContainingReplacement);
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  EXPECT_EQ(2u, Replaces.size());
+  EXPECT_EQ(*Replaces.begin(), ContainingReplacement);
+  EXPECT_EQ(*(++Replaces.begin()), After);
+}
+
+TEST_F(ReplacementTest, InsertionBeforeMergedDeletions) {
+  Replacements Replaces;
+
+  Replacement Insertion("x.cc", 0, 0, "123");
+  auto Err = Replaces.add(Insertion);
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Err = Replaces.add(Replacement("x.cc", 5, 5, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Replacement Deletion("x.cc", 0, 10, "");
+  Err = Replaces.add(Deletion);
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  EXPECT_EQ(2u, Replaces.size());
+  EXPECT_EQ(*Replaces.begin(), Insertion);
+  EXPECT_EQ(*(++Replaces.begin()), Deletion);
+}
+
+TEST_F(ReplacementTest, MergeOverlappingDeletions) {
+  Replacements Replaces;
+  auto Err = Replaces.add(Replacement("x.cc", 0, 2, ""));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Err = Replaces.add(Replacement("x.cc", 0, 5, 

[PATCH] D24961: [avx512] Add aliases to some missing avx512 intrinsics.

2016-09-27 Thread Ayman Musa via cfe-commits
aymanmus created this revision.
aymanmus added reviewers: m_zuckerman, igorb, delena.
aymanmus added a subscriber: cfe-commits.

- "//_mm512_cmp_pd_mask//" Intrinsics, where  = {eq, le, lt, neq, nle, 
nlt, ord, unord}.
- //_mm512_cvtepi32lo_pd, _mm512_mask_cvtepi32lo_pd, _mm512_cvtepu32lo_pd, 
_mm512_mask_cvtepu32lo_pd//
- //_mm512_cvtpd_pslo, _mm512_mask_cvtpd_pslo, _mm512_cvtpslo_pd, 
_mm512_mask_cvtpslo_pd//

https://reviews.llvm.org/D24961

Files:
  lib/Headers/avx512fintrin.h
  test/CodeGen/avx512f-builtins.c

Index: lib/Headers/avx512fintrin.h
===
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -3555,10 +3555,49 @@
 
 #define _mm512_cmp_ps_mask(A, B, P) \
   _mm512_cmp_round_ps_mask((A), (B), (P), _MM_FROUND_CUR_DIRECTION)
-
 #define _mm512_mask_cmp_ps_mask(U, A, B, P) \
   _mm512_mask_cmp_round_ps_mask((U), (A), (B), (P), _MM_FROUND_CUR_DIRECTION)
 
+#define _mm512_cmpeq_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_EQ_OQ)
+#define _mm512_mask_cmpeq_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_EQ_OQ)
+
+#define _mm512_cmplt_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_LT_OS)
+#define _mm512_mask_cmplt_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_LT_OS)
+
+#define _mm512_cmple_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_LE_OS)
+#define _mm512_mask_cmple_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_LE_OS)
+
+#define _mm512_cmpunord_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_UNORD_Q)
+#define _mm512_mask_cmpunord_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_UNORD_Q)
+
+#define _mm512_cmpneq_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_NEQ_UQ)
+#define _mm512_mask_cmpneq_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_NEQ_UQ)
+
+#define _mm512_cmpnlt_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_NLT_US)
+#define _mm512_mask_cmpnlt_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_NLT_US)
+
+#define _mm512_cmpnle_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_NLE_US)
+#define _mm512_mask_cmpnle_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_NLE_US)
+
+#define _mm512_cmpord_ps_mask(A, B) \
+_mm512_cmp_ps_mask((A), (B), _CMP_ORD_Q)
+#define _mm512_mask_cmpord_ps_mask(k, A, B) \
+_mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_ORD_Q)
+
 #define _mm512_cmp_round_pd_mask(A, B, P, R) __extension__ ({ \
   (__mmask8)__builtin_ia32_cmppd512_mask((__v8df)(__m512d)(A), \
  (__v8df)(__m512d)(B), (int)(P), \
@@ -3571,10 +3610,49 @@
 
 #define _mm512_cmp_pd_mask(A, B, P) \
   _mm512_cmp_round_pd_mask((A), (B), (P), _MM_FROUND_CUR_DIRECTION)
-
 #define _mm512_mask_cmp_pd_mask(U, A, B, P) \
   _mm512_mask_cmp_round_pd_mask((U), (A), (B), (P), _MM_FROUND_CUR_DIRECTION)
 
+#define _mm512_cmpeq_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_EQ_OQ)
+#define _mm512_mask_cmpeq_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_EQ_OQ)
+
+#define _mm512_cmplt_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_LT_OS)
+#define _mm512_mask_cmplt_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_LT_OS)
+
+#define _mm512_cmple_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_LE_OS)
+#define _mm512_mask_cmple_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_LE_OS)
+
+#define _mm512_cmpunord_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_UNORD_Q)
+#define _mm512_mask_cmpunord_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_UNORD_Q)
+
+#define _mm512_cmpneq_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_NEQ_UQ)
+#define _mm512_mask_cmpneq_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_NEQ_UQ)
+
+#define _mm512_cmpnlt_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_NLT_US)
+#define _mm512_mask_cmpnlt_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_NLT_US)
+
+#define _mm512_cmpnle_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_NLE_US)
+#define _mm512_mask_cmpnle_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_NLE_US)
+
+#define _mm512_cmpord_pd_mask(A, B) \
+_mm512_cmp_pd_mask((A), (B), _CMP_ORD_Q)
+#define _mm512_mask_cmpord_pd_mask(k, A, B) \
+_mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_ORD_Q)
+
 /* Conversion */
 
 #define _mm512_cvtt_roundps_epu32(A, R) __extension__ ({ \
@@ -3703,6 +3781,18 @@
 (__mmask8) __U);
 }
 
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_cvtepi32lo_pd(__m512i __A)
+{
+  return (__m512d) _mm512_cvtepi32_pd(_mm512_castsi512_si256(__A));
+}
+
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_mask_cvtepi32lo_pd(__m512d __W, __mmask8 __U,__m512i __A)
+{
+  return (__m512d) _mm512_mask_cvtepi32_pd(__W, __U, _mm512_castsi512_si256(__A));
+}
+
 static 

  1   2   >