r263202 - [OpenMP] NFC fix compilation warning about unused variable

2016-03-11 Thread Dmitry Polukhin via cfe-commits
Author: dpolukhin
Date: Fri Mar 11 01:58:34 2016
New Revision: 263202

URL: http://llvm.org/viewvc/llvm-project?rev=263202&view=rev
Log:
[OpenMP] NFC fix compilation warning about unused variable

lib/Sema/SemaOpenMP.cpp:9243:13: warning: variable ‘IsRightMostExpression’ set 
but not used

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

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=263202&r1=263201&r2=263202&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Mar 11 01:58:34 2016
@@ -9240,8 +9240,7 @@ static Expr *CheckMapClauseExpressionBas
   bool AllowUnitySizeArraySection = true;
   bool AllowWholeSizeArraySection = true;
 
-  for (bool IsRightMostExpression = true; !RelevantExpr;
-   IsRightMostExpression = false) {
+  while (!RelevantExpr) {
 E = E->IgnoreParenImpCasts();
 
 if (auto *CurE = dyn_cast(E)) {


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


Re: [PATCH] D18024: Remove compile time PreserveName switch based on NDEBUG

2016-03-11 Thread Chandler Carruth via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D18024



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


r263210 - Update to include the new header file providing createGVNPass.

2016-03-11 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Fri Mar 11 03:02:43 2016
New Revision: 263210

URL: http://llvm.org/viewvc/llvm-project?rev=263210&view=rev
Log:
Update to include the new header file providing createGVNPass.

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

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=263210&r1=263209&r2=263210&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Mar 11 03:02:43 2016
@@ -42,6 +42,7 @@
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
+#include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include 
 using namespace clang;


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


Re: [PATCH] D17958: [clang-tidy] Make 'modernize-use-nullptr' check ignores NULL marcos used in other macros.

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

Patch looks good, only one cosmetic comment.



Comment at: clang-tidy/modernize/UseNullptrCheck.cpp:232
@@ +231,3 @@
+  if (!getMacroAndArgLocations(StartLoc, ImmediateMarcoArgLoc, MacroLoc)
+  || ImmediateMarcoArgLoc != FileLocStart)
+return skipSubTree();

This doesn't look clang-formatted.


Repository:
  rL LLVM

http://reviews.llvm.org/D17958



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


Re: [PATCH] D17958: [clang-tidy] Make 'modernize-use-nullptr' check ignores NULL marcos used in other macros.

2016-03-11 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 50409.
hokein added a comment.

Format code.


http://reviews.llvm.org/D17958

Files:
  clang-tidy/modernize/UseNullptrCheck.cpp
  test/clang-tidy/modernize-use-nullptr.cpp

Index: test/clang-tidy/modernize-use-nullptr.cpp
===
--- test/clang-tidy/modernize-use-nullptr.cpp
+++ test/clang-tidy/modernize-use-nullptr.cpp
@@ -195,6 +195,16 @@
   // CHECK-FIXES: assert2(p == nullptr);
 #undef assert2
 #undef assert1
+
+#define ASSERT_EQ(a, b) a == b
+#define ASSERT_NULL(x) ASSERT_EQ(static_cast(NULL), x)
+  int *pp;
+  ASSERT_NULL(pp);
+  ASSERT_NULL(NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use nullptr
+  // CHECK-FIXES: ASSERT_NULL(nullptr);
+#undef ASSERT_NULL
+#undef ASSERT_EQ
 }
 
 // One of the ancestor of the cast is a NestedNameSpecifierLoc.
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -226,6 +226,12 @@
 if (SM.isMacroArgExpansion(StartLoc) && SM.isMacroArgExpansion(EndLoc)) {
   SourceLocation FileLocStart = SM.getFileLoc(StartLoc),
  FileLocEnd = SM.getFileLoc(EndLoc);
+  SourceLocation ImmediateMarcoArgLoc, MacroLoc;
+  // Skip NULL macros used in macro.
+  if (!getMacroAndArgLocations(StartLoc, ImmediateMarcoArgLoc, MacroLoc) ||
+  ImmediateMarcoArgLoc != FileLocStart)
+return skipSubTree();
+
   if (isReplaceableRange(FileLocStart, FileLocEnd, SM) &&
   allArgUsesValid(C)) {
 replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd);


Index: test/clang-tidy/modernize-use-nullptr.cpp
===
--- test/clang-tidy/modernize-use-nullptr.cpp
+++ test/clang-tidy/modernize-use-nullptr.cpp
@@ -195,6 +195,16 @@
   // CHECK-FIXES: assert2(p == nullptr);
 #undef assert2
 #undef assert1
+
+#define ASSERT_EQ(a, b) a == b
+#define ASSERT_NULL(x) ASSERT_EQ(static_cast(NULL), x)
+  int *pp;
+  ASSERT_NULL(pp);
+  ASSERT_NULL(NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use nullptr
+  // CHECK-FIXES: ASSERT_NULL(nullptr);
+#undef ASSERT_NULL
+#undef ASSERT_EQ
 }
 
 // One of the ancestor of the cast is a NestedNameSpecifierLoc.
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -226,6 +226,12 @@
 if (SM.isMacroArgExpansion(StartLoc) && SM.isMacroArgExpansion(EndLoc)) {
   SourceLocation FileLocStart = SM.getFileLoc(StartLoc),
  FileLocEnd = SM.getFileLoc(EndLoc);
+  SourceLocation ImmediateMarcoArgLoc, MacroLoc;
+  // Skip NULL macros used in macro.
+  if (!getMacroAndArgLocations(StartLoc, ImmediateMarcoArgLoc, MacroLoc) ||
+  ImmediateMarcoArgLoc != FileLocStart)
+return skipSubTree();
+
   if (isReplaceableRange(FileLocStart, FileLocEnd, SM) &&
   allArgUsesValid(C)) {
 replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17958: [clang-tidy] Make 'modernize-use-nullptr' check ignores NULL marcos used in other macros.

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

http://reviews.llvm.org/D17958



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


[clang-tools-extra] r263221 - [clang-tidy] Make 'modernize-use-nullptr' check ignores NULL marcos used in other macros.

2016-03-11 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Mar 11 05:40:08 2016
New Revision: 263221

URL: http://llvm.org/viewvc/llvm-project?rev=263221&view=rev
Log:
[clang-tidy] Make 'modernize-use-nullptr' check ignores NULL marcos used in 
other macros.

Reviewers: bkramer, alexfh

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=263221&r1=263220&r2=263221&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Fri Mar 11 
05:40:08 2016
@@ -226,6 +226,12 @@ public:
 if (SM.isMacroArgExpansion(StartLoc) && SM.isMacroArgExpansion(EndLoc)) {
   SourceLocation FileLocStart = SM.getFileLoc(StartLoc),
  FileLocEnd = SM.getFileLoc(EndLoc);
+  SourceLocation ImmediateMarcoArgLoc, MacroLoc;
+  // Skip NULL macros used in macro.
+  if (!getMacroAndArgLocations(StartLoc, ImmediateMarcoArgLoc, MacroLoc) ||
+  ImmediateMarcoArgLoc != FileLocStart)
+return skipSubTree();
+
   if (isReplaceableRange(FileLocStart, FileLocEnd, SM) &&
   allArgUsesValid(C)) {
 replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd);

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp?rev=263221&r1=263220&r2=263221&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp Fri Mar 
11 05:40:08 2016
@@ -195,6 +195,16 @@ void test_macro_args() {
   // CHECK-FIXES: assert2(p == nullptr);
 #undef assert2
 #undef assert1
+
+#define ASSERT_EQ(a, b) a == b
+#define ASSERT_NULL(x) ASSERT_EQ(static_cast(NULL), x)
+  int *pp;
+  ASSERT_NULL(pp);
+  ASSERT_NULL(NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use nullptr
+  // CHECK-FIXES: ASSERT_NULL(nullptr);
+#undef ASSERT_NULL
+#undef ASSERT_EQ
 }
 
 // One of the ancestor of the cast is a NestedNameSpecifierLoc.


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


Re: [PATCH] D17958: [clang-tidy] Make 'modernize-use-nullptr' check ignores NULL marcos used in other macros.

2016-03-11 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263221: [clang-tidy] Make 'modernize-use-nullptr' check 
ignores NULL marcos used in… (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D17958?vs=50409&id=50414#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17958

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -226,6 +226,12 @@
 if (SM.isMacroArgExpansion(StartLoc) && SM.isMacroArgExpansion(EndLoc)) {
   SourceLocation FileLocStart = SM.getFileLoc(StartLoc),
  FileLocEnd = SM.getFileLoc(EndLoc);
+  SourceLocation ImmediateMarcoArgLoc, MacroLoc;
+  // Skip NULL macros used in macro.
+  if (!getMacroAndArgLocations(StartLoc, ImmediateMarcoArgLoc, MacroLoc) ||
+  ImmediateMarcoArgLoc != FileLocStart)
+return skipSubTree();
+
   if (isReplaceableRange(FileLocStart, FileLocEnd, SM) &&
   allArgUsesValid(C)) {
 replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd);
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
@@ -195,6 +195,16 @@
   // CHECK-FIXES: assert2(p == nullptr);
 #undef assert2
 #undef assert1
+
+#define ASSERT_EQ(a, b) a == b
+#define ASSERT_NULL(x) ASSERT_EQ(static_cast(NULL), x)
+  int *pp;
+  ASSERT_NULL(pp);
+  ASSERT_NULL(NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use nullptr
+  // CHECK-FIXES: ASSERT_NULL(nullptr);
+#undef ASSERT_NULL
+#undef ASSERT_EQ
 }
 
 // One of the ancestor of the cast is a NestedNameSpecifierLoc.


Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -226,6 +226,12 @@
 if (SM.isMacroArgExpansion(StartLoc) && SM.isMacroArgExpansion(EndLoc)) {
   SourceLocation FileLocStart = SM.getFileLoc(StartLoc),
  FileLocEnd = SM.getFileLoc(EndLoc);
+  SourceLocation ImmediateMarcoArgLoc, MacroLoc;
+  // Skip NULL macros used in macro.
+  if (!getMacroAndArgLocations(StartLoc, ImmediateMarcoArgLoc, MacroLoc) ||
+  ImmediateMarcoArgLoc != FileLocStart)
+return skipSubTree();
+
   if (isReplaceableRange(FileLocStart, FileLocEnd, SM) &&
   allArgUsesValid(C)) {
 replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd);
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
@@ -195,6 +195,16 @@
   // CHECK-FIXES: assert2(p == nullptr);
 #undef assert2
 #undef assert1
+
+#define ASSERT_EQ(a, b) a == b
+#define ASSERT_NULL(x) ASSERT_EQ(static_cast(NULL), x)
+  int *pp;
+  ASSERT_NULL(pp);
+  ASSERT_NULL(NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use nullptr
+  // CHECK-FIXES: ASSERT_NULL(nullptr);
+#undef ASSERT_NULL
+#undef ASSERT_EQ
 }
 
 // One of the ancestor of the cast is a NestedNameSpecifierLoc.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-03-11 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin updated this revision to Diff 50416.
DmitryPolukhin added a comment.

Re-base to resolve merge conflicts with r263109.


http://reviews.llvm.org/D18035

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

Index: test/SemaCXX/attr-abi-tag.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-abi-tag.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -triple x86_64-unknown-linux -emit-llvm < %s | FileCheck %s
+
+// CHECK: @_Z5Func1B6Names1v()
+inline namespace Names1 __attribute__((__abi_tag__)) {
+class C1 {};
+}
+C1 Func1() { return C1(); }
+
+// CHECK: @_Z5Func2B4Tag1B4Tag2v()
+inline namespace Names2 __attribute__((__abi_tag__("Tag1", "Tag2"))) {
+class C2 {};
+}
+C2 Func2() { return C2(); }
Index: test/SemaCXX/attr-abi-tag-syntax.cpp
===
--- test/SemaCXX/attr-abi-tag-syntax.cpp
+++ test/SemaCXX/attr-abi-tag-syntax.cpp
@@ -16,28 +16,18 @@
 // expected-warning@-1 {{'abi_tag' attribute on anonymous namespace ignored}}
 
 inline namespace N __attribute__((__abi_tag__)) {}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-2 {{'__abi_tag__' attribute ignored}}
 
 } // namespcace N2
 
 __attribute__((abi_tag("B", "A"))) extern int a1;
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-2 {{'abi_tag' attribute ignored}}
 
 __attribute__((abi_tag("A", "B"))) extern int a1;
 // expected-note@-1 {{previous declaration is here}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
 
 __attribute__((abi_tag("A", "C"))) extern int a1;
 // expected-error@-1 {{'abi_tag' C missing in original declaration}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
 
 extern int a2;
 // expected-note@-1 {{previous declaration is here}}
 __attribute__((abi_tag("A")))extern int a2;
 // expected-error@-1 {{cannot add 'abi_tag' attribute in a redeclaration}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
Index: test/CodeGenCXX/mangle-abi-tag.cpp
===
--- /dev/null
+++ test/CodeGenCXX/mangle-abi-tag.cpp
@@ -0,0 +1,124 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple %itanium_abi_triple -o - | FileCheck %s
+
+struct __attribute__((abi_tag("A", "B"))) A { };
+
+struct B: A { };
+
+template
+
+struct C {
+};
+
+struct D { A* p; };
+
+template
+struct __attribute__((abi_tag("C", "D"))) E {
+};
+
+struct __attribute__((abi_tag("A", "B"))) F { };
+
+A a1;
+// CHECK: @_Z2a1B1AB1B =
+
+__attribute__((abi_tag("C", "D")))
+A a2;
+// CHECK: @_Z2a2B1AB1BB1CB1D =
+
+B a3;
+// CHECK: @a3 =
+
+C a4;
+// CHECK: @_Z2a4B1AB1B =
+
+D a5;
+// CHECK: @a5 =
+
+E a6;
+// CHECK: @_Z2a6B1CB1D =
+
+E a7;
+// CHECK: @_Z2a7B1AB1BB1CB1D =
+
+template<>
+struct E {
+  static float a8;
+};
+float E::a8;
+// CHECK: @_ZN1EB1CB1DIfE2a8E =
+
+template<>
+struct E {
+  static bool a9;
+};
+bool E::a9;
+// CHECK: @_ZN1EB1CB1DI1FB1AB1BE2a9E =
+
+struct __attribute__((abi_tag("A", "B"))) A10 {
+  virtual ~A10() {}
+} a10;
+// vtable
+// CHECK: @_ZTV3A10B1AB1B =
+// typeinfo
+// CHECK: @_ZTI3A10B1AB1B =
+
+// Local variables from f9.
+// f9()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B]
+// CHECK-DAG: @_ZZZ2f9vEN1L3fooB1CB1DEvE1aB1AB1B =
+// guard variable for f9()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B]
+// CHECK-DAG: @_ZGVZZ2f9vEN1L3fooB1CB1DEvE1aB1AB1B =
+
+__attribute__ ((abi_tag("C", "D")))
+void* f1() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f1B1CB1Dv(
+
+__attribute__ ((abi_tag("C", "D")))
+A* f2() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f2B1AB1BB1CB1Dv(
+
+B* f3() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f3v(
+
+C* f4() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f4B1AB1Bv(
+
+D* f5() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f5v(
+
+E* f6() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f6B1CB1Dv(
+
+E* f7() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f7B1AB1BB1CB1Dv(
+
+void f8(E*) {
+}
+// CHECK: define {{.*}} @_Z2f8P1EB1CB1DI1AB1AB1BE(
+
+inline void f9() {
+  struct L {
+static E* foo() {
+  static A10 a;
+  return 0;
+}
+  };
+  L::foo();
+}
+void f9_test() {
+  f9();
+}
+// f9()::L::foo[abi:C][abi:D]()
+// CHECK: define linkonce_odr %struct.E* @_ZZ2f9vEN1L3fooB1CB1DEv(
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4667,10 +4667,6 @@
   D->addAttr(::new (S.Context)
  AbiTagAttr(Attr.getRange(), S.Context, Tags.data(), Tags.size(),
 Attr.getAttri

Re: [PATCH] D18076: Improve Visual Studio visualizations of llvm::PointerUnion by increasing type correctness

2016-03-11 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

I think this change is good, but it likely needs to be replicated to 
PointerUnion3 and PointerUnion4, doesn't it?


http://reviews.llvm.org/D18076



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


Re: [PATCH] D16538: [cc1as] Add MCTargetOptions argument to createAsmBackend

2016-03-11 Thread Daniel Sanders via cfe-commits
dsanders added subscribers: eugenis, ygorshenin.
dsanders added a comment.

I think it refers to MCTargetOptions::SanitizeAddress but I don't know where 
we'd get that information from. Unfortunately, it seems that the original 
author (@ygorshenin) might not be on the list anymore (phabricator shows no 
activity since 2014) but we can ask Evgeniy.



Comment at: tools/driver/cc1as_main.cpp:413-416
@@ -412,6 +414,6 @@
 
   // FIXME: init MCTargetOptions from sanitizer flags here.
   MCTargetOptions Options;
   std::unique_ptr TAP(
   TheTarget->createMCAsmParser(*STI, *Parser, *MCII, Options));
   if (!TAP)

@eugenis: Do you know what needs to be done for this FIXME?


http://reviews.llvm.org/D16538



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


Re: [PATCH] D18052: Add tests for ARM Cortex-R8

2016-03-11 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263245: Add tests for ARM Cortex-R8 (authored by alelab01).

Changed prior to commit:
  http://reviews.llvm.org/D18052?vs=50303&id=50429#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18052

Files:
  cfe/trunk/test/Driver/arm-cortex-cpus.c

Index: cfe/trunk/test/Driver/arm-cortex-cpus.c
===
--- cfe/trunk/test/Driver/arm-cortex-cpus.c
+++ cfe/trunk/test/Driver/arm-cortex-cpus.c
@@ -433,6 +433,7 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4f -mbig-endian -### -c 
%s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r5 -mbig-endian -### -c 
%s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r7 -mbig-endian -### -c 
%s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r8 -mbig-endian -### -c 
%s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R %s
 // CHECK-BE-CPUV7R: "-cc1"{{.*}} "-triple" "armebv7r-{{.*}}
 
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4 -mthumb -### -c %s 
2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
@@ -443,6 +444,7 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4f -mlittle-endian 
-mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r5 -mlittle-endian 
-mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r7 -mlittle-endian 
-mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r8 -mlittle-endian 
-mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
 // CHECK-CPUV7R-THUMB: "-cc1"{{.*}} "-triple" "thumbv7r-{{.*}}
 
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-r4 -mthumb -### -c %s 
2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
@@ -453,6 +455,7 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4f -mbig-endian -mthumb 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r5 -mbig-endian -mthumb 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r7 -mbig-endian -mthumb 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r8 -mbig-endian -mthumb 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
 // CHECK-BE-CPUV7R-THUMB: "-cc1"{{.*}} "-triple" "thumbebv7r-{{.*}}
 
 // RUN: %clang -target arm -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8A %s


Index: cfe/trunk/test/Driver/arm-cortex-cpus.c
===
--- cfe/trunk/test/Driver/arm-cortex-cpus.c
+++ cfe/trunk/test/Driver/arm-cortex-cpus.c
@@ -433,6 +433,7 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4f -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r5 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r7 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r8 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R %s
 // CHECK-BE-CPUV7R: "-cc1"{{.*}} "-triple" "armebv7r-{{.*}}
 
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
@@ -443,6 +444,7 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4f -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r5 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r7 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r8 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
 // CHECK-CPUV7R-THUMB: "-cc1"{{.*}} "-triple" "thumbv7r-{{.*}}
 
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-r4 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
@@ -453,6 +455,7 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4f -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r5 -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=

r263245 - Add tests for ARM Cortex-R8

2016-03-11 Thread Alexandros Lamprineas via cfe-commits
Author: alelab01
Date: Fri Mar 11 09:03:40 2016
New Revision: 263245

URL: http://llvm.org/viewvc/llvm-project?rev=263245&view=rev
Log:
Add tests for ARM Cortex-R8

Add command-line tests for ARM Cortex-R8 checking that the driver calls
clang -cc1 with the correct little-endian/big-endian, and ARM/Thumb triple.

Patch by Pablo Barrio 

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

Modified:
cfe/trunk/test/Driver/arm-cortex-cpus.c

Modified: cfe/trunk/test/Driver/arm-cortex-cpus.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-cortex-cpus.c?rev=263245&r1=263244&r2=263245&view=diff
==
--- cfe/trunk/test/Driver/arm-cortex-cpus.c (original)
+++ cfe/trunk/test/Driver/arm-cortex-cpus.c Fri Mar 11 09:03:40 2016
@@ -433,6 +433,7 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4f -mbig-endian -### -c 
%s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r5 -mbig-endian -### -c 
%s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r7 -mbig-endian -### -c 
%s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r8 -mbig-endian -### -c 
%s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R %s
 // CHECK-BE-CPUV7R: "-cc1"{{.*}} "-triple" "armebv7r-{{.*}}
 
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4 -mthumb -### -c %s 
2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
@@ -443,6 +444,7 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4f -mlittle-endian 
-mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r5 -mlittle-endian 
-mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r7 -mlittle-endian 
-mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r8 -mlittle-endian 
-mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R-THUMB %s
 // CHECK-CPUV7R-THUMB: "-cc1"{{.*}} "-triple" "thumbv7r-{{.*}}
 
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-r4 -mthumb -### -c %s 
2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
@@ -453,6 +455,7 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4f -mbig-endian -mthumb 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r5 -mbig-endian -mthumb 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r7 -mbig-endian -mthumb 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r8 -mbig-endian -mthumb 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
 // CHECK-BE-CPUV7R-THUMB: "-cc1"{{.*}} "-triple" "thumbebv7r-{{.*}}
 
 // RUN: %clang -target arm -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8A %s


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


[libcxx] r263246 - Revert r263036, it's ABI-breaking.

2016-03-11 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Mar 11 09:26:06 2016
New Revision: 263246

URL: http://llvm.org/viewvc/llvm-project?rev=263246&view=rev
Log:
Revert r263036, it's ABI-breaking.

Modified:
libcxx/trunk/include/string
libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=263246&r1=263245&r2=263246&view=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Fri Mar 11 09:26:06 2016
@@ -98,10 +98,8 @@ public:
 basic_string(const basic_string& str);
 basic_string(basic_string&& str)
 noexcept(is_nothrow_move_constructible::value);
-basic_string(const basic_string& str, size_type pos, // 
LWG#2583
+basic_string(const basic_string& str, size_type pos, size_type n = npos,
  const allocator_type& a = allocator_type());
-basic_string(const basic_string& str, size_type pos, size_type n,// 
LWG#2583
- const Allocator& a = Allocator()); 
 basic_string(const value_type* s, const allocator_type& a = 
allocator_type());
 basic_string(const value_type* s, size_type n, const allocator_type& a = 
allocator_type());
 basic_string(size_type n, value_type c, const allocator_type& a = 
allocator_type());
@@ -1399,9 +1397,7 @@ public:
 basic_string(size_type __n, value_type __c);
 _LIBCPP_INLINE_VISIBILITY
 basic_string(size_type __n, value_type __c, const allocator_type& __a);
-basic_string(const basic_string& __str, size_type __pos, size_type __n,
- const allocator_type& __a = allocator_type());
-basic_string(const basic_string& __str, size_type __pos,
+basic_string(const basic_string& __str, size_type __pos, size_type __n = 
npos,
  const allocator_type& __a = allocator_type());
 template
 _LIBCPP_INLINE_VISIBILITY
@@ -2224,20 +2220,6 @@ basic_string<_CharT, _Traits, _Allocator
 #if _LIBCPP_DEBUG_LEVEL >= 2
 __get_db()->__insert_c(this);
 #endif
-}
-
-template 
-basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& 
__str, size_type __pos,
-const allocator_type& 
__a)
-: __r_(__a)
-{
-size_type __str_sz = __str.size();
-if (__pos > __str_sz)
-this->__throw_out_of_range();
-__init(__str.data() + __pos, __str_sz - __pos);
-#if _LIBCPP_DEBUG_LEVEL >= 2
-__get_db()->__insert_c(this);
-#endif
 }
 
 template 

Modified: libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp?rev=263246&r1=263245&r2=263246&view=diff
==
--- libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp 
(original)
+++ libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp Fri 
Mar 11 09:26:06 2016
@@ -11,21 +11,14 @@
 // 
 
 // basic_string(const basic_string& str,
-//  size_type pos, size_type n,
-//  const Allocator& a = Allocator());
-//
-// basic_string(const basic_string& str,
-//  size_type pos,
+//  size_type pos, size_type n = npos,
 //  const Allocator& a = Allocator());
 
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 
-#include "test_macros.h"
 #include "test_allocator.h"
 #include "min_allocator.h"
 
@@ -98,20 +91,6 @@ test(S str, unsigned pos, unsigned n, co
 }
 }
 
-#if TEST_STD_VER >= 11
-void test2583()
-{   // LWG #2583
-typedef std::basic_string, 
test_allocator > StringA;
-std::vector>> vs;
-StringA s{"1234"};
-vs.emplace_back(s, 2);
-
-try { vs.emplace_back(s, 5); }
-catch (const std::out_of_range&) { return; }
-assert(false);
-}
-#endif
-
 int main()
 {
 {
@@ -152,7 +131,7 @@ int main()
 
test(S("1234567890123456789012345678901234567890123456789012345678901234567890",
 A(7)), 50, 10, A(8));
 
test(S("1234567890123456789012345678901234567890123456789012345678901234567890",
 A(7)), 50, 100, A(8));
 }
-#if TEST_STD_VER >= 11
+#if __cplusplus >= 201103L
 {
 typedef min_allocator A;
 typedef std::basic_string, A> S;
@@ -191,7 +170,5 @@ int main()
 
test(S("1234567890123456789012345678901234567890123456789012345678901234567890",
 A()), 50, 10, A());
 
test(S("1234567890123456789012345678901234567890123456789012345678901234567890",
 A()), 50, 100, A());
 }
-
-test2583();
 #endif
 }

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

Re: [libcxx] r263036 - Implement LWG#2583: There is no way to supply an allocator for basic_string(str, pos)

2016-03-11 Thread Nico Weber via cfe-commits
I reverted this in 263246 for now. I think the right fix is just to
add _LIBCPP_INLINE_VISIBILITY to the new constructor, but I'm not 100% sure.

On Thu, Mar 10, 2016 at 10:21 AM, Nico Weber  wrote:

> I think this is ABI-breaking. On OS X, new libc++ headers must work with
> old system libc++.dylibs. When I build in this setup with this change, I get
>
> Undefined symbols for architecture x86_64:
>   "std::__1::basic_string,
> std::__1::allocator >::basic_string(std::__1::basic_string std::__1::char_traits, std::__1::allocator > const&, unsigned
> long, std::__1::allocator const&)", referenced from:
>
> The new function probably needs that always_inline treatment that many
> other functions have?
>
>
> On Wed, Mar 9, 2016 at 12:51 PM, Marshall Clow via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: marshall
>> Date: Wed Mar  9 11:51:43 2016
>> New Revision: 263036
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=263036&view=rev
>> Log:
>> Implement LWG#2583: There is no way to supply an allocator for
>> basic_string(str, pos)
>>
>> Modified:
>> libcxx/trunk/include/string
>> libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp
>> libcxx/trunk/www/cxx1z_status.html
>>
>> Modified: libcxx/trunk/include/string
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=263036&r1=263035&r2=263036&view=diff
>>
>> ==
>> --- libcxx/trunk/include/string (original)
>> +++ libcxx/trunk/include/string Wed Mar  9 11:51:43 2016
>> @@ -98,8 +98,10 @@ public:
>>  basic_string(const basic_string& str);
>>  basic_string(basic_string&& str)
>>  noexcept(is_nothrow_move_constructible::value);
>> -basic_string(const basic_string& str, size_type pos, size_type n =
>> npos,
>> +basic_string(const basic_string& str, size_type pos,
>>  // LWG#2583
>>   const allocator_type& a = allocator_type());
>> +basic_string(const basic_string& str, size_type pos, size_type n,
>> // LWG#2583
>> + const Allocator& a = Allocator());
>>  basic_string(const value_type* s, const allocator_type& a =
>> allocator_type());
>>  basic_string(const value_type* s, size_type n, const allocator_type&
>> a = allocator_type());
>>  basic_string(size_type n, value_type c, const allocator_type& a =
>> allocator_type());
>> @@ -1397,7 +1399,9 @@ public:
>>  basic_string(size_type __n, value_type __c);
>>  _LIBCPP_INLINE_VISIBILITY
>>  basic_string(size_type __n, value_type __c, const allocator_type&
>> __a);
>> -basic_string(const basic_string& __str, size_type __pos, size_type
>> __n = npos,
>> +basic_string(const basic_string& __str, size_type __pos, size_type
>> __n,
>> + const allocator_type& __a = allocator_type());
>> +basic_string(const basic_string& __str, size_type __pos,
>>   const allocator_type& __a = allocator_type());
>>  template
>>  _LIBCPP_INLINE_VISIBILITY
>> @@ -2220,6 +2224,20 @@ basic_string<_CharT, _Traits, _Allocator
>>  #if _LIBCPP_DEBUG_LEVEL >= 2
>>  __get_db()->__insert_c(this);
>>  #endif
>> +}
>> +
>> +template 
>> +basic_string<_CharT, _Traits, _Allocator>::basic_string(const
>> basic_string& __str, size_type __pos,
>> +const
>> allocator_type& __a)
>> +: __r_(__a)
>> +{
>> +size_type __str_sz = __str.size();
>> +if (__pos > __str_sz)
>> +this->__throw_out_of_range();
>> +__init(__str.data() + __pos, __str_sz - __pos);
>> +#if _LIBCPP_DEBUG_LEVEL >= 2
>> +__get_db()->__insert_c(this);
>> +#endif
>>  }
>>
>>  template 
>>
>> Modified:
>> libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp?rev=263036&r1=263035&r2=263036&view=diff
>>
>> ==
>> ---
>> libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp
>> (original)
>> +++
>> libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp Wed
>> Mar  9 11:51:43 2016
>> @@ -11,14 +11,21 @@
>>  // 
>>
>>  // basic_string(const basic_string& str,
>> -//  size_type pos, size_type n = npos,
>> +//  size_type pos, size_type n,
>> +//  const Allocator& a = Allocator());
>> +//
>> +// basic_string(const basic_string& str,
>> +//  size_type pos,
>>  //  const Allocator& a = Allocator());
>>
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>> +#include 
>>  #include 
>>
>> +#include "test_macros.h"
>>  #include "test_allocator.h"
>>  #include "min_allocator.h"
>>
>> @@ -91,6 +98,20 @@ test(S str, unsigned pos, unsigned n, co
>>  }
>>  }
>>
>> +#if TEST_STD_VER >= 11
>> +void test2583()
>> +{   // LWG #2583
>> +typedef std

Re: [PATCH] D18076: Improve Visual Studio visualizations of llvm::PointerUnion by increasing type correctness

2016-03-11 Thread Mike Spertus via cfe-commits
mspertus added a comment.

Good catch. Give me two minutes


http://reviews.llvm.org/D18076



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


Re: [libcxx] r263036 - Implement LWG#2583: There is no way to supply an allocator for basic_string(str, pos)

2016-03-11 Thread Eric Fiselier via cfe-commits
I agree with Nico. Adding _LIBCPP_INLINE_VISIBILITY should fix the problem,
but it's a bit of a hack. Also we should only *add* additional signatures
if possible since existing signatures already exist in the dylib so we
can't modify them.

On Fri, Mar 11, 2016 at 8:32 AM, Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> I reverted this in 263246 for now. I think the right fix is just to
> add _LIBCPP_INLINE_VISIBILITY to the new constructor, but I'm not 100% sure.
>
> On Thu, Mar 10, 2016 at 10:21 AM, Nico Weber  wrote:
>
>> I think this is ABI-breaking. On OS X, new libc++ headers must work with
>> old system libc++.dylibs. When I build in this setup with this change, I get
>>
>> Undefined symbols for architecture x86_64:
>>   "std::__1::basic_string,
>> std::__1::allocator >::basic_string(std::__1::basic_string> std::__1::char_traits, std::__1::allocator > const&, unsigned
>> long, std::__1::allocator const&)", referenced from:
>>
>> The new function probably needs that always_inline treatment that many
>> other functions have?
>>
>>
>> On Wed, Mar 9, 2016 at 12:51 PM, Marshall Clow via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: marshall
>>> Date: Wed Mar  9 11:51:43 2016
>>> New Revision: 263036
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=263036&view=rev
>>> Log:
>>> Implement LWG#2583: There is no way to supply an allocator for
>>> basic_string(str, pos)
>>>
>>> Modified:
>>> libcxx/trunk/include/string
>>>
>>> libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp
>>> libcxx/trunk/www/cxx1z_status.html
>>>
>>> Modified: libcxx/trunk/include/string
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=263036&r1=263035&r2=263036&view=diff
>>>
>>> ==
>>> --- libcxx/trunk/include/string (original)
>>> +++ libcxx/trunk/include/string Wed Mar  9 11:51:43 2016
>>> @@ -98,8 +98,10 @@ public:
>>>  basic_string(const basic_string& str);
>>>  basic_string(basic_string&& str)
>>>  noexcept(is_nothrow_move_constructible::value);
>>> -basic_string(const basic_string& str, size_type pos, size_type n =
>>> npos,
>>> +basic_string(const basic_string& str, size_type pos,
>>>  // LWG#2583
>>>   const allocator_type& a = allocator_type());
>>> +basic_string(const basic_string& str, size_type pos, size_type n,
>>>   // LWG#2583
>>> + const Allocator& a = Allocator());
>>>  basic_string(const value_type* s, const allocator_type& a =
>>> allocator_type());
>>>  basic_string(const value_type* s, size_type n, const
>>> allocator_type& a = allocator_type());
>>>  basic_string(size_type n, value_type c, const allocator_type& a =
>>> allocator_type());
>>> @@ -1397,7 +1399,9 @@ public:
>>>  basic_string(size_type __n, value_type __c);
>>>  _LIBCPP_INLINE_VISIBILITY
>>>  basic_string(size_type __n, value_type __c, const allocator_type&
>>> __a);
>>> -basic_string(const basic_string& __str, size_type __pos, size_type
>>> __n = npos,
>>> +basic_string(const basic_string& __str, size_type __pos, size_type
>>> __n,
>>> + const allocator_type& __a = allocator_type());
>>> +basic_string(const basic_string& __str, size_type __pos,
>>>   const allocator_type& __a = allocator_type());
>>>  template
>>>  _LIBCPP_INLINE_VISIBILITY
>>> @@ -2220,6 +2224,20 @@ basic_string<_CharT, _Traits, _Allocator
>>>  #if _LIBCPP_DEBUG_LEVEL >= 2
>>>  __get_db()->__insert_c(this);
>>>  #endif
>>> +}
>>> +
>>> +template 
>>> +basic_string<_CharT, _Traits, _Allocator>::basic_string(const
>>> basic_string& __str, size_type __pos,
>>> +const
>>> allocator_type& __a)
>>> +: __r_(__a)
>>> +{
>>> +size_type __str_sz = __str.size();
>>> +if (__pos > __str_sz)
>>> +this->__throw_out_of_range();
>>> +__init(__str.data() + __pos, __str_sz - __pos);
>>> +#if _LIBCPP_DEBUG_LEVEL >= 2
>>> +__get_db()->__insert_c(this);
>>> +#endif
>>>  }
>>>
>>>  template 
>>>
>>> Modified:
>>> libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp?rev=263036&r1=263035&r2=263036&view=diff
>>>
>>> ==
>>> ---
>>> libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp
>>> (original)
>>> +++
>>> libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp Wed
>>> Mar  9 11:51:43 2016
>>> @@ -11,14 +11,21 @@
>>>  // 
>>>
>>>  // basic_string(const basic_string& str,
>>> -//  size_type pos, size_type n = npos,
>>> +//  size_type pos, size_type n,
>>> +//  const Allocator& a = Allocator());
>>> +//
>>> +// basic_string(const 

Re: [PATCH] D18076: Improve Visual Studio visualizations of llvm::PointerUnion by increasing type correctness

2016-03-11 Thread Mike Spertus via cfe-commits
mspertus updated this revision to Diff 50432.
mspertus added a comment.

Applying same logic to PointerUnion3 and PointerUnion4 as suggested by Aaron


http://reviews.llvm.org/D18076

Files:
  llvm.natvis

Index: llvm.natvis
===
--- llvm.natvis
+++ llvm.natvis
@@ -54,30 +54,30 @@
   
 
   
-{"$T1", s8b} {(void*)(Val.Value & 
Val.PointerBitMask)}
-{"$T2", s8b} {(void*)(Val.Value & 
Val.PointerBitMask)}
+{"$T1", s8b}: {($T1)(Val.Value & 
Val.PointerBitMask)}
+{"$T2", s8b}: {($T2)(Val.Value & 
Val.PointerBitMask)}
 
   ($T1)(Val.Value & Val.PointerBitMask)
   ($T2)(Val.Value & Val.PointerBitMask)
 
   
 
   
-{"$T1", s8b} {(void*)((Val.Val.Value >> 2) 
<< 2)}
-{"$T2", s8b} 
{(void*)((Val.Val.Value >> 2) << 2)}
-{"$T3", s8b} 
{(void*)((Val.Val.Value >> 2) << 2)}
+{"$T1", s8b}: {($T1)((Val.Val.Value >> 2) 
<< 2)}
+{"$T2", s8b}: 
{($T2)((Val.Val.Value >> 2) << 2)}
+{"$T3", s8b}: 
{($T3)((Val.Val.Value >> 2) << 2)}
 
   ($T1)((Val.Val.Value >> 2) << 
2)
   ($T2)((Val.Val.Value >> 2) << 2)
   ($T3)((Val.Val.Value >> 2) << 2)
 
   
 
   
-{"$T1", 
s8b} {(void*)((Val.Val.Value >> 2) << 2)}
-{"$T2", s8b} {(void*)((Val.Val.Value >> 2) 
<< 2)}
-{"$T3", s8b} {(void*)((Val.Val.Value >> 2) 
<< 2)}
-{"$T4", s8b} 
{(void*)((Val.Val.Value >> 2) << 2)}
+{"$T1", 
s8b}: {($T1)((Val.Val.Value >> 2) << 2)}
+{"$T2", s8b}: {($T2)((Val.Val.Value >> 2) 
<< 2)}
+{"$T3", s8b}: {($T3)((Val.Val.Value >> 2) 
<< 2)}
+{"$T4", s8b}: 
{($T4)((Val.Val.Value >> 2) << 2)}
 
   ($T1)((Val.Val.Value >> 2) << 2)
   ($T2)((Val.Val.Value >> 2) << 
2)


Index: llvm.natvis
===
--- llvm.natvis
+++ llvm.natvis
@@ -54,30 +54,30 @@
   
 
   
-{"$T1", s8b} {(void*)(Val.Value & Val.PointerBitMask)}
-{"$T2", s8b} {(void*)(Val.Value & Val.PointerBitMask)}
+{"$T1", s8b}: {($T1)(Val.Value & Val.PointerBitMask)}
+{"$T2", s8b}: {($T2)(Val.Value & Val.PointerBitMask)}
 
   ($T1)(Val.Value & Val.PointerBitMask)
   ($T2)(Val.Value & Val.PointerBitMask)
 
   
 
   
-{"$T1", s8b} {(void*)((Val.Val.Value >> 2) << 2)}
-{"$T2", s8b} {(void*)((Val.Val.Value >> 2) << 2)}
-{"$T3", s8b} {(void*)((Val.Val.Value >> 2) << 2)}
+{"$T1", s8b}: {($T1)((Val.Val.Value >> 2) << 2)}
+{"$T2", s8b}: {($T2)((Val.Val.Value >> 2) << 2)}
+{"$T3", s8b}: {($T3)((Val.Val.Value >> 2) << 2)}
 
   ($T1)((Val.Val.Value >> 2) << 2)
   ($T2)((Val.Val.Value >> 2) << 2)
   ($T3)((Val.Val.Value >> 2) << 2)
 
   
 
   
-{"$T1", s8b} {(void*)((Val.Val.Value >> 2) << 2)}
-{"$T2", s8b} {(void*)((Val.Val.Value >> 2) << 2)}
-{"$T3", s8b} {(void*)((Val.Val.Value >> 2) << 2)}
-{"$T4", s8b} {(void*)((Val.Val.Value >> 2) << 2)}
+{"$T1", s8b}: {($T1)((Val.Val.Value >> 2) << 2)}
+{"$T2", s8b}: {($T2)((Val.Val.Value >> 2) << 2)}
+{"$T3", s8b}: {($T3)((Val.Val.Value >> 2) << 2)}
+{"$T4", s8b}: {($T4)((Val.Val.Value >> 2) << 2)}
 
   ($T1)((Val.Val.Value >> 2) << 2)
   ($T2)((Val.Val.Value >> 2) << 2)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18076: Improve Visual Studio visualizations of llvm::PointerUnion by increasing type correctness

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

LGTM, thank you!


http://reviews.llvm.org/D18076



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


Re: [libcxx] r263036 - Implement LWG#2583: There is no way to supply an allocator for basic_string(str, pos)

2016-03-11 Thread Duncan Exon Smith via cfe-commits
There's a longer term fix involving availability attributes.   My patch to the 
test system for deployment targets is holding up a series of patches that tell 
the compiler when API was introduced (with a 'strict' flag).  This moves link 
time errors (and load time errors when back deploying) to compile time.  (I 
also have patches to get the test suite green for all Apple deployment targets.)

That doesn't handle this case explicitly, but I have an idea for new support in 
clang via a new flag:
- extern=10.10: only respect extern template for this function for dylibs 10.10 
and later, otherwise leave as linkonce. 

This would allow libc++ to add new basic_string functions to the dylib over 
time. 

-- dpnes

> On Mar 11, 2016, at 7:32 AM, Nico Weber  wrote:
> 
> I reverted this in 263246 for now. I think the right fix is just to add 
> _LIBCPP_INLINE_VISIBILITY to the new constructor, but I'm not 100% sure.
> 
>> On Thu, Mar 10, 2016 at 10:21 AM, Nico Weber  wrote:
>> I think this is ABI-breaking. On OS X, new libc++ headers must work with old 
>> system libc++.dylibs. When I build in this setup with this change, I get
>> 
>> Undefined symbols for architecture x86_64:
>>   "std::__1::basic_string, 
>> std::__1::allocator >::basic_string(std::__1::basic_string> std::__1::char_traits, std::__1::allocator > const&, unsigned 
>> long, std::__1::allocator const&)", referenced from:
>>  
>> The new function probably needs that always_inline treatment that many other 
>> functions have?
>> 
>> 
>>> On Wed, Mar 9, 2016 at 12:51 PM, Marshall Clow via cfe-commits 
>>>  wrote:
>>> Author: marshall
>>> Date: Wed Mar  9 11:51:43 2016
>>> New Revision: 263036
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=263036&view=rev
>>> Log:
>>> Implement LWG#2583: There is no way to supply an allocator for 
>>> basic_string(str, pos)
>>> 
>>> Modified:
>>> libcxx/trunk/include/string
>>> libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp
>>> libcxx/trunk/www/cxx1z_status.html
>>> 
>>> Modified: libcxx/trunk/include/string
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=263036&r1=263035&r2=263036&view=diff
>>> ==
>>> --- libcxx/trunk/include/string (original)
>>> +++ libcxx/trunk/include/string Wed Mar  9 11:51:43 2016
>>> @@ -98,8 +98,10 @@ public:
>>>  basic_string(const basic_string& str);
>>>  basic_string(basic_string&& str)
>>>  noexcept(is_nothrow_move_constructible::value);
>>> -basic_string(const basic_string& str, size_type pos, size_type n = 
>>> npos,
>>> +basic_string(const basic_string& str, size_type pos, 
>>> // LWG#2583
>>>   const allocator_type& a = allocator_type());
>>> +basic_string(const basic_string& str, size_type pos, size_type n,
>>> // LWG#2583
>>> + const Allocator& a = Allocator());
>>>  basic_string(const value_type* s, const allocator_type& a = 
>>> allocator_type());
>>>  basic_string(const value_type* s, size_type n, const allocator_type& a 
>>> = allocator_type());
>>>  basic_string(size_type n, value_type c, const allocator_type& a = 
>>> allocator_type());
>>> @@ -1397,7 +1399,9 @@ public:
>>>  basic_string(size_type __n, value_type __c);
>>>  _LIBCPP_INLINE_VISIBILITY
>>>  basic_string(size_type __n, value_type __c, const allocator_type& __a);
>>> -basic_string(const basic_string& __str, size_type __pos, size_type __n 
>>> = npos,
>>> +basic_string(const basic_string& __str, size_type __pos, size_type __n,
>>> + const allocator_type& __a = allocator_type());
>>> +basic_string(const basic_string& __str, size_type __pos,
>>>   const allocator_type& __a = allocator_type());
>>>  template
>>>  _LIBCPP_INLINE_VISIBILITY
>>> @@ -2220,6 +2224,20 @@ basic_string<_CharT, _Traits, _Allocator
>>>  #if _LIBCPP_DEBUG_LEVEL >= 2
>>>  __get_db()->__insert_c(this);
>>>  #endif
>>> +}
>>> +
>>> +template 
>>> +basic_string<_CharT, _Traits, _Allocator>::basic_string(const 
>>> basic_string& __str, size_type __pos,
>>> +const 
>>> allocator_type& __a)
>>> +: __r_(__a)
>>> +{
>>> +size_type __str_sz = __str.size();
>>> +if (__pos > __str_sz)
>>> +this->__throw_out_of_range();
>>> +__init(__str.data() + __pos, __str_sz - __pos);
>>> +#if _LIBCPP_DEBUG_LEVEL >= 2
>>> +__get_db()->__insert_c(this);
>>> +#endif
>>>  }
>>> 
>>>  template 
>>> 
>>> Modified: 
>>> libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp?rev=263036&r1=263035&r2=263036&view=diff
>>> ==
>>> --- libcxx/trunk/test/std/strings/basic.string/st

Re: [PATCH] D17986: [ASTMatchers] Existing matcher hasAnyArgument fixed and new matcher hasReturnValue added

2016-03-11 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

The reason we haven't fixed hasAnyArgument is that it can potentially break its 
users.
I'd prefer if you separated the fix from the addition.
That way we can revert the fix if needed.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:4796
@@ +4795,3 @@
+/// \endcode
+/// hasReturnValue(binaryOperator())
+///   matches 'return a+b'

New matchers must be tested.
See ASTMatchersTest.cpp.

Also, they should be added to the dynamic registry.
See Dynamic/Registry.cpp


Comment at: include/clang/ASTMatchers/ASTMatchers.h:4800
@@ +4799,3 @@
+///   matching 'a+b'
+AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher, 
InnerMatcher) {
+  BoundNodesTreeBuilder Result(*Builder);

I'm not sure this is needed.
`returnStmt(hasReturnValue(...))` is equivalent to `returnStmt(has(...))`
There are many checks using the latter already.


http://reviews.llvm.org/D17986



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


Re: [PATCH] D17986: [ASTMatchers] Existing matcher hasAnyArgument fixed and new matcher hasReturnValue added

2016-03-11 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added a comment.

In http://reviews.llvm.org/D17986#373134, @sbenza wrote:

> The reason we haven't fixed hasAnyArgument is that it can potentially break 
> its users.
>  I'd prefer if you separated the fix from the addition.
>  That way we can revert the fix if needed.


I will separate it, OK. In the Clang there is one use case that I fixed, 
although it did not break the tests. Neither of the other "has..." checkers 
(except the general ones) ignore implicit casts and parenthesized expressions 
so this one should not do it either because it makes checking implicit casts 
impossible.

Matcher "hasReturnValue" is needed because "has" ignores all implicit casts and 
parenthesized expressions and we need to the check implicit casts. I will add a 
test and add it to the dynamic registry.


http://reviews.llvm.org/D17986



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


Re: [libcxx] r263036 - Implement LWG#2583: There is no way to supply an allocator for basic_string(str, pos)

2016-03-11 Thread Eric Fiselier via cfe-commits
On Fri, Mar 11, 2016 at 8:52 AM, Duncan Exon Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> There's a longer term fix involving availability attributes.   My patch to
> the test system for deployment targets is holding up a series of patches
> that tell the compiler when API was introduced (with a 'strict' flag).
> This moves link time errors (and load time errors when back deploying) to
> compile time.
>

Sounds great. Libc++ and libc++abi will have to get better at dylib
versioning but now it sounds like we have a motivating reason.


> (I also have patches to get the test suite green for all Apple deployment
> targets.)
>

I'm very excited for that :-)


>
> That doesn't handle this case explicitly, but I have an idea for new
> support in clang via a new flag:
> - extern=10.10: only respect extern template for this function for dylibs
> 10.10 and later, otherwise leave as linkonce.
>
> This would allow libc++ to add new basic_string functions to the dylib
> over time.
>
> -- dpnes
>
> On Mar 11, 2016, at 7:32 AM, Nico Weber  wrote:
>
> I reverted this in 263246 for now. I think the right fix is just to
> add _LIBCPP_INLINE_VISIBILITY to the new constructor, but I'm not 100% sure.
>
> On Thu, Mar 10, 2016 at 10:21 AM, Nico Weber  wrote:
>
>> I think this is ABI-breaking. On OS X, new libc++ headers must work with
>> old system libc++.dylibs. When I build in this setup with this change, I get
>>
>> Undefined symbols for architecture x86_64:
>>   "std::__1::basic_string,
>> std::__1::allocator >::basic_string(std::__1::basic_string> std::__1::char_traits, std::__1::allocator > const&, unsigned
>> long, std::__1::allocator const&)", referenced from:
>>
>> The new function probably needs that always_inline treatment that many
>> other functions have?
>>
>>
>> On Wed, Mar 9, 2016 at 12:51 PM, Marshall Clow via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: marshall
>>> Date: Wed Mar  9 11:51:43 2016
>>> New Revision: 263036
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=263036&view=rev
>>> Log:
>>> Implement LWG#2583: There is no way to supply an allocator for
>>> basic_string(str, pos)
>>>
>>> Modified:
>>> libcxx/trunk/include/string
>>>
>>> libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp
>>> libcxx/trunk/www/cxx1z_status.html
>>>
>>> Modified: libcxx/trunk/include/string
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=263036&r1=263035&r2=263036&view=diff
>>>
>>> ==
>>> --- libcxx/trunk/include/string (original)
>>> +++ libcxx/trunk/include/string Wed Mar  9 11:51:43 2016
>>> @@ -98,8 +98,10 @@ public:
>>>  basic_string(const basic_string& str);
>>>  basic_string(basic_string&& str)
>>>  noexcept(is_nothrow_move_constructible::value);
>>> -basic_string(const basic_string& str, size_type pos, size_type n =
>>> npos,
>>> +basic_string(const basic_string& str, size_type pos,
>>>  // LWG#2583
>>>   const allocator_type& a = allocator_type());
>>> +basic_string(const basic_string& str, size_type pos, size_type n,
>>>   // LWG#2583
>>> + const Allocator& a = Allocator());
>>>  basic_string(const value_type* s, const allocator_type& a =
>>> allocator_type());
>>>  basic_string(const value_type* s, size_type n, const
>>> allocator_type& a = allocator_type());
>>>  basic_string(size_type n, value_type c, const allocator_type& a =
>>> allocator_type());
>>> @@ -1397,7 +1399,9 @@ public:
>>>  basic_string(size_type __n, value_type __c);
>>>  _LIBCPP_INLINE_VISIBILITY
>>>  basic_string(size_type __n, value_type __c, const allocator_type&
>>> __a);
>>> -basic_string(const basic_string& __str, size_type __pos, size_type
>>> __n = npos,
>>> +basic_string(const basic_string& __str, size_type __pos, size_type
>>> __n,
>>> + const allocator_type& __a = allocator_type());
>>> +basic_string(const basic_string& __str, size_type __pos,
>>>   const allocator_type& __a = allocator_type());
>>>  template
>>>  _LIBCPP_INLINE_VISIBILITY
>>> @@ -2220,6 +2224,20 @@ basic_string<_CharT, _Traits, _Allocator
>>>  #if _LIBCPP_DEBUG_LEVEL >= 2
>>>  __get_db()->__insert_c(this);
>>>  #endif
>>> +}
>>> +
>>> +template 
>>> +basic_string<_CharT, _Traits, _Allocator>::basic_string(const
>>> basic_string& __str, size_type __pos,
>>> +const
>>> allocator_type& __a)
>>> +: __r_(__a)
>>> +{
>>> +size_type __str_sz = __str.size();
>>> +if (__pos > __str_sz)
>>> +this->__throw_out_of_range();
>>> +__init(__str.data() + __pos, __str_sz - __pos);
>>> +#if _LIBCPP_DEBUG_LEVEL >= 2
>>> +__get_db()->__insert_c(this);
>>> +#endif
>>>  }
>>>
>>>  template 
>>>
>>> Modified:
>>> libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp
>>> URL:

Re: [PATCH] D17981: [clang-tidy] Fix clang-tidy to support parsing of assembly statements.

2016-03-11 Thread Reid Kleckner via cfe-commits
rnk added a comment.

In http://reviews.llvm.org/D17981#372823, @alexfh wrote:

> If this issue is specific to MS inline asm, then the additional dependencies 
> should only be added, when we care about MS inline asm (windows builds only?).


Clang is always a cross compiler, we never know what we are targeting until we 
see the command line.


http://reviews.llvm.org/D17981



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


[PATCH] D18088: Add a new warning to notify users of mismatched SDK and deployment target

2016-03-11 Thread Chris Bieneman via cfe-commits
beanz created this revision.
beanz added a reviewer: bob.wilson.
beanz added a subscriber: cfe-commits.

This patch adds a new driver warning -Wincompatible-sdk which notifies the user 
when they are mismatching the version min options and the sysroot.

The patch works by checking the sysroot (if present) for an SDK name, then 
matching that against the target platform. In the case of a mismatch it logs a 
warning.

http://reviews.llvm.org/D18088

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Options.td
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  test/Driver/incompatible_sdk.c

Index: test/Driver/incompatible_sdk.c
===
--- /dev/null
+++ test/Driver/incompatible_sdk.c
@@ -0,0 +1,10 @@
+// RUN: %clang -Wincompatible-sdk -isysroot SDKs/MacOSX10.9.sdk -mios-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-OSX-IOS %s
+// RUN: %clang -Wincompatible-sdk -isysroot SDKs/iPhoneOS9.2.sdk -mwatchos-version-min=2.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-IOS-WATCHOS %s
+// RUN: %clang -Wincompatible-sdk -isysroot SDKs/iPhoneOS9.2.sdk -mtvos-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-IOS-TVOS %s
+// RUN: %clang -Wincompatible-sdk -isysroot SDKs/iPhoneSimulator9.2.sdk -mios-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-IOS-IOSSIM %s
+
+int main() { return 0; }
+// CHECK-OSX-IOS: warning: using SDK for 'MacOSX10.9' but deploying to 'iPhone'
+// CHECK-IOS-WATCHOS: warning: using SDK for 'iPhoneOS9.2' but deploying to 'Watch'
+// CHECK-IOS-TVOS: warning: using SDK for 'iPhoneOS9.2' but deploying to 'AppleTV'
+// CHECK-IOS-IOSSIM-NOT: warning: using SDK for '{{.*}}' but deploying to '{{.*}}'
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -496,6 +496,7 @@
 return TargetVersion < VersionTuple(V0, V1, V2);
   }
 
+  StringRef getPlatformFamily() const;
   StringRef getOSLibraryNameSuffix() const;
 
 public:
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -329,6 +329,23 @@
   }
 }
 
+StringRef Darwin::getPlatformFamily() const {
+  switch(TargetPlatform) {
+  case DarwinPlatformKind::MacOS:
+return "MacOSX";
+  case DarwinPlatformKind::IPhoneOS:
+  case DarwinPlatformKind::IPhoneOSSimulator:
+return "iPhone";
+  case DarwinPlatformKind::TvOS:
+  case DarwinPlatformKind::TvOSSimulator:
+return "AppleTV";
+  case DarwinPlatformKind::WatchOS:
+  case DarwinPlatformKind::WatchOSSimulator:
+return "Watch";
+  }
+  llvm_unreachable("Unsupported platform");
+}
+
 StringRef Darwin::getOSLibraryNameSuffix() const {
   switch(TargetPlatform) {
   case DarwinPlatformKind::MacOS:
@@ -721,6 +738,21 @@
 Platform = WatchOSSimulator;
 
   setTarget(Platform, Major, Minor, Micro);
+
+  if(Args.hasArg(options::OPT_Wincompatible_sdk)) {
+if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
+  StringRef isysroot = A->getValue();
+  // Assume SDK has path: SOME_PATH/SDKs/PlatformXX.YY.sdk
+  size_t BeginSDK = isysroot.rfind("SDKs/");
+  size_t EndSDK = isysroot.rfind(".sdk");
+  if (BeginSDK != StringRef::npos && EndSDK != StringRef::npos) {
+StringRef SDK = isysroot.slice(BeginSDK + 5, EndSDK);
+if(!SDK.startswith(getPlatformFamily()))
+  getDriver().Diag(diag::warn_incompatible_sdk) << SDK
+<< getPlatformFamily();
+  }
+}
+  }
 }
 
 void DarwinClang::AddCXXStdlibLibArgs(const ArgList &Args,
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1087,6 +1087,8 @@
 def Wlarger_than_EQ : Joined<["-"], "Wlarger-than=">, Group;
 def Wlarger_than_ : Joined<["-"], "Wlarger-than-">, Alias;
 def Wframe_larger_than_EQ : Joined<["-"], "Wframe-larger-than=">, Group, Flags<[DriverOption]>;
+def Wincompatible_sdk : Flag<["-"], "Wincompatible-sdk">, Group,
+  Flags<[DriverOption]>;
 
 def : Flag<["-"], "fterminated-vtables">, Alias;
 def fthreadsafe_statics : Flag<["-"], "fthreadsafe-statics">, Group;
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -195,6 +195,7 @@
   "precompiled header '%0' was ignored because '%1' is not first '-include'">;
 def warn_missing_sysroot : Warning<"no such sysroot directory: '%0'">,
   InGroup>;
+def warn_incompatible_sdk : Warning<"using SDK for '%0' but deploying to '%1'">;
 def warn_debug_compression_unavailable : Warning<"cannot compress debug sections (zlib not installed)">,
   InGroup>;
 def warn_drv_enabling_rtti_with_exceptions : Warning<
__

Re: [PATCH] D17821: [OpenCL] Complete image types support

2016-03-11 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: include/clang/AST/OpenCLImageTypes.def:39
@@ +38,3 @@
+
+IMAGE_READ_TYPE(image1d, OCLImage1d)
+IMAGE_READ_TYPE(image1d_array, OCLImage1dArray)

bader wrote:
> Minor comment: any image access qualifier can be applied to any image type, 
> so I think it's better to list all image types once to avoid duplication.
> 
Sure, we could try that. Although, I think there are places where this file is 
included needing images without an access qualifier using GENERIC_IMAGE_TYPE 
macro.

For example in include/clang/Basic/TokenKinds.def

 


http://reviews.llvm.org/D17821



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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-11 Thread Eric Fiselier via cfe-commits
EricWF added a subscriber: EricWF.
EricWF added a comment.

I tried to do this over the summer. The author of the annotations insisted that 
it would be a bad idea to apply them to libc++ since it would break existing 
code. Should these be off by default?

Also at the time the annotations were unstable and somewhat buggy. Has this 
situtation cleared up?

Also could we add some ".fail.cpp" tests that use Clang verify? I'm happy to 
give an example if your unfamiliar with how libc++ handles testing.


http://reviews.llvm.org/D14731



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


Re: [PATCH] D17453: [Driver] Enable --rtlib option for MSVC target

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

lgtm



Comment at: lib/Driver/Tools.cpp:8948
@@ -8947,5 +8947,3 @@
 break;
-  case ToolChain::RLT_Libgcc:
-AddLibgcc(TC.getTriple(), D, CmdArgs, Args);
-break;
-  }
+case ToolChain::RLT_Libgcc:
+  // Make sure libgcc is not used under MSVC environment by default

Can you make sure you didn't change the indentation of this line? It should be 
two spaces left of the 'break' above.


http://reviews.llvm.org/D17453



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


Re: [PATCH] D17990: [clang-tidy] minor improvements in modernise-deprecated-headers check

2016-03-11 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

@alexfh, why? I've deleted these headers both from sources and from testset, 
didn't I?


http://reviews.llvm.org/D17990



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


r263257 - Remove compile time PreserveName switch based on NDEBUG

2016-03-11 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Fri Mar 11 11:15:44 2016
New Revision: 263257

URL: http://llvm.org/viewvc/llvm-project?rev=263257&view=rev
Log:
Remove compile time PreserveName switch based on NDEBUG

Summary:
Following r263086, we are now relying on a flag on the Context to
discard Value names in release builds.

Reviewers: chandlerc

Subscribers: cfe-commits

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

From: Mehdi Amini 

Modified:
cfe/trunk/lib/CodeGen/CGBuilder.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuilder.h?rev=263257&r1=263256&r2=263257&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuilder.h (original)
+++ cfe/trunk/lib/CodeGen/CGBuilder.h Fri Mar 11 11:15:44 2016
@@ -23,9 +23,7 @@ class CodeGenFunction;
 /// \brief This is an IRBuilder insertion helper that forwards to
 /// CodeGenFunction::InsertHelper, which adds necessary metadata to
 /// instructions.
-template 
-class CGBuilderInserter
-: protected llvm::IRBuilderDefaultInserter {
+class CGBuilderInserter : protected llvm::IRBuilderDefaultInserter {
 public:
   CGBuilderInserter() = default;
   explicit CGBuilderInserter(CodeGenFunction *CGF) : CGF(CGF) {}
@@ -39,17 +37,10 @@ private:
   CodeGenFunction *CGF = nullptr;
 };
 
-// Don't preserve names on values in an optimized build.
-#ifdef NDEBUG
-#define PreserveNames false
-#else
-#define PreserveNames true
-#endif
+typedef CGBuilderInserter CGBuilderInserterTy;
 
-typedef CGBuilderInserter CGBuilderInserterTy;
-
-typedef llvm::IRBuilder CGBuilderBaseTy;
+typedef llvm::IRBuilder
+CGBuilderBaseTy;
 
 class CGBuilderTy : public CGBuilderBaseTy {
   /// Storing a reference to the type cache here makes it a lot easier
@@ -305,8 +296,6 @@ public:
   }
 };
 
-#undef PreserveNames
-
 }  // end namespace CodeGen
 }  // end namespace clang
 

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=263257&r1=263256&r2=263257&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Mar 11 11:15:44 2016
@@ -3840,7 +3840,7 @@ RValue CodeGenFunction::EmitCall(const C
   }
 
   llvm::Instruction *CI = CS.getInstruction();
-  if (Builder.isNamePreserving() && !CI->getType()->isVoidTy())
+  if (!CI->getType()->isVoidTy())
 CI->setName("call");
 
   // Emit any writebacks immediately.  Arguably this should happen

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=263257&r1=263256&r2=263257&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Mar 11 11:15:44 2016
@@ -66,8 +66,6 @@ Address CodeGenFunction::CreateTempAlloc
 /// block.
 llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty,
 const Twine &Name) {
-  if (!Builder.isNamePreserving())
-return new llvm::AllocaInst(Ty, nullptr, "", AllocaInsertPt);
   return new llvm::AllocaInst(Ty, nullptr, Name, AllocaInsertPt);
 }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=263257&r1=263256&r2=263257&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri Mar 11 11:15:44 2016
@@ -656,7 +656,13 @@ void BackendConsumer::DiagnosticHandlerI
 
 CodeGenAction::CodeGenAction(unsigned _Act, LLVMContext *_VMContext)
 : Act(_Act), VMContext(_VMContext ? _VMContext : new LLVMContext),
-  OwnsVMContext(!_VMContext) {}
+  OwnsVMContext(!_VMContext) {
+#ifdef NDEBUG
+  // FIXME: change this to be controlled by a cc1 flag that the driver passes,
+  // on the model of --disable-free
+  _VMContext.setDiscardValueNames(true);
+#endif
+}
 
 CodeGenAction::~CodeGenAction() {
   TheModule.reset();

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=263257&r1=263256&r2=263257&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Mar 11 11:15:44 2016
@@ -747,9 +747,7 @@ void CodeGenFunction::StartFunction(Glob
   // later.  Don't create this with the builder, because we don't want it
   // folded.
   llvm::Value *Undef = llvm::UndefValue::get(Int32Ty);
- 

Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-11 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I generated an updated patch with a sample test case (and the LIT changes 
needed to run it).
https://gist.github.com/EricWF/12f77078e4efc6610572


http://reviews.llvm.org/D14731



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


r263267 - Fix build: use -> with pointers and not .

2016-03-11 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Fri Mar 11 11:32:58 2016
New Revision: 263267

URL: http://llvm.org/viewvc/llvm-project?rev=263267&view=rev
Log:
Fix build: use -> with pointers and not .

Silly typo.

From: Mehdi Amini 

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=263267&r1=263266&r2=263267&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri Mar 11 11:32:58 2016
@@ -660,7 +660,7 @@ CodeGenAction::CodeGenAction(unsigned _A
 #ifdef NDEBUG
   // FIXME: change this to be controlled by a cc1 flag that the driver passes,
   // on the model of --disable-free
-  _VMContext.setDiscardValueNames(true);
+  _VMContext->setDiscardValueNames(true);
 #endif
 }
 


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


r263269 - [SEH] Remove nounwind/noinline from outlined finally funclets

2016-03-11 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Mar 11 11:36:16 2016
New Revision: 263269

URL: http://llvm.org/viewvc/llvm-project?rev=263269&view=rev
Log:
[SEH] Remove nounwind/noinline from outlined finally funclets

With the new EH representation this is no longer necessary.

Modified:
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/test/CodeGen/exceptions-seh-finally.c

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=263269&r1=263268&r2=263269&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Fri Mar 11 11:36:16 2016
@@ -1708,12 +1708,6 @@ CodeGenFunction::GenerateSEHFinallyFunct
   const Stmt *FinallyBlock = Finally.getBlock();
   startOutlinedSEHHelper(ParentCGF, false, FinallyBlock);
 
-  // Mark finally block calls as nounwind and noinline to make LLVM's job a
-  // little easier.
-  // FIXME: Remove these restrictions in the future.
-  CurFn->addFnAttr(llvm::Attribute::NoUnwind);
-  CurFn->addFnAttr(llvm::Attribute::NoInline);
-
   // Emit the original filter expression, convert to i32, and return.
   EmitStmt(FinallyBlock);
 

Modified: cfe/trunk/test/CodeGen/exceptions-seh-finally.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exceptions-seh-finally.c?rev=263269&r1=263268&r2=263269&view=diff
==
--- cfe/trunk/test/CodeGen/exceptions-seh-finally.c (original)
+++ cfe/trunk/test/CodeGen/exceptions-seh-finally.c Fri Mar 11 11:36:16 2016
@@ -29,6 +29,7 @@ void basic_finally(void) {
 // CHECK-NEXT: cleanupret from %[[pad]] unwind to caller
 
 // CHECK: define internal void @"\01?fin$0@0@basic_finally@@"({{.*}})
+// CHECK-SAME: [[finally_attrs:#[0-9]+]]
 // CHECK: call void @cleanup()
 
 // Mostly check that we don't double emit 'r' which would crash.
@@ -62,6 +63,7 @@ l:
 // CHECK: ret void
 
 // CHECK: define internal void @"\01?fin$0@0@label_in_finally@@"({{.*}})
+// CHECK-SAME: [[finally_attrs]]
 // CHECK: br label %[[l:[^ ]*]]
 //
 // CHECK: [[l]]
@@ -95,6 +97,7 @@ void use_abnormal_termination(void) {
 // CHECK-NEXT: cleanupret from %[[pad]] unwind to caller
 
 // CHECK: define internal void @"\01?fin$0@0@use_abnormal_termination@@"({{i8( 
zeroext)?}} %[[abnormal:abnormal_termination]], i8* %frame_pointer)
+// CHECK-SAME: [[finally_attrs]]
 // CHECK: %[[abnormal_zext:[^ ]*]] = zext i8 %[[abnormal]] to i32
 // CHECK: store i32 %[[abnormal_zext]], i32* @crashed
 // CHECK-NEXT: ret void
@@ -112,6 +115,7 @@ void noreturn_noop_finally() {
 // CHECK: ret void
 
 // CHECK: define internal void @"\01?fin$0@0@noreturn_noop_finally@@"({{.*}})
+// CHECK-SAME: [[finally_attrs]]
 // CHECK: call void @abort()
 // CHECK: unreachable
 
@@ -137,6 +141,7 @@ void noreturn_finally() {
 // CHECK-NEXT: cleanupret from %[[pad]] unwind to caller
 
 // CHECK: define internal void @"\01?fin$0@0@noreturn_finally@@"({{.*}})
+// CHECK-SAME: [[finally_attrs]]
 // CHECK: call void @abort()
 // CHECK: unreachable
 
@@ -151,6 +156,7 @@ int finally_with_return() {
 // CHECK-NEXT: ret i32 42
 
 // CHECK: define internal void @"\01?fin$0@0@finally_with_return@@"({{.*}})
+// CHECK-SAME: [[finally_attrs]]
 // CHECK-NOT: br i1
 // CHECK-NOT: br label
 // CHECK: ret void
@@ -181,9 +187,11 @@ int nested___finally___finally() {
 // CHECK-NEXT: cleanupret from %[[pad]] unwind to caller
 
 // CHECK-LABEL: define internal void 
@"\01?fin$0@0@nested___finally___finally@@"({{.*}})
+// CHECK-SAME: [[finally_attrs]]
 // CHECK: ret void
 
 // CHECK-LABEL: define internal void 
@"\01?fin$1@0@nested___finally___finally@@"({{.*}})
+// CHECK-SAME: [[finally_attrs]]
 // CHECK: unreachable
 
 // FIXME: Our behavior seems suspiciously different.
@@ -226,9 +234,11 @@ int nested___finally___finally_with_eh_e
 // CHECK-NEXT: cleanupret from %[[outerpad]] unwind to caller
 
 // CHECK-LABEL: define internal void 
@"\01?fin$0@0@nested___finally___finally_with_eh_edge@@"({{.*}})
+// CHECK-SAME: [[finally_attrs]]
 // CHECK: ret void
 
 // CHECK-LABEL: define internal void 
@"\01?fin$1@0@nested___finally___finally_with_eh_edge@@"({{.*}})
+// CHECK-SAME: [[finally_attrs]]
 // CHECK: unreachable
 
 void finally_within_finally() {
@@ -248,10 +258,17 @@ void finally_within_finally() {
 // CHECK: call void @"\01?fin$0@0@finally_within_finally@@"(
 // CHECK: call void @"\01?fin$0@0@finally_within_finally@@"({{.*}}) [ 
"funclet"(
 
-// CHECK-LABEL: define internal void @"\01?fin$0@0@finally_within_finally@@"(
+// CHECK-LABEL: define internal void 
@"\01?fin$0@0@finally_within_finally@@"({{[^)]*}})
+// CHECK-SAME: [[finally_attrs]]
 // CHECK: invoke void @might_crash(
 
 // CHECK: call void @"\01?fin$1@0@finally_within_finally@@"(
 // CHECK: call void @"\01?fin$1@0@finally_within_finally@@"({{.*}}) [ 
"funclet"(
 
-// CHECK-LABEL: define internal void @"\01?fin$1@0@finally_withi

Re: [PATCH] D17990: [clang-tidy] minor improvements in modernise-deprecated-headers check

2016-03-11 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D17990#373177, @omtcyf0 wrote:

> @alexfh, why? I've deleted these headers both from sources and from testset, 
> didn't I?


I think, you misunderstood Richard's comment. The check should remove includes 
of these three headers from the code, since they have no effect in C++.


http://reviews.llvm.org/D17990



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


Re: [PATCH] D17981: [clang-tidy] Fix clang-tidy to support parsing of assembly statements.

2016-03-11 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D17981#373153, @rnk wrote:

> In http://reviews.llvm.org/D17981#372823, @alexfh wrote:
>
> > If this issue is specific to MS inline asm, then the additional 
> > dependencies should only be added, when we care about MS inline asm 
> > (windows builds only?).
>
>
> Clang is always a cross compiler, we never know what we are targeting until 
> we see the command line.


Fair enough, but I guess there are situations, where the one who builds the 
binary knows for sure that it won't be used for MS targets. We could add a 
configuration option to enable handling of MS inline assembly in Clang tools.


http://reviews.llvm.org/D17981



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


Re: r256937 - [Driver] Add support for -fno-builtin-foo options.

2016-03-11 Thread Duncan P. N. Exon Smith via cfe-commits
Chad and I talked about this off-list (my fault!) a couple of weeks
ago; finally moving this to an actual review thread.

> On 2016-Jan-06, at 06:35, Chad Rosier via cfe-commits 
>  wrote:
> 
> Author: mcrosier
> Date: Wed Jan  6 08:35:46 2016
> New Revision: 256937
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=256937&view=rev
> Log:
> [Driver] Add support for -fno-builtin-foo options.
> 
> Addresses PR4941 and rdar://6756912.
> http://reviews.llvm.org/D15195
> 
> Modified:
>cfe/trunk/include/clang/Basic/Builtins.h
>cfe/trunk/include/clang/Basic/LangOptions.h
>cfe/trunk/include/clang/Driver/Options.td
>cfe/trunk/include/clang/Frontend/CodeGenOptions.h
>cfe/trunk/lib/Basic/Builtins.cpp
>cfe/trunk/lib/Basic/LangOptions.cpp
>cfe/trunk/lib/CodeGen/BackendUtil.cpp
>cfe/trunk/lib/CodeGen/CGCall.cpp
>cfe/trunk/lib/CodeGen/CGVTables.cpp
>cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>cfe/trunk/lib/CodeGen/CodeGenModule.h
>cfe/trunk/lib/Driver/Tools.cpp
>cfe/trunk/lib/Frontend/CodeGenOptions.cpp
>cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>cfe/trunk/test/CodeGen/2007-04-14-FNoBuiltin.c
>cfe/trunk/test/CodeGen/libcalls-complex.c
>cfe/trunk/test/CodeGen/libcalls-fno-builtin.c
>cfe/trunk/test/CodeGen/nobuiltin.c
>cfe/trunk/test/Sema/implicit-builtin-freestanding.c
> 
> 
> Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=256937&r1=256936&r2=256937&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
> +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Jan  6 08:35:46 2016
> @@ -249,6 +249,13 @@ static TargetLibraryInfoImpl *createTLII
>   TargetLibraryInfoImpl *TLII = new TargetLibraryInfoImpl(TargetTriple);
>   if (!CodeGenOpts.SimplifyLibCalls)
> TLII->disableAllFunctions();
> +  else {
> +// Disable individual libc/libm calls in TargetLibraryInfo.
> +LibFunc::Func F;
> +for (auto &FuncName : CodeGenOpts.getNoBuiltinFuncs())
> +  if (TLII->getLibFunc(FuncName, F))
> +TLII->setUnavailable(F);

I noticed a difference in LTO with -fno-builtin-FOO, since this code
has no way of running at LTO-time.

Chad wondered if we might be, more generally, conflating the meanings
of -ffreestanding and -fno-builtin.  -fno-builtin-FOO doesn't
necessarily block optimizations to a builtin function, it just
designates a particular function as not being a builtin.

I suggest we revert this part of the patch.  There's also a follow-up
question: should we stop deleting functions from TLI for (plain)
-fno-builtin?

> +  }
> 
>   switch (CodeGenOpts.getVecLib()) {
>   case CodeGenOptions::Accelerate:

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


Re: [PATCH] D18076: Improve Visual Studio visualizations of llvm::PointerUnion by increasing type correctness

2016-03-11 Thread Mike Spertus via cfe-commits
mspertus closed this revision.
mspertus added a comment.

Committed as svn revision 263270


http://reviews.llvm.org/D18076



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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-11 Thread James Robinson via cfe-commits
jamesr added a comment.

Thank you for posting the LIT changes - that's the part I was unable to figure 
out.  I have a number of additional failure test cases that I will add.

I don't know what sort of code this could break, although I certainly don't 
claim to know more about these annotations than the author.  Do you have a link 
to that discussion handy?  The most obvious way this could break existing code 
would be if existing code was compiling with -Wthread-safety and had its own 
annotations that were inconsistent with these, but as it's a compile error to 
declare thread-safety relationships with types that aren't already annotated I 
can't see how any code that would be broken could compile today.  Concretely, 
if some code is written like this today:

struct Foo {

  int a __attribute__((guarded_by(m)));
  std::mutex m;

};

void Bad(Foo* f) { f->a++; }

will fail to compile without this patch in libc++ with the error:

/tmp/test.cc:4:26: error: 'guarded_by' attribute requires arguments whose type 
is annotated with 'capability' attribute; type here is 'std::mutex'

[-Werror,-Wthread-safety-attributes]
  int a __attribute__((guarded_by(m))


http://reviews.llvm.org/D14731



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


r263273 - Fix clang crash: when CodeGenAction is initialized without a context, use the member and not the parameter

2016-03-11 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Fri Mar 11 12:48:02 2016
New Revision: 263273

URL: http://llvm.org/viewvc/llvm-project?rev=263273&view=rev
Log:
Fix clang crash: when CodeGenAction is initialized without a context, use the 
member and not the parameter

From: Mehdi Amini 

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=263273&r1=263272&r2=263273&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri Mar 11 12:48:02 2016
@@ -660,7 +660,7 @@ CodeGenAction::CodeGenAction(unsigned _A
 #ifdef NDEBUG
   // FIXME: change this to be controlled by a cc1 flag that the driver passes,
   // on the model of --disable-free
-  _VMContext->setDiscardValueNames(true);
+  VMContext->setDiscardValueNames(true);
 #endif
 }
 


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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-11 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Unfortunately the discussion was offline so it's not available.

Anybody using `std::mutex` with `std::unique_lock` or their own lock guards 
will probably experience some breakage.

Heres an example of code that will now not compile with "-Werror=thread-safety"

  std::mutex m;
  m.lock();
  {
std::unique_lock g(m, std::adopt_lock);
  }  // -Wthread-safety thinks `m` is still locked

AFAIK we can't fully annotate `std::unique_lock` either because there is no way 
to model the deferred locking behavior.


http://reviews.llvm.org/D14731



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


r263276 - Update test case for llvm summary format changes in D17592.

2016-03-11 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Fri Mar 11 12:52:42 2016
New Revision: 263276

URL: http://llvm.org/viewvc/llvm-project?rev=263276&view=rev
Log:
Update test case for llvm summary format changes in D17592.

Modified:
cfe/trunk/test/Misc/thinlto.c

Modified: cfe/trunk/test/Misc/thinlto.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/thinlto.c?rev=263276&r1=263275&r2=263276&view=diff
==
--- cfe/trunk/test/Misc/thinlto.c (original)
+++ cfe/trunk/test/Misc/thinlto.c Fri Mar 11 12:52:42 2016
@@ -1,8 +1,8 @@
 // RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-bcanalyzer -dump | 
FileCheck %s
-// CHECK: http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r263279 - Allow sizeof(UnrelatedClass::field) in C++11 class template methods

2016-03-11 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Mar 11 12:59:12 2016
New Revision: 263279

URL: http://llvm.org/viewvc/llvm-project?rev=263279&view=rev
Log:
Allow sizeof(UnrelatedClass::field) in C++11 class template methods

This feature works outside of templates by forming a DeclRefExpr to a
FieldDecl instead of a MemberExpr, which requires a base object in
addition to the FieldDecl.

Previously, while building up the template AST before instantiation, we
formed a CXXDependentScopeMemberExpr, which always instantiates to a
MemberExpr. Now, in unevaluated contexts we form a
DependentScopeDeclRefExpr, which is a more flexible node that can
instantiate to either a MemberExpr or a DeclRefExpr depending on lookup
results.

Fixes PR26893.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/instantiate-sizeof.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=263279&r1=263278&r2=263279&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Mar 11 12:59:12 2016
@@ -414,9 +414,22 @@ Sema::ActOnDependentIdExpression(const C
const TemplateArgumentListInfo *TemplateArgs) {
   DeclContext *DC = getFunctionLevelDeclContext();
 
-  if (!isAddressOfOperand &&
-  isa(DC) &&
-  cast(DC)->isInstance()) {
+  // C++11 [expr.prim.general]p12:
+  //   An id-expression that denotes a non-static data member or non-static
+  //   member function of a class can only be used:
+  //   (...)
+  //   - if that id-expression denotes a non-static data member and it
+  // appears in an unevaluated operand.
+  //
+  // If this might be the case, form a DependentScopeDeclRefExpr instead of a
+  // CXXDependentScopeMemberExpr. The former can instantiate to either
+  // DeclRefExpr or MemberExpr depending on lookup results, while the latter is
+  // always a MemberExpr.
+  bool MightBeCxx11UnevalField =
+  getLangOpts().CPlusPlus11 && isUnevaluatedContext();
+
+  if (!MightBeCxx11UnevalField && !isAddressOfOperand &&
+  isa(DC) && cast(DC)->isInstance()) {
 QualType ThisType = cast(DC)->getThisType(Context);
 
 // Since the 'this' expression is synthesized, we don't need to

Modified: cfe/trunk/test/SemaTemplate/instantiate-sizeof.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-sizeof.cpp?rev=263279&r1=263278&r2=263279&view=diff
==
--- cfe/trunk/test/SemaTemplate/instantiate-sizeof.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-sizeof.cpp Fri Mar 11 12:59:12 2016
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-// expected-no-diagnostics
 
 // Make sure we handle contexts correctly with sizeof
 template void f(T n) {
@@ -9,3 +8,29 @@ template void f(T n) {
 int main() {
   f(1);
 }
+
+// Make sure we handle references to non-static data members in unevaluated
+// contexts in class template methods correctly. Previously we assumed these
+// would be valid MemberRefExprs, but they have no 'this' so we need to form a
+// DeclRefExpr to the FieldDecl instead.
+// PR26893
+template 
+struct M {
+  M() {}; // expected-note {{in instantiation of default member initializer 
'M::m' requested here}}
+  int m = *T::x; // expected-error {{invalid use of non-static data member 
'x'}}
+  void f() {
+// These are valid.
+static_assert(sizeof(T::x) == 8, "ptr");
+static_assert(sizeof(*T::x) == 4, "int");
+  }
+};
+struct S { int *x; };
+template struct M; // expected-note {{in instantiation of member function 
'M::M' requested here}}
+
+// Similar test case for PR26893.
+template 
+struct bar {
+  struct foo { int array[10]; };
+  int baz() { return sizeof(foo::array); }
+};
+template struct bar<>;


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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-11 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

My suggestion would be to make these annotations OFF by default and allow users 
to turn them on with a macro.


http://reviews.llvm.org/D14731



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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-11 Thread James Robinson via cfe-commits
jamesr added a comment.

Ah, that's true.  I didn't think of that case.  With the design of these 
annotations the author of that function would have to disable checks in each 
piece of code that uses these patterns.

What about adding a different guard for these annotations in libc++ that 
consumers could choose to toggle independently of the -Wthread-safety compiler 
option?  That way consumers could choose to enable the libc++ annotations if 
their codebase was compatible with them.  The alternative is that consumers 
have to fully wrap the std:: types in their own types to add the annotations 
which works but makes code reuse very difficult.


http://reviews.llvm.org/D14731



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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-11 Thread James Robinson via cfe-commits
jamesr added a comment.

In http://reviews.llvm.org/D14731#373289, @EricWF wrote:

> My suggestion would be to make these annotations OFF by default and allow 
> users to turn them on with a macro.


Our comments crossed streams but suggested the same thing :).  Any suggestions 
on a naming convention for the guard?  Also, would I set this macro 
unconditionally in LIT or is there a way to have it run tests both with and 
without the macro to ensure that when it is off code like the snippet you 
posted continues to build unmodified?


http://reviews.llvm.org/D14731



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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-11 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D14731#373301, @jamesr wrote:

> In http://reviews.llvm.org/D14731#373289, @EricWF wrote:
>
> > My suggestion would be to make these annotations OFF by default and allow 
> > users to turn them on with a macro.
>
>
> Our comments crossed streams but suggested the same thing :).  Any 
> suggestions on a naming convention for the guard?  Also, would I set this 
> macro unconditionally in LIT or is there a way to have it run tests both with 
> and without the macro to ensure that when it is off code like the snippet you 
> posted continues to build unmodified?


My suggestion would be `_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS` but I'm bad 
at naming things :-P

I think we leave the macro off in LIT because each test can `#define` it at the 
top of the file if it want's it on.


http://reviews.llvm.org/D14731



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


r263285 - Add missing triple to instantiate-sizeof.cpp test

2016-03-11 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Mar 11 13:17:53 2016
New Revision: 263285

URL: http://llvm.org/viewvc/llvm-project?rev=263285&view=rev
Log:
Add missing triple to instantiate-sizeof.cpp test

Modified:
cfe/trunk/test/SemaTemplate/instantiate-sizeof.cpp

Modified: cfe/trunk/test/SemaTemplate/instantiate-sizeof.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-sizeof.cpp?rev=263285&r1=263284&r2=263285&view=diff
==
--- cfe/trunk/test/SemaTemplate/instantiate-sizeof.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-sizeof.cpp Fri Mar 11 13:17:53 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -std=c++11 %s
 
 // Make sure we handle contexts correctly with sizeof
 template void f(T n) {


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


Re: [PATCH] D16538: [cc1as] Add MCTargetOptions argument to createAsmBackend

2016-03-11 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.


Comment at: tools/driver/cc1as_main.cpp:413-416
@@ -412,6 +414,6 @@
 
   // FIXME: init MCTargetOptions from sanitizer flags here.
   MCTargetOptions Options;
   std::unique_ptr TAP(
   TheTarget->createMCAsmParser(*STI, *Parser, *MCII, Options));
   if (!TAP)

dsanders wrote:
> @eugenis: Do you know what needs to be done for this FIXME?
I think this is about allowing -fsanitize=address as a cc1as flag to enable 
asan instrumentation in standalone assembly files. Currently it is only 
supported in inline assembly.


http://reviews.llvm.org/D16538



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


Re: [PATCH] D17986: [ASTMatchers] Existing matcher hasAnyArgument fixed and new matcher hasReturnValue added

2016-03-11 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

> I will separate it, OK. In the Clang there is one use case that I fixed, 
> although it did not break the tests. Neither of the other "has..." checkers 
> (except the general ones) ignore implicit casts and parenthesized expressions 
> so this one should not do it either because it makes checking implicit casts 
> impossible.


I agree that we want it, just wanted to point out that it has to be done with 
care.

> Matcher "hasReturnValue" is needed because "has" ignores all implicit casts 
> and parenthesized expressions and we need to the check implicit casts. I will 
> add a test and add it to the dynamic registry.


I see. has() suffers from the same problem. Then it makes sense.


http://reviews.llvm.org/D17986



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


Re: [PATCH] D18025: Add attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end

2016-03-11 Thread Roman Levenstein via cfe-commits
Hi Aaron, Hi Juergen,

Could you review this simple patch? Is it OK to merge or are there any changes 
to be made?

Thanks,
  Roman

> On Mar 9, 2016, at 7:25 PM, Roman Levenstein  wrote:
> 
> swiftix created this revision.
> swiftix added reviewers: ributzka, aaron.ballman.
> swiftix added a subscriber: cfe-commits.
> Herald added a subscriber: aemerson.
> 
> Till now, preserve_mostcc/preserve_allcc calling convention attributes were 
> only available at the LLVM IR level. This patch adds attributes for 
> preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end.
> 
> The code was mostly written by Juergen Ributzka. I just added support for the 
> AArch64 target and tests.
> 
> http://reviews.llvm.org/D18025
> 
> Files:
>  include/clang-c/Index.h
>  include/clang/AST/Type.h
>  include/clang/Basic/Attr.td
>  include/clang/Basic/AttrDocs.td
>  include/clang/Basic/Specifiers.h
>  lib/AST/ItaniumMangle.cpp
>  lib/AST/Type.cpp
>  lib/AST/TypePrinter.cpp
>  lib/Basic/Targets.cpp
>  lib/CodeGen/CGCall.cpp
>  lib/Sema/SemaDeclAttr.cpp
>  lib/Sema/SemaType.cpp
>  test/CodeGen/preserve_all.c
>  test/CodeGen/preserve_most.c
>  test/Sema/preserve_all-call-conv.c
>  test/Sema/preserve_most-call-conv.c
>  tools/libclang/CXType.cpp
> 
> 

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


LLVM buildmaster will be restarted tonight

2016-03-11 Thread Galina Kistanova via cfe-commits
Hello everyone,

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

Thanks

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


Re: [PATCH] D16873: Refactor MemRegionManager::getVarRegion to call two new functions, improving readability

2016-03-11 Thread Alexander Riccio via cfe-commits
ariccio marked an inline comment as done.
ariccio added a comment.

In http://reviews.llvm.org/D16873#371736, @a.sidorin wrote:

> Alexander, could you update status of this review?


It's become a zombie review. I should just abandon it, as I'll be away for two 
weeks starting tomorrow.


http://reviews.llvm.org/D16873



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


r263295 - Fix ObjCMethodDecl::findPropertyDecl for class properties.

2016-03-11 Thread Jordan Rose via cfe-commits
Author: jrose
Date: Fri Mar 11 15:14:40 2016
New Revision: 263295

URL: http://llvm.org/viewvc/llvm-project?rev=263295&view=rev
Log:
Fix ObjCMethodDecl::findPropertyDecl for class properties.

This affects code completion and a few other things; hopefully the code 
completion
test is sufficient to catch regressions.

Added:
cfe/trunk/test/CodeCompletion/documentation.m
Modified:
cfe/trunk/lib/AST/DeclObjC.cpp

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=263295&r1=263294&r2=263295&view=diff
==
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Fri Mar 11 15:14:40 2016
@@ -1234,23 +1234,29 @@ ObjCMethodDecl::findPropertyDecl(bool Ch
   if (NumArgs > 1)
 return nullptr;
 
-  if (!isInstanceMethod())
-return nullptr;
-
   if (isPropertyAccessor()) {
 const ObjCContainerDecl *Container = cast(getParent());
 bool IsGetter = (NumArgs == 0);
+bool IsInstance = isInstanceMethod();
 
 /// Local function that attempts to find a matching property within the
 /// given Objective-C container.
 auto findMatchingProperty =
   [&](const ObjCContainerDecl *Container) -> const ObjCPropertyDecl * {
-
-  for (const auto *I : Container->instance_properties()) {
-Selector NextSel = IsGetter ? I->getGetterName()
-: I->getSetterName();
-if (NextSel == Sel)
-  return I;
+  if (IsInstance) {
+for (const auto *I : Container->instance_properties()) {
+  Selector NextSel = IsGetter ? I->getGetterName()
+  : I->getSetterName();
+  if (NextSel == Sel)
+return I;
+}
+  } else {
+for (const auto *I : Container->class_properties()) {
+  Selector NextSel = IsGetter ? I->getGetterName()
+  : I->getSetterName();
+  if (NextSel == Sel)
+return I;
+}
   }
 
   return nullptr;

Added: cfe/trunk/test/CodeCompletion/documentation.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/documentation.m?rev=263295&view=auto
==
--- cfe/trunk/test/CodeCompletion/documentation.m (added)
+++ cfe/trunk/test/CodeCompletion/documentation.m Fri Mar 11 15:14:40 2016
@@ -0,0 +1,25 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+@interface Base
+@end
+
+@interface Test : Base
+/// Instance!
+@property id instanceProp;
+/// Class!
+@property (class) id classProp;
+@end
+
+void test(Test *obj) {
+  [obj instanceProp];
+  [Test classProp];
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments 
-code-completion-at=%s:15:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: instanceProp : [#id#]instanceProp : Instance!
+// CHECK-CC1: setInstanceProp: : [#void#]setInstanceProp:<#(id)#> : Instance!
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments 
-code-completion-at=%s:16:9 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: classProp : [#id#]classProp : Class!
+// CHECK-CC2: setClassProp: : [#void#]setClassProp:<#(id)#> : Class!


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


Re: [PATCH] D15599: [CodeGen] Fix a crash that occurs when attribute "naked" is attached to a c++ member function

2016-03-11 Thread Reid Kleckner via cfe-commits
rnk added a comment.

I guess I'm OK with the approach.



Comment at: lib/CodeGen/CodeGenFunction.cpp:1967
@@ +1966,3 @@
+
+void CodeGenFunction::cleanupNakedFunction() {
+  llvm::SmallPtrSet InstrsToRemove;

This isn't the right approach. Look at Function::dropAllReferences and try 
modelling this code on that. This does a lot of unnecessary RAUW when we can 
just null out all operands and delete all instructions except for the inline 
asm CallInst.


Comment at: test/CodeGen/attr-naked.c:20
@@ -19,3 +19,3 @@
 __attribute((naked)) void t3(int x) {
-// CHECK: define void @t3(i32)
+// CHECK: define void @t3(i32 %x)
 // CHECK-NOT: alloca

unrelated change?


Comment at: test/CodeGenCXX/attr-naked.cpp:7
@@ +6,3 @@
+  int __attribute__((naked)) m2() { __asm__ volatile("retq"); }
+};
+

Can you add a test involving vtable thunks? I'm worried that we will clean up 
the thunk for a naked virtual method implementation. The code looks correct 
today, but I'd like to defend against that possibility in the future.


Comment at: test/CodeGenCXX/attr-naked.cpp:30
@@ +29,3 @@
+// CHECK: define internal i32 @"_ZZ4foo1iP6Class1ENK3$_0clEv"(%class.anon* 
%this) [[ATTR1:#[0-9]]]
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void asm sideeffect "retq

Won't this require asserts? We don't name BBs in NDEBUG builds.


http://reviews.llvm.org/D15599



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


r263299 - Add fix-it for format-security warnings.

2016-03-11 Thread Bob Wilson via cfe-commits
Author: bwilson
Date: Fri Mar 11 15:55:37 2016
New Revision: 263299

URL: http://llvm.org/viewvc/llvm-project?rev=263299&view=rev
Log:
Add fix-it for format-security warnings.

Added:
cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/format-strings-fixit.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=263299&r1=263298&r2=263299&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Mar 11 15:55:37 2016
@@ -3621,20 +3621,32 @@ bool Sema::CheckFormatArguments(ArrayRef
   // format is either NSString or CFString. This is a hack to prevent
   // diag when using the NSLocalizedString and CFCopyLocalizedString macros
   // which are usually used in place of NS and CF string literals.
-  if (Type == FST_NSString &&
-  SourceMgr.isInSystemMacro(Args[format_idx]->getLocStart()))
+  SourceLocation FormatLoc = Args[format_idx]->getLocStart();
+  if (Type == FST_NSString && SourceMgr.isInSystemMacro(FormatLoc))
 return false;
 
   // If there are no arguments specified, warn with -Wformat-security, 
otherwise
   // warn only with -Wformat-nonliteral.
-  if (Args.size() == firstDataArg)
-Diag(Args[format_idx]->getLocStart(),
- diag::warn_format_nonliteral_noargs)
+  if (Args.size() == firstDataArg) {
+const SemaDiagnosticBuilder &D =
+  Diag(FormatLoc, diag::warn_format_nonliteral_noargs);
+switch (Type) {
+default:
+  D << OrigFormatExpr->getSourceRange();
+  break;
+case FST_Kprintf:
+case FST_FreeBSDKPrintf:
+case FST_Printf:
+  D << FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
+  break;
+case FST_NSString:
+  D << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", ");
+  break;
+}
+  } else {
+Diag(FormatLoc, diag::warn_format_nonliteral)
   << OrigFormatExpr->getSourceRange();
-  else
-Diag(Args[format_idx]->getLocStart(),
- diag::warn_format_nonliteral)
-   << OrigFormatExpr->getSourceRange();
+  }
   return false;
 }
 

Modified: cfe/trunk/test/Sema/format-strings-fixit.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings-fixit.c?rev=263299&r1=263298&r2=263299&view=diff
==
--- cfe/trunk/test/Sema/format-strings-fixit.c (original)
+++ cfe/trunk/test/Sema/format-strings-fixit.c Fri Mar 11 15:55:37 2016
@@ -16,6 +16,8 @@ typedef __UINTMAX_TYPE__ uintmax_t;
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
 typedef __WCHAR_TYPE__ wchar_t;
 
+extern const char *NonliteralString;
+
 void test() {
   // Basic types
   printf("%s", (int) 123);
@@ -94,6 +96,9 @@ void test() {
   printf("%G", (long double) 42);
   printf("%a", (long double) 42);
   printf("%A", (long double) 42);
+
+  // nonliteral format
+  printf(NonliteralString);
 }
 
 int scanf(char const *, ...);
@@ -218,6 +223,7 @@ void test2(int intSAParm[static 2]) {
 // CHECK: printf("%LG", (long double) 42);
 // CHECK: printf("%La", (long double) 42);
 // CHECK: printf("%LA", (long double) 42);
+// CHECK: printf("%s", NonliteralString);
 
 // CHECK: scanf("%99s", str);
 // CHECK: scanf("%s", vstr);

Added: cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m?rev=263299&view=auto
==
--- cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m (added)
+++ cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m Fri Mar 11 15:55:37 2016
@@ -0,0 +1,31 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin 
-Wno-objc-root-class -pedantic -Wall -fixit %t
+// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin 
-Wno-objc-root-class -fsyntax-only -pedantic -Wall -Werror %t
+// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin 
-Wno-objc-root-class -E -o - %t | FileCheck %s
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSCoder, NSString, NSEnumerator;
+@protocol NSObject  - (BOOL)isEqual:(id)object; @end
+@protocol NSCopying  - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSMutableCopying  - (id)mutableCopyWithZone:(NSZone *)zone; @end
+@protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject  {} @end
+@interface NSString : NSObject   - 
(NSUInteger)length; @end
+extern void NSLog(NSString *format, ...);
+
+/* This is a test of the various code modification hints that are
+   provided as part of warning or extension diagnostics. All of the
+   warnings will be fixed by -fixit, and the resulting file should
+   compile cleanly with -Werror -pedantic. */
+
+extern NSString *NonliteralString;
+
+voi

Re: [PATCH] D17941: add fix-its for format-security warnings

2016-03-11 Thread Bob Wilson via cfe-commits
bob.wilson accepted this revision.
bob.wilson added a reviewer: bob.wilson.
bob.wilson added a comment.
This revision is now accepted and ready to land.

Thanks Ben. Committed in r263299


http://reviews.llvm.org/D17941



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


Re: [PATCH] D18015: Make functions in altivec.h be inline.

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

LGTM, nice catch Daniel.

(Yes, weird that nothing changed in the IR, but the patch is correct).

-eric


http://reviews.llvm.org/D18015



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


Re: [PATCH] D18015: Make functions in altivec.h be inline.

2016-03-11 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Want me to run clang-format on the file/diff?


http://reviews.llvm.org/D18015



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


Re: [PATCH] D18015: Make functions in altivec.h be inline.

2016-03-11 Thread Eric Christopher via cfe-commits
echristo added a comment.

Since you're changing everything anyways? Sure why not! :)

-eric


http://reviews.llvm.org/D18015



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


Re: [PATCH] D18015: Make functions in altivec.h be inline.

2016-03-11 Thread Daniel Jasper via cfe-commits
djasper closed this revision.
djasper added a comment.

Formatted and submitted as r263302.


http://reviews.llvm.org/D18015



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


Re: [PATCH] D17865: Add an optional string argument to DeprecatedAttr for Fix-It.

2016-03-11 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/Basic/Attr.td:726
@@ +725,3 @@
+  let Args = [StringArgument<"Message", 1>,
+  // An optional string argument that enables us to provide a Fix-It.
+  StringArgument<"Replacement", 1>];

The formatting here is a bit strange.


Comment at: lib/Sema/SemaDeclAttr.cpp:5143
@@ +5142,3 @@
+
+  D->addAttr(::new (S.Context) DeprecatedAttr(Attr.getRange(), S.Context, Str,
+   Replacement,

This should move back down below the extension warning (the effect is the same, 
but logically we want to warn before attaching).


Comment at: utils/TableGen/ClangAttrEmitter.cpp:1234
@@ +1233,3 @@
+if ((Spelling == "deprecated" || Spelling == "gnu::deprecated") &&
+Variety != "GNU" && index == 1)
+  continue;

manmanren wrote:
> This does not look pretty. Maybe we can implement a function 
> writeDeprecatedValue that can skip the second argument if it is empty?
I wouldn't be opposed to that approach; we already do it for 
`writeAvailabilityValue()`, so another one for deprecated wouldn't be that 
horrible.


http://reviews.llvm.org/D17865



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


Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2016-03-11 Thread Pete Cooper via cfe-commits
pete added a comment.

Hi John

Sorry, getting back to this after way too long!

In http://reviews.llvm.org/D14737#294218, @rjmccall wrote:

> In http://reviews.llvm.org/D14737#293967, @pete wrote:
>
> > Added a couple of tests for retain returning types other than id.  
> > Returning a pointer should still be converted to a call, while returning a 
> > non-pointer such as float will get a message instead.
> >
> > I walked through the code in the debugger to check on the return cast.  
> > Turns out it is handled at the very end of emitARCValueOperation as follows:
> >
> >  
> >   // Cast the result back to the original type.
> >   return CGF.Builder.CreateBitCast(call, origType);
>
>
> Right, that'll cast back to the original type.  That will be the type of the 
> receiver of the message, which is not necessarily the type of the result of 
> the message.


I stepped through this one in the debugger to make sure I had it right.

So the reason the bit cast ends up not being needed is because we restricted 
this optimization to cases where the result type "isObjCObjectPointerType()" 
which conveniently ends up begin i8* and is exactly the same type as the 
message receiver.  I guess if either the receiver type or the result type 
wasn't represented as i8* then the IRBuilder would have crashed.

If we permitted converting say messaging (int*)retain to a call to objc_retain 
then the bit cast would be needed.  Would you like me to permit this change on 
functions returning anything other than isObjCObjectPointerType(), eg, change 
that to "isAnyPointerType()"?

Cheers,
Pete


http://reviews.llvm.org/D14737



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


Re: [PATCH] D18025: Add attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end

2016-03-11 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D18025#373373, @cfe-commits wrote:

> Could you review this simple patch? Is it OK to merge or are there any 
> changes to be made?


The usual rule of thumb is to wait about a week before pinging a review -- 
sometimes the backlogs for reviews are kind of long. Also, all of the previous 
comments on the review appear to have gone missing, which makes the review kind 
of tough. It is possible to add cfe-commits to the subscribers list directly 
instead of starting an entirely new review (it's under the Action drop-down 
where you can add subscribers as well as reviewers).



Comment at: include/clang/Basic/Attr.td:1394
@@ -1393,1 +1393,3 @@
 
+def PreserveMost : InheritableAttr {
+  let Spellings = [GNU<"preserve_most">];

Do these attributes do anything on targets other than AArch64 and x86-64? If 
not, these should probably be inheriting from TargetSpecificAttr. (With tests 
confirming the behavior on other targets.)


Comment at: include/clang/Basic/AttrDocs.td:2137
@@ +2136,3 @@
+def PreserveMostDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{

This should go under DocCatCallingConvs instead of DocCatVariable (especially 
since calling conventions apply to functions, not variables, generally 
speaking).


Comment at: include/clang/Basic/AttrDocs.td:2165
@@ +2164,3 @@
+
+This calling convention will be used by a future version of the ObjectiveC
+runtime and should therefore still be considered experimental at this time.

Objective-C (here and elsewhere)?


Comment at: include/clang/Basic/AttrDocs.td:2176
@@ +2175,3 @@
+def PreserveAllDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{

Same category issue as above.


Comment at: test/CodeGen/preserve_most.c:1
@@ +1,2 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm < %s | FileCheck 
%s
+// RUN: %clang_cc1 -triple arm64-unknown-unknown -emit-llvm < %s | FileCheck %s

I would combine these tests with preserve_all.c and just have one file checking 
both attributes (since they're highly related).


Comment at: test/Sema/preserve_most-call-conv.c:1
@@ +1,2 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify
+// RUN: %clang_cc1 %s -fsyntax-only -triple arm64-unknown-unknown -verify

Same suggestion here as above.


http://reviews.llvm.org/D18025



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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-11 Thread James Robinson via cfe-commits
jamesr updated this revision to Diff 50481.
jamesr added a comment.

This patch guards the new annotations with 
_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS and adds a number of tests to check 
that the annotations produce errors when the annotations are enabled that code 
violates the thread safety rules, that correct code does not produce errors, 
and that code that does not enable the annotations does not produce errors even 
in code that the thread-safety feature in Clang does not understand.

The feature guard is state in the positive as opposed to the negative as the 
annotations may be incompatible with correct code in some situations.


http://reviews.llvm.org/D14731

Files:
  include/__config
  include/__mutex_base
  test/libcxx/test/format.py
  
test/libcxx/thread/thread.mutex/thread_safety_access_guarded_without_lock.fail.cpp
  test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.cpp
  
test/libcxx/thread/thread.mutex/thread_safety_call_requires_capability_without_having.fail.cpp
  test/libcxx/thread/thread.mutex/thread_safety_lock_guard.cpp
  test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.cpp
  test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
  test/libcxx/thread/thread.mutex/thread_safety_requires_capability.cpp

Index: test/libcxx/thread/thread.mutex/thread_safety_requires_capability.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_requires_capability.cpp
@@ -0,0 +1,22 @@
+#if !defined(__clang__) || !__has_attribute(acquire_capability)
+// This test is only meaningful on versions of clang that understand thread
+// safety annotations.
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+void increment() __attribute__((requires_capability(m))) {
+  foo++;
+}
+
+int main() {
+  m.lock();
+  increment();
+  m.unlock();
+}
+
+#endif
Index: test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
@@ -0,0 +1,15 @@
+#if !defined(__clang__) || !__has_attribute(acquire_capability)
+// This test is only meaningful on versions of clang that understand thread
+// safety annotations.
+#error Test only supported on clang versions that support the acquire_capability annotation
+#endif
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+
+int main() {
+  m.lock();
+} // expected-error {{mutex 'm' is still held at the end of function}}
Index: test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.cpp
@@ -0,0 +1,18 @@
+#if !defined(__clang__) || !__has_attribute(acquire_capability)
+// This test is only meaningful on versions of clang that understand thread
+// safety annotations.
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+int main() {
+  m.lock();
+  foo++;
+  m.unlock();
+}
+
+#endif
Index: test/libcxx/thread/thread.mutex/thread_safety_lock_guard.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_lock_guard.cpp
@@ -0,0 +1,17 @@
+#if !defined(__clang__) || !__has_attribute(acquire_capability)
+// This test is only meaningful on versions of clang that understand thread
+// safety annotations.
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+int main() {
+  std::lock_guard lock(m);
+  foo++;
+}
+
+#endif
Index: test/libcxx/thread/thread.mutex/thread_safety_call_requires_capability_without_having.fail.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_call_requires_capability_without_having.fail.cpp
@@ -0,0 +1,20 @@
+#if !defined(__clang__) || !__has_attribute(acquire_capability)
+// This test is only meaningful on versions of clang that understand thread
+// safety annotations.
+#error Test only supported on clang versions that support the acquire_capability annotation
+#endif
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+void increment() __attribute__((requires_capability(m))) {
+  foo++;
+}
+
+int main() {
+  increment();  // expected-error{{calling function 'increment' requires holding mutex 'm' exclusively}}
+}
Index: test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.cpp
@@ -0,0 +1,

[PATCH] D18105: [OPENMP] Support for codegen of private clause of target, host side

2016-03-11 Thread Carlo Bertolli via cfe-commits
carlo.bertolli created this revision.
carlo.bertolli added reviewers: ABataev, kkwli0.
carlo.bertolli added subscribers: caomhin, sfantao, arpith-jacob, fraggamuffin, 
cfe-commits.
carlo.bertolli set the repository for this revision to rL LLVM.

This patch adds support for codegen of private clause of target and a 
regression test for host code generation, when the host is used as target 
device. I believe that code generation for nvptx backend would not require 
anything additional or different to what is done for the host.

Repository:
  rL LLVM

http://reviews.llvm.org/D18105

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/target_private_codegen.cpp

Index: test/OpenMP/target_private_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_private_codegen.cpp
@@ -0,0 +1,264 @@
+// Only test codegen on target side, as private clause does not require any action on the host side
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RXUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RXUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RXUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
+// RXUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32
+// RXUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o %t %s
+// RXUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+template
+struct TT{
+  tx X;
+  ty Y;
+};
+
+// TCHECK: [[TT:%.+]] = type { i64, i8 }
+// TCHECK: [[S1:%.+]] = type { double }
+
+int foo(int n) {
+  int a = 0;
+  short aa = 0;
+  float b[10];
+  float bn[n];
+  double c[5][10];
+  double cn[5][n];
+  TT d;
+
+  #pragma omp target private(a)
+  {
+  }
+
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK-NOT: store {{.+}}, {{.+}} [[A]],
+  // TCHECK:  ret void  
+
+#pragma omp target private(a)
+  {
+a = 1;
+  }
+
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[A]],
+  // TCHECK:  ret void
+  
+  #pragma omp target private(a, aa)
+  {
+a = 1;
+aa = 1;
+  }
+
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[A2:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[A]],
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[A2]],
+  // TCHECK:  ret void
+
+  #pragma omp target private(a, b, bn, c, cn, d)
+  {
+a = 1;
+b[2] = 1.0;
+bn[3] = 1.0;
+c[1][2] = 1.0;
+cn[1][3] = 1.0;
+d.X = 1;
+d.Y = 1;
+  }
+  // make sure that private variables are generated in all cases and that we use those instances for operations inside the
+  // target region
+  // TCHECK:  define void @__omp_offloading_{{.+}}(i{{[0-9]+}} [[VLA:%.+]], i{{[0-9]+}} [[VLA1:%.+]], i{{[0-9]+}} [[VLA3:%.+]])
+  // TCHECK:  [[VLA_ADDR:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[VLA_ADDR2:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[VLA_ADDR4:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[B:%.+]] = alloca [10 x float],
+  // TCHECK:  [[SSTACK:%.+]] = alloca i8*,
+  // TCHECK:  [[C:%.+]] = alloca [5 x [10 x double]],
+  // TCHECK:  [[D:%.+]] = alloca [[TT]],
+  // TCHECK:  store i{{[0-9]+}} [[VLA]], i{{[0-9]+}}* [[VLA_ADDR]],
+  // TCHECK:  store i{{[0-9]+}} [[VLA1]], i{{[0-9]+}}* [[VLA_ADDR2]],
+  // TCHECK:  store i{{[0-9]+}} [[VLA3]], i{{[0-9]+}}* [[VLA_ADDR4]],
+  // TCHECK:  [[VLA_ADDR_REF:%.+]] = load

Re: [PATCH] D18105: [OPENMP] Support for codegen of private clause of target, host side

2016-03-11 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 50489.
carlo.bertolli added a comment.

[OPENMP] Add testing for 32-bit arch


Repository:
  rL LLVM

http://reviews.llvm.org/D18105

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/target_private_codegen.cpp

Index: test/OpenMP/target_private_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_private_codegen.cpp
@@ -0,0 +1,264 @@
+// Only test codegen on target side, as private clause does not require any action on the host side
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+template
+struct TT{
+  tx X;
+  ty Y;
+};
+
+// TCHECK: [[TT:%.+]] = type { i64, i8 }
+// TCHECK: [[S1:%.+]] = type { double }
+
+int foo(int n) {
+  int a = 0;
+  short aa = 0;
+  float b[10];
+  float bn[n];
+  double c[5][10];
+  double cn[5][n];
+  TT d;
+
+  #pragma omp target private(a)
+  {
+  }
+
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK-NOT: store {{.+}}, {{.+}} [[A]],
+  // TCHECK:  ret void  
+
+#pragma omp target private(a)
+  {
+a = 1;
+  }
+
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[A]],
+  // TCHECK:  ret void
+  
+  #pragma omp target private(a, aa)
+  {
+a = 1;
+aa = 1;
+  }
+
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[A2:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[A]],
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[A2]],
+  // TCHECK:  ret void
+
+  #pragma omp target private(a, b, bn, c, cn, d)
+  {
+a = 1;
+b[2] = 1.0;
+bn[3] = 1.0;
+c[1][2] = 1.0;
+cn[1][3] = 1.0;
+d.X = 1;
+d.Y = 1;
+  }
+  // make sure that private variables are generated in all cases and that we use those instances for operations inside the
+  // target region
+  // TCHECK:  define void @__omp_offloading_{{.+}}(i{{[0-9]+}} [[VLA:%.+]], i{{[0-9]+}} [[VLA1:%.+]], i{{[0-9]+}} [[VLA3:%.+]])
+  // TCHECK:  [[VLA_ADDR:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[VLA_ADDR2:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[VLA_ADDR4:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[B:%.+]] = alloca [10 x float],
+  // TCHECK:  [[SSTACK:%.+]] = alloca i8*,
+  // TCHECK:  [[C:%.+]] = alloca [5 x [10 x double]],
+  // TCHECK:  [[D:%.+]] = alloca [[TT]],
+  // TCHECK:  store i{{[0-9]+}} [[VLA]], i{{[0-9]+}}* [[VLA_ADDR]],
+  // TCHECK:  store i{{[0-9]+}} [[VLA1]], i{{[0-9]+}}* [[VLA_ADDR2]],
+  // TCHECK:  store i{{[0-9]+}} [[VLA3]], i{{[0-9]+}}* [[VLA_ADDR4]],
+  // TCHECK:  [[VLA_ADDR_REF:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[VLA_ADDR]],
+  // TCHECK:  [[VLA_ADDR_REF2:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[VLA_ADDR2]],
+  // TCHECK:  [[VLA_ADDR_REF4:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[VLA_ADDR4]],
+  // TCHECK:  [[RET_STACK:%.+]] = call i8* @llvm.stacksave()
+  // TCHECK:  store i8* [[RET_STACK]], i8** [[SSTACK]],
+  // TCHECK:  [[VLA5:%.+]] = alloca float, i{{[0-9]+}} [[VLA_ADDR_REF]],
+  // TCHE

Re: [PATCH] D18025: Add attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end

2016-03-11 Thread Roman Levenstein via cfe-commits
swiftix added a comment.

Thanks for the hint about adding subscribers, because I was not aware it is 
possible in the Web-GUI. That was the reason why a new review was created.

And thanks for the comments. I'll address your comments and upload the new 
patch for review.


http://reviews.llvm.org/D18025



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


[PATCH] D18107: Disable CFI checks in std::addressof.

2016-03-11 Thread Evgeniy Stepanov via cfe-commits
eugenis created this revision.
eugenis added a reviewer: EricWF.
eugenis added a subscriber: cfe-commits.
eugenis set the repository for this revision to rL LLVM.

std::addressof may be used on a storage of an object before the start
of its lifetime (see std::allocate_shared for example). CFI flags the
C-style cast as invalid in that case.


Repository:
  rL LLVM

http://reviews.llvm.org/D18107

Files:
  include/type_traits

Index: include/type_traits
===
--- include/type_traits
+++ include/type_traits
@@ -399,7 +399,7 @@
 // addressof
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
 _Tp*
 addressof(_Tp& __x) _NOEXCEPT
 {


Index: include/type_traits
===
--- include/type_traits
+++ include/type_traits
@@ -399,7 +399,7 @@
 // addressof
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
 _Tp*
 addressof(_Tp& __x) _NOEXCEPT
 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18107: Disable CFI checks in std::addressof.

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

LGTM.


Repository:
  rL LLVM

http://reviews.llvm.org/D18107



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


[libcxx] r263310 - Disable CFI checks in std::addressof.

2016-03-11 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Fri Mar 11 17:50:57 2016
New Revision: 263310

URL: http://llvm.org/viewvc/llvm-project?rev=263310&view=rev
Log:
Disable CFI checks in std::addressof.

std::addressof may be used on a storage of an object before the start
of its lifetime (see std::allocate_shared for example). CFI flags the
C-style cast as invalid in that case.

Modified:
libcxx/trunk/include/type_traits

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=263310&r1=263309&r2=263310&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Fri Mar 11 17:50:57 2016
@@ -399,7 +399,7 @@ template  us
 // addressof
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
 _Tp*
 addressof(_Tp& __x) _NOEXCEPT
 {


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


Re: r263299 - Add fix-it for format-security warnings.

2016-03-11 Thread Nico Weber via cfe-commits
I think http://clang.llvm.org/docs/InternalsManual.html#fix-it-hints says
that if a fixit is on a warning, then clang should process the code as if
the fixit had been applied. That's not the case here, so I think the fixit
should be on a note instead.

On Fri, Mar 11, 2016 at 4:55 PM, Bob Wilson via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: bwilson
> Date: Fri Mar 11 15:55:37 2016
> New Revision: 263299
>
> URL: http://llvm.org/viewvc/llvm-project?rev=263299&view=rev
> Log:
> Add fix-it for format-security warnings.
>
> Added:
> cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m
> Modified:
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/test/Sema/format-strings-fixit.c
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=263299&r1=263298&r2=263299&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Mar 11 15:55:37 2016
> @@ -3621,20 +3621,32 @@ bool Sema::CheckFormatArguments(ArrayRef
>// format is either NSString or CFString. This is a hack to prevent
>// diag when using the NSLocalizedString and CFCopyLocalizedString
> macros
>// which are usually used in place of NS and CF string literals.
> -  if (Type == FST_NSString &&
> -  SourceMgr.isInSystemMacro(Args[format_idx]->getLocStart()))
> +  SourceLocation FormatLoc = Args[format_idx]->getLocStart();
> +  if (Type == FST_NSString && SourceMgr.isInSystemMacro(FormatLoc))
>  return false;
>
>// If there are no arguments specified, warn with -Wformat-security,
> otherwise
>// warn only with -Wformat-nonliteral.
> -  if (Args.size() == firstDataArg)
> -Diag(Args[format_idx]->getLocStart(),
> - diag::warn_format_nonliteral_noargs)
> +  if (Args.size() == firstDataArg) {
> +const SemaDiagnosticBuilder &D =
> +  Diag(FormatLoc, diag::warn_format_nonliteral_noargs);
> +switch (Type) {
> +default:
> +  D << OrigFormatExpr->getSourceRange();
> +  break;
> +case FST_Kprintf:
> +case FST_FreeBSDKPrintf:
> +case FST_Printf:
> +  D << FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
> +  break;
> +case FST_NSString:
> +  D << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", ");
> +  break;
> +}
> +  } else {
> +Diag(FormatLoc, diag::warn_format_nonliteral)
><< OrigFormatExpr->getSourceRange();
> -  else
> -Diag(Args[format_idx]->getLocStart(),
> - diag::warn_format_nonliteral)
> -   << OrigFormatExpr->getSourceRange();
> +  }
>return false;
>  }
>
>
> Modified: cfe/trunk/test/Sema/format-strings-fixit.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings-fixit.c?rev=263299&r1=263298&r2=263299&view=diff
>
> ==
> --- cfe/trunk/test/Sema/format-strings-fixit.c (original)
> +++ cfe/trunk/test/Sema/format-strings-fixit.c Fri Mar 11 15:55:37 2016
> @@ -16,6 +16,8 @@ typedef __UINTMAX_TYPE__ uintmax_t;
>  typedef __PTRDIFF_TYPE__ ptrdiff_t;
>  typedef __WCHAR_TYPE__ wchar_t;
>
> +extern const char *NonliteralString;
> +
>  void test() {
>// Basic types
>printf("%s", (int) 123);
> @@ -94,6 +96,9 @@ void test() {
>printf("%G", (long double) 42);
>printf("%a", (long double) 42);
>printf("%A", (long double) 42);
> +
> +  // nonliteral format
> +  printf(NonliteralString);
>  }
>
>  int scanf(char const *, ...);
> @@ -218,6 +223,7 @@ void test2(int intSAParm[static 2]) {
>  // CHECK: printf("%LG", (long double) 42);
>  // CHECK: printf("%La", (long double) 42);
>  // CHECK: printf("%LA", (long double) 42);
> +// CHECK: printf("%s", NonliteralString);
>
>  // CHECK: scanf("%99s", str);
>  // CHECK: scanf("%s", vstr);
>
> Added: cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m?rev=263299&view=auto
>
> ==
> --- cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m (added)
> +++ cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m Fri Mar 11
> 15:55:37 2016
> @@ -0,0 +1,31 @@
> +// RUN: cp %s %t
> +// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin
> -Wno-objc-root-class -pedantic -Wall -fixit %t
> +// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin
> -Wno-objc-root-class -fsyntax-only -pedantic -Wall -Werror %t
> +// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin
> -Wno-objc-root-class -E -o - %t | FileCheck %s
> +
> +typedef signed char BOOL;
> +typedef unsigned int NSUInteger;
> +typedef struct _NSZone NSZone;
> +@class NSCoder, NSString, NSEnumerator;
> +@protocol NSObject  - (BOOL)isEqual:(id)object; @end
> +@protocol NSCopying  - (id)copyWithZone:(NSZone *)zone; @end

Re: [libcxx] r249738 - Split out of .

2016-03-11 Thread Duncan P. N. Exon Smith via cfe-commits
Did anyone file a PR for this?

> On 2015-Oct-19, at 15:52, Richard Smith via cfe-commits 
>  wrote:
> 
> Ugh, looks like I missed a submodule for stdio.h :(
> 
> On Oct 19, 2015 11:34 AM, "Adrian Prantl"  wrote:
> While building module 'std' imported from 
> /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/cassert:20:
> While building module 'Darwin' imported from 
> /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/ctype.h:39:
> In file included from :95:
> In file included from 
> /Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/util.h:64:
> /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/stdio.h:102:10: 
> fatal error: 
>   '__config' file not found
> #include <__config>
>  ^
> While building module 'std' imported from 
> /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/cassert:20:
> In file included from :2:
> /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/ctype.h:39:15: 
> fatal error: 
>   could not build module 'Darwin'
> #include_next 
>  ~^
> In file included from test.cpp:2:
> /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/cassert:20:10: 
> fatal error: 
>   could not build module 'std'
> #include <__config>
>  ^
> 3 errors generated.
> ___
> 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] D18107: Disable CFI checks in std::addressof.

2016-03-11 Thread Evgeniy Stepanov via cfe-commits
eugenis closed this revision.
eugenis added a comment.

r263310
Thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D18107



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


Re: r263299 - Add fix-it for format-security warnings.

2016-03-11 Thread Bob Wilson via cfe-commits
I’m not sure how to interpret that. It says: "Clang must recover from errors as 
if the fix-it had been applied.” I suppose that format-security could be an 
error if you’re building with -Werror, but I had been interpreting that to mean 
an error that would block further compilation. Can someone clarify this 
expectation?

I don’t think we can change -Wformat-security to be a note. It is an existing 
warning, and people expect us to match GCC on it as well.

> On Mar 11, 2016, at 4:03 PM, Nico Weber  wrote:
> 
> I think http://clang.llvm.org/docs/InternalsManual.html#fix-it-hints 
>  says that if a 
> fixit is on a warning, then clang should process the code as if the fixit had 
> been applied. That's not the case here, so I think the fixit should be on a 
> note instead.
> 
> On Fri, Mar 11, 2016 at 4:55 PM, Bob Wilson via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: bwilson
> Date: Fri Mar 11 15:55:37 2016
> New Revision: 263299
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=263299&view=rev 
> 
> Log:
> Add fix-it for format-security warnings.
> 
> Added:
> cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m
> Modified:
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/test/Sema/format-strings-fixit.c
> 
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=263299&r1=263298&r2=263299&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Mar 11 15:55:37 2016
> @@ -3621,20 +3621,32 @@ bool Sema::CheckFormatArguments(ArrayRef
>// format is either NSString or CFString. This is a hack to prevent
>// diag when using the NSLocalizedString and CFCopyLocalizedString macros
>// which are usually used in place of NS and CF string literals.
> -  if (Type == FST_NSString &&
> -  SourceMgr.isInSystemMacro(Args[format_idx]->getLocStart()))
> +  SourceLocation FormatLoc = Args[format_idx]->getLocStart();
> +  if (Type == FST_NSString && SourceMgr.isInSystemMacro(FormatLoc))
>  return false;
> 
>// If there are no arguments specified, warn with -Wformat-security, 
> otherwise
>// warn only with -Wformat-nonliteral.
> -  if (Args.size() == firstDataArg)
> -Diag(Args[format_idx]->getLocStart(),
> - diag::warn_format_nonliteral_noargs)
> +  if (Args.size() == firstDataArg) {
> +const SemaDiagnosticBuilder &D =
> +  Diag(FormatLoc, diag::warn_format_nonliteral_noargs);
> +switch (Type) {
> +default:
> +  D << OrigFormatExpr->getSourceRange();
> +  break;
> +case FST_Kprintf:
> +case FST_FreeBSDKPrintf:
> +case FST_Printf:
> +  D << FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
> +  break;
> +case FST_NSString:
> +  D << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", ");
> +  break;
> +}
> +  } else {
> +Diag(FormatLoc, diag::warn_format_nonliteral)
><< OrigFormatExpr->getSourceRange();
> -  else
> -Diag(Args[format_idx]->getLocStart(),
> - diag::warn_format_nonliteral)
> -   << OrigFormatExpr->getSourceRange();
> +  }
>return false;
>  }
> 
> 
> Modified: cfe/trunk/test/Sema/format-strings-fixit.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings-fixit.c?rev=263299&r1=263298&r2=263299&view=diff
>  
> 
> ==
> --- cfe/trunk/test/Sema/format-strings-fixit.c (original)
> +++ cfe/trunk/test/Sema/format-strings-fixit.c Fri Mar 11 15:55:37 2016
> @@ -16,6 +16,8 @@ typedef __UINTMAX_TYPE__ uintmax_t;
>  typedef __PTRDIFF_TYPE__ ptrdiff_t;
>  typedef __WCHAR_TYPE__ wchar_t;
> 
> +extern const char *NonliteralString;
> +
>  void test() {
>// Basic types
>printf("%s", (int) 123);
> @@ -94,6 +96,9 @@ void test() {
>printf("%G", (long double) 42);
>printf("%a", (long double) 42);
>printf("%A", (long double) 42);
> +
> +  // nonliteral format
> +  printf(NonliteralString);
>  }
> 
>  int scanf(char const *, ...);
> @@ -218,6 +223,7 @@ void test2(int intSAParm[static 2]) {
>  // CHECK: printf("%LG", (long double) 42);
>  // CHECK: printf("%La", (long double) 42);
>  // CHECK: printf("%LA", (long double) 42);
> +// CHECK: printf("%s", NonliteralString);
> 
>  // CHECK: scanf("%99s", str);
>  // CHECK: scanf("%s", vstr);
> 
> Added: cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/format-strings-objc-f

Re: r263299 - Add fix-it for format-security warnings.

2016-03-11 Thread David Blaikie via cfe-commits
On Fri, Mar 11, 2016 at 4:14 PM, Bob Wilson via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> I’m not sure how to interpret that. It says: "Clang must recover from
> errors as if the fix-it had been applied.” I suppose that format-security
> could be an error if you’re building with -Werror, but I had been
> interpreting that to mean an error that would block further compilation.
> Can someone clarify this expectation?
>
> I don’t think we can change -Wformat-security to be a note.
>

The suggestion isn't to change it to be a note, but to keep the warning but
move the fixit to a note associated with the warning.

That way -fix-it doesn't automatically apply the fix-it, which avoids the
issue of recovery as-if the fixit was applied.


> It is an existing warning, and people expect us to match GCC on it as well.
>
>
> On Mar 11, 2016, at 4:03 PM, Nico Weber  wrote:
>
> I think http://clang.llvm.org/docs/InternalsManual.html#fix-it-hints says
> that if a fixit is on a warning, then clang should process the code as if
> the fixit had been applied. That's not the case here, so I think the fixit
> should be on a note instead.
>
> On Fri, Mar 11, 2016 at 4:55 PM, Bob Wilson via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: bwilson
>> Date: Fri Mar 11 15:55:37 2016
>> New Revision: 263299
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=263299&view=rev
>> Log:
>> Add fix-it for format-security warnings.
>>
>> Added:
>> cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m
>> Modified:
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/test/Sema/format-strings-fixit.c
>>
>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=263299&r1=263298&r2=263299&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Mar 11 15:55:37 2016
>> @@ -3621,20 +3621,32 @@ bool Sema::CheckFormatArguments(ArrayRef
>>// format is either NSString or CFString. This is a hack to prevent
>>// diag when using the NSLocalizedString and CFCopyLocalizedString
>> macros
>>// which are usually used in place of NS and CF string literals.
>> -  if (Type == FST_NSString &&
>> -  SourceMgr.isInSystemMacro(Args[format_idx]->getLocStart()))
>> +  SourceLocation FormatLoc = Args[format_idx]->getLocStart();
>> +  if (Type == FST_NSString && SourceMgr.isInSystemMacro(FormatLoc))
>>  return false;
>>
>>// If there are no arguments specified, warn with -Wformat-security,
>> otherwise
>>// warn only with -Wformat-nonliteral.
>> -  if (Args.size() == firstDataArg)
>> -Diag(Args[format_idx]->getLocStart(),
>> - diag::warn_format_nonliteral_noargs)
>> +  if (Args.size() == firstDataArg) {
>> +const SemaDiagnosticBuilder &D =
>> +  Diag(FormatLoc, diag::warn_format_nonliteral_noargs);
>> +switch (Type) {
>> +default:
>> +  D << OrigFormatExpr->getSourceRange();
>> +  break;
>> +case FST_Kprintf:
>> +case FST_FreeBSDKPrintf:
>> +case FST_Printf:
>> +  D << FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
>> +  break;
>> +case FST_NSString:
>> +  D << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", ");
>> +  break;
>> +}
>> +  } else {
>> +Diag(FormatLoc, diag::warn_format_nonliteral)
>><< OrigFormatExpr->getSourceRange();
>> -  else
>> -Diag(Args[format_idx]->getLocStart(),
>> - diag::warn_format_nonliteral)
>> -   << OrigFormatExpr->getSourceRange();
>> +  }
>>return false;
>>  }
>>
>>
>> Modified: cfe/trunk/test/Sema/format-strings-fixit.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings-fixit.c?rev=263299&r1=263298&r2=263299&view=diff
>>
>> ==
>> --- cfe/trunk/test/Sema/format-strings-fixit.c (original)
>> +++ cfe/trunk/test/Sema/format-strings-fixit.c Fri Mar 11 15:55:37 2016
>> @@ -16,6 +16,8 @@ typedef __UINTMAX_TYPE__ uintmax_t;
>>  typedef __PTRDIFF_TYPE__ ptrdiff_t;
>>  typedef __WCHAR_TYPE__ wchar_t;
>>
>> +extern const char *NonliteralString;
>> +
>>  void test() {
>>// Basic types
>>printf("%s", (int) 123);
>> @@ -94,6 +96,9 @@ void test() {
>>printf("%G", (long double) 42);
>>printf("%a", (long double) 42);
>>printf("%A", (long double) 42);
>> +
>> +  // nonliteral format
>> +  printf(NonliteralString);
>>  }
>>
>>  int scanf(char const *, ...);
>> @@ -218,6 +223,7 @@ void test2(int intSAParm[static 2]) {
>>  // CHECK: printf("%LG", (long double) 42);
>>  // CHECK: printf("%La", (long double) 42);
>>  // CHECK: printf("%LA", (long double) 42);
>> +// CHECK: printf("%s", NonliteralString);
>>
>>  // CHECK: scanf("%99s", str);
>>  // CHECK: scanf("%s", vstr);
>>
>> Added: cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m
>> URL:
>> htt

[PATCH] D18110: [OpenMP] Fix SEMA bug in the capture of global variables in template functions.

2016-03-11 Thread Samuel Antao via cfe-commits
sfantao created this revision.
sfantao added reviewers: ABataev, hfinkel, carlo.bertolli, arpith-jacob, kkwli0.
sfantao added subscribers: fraggamuffin, caomhin, cfe-commits.

Target regions require globals to be captured. The capturing scope has been 
determine by matching the scope of the captured region and the data sharing 
attribute stack (DSA stack). However, if the code is in a templated function, 
the scope is set to null and can no longer be used to  determine scopes.

This patch fixes the issue by matching the SEMA parent contexts (that are 
always defined) of the region scope and DSA scope.

http://reviews.llvm.org/D18110

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_codegen_global_capture.cpp
  test/OpenMP/teams_codegen.cpp

Index: test/OpenMP/teams_codegen.cpp
===
--- test/OpenMP/teams_codegen.cpp
+++ test/OpenMP/teams_codegen.cpp
@@ -250,12 +250,10 @@
 // CK4:  ret void
 // CK4-NEXT: }
 
-// CK4:  define {{.*}}void @{{[^,]+}}(i8*** dereferenceable({{.}}) [[ARGC1:%.+]])
-// CK4:  [[ARGCADDR1:%.+]] = alloca i8***
-// CK4:  store i8*** [[ARGC1]], i8 [[ARGCADDR1]]
-// CK4:  [[CONV1:%.+]] = load i8***, i8 [[ARGCADDR1]]
-// CK4:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(%ident_t* [[DEF_LOC_0]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***)* {{.+}} to void (i32*, i32*, ...)*), i8*** [[CONV1]])
-
+// CK4:  define {{.*}}void @{{[^,]+}}(i8** [[ARGC1:%.+]])
+// CK4:  [[ARGCADDR1:%.+]] = alloca i8**
+// CK4:  store i8** [[ARGC1]], i8*** [[ARGCADDR1]]
+// CK4:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(%ident_t* [[DEF_LOC_0]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***)* {{.+}} to void (i32*, i32*, ...)*), i8*** [[ARGCADDR1]])
 
 #endif // CK4
 
@@ -320,21 +318,22 @@
 // CK5-64:  call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(%ident_t* [[DEF_LOC_0]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* @.omp_outlined. to void (i32*, i32*, ...)*), i32* [[CONV]])
 // CK5-32:  call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(%ident_t* [[DEF_LOC_0]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* @.omp_outlined. to void (i32*, i32*, ...)*), i32* [[ARGCADDR]])
 
-// CK5:  define {{.*}}void @{{[^,]+}}(i{{.+}} dereferenceable({{.+}}) [[AP:%.+]], i{{.+}} dereferenceable({{.+}}) [[BP:%.+]], i{{.+}} dereferenceable({{.+}}) [[ARGC:%.+]])
+// CK5:  define {{.*}}void @{{[^,]+}}(i{{.+}} [[AP:%.+]], i{{.+}} [[BP:%.+]], i8** [[ARGC:%.+]])
 // CK5:  [[AADDR:%.+]] = alloca i{{.+}}
 // CK5:  [[BADDR:%.+]] = alloca i{{.+}}
-// CK5:  [[ARGCADDR:%.+]] = alloca i{{.+}}
+// CK5:  [[ARGCADDR:%.+]] = alloca i8**
 // CK5:  [[GBL_TH_NUM:%.+]] = call i32 @__kmpc_global_thread_num(%ident_t* [[DEF_LOC_0]])
 // CK5:  store i{{.+}} [[AP]], i{{.+}}* [[AADDR]]
 // CK5:  store i{{.+}} [[BP]], i{{.+}}* [[BADDR]]
-// CK5:  store i{{.+}} [[ARGC]], i{{.+}}* [[ARGCADDR]]
-// CK5:  [[A_ADDR_VAL:%.+]] = load i32*, i32** [[AADDR]]
-// CK5:  [[B_ADDR_VAL:%.+]] = load i32*, i32** [[BADDR]]
-// CK5:  [[ARGC_ADDR_VAL:%.+]] = load i{{.+}}, i{{.+}}* [[ARGCADDR]]
-// CK5:  [[A_VAL:%.+]] = load i32, i32* [[A_ADDR_VAL]]
-// CK5:  [[B_VAL:%.+]] = load i32, i32* [[B_ADDR_VAL]]
-// CK5:  {{.+}} = call i32 @__kmpc_push_num_teams(%ident_t* [[DEF_LOC_0]], i32 [[GBL_TH_NUM]], i32 [[A_VAL]], i32 [[B_VAL]])
-// CK5:  call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(%ident_t* [[DEF_LOC_0]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i{{.+}})* @.omp_outlined.{{.+}} to void (i32*, i32*, ...)*), i{{.+}} [[ARGC_ADDR_VAL]])
+// CK5:  store i8** [[ARGC]], i8*** [[ARGCADDR]]
+// CK5-64:  [[ACONV:%.+]] = bitcast i64* [[AADDR]] to i32*
+// CK5-64:  [[BCONV:%.+]] = bitcast i64* [[BADDR]] to i32*
+// CK5-64:  [[ACONVVAL:%.+]] = load i32, i32* [[ACONV]]
+// CK5-64:  [[BCONVVAL:%.+]] = load i32, i32* [[BCONV]]
+// CK5-32:  [[ACONVVAL:%.+]] = load i32, i32* [[AADDR]]
+// CK5-32:  [[BCONVVAL:%.+]] = load i32, i32* [[BADDR]]
+// CK5:  {{.+}} = call i32 @__kmpc_push_num_teams(%ident_t* [[DEF_LOC_0]], i32 [[GBL_TH_NUM]], i32 [[ACONVVAL]], i32 [[BCONVVAL]])
+// CK5:  call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(%ident_t* [[DEF_LOC_0]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i{{.+}})* @.omp_outlined.{{.+}} to void (i32*, i32*, ...)*), i8*** [[ARGCADDR]])
 // CK5:  ret void
 // CK5-NEXT: }
 
Index: test/OpenMP/target_codegen_global_capture.cpp
===
--- test/OpenMP/target_codegen_global_capture.cpp
+++ test/OpenMP/target_codegen_global_capture.cpp
@@ -21,6 +21,11 @@
 // CHECK-DAG: [[BB:@.+]] = internal global float 1.00e+01
 // CHECK-DAG: [[BC:@.+]] = internal global float 1.10e+01
 // CHECK-DAG: [[BD:@.+]] = internal global float 1.20e+01
+/

Re: [PATCH] D18071: CodeGen: Mark runtime functions with reserved names as unnamed_addr.

2016-03-11 Thread Peter Collingbourne via cfe-commits
pcc added subscribers: majnemer, rnk.
pcc added a comment.

Done (this also affects `_purecall` in the MS ABI; I don't think this change 
should break anything there, but someone working on that might want to 
comment). Since this patch is now specific to virtual tables anyway, I've 
incorporated another relevant change, which is to mark virtual function 
declarations as `unnamed_addr`.


http://reviews.llvm.org/D18071



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


Re: [PATCH] D18071: CodeGen: Mark runtime functions with reserved names as unnamed_addr.

2016-03-11 Thread Peter Collingbourne via cfe-commits
pcc updated this revision to Diff 50500.
pcc added a comment.

Restrict to functions referenced in virtual tables


http://reviews.llvm.org/D18071

Files:
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCXX/virtual-function-attrs.cpp
  test/CodeGenCXX/vtt-layout.cpp

Index: test/CodeGenCXX/vtt-layout.cpp
===
--- test/CodeGenCXX/vtt-layout.cpp
+++ test/CodeGenCXX/vtt-layout.cpp
@@ -84,3 +84,5 @@
 // CHECK: @_ZTTN5Test21CE = linkonce_odr unnamed_addr constant [2 x i8*] [i8* 
bitcast (i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @_ZTVN5Test21CE, 
i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([5 x i8*], [5 
x i8*]* @_ZTVN5Test21CE, i64 0, i64 4) to i8*)] 
 // CHECK: @_ZTTN5Test31DE = linkonce_odr unnamed_addr constant [13 x i8*] [i8* 
bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, 
i64 0, i64 5) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*], [7 
x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i64 0, i64 3) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([7 x i8*], [7 x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i64 0, 
i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*], [14 x 
i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 6) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([14 x i8*], [14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 
0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*], [14 x 
i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 10) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([14 x i8*], [14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 
0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x 
i8*]* @_ZTVN5Test31DE, i64 0, i64 15) to i8*), i8* bitcast (i8** getelementptr 
inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 11) to i8*), i8* 
bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, 
i64 0, i64 11) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], 
[19 x i8*]* @_ZTVN5Test31DE, i64 1, i64 0) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([7 x i8*], [7 x i8*]* @_ZTCN5Test31DE64_NS_2V2E, i64 0, 
i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* 
@_ZTCN5Test31DE64_NS_2V2E, i64 0, i64 6) to i8*)] 
 // CHECK: @_ZTTN5Test41DE = linkonce_odr unnamed_addr constant [19 x i8*] [i8* 
bitcast (i8** getelementptr inbounds ([25 x i8*], [25 x i8*]* @_ZTVN5Test41DE, 
i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*], 
[11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 4) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([11 x i8*], [11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 
0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*], [11 x 
i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 10) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 
0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x 
i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 7) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 
0, i64 12) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x 
i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 15) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 
0, i64 18) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*], [25 x 
i8*]* @_ZTVN5Test41DE, i64 0, i64 17) to i8*), i8* bitcast (i8** getelementptr 
inbounds ([25 x i8*], [25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 20) to i8*), i8* 
bitcast (i8** getelementptr inbounds ([25 x i8*], [25 x i8*]* @_ZTVN5Test41DE, 
i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*], 
[25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 13) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([25 x i8*], [25 x i8*]* @_ZTVN5Test41DE, i64 1, i64 0) 
to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* 
@_ZTCN5Test41DE40_NS_2V1E, i64 0, i64 3) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([7 x i8*], [7 x i8*]* @_ZTCN5Test41DE40_NS_2V1E, i64 0, 
i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*], [11 x 
i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 4) to i8*), i8* bitcast (i8** 
getelementptr inbounds ([11 x i8*], [11 x i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 
0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*], [11 x 
i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 10) to i8*)] 
+// CHECK: declare void @__cxa_pure_virtual() unnamed_addr
+// CHECK: declare void @__cxa_deleted_virtual() unnamed_addr
Index: test/CodeGenCXX/virtual-function-attrs.cpp
===
--- /dev/null
+++ test/CodeGenCXX/virtual-function-attrs.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | 
FileCheck %s
+
+class A {

Re: r263299 - Add fix-it for format-security warnings.

2016-03-11 Thread Bob Wilson via cfe-commits
OK. I will do that.

> On Mar 11, 2016, at 4:15 PM, David Blaikie  wrote:
> 
> 
> 
> On Fri, Mar 11, 2016 at 4:14 PM, Bob Wilson via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> I’m not sure how to interpret that. It says: "Clang must recover from errors 
> as if the fix-it had been applied.” I suppose that format-security could be 
> an error if you’re building with -Werror, but I had been interpreting that to 
> mean an error that would block further compilation. Can someone clarify this 
> expectation?
> 
> I don’t think we can change -Wformat-security to be a note.
> 
> The suggestion isn't to change it to be a note, but to keep the warning but 
> move the fixit to a note associated with the warning.
> 
> That way -fix-it doesn't automatically apply the fix-it, which avoids the 
> issue of recovery as-if the fixit was applied.
>  
> It is an existing warning, and people expect us to match GCC on it as well.
> 
> 
>> On Mar 11, 2016, at 4:03 PM, Nico Weber > > wrote:
>> 
>> I think http://clang.llvm.org/docs/InternalsManual.html#fix-it-hints 
>>  says that if 
>> a fixit is on a warning, then clang should process the code as if the fixit 
>> had been applied. That's not the case here, so I think the fixit should be 
>> on a note instead.
>> 
>> On Fri, Mar 11, 2016 at 4:55 PM, Bob Wilson via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> Author: bwilson
>> Date: Fri Mar 11 15:55:37 2016
>> New Revision: 263299
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=263299&view=rev 
>> 
>> Log:
>> Add fix-it for format-security warnings.
>> 
>> Added:
>> cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m
>> Modified:
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/test/Sema/format-strings-fixit.c
>> 
>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=263299&r1=263298&r2=263299&view=diff
>>  
>> 
>> ==
>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Mar 11 15:55:37 2016
>> @@ -3621,20 +3621,32 @@ bool Sema::CheckFormatArguments(ArrayRef
>>// format is either NSString or CFString. This is a hack to prevent
>>// diag when using the NSLocalizedString and CFCopyLocalizedString macros
>>// which are usually used in place of NS and CF string literals.
>> -  if (Type == FST_NSString &&
>> -  SourceMgr.isInSystemMacro(Args[format_idx]->getLocStart()))
>> +  SourceLocation FormatLoc = Args[format_idx]->getLocStart();
>> +  if (Type == FST_NSString && SourceMgr.isInSystemMacro(FormatLoc))
>>  return false;
>> 
>>// If there are no arguments specified, warn with -Wformat-security, 
>> otherwise
>>// warn only with -Wformat-nonliteral.
>> -  if (Args.size() == firstDataArg)
>> -Diag(Args[format_idx]->getLocStart(),
>> - diag::warn_format_nonliteral_noargs)
>> +  if (Args.size() == firstDataArg) {
>> +const SemaDiagnosticBuilder &D =
>> +  Diag(FormatLoc, diag::warn_format_nonliteral_noargs);
>> +switch (Type) {
>> +default:
>> +  D << OrigFormatExpr->getSourceRange();
>> +  break;
>> +case FST_Kprintf:
>> +case FST_FreeBSDKPrintf:
>> +case FST_Printf:
>> +  D << FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
>> +  break;
>> +case FST_NSString:
>> +  D << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", ");
>> +  break;
>> +}
>> +  } else {
>> +Diag(FormatLoc, diag::warn_format_nonliteral)
>><< OrigFormatExpr->getSourceRange();
>> -  else
>> -Diag(Args[format_idx]->getLocStart(),
>> - diag::warn_format_nonliteral)
>> -   << OrigFormatExpr->getSourceRange();
>> +  }
>>return false;
>>  }
>> 
>> 
>> Modified: cfe/trunk/test/Sema/format-strings-fixit.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings-fixit.c?rev=263299&r1=263298&r2=263299&view=diff
>>  
>> 
>> ==
>> --- cfe/trunk/test/Sema/format-strings-fixit.c (original)
>> +++ cfe/trunk/test/Sema/format-strings-fixit.c Fri Mar 11 15:55:37 2016
>> @@ -16,6 +16,8 @@ typedef __UINTMAX_TYPE__ uintmax_t;
>>  typedef __PTRDIFF_TYPE__ ptrdiff_t;
>>  typedef __WCHAR_TYPE__ wchar_t;
>> 
>> +extern const char *NonliteralString;
>> +
>>  void test() {
>>// Basic types
>>printf("%s", (int) 123);
>> @@ -94,6 +96,9 @@ void test() {
>>printf("%G", (long double) 42);
>>printf("%a", (long double) 

Re: [PATCH] D17865: Add an optional string argument to DeprecatedAttr for Fix-It.

2016-03-11 Thread Manman Ren via cfe-commits
manmanren updated this revision to Diff 50502.

http://reviews.llvm.org/D17865

Files:
  include/clang/Basic/Attr.td
  lib/Lex/PPMacroExpansion.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCXX/attr-deprecated-replacement-error.cpp
  test/SemaCXX/attr-deprecated-replacement-fixit.cpp
  test/SemaCXX/cxx11-attr-print.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: test/SemaCXX/attr-deprecated-replacement-fixit.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-deprecated-replacement-fixit.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: cp %s %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fixit %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -Werror %t
+
+#if !__has_feature(attribute_deprecated_with_replacement)
+#error "Missing __has_feature"
+#endif
+
+void f_8(int) __attribute__((deprecated("message", "new8"))); // expected-note {{'f_8' has been explicitly marked deprecated here}}
+void new8(int);
+void test() {
+  f_8(0); // expected-warning{{'f_8' is deprecated}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:6}:"new8"
+}
Index: test/SemaCXX/attr-deprecated-replacement-error.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-deprecated-replacement-error.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -verify -fsyntax-only -std=c++11 -fms-extensions %s
+
+#if !__has_feature(attribute_deprecated_with_replacement)
+#error "Missing __has_feature"
+#endif
+
+int a1 [[deprecated("warning", "fixit")]]; // expected-error{{'deprecated' attribute takes no more than 1 argument}}
+int a2 [[deprecated("warning", 1)]]; // expected-error{{'deprecated' attribute takes no more than 1 argument}}
+
+int b1 [[gnu::deprecated("warning", "fixit")]]; // expected-error{{'deprecated' attribute takes no more than 1 argument}}
+int b2 [[gnu::deprecated("warning", 1)]]; // expected-error{{'deprecated' attribute takes no more than 1 argument}}
+
+__declspec(deprecated("warning", "fixit")) int c1; // expected-error{{'deprecated' attribute takes no more than 1 argument}}
+__declspec(deprecated("warning", 1)) int c2; // expected-error{{'deprecated' attribute takes no more than 1 argument}}
+
+int d1 __attribute__((deprecated("warning", "fixit")));
+int d2 __attribute__((deprecated("warning", 1))); // expected-error{{'deprecated' attribute requires a string}}
Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -,6 +,15 @@
  << "  OS << \"";
 }
 
+static void writeDeprecatedAttrValue(raw_ostream &OS, std::string &Variety) {
+  OS << "\\\"\" << getMessage() << \"\\\"\";\n";
+  // Only GNU deprecated has an optional fixit argument at the second position.
+  if (Variety == "GNU")
+ OS << "if (!getReplacement().empty()) OS << \", \\\"\""
+   " << getReplacement() << \"\\\"\";\n";
+  OS << "OS << \"";
+}
+
 static void writeGetSpellingFunction(Record &R, raw_ostream &OS) {
   std::vector Spellings = GetFlattenedSpellings(R);
 
@@ -1224,6 +1233,8 @@
   OS << "(";
 if (Spelling == "availability") {
   writeAvailabilityValue(OS);
+} else if (Spelling == "deprecated" || Spelling == "gnu::deprecated") {
+writeDeprecatedAttrValue(OS, Variety);
 } else {
   unsigned index = 0;
   for (const auto &arg : Args) {
Index: test/SemaCXX/cxx11-attr-print.cpp
===
--- test/SemaCXX/cxx11-attr-print.cpp
+++ test/SemaCXX/cxx11-attr-print.cpp
@@ -16,6 +16,15 @@
 // CHECK: int b {{\[}}[gnu::deprecated("warning")]];
 int b [[gnu::deprecated("warning")]];
 
+// CHECK: __declspec(deprecated("warning"))
+__declspec(deprecated("warning")) int c;
+
+// CHECK: int d {{\[}}[deprecated("warning")]];
+int d [[deprecated("warning")]];
+
+// CHECK: __attribute__((deprecated("warning", "fixit")));
+int e __attribute__((deprecated("warning", "fixit")));
+
 // CHECK: int cxx11_alignas alignas(4);
 alignas(4) int cxx11_alignas;
 
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5127,12 +5127,27 @@
 }
   }
 
+  // Handle the cases where the attribute has a text message.
+  StringRef Str, Replacement;
+  if (Attr.isArgExpr(0) && Attr.getArgAsExpr(0) &&
+  !S.checkStringLiteralArgumentAttr(Attr, 0, Str))
+return;
+
+  // Only support a single optional message for Declspec and CXX11.
+  if (Attr.isDeclspecAttribute() || Attr.isCXX11Attribute())
+checkAttributeAtMostNumArgs(S, Attr, 1);
+  else if (Attr.isArgExpr(1) && Attr.getArgAsExpr(1) &&
+   !S.checkStringLiteralArgu

Re: [PATCH] D17865: Add an optional string argument to DeprecatedAttr for Fix-It.

2016-03-11 Thread Manman Ren via cfe-commits
manmanren marked 3 inline comments as done.
manmanren added a comment.

Upload patch to address review comments.

Thanks,
Manman


http://reviews.llvm.org/D17865



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


[PATCH] D18112: [OpenMP] Replace offloading option that start with -o with -fo.

2016-03-11 Thread Samuel Antao via cfe-commits
sfantao created this revision.
sfantao added reviewers: ABataev, hfinkel, carlo.bertolli, arpith-jacob, kkwli0.
sfantao added subscribers: fraggamuffin, caomhin, cfe-commits.

The current offloading implementation is using -omptargets and 
-omp-host-ir-file-path options in the frontend. This causes the user a lot of 
trouble due to to the conflicts with the -o option. E.g. if the user misspells  
omptargets he will end up with a file with a weird name.

This patches replaces these two options with  -fomptargets and 
-fomp-host-ir-file-path to avoid these issues, and it is also more consistent 
with the other options like -fopenmp.

http://reviews.llvm.org/D18112

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/Frontend/CompilerInvocation.cpp
  test/OpenMP/distribute_codegen.cpp
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_codegen_global_capture.cpp
  test/OpenMP/target_codegen_registration.cpp
  test/OpenMP/target_codegen_registration_naming.cpp
  test/OpenMP/target_map_codegen.cpp
  test/OpenMP/target_messages.cpp
  test/OpenMP/target_parallel_messages.cpp
  test/OpenMP/teams_codegen.cpp
  test/OpenMP/teams_firstprivate_codegen.cpp
  test/OpenMP/teams_private_codegen.cpp

Index: test/OpenMP/teams_private_codegen.cpp
===
--- test/OpenMP/teams_private_codegen.cpp
+++ test/OpenMP/teams_private_codegen.cpp
@@ -1,16 +1,16 @@
-// RUN: %clang_cc1 -DLAMBDA -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix LAMBDA --check-prefix LAMBDA-64
-// RUN: %clang_cc1 -DLAMBDA -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
-// RUN: %clang_cc1 -DLAMBDA -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix LAMBDA --check-prefix LAMBDA-64
-// RUN: %clang_cc1 -DLAMBDA -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix LAMBDA --check-prefix LAMBDA-32
-// RUN: %clang_cc1 -DLAMBDA -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -o %t %s
-// RUN: %clang_cc1 -DLAMBDA -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix LAMBDA --check-prefix LAMBDA-32
+// RUN: %clang_cc1 -DLAMBDA -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fomptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix LAMBDA --check-prefix LAMBDA-64
+// RUN: %clang_cc1 -DLAMBDA -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fomptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -DLAMBDA -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fomptargets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix LAMBDA --check-prefix LAMBDA-64
+// RUN: %clang_cc1 -DLAMBDA -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fomptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix LAMBDA --check-prefix LAMBDA-32
+// RUN: %clang_cc1 -DLAMBDA -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fomptargets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -DLAMBDA -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fomptargets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix LAMBDA --check-prefix LAMBDA-32
 
-// RUN: %clang_cc1  -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
-// RUN: %clang_cc1  -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
-// RUN: %clang_cc1  -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
-// RUN: %clang_cc1  -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
-// RUN: %clang_cc1  -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -o %t %s
-// RUN: %clang_cc1  -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1  -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unk

[PATCH] D18113: CodeGen: Use 32-bit gep offsets to address vtable address points.

2016-03-11 Thread Peter Collingbourne via cfe-commits
pcc created this revision.
pcc added reviewers: rsmith, rjmccall.
pcc added a subscriber: cfe-commits.

The relative vtable ABI will use a struct rather than an array as the type
of a vtable. LLVM only allows 32-bit integers as struct indices, so we need
to use 32-bit integers to get addresses of address points. In order to keep
the code simple, we might as well do that unconditionally.

It's probably a reasonable implementation limit to support no more than 2
billion virtual functions per class.

This change causes quite a bit of churn in the test suite, so I'm making
it separately.

http://reviews.llvm.org/D18113

Files:
  lib/CodeGen/CGVTT.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/const-init-cxx11.cpp
  test/CodeGenCXX/constructor-init.cpp
  test/CodeGenCXX/copy-constructor-synthesis-2.cpp
  test/CodeGenCXX/copy-constructor-synthesis.cpp
  test/CodeGenCXX/microsoft-interface.cpp
  test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
  test/CodeGenCXX/strict-vtable-pointers.cpp
  test/CodeGenCXX/vtable-assume-load.cpp
  test/CodeGenCXX/vtable-pointer-initialization.cpp
  test/CodeGenCXX/vtt-layout.cpp

Index: test/CodeGenCXX/vtt-layout.cpp
===
--- test/CodeGenCXX/vtt-layout.cpp
+++ test/CodeGenCXX/vtt-layout.cpp
@@ -78,9 +78,9 @@
   }
 }
 
-// CHECK: @_ZTTN5Test11BE = unnamed_addr constant [1 x i8*] [i8* bitcast (i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @_ZTVN5Test11BE, i64 0, i64 3) to i8*)]
+// CHECK: @_ZTTN5Test11BE = unnamed_addr constant [1 x i8*] [i8* bitcast (i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @_ZTVN5Test11BE, i32 0, i32 3) to i8*)]
 // CHECK: @_ZTVN5Test51AE = unnamed_addr constant [4 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTIN5Test51AE to i8*), i8* bitcast (void ()* @__cxa_pure_virtual to i8*), i8* bitcast (void (%"struct.Test5::A"*)* @_ZN5Test51A6anchorEv to i8*)]
 // CHECK: @_ZTVN5Test61AE = unnamed_addr constant [4 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTIN5Test61AE to i8*), i8* bitcast (void ()* @__cxa_deleted_virtual to i8*), i8* bitcast (void (%"struct.Test6::A"*)* @_ZN5Test61A6anchorEv to i8*)]
-// CHECK: @_ZTTN5Test21CE = linkonce_odr unnamed_addr constant [2 x i8*] [i8* bitcast (i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @_ZTVN5Test21CE, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @_ZTVN5Test21CE, i64 0, i64 4) to i8*)] 
-// CHECK: @_ZTTN5Test31DE = linkonce_odr unnamed_addr constant [13 x i8*] [i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 5) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i64 0, i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*], [14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*], [14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*], [14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 10) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*], [14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 15) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 11) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 11) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, i64 1, i64 0) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* @_ZTCN5Test31DE64_NS_2V2E, i64 0, i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* @_ZTCN5Test31DE64_NS_2V2E, i64 0, i64 6) to i8*)] 
-// CHECK: @_ZTTN5Test41DE = linkonce_odr unnamed_addr constant [19 x i8*] [i8* bitcast (i8** getelementptr inbounds ([25 x i8*], [25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*], [11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*], [11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*], [11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 10) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 12) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 15) to i8*), i8* bitcast (i8** gete

Re: [PATCH] D18025: Add attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end

2016-03-11 Thread Roman Levenstein via cfe-commits
swiftix added inline comments.


Comment at: include/clang/Basic/Attr.td:1394
@@ -1393,1 +1393,3 @@
 
+def PreserveMost : InheritableAttr {
+  let Spellings = [GNU<"preserve_most">];

aaron.ballman wrote:
> Do these attributes do anything on targets other than AArch64 and x86-64? If 
> not, these should probably be inheriting from TargetSpecificAttr. (With tests 
> confirming the behavior on other targets.)
These attributes are not target-specific, IMHO, and they would make sense for 
other targets as well.  But they are currently implemented only for AArch64 and 
x86-64.


http://reviews.llvm.org/D18025



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


r263320 - Temporarily revert these patches:

2016-03-11 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Fri Mar 11 19:47:11 2016
New Revision: 263320

URL: http://llvm.org/viewvc/llvm-project?rev=263320&view=rev
Log:
Temporarily revert these patches:

commit 60d9845f6a037122d9be9a6d92d4de617ef45b04
Author: Mehdi Amini 
Date:   Fri Mar 11 18:48:02 2016 +

Fix clang crash: when CodeGenAction is initialized without a
context, use the member and not the parameter

From: Mehdi Amini 

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263273
91177308-0d34-0410-b5e6-96231b3b80d8

commit af7ce3bf04a75ad5124b457b805df26006bd215b
Author: Mehdi Amini 
Date:   Fri Mar 11 17:32:58 2016 +

Fix build: use -> with pointers and not .

Silly typo.

From: Mehdi Amini 

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263267
91177308-0d34-0410-b5e6-96231b3b80d8

commit d0eea119192814954e7368c77d0dc5a9eeec1fbb
Author: Mehdi Amini 
Date:   Fri Mar 11 17:15:44 2016 +

Remove compile time PreserveName switch based on NDEBUG

Summary:
Following r263086, we are now relying on a flag on the Context to
discard Value names in release builds.

Reviewers: chandlerc

Subscribers: cfe-commits

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

From: Mehdi Amini 

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263257
91177308-0d34-0410-b5e6-96231b3b80d8

until we can fix the Release builds.

This reverts commits 263257, 263267, 263273

Modified:
cfe/trunk/lib/CodeGen/CGBuilder.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuilder.h?rev=263320&r1=263319&r2=263320&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuilder.h (original)
+++ cfe/trunk/lib/CodeGen/CGBuilder.h Fri Mar 11 19:47:11 2016
@@ -23,7 +23,9 @@ class CodeGenFunction;
 /// \brief This is an IRBuilder insertion helper that forwards to
 /// CodeGenFunction::InsertHelper, which adds necessary metadata to
 /// instructions.
-class CGBuilderInserter : protected llvm::IRBuilderDefaultInserter {
+template 
+class CGBuilderInserter
+: protected llvm::IRBuilderDefaultInserter {
 public:
   CGBuilderInserter() = default;
   explicit CGBuilderInserter(CodeGenFunction *CGF) : CGF(CGF) {}
@@ -37,10 +39,17 @@ private:
   CodeGenFunction *CGF = nullptr;
 };
 
-typedef CGBuilderInserter CGBuilderInserterTy;
+// Don't preserve names on values in an optimized build.
+#ifdef NDEBUG
+#define PreserveNames false
+#else
+#define PreserveNames true
+#endif
 
-typedef llvm::IRBuilder
-CGBuilderBaseTy;
+typedef CGBuilderInserter CGBuilderInserterTy;
+
+typedef llvm::IRBuilder CGBuilderBaseTy;
 
 class CGBuilderTy : public CGBuilderBaseTy {
   /// Storing a reference to the type cache here makes it a lot easier
@@ -296,6 +305,8 @@ public:
   }
 };
 
+#undef PreserveNames
+
 }  // end namespace CodeGen
 }  // end namespace clang
 

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=263320&r1=263319&r2=263320&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Mar 11 19:47:11 2016
@@ -3840,7 +3840,7 @@ RValue CodeGenFunction::EmitCall(const C
   }
 
   llvm::Instruction *CI = CS.getInstruction();
-  if (!CI->getType()->isVoidTy())
+  if (Builder.isNamePreserving() && !CI->getType()->isVoidTy())
 CI->setName("call");
 
   // Emit any writebacks immediately.  Arguably this should happen

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=263320&r1=263319&r2=263320&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Mar 11 19:47:11 2016
@@ -66,6 +66,8 @@ Address CodeGenFunction::CreateTempAlloc
 /// block.
 llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty,
 const Twine &Name) {
+  if (!Builder.isNamePreserving())
+return new llvm::AllocaInst(Ty, nullptr, "", AllocaInsertPt);
   return new llvm::AllocaInst(Ty, nullptr, Name, AllocaInsertPt);
 }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=263320&r1=263319&r2=263320&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri Mar 11 19:47:11 2016
@@ -656,13 +656,7 @@ void BackendConsumer::DiagnosticHandlerI
 
 CodeGenAction::CodeGen

Re: [PATCH] D18025: Add attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end

2016-03-11 Thread Roman Levenstein via cfe-commits
swiftix updated this revision to Diff 50508.
swiftix added a comment.

This patch revision addresses all issues mentioned by reviewers:

- DocCatCallingConvs is used instead of DocCatVariable.
- ObjectiveC is replaced by Objective-C in the docs.
- Tests for preserve_most and preserve_all are combined into one file.


http://reviews.llvm.org/D18025

Files:
  include/clang-c/Index.h
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/Specifiers.h
  lib/AST/ItaniumMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  test/CodeGen/preserve-call-conv.c
  test/Sema/preserve-call-conv.c
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -534,6 +534,8 @@
   TCALLINGCONV(AAPCS_VFP);
   TCALLINGCONV(IntelOclBicc);
   TCALLINGCONV(Swift);
+  TCALLINGCONV(PreserveMost);
+  TCALLINGCONV(PreserveAll);
 case CC_SpirFunction: return CXCallingConv_Unexposed;
 case CC_SpirKernel: return CXCallingConv_Unexposed;
   break;
Index: test/Sema/preserve-call-conv.c
===
--- /dev/null
+++ test/Sema/preserve-call-conv.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify
+// RUN: %clang_cc1 %s -fsyntax-only -triple arm64-unknown-unknown -verify
+typedef void typedef_fun_t(int);
+
+void __attribute__((preserve_most)) foo(void *ptr) {
+}
+
+void __attribute__((preserve_most(1))) foo1(void *ptr) { // expected-error {{'preserve_most' attribute takes no arguments}}
+}
+
+void (__attribute__((preserve_most)) *pfoo1)(void *) = foo;
+
+void (__attribute__((cdecl)) *pfoo2)(void *) = foo; // expected-warning {{incompatible pointer types initializing 'void (*)(void *) __attribute__((cdecl))' with an expression of type 'void (void *) __attribute__((preserve_most))'}}
+void (*pfoo3)(void *) = foo; // expected-warning {{incompatible pointer types initializing 'void (*)(void *)' with an expression of type 'void (void *) __attribute__((preserve_most))'}}
+
+typedef_fun_t typedef_fun_foo; // expected-note {{previous declaration is here}}
+void __attribute__((preserve_most)) typedef_fun_foo(int x) { } // expected-error {{function declared 'preserve_most' here was previously declared without calling convention}}
+
+struct type_test_foo {} __attribute__((preserve_most));  // expected-warning {{'preserve_most' attribute only applies to functions and methods}}
+
+void __attribute__((preserve_all)) boo(void *ptr) {
+}
+
+void __attribute__((preserve_all(1))) boo1(void *ptr) { // expected-error {{'preserve_all' attribute takes no arguments}}
+}
+
+void (__attribute__((preserve_all)) *pboo1)(void *) = boo;
+
+void (__attribute__((cdecl)) *pboo2)(void *) = boo; // expected-warning {{incompatible pointer types initializing 'void (*)(void *) __attribute__((cdecl))' with an expression of type 'void (void *) __attribute__((preserve_all))'}}
+void (*pboo3)(void *) = boo; // expected-warning {{incompatible pointer types initializing 'void (*)(void *)' with an expression of type 'void (void *) __attribute__((preserve_all))'}}
+
+typedef_fun_t typedef_fun_boo; // expected-note {{previous declaration is here}}
+void __attribute__((preserve_all)) typedef_fun_boo(int x) { } // expected-error {{function declared 'preserve_all' here was previously declared without calling convention}}
+
+struct type_test_boo {} __attribute__((preserve_all));  // expected-warning {{'preserve_all' attribute only applies to functions and methods}}
Index: test/CodeGen/preserve-call-conv.c
===
--- /dev/null
+++ test/CodeGen/preserve-call-conv.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-unknown-unknown -emit-llvm < %s | FileCheck %s
+
+// Check that the preserve_most calling convention attribute at the source level
+// is lowered to the corresponding calling convention attrribute at the LLVM IR
+// level.
+void foo() __attribute__((preserve_most)) {
+  // CHECK-LABEL: define preserve_mostcc void @foo()
+}
+
+// Check that the preserve_most calling convention attribute at the source level
+// is lowered to the corresponding calling convention attrribute at the LLVM IR
+// level.
+void boo() __attribute__((preserve_all)) {
+  // CHECK-LABEL: define preserve_allcc void @boo()
+}
+
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -112,7 +112,9 @@
 case AttributeList::AT_MSABI: \
 case AttributeList::AT_SysVABI: \
 case AttributeList::AT_Pcs: \
-case AttributeList::AT_IntelOclBicc
+case Att

Re: r263320 - Temporarily revert these patches:

2016-03-11 Thread Eric Christopher via cfe-commits
To be clear these were due to test failures under Release (no Asserts)
coming from clang. Mehdi already has a fix in mind.

The bot I mention in followup to the original patch has the test failures.

-eric

On Fri, Mar 11, 2016 at 5:52 PM Eric Christopher via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: echristo
> Date: Fri Mar 11 19:47:11 2016
> New Revision: 263320
>
> URL: http://llvm.org/viewvc/llvm-project?rev=263320&view=rev
> Log:
> Temporarily revert these patches:
>
> commit 60d9845f6a037122d9be9a6d92d4de617ef45b04
> Author: Mehdi Amini 
> Date:   Fri Mar 11 18:48:02 2016 +
>
> Fix clang crash: when CodeGenAction is initialized without a
> context, use the member and not the parameter
>
> From: Mehdi Amini 
>
> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263273
> 91177308-0d34-0410-b5e6-96231b3b80d8
>
> commit af7ce3bf04a75ad5124b457b805df26006bd215b
> Author: Mehdi Amini 
> Date:   Fri Mar 11 17:32:58 2016 +
>
> Fix build: use -> with pointers and not .
>
> Silly typo.
>
> From: Mehdi Amini 
>
> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263267
> 91177308-0d34-0410-b5e6-96231b3b80d8
>
> commit d0eea119192814954e7368c77d0dc5a9eeec1fbb
> Author: Mehdi Amini 
> Date:   Fri Mar 11 17:15:44 2016 +
>
> Remove compile time PreserveName switch based on NDEBUG
>
> Summary:
> Following r263086, we are now relying on a flag on the Context to
> discard Value names in release builds.
>
> Reviewers: chandlerc
>
> Subscribers: cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D18024
>
> From: Mehdi Amini 
>
> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263257
> 91177308-0d34-0410-b5e6-96231b3b80d8
>
> until we can fix the Release builds.
>
> This reverts commits 263257, 263267, 263273
>
> Modified:
> cfe/trunk/lib/CodeGen/CGBuilder.h
> cfe/trunk/lib/CodeGen/CGCall.cpp
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGBuilder.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuilder.h?rev=263320&r1=263319&r2=263320&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGBuilder.h (original)
> +++ cfe/trunk/lib/CodeGen/CGBuilder.h Fri Mar 11 19:47:11 2016
> @@ -23,7 +23,9 @@ class CodeGenFunction;
>  /// \brief This is an IRBuilder insertion helper that forwards to
>  /// CodeGenFunction::InsertHelper, which adds necessary metadata to
>  /// instructions.
> -class CGBuilderInserter : protected llvm::IRBuilderDefaultInserter {
> +template 
> +class CGBuilderInserter
> +: protected llvm::IRBuilderDefaultInserter {
>  public:
>CGBuilderInserter() = default;
>explicit CGBuilderInserter(CodeGenFunction *CGF) : CGF(CGF) {}
> @@ -37,10 +39,17 @@ private:
>CodeGenFunction *CGF = nullptr;
>  };
>
> -typedef CGBuilderInserter CGBuilderInserterTy;
> +// Don't preserve names on values in an optimized build.
> +#ifdef NDEBUG
> +#define PreserveNames false
> +#else
> +#define PreserveNames true
> +#endif
>
> -typedef llvm::IRBuilder
> -CGBuilderBaseTy;
> +typedef CGBuilderInserter CGBuilderInserterTy;
> +
> +typedef llvm::IRBuilder +CGBuilderInserterTy> CGBuilderBaseTy;
>
>  class CGBuilderTy : public CGBuilderBaseTy {
>/// Storing a reference to the type cache here makes it a lot easier
> @@ -296,6 +305,8 @@ public:
>}
>  };
>
> +#undef PreserveNames
> +
>  }  // end namespace CodeGen
>  }  // end namespace clang
>
>
> Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=263320&r1=263319&r2=263320&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Mar 11 19:47:11 2016
> @@ -3840,7 +3840,7 @@ RValue CodeGenFunction::EmitCall(const C
>}
>
>llvm::Instruction *CI = CS.getInstruction();
> -  if (!CI->getType()->isVoidTy())
> +  if (Builder.isNamePreserving() && !CI->getType()->isVoidTy())
>  CI->setName("call");
>
>// Emit any writebacks immediately.  Arguably this should happen
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=263320&r1=263319&r2=263320&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Mar 11 19:47:11 2016
> @@ -66,6 +66,8 @@ Address CodeGenFunction::CreateTempAlloc
>  /// block.
>  llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty,
>  const Twine &Name) {
> +  if (!Builder.isNamePreserving())
> + 

[PATCH] D18115: [libcxx] unordered_set: Update test for unnecessary mallocs in insert, NFC

2016-03-11 Thread Duncan P. N. Exon Smith via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: EricWF.
dexonsmith added a subscriber: cfe-commits.

Modernize the test from r239666 as a precursor for making similar fixes
to unordered_map.


http://reviews.llvm.org/D18115

Files:
  test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp

Index: test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
===
--- test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
+++ test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
@@ -11,38 +11,58 @@
 // unordered_set. See PR12999 http://llvm.org/bugs/show_bug.cgi?id=12999
 
 #include 
+#include 
 #include 
+
+#include "container_test_types.h"
 #include "count_new.hpp"
-#include "MoveOnly.h"
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 11
+template 
+void PrintInfo(int line, Arg&& arg)
+#else
+template 
+void PrintInfo(int line, Arg arg)
+#endif
+{
+  std::cout << "In " << __FILE__ << ":" << line << ":\n" << arg << "\n" << 
std::endl;
+}
+#define PRINT(...) PrintInfo(__LINE__, __VA_ARGS__)
+
+template 
+void testContainerInsert()
+{
+  typedef typename Container::value_type ValueTp;
+  typedef Container C;
+  typedef std::pair R;
+  ConstructController* cc = getConstructController();
+  cc->reset();
+  Container c;
+  cc->expect();
+
+  PRINT("Expect a malloc in initial insertion");
+  assert(c.insert(ValueTp(3)).second);
+  assert(!cc->unchecked());
+  DisableAllocationGuard g;
+
+  PRINT("Checking for mallocs in insert(value_type&&)");
+  assert(!c.insert(ValueTp(3)).second);
+
+  PRINT("Checking for mallocs in insert(value_type&)");
+  {
+ValueTp v(3);
+assert(!c.insert(v).second);
+  }
+
+  PRINT("Checking for mallocs in insert(const value_type&)");
+  {
+const ValueTp v(3);
+assert(!c.insert(v).second);
+  }
+}
 
 int main()
 {
-{
-std::unordered_set s;
-assert(globalMemCounter.checkNewCalledEq(0));
-
-for(int i=0; i < 100; ++i)
-s.insert(3);
-
-assert(s.size() == 1);
-assert(s.count(3) == 1);
-assert(globalMemCounter.checkNewCalledEq(2));
-}
-assert(globalMemCounter.checkOutstandingNewEq(0));
-globalMemCounter.reset();
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-{
-std::unordered_set s;
-assert(globalMemCounter.checkNewCalledEq(0));
-
-for(int i=0; i<100; i++)
-s.insert(MoveOnly(3));
-
-assert(s.size() == 1);
-assert(s.count(MoveOnly(3)) == 1);
-assert(globalMemCounter.checkNewCalledEq(2));
-}
-assert(globalMemCounter.checkOutstandingNewEq(0));
-globalMemCounter.reset();
-#endif
+  testContainerInsert >();
 }


Index: test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
===
--- test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
+++ test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
@@ -11,38 +11,58 @@
 // unordered_set. See PR12999 http://llvm.org/bugs/show_bug.cgi?id=12999
 
 #include 
+#include 
 #include 
+
+#include "container_test_types.h"
 #include "count_new.hpp"
-#include "MoveOnly.h"
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 11
+template 
+void PrintInfo(int line, Arg&& arg)
+#else
+template 
+void PrintInfo(int line, Arg arg)
+#endif
+{
+  std::cout << "In " << __FILE__ << ":" << line << ":\n" << arg << "\n" << std::endl;
+}
+#define PRINT(...) PrintInfo(__LINE__, __VA_ARGS__)
+
+template 
+void testContainerInsert()
+{
+  typedef typename Container::value_type ValueTp;
+  typedef Container C;
+  typedef std::pair R;
+  ConstructController* cc = getConstructController();
+  cc->reset();
+  Container c;
+  cc->expect();
+
+  PRINT("Expect a malloc in initial insertion");
+  assert(c.insert(ValueTp(3)).second);
+  assert(!cc->unchecked());
+  DisableAllocationGuard g;
+
+  PRINT("Checking for mallocs in insert(value_type&&)");
+  assert(!c.insert(ValueTp(3)).second);
+
+  PRINT("Checking for mallocs in insert(value_type&)");
+  {
+ValueTp v(3);
+assert(!c.insert(v).second);
+  }
+
+  PRINT("Checking for mallocs in insert(const value_type&)");
+  {
+const ValueTp v(3);
+assert(!c.insert(v).second);
+  }
+}
 
 int main()
 {
-{
-std::unordered_set s;
-assert(globalMemCounter.checkNewCalledEq(0));
-
-for(int i=0; i < 100; ++i)
-s.insert(3);
-
-assert(s.size() == 1);
-assert(s.count(3) == 1);
-assert(globalMemCounter.checkNewCalledEq(2));
-}
-assert(globalMemCounter.checkOutstandingNewEq(0));
-globalMemCounter.reset();
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-{
-std::unordered_set s;
-assert(globalMemCounter.checkNewCalledEq(0));
-
-for(int i=0; i<100; i++)
-s.insert(MoveOnly(3));
-
-assert(s.size() == 1);
-assert(s.count(MoveOnly(3)) == 1);
-assert(globalMemCounter.checkNewCalledEq(2));
-}
-assert(globalMemCounter.checkOutstandingNewEq(0));
-globalMe

Re: [PATCH] D18105: [OPENMP] Support for codegen of private clause of target, host side

2016-03-11 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 50512.
carlo.bertolli added a comment.

[OPENMP] Add missing check macros in regression test and remove reference to 
firstprivate (will come in next patch).


Repository:
  rL LLVM

http://reviews.llvm.org/D18105

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/target_private_codegen.cpp

Index: test/OpenMP/target_private_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_private_codegen.cpp
@@ -0,0 +1,264 @@
+// Only test codegen on target side, as private clause does not require any action on the host side
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+template
+struct TT{
+  tx X;
+  ty Y;
+};
+
+// TCHECK: [[TT:%.+]] = type { i64, i8 }
+// TCHECK: [[S1:%.+]] = type { double }
+
+int foo(int n) {
+  int a = 0;
+  short aa = 0;
+  float b[10];
+  float bn[n];
+  double c[5][10];
+  double cn[5][n];
+  TT d;
+
+  #pragma omp target private(a)
+  {
+  }
+
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK-NOT: store {{.+}}, {{.+}} [[A]],
+  // TCHECK:  ret void  
+
+#pragma omp target private(a)
+  {
+a = 1;
+  }
+
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[A]],
+  // TCHECK:  ret void
+  
+  #pragma omp target private(a, aa)
+  {
+a = 1;
+aa = 1;
+  }
+
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[A2:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[A]],
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[A2]],
+  // TCHECK:  ret void
+
+  #pragma omp target private(a, b, bn, c, cn, d)
+  {
+a = 1;
+b[2] = 1.0;
+bn[3] = 1.0;
+c[1][2] = 1.0;
+cn[1][3] = 1.0;
+d.X = 1;
+d.Y = 1;
+  }
+  // make sure that private variables are generated in all cases and that we use those instances for operations inside the
+  // target region
+  // TCHECK:  define void @__omp_offloading_{{.+}}(i{{[0-9]+}} [[VLA:%.+]], i{{[0-9]+}} [[VLA1:%.+]], i{{[0-9]+}} [[VLA3:%.+]])
+  // TCHECK:  [[VLA_ADDR:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[VLA_ADDR2:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[VLA_ADDR4:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[B:%.+]] = alloca [10 x float],
+  // TCHECK:  [[SSTACK:%.+]] = alloca i8*,
+  // TCHECK:  [[C:%.+]] = alloca [5 x [10 x double]],
+  // TCHECK:  [[D:%.+]] = alloca [[TT]],
+  // TCHECK:  store i{{[0-9]+}} [[VLA]], i{{[0-9]+}}* [[VLA_ADDR]],
+  // TCHECK:  store i{{[0-9]+}} [[VLA1]], i{{[0-9]+}}* [[VLA_ADDR2]],
+  // TCHECK:  store i{{[0-9]+}} [[VLA3]], i{{[0-9]+}}* [[VLA_ADDR4]],
+  // TCHECK:  [[VLA_ADDR_REF:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[VLA_ADDR]],
+  // TCHECK:  [[VLA_ADDR_REF2:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[VLA_ADDR2]],
+  // TCHECK:  [[VLA_ADDR_REF4:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[VLA_ADDR4]],
+  // TCHECK:  [[RET_STACK:%.+]] = call i8* @llvm.stacksave()
+  // TCHECK:  store i8* [[RET_STACK]], i8** [[SSTACK]],
+  

Re: [PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-03-11 Thread Duncan P. N. Exon Smith via cfe-commits
dexonsmith updated this revision to Diff 50514.
dexonsmith added a comment.

A few updates:

- Rebased on top of http://reviews.llvm.org/D18115.
- Rewrote the test to match suggested style.
- Updated the code to catch unordered_set::emplace as well, using a 
__can_extract_key trait and a companion __extract_key functor.

Sorry for the latency reposting; let me know how this looks.


http://reviews.llvm.org/D16360

Files:
  include/__hash_table
  test/libcxx/containers/unord/unord.map/insert_dup_alloc.pass.cpp
  test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp

Index: test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
===
--- test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
+++ test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
@@ -60,6 +60,21 @@
 const ValueTp v(3);
 assert(!c.insert(v).second);
   }
+
+  PRINT("Checking for mallocs in emplace(value_type&&)");
+  assert(!c.emplace(ValueTp(3)).second);
+
+  PRINT("Checking for mallocs in emplace(value_type&)");
+  {
+ValueTp v(3);
+assert(!c.emplace(v).second);
+  }
+
+  PRINT("Checking for mallocs in emplace(const value_type&)");
+  {
+const ValueTp v(3);
+assert(!c.emplace(v).second);
+  }
 }
 
 int main()
Index: test/libcxx/containers/unord/unord.map/insert_dup_alloc.pass.cpp
===
--- /dev/null
+++ test/libcxx/containers/unord/unord.map/insert_dup_alloc.pass.cpp
@@ -0,0 +1,103 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// Check that we don't allocate when trying to insert a duplicate value into a
+// unordered_map.
+
+#include 
+#include 
+#include 
+
+#include "container_test_types.h"
+#include "count_new.hpp"
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 11
+template 
+void PrintInfo(int line, Arg&& arg)
+#else
+template 
+void PrintInfo(int line, Arg arg)
+#endif
+{
+  std::cout << "In " << __FILE__ << ":" << line << ":\n" << arg << "\n" << std::endl;
+}
+#define PRINT(...) PrintInfo(__LINE__, __VA_ARGS__)
+
+template 
+void testContainerInsert()
+{
+  typedef typename Container::value_type ValueTp;
+  typedef std::pair
+  PairTp;
+  typedef Container C;
+  typedef std::pair R;
+  ConstructController* cc = getConstructController();
+  cc->reset();
+  Container c;
+  cc->expect();
+
+  PRINT("Expect a malloc in initial insertion");
+  assert(c.insert(ValueTp(3, 4)).second);
+  assert(!cc->unchecked());
+  DisableAllocationGuard g;
+
+  PRINT("Checking for mallocs in insert(value_type&&)");
+  assert(!c.insert(ValueTp(3, 4)).second);
+  assert(!c.insert(PairTp(3, 4)).second);
+
+  PRINT("Checking for mallocs in insert(value_type&)");
+  {
+ValueTp v(3, 4);
+assert(!c.insert(v).second);
+  }
+  {
+PairTp v(3, 4);
+assert(!c.insert(v).second);
+  }
+
+  PRINT("Checking for mallocs in insert(const value_type&)");
+  {
+const ValueTp v(3, 4);
+assert(!c.insert(v).second);
+  }
+  {
+const PairTp v(3, 4);
+assert(!c.insert(v).second);
+  }
+
+  PRINT("Checking for mallocs in emplace(value_type&&)");
+  assert(!c.emplace(ValueTp(3, 4)).second);
+  assert(!c.emplace(PairTp(3, 4)).second);
+
+  PRINT("Checking for mallocs in emplace(value_type&)");
+  {
+ValueTp v(3, 4);
+assert(!c.emplace(v).second);
+  }
+  {
+PairTp v(3, 4);
+assert(!c.emplace(v).second);
+  }
+
+  PRINT("Checking for mallocs in emplace(const value_type&)");
+  {
+const ValueTp v(3, 4);
+assert(!c.emplace(v).second);
+  }
+  {
+const PairTp v(3, 4);
+assert(!c.emplace(v).second);
+  }
+}
+
+int main()
+{
+  testContainerInsert >();
+}
Index: include/__hash_table
===
--- include/__hash_table
+++ include/__hash_table
@@ -100,6 +100,34 @@
 return size_t(1) << (std::numeric_limits::digits - __clz(__n-1));
 }
 
+template 
+struct __extract_key;
+
+template ::type>
+struct __can_extract_key
+: is_same<
+  typename remove_const::type>::type,
+  _Key> {};
+template 
+struct __extract_key<_Key, _Key> {
+  const _Key &operator()(const _Key &__key) { return __key; }
+};
+
+template 
+struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
+: is_same::type, _Key> {};
+template 
+struct __extract_key, _Key> {
+  const _Key &operator()(const pair<_Key, _Second> &__p) { return __p.first; }
+};
+template 
+struct __extract_key, _Key> {
+  const _Key &operator()(const pair &__p) {
+return __p.first;
+  }
+};
+
 template  class __hash_table;
 
 template   class _LIBCPP_TYPE_VIS_ONLY __hash_iterator;
@@ -9

Re: [PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-03-11 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

No worries, I'll try and take a look this weekend. Thanks.


http://reviews.llvm.org/D16360



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