Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-04-28 Thread Hal Finkel via cfe-commits
hfinkel added inline comments.


Comment at: lib/CodeGen/CodeGenAction.cpp:734-737
@@ +733,6 @@
+
+  OS << llvm::format_decimal(L + 1, LNDigits) << " ";
+  OS << (LLI.Inlined.Transformed && InlinedCols < 2 ? "I" : " ");
+  OS << (LLI.Unrolled.Transformed && UnrolledCols < 2 ? "U" : " ");
+  OS << (LLI.Vectorized.Transformed && VectorizedCols < 2 ? "V" : " ");
+

anemet wrote:
> Should the abbreviation be somehow part of the optimization remark API and 
> passed in just like the pass name?
> 
> It would be nice if someone added optimization remark for a new opt, it would 
> show up here automatically.  I could see how that could make the output too 
> busy but at least have the option?
> 
So long as we're careful in the backend to respect the limited visual real 
estate and namespace in this kind of report, we could have the optimizations 
themselves provide a letter. I'm undecided.


http://reviews.llvm.org/D19678



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


Re: [PATCH] D17841: [libclang/python] Add bindings for children of diagnostics

2016-04-28 Thread Hanson Wang via cfe-commits
hansonw added a comment.

Thanks! I don't have commit permissions; could you check this in for me?



Comment at: bindings/python/clang/cindex.py:369
@@ +368,3 @@
+def __len__(self):
+return 
int(conf.lib.clang_getNumDiagnosticsInSet(self.diag_set))
+

compnerd wrote:
> Why does this need the explicit int construction?
This returns a long on 64-bit systems - however `__len__` must return a plain 
int.


http://reviews.llvm.org/D17841



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


[libcxx] r267983 - Move extern C include test into test/libcxx

2016-04-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Apr 28 23:19:48 2016
New Revision: 267983

URL: http://llvm.org/viewvc/llvm-project?rev=267983=rev
Log:
Move extern C include test into test/libcxx

Added:
libcxx/trunk/test/libcxx/depr/
libcxx/trunk/test/libcxx/depr/depr.c.headers/
libcxx/trunk/test/libcxx/depr/depr.c.headers/extern_c.pass.cpp
Removed:
libcxx/trunk/test/std/depr/depr.c.headers/extern_c.pass.cpp

Added: libcxx/trunk/test/libcxx/depr/depr.c.headers/extern_c.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/depr/depr.c.headers/extern_c.pass.cpp?rev=267983=auto
==
--- libcxx/trunk/test/libcxx/depr/depr.c.headers/extern_c.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/depr/depr.c.headers/extern_c.pass.cpp Thu Apr 28 
23:19:48 2016
@@ -0,0 +1,43 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// Sometimes C++'s  headers get included within extern "C" contexts. 
This
+// is ill-formed (no diagnostic required), per [using.headers]p3, but we permit
+// it as an extension.
+
+extern "C" {
+#include 
+// complex.h is not supported in extern "C".
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+// tgmath.h is not supported in extern "C".
+#include 
+// FIXME: #include 
+#include 
+#include 
+}
+
+int main() {}

Removed: libcxx/trunk/test/std/depr/depr.c.headers/extern_c.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/extern_c.pass.cpp?rev=267982=auto
==
--- libcxx/trunk/test/std/depr/depr.c.headers/extern_c.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/extern_c.pass.cpp (removed)
@@ -1,43 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// Sometimes C++'s  headers get included within extern "C" contexts. 
This
-// is ill-formed (no diagnostic required), per [using.headers]p3, but we permit
-// it as an extension.
-
-extern "C" {
-#include 
-// complex.h is not supported in extern "C".
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-// tgmath.h is not supported in extern "C".
-#include 
-// FIXME: #include 
-#include 
-#include 
-}
-
-int main() {}


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


Re: [PATCH] D17841: [libclang/python] Add bindings for children of diagnostics

2016-04-28 Thread Saleem Abdulrasool via cfe-commits
compnerd accepted this revision.
This revision is now accepted and ready to land.


Comment at: bindings/python/clang/cindex.py:369
@@ +368,3 @@
+def __len__(self):
+return 
int(conf.lib.clang_getNumDiagnosticsInSet(self.diag_set))
+

Why does this need the explicit int construction?


http://reviews.llvm.org/D17841



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


[libcxx] r267982 - Fix test failures by adding missing include

2016-04-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Apr 28 23:18:13 2016
New Revision: 267982

URL: http://llvm.org/viewvc/llvm-project?rev=267982=rev
Log:
Fix test failures by adding missing include

Modified:
libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp

Modified: libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp?rev=267982=267981=267982=diff
==
--- libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp Thu Apr 28 23:18:13 
2016
@@ -10,6 +10,7 @@
 // 
 
 #include 
+#include 
 #include 
 
 #ifndef NULL


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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-04-28 Thread David Majnemer via cfe-commits
majnemer added a comment.

It would be good to have a test for the variable template case:

  template 
  T x;
  
  auto g() { return x; }

should mangle to `??$x@PEFAH@@3PEFAHEFA`


http://reviews.llvm.org/D19654



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


[libcxx] r267981 - Fix or move various non-standard tests.

2016-04-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Apr 28 23:07:45 2016
New Revision: 267981

URL: http://llvm.org/viewvc/llvm-project?rev=267981=rev
Log:
Fix or move various non-standard tests.

This patch does the following:

* Remove <__config> includes from some container tests.
* Guards uses of std::launch::any in async tests because it's an extension.
* Move "test/std/extensions" to "test/libcxx/extensions"
* Moves various non-standard tests including those in "sequences/vector",
  "std/localization" and "utilities/meta".

Added:

libcxx/trunk/test/libcxx/containers/sequences/vector/const_value_type.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/vector/db_back.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/vector/db_cback.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/vector/db_cindex.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/vector/db_front.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/vector/db_index.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/vector/db_iterators_2.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/vector/db_iterators_3.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/vector/db_iterators_4.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/vector/db_iterators_8.pass.cpp
libcxx/trunk/test/libcxx/extensions/
libcxx/trunk/test/libcxx/extensions/hash/
libcxx/trunk/test/libcxx/extensions/hash/specializations.fail.cpp
libcxx/trunk/test/libcxx/extensions/hash/specializations.pass.cpp
libcxx/trunk/test/libcxx/extensions/hash_map/
libcxx/trunk/test/libcxx/extensions/hash_map/const_iterator.fail.cpp
libcxx/trunk/test/libcxx/extensions/nothing_to_do.pass.cpp
libcxx/trunk/test/libcxx/localization/
libcxx/trunk/test/libcxx/localization/locale.categories/

libcxx/trunk/test/libcxx/localization/locale.categories/__scan_keyword.pass.cpp
libcxx/trunk/test/libcxx/localization/locales/
libcxx/trunk/test/libcxx/localization/locales/locale/
libcxx/trunk/test/libcxx/localization/locales/locale/locale.types/

libcxx/trunk/test/libcxx/localization/locales/locale/locale.types/locale.facet/

libcxx/trunk/test/libcxx/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
libcxx/trunk/test/libcxx/localization/locales/locale/locale.types/locale.id/

libcxx/trunk/test/libcxx/localization/locales/locale/locale.types/locale.id/id.pass.cpp
libcxx/trunk/test/libcxx/utilities/meta/meta.unary/
libcxx/trunk/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/

libcxx/trunk/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp

libcxx/trunk/test/std/localization/locales/locale/locale.types/locale.facet/tested_elsewhere.pass.cpp

libcxx/trunk/test/std/localization/locales/locale/locale.types/locale.id/tested_elsewhere.pass.cpp
Removed:
libcxx/trunk/test/std/containers/sequences/vector/const_value_type.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector/db_back.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector/db_cback.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector/db_cfront.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector/db_cindex.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector/db_front.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector/db_index.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector/db_iterators_2.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector/db_iterators_3.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector/db_iterators_4.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector/db_iterators_5.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector/db_iterators_6.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector/db_iterators_7.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector/db_iterators_8.pass.cpp
libcxx/trunk/test/std/extensions/
libcxx/trunk/test/std/localization/locale.categories/__scan_keyword.pass.cpp

libcxx/trunk/test/std/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp

libcxx/trunk/test/std/localization/locales/locale/locale.types/locale.id/id.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp
Modified:

libcxx/trunk/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp


Re: [PATCH] D19703: [clang-tidy] Improve misc-redundant-expression and decrease false-positive

2016-04-28 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 55526.
etienneb added a comment.

adding unittests


http://reviews.llvm.org/D19703

Files:
  clang-tidy/misc/RedundantExpressionCheck.cpp
  docs/clang-tidy/checks/misc-redundant-expression.rst
  test/clang-tidy/misc-redundant-expression.cpp

Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -68,14 +68,14 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both side of operator are equivalent
 
   if (foo(0) - 2 < foo(0) - 2) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: both side of operator are equivalent  
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: both side of operator are equivalent
   if (foo(bar(0)) < (foo(bar((0) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both side of operator are equivalent  
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both side of operator are equivalent
 
   if (P1.x < P2.x && P1.x < P2.x) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both side of operator are equivalent  
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both side of operator are equivalent
   if (P2.a[P1.x + 2] < P2.x && P2.a[(P1.x) + (2)] < (P2.x)) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: both side of operator are equivalent  
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: both side of operator are equivalent
 
   return 0;
 }
@@ -100,13 +100,36 @@
   return 0;
 }
 
+int TestConditional(int x, int y) {
+  int k = 0;
+  k += (y < 0) ? x : x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: 'true' and 'false' expression are equivalent
+  k += (y < 0) ? x + 1 : x + 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: 'true' and 'false' expression are equivalent
+  return k;
+}
+
+struct MyStruct {
+  int x;
+} Q;
+bool operator==(const MyStruct& lhs, const MyStruct& rhs) { return lhs.x == rhs.x; }
+bool TestOperator(const MyStruct& S) {
+  if (S == Q) return false;
+  return S == S;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: both side of overloaded operator are equivalent
+}
+
 #define LT(x, y) (void)((x) < (y))
+#define COND(x, y, z) ((x)?(y):(z))
+#define EQUALS(x, y) (x) == (y)
 
 int TestMacro(int X, int Y) {
   LT(0, 0);
   LT(1, 0);
   LT(X, X);
   LT(X+1, X + 1);
+  COND(X < Y, X, X);
+  EQUALS(Q, Q);
 }
 
 int TestFalsePositive(int* A, int X, float F) {
@@ -118,3 +141,22 @@
   if (F != F && F == F) return 1;
   return 0;
 }
+
+int TestBannedMacros() {
+#define EAGAIN 3
+#define NOT_EAGAIN 3
+  if (EAGAIN == 0 | EAGAIN == 0) return 0;
+  if (NOT_EAGAIN == 0 | NOT_EAGAIN == 0) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: both side of operator are equivalent
+}
+
+struct MyClass {
+static const int Value = 42;
+};
+template 
+void TemplateCheck() {
+  static_assert(T::Value == U::Value, "should be identical");
+  static_assert(T::Value == T::Value, "should be identical");
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: both side of overloaded operator are equivalent
+}
+void TestTemplate() { TemplateCheck(); }
Index: docs/clang-tidy/checks/misc-redundant-expression.rst
===
--- docs/clang-tidy/checks/misc-redundant-expression.rst
+++ docs/clang-tidy/checks/misc-redundant-expression.rst
@@ -12,6 +12,7 @@
   * always be a constant (zero or one)
 
 Example:
+
 .. code:: c++
 
   ((x+1) | (x+1)) // (x+1) is redundant
Index: clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -11,14 +11,39 @@
 #include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
-static bool AreIdenticalExpr(const Expr *Left, const Expr *Right) {
+static const char KnownBannedMacroNames[] =
+"EAGAIN;EWOULDBLOCK;SIGCLD;SIGCHLD;";
+
+static const char MacroNamesDelimiter[] = ";";
+
+static void ParseMacroNames(StringRef Option,
+std::vector *Result) {
+  SmallVector Names;
+  Option.split(Names, MacroNamesDelimiter);
+  for (StringRef  : Names) {
+Name = Name.trim();
+if (!Name.empty())
+  Result->push_back(Name);
+  }
+}
+
+static bool AreEquivalentNameSpecifier(const NestedNameSpecifier *Left,
+   const NestedNameSpecifier *Right) {
+  llvm::FoldingSetNodeID LeftID, RightID;
+  Left->Profile(LeftID);
+  Right->Profile(RightID);
+  return LeftID == RightID;
+}
+
+static bool AreEquivalentExpr(const Expr *Left, const Expr *Right) {
   if (!Left || !Right)
 return !Left && !Right;
 
@@ -33,8 +58,8 @@
   

[PATCH] D19708: [CGDebugInfo] Generate debug info for member calls in the context of the callee expression

2016-04-28 Thread Hal Finkel via cfe-commits
hfinkel created this revision.
hfinkel added reviewers: rsmith, aprantl, dexonsmith, dblaikie, echristo.
hfinkel added a subscriber: cfe-commits.
Herald added subscribers: joker.eph, mcrosier.

We currently generate debug info for member calls in the context of the call 
expression. For member calls, this has an odd effect, which becomes especially 
obvious when generating source locations for optimizer-feedback remarks 
regarding inlining.

Given this:

  $ cat -n /tmp/i.cpp 
 1  void ext();
 2  
 3  struct Bar {
 4void bar() { ext(); }
 5  };
 6  
 7  struct Foo {
 8Bar *b;
 9  
10Bar *foo() { return b; }
11  };
12  
13  void test(Foo *f) {
14f->foo()->bar();
15  }

  $ clang -g /tmp/i.cpp -S -emit-llvm -o - 
  
  define void @_Z4testP3Foo(%struct.Foo* %f) #0 !dbg !6 {
...
%call = call %struct.Bar* @_ZN3Foo3fooEv(%struct.Foo* %0), !dbg !27
call void @_ZN3Bar3barEv(%struct.Bar* %call), !dbg !28
...
  !27 = !DILocation(line: 14, column: 3, scope: !6)
  !28 = !DILocation(line: 14, column: 3, scope: !29)

but we want instead for the calls to point to the callee expressions (foo() and 
bar() in this case). With this change, that's what happens.

Fixes PR27567.

http://reviews.llvm.org/D19708

Files:
  lib/CodeGen/CGExprCXX.cpp
  test/CodeGenCXX/debug-info-member-call.cpp

Index: test/CodeGenCXX/debug-info-member-call.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-member-call.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm 
-debug-info-kind=standalone -dwarf-column-info %s -o - | FileCheck %s
+void ext();
+
+struct Bar {
+  void bar() { ext(); }
+};
+
+struct Foo {
+  Bar *b;
+
+  Bar *foo() { return b; }
+};
+
+void test(Foo *f) {
+  f->foo()->bar();
+}
+
+// CHECK-LABEL: @_Z4testP3Foo
+// CHECK: call {{.*}} @_ZN3Foo3fooEv{{.*}}, !dbg ![[CALL1LOC:.*]]
+// CHECK: call void @_ZN3Bar3barEv{{.*}}, !dbg ![[CALL2LOC:.*]]
+
+// CHECK: ![[CALL1LOC]] = !DILocation(line: [[LINE:[0-9]+]], column: 6,
+// CHECK: ![[CALL2LOC]] = !DILocation(line: [[LINE]], column: 13,
+
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -107,6 +107,10 @@
   ReturnValueSlot ReturnValue) {
   const Expr *callee = CE->getCallee()->IgnoreParens();
 
+  // The debug information for the call instruction should point to the callee
+  // expression.
+  ApplyDebugLocation DL(*this, callee);
+
   if (isa(callee))
 return EmitCXXMemberPointerCallExpr(CE, ReturnValue);
 


Index: test/CodeGenCXX/debug-info-member-call.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-member-call.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm -debug-info-kind=standalone -dwarf-column-info %s -o - | FileCheck %s
+void ext();
+
+struct Bar {
+  void bar() { ext(); }
+};
+
+struct Foo {
+  Bar *b;
+
+  Bar *foo() { return b; }
+};
+
+void test(Foo *f) {
+  f->foo()->bar();
+}
+
+// CHECK-LABEL: @_Z4testP3Foo
+// CHECK: call {{.*}} @_ZN3Foo3fooEv{{.*}}, !dbg ![[CALL1LOC:.*]]
+// CHECK: call void @_ZN3Bar3barEv{{.*}}, !dbg ![[CALL2LOC:.*]]
+
+// CHECK: ![[CALL1LOC]] = !DILocation(line: [[LINE:[0-9]+]], column: 6,
+// CHECK: ![[CALL2LOC]] = !DILocation(line: [[LINE]], column: 13,
+
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -107,6 +107,10 @@
   ReturnValueSlot ReturnValue) {
   const Expr *callee = CE->getCallee()->IgnoreParens();
 
+  // The debug information for the call instruction should point to the callee
+  // expression.
+  ApplyDebugLocation DL(*this, callee);
+
   if (isa(callee))
 return EmitCXXMemberPointerCallExpr(CE, ReturnValue);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19175: Fix for PR27015 (variable template initialized with a generic lambda expression)

2016-04-28 Thread Richard Smith via cfe-commits
On Thu, Apr 28, 2016 at 7:34 PM, Akira Hatanaka via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> ahatanak added a comment.
>
> Thanks for the review. I committed the patch in r267956 and r267975.
>
> Do you think I should make setFlags(unsigned F) return early if F == Flags?


I don't think that should happen in practice, so it doesn't seem worth
checking.

Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D19175
>
>
>
> ___
> 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] D19175: Fix for PR27015 (variable template initialized with a generic lambda expression)

2016-04-28 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

Thanks for the review. I committed the patch in r267956 and r267975.

Do you think I should make setFlags(unsigned F) return early if F == Flags?


Repository:
  rL LLVM

http://reviews.llvm.org/D19175



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


r267975 - [Parser] Clear the TemplateParamScope bit of the current scope's flag

2016-04-28 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Apr 28 21:24:14 2016
New Revision: 267975

URL: http://llvm.org/viewvc/llvm-project?rev=267975=rev
Log:
[Parser] Clear the TemplateParamScope bit of the current scope's flag
if we are parsing a template specialization.

This commit makes changes to clear the TemplateParamScope bit and set
the TemplateParamParent field of the current scope to null if a template
specialization is being parsed.

Before this commit, Sema::ActOnStartOfLambdaDefinition would check
whether the parent template scope had any decls to determine whether
or not a template specialization was being parsed. This wasn't correct
since it couldn't distinguish between a real template specialization and
a template defintion with an unnamed template parameter (only template
parameters with names are added to the scope's decl list). To fix the
bug, this commit changes the code to check the pointer to the parent
template scope rather than the decl list.

rdar://problem/23440346

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

Modified:
cfe/trunk/include/clang/Sema/Scope.h
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Sema/Scope.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/test/CXX/drs/dr1xx.cpp
cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp

Modified: cfe/trunk/include/clang/Sema/Scope.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Scope.h?rev=267975=267974=267975=diff
==
--- cfe/trunk/include/clang/Sema/Scope.h (original)
+++ cfe/trunk/include/clang/Sema/Scope.h Thu Apr 28 21:24:14 2016
@@ -197,6 +197,8 @@ private:
   /// this scope, or over-defined. The bit is true when over-defined.
   llvm::PointerIntPair NRVO;
 
+  void setFlags(Scope *Parent, unsigned F);
+
 public:
   Scope(Scope *Parent, unsigned ScopeFlags, DiagnosticsEngine )
 : ErrorTrap(Diag) {
@@ -206,7 +208,7 @@ public:
   /// getFlags - Return the flags for this scope.
   ///
   unsigned getFlags() const { return Flags; }
-  void setFlags(unsigned F) { Flags = F; }
+  void setFlags(unsigned F) { setFlags(getParent(), F); }
 
   /// isBlockScope - Return true if this scope correspond to a closure.
   bool isBlockScope() const { return Flags & BlockScope; }

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=267975=267974=267975=diff
==
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Thu Apr 28 21:24:14 2016
@@ -147,6 +147,9 @@ Parser::ParseTemplateDeclarationOrSpecia
 }
   } while (Tok.isOneOf(tok::kw_export, tok::kw_template));
 
+  unsigned NewFlags = getCurScope()->getFlags() & ~Scope::TemplateParamScope;
+  ParseScopeFlags TemplateScopeFlags(this, NewFlags, isSpecialization);
+
   // Parse the actual template declaration.
   return ParseSingleDeclarationAfterTemplate(Context,
  ParsedTemplateInfo(,

Modified: cfe/trunk/lib/Sema/Scope.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Scope.cpp?rev=267975=267974=267975=diff
==
--- cfe/trunk/lib/Sema/Scope.cpp (original)
+++ cfe/trunk/lib/Sema/Scope.cpp Thu Apr 28 21:24:14 2016
@@ -18,7 +18,7 @@
 
 using namespace clang;
 
-void Scope::Init(Scope *parent, unsigned flags) {
+void Scope::setFlags(Scope *parent, unsigned flags) {
   AnyParent = parent;
   Flags = flags;
 
@@ -83,6 +83,10 @@ void Scope::Init(Scope *parent, unsigned
 else
   incrementMSManglingNumber();
   }
+}
+
+void Scope::Init(Scope *parent, unsigned flags) {
+  setFlags(parent, flags);
 
   DeclsInScope.clear();
   UsingDirectives.clear();

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=267975=267974=267975=diff
==
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Thu Apr 28 21:24:14 2016
@@ -814,9 +814,8 @@ void Sema::ActOnStartOfLambdaDefinition(
   // The lambda-expression's closure type might be dependent even if its
   // semantic context isn't, if it appears within a default argument of a
   // function template.
-  if (Scope *TmplScope = CurScope->getTemplateParamParent())
-if (!TmplScope->decl_empty())
-  KnownDependent = true;
+  if (CurScope->getTemplateParamParent())
+KnownDependent = true;
 
   // Determine the signature of the call operator.
   TypeSourceInfo *MethodTyInfo;

Modified: cfe/trunk/test/CXX/drs/dr1xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr1xx.cpp?rev=267975=267974=267975=diff

Re: [PATCH] D19175: Fix for PR27015 (variable template initialized with a generic lambda expression)

2016-04-28 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL267975: [Parser] Clear the TemplateParamScope bit of the 
current scope's flag (authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D19175?vs=55484=55523#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19175

Files:
  cfe/trunk/include/clang/Sema/Scope.h
  cfe/trunk/lib/Parse/ParseTemplate.cpp
  cfe/trunk/lib/Sema/Scope.cpp
  cfe/trunk/lib/Sema/SemaLambda.cpp
  cfe/trunk/test/CXX/drs/dr1xx.cpp
  cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp

Index: cfe/trunk/include/clang/Sema/Scope.h
===
--- cfe/trunk/include/clang/Sema/Scope.h
+++ cfe/trunk/include/clang/Sema/Scope.h
@@ -197,6 +197,8 @@
   /// this scope, or over-defined. The bit is true when over-defined.
   llvm::PointerIntPair NRVO;
 
+  void setFlags(Scope *Parent, unsigned F);
+
 public:
   Scope(Scope *Parent, unsigned ScopeFlags, DiagnosticsEngine )
 : ErrorTrap(Diag) {
@@ -206,7 +208,7 @@
   /// getFlags - Return the flags for this scope.
   ///
   unsigned getFlags() const { return Flags; }
-  void setFlags(unsigned F) { Flags = F; }
+  void setFlags(unsigned F) { setFlags(getParent(), F); }
 
   /// isBlockScope - Return true if this scope correspond to a closure.
   bool isBlockScope() const { return Flags & BlockScope; }
Index: cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp
===
--- cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp
+++ cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
 // expected-no-diagnostics
 
+template  auto fn0 = [] {};
+template  void foo0() { fn0(); }
+
 template auto fn1 = [](auto a) { return a + T(1); };
 
 template 
Index: cfe/trunk/test/CXX/drs/dr1xx.cpp
===
--- cfe/trunk/test/CXX/drs/dr1xx.cpp
+++ cfe/trunk/test/CXX/drs/dr1xx.cpp
@@ -902,7 +902,11 @@
 typedef int X;
   };
   template<> struct A {
+#if __cplusplus <= 199711
+typename B::X x; // expected-error {{'typename' occurs outside of a template}}
+#else
 typename B::X x;
+#endif
   };
 }
 
Index: cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
===
--- cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
+++ cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
@@ -195,7 +195,7 @@
 namespace default_args {
 #ifdef CPP11ONLY
 namespace lambdas {
-template //expected-error 2{{constant expression}} expected-note{{constant expression}}
+template //expected-error {{constant expression}}
 int f();
 }
 #endif // CPP11ONLY
Index: cfe/trunk/lib/Sema/SemaLambda.cpp
===
--- cfe/trunk/lib/Sema/SemaLambda.cpp
+++ cfe/trunk/lib/Sema/SemaLambda.cpp
@@ -814,9 +814,8 @@
   // The lambda-expression's closure type might be dependent even if its
   // semantic context isn't, if it appears within a default argument of a
   // function template.
-  if (Scope *TmplScope = CurScope->getTemplateParamParent())
-if (!TmplScope->decl_empty())
-  KnownDependent = true;
+  if (CurScope->getTemplateParamParent())
+KnownDependent = true;
 
   // Determine the signature of the call operator.
   TypeSourceInfo *MethodTyInfo;
Index: cfe/trunk/lib/Sema/Scope.cpp
===
--- cfe/trunk/lib/Sema/Scope.cpp
+++ cfe/trunk/lib/Sema/Scope.cpp
@@ -18,7 +18,7 @@
 
 using namespace clang;
 
-void Scope::Init(Scope *parent, unsigned flags) {
+void Scope::setFlags(Scope *parent, unsigned flags) {
   AnyParent = parent;
   Flags = flags;
 
@@ -83,6 +83,10 @@
 else
   incrementMSManglingNumber();
   }
+}
+
+void Scope::Init(Scope *parent, unsigned flags) {
+  setFlags(parent, flags);
 
   DeclsInScope.clear();
   UsingDirectives.clear();
Index: cfe/trunk/lib/Parse/ParseTemplate.cpp
===
--- cfe/trunk/lib/Parse/ParseTemplate.cpp
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp
@@ -147,6 +147,9 @@
 }
   } while (Tok.isOneOf(tok::kw_export, tok::kw_template));
 
+  unsigned NewFlags = getCurScope()->getFlags() & ~Scope::TemplateParamScope;
+  ParseScopeFlags TemplateScopeFlags(this, NewFlags, isSpecialization);
+
   // Parse the actual template declaration.
   return ParseSingleDeclarationAfterTemplate(Context,
  ParsedTemplateInfo(,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-04-28 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

In http://reviews.llvm.org/D19678#416039, @hfinkel wrote:

> In http://reviews.llvm.org/D19678#415902, @rsmith wrote:
>
> > You give this example:
> >
> > >   343 | Loc = ConvertBackendLocation(D, 
> > > Context->getSourceManager());
> >
> > >   I   |   ^
> >
> > >   I   | ^
> >
> >
> > How does this look for a case like `p->Foo()->Bar()` (where one or both of 
> > the calls are inlined)? Can we get the source location to point at the 
> > function name instead of the start of the expression to reduce the scope 
> > for ambiguity?
>
>
> That does not currently work very well (I assume this needs a backend fix, 
> but I'll check).


Actually, it's a Clang problem. https://llvm.org/bugs/show_bug.cgi?id=27567


http://reviews.llvm.org/D19678



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


Re: [PATCH] D18474: [OPENMP] Enable correct generation of runtime call when target directive is separated from teams directive by multiple curly brackets

2016-04-28 Thread Carlo Bertolli via cfe-commits
carlo.bertolli closed this revision.
carlo.bertolli marked an inline comment as done.
carlo.bertolli added a comment.

Committed revision 267972.


Repository:
  rL LLVM

http://reviews.llvm.org/D18474



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


r267972 - [OPENMP] Enable correct generation of runtime call when target directive is separated from teams directive by multiple curly brackets

2016-04-28 Thread Carlo Bertolli via cfe-commits
Author: cbertol
Date: Thu Apr 28 20:37:30 2016
New Revision: 267972

URL: http://llvm.org/viewvc/llvm-project?rev=267972=rev
Log:
[OPENMP] Enable correct generation of runtime call when target directive is 
separated from teams directive by multiple curly brackets

http://reviews.llvm.org/D18474

This patch fixes a bug in code generation of the correct OpenMP runtime library 
call in presence of target and teams, when target is separated by teams with 
multiple curly brackets. The current implementation will not be able to see the 
teams directive inside target and issue a call to tgt_target instead of the 
correct one tgt_target_teams.


Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/teams_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=267972=267971=267972=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Apr 28 20:37:30 2016
@@ -4556,6 +4556,14 @@ void CGOpenMPRuntime::emitTargetOutlined
   DeviceID, FileID, ParentName, Line, OutlinedFn, OutlinedFnID);
 }
 
+/// discard all CompoundStmts intervening between two constructs
+static const Stmt *ignoreCompoundStmts(const Stmt *Body) {
+  while (auto *CS = dyn_cast_or_null(Body))
+Body = CS->body_front();
+
+  return Body;
+}
+
 /// \brief Emit the num_teams clause of an enclosed teams directive at the
 /// target region scope. If there is no teams directive associated with the
 /// target directive, or if there is no num_teams clause associated with the
@@ -4586,7 +4594,8 @@ emitNumTeamsClauseForTargetDirective(CGO
 
   // FIXME: Accommodate other combined directives with teams when they become
   // available.
-  if (auto *TeamsDir = dyn_cast(CS.getCapturedStmt())) {
+  if (auto *TeamsDir = dyn_cast_or_null(
+  ignoreCompoundStmts(CS.getCapturedStmt( {
 if (auto *NTE = TeamsDir->getSingleClause()) {
   CGOpenMPInnerExprInfo CGInfo(CGF, CS);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );
@@ -4634,7 +4643,8 @@ emitThreadLimitClauseForTargetDirective(
 
   // FIXME: Accommodate other combined directives with teams when they become
   // available.
-  if (auto *TeamsDir = dyn_cast(CS.getCapturedStmt())) {
+  if (auto *TeamsDir = dyn_cast_or_null(
+  ignoreCompoundStmts(CS.getCapturedStmt( {
 if (auto *TLE = TeamsDir->getSingleClause()) {
   CGOpenMPInnerExprInfo CGInfo(CGF, CS);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );

Modified: cfe/trunk/test/OpenMP/teams_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_codegen.cpp?rev=267972=267971=267972=diff
==
--- cfe/trunk/test/OpenMP/teams_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_codegen.cpp Thu Apr 28 20:37:30 2016
@@ -29,6 +29,16 @@ int teams_argument_global_local(int a){
 ++comp;
   }
 
+  // CK1: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 1, i8** 
%{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* 
{{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 0)
+  // CK1: call void @{{.+}}(i{{64|32}} %{{.+}})
+  #pragma omp target
+  {{{
+#pragma omp teams
+{
+  ++comp;
+}
+  }}}
+
   // CK1-DAG: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 2, i8** 
%{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* 
{{.+}}@{{[^,]+}}, i32 0, i32 0), i32 [[NT:%[^,]+]], i32 0)
   // CK1-DAG: [[NT]] = load i32, i32* [[NTA:%[^,]+]],
 


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


RE: [PATCH] D19702: [libcxx] [test] Fix get_temp_file_name() to compile for Windows.

2016-04-28 Thread Stephan T. Lavavej via cfe-commits
[David Majnemer]
> Er, I don't think mingw provides _mktemp_s.

Yeah, I don't know what needs to be done for MinGW. (I avoided using _mktemp 
for MSVC because I knew it would complain about "security".)

I am pretty sure that this code was already broken for MinGW - I grepped and 
found no inclusions of windows.h throughout the tests, and I believe that 
MinGW's io.h and other CRT headers don't declare the windows.h GetTempPath/etc. 
machinery that this was trying to use.

[Eric Fiselier]
> I went back to the old method for MinGW in r267968 just to be safe. Thanks 
> for the input.

I should have done that in the first place to be non-intrusive. Sorry for the 
minor headache.

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


Re: [PATCH] D19623: [libcxx] [test] Initialize local doubles to NaN.

2016-04-28 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

*disclaimer* I have no idea what I'm talking about.

Is there any reason why using signalling NaN would be better than quiet NaN in 
this case?


http://reviews.llvm.org/D19623



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


Re: [PATCH] D19625: [libc++] Void-cast runtime-unused variables.

2016-04-28 Thread Eric Fiselier via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

One inline change requested.



Comment at: 
test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp:24421
@@ -24420,2 +24420,3 @@
 std::locale lc = std::locale::classic();
 std::locale lg(lc, new my_numpunct);
+((void)str); // Prevent unused warning

Isn't this unused as well on non-apple platforms?


Comment at: 
test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp:24422
@@ -24421,2 +24421,3 @@
 std::locale lg(lc, new my_numpunct);
+((void)str); // Prevent unused warning
 #ifdef __APPLE__

Move  `str` inside the `#ifdef __APPLE__` instead.


Comment at: test/std/numerics/rand/rand.device/eval.pass.cpp:33
@@ -32,3 +32,3 @@
 }
-catch (const std::system_error& e)
+catch (const std::system_error&)
 {

This looks OK, but I noticed that *technically* the spec only says the 
exception type is derived from `std::exception`.

However if we can keep testing this exception without bothering anybody I say 
we do.


http://reviews.llvm.org/D19625



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


Re: [PATCH] D19702: [libcxx] [test] Fix get_temp_file_name() to compile for Windows.

2016-04-28 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D19702#416314, @majnemer wrote:

> Er, I don't think mingw provides _mktemp_s.


I went back to the old method for MinGW in r267968 just to be safe. Thanks for 
the input.


http://reviews.llvm.org/D19702



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


[libcxx] r267968 - Fix possible test breakage for MinGW

2016-04-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Apr 28 20:22:16 2016
New Revision: 267968

URL: http://llvm.org/viewvc/llvm-project?rev=267968=rev
Log:
Fix possible test breakage for MinGW

Modified:
libcxx/trunk/test/support/platform_support.h

Modified: libcxx/trunk/test/support/platform_support.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/platform_support.h?rev=267968=267967=267968=diff
==
--- libcxx/trunk/test/support/platform_support.h (original)
+++ libcxx/trunk/test/support/platform_support.h Thu Apr 28 20:22:16 2016
@@ -67,16 +67,17 @@ extern "C" {
 
 #ifndef __CloudABI__
 inline
-std::string
-get_temp_file_name()
+std::string get_temp_file_name()
 {
-#if defined(_WIN32) || defined(__MINGW32__)
+#if defined(__MINGW32__)
+char Path[MAX_PATH + 1];
+char FN[MAX_PATH + 1];
+do { } while (0 == GetTempPath(MAX_PATH+1, Path));
+do { } while (0 == GetTempFileName(Path, "libcxx", 0, FN));
+return FN;
+#elif defined(_WIN32)
 char Name[] = "libcxx.XX";
-
-if (_mktemp_s(Name, sizeof(Name)) != 0) {
-abort();
-}
-
+if (_mktemp_s(Name, sizeof(Name)) != 0) abort();
 return Name;
 #else
 std::string Name;


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


Re: [PATCH] D19698: [libcxx] [test] Need to include for std::unique_ptr.

2016-04-28 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D19698#416315, @rsmith wrote:

> In http://reviews.llvm.org/D19698#416309, @EricWF wrote:
>
> > Most tests pretty much rely on  getting dragged in indirectly, 
> > same thing with  and the bits of  we actually define in 
> > .
>
>
> There are also a few symbols that libc++ defines in the wrong header and then 
> #includes into the right one. Any automated fix is going to mess up on those.


Ah, I stupidly assumed that the automatic fix would handle "std::" symbols 
based off of the spec and not the implementation.


http://reviews.llvm.org/D19698



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


Re: [PATCH] D19698: [libcxx] [test] Need to include for std::unique_ptr.

2016-04-28 Thread Richard Smith via cfe-commits
rsmith added a comment.

In http://reviews.llvm.org/D19698#416309, @EricWF wrote:

> Most tests pretty much rely on  getting dragged in indirectly, 
> same thing with  and the bits of  we actually define in 
> .


There are also a few symbols that libc++ defines in the wrong header and then 
#includes into the right one. Any automated fix is going to mess up on those.


http://reviews.llvm.org/D19698



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


Re: [PATCH] D19702: [libcxx] [test] Fix get_temp_file_name() to compile for Windows.

2016-04-28 Thread David Majnemer via cfe-commits
Er, I don't think mingw provides _mktemp_s.

On Thu, Apr 28, 2016 at 5:57 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> EricWF closed this revision.
> EricWF added a comment.
>
> r267963.
>
>
> http://reviews.llvm.org/D19702
>
>
>
> ___
> 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] D19698: [libcxx] [test] Need to include for std::unique_ptr.

2016-04-28 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

> I was hoping that maybe "Include What You Use" had a fix-it mode. I'll look 
> into this further tonight.


It has fix_includes.py script, but I encountered quite a lot of false 
positives, so I prefer to fix problems manually.


http://reviews.llvm.org/D19698



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


Re: [PATCH] D19625: [libc++] Void-cast runtime-unused variables.

2016-04-28 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT added a comment.

Are there any issues with these changes? I tried to follow the existing 
practice for void-casting, including the comment (although the comments varied).


http://reviews.llvm.org/D19625



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


Re: [PATCH] D19698: [libcxx] [test] Need to include for std::unique_ptr.

2016-04-28 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D19698#416306, @rsmith wrote:

> In http://reviews.llvm.org/D19698#416255, @Eugene.Zelenko wrote:
>
> > It'll be good idea to run Include What You Use 
> >  to make sure 
> > that all dependencies are explicit.
>
>
> You can also remove all the `export *`s from the module map and try running 
> the testsuite with modules enabled for a nasty shock about how common this 
> problem is...


Most tests pretty much rely on  getting dragged in indirectly, 
same thing with  and the bits of  we actually define in 
.

I was hoping that maybe "Include What You Use" had a fix-it mode. I'll look 
into this further tonight.


http://reviews.llvm.org/D19698



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


RE: [PATCH] D19700: [libcxx] [test] nasty_mutex::operator& should return nullptr, like nasty_list above it.

2016-04-28 Thread Stephan T. Lavavej via cfe-commits
[Eric Fiselier] 
> Well arguable it should be `no return` or even better it should
> have an "= delete" so it's diagnosed even if it's not called.
> For now this works though.

Agreed - I just wasn't sure what this code was trying to do, and I figured it 
should be consistent. I'm trying to keep my patches minimally intrusive until I 
understand your tests better.

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


Re: [PATCH] D19698: [libcxx] [test] Need to include for std::unique_ptr.

2016-04-28 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.
rsmith added a comment.

In http://reviews.llvm.org/D19698#416255, @Eugene.Zelenko wrote:

> It'll be good idea to run Include What You Use 
>  to make sure 
> that all dependencies are explicit.


You can also remove all the `export *`s from the module map and try running the 
testsuite with modules enabled for a nasty shock about how common this problem 
is...


http://reviews.llvm.org/D19698



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


Re: [PATCH] D19702: [libcxx] [test] Fix get_temp_file_name() to compile for Windows.

2016-04-28 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r267963.


http://reviews.llvm.org/D19702



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


Re: [PATCH] D19702: [libcxx] [test] Fix get_temp_file_name() to compile for Windows.

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

LGTM but I don't know much about Windows or MinGW.


http://reviews.llvm.org/D19702



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


Re: [PATCH] D19701: [libcxx] [test] Remove more names of unreferenced parameters.

2016-04-28 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r267962.


http://reviews.llvm.org/D19701



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


[libcxx] r267962 - Remove more names of unreferenced parameters. Patch from s...@microsoft.com

2016-04-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Apr 28 19:47:16 2016
New Revision: 267962

URL: http://llvm.org/viewvc/llvm-project?rev=267962=rev
Log:
Remove more names of unreferenced parameters. Patch from s...@microsoft.com

Modified:

libcxx/trunk/test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp

libcxx/trunk/test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp

Modified: 
libcxx/trunk/test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp?rev=267962=267961=267962=diff
==
--- 
libcxx/trunk/test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
 Thu Apr 28 19:47:16 2016
@@ -41,17 +41,17 @@ bool g1_called = false;
 bool g2_called = false;
 bool g3_called = false;
 
-void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+void f1(std::ios_base::event, std::ios_base&, int)
 {
 f1_called = true;
 }
 
-void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+void f2(std::ios_base::event, std::ios_base&, int)
 {
 f2_called = true;
 }
 
-void g1(std::ios_base::event ev, std::ios_base& stream, int index)
+void g1(std::ios_base::event ev, std::ios_base&, int index)
 {
 if (ev == std::ios_base::imbue_event)
 {
@@ -60,7 +60,7 @@ void g1(std::ios_base::event ev, std::io
 }
 }
 
-void g2(std::ios_base::event ev, std::ios_base& stream, int index)
+void g2(std::ios_base::event ev, std::ios_base&, int index)
 {
 if (ev == std::ios_base::imbue_event)
 {
@@ -69,7 +69,7 @@ void g2(std::ios_base::event ev, std::io
 }
 }
 
-void g3(std::ios_base::event ev, std::ios_base& stream, int index)
+void g3(std::ios_base::event ev, std::ios_base&, int index)
 {
 if (ev == std::ios_base::imbue_event)
 {

Modified: 
libcxx/trunk/test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp?rev=267962=267961=267962=diff
==
--- 
libcxx/trunk/test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
 Thu Apr 28 19:47:16 2016
@@ -41,31 +41,31 @@ bool g1_called = false;
 bool g2_called = false;
 bool g3_called = false;
 
-void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+void f1(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 4);
 f1_called = true;
 }
 
-void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+void f2(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 5);
 f2_called = true;
 }
 
-void g1(std::ios_base::event ev, std::ios_base& stream, int index)
+void g1(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 7);
 g1_called = true;
 }
 
-void g2(std::ios_base::event ev, std::ios_base& stream, int index)
+void g2(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 8);
 g2_called = true;
 }
 
-void g3(std::ios_base::event ev, std::ios_base& stream, int index)
+void g3(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 9);
 g3_called = true;


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


Re: [PATCH] D19700: [libcxx] [test] nasty_mutex::operator& should return nullptr, like nasty_list above it.

2016-04-28 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r267961.


http://reviews.llvm.org/D19700



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


Re: [PATCH] D19700: [libcxx] [test] nasty_mutex::operator& should return nullptr, like nasty_list above it.

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

Well arguable it should be `no return` or even better it should have an "= 
delete" so it's diagnosed even if it's not called.

For now this works though.


http://reviews.llvm.org/D19700



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


[libcxx] r267961 - Add a return value for nasty_mutex::operator&. Patch from s...@microsoft.com

2016-04-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Apr 28 19:45:46 2016
New Revision: 267961

URL: http://llvm.org/viewvc/llvm-project?rev=267961=rev
Log:
Add a return value for nasty_mutex::operator&. Patch from s...@microsoft.com

Modified:
libcxx/trunk/test/support/nasty_containers.hpp

Modified: libcxx/trunk/test/support/nasty_containers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/nasty_containers.hpp?rev=267961=267960=267961=diff
==
--- libcxx/trunk/test/support/nasty_containers.hpp (original)
+++ libcxx/trunk/test/support/nasty_containers.hpp Thu Apr 28 19:45:46 2016
@@ -287,7 +287,7 @@ public:
  nasty_mutex() _NOEXCEPT {}
  ~nasty_mutex() {}
 
-   nasty_mutex *operator& ()   { assert(false); }
+   nasty_mutex *operator& ()   { assert(false); return nullptr; }
template 
void operator, (const T &) { assert(false); }
 


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


Re: [PATCH] D19699: [libcxx] [test] Need to include for its streaming operators.

2016-04-28 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r267959.


http://reviews.llvm.org/D19699



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


[libcxx] r267959 - Add include for streaming operators. Patch from s...@microsoft.com

2016-04-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Apr 28 19:39:40 2016
New Revision: 267959

URL: http://llvm.org/viewvc/llvm-project?rev=267959=rev
Log:
Add  include for streaming operators. Patch from s...@microsoft.com

Modified:

libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp

libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp

libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp

libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp

libcxx/trunk/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp

libcxx/trunk/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp

libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp

libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp

Modified: 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp?rev=267959=267958=267959=diff
==
--- 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp
 Thu Apr 28 19:39:40 2016
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {

Modified: 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp?rev=267959=267958=267959=diff
==
--- 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp
 Thu Apr 28 19:39:40 2016
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {

Modified: 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp?rev=267959=267958=267959=diff
==
--- 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp
 Thu Apr 28 19:39:40 2016
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {

Modified: 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp?rev=267959=267958=267959=diff
==
--- 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp
 Thu Apr 28 19:39:40 2016
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {

Modified: 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp?rev=267959=267958=267959=diff
==
--- 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp
 Thu Apr 28 19:39:40 2016
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {

Modified: 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp?rev=267959=267958=267959=diff
==
--- 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
 (original)
+++ 

r267957 - Avoid -Wshadow warnings about constructor parameters named after fields

2016-04-28 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Apr 28 19:37:43 2016
New Revision: 267957

URL: http://llvm.org/viewvc/llvm-project?rev=267957=rev
Log:
Avoid -Wshadow warnings about constructor parameters named after fields

Usually these parameters are used solely to initialize the field in the
initializer list, and there is no real shadowing confusion.

There is a new warning under -Wshadow called
-Wshadow-field-in-constructor-modified. It attempts to find
modifications of such constructor parameters that probably intended to
modify the field.

It has some false negatives, though, so there is another warning group,
-Wshadow-field-in-constructor, which always warns on this special case.
For users who just want the old behavior and don't care about these fine
grained groups, we have a new warning group called -Wshadow-all that
activates everything.

Fixes PR16088.

Reviewers: rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/warn-shadow.cpp

Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=267957=267956=267957=diff
==
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Thu Apr 28 19:37:43 2016
@@ -1072,10 +1072,10 @@ inline const DiagnosticBuilder 
 // so that we only match those arguments that are (statically) DeclContexts;
 // other arguments that derive from DeclContext (e.g., RecordDecls) will not
 // match.
-template
-inline
-typename std::enable_if::value,
-const DiagnosticBuilder &>::type
+template 
+inline typename std::enable_if<
+std::is_same::type, DeclContext>::value,
+const DiagnosticBuilder &>::type
 operator<<(const DiagnosticBuilder , T *DC) {
   DB.AddTaggedVal(reinterpret_cast(DC),
   DiagnosticsEngine::ak_declcontext);

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=267957=267956=267957=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Apr 28 19:37:43 2016
@@ -337,7 +337,16 @@ def SelfMove : DiagGroup<"self-move">;
 def SemiBeforeMethodBody : DiagGroup<"semicolon-before-method-body">;
 def Sentinel : DiagGroup<"sentinel">;
 def MissingMethodReturnType : DiagGroup<"missing-method-return-type">;
-def Shadow : DiagGroup<"shadow">;
+
+def ShadowFieldInConstructorModified : 
DiagGroup<"shadow-field-in-constructor-modified">;
+def ShadowFieldInConstructor : DiagGroup<"shadow-field-in-constructor",
+ [ShadowFieldInConstructorModified]>;
+
+// -Wshadow-all is a catch-all for all shadowing. -Wshadow is just the
+// shadowing that we think is unsafe.
+def Shadow : DiagGroup<"shadow", [ShadowFieldInConstructorModified]>;
+def ShadowAll : DiagGroup<"shadow-all", [Shadow, ShadowFieldInConstructor]>;
+
 def Shorten64To32 : DiagGroup<"shorten-64-to-32">;
 def : DiagGroup<"sign-promo">;
 def SignCompare : DiagGroup<"sign-compare">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=267957=267956=267957=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Apr 28 19:37:43 
2016
@@ -352,6 +352,14 @@ def warn_decl_shadow :
   "static data member of %2|"
   "field of %2}1">,
   InGroup, DefaultIgnore;
+def warn_ctor_parm_shadows_field:
+  Warning<"constructor parameter %0 shadows the field %1 of %2">,
+  InGroup, DefaultIgnore;
+def warn_modifying_shadowing_decl :
+  Warning<"modifying constructor parameter %0 that shadows a "
+  "field of %1">,
+  InGroup, DefaultIgnore;
+
 
 // C++ using declarations
 def err_using_requires_qualname : Error<
@@ -1667,7 +1675,7 @@ def warn_maybe_uninit_var : Warning<
   "variable %0 may be uninitialized when "
   "%select{used here|captured by block}1">,
   InGroup, DefaultIgnore;
-def note_uninit_var_def : Note<"variable %0 is declared here">;
+def note_var_declared_here : Note<"variable %0 is declared here">;
 def note_uninit_var_use : Note<
   "%select{uninitialized use occurs|variable is captured by block}0 here">;
 def 

Re: [PATCH] D19698: [libcxx] [test] Need to include for std::unique_ptr.

2016-04-28 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r267958.


http://reviews.llvm.org/D19698



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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-04-28 Thread Reid Kleckner via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL267957: Avoid -Wshadow warnings about constructor parameters 
named after fields (authored by rnk).

Changed prior to commit:
  http://reviews.llvm.org/D18271?vs=55359=55515#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18271

Files:
  cfe/trunk/include/clang/Basic/Diagnostic.h
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/SemaCXX/warn-shadow.cpp

Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -1609,9 +1609,19 @@
 // If this was a forward reference to a label, verify it was defined.
 if (LabelDecl *LD = dyn_cast(D))
   CheckPoppedLabel(LD, *this);
-
-// Remove this name from our lexical scope.
+
+// Remove this name from our lexical scope, and warn on it if we haven't
+// already.
 IdResolver.RemoveDecl(D);
+auto ShadowI = ShadowingDecls.find(D);
+if (ShadowI != ShadowingDecls.end()) {
+  if (const auto *FD = dyn_cast(ShadowI->second)) {
+Diag(D->getLocation(), diag::warn_ctor_parm_shadows_field)
+<< D << FD << FD->getParent();
+Diag(FD->getLocation(), diag::note_previous_declaration);
+  }
+  ShadowingDecls.erase(ShadowI);
+}
   }
 }
 
@@ -6382,6 +6392,17 @@
   return NewVD;
 }
 
+/// Enum describing the %select options in diag::warn_decl_shadow.
+enum ShadowedDeclKind { SDK_Local, SDK_Global, SDK_StaticMember, SDK_Field };
+
+/// Determine what kind of declaration we're shadowing.
+static ShadowedDeclKind computeShadowedDeclKind(const NamedDecl *ShadowedDecl,
+const DeclContext *OldDC) {
+  if (isa(OldDC))
+return isa(ShadowedDecl) ? SDK_Field : SDK_StaticMember;
+  return OldDC->isFileContext() ? SDK_Global : SDK_Local;
+}
+
 /// \brief Diagnose variable or built-in function shadowing.  Implements
 /// -Wshadow.
 ///
@@ -6410,12 +6431,23 @@
   if (!isa(ShadowedDecl) && !isa(ShadowedDecl))
 return;
 
-  // Fields are not shadowed by variables in C++ static methods.
-  if (isa(ShadowedDecl))
+  if (FieldDecl *FD = dyn_cast(ShadowedDecl)) {
+// Fields are not shadowed by variables in C++ static methods.
 if (CXXMethodDecl *MD = dyn_cast(NewDC))
   if (MD->isStatic())
 return;
 
+// Fields shadowed by constructor parameters are a special case. Usually
+// the constructor initializes the field with the parameter.
+if (isa(NewDC) && isa(D)) {
+  // Remember that this was shadowed so we can either warn about its
+  // modification or its existence depending on warning settings.
+  D = D->getCanonicalDecl();
+  ShadowingDecls.insert({D, FD});
+  return;
+}
+  }
+
   if (VarDecl *shadowedVar = dyn_cast(ShadowedDecl))
 if (shadowedVar->isExternC()) {
   // For shadowing external vars, make sure that we point to the global
@@ -6443,27 +6475,13 @@
 // shadowing context, but that's just a false negative.
   }
 
-  // Determine what kind of declaration we're shadowing.
-
-  // The order must be consistent with the %select in the warning message.
-  enum ShadowedDeclKind { Local, Global, StaticMember, Field };
-  ShadowedDeclKind Kind;
-  if (isa(OldDC)) {
-if (isa(ShadowedDecl))
-  Kind = Field;
-else
-  Kind = StaticMember;
-  } else if (OldDC->isFileContext()) {
-Kind = Global;
-  } else {
-Kind = Local;
-  }
 
   DeclarationName Name = R.getLookupName();
 
   // Emit warning and note.
   if (getSourceManager().isInSystemMacro(R.getNameLoc()))
 return;
+  ShadowedDeclKind Kind = computeShadowedDeclKind(ShadowedDecl, OldDC);
   Diag(R.getNameLoc(), diag::warn_decl_shadow) << Name << Kind << OldDC;
   Diag(ShadowedDecl->getLocation(), diag::note_previous_declaration);
 }
@@ -6479,6 +6497,30 @@
   CheckShadow(S, D, R);
 }
 
+/// Check if 'E', which is an expression that is about to be modified, refers
+/// to a constructor parameter that shadows a field.
+void Sema::CheckShadowingDeclModification(Expr *E, SourceLocation Loc) {
+  // Quickly ignore expressions that can't be shadowing ctor parameters.
+  if (!getLangOpts().CPlusPlus || ShadowingDecls.empty())
+return;
+  E = E->IgnoreParenImpCasts();
+  auto *DRE = dyn_cast(E);
+  if (!DRE)
+return;
+  const NamedDecl *D = cast(DRE->getDecl()->getCanonicalDecl());
+  auto I = ShadowingDecls.find(D);
+  if (I == ShadowingDecls.end())
+return;
+  const NamedDecl *ShadowedDecl = I->second;
+  const DeclContext *OldDC = ShadowedDecl->getDeclContext();
+  Diag(Loc, diag::warn_modifying_shadowing_decl) << D << OldDC;
+  Diag(D->getLocation(), diag::note_var_declared_here) << 

[libcxx] r267958 - Add proper include for unique_ptr. Patch from s...@microsoft.com

2016-04-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Apr 28 19:37:56 2016
New Revision: 267958

URL: http://llvm.org/viewvc/llvm-project?rev=267958=rev
Log:
Add proper include for unique_ptr. Patch from s...@microsoft.com

Modified:
libcxx/trunk/test/std/utilities/meta/meta.rel/is_callable.pass.cpp

Modified: libcxx/trunk/test/std/utilities/meta/meta.rel/is_callable.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.rel/is_callable.pass.cpp?rev=267958=267957=267958=diff
==
--- libcxx/trunk/test/std/utilities/meta/meta.rel/is_callable.pass.cpp 
(original)
+++ libcxx/trunk/test/std/utilities/meta/meta.rel/is_callable.pass.cpp Thu Apr 
28 19:37:56 2016
@@ -18,6 +18,7 @@
 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 


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


Re: [PATCH] D19698: [libcxx] [test] Need to include for std::unique_ptr.

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

Woops. My bad.


http://reviews.llvm.org/D19698



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


Re: [PATCH] D19703: [clang-tidy] Improve misc-redundant-expression and decrease false-positive

2016-04-28 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 55514.
etienneb added a comment.

nit


http://reviews.llvm.org/D19703

Files:
  clang-tidy/misc/RedundantExpressionCheck.cpp
  docs/clang-tidy/checks/misc-redundant-expression.rst
  test/clang-tidy/misc-redundant-expression.cpp

Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -68,14 +68,14 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both side of operator are equivalent
 
   if (foo(0) - 2 < foo(0) - 2) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: both side of operator are equivalent  
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: both side of operator are equivalent
   if (foo(bar(0)) < (foo(bar((0) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both side of operator are equivalent  
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both side of operator are equivalent
 
   if (P1.x < P2.x && P1.x < P2.x) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both side of operator are equivalent  
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both side of operator are equivalent
   if (P2.a[P1.x + 2] < P2.x && P2.a[(P1.x) + (2)] < (P2.x)) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: both side of operator are equivalent  
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: both side of operator are equivalent
 
   return 0;
 }
@@ -118,3 +118,22 @@
   if (F != F && F == F) return 1;
   return 0;
 }
+
+int TestBannedMacros() {
+#define EAGAIN 3
+#define NOT_EAGAIN 3
+  if (EAGAIN == 0 | EAGAIN == 0) return 0;
+  if (NOT_EAGAIN == 0 | NOT_EAGAIN == 0) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: both side of operator are equivalent
+}
+
+struct MyClass {
+static const int Value = 42;
+};
+template 
+void TemplateCheck() {
+  static_assert(T::Value == U::Value, "should be identical");
+  static_assert(T::Value == T::Value, "should be identical");
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: both side of operator are equivalent
+}
+void TestTemplate() { TemplateCheck(); }
Index: docs/clang-tidy/checks/misc-redundant-expression.rst
===
--- docs/clang-tidy/checks/misc-redundant-expression.rst
+++ docs/clang-tidy/checks/misc-redundant-expression.rst
@@ -12,6 +12,7 @@
   * always be a constant (zero or one)
 
 Example:
+
 .. code:: c++
 
   ((x+1) | (x+1)) // (x+1) is redundant
Index: clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -11,14 +11,39 @@
 #include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
-static bool AreIdenticalExpr(const Expr *Left, const Expr *Right) {
+static const char KnownBannedMacroNames[] =
+"EAGAIN;EWOULDBLOCK;SIGCLD;SIGCHLD;";
+
+static const char MacroNamesDelimiter[] = ";";
+
+static void ParseMacroNames(StringRef Option,
+std::vector *Result) {
+  SmallVector Names;
+  Option.split(Names, MacroNamesDelimiter);
+  for (StringRef  : Names) {
+Name = Name.trim();
+if (!Name.empty())
+  Result->push_back(Name);
+  }
+}
+
+static bool AreEquivalentNameSpecifier(const NestedNameSpecifier *Left,
+   const NestedNameSpecifier *Right) {
+  llvm::FoldingSetNodeID LeftID, RightID;
+  Left->Profile(LeftID);
+  Right->Profile(RightID);
+  return LeftID == RightID;
+}
+
+static bool AreEquivalentExpr(const Expr *Left, const Expr *Right) {
   if (!Left || !Right)
 return !Left && !Right;
 
@@ -33,8 +58,8 @@
   Expr::const_child_iterator LeftIter = Left->child_begin();
   Expr::const_child_iterator RightIter = Right->child_begin();
   while (LeftIter != Left->child_end() && RightIter != Right->child_end()) {
-if (!AreIdenticalExpr(dyn_cast(*LeftIter),
-  dyn_cast(*RightIter)))
+if (!AreEquivalentExpr(dyn_cast(*LeftIter),
+   dyn_cast(*RightIter)))
   return false;
 ++LeftIter;
 ++RightIter;
@@ -53,15 +78,23 @@
   case Stmt::IntegerLiteralClass: {
 llvm::APInt LeftLit = cast(Left)->getValue();
 llvm::APInt RightLit = cast(Right)->getValue();
-return LeftLit.getBitWidth() == RightLit.getBitWidth() && LeftLit == RightLit;
+return LeftLit.getBitWidth() == RightLit.getBitWidth() &&
+   LeftLit == RightLit;
   }
   case Stmt::FloatingLiteralClass:
 return cast(Left)->getValue().bitwiseIsEqual(
 cast(Right)->getValue());
   case Stmt::StringLiteralClass:
 return cast(Left)->getBytes() ==
 

Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-04-28 Thread Adam Nemet via cfe-commits
anemet added inline comments.


Comment at: lib/CodeGen/CodeGenAction.cpp:734-737
@@ +733,6 @@
+
+  OS << llvm::format_decimal(L + 1, LNDigits) << " ";
+  OS << (LLI.Inlined.Transformed && InlinedCols < 2 ? "I" : " ");
+  OS << (LLI.Unrolled.Transformed && UnrolledCols < 2 ? "U" : " ");
+  OS << (LLI.Vectorized.Transformed && VectorizedCols < 2 ? "V" : " ");
+

Should the abbreviation be somehow part of the optimization remark API and 
passed in just like the pass name?

It would be nice if someone added optimization remark for a new opt, it would 
show up here automatically.  I could see how that could make the output too 
busy but at least have the option?



http://reviews.llvm.org/D19678



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


[PATCH] D19703: [clang-tidy] Improve misc-redundant-expression and decrease false-positive

2016-04-28 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

This patch is adding support for conditional expression and overloaded 
operators.

To decrease false-positive, this patch is adding a list of banned macro names 
that
has multiple variant with same integer value.

Also fixed support for template instantiation and added an unittest.

http://reviews.llvm.org/D19703

Files:
  clang-tidy/misc/RedundantExpressionCheck.cpp
  docs/clang-tidy/checks/misc-redundant-expression.rst
  test/clang-tidy/misc-redundant-expression.cpp

Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -68,14 +68,14 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both side of operator are equivalent
 
   if (foo(0) - 2 < foo(0) - 2) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: both side of operator are equivalent  
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: both side of operator are equivalent
   if (foo(bar(0)) < (foo(bar((0) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both side of operator are equivalent  
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both side of operator are equivalent
 
   if (P1.x < P2.x && P1.x < P2.x) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both side of operator are equivalent  
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both side of operator are equivalent
   if (P2.a[P1.x + 2] < P2.x && P2.a[(P1.x) + (2)] < (P2.x)) return 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: both side of operator are equivalent  
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: both side of operator are equivalent
 
   return 0;
 }
@@ -118,3 +118,22 @@
   if (F != F && F == F) return 1;
   return 0;
 }
+
+int TestBannedMacros() {
+#define EAGAIN 3
+#define NOT_EAGAIN 3
+  if (EAGAIN == 0 | EAGAIN == 0) return 0;
+  if (NOT_EAGAIN == 0 | NOT_EAGAIN == 0) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: both side of operator are equivalent
+}
+
+struct MyClass {
+static const int Value = 42;
+};
+template 
+void TemplateCheck() {
+  static_assert(T::Value == U::Value, "should be identical");
+  static_assert(T::Value == T::Value, "should be identical");
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: both side of operator are equivalent
+}
+void TestTemplate() { TemplateCheck(); }
Index: docs/clang-tidy/checks/misc-redundant-expression.rst
===
--- docs/clang-tidy/checks/misc-redundant-expression.rst
+++ docs/clang-tidy/checks/misc-redundant-expression.rst
@@ -12,6 +12,7 @@
   * always be a constant (zero or one)
 
 Example:
+
 .. code:: c++
 
   ((x+1) | (x+1)) // (x+1) is redundant
Index: clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -11,14 +11,39 @@
 #include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
-static bool AreIdenticalExpr(const Expr *Left, const Expr *Right) {
+static const char KnownBannedMacroNames[] =
+"EAGAIN;EWOULDBLOCK;SIGCLD;SIGCHLD;";
+
+static const char MacroNamesDelimiter[] = ";";
+
+static void ParseMacroNames(StringRef Option,
+std::vector *Result) {
+  SmallVector Names;
+  Option.split(Names, MacroNamesDelimiter);
+  for (StringRef  : Names) {
+Name = Name.trim();
+if (!Name.empty())
+  Result->push_back(Name);
+  }
+}
+
+static bool AreEquivalentNameSpecifier(const NestedNameSpecifier *Left,
+   NestedNameSpecifier *Right) {
+  llvm::FoldingSetNodeID LeftID, RightID;
+  Left->Profile(LeftID);
+  Right->Profile(RightID);
+  return LeftID == RightID;
+}
+
+static bool AreEquivalentExpr(const Expr *Left, const Expr *Right) {
   if (!Left || !Right)
 return !Left && !Right;
 
@@ -33,8 +58,8 @@
   Expr::const_child_iterator LeftIter = Left->child_begin();
   Expr::const_child_iterator RightIter = Right->child_begin();
   while (LeftIter != Left->child_end() && RightIter != Right->child_end()) {
-if (!AreIdenticalExpr(dyn_cast(*LeftIter),
-  dyn_cast(*RightIter)))
+if (!AreEquivalentExpr(dyn_cast(*LeftIter),
+   dyn_cast(*RightIter)))
   return false;
 ++LeftIter;
 ++RightIter;
@@ -53,15 +78,23 @@
   case Stmt::IntegerLiteralClass: {
 llvm::APInt LeftLit = cast(Left)->getValue();
 llvm::APInt RightLit = cast(Right)->getValue();
-return LeftLit.getBitWidth() == RightLit.getBitWidth() && LeftLit == 

Re: [PATCH] D19698: [libcxx] [test] Need to include for std::unique_ptr.

2016-04-28 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

It'll be good idea to run Include What You Use 
 to make sure 
that all dependencies are explicit.


http://reviews.llvm.org/D19698



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


[PATCH] D19702: [libcxx] [test] Fix get_temp_file_name() to compile for Windows.

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

[libcxx] [test] Fix get_temp_file_name() to compile for Windows.

It was including  but attempting to use GetTempPath() and 
GetTempFileName(), which are provided by .

Instead of dragging in  (which is large), we can use _mktemp_s() 
from .

Fixes MSVC errors:
"error C2065: 'MAX_PATH': undeclared identifier"
"error C3861: 'GetTempPath': identifier not found"
"error C3861: 'GetTempFileName': identifier not found"

http://reviews.llvm.org/D19702

Files:
  test/support/platform_support.h

Index: test/support/platform_support.h
===
--- test/support/platform_support.h
+++ test/support/platform_support.h
@@ -53,7 +53,7 @@
 #include 
 #include 
 #if defined(_WIN32) || defined(__MINGW32__)
-#include  // _mktemp
+#include  // _mktemp_s
 #else
 #include  // close
 #endif
@@ -71,11 +71,13 @@
 get_temp_file_name()
 {
 #if defined(_WIN32) || defined(__MINGW32__)
-char Path[MAX_PATH+1];
-char FN[MAX_PATH+1];
-do { } while (0 == GetTempPath(MAX_PATH+1, Path));
-do { } while (0 == GetTempFileName(Path, "libcxx", 0, FN));
-return FN;
+char Name[] = "libcxx.XX";
+
+if (_mktemp_s(Name, sizeof(Name)) != 0) {
+abort();
+}
+
+return Name;
 #else
 std::string Name;
 int FD = -1;


Index: test/support/platform_support.h
===
--- test/support/platform_support.h
+++ test/support/platform_support.h
@@ -53,7 +53,7 @@
 #include 
 #include 
 #if defined(_WIN32) || defined(__MINGW32__)
-#include  // _mktemp
+#include  // _mktemp_s
 #else
 #include  // close
 #endif
@@ -71,11 +71,13 @@
 get_temp_file_name()
 {
 #if defined(_WIN32) || defined(__MINGW32__)
-char Path[MAX_PATH+1];
-char FN[MAX_PATH+1];
-do { } while (0 == GetTempPath(MAX_PATH+1, Path));
-do { } while (0 == GetTempFileName(Path, "libcxx", 0, FN));
-return FN;
+char Name[] = "libcxx.XX";
+
+if (_mktemp_s(Name, sizeof(Name)) != 0) {
+abort();
+}
+
+return Name;
 #else
 std::string Name;
 int FD = -1;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19701: [libcxx] [test] Remove more names of unreferenced parameters.

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

[libcxx] [test] Remove more names of unreferenced parameters.

Fixes MSVC "warning C4100: unreferenced formal parameter".

http://reviews.llvm.org/D19701

Files:
  test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
  test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp

Index: test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
+++ test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
@@ -41,31 +41,31 @@
 bool g2_called = false;
 bool g3_called = false;
 
-void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+void f1(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 4);
 f1_called = true;
 }
 
-void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+void f2(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 5);
 f2_called = true;
 }
 
-void g1(std::ios_base::event ev, std::ios_base& stream, int index)
+void g1(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 7);
 g1_called = true;
 }
 
-void g2(std::ios_base::event ev, std::ios_base& stream, int index)
+void g2(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 8);
 g2_called = true;
 }
 
-void g3(std::ios_base::event ev, std::ios_base& stream, int index)
+void g3(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 9);
 g3_called = true;
Index: test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
+++ test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
@@ -41,35 +41,35 @@
 bool g2_called = false;
 bool g3_called = false;
 
-void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+void f1(std::ios_base::event, std::ios_base&, int)
 {
 f1_called = true;
 }
 
-void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+void f2(std::ios_base::event, std::ios_base&, int)
 {
 f2_called = true;
 }
 
-void g1(std::ios_base::event ev, std::ios_base& stream, int index)
+void g1(std::ios_base::event ev, std::ios_base&, int index)
 {
 if (ev == std::ios_base::imbue_event)
 {
 assert(index == 7);
 g1_called = true;
 }
 }
 
-void g2(std::ios_base::event ev, std::ios_base& stream, int index)
+void g2(std::ios_base::event ev, std::ios_base&, int index)
 {
 if (ev == std::ios_base::imbue_event)
 {
 assert(index == 8);
 g2_called = true;
 }
 }
 
-void g3(std::ios_base::event ev, std::ios_base& stream, int index)
+void g3(std::ios_base::event ev, std::ios_base&, int index)
 {
 if (ev == std::ios_base::imbue_event)
 {


Index: test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
+++ test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
@@ -41,31 +41,31 @@
 bool g2_called = false;
 bool g3_called = false;
 
-void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+void f1(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 4);
 f1_called = true;
 }
 
-void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+void f2(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 5);
 f2_called = true;
 }
 
-void g1(std::ios_base::event ev, std::ios_base& stream, int index)
+void g1(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 7);
 g1_called = true;
 }
 
-void g2(std::ios_base::event ev, std::ios_base& stream, int index)
+void g2(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 8);
 g2_called = true;
 }
 
-void g3(std::ios_base::event ev, std::ios_base& stream, int index)
+void g3(std::ios_base::event, std::ios_base&, int index)
 {
 assert(index == 9);
 g3_called = true;
Index: test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
+++ test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
@@ -41,35 +41,35 @@
 bool g2_called = false;
 bool g3_called = false;
 
-void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+void f1(std::ios_base::event, std::ios_base&, int)
 {
 f1_called = true;
 }
 
-void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+void f2(std::ios_base::event, std::ios_base&, int)
 

[PATCH] D19700: [libcxx] [test] nasty_mutex::operator& should return nullptr, like nasty_list above it.

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

[libcxx] [test] nasty_mutex::operator& should return nullptr, like nasty_list 
above it.

Fixes MSVC "error C4716: 'nasty_mutex::operator&': must return a value".

http://reviews.llvm.org/D19700

Files:
  test/support/nasty_containers.hpp

Index: test/support/nasty_containers.hpp
===
--- test/support/nasty_containers.hpp
+++ test/support/nasty_containers.hpp
@@ -287,7 +287,7 @@
  nasty_mutex() _NOEXCEPT {}
  ~nasty_mutex() {}
 
-   nasty_mutex *operator& ()   { assert(false); }
+   nasty_mutex *operator& ()   { assert(false); return nullptr; }
template 
void operator, (const T &) { assert(false); }
 


Index: test/support/nasty_containers.hpp
===
--- test/support/nasty_containers.hpp
+++ test/support/nasty_containers.hpp
@@ -287,7 +287,7 @@
  nasty_mutex() _NOEXCEPT {}
  ~nasty_mutex() {}
 
-	nasty_mutex *operator& ()   { assert(false); }
+	nasty_mutex *operator& ()   { assert(false); return nullptr; }
 	template 
 	void operator, (const T &) { assert(false); }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19699: [libcxx] [test] Need to include for its streaming operators.

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

[libcxx] [test] Need to include  for its streaming operators.

Fixes MSVC errors:
"error C2678: binary '>>': no operator found which takes a left-hand operand of 
type 'std::istrstream' (or there is no acceptable conversion)"
"error C2679: binary '<<': no operator found which takes a right-hand operand 
of type 'std::string' (or there is no acceptable conversion)"

http://reviews.llvm.org/D19699

Files:
  
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp
  
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp
  
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp
  
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp
  
test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp
  
test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
  
test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp
  
test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp

Index: 
test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
===
--- 
test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
+++ 
test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {
Index: 
test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp
===
--- 
test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp
+++ 
test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {
Index: 
test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
===
--- 
test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
+++ 
test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {
Index: 
test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp
===
--- 
test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp
+++ 
test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {
Index: 
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp
===
--- 
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp
+++ 
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {
Index: 
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp
===
--- 
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp
+++ 
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {
Index: 
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp
===
--- 
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp
+++ 
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {
Index: 
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp
===
--- 
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp
+++ 
test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {


Index: test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
===
--- test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
+++ test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
@@ -15,6 +15,7 @@
 
 #include 
 #include 

[PATCH] D19698: [libcxx] [test] Need to include for std::unique_ptr.

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

[libcxx] [test] Need to include  for std::unique_ptr.

Fixes MSVC "error C2039: 'unique_ptr': is not a member of 'std'".

http://reviews.llvm.org/D19698

Files:
  test/std/utilities/meta/meta.rel/is_callable.pass.cpp

Index: test/std/utilities/meta/meta.rel/is_callable.pass.cpp
===
--- test/std/utilities/meta/meta.rel/is_callable.pass.cpp
+++ test/std/utilities/meta/meta.rel/is_callable.pass.cpp
@@ -18,6 +18,7 @@
 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 


Index: test/std/utilities/meta/meta.rel/is_callable.pass.cpp
===
--- test/std/utilities/meta/meta.rel/is_callable.pass.cpp
+++ test/std/utilities/meta/meta.rel/is_callable.pass.cpp
@@ -18,6 +18,7 @@
 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19623: [libcxx] [test] Initialize local doubles to NaN.

2016-04-28 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT retitled this revision from "[libc++] Initialize local doubles to 
0.0." to "[libcxx] [test] Initialize local doubles to NaN.".
STL_MSFT updated the summary for this revision.
STL_MSFT updated this revision to Diff 55506.
STL_MSFT added a comment.

Now I'm using NaN instead of 0.0 for the initializations, as suggested by 
Howard.


http://reviews.llvm.org/D19623

Files:
  
test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp
  
test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp

Index: test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp
===
--- test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp
+++ test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 #include// for sort
 #include 
+#include 
 
 template 
 inline
@@ -59,10 +60,10 @@
 }
 std::sort(u.begin(), u.end());
 int kp = -1;
-double a;
-double m;
-double bk;
-double c;
+double a = std::numeric_limits::quiet_NaN();
+double m = std::numeric_limits::quiet_NaN();
+double bk = std::numeric_limits::quiet_NaN();
+double c = std::numeric_limits::quiet_NaN();
 std::vector areas(Np);
 double S = 0;
 for (int i = 0; i < areas.size(); ++i)
Index: test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp
===
--- test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp
+++ test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 template 
 inline
@@ -60,10 +61,10 @@
 }
 std::sort(u.begin(), u.end());
 int kp = -1;
-double a;
-double m;
-double bk;
-double c;
+double a = std::numeric_limits::quiet_NaN();
+double m = std::numeric_limits::quiet_NaN();
+double bk = std::numeric_limits::quiet_NaN();
+double c = std::numeric_limits::quiet_NaN();
 std::vector areas(Np);
 double S = 0;
 for (int i = 0; i < areas.size(); ++i)
@@ -110,10 +111,10 @@
 }
 std::sort(u.begin(), u.end());
 int kp = -1;
-double a;
-double m;
-double bk;
-double c;
+double a = std::numeric_limits::quiet_NaN();
+double m = std::numeric_limits::quiet_NaN();
+double bk = std::numeric_limits::quiet_NaN();
+double c = std::numeric_limits::quiet_NaN();
 std::vector areas(Np);
 double S = 0;
 for (int i = 0; i < areas.size(); ++i)
@@ -160,10 +161,10 @@
 }
 std::sort(u.begin(), u.end());
 int kp = -1;
-double a;
-double m;
-double bk;
-double c;
+double a = std::numeric_limits::quiet_NaN();
+double m = std::numeric_limits::quiet_NaN();
+double bk = std::numeric_limits::quiet_NaN();
+double c = std::numeric_limits::quiet_NaN();
 std::vector areas(Np);
 double S = 0;
 for (int i = 0; i < areas.size(); ++i)
@@ -210,10 +211,10 @@
 }
 std::sort(u.begin(), u.end());
 int kp = -1;
-double a;
-double m;
-double bk;
-double c;
+double a = std::numeric_limits::quiet_NaN();
+double m = std::numeric_limits::quiet_NaN();
+double bk = std::numeric_limits::quiet_NaN();
+double c = std::numeric_limits::quiet_NaN();
 std::vector areas(Np);
 double S = 0;
 for (int i = 0; i < areas.size(); ++i)
@@ -260,10 +261,10 @@
 }
 std::sort(u.begin(), u.end());
 int kp = -1;
-double a;
-double m;
-double bk;
-double c;
+double a = std::numeric_limits::quiet_NaN();
+double m = std::numeric_limits::quiet_NaN();
+double bk = std::numeric_limits::quiet_NaN();
+double c = std::numeric_limits::quiet_NaN();
 std::vector areas(Np);
 double S = 0;
 for (int i = 0; i < areas.size(); ++i)
@@ -310,10 +311,10 @@
 }
 std::sort(u.begin(), u.end());
 int kp = -1;
-double a;
-double m;
-double bk;
-double c;
+double a = std::numeric_limits::quiet_NaN();
+double m = std::numeric_limits::quiet_NaN();
+double bk = std::numeric_limits::quiet_NaN();
+double c = std::numeric_limits::quiet_NaN();
 std::vector areas(Np);
 double S = 0;
 for (int i = 0; i < areas.size(); ++i)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-28 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

OK. I *think* this is my last round of review comments except for one specific 
issue. I'm still looking into the changes to the static mutex's and 
condition_variables in `memory.cpp` and `algorithm.cpp`. In these cases I don't 
want to go from compile-time initialization to run-time initialization.  This 
could introduce the static initialization order fiasco.



Comment at: include/__mutex_base:37
@@ -38,2 +36,3 @@
 {
-pthread_mutex_t __m_;
+typedef __libcpp_mutex_t __mutex_type;
+__mutex_type __m_;

Why not use `__libcpp_mutex_t` directly? Sorry for yet another renaming comment.


Comment at: include/__mutex_base:43
@@ -43,3 +42,3 @@
 #ifndef _LIBCPP_HAS_NO_CONSTEXPR
- constexpr mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {}
+constexpr mutex() _NOEXCEPT : __m_(__LIBCPP_MUTEX_INITIALIZER) {}
 #else

Only one underscore in `_LIBCPP_MUTEX_INITIALIZER`


Comment at: include/__threading_support:11
@@ +10,3 @@
+
+#ifndef _LIBCPP_OS_SUPPORT
+#define _LIBCPP_OS_SUPPORT

`_LIBCPP_THREADING_SUPPORT`


Comment at: include/__threading_support:13
@@ +12,3 @@
+#define _LIBCPP_OS_SUPPORT
+
+#ifndef _LIBCPP_HAS_NO_THREADS

```
#include <__config>

#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
#pragma GCC system_header
#endif
```


Comment at: include/__threading_support:30
@@ +29,3 @@
+inline _LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_init(__libcpp_mutex_t* __m, bool is_recursive = false)
+{

Two comments:
1. This is only used to initialize a recursive mutex. Let's simply name this 
`__libcpp_recursive_mutex_init` and get rid of the bool parameter. 
2. This is only used in `recursive_mutex.cpp`. It's OK to keep this in 
`__threading_support` for now but I'll probably want to move this out of the 
headers later.


Comment at: include/__threading_support:33
@@ +32,3 @@
+pthread_mutexattr_t attr;
+int ec = pthread_mutexattr_init();
+if (!ec && is_recursive) {

Nit:

Let's invert the control flow here:
```
if (ec) return ec;
ec = pthread_mutexattr_settype(...);
```

Then at the end we can just `return 0;`



Comment at: include/__threading_support:82
@@ +81,3 @@
+// Condition variable
+#define __LIBCPP_COND_INITIALIZER PTHREAD_COND_INITIALIZER
+typedef pthread_cond_t __libcpp_condvar_t;

Nit: `_LIBCPP_CONDVAR_INITIALIZER`


Comment at: include/__threading_support:119
@@ +118,3 @@
+inline _LIBCPP_ALWAYS_INLINE
+int __libcpp_thread_id_compare(__libcpp_thread_id t1, __libcpp_thread_id t2)
+{

Can we split this into `__libcpp_thread_id_equal` and `__libcpp_thread_id_less`?




Comment at: include/__threading_support:129
@@ +128,3 @@
+inline _LIBCPP_ALWAYS_INLINE
+int __libcpp_thread_create(__libcpp_thread_t* __t, _Func&& __f, _Arg&& __arg)
+{

This signature needs to work in C++03. Let's make the signature 
`__libcpp_thread_create(__libcpp_thread_t* __t, _Func* __f, _Arg* __arg)` 
because both `_Func` and `_Arg` should be pointers so there is no need to 
perfect forward them.


Comment at: include/__threading_support:169
@@ +168,3 @@
+inline _LIBCPP_ALWAYS_INLINE
+int __libcpp_tl_create(__libcpp_tl_key* __key, _Func&& __at_exit)
+{

This signature needs to work in C++03. Make the signature 
`__libcpp_tl_create(__libcpp_tl_key*, _Func*)` since the function must be a 
pointer.


Comment at: include/__threading_support:194
@@ +193,2 @@
+
+#endif // _LIBCPP_OS_SUPPORT

`_LIBCPP_THREADING_SUPPORT`


Comment at: src/mutex.cpp:228
@@ -249,3 +227,3 @@
 #else // !_LIBCPP_HAS_NO_THREADS
-pthread_mutex_lock();
+unique_lock lk(mut);
 while (flag == 1)

This change seems incorrect. There are some paths below where we manually 
unlock `mut` before a `throw` or `return`. Using `unique_lock` will result in a 
double unlock.

I think the fix is to change all `mut.lock()` and `mut.unlock()` calls into 
`lk.lock()`/`lk.unlock()` calls.


http://reviews.llvm.org/D19412



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


RE: [PATCH] D19689: Add Subjects to NoDebugAttr [NFC]

2016-04-28 Thread Robinson, Paul via cfe-commits
Generally tests test something other than "this program doesn't crash" - should 
it test that we apply the attribute correctly? (either via ast dump, or 
checking the resulting DWARF doesn't have debug info on the relevant entity)

Or is this not actually a new/separate codepath? In which case do we really 
need the test?

It's a –verify test which is about diagnostics, rather than not-crashing.  It 
parallels line 3 of Sema/attr-nodebug.c, which verifies the attribute can be 
applied to a function.  Without this test, you could remove "ObjCMethod" from 
the Subjects line and no test would fail.  I put "ObjCMethod" on the Subjects 
line because the hand-coded condition used "isFunctionOrMethod" which permits 
Objective-C methods.  The new test passes with old and new compilers, 
demonstrating the NFC claim.

Now, if we decide the 'nodebug' attribute should not apply to Objective-C, 
that's fine with me, in which case the new test should verify that a diagnostic 
*is* produced.

I am admittedly clueless about Objective-C, are they handled differently from 
other functions by the time we get to CGDebugInfo?  If there's another path I 
should tweak, I'd like to know about it.
Thanks,
--paulr

From: David Blaikie [mailto:dblai...@gmail.com]
Sent: Thursday, April 28, 2016 4:26 PM
To: reviews+d19689+public+514682b5314c5...@reviews.llvm.org; Robinson, Paul
Cc: Aaron Ballman; cfe-commits
Subject: Re: [PATCH] D19689: Add Subjects to NoDebugAttr [NFC]

LGTM

On Thu, Apr 28, 2016 at 2:10 PM, Paul Robinson via cfe-commits 
> wrote:
probinson created this revision.
probinson added a reviewer: aaron.ballman.
probinson added a subscriber: cfe-commits.

The 'nodebug' attribute had hand-coded constraints; replace those with a 
Subjects line in Attr.td.
Also add a missing test to verify the attribute is okay on an Objective-C 
method.

http://reviews.llvm.org/D19689

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/attr-nodebug.c
  test/SemaObjC/attr-nodebug.m

Index: test/SemaObjC/attr-nodebug.m
===
--- test/SemaObjC/attr-nodebug.m
+++ test/SemaObjC/attr-nodebug.m
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+@interface NSObject
+- (void)doSomething __attribute__((nodebug));
+@end

Generally tests test something other than "this program doesn't crash" - should 
it test that we apply the attribute correctly? (either via ast dump, or 
checking the resulting DWARF doesn't have debug info on the relevant entity)

Or is this not actually a new/separate codepath? In which case do we really 
need the test?

Index: test/Sema/attr-nodebug.c
===
--- test/Sema/attr-nodebug.c
+++ test/Sema/attr-nodebug.c
@@ -3,7 +3,7 @@
 int a __attribute__((nodebug));

 void b() {
-  int b __attribute__((nodebug)); // expected-warning {{'nodebug' only applies 
to variables with static storage duration and functions}}
+  int b __attribute__((nodebug)); // expected-warning {{'nodebug' attribute 
only applies to functions and global variables}}
 }

 void t1() __attribute__((nodebug));
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3572,18 +3572,6 @@
 }

 static void handleNoDebugAttr(Sema , Decl *D, const AttributeList ) {
-  if (const VarDecl *VD = dyn_cast(D)) {
-if (!VD->hasGlobalStorage())
-  S.Diag(Attr.getLoc(),
- diag::warn_attribute_requires_functions_or_static_globals)
-<< Attr.getName();
-  } else if (!isFunctionOrMethod(D)) {
-S.Diag(Attr.getLoc(),
-   diag::warn_attribute_requires_functions_or_static_globals)
-  << Attr.getName();
-return;
-  }
-
   D->addAttr(::new (S.Context)
  NoDebugAttr(Attr.getRange(), S.Context,
  Attr.getAttributeSpellingListIndex()));
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2504,9 +2504,6 @@
 def warn_incomplete_encoded_type : Warning<
   "encoding of %0 type is incomplete because %1 component has unknown 
encoding">,
   InGroup>;
-def warn_attribute_requires_functions_or_static_globals : Warning<
-  "%0 only applies to variables with static storage duration and functions">,
-  InGroup;
 def warn_gnu_inline_attribute_requires_inline : Warning<
   "'gnu_inline' attribute requires function to be marked 'inline',"
   " attribute ignored">,
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -973,6 +973,8 

Re: r267904 - Debug info: Apply an artificial debug location to __cyg_profile_func.* calls.

2016-04-28 Thread Adrian Prantl via cfe-commits

> On Apr 28, 2016, at 4:31 PM, David Blaikie  wrote:
> 
> 
> 
> On Thu, Apr 28, 2016 at 1:11 PM, Adrian Prantl  > wrote:
> 
>> On Apr 28, 2016, at 12:53 PM, David Blaikie > > wrote:
>> 
>> 
>> 
>> On Thu, Apr 28, 2016 at 12:50 PM, Adrian Prantl > > wrote:
>> 
>>> On Apr 28, 2016, at 12:34 PM, David Blaikie >> > wrote:
>>> 
>>> Should these have no/artificial location? It seems like perhaps they should 
>>> have the same location as the scope they're for? (well, the beginning or 
>>> end of that scope, respectively, etc)
>> 
>> While there is usually a single source location for the beginning of the 
>> function, there can be more than one such location for the end of the 
>> function, so I don’t think this is generally possible.
>> 
>> Seems to me like it would be - declare a variable with a non-trivial dtor at 
>> the start of the function. Whichever line the dtor call is attributed to, 
>> that's the end of the function. (I think we use the } for this, or perhaps 
>> the final return statement if there is one and only one - I forget the 
>> specifics)
> 
> Ah yes, I guess we could be using the cleanup location of the function for 
> this.
> 
>>  
>> The artificial location unambiguously marks the function call as something 
>> that does not appear in source code. For a (terrible) example (given the 
>> nature of these function calls :-p) if you look at a profile you wouldn’t 
>> want these function calls to be misattributed to any line in the source code.
>> 
>> I'm not quite sure what the ramifications of that would be/why that would be 
>> bad (or good) - could you explain further?
> 
> If the compiler generates code that does not have any meaningful source 
> location (in this case one could argue that ‘{‘ and ‘}’ might be meaningful 
> source locations?) then I wouldn’t want that code to be attributed to a 
> source location just because the instructions immediately follow some 
> completely unrelated instructions that happen to have a source location.
> 
> Sorry, I meant specifically what would be the impact of giving it the 
> non-artificial location (the same as the location of the cleanup code, as you 
> noted), not the impact of not giving it a location at all.
>  
> - Profiling: It shouldn't show up in a profile counted towards the source 
> location of the instructions before it.
> - Debugging: Since there is no source code for it a source-based debugger 
> (you can still switch to disassembly) should treat the function call as 
> transparent and skip over it as if it didn’t exist.
> 
> Much like the non-trivial dtor, just because the user didn't explicitly write 
> the function call doesn't seem to me to mean it should be invisible.

The user may not have written the call to the dtor, but the user did at least 
write the dtor itself; and there exists source code for it.

> The profiling argument sort of makes sense to me - but it's going to be 
> attributed to /something/, right? (& wait - aren't these functions the 
> profiling mechanisms themselves for counter based (rather than sample based) 
> profiling?

Yes they are, that’s why I said at the beginning that this example was a 
terrible one :-)

> Do people sample /and/ counter profile the same binary?)

Hopefully not. This was really just meant as an example why someone would 
choose an artificial location over a concrete one in similar situations. In the 
end, I’m not particularly attached to using the artificial location here, but 
these were the reasons that made me opt for an artificial location here.

-- adrian

> 
> - Dave
>  
> 
> -- adrian
> 
>> 
>> - Dave
>>  
>> 
>> -- adrian
>> 
>>> 
>>> On Thu, Apr 28, 2016 at 10:21 AM, Adrian Prantl via cfe-commits 
>>> > wrote:
>>> Author: adrian
>>> Date: Thu Apr 28 12:21:56 2016
>>> New Revision: 267904
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=267904=rev 
>>> 
>>> Log:
>>> Debug info: Apply an artificial debug location to __cyg_profile_func.* 
>>> calls.
>>> The LLVM Verifier expects all inlinable calls in debuggable functions to
>>> have a location.
>>> 
>>> rdar://problem/25818489 <>
>>> 
>>> Modified:
>>> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>>> cfe/trunk/test/CodeGen/instrument-functions.c
>>> 
>>> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=267904=267903=267904=diff
>>>  
>>> 
>>> ==
>>> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
>>> +++ 

Re: r267904 - Debug info: Apply an artificial debug location to __cyg_profile_func.* calls.

2016-04-28 Thread David Blaikie via cfe-commits
On Thu, Apr 28, 2016 at 1:11 PM, Adrian Prantl  wrote:

>
> On Apr 28, 2016, at 12:53 PM, David Blaikie  wrote:
>
>
>
> On Thu, Apr 28, 2016 at 12:50 PM, Adrian Prantl  wrote:
>
>>
>> On Apr 28, 2016, at 12:34 PM, David Blaikie  wrote:
>>
>> Should these have no/artificial location? It seems like perhaps they
>> should have the same location as the scope they're for? (well, the
>> beginning or end of that scope, respectively, etc)
>>
>>
>> While there is usually a single source location for the beginning of the
>> function, there can be more than one such location for the end of the
>> function, so I don’t think this is generally possible.
>>
>
> Seems to me like it would be - declare a variable with a non-trivial dtor
> at the start of the function. Whichever line the dtor call is attributed
> to, that's the end of the function. (I think we use the } for this, or
> perhaps the final return statement if there is one and only one - I forget
> the specifics)
>
>
> Ah yes, I guess we could be using the cleanup location of the function for
> this.
>
>
>
>> The artificial location unambiguously marks the function call as
>> something that does not appear in source code. For a (terrible) example
>> (given the nature of these function calls :-p) if you look at a profile you
>> wouldn’t want these function calls to be misattributed to any line in the
>> source code.
>>
>
> I'm not quite sure what the ramifications of that would be/why that would
> be bad (or good) - could you explain further?
>
>
> If the compiler generates code that does not have any meaningful source
> location (in this case one could argue that ‘{‘ and ‘}’ might be meaningful
> source locations?) then I wouldn’t want that code to be attributed to a
> source location just because the instructions immediately follow some
> completely unrelated instructions that happen to have a source location.
>

Sorry, I meant specifically what would be the impact of giving it the
non-artificial location (the same as the location of the cleanup code, as
you noted), not the impact of not giving it a location at all.


> - Profiling: It shouldn't show up in a profile counted towards the source
> location of the instructions before it.
> - Debugging: Since there is no source code for it a source-based debugger
> (you can still switch to disassembly) should treat the function call as
> transparent and skip over it as if it didn’t exist.
>

Much like the non-trivial dtor, just because the user didn't explicitly
write the function call doesn't seem to me to mean it should be invisible.

The profiling argument sort of makes sense to me - but it's going to be
attributed to /something/, right? (& wait - aren't these functions the
profiling mechanisms themselves for counter based (rather than sample
based) profiling? Do people sample /and/ counter profile the same binary?)

- Dave


>
> -- adrian
>
>
> - Dave
>
>
>>
>> -- adrian
>>
>>
>> On Thu, Apr 28, 2016 at 10:21 AM, Adrian Prantl via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: adrian
>>> Date: Thu Apr 28 12:21:56 2016
>>> New Revision: 267904
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=267904=rev
>>> Log:
>>> Debug info: Apply an artificial debug location to __cyg_profile_func.*
>>> calls.
>>> The LLVM Verifier expects all inlinable calls in debuggable functions to
>>> have a location.
>>>
>>> rdar://problem/25818489
>>>
>>> Modified:
>>> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>>> cfe/trunk/test/CodeGen/instrument-functions.c
>>>
>>> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=267904=267903=267904=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Apr 28 12:21:56 2016
>>> @@ -401,6 +401,7 @@ bool CodeGenFunction::ShouldInstrumentFu
>>>  /// instrumentation function with the current function and the call
>>> site, if
>>>  /// function instrumentation is enabled.
>>>  void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) {
>>> +  auto NL = ApplyDebugLocation::CreateArtificial(*this);
>>>// void __cyg_profile_func_{enter,exit} (void *this_fn, void
>>> *call_site);
>>>llvm::PointerType *PointerTy = Int8PtrTy;
>>>llvm::Type *ProfileFuncArgs[] = { PointerTy, PointerTy };
>>>
>>> Modified: cfe/trunk/test/CodeGen/instrument-functions.c
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/instrument-functions.c?rev=267904=267903=267904=diff
>>>
>>> ==
>>> --- cfe/trunk/test/CodeGen/instrument-functions.c (original)
>>> +++ cfe/trunk/test/CodeGen/instrument-functions.c Thu Apr 28 12:21:56
>>> 2016
>>> @@ -1,9 +1,9 @@
>>> -// RUN: 

Re: [PATCH] D19689: Add Subjects to NoDebugAttr [NFC]

2016-04-28 Thread David Blaikie via cfe-commits
LGTM

On Thu, Apr 28, 2016 at 2:10 PM, Paul Robinson via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> probinson created this revision.
> probinson added a reviewer: aaron.ballman.
> probinson added a subscriber: cfe-commits.
>
> The 'nodebug' attribute had hand-coded constraints; replace those with a
> Subjects line in Attr.td.
> Also add a missing test to verify the attribute is okay on an Objective-C
> method.
>
> http://reviews.llvm.org/D19689
>
> Files:
>   include/clang/Basic/Attr.td
>   include/clang/Basic/DiagnosticSemaKinds.td
>   lib/Sema/SemaDeclAttr.cpp
>   test/Sema/attr-nodebug.c
>   test/SemaObjC/attr-nodebug.m
>
> Index: test/SemaObjC/attr-nodebug.m
> ===
> --- test/SemaObjC/attr-nodebug.m
> +++ test/SemaObjC/attr-nodebug.m
> @@ -0,0 +1,5 @@
> +// RUN: %clang_cc1 -fsyntax-only -verify %s
> +// expected-no-diagnostics
> +@interface NSObject
> +- (void)doSomething __attribute__((nodebug));
> +@end
>

Generally tests test something other than "this program doesn't crash" -
should it test that we apply the attribute correctly? (either via ast dump,
or checking the resulting DWARF doesn't have debug info on the relevant
entity)

Or is this not actually a new/separate codepath? In which case do we really
need the test?


> Index: test/Sema/attr-nodebug.c
> ===
> --- test/Sema/attr-nodebug.c
> +++ test/Sema/attr-nodebug.c
> @@ -3,7 +3,7 @@
>  int a __attribute__((nodebug));
>
>  void b() {
> -  int b __attribute__((nodebug)); // expected-warning {{'nodebug' only
> applies to variables with static storage duration and functions}}
> +  int b __attribute__((nodebug)); // expected-warning {{'nodebug'
> attribute only applies to functions and global variables}}
>  }
>
>  void t1() __attribute__((nodebug));
> Index: lib/Sema/SemaDeclAttr.cpp
> ===
> --- lib/Sema/SemaDeclAttr.cpp
> +++ lib/Sema/SemaDeclAttr.cpp
> @@ -3572,18 +3572,6 @@
>  }
>
>  static void handleNoDebugAttr(Sema , Decl *D, const AttributeList
> ) {
> -  if (const VarDecl *VD = dyn_cast(D)) {
> -if (!VD->hasGlobalStorage())
> -  S.Diag(Attr.getLoc(),
> - diag::warn_attribute_requires_functions_or_static_globals)
> -<< Attr.getName();
> -  } else if (!isFunctionOrMethod(D)) {
> -S.Diag(Attr.getLoc(),
> -   diag::warn_attribute_requires_functions_or_static_globals)
> -  << Attr.getName();
> -return;
> -  }
> -
>D->addAttr(::new (S.Context)
>   NoDebugAttr(Attr.getRange(), S.Context,
>   Attr.getAttributeSpellingListIndex()));
> Index: include/clang/Basic/DiagnosticSemaKinds.td
> ===
> --- include/clang/Basic/DiagnosticSemaKinds.td
> +++ include/clang/Basic/DiagnosticSemaKinds.td
> @@ -2504,9 +2504,6 @@
>  def warn_incomplete_encoded_type : Warning<
>"encoding of %0 type is incomplete because %1 component has unknown
> encoding">,
>InGroup>;
> -def warn_attribute_requires_functions_or_static_globals : Warning<
> -  "%0 only applies to variables with static storage duration and
> functions">,
> -  InGroup;
>  def warn_gnu_inline_attribute_requires_inline : Warning<
>"'gnu_inline' attribute requires function to be marked 'inline',"
>" attribute ignored">,
> Index: include/clang/Basic/Attr.td
> ===
> --- include/clang/Basic/Attr.td
> +++ include/clang/Basic/Attr.td
> @@ -973,6 +973,8 @@
>
>  def NoDebug : InheritableAttr {
>let Spellings = [GCC<"nodebug">];
> +  let Subjects = SubjectList<[FunctionLike, ObjCMethod, GlobalVar],
> WarnDiag,
> +
> "ExpectedFunctionGlobalVarMethodOrProperty">;
>let Documentation = [NoDebugDocs];
>  }
>
>
>
>
> ___
> 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


LLVM buildmaster will be updated and restarted tonight

2016-04-28 Thread Galina Kistanova via cfe-commits
Hello everyone,

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

Thanks

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


Re: [PATCH] D18823: Implementation of VlA of GNU C++ extension

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

LGTM.


http://reviews.llvm.org/D18823



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


r267948 - Differential Revision: http://reviews.llvm.org/D19687

2016-04-28 Thread Sriraman Tallam via cfe-commits
Author: tmsriram
Date: Thu Apr 28 17:34:00 2016
New Revision: 267948

URL: http://llvm.org/viewvc/llvm-project?rev=267948=rev
Log:
Differential Revision: http://reviews.llvm.org/D19687

Set module flag PIELevel. Simplify code that sets PICLevel flag.

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

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=267948=267947=267948=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Apr 28 17:34:00 2016
@@ -477,15 +477,13 @@ void CodeGenModule::Release() {
   }
 
   if (uint32_t PLevel = Context.getLangOpts().PICLevel) {
-llvm::PICLevel::Level PL = llvm::PICLevel::Default;
-switch (PLevel) {
-case 0: break;
-case 1: PL = llvm::PICLevel::Small; break;
-case 2: PL = llvm::PICLevel::Large; break;
-default: llvm_unreachable("Invalid PIC Level");
-}
+assert(PLevel < 3 && "Invalid PIC Level");
+getModule().setPICLevel(static_cast(PLevel));
+  }
 
-getModule().setPICLevel(PL);
+  if (uint32_t PLevel = Context.getLangOpts().PIELevel) {
+assert(PLevel < 3 && "Invalid PIE Level");
+getModule().setPIELevel(static_cast(PLevel));
   }
 
   SimplifyPersonality();


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


Re: [PATCH] D19693: [Clang][Darwin] Define __ARM_DWARF_EH__ for WatchABI

2016-04-28 Thread Chris Bieneman via cfe-commits
Yea… Arc seems to have done something odd with my out-of-date checkout.

I’ll make sure that gets cleaned up, and I’ll add a test.

Thanks,
-Chris

> On Apr 28, 2016, at 3:23 PM, Tim Northover  wrote:
> 
> t.p.northover added a comment.
> 
> The __ARM_DWARF_EH__ change looks reasonable, but it's probably an idea to 
> put a check into tools/clang/tests/Preprocessor/arm-target-features.c (watch 
> is checked with "ARMV7K").
> 
> The rest of the changes look like they're from an unsynchronized branch?
> 
> 
> http://reviews.llvm.org/D19693
> 
> 
> 

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


Re: [PATCH] D19693: [Clang][Darwin] Define __ARM_DWARF_EH__ for WatchABI

2016-04-28 Thread Chris Bieneman via cfe-commits
beanz added a subscriber: beanz.
beanz added a comment.

Yea… Arc seems to have done something odd with my out-of-date checkout.

I’ll make sure that gets cleaned up, and I’ll add a test.

Thanks,
-Chris


http://reviews.llvm.org/D19693



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


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

2016-04-28 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 55503.
rmaprath added a comment.

Updating to syc-up with http://reviews.llvm.org/D19412. Obviously, this patch 
needs more work in terms of setting up the testing story (using a pthreads 
based implementation of the threading API).


http://reviews.llvm.org/D19415

Files:
  include/__threading_support

Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -183,7 +183,75 @@
 pthread_setspecific(__key, __p);
 }
 
-#else // !_LIBCPP_THREAD_API_PTHREAD
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+
+// Mutex
+#if !defined(__LIBCPP_MUTEX_INITIALIZER)
+  #error "__LIBCPP_MUTEX_INITIALIZER must be defined."
+#endif
+struct __libcpp_mutex_external;
+typedef __libcpp_mutex_external* __libcpp_mutex_t;
+
+int __libcpp_mutex_init(__libcpp_mutex_t* __m, bool is_recursive);
+
+int __libcpp_mutex_lock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_trylock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t* __m);
+
+// Condition variable
+#if !defined(__LIBCPP_COND_INITIALIZER)
+  #error "__LIBCPP_COND_INITIALIZER must be defined."
+#endif
+struct __libcpp_condvar_external;
+typedef __libcpp_condvar_external* __libcpp_condvar_t;
+
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
+
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* 
__m, timespec* __ts);
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
+
+// Thread id
+typedef unsigned long __libcpp_thread_id;
+
+int __libcpp_thread_id_compare(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Thread
+struct __libcpp_thread_external;
+typedef __libcpp_thread_external* __libcpp_thread_t;
+
+template
+int __libcpp_thread_create(__libcpp_thread_t* __t, _Func&& __f, _Arg&& __arg);
+
+__libcpp_thread_id __libcpp_thread_get_current_id();
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t);
+
+int __libcpp_thread_join(__libcpp_thread_t* __t);
+
+int __libcpp_thread_detach(__libcpp_thread_t* __t);
+
+void __libcpp_thread_yield();
+
+// Thread local storage
+typedef unsigned long __libcpp_tl_key;
+
+template
+int __libcpp_tl_create(__libcpp_tl_key* __key, _Func&& __at_exit);
+
+void* __libcpp_tl_get(__libcpp_tl_key __key);
+
+void __libcpp_tl_set(__libcpp_tl_key __key, void* __p);
+
+#else
   #error "No thread API selected."
 #endif
 


Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -183,7 +183,75 @@
 pthread_setspecific(__key, __p);
 }
 
-#else // !_LIBCPP_THREAD_API_PTHREAD
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+
+// Mutex
+#if !defined(__LIBCPP_MUTEX_INITIALIZER)
+  #error "__LIBCPP_MUTEX_INITIALIZER must be defined."
+#endif
+struct __libcpp_mutex_external;
+typedef __libcpp_mutex_external* __libcpp_mutex_t;
+
+int __libcpp_mutex_init(__libcpp_mutex_t* __m, bool is_recursive);
+
+int __libcpp_mutex_lock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_trylock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t* __m);
+
+// Condition variable
+#if !defined(__LIBCPP_COND_INITIALIZER)
+  #error "__LIBCPP_COND_INITIALIZER must be defined."
+#endif
+struct __libcpp_condvar_external;
+typedef __libcpp_condvar_external* __libcpp_condvar_t;
+
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
+
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts);
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
+
+// Thread id
+typedef unsigned long __libcpp_thread_id;
+
+int __libcpp_thread_id_compare(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Thread
+struct __libcpp_thread_external;
+typedef __libcpp_thread_external* __libcpp_thread_t;
+
+template
+int __libcpp_thread_create(__libcpp_thread_t* __t, _Func&& __f, _Arg&& __arg);
+
+__libcpp_thread_id __libcpp_thread_get_current_id();
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t);
+
+int __libcpp_thread_join(__libcpp_thread_t* __t);
+
+int __libcpp_thread_detach(__libcpp_thread_t* __t);
+
+void __libcpp_thread_yield();
+
+// Thread local storage
+typedef unsigned long __libcpp_tl_key;
+
+template
+int __libcpp_tl_create(__libcpp_tl_key* __key, _Func&& __at_exit);
+
+void* __libcpp_tl_get(__libcpp_tl_key __key);
+
+void __libcpp_tl_set(__libcpp_tl_key __key, void* __p);
+
+#else
   #error "No thread API selected."
 #endif
 
___
cfe-commits mailing 

Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-28 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 55501.
rmaprath added a comment.

Addressing review comments from @EricWF:

- Agree with all the suggested changes, I've applied them all.

Thanks!

/ Asiri


http://reviews.llvm.org/D19412

Files:
  include/__config
  include/__mutex_base
  include/__threading_support
  include/mutex
  include/thread
  src/algorithm.cpp
  src/condition_variable.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -46,7 +46,7 @@
 void
 thread::join()
 {
-int ec = pthread_join(__t_, 0);
+int ec = __libcpp_thread_join(&__t_);
 #ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
 throw system_error(error_code(ec, system_category()), "thread::join failed");
@@ -62,7 +62,7 @@
 int ec = EINVAL;
 if (__t_ != 0)
 {
-ec = pthread_detach(__t_);
+ec = __libcpp_thread_detach(&__t_);
 if (ec == 0)
 __t_ = 0;
 }
Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -23,89 +23,67 @@
 
 mutex::~mutex()
 {
-pthread_mutex_destroy(&__m_);
+__libcpp_mutex_destroy(&__m_);
 }
 
 void
 mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __libcpp_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "mutex lock failed");
 }
 
 bool
 mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __libcpp_mutex_trylock(&__m_) == 0;
 }
 
 void
 mutex::unlock() _NOEXCEPT
 {
-int ec = pthread_mutex_unlock(&__m_);
+int ec = __libcpp_mutex_unlock(&__m_);
 (void)ec;
 assert(ec == 0);
 }
 
 // recursive_mutex
 
 recursive_mutex::recursive_mutex()
 {
-pthread_mutexattr_t attr;
-int ec = pthread_mutexattr_init();
+int ec = __libcpp_mutex_init(&__m_, true);
 if (ec)
-goto fail;
-ec = pthread_mutexattr_settype(, PTHREAD_MUTEX_RECURSIVE);
-if (ec)
-{
-pthread_mutexattr_destroy();
-goto fail;
-}
-ec = pthread_mutex_init(&__m_, );
-if (ec)
-{
-pthread_mutexattr_destroy();
-goto fail;
-}
-ec = pthread_mutexattr_destroy();
-if (ec)
-{
-pthread_mutex_destroy(&__m_);
-goto fail;
-}
-return;
-fail:
-__throw_system_error(ec, "recursive_mutex constructor failed");
+__throw_system_error(ec, "recursive_mutex constructor failed");
 }
 
 recursive_mutex::~recursive_mutex()
 {
-int e = pthread_mutex_destroy(&__m_);
+int e = __libcpp_mutex_destroy(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 void
 recursive_mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __libcpp_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "recursive_mutex lock failed");
 }
 
 void
 recursive_mutex::unlock() _NOEXCEPT
 {
-int e = pthread_mutex_unlock(&__m_);
+int e = __libcpp_mutex_unlock(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __libcpp_mutex_trylock(&__m_) == 0;
 }
 
 // timed_mutex
@@ -165,9 +143,9 @@
 void
 recursive_timed_mutex::lock()
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __libcpp_thread_get_current_id();
 unique_lock lk(__m_);
-if (pthread_equal(id, __id_))
+if (__libcpp_thread_id_compare(id, __id_) == 0)
 {
 if (__count_ == numeric_limits::max())
 __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
@@ -183,9 +161,9 @@
 bool
 recursive_timed_mutex::try_lock() _NOEXCEPT
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __libcpp_thread_get_current_id();
 unique_lock lk(__m_, try_to_lock);
-if (lk.owns_lock() && (__count_ == 0 || pthread_equal(id, __id_)))
+if (lk.owns_lock() && (__count_ == 0 || __libcpp_thread_id_compare(id, __id_) == 0))
 {
 if (__count_ == numeric_limits::max())
 return false;
@@ -217,8 +195,8 @@
 // keep in sync with:  7741191.
 
 #ifndef _LIBCPP_HAS_NO_THREADS
-static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t  cv  = PTHREAD_COND_INITIALIZER;
+static mutex mut;
+static condition_variable cv;
 #endif
 
 /// NOTE: Changes to flag are done via relaxed atomic stores
@@ -247,36 +225,36 @@
 #endif  // _LIBCPP_NO_EXCEPTIONS
 }
 #else // !_LIBCPP_HAS_NO_THREADS
-pthread_mutex_lock();
+unique_lock lk(mut);
 while (flag == 1)
-pthread_cond_wait(, );
+cv.wait(lk);
 if (flag == 0)
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
 #endif  // _LIBCPP_NO_EXCEPTIONS
 __libcpp_relaxed_store(, 1ul);
-pthread_mutex_unlock();
+mut.unlock();
 func(arg);
-pthread_mutex_lock();
+mut.lock();
 

Re: [PATCH] D19048: Test for a module related crash in CGDebugInfo.cpp

2016-04-28 Thread Adrian Prantl via cfe-commits
aprantl added a comment.

Please make sure that the two DINodes are connected, otherwise LGTM. Thanks!


http://reviews.llvm.org/D19048



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


Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-04-28 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

In http://reviews.llvm.org/D19678#416127, @rcox2 wrote:

> Actually, the Intel compiler distinguishes between an optimization report 
> (-qopt-report) and an annotated listing (-qopt-report-annotate).


Interesting; thanks for pointing this out (and for the example).

>   The optimization report lists the info for optimizations in a hierarchical 
> fashion.  To use you example, 

> icc -c -O3 -qopt-report=1 -qopt-report-file=stderr v.c 

> 

> yields:

> 

>   Report from: Interprocedural optimizations [ipo]

>

> 

> INLINING OPTION VALUES:

> 

>   -inline-factor: 100

>   -inline-min-size: 20

>   -inline-max-size: 230

>   -inline-max-total-size: 2000

>   -inline-max-per-routine: 1

>   -inline-max-per-compile: 50

>

>

> 

> Begin optimization report for: foo()

> 

>   Report from: Interprocedural optimizations [ipo]

>

> 

> INLINE REPORT: (foo()) [1] v.c(2,12)

> 

>   Report from: Code generation optimizations [cg]

>

> 

> v.c(2,12):remark #34051: REGISTER ALLOCATION : [foo] v.c:2

> 

>   Hardware registers

>   Reserved :1[ esp]

>   Available:   23[ eax edx ecx ebx ebp esi edi mm0-mm7 zmm0-zmm7]

>   Callee-save  :4[ ebx ebp esi edi]

>   Assigned :0[ reg_null]

>

>   Routine temporaries

>   Total :   4

>   Global:   0

>   Local :   4

>   Regenerable   :   0

>   Spilled   :   0

>

>   Routine stack

>   Variables :   0 bytes*

>   Reads :   0 [0.00e+00 ~ 0.0%]

>   Writes:   0 [0.00e+00 ~ 0.0%]

>   Spills:   0 bytes*

>   Reads :   0 [0.00e+00 ~ 0.0%]

>   Writes:   0 [0.00e+00 ~ 0.0%]

>

>   Notes

>

>   *Non-overlapping variables and spills may share stack space,

>so the total stack size might be less than this.

>

>

> 

> ===

> 

> Begin optimization report for: Test(int *, int *, int *, int *, int)

> 

>   Report from: Interprocedural optimizations [ipo]

>

> 

> INLINE REPORT: (Test(int *, int *, int *, int *, int)) [2] v.c(4,52)

> 

>   -> INLINE: (16,3) foo()

>   -> INLINE: (18,3) foo()

>   -> INLINE: (18,17) foo()

>

>

> Report from: Loop nest, Vector & Auto-parallelization optimizations 
> [loop, vec, par]

>

>

> 

> LOOP BEGIN at v.c(8,8)

>  

>  LOOP END

> 

> LOOP BEGIN at v.c(8,8)

> 

>   remark #15301: SIMD LOOP WAS VECTORIZED

> 

> LOOP END

> 

> LOOP BEGIN at v.c(8,8)

>  

>  LOOP END

> 

> LOOP BEGIN at v.c(8,8)

>  

> 

>   remark #15335: remainder loop was not vectorized: vectorization possible 
> but seems inefficient. Use vector always directive or -vec-threshold0 to 
> override

> 

> LOOP END

> 

> LOOP BEGIN at v.c(12,3)

> 

>   remark #15344: loop was not vectorized: vector dependence prevents 
> vectorization. First dependence is shown below. Use level 5 report for details

>   remark #15346: vector dependence: assumed FLOW dependence between res[i] 
> (13:5) and d[i] (13:5)

>   remark #25436: completely unrolled by 16

> 

> LOOP END

> 

>   Report from: Code generation optimizations [cg]

>

> 

> v.c(4,52):remark #34051: REGISTER ALLOCATION : [Test] v.c:4

> 

>   Hardware registers

>   Reserved :1[ esp]

>   Available:   23[ eax edx ecx ebx ebp esi edi mm0-mm7 zmm0-zmm7]

>   Callee-save  :4[ ebx ebp esi edi]

>   Assigned :   15[ eax edx ecx ebx ebp esi edi zmm0-zmm7]

>

>   Routine temporaries

>   Total : 123

>   Global:  47

>   Local :  76

>   Regenerable   :   5

>   Spilled   :   6

>

>   Routine stack

>   Variables :   0 bytes*

>   Reads :   0 [0.00e+00 ~ 0.0%]

>   Writes:   0 [0.00e+00 ~ 0.0%]

>   Spills:   8 bytes*

>   Reads :   5 [1.41e+01 ~ 1.4%]

>   Writes:   3 [3.00e+00 ~ 0.3%]

>

>   Notes

>

>   *Non-overlapping variables and spills may share stack space,

>so the total stack size might be less than this.

>

> 

> while the annotated listing looks like:

> 

> //

>  // --- Annotated listing with optimization reports for 
> "/export/iusers/rcox2/rgHF/v.c" ---

>  //

>  //INLINING OPTION VALUES:

>  //  -inline-factor: 100

>  //  -inline-min-size: 20

>  //  -inline-max-size: 230

>  //  -inline-max-total-size: 2000

>  //  -inline-max-per-routine: 1

>  //  -inline-max-per-compile: 50

>  //

>  1   void bar();

>  2   void foo() { bar(); }

>  //INLINE REPORT: (foo()) [1] /export/iusers/rcox2/rgHF/v.c(2,12)

>  //

>  ///export/iusers/rcox2/rgHF/v.c(2,12):remark #34051: REGISTER ALLOCATION : 
> [foo] /export/iusers/rcox2/rgHF/v.c:2

>  //

>  //Hardware 

Re: [PATCH] D19687: Set PIELevel module flag

2016-04-28 Thread Sriraman Tallam via cfe-commits
tmsriram updated this revision to Diff 55493.
tmsriram added a comment.

Simplify code setting PICLevel and PIELevel module flags.


http://reviews.llvm.org/D19687

Files:
  lib/CodeGen/CodeGenModule.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -477,15 +477,13 @@
   }
 
   if (uint32_t PLevel = Context.getLangOpts().PICLevel) {
-llvm::PICLevel::Level PL = llvm::PICLevel::Default;
-switch (PLevel) {
-case 0: break;
-case 1: PL = llvm::PICLevel::Small; break;
-case 2: PL = llvm::PICLevel::Large; break;
-default: llvm_unreachable("Invalid PIC Level");
-}
+assert (PLevel < 3 && "Invalid PIC Level");
+getModule().setPICLevel(static_cast(PLevel));
+  }
 
-getModule().setPICLevel(PL);
+  if (uint32_t PLevel = Context.getLangOpts().PIELevel) {
+assert (PLevel < 3 && "Invalid PIE Level");
+getModule().setPIELevel(static_cast(PLevel));
   }
 
   SimplifyPersonality();


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -477,15 +477,13 @@
   }
 
   if (uint32_t PLevel = Context.getLangOpts().PICLevel) {
-llvm::PICLevel::Level PL = llvm::PICLevel::Default;
-switch (PLevel) {
-case 0: break;
-case 1: PL = llvm::PICLevel::Small; break;
-case 2: PL = llvm::PICLevel::Large; break;
-default: llvm_unreachable("Invalid PIC Level");
-}
+assert (PLevel < 3 && "Invalid PIC Level");
+getModule().setPICLevel(static_cast(PLevel));
+  }
 
-getModule().setPICLevel(PL);
+  if (uint32_t PLevel = Context.getLangOpts().PIELevel) {
+assert (PLevel < 3 && "Invalid PIE Level");
+getModule().setPIELevel(static_cast(PLevel));
   }
 
   SimplifyPersonality();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-04-28 Thread Robert Cox via cfe-commits
rcox2 added a comment.

Actually, the Intel compiler distinguishes between an optimization report 
(-qopt-report) and an annotated listing (-qopt-report-annotate).  The 
optimization report lists the info for optimizations in a hierarchical fashion. 
 To use you example,

  icc -c -O3 -qopt-report=1 -qopt-report-file=stderr v.c 

yields:

  Report from: Interprocedural optimizations [ipo]

INLINING OPTION VALUES:

  -inline-factor: 100
  -inline-min-size: 20
  -inline-max-size: 230
  -inline-max-total-size: 2000
  -inline-max-per-routine: 1
  -inline-max-per-compile: 50

Begin optimization report for: foo()

  Report from: Interprocedural optimizations [ipo]

INLINE REPORT: (foo()) [1] v.c(2,12)

  Report from: Code generation optimizations [cg]

v.c(2,12):remark #34051: REGISTER ALLOCATION : [foo] v.c:2

  Hardware registers
  Reserved :1[ esp]
  Available:   23[ eax edx ecx ebx ebp esi edi mm0-mm7 zmm0-zmm7]
  Callee-save  :4[ ebx ebp esi edi]
  Assigned :0[ reg_null]
  
  Routine temporaries
  Total :   4
  Global:   0
  Local :   4
  Regenerable   :   0
  Spilled   :   0
  
  Routine stack
  Variables :   0 bytes*
  Reads :   0 [0.00e+00 ~ 0.0%]
  Writes:   0 [0.00e+00 ~ 0.0%]
  Spills:   0 bytes*
  Reads :   0 [0.00e+00 ~ 0.0%]
  Writes:   0 [0.00e+00 ~ 0.0%]
  
  Notes
  
  *Non-overlapping variables and spills may share stack space,
   so the total stack size might be less than this.




Begin optimization report for: Test(int *, int *, int *, int *, int)

  Report from: Interprocedural optimizations [ipo]

INLINE REPORT: (Test(int *, int *, int *, int *, int)) [2] v.c(4,52)

  -> INLINE: (16,3) foo()
  -> INLINE: (18,3) foo()
  -> INLINE: (18,17) foo()
  
  
Report from: Loop nest, Vector & Auto-parallelization optimizations [loop, 
vec, par]

LOOP BEGIN at v.c(8,8)

LOOP END

LOOP BEGIN at v.c(8,8)

  remark #15301: SIMD LOOP WAS VECTORIZED

LOOP END

LOOP BEGIN at v.c(8,8)

LOOP END

LOOP BEGIN at v.c(8,8)


  remark #15335: remainder loop was not vectorized: vectorization possible but 
seems inefficient. Use vector always directive or -vec-threshold0 to override

LOOP END

LOOP BEGIN at v.c(12,3)

  remark #15344: loop was not vectorized: vector dependence prevents 
vectorization. First dependence is shown below. Use level 5 report for details
  remark #15346: vector dependence: assumed FLOW dependence between res[i] 
(13:5) and d[i] (13:5)
  remark #25436: completely unrolled by 16

LOOP END

  Report from: Code generation optimizations [cg]

v.c(4,52):remark #34051: REGISTER ALLOCATION : [Test] v.c:4

  Hardware registers
  Reserved :1[ esp]
  Available:   23[ eax edx ecx ebx ebp esi edi mm0-mm7 zmm0-zmm7]
  Callee-save  :4[ ebx ebp esi edi]
  Assigned :   15[ eax edx ecx ebx ebp esi edi zmm0-zmm7]
  
  Routine temporaries
  Total : 123
  Global:  47
  Local :  76
  Regenerable   :   5
  Spilled   :   6
  
  Routine stack
  Variables :   0 bytes*
  Reads :   0 [0.00e+00 ~ 0.0%]
  Writes:   0 [0.00e+00 ~ 0.0%]
  Spills:   8 bytes*
  Reads :   5 [1.41e+01 ~ 1.4%]
  Writes:   3 [3.00e+00 ~ 0.3%]
  
  Notes
  
  *Non-overlapping variables and spills may share stack space,
   so the total stack size might be less than this.

while the annotated listing looks like:

//
// --- Annotated listing with optimization reports for 
"/export/iusers/rcox2/rgHF/v.c" ---
//
//INLINING OPTION VALUES:
//  -inline-factor: 100
//  -inline-min-size: 20
//  -inline-max-size: 230
//  -inline-max-total-size: 2000
//  -inline-max-per-routine: 1
//  -inline-max-per-compile: 50
//
1   void bar();
2   void foo() { bar(); }
//INLINE REPORT: (foo()) [1] /export/iusers/rcox2/rgHF/v.c(2,12)
//
///export/iusers/rcox2/rgHF/v.c(2,12):remark #34051: REGISTER ALLOCATION : 
[foo] /export/iusers/rcox2/rgHF/v.c:2
//
//Hardware registers
//Reserved :1[ esp]
//Available:   23[ eax edx ecx ebx ebp esi edi mm0-mm7 zmm0-zmm7]
//Callee-save  :4[ ebx ebp esi edi]
//Assigned :0[ reg_null]
//
//Routine temporaries
//Total :   4
//Global:   0
//Local :   4
//Regenerable   :   0
//Spilled   :   0
//
//Routine stack
//Variables :   0 bytes*
//Reads :   0 [0.00e+00 ~ 0.0%]
//Writes:   0 [0.00e+00 ~ 0.0%]
//Spills:   0 bytes*
//Reads :   0 [0.00e+00 ~ 0.0%]
//Writes:   0 [0.00e+00 ~ 0.0%]
//
//Notes
//
//*Non-overlapping 

[PATCH] D19687: Set PIELevel module flag

2016-04-28 Thread Sriraman Tallam via cfe-commits
tmsriram created this revision.
tmsriram added reviewers: rnk, davidxl.
tmsriram added a subscriber: cfe-commits.

In patch http://reviews.llvm.org/D19671, I added a patch to create PIELevel 
module flag.  This patch sets the flag.

http://reviews.llvm.org/D19687

Files:
  lib/CodeGen/CodeGenModule.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -488,6 +488,18 @@
 getModule().setPICLevel(PL);
   }
 
+  if (uint32_t PLevel = Context.getLangOpts().PIELevel) {
+llvm::PIELevel::Level PL = llvm::PIELevel::Default;
+switch (PLevel) {
+case 0: break;
+case 1: PL = llvm::PIELevel::Small; break;
+case 2: PL = llvm::PIELevel::Large; break;
+default: llvm_unreachable("Invalid PIE Level");
+}
+
+getModule().setPIELevel(PL);
+  }
+
   SimplifyPersonality();
 
   if (getCodeGenOpts().EmitDeclMetadata)


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -488,6 +488,18 @@
 getModule().setPICLevel(PL);
   }
 
+  if (uint32_t PLevel = Context.getLangOpts().PIELevel) {
+llvm::PIELevel::Level PL = llvm::PIELevel::Default;
+switch (PLevel) {
+case 0: break;
+case 1: PL = llvm::PIELevel::Small; break;
+case 2: PL = llvm::PIELevel::Large; break;
+default: llvm_unreachable("Invalid PIE Level");
+}
+
+getModule().setPIELevel(PL);
+  }
+
   SimplifyPersonality();
 
   if (getCodeGenOpts().EmitDeclMetadata)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19693: [Clang][Darwin] Define __ARM_DWARF_EH__ for WatchABI

2016-04-28 Thread Tim Northover via cfe-commits
t.p.northover added a comment.

The __ARM_DWARF_EH__ change looks reasonable, but it's probably an idea to put 
a check into tools/clang/tests/Preprocessor/arm-target-features.c (watch is 
checked with "ARMV7K").

The rest of the changes look like they're from an unsynchronized branch?


http://reviews.llvm.org/D19693



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


Re: [PATCH] D19346: [CUDA] Copy host builtin types to NVPTXTargetInfo.

2016-04-28 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Basic/Targets.cpp:1648-1684
@@ +1647,39 @@
+
+// Match the host's types.
+PointerWidth = HostTarget->getPointerWidth(/* AddrSpace = */ 0);
+PointerAlign = HostTarget->getPointerAlign(/* AddrSpace = */ 0);
+BoolWidth = HostTarget->getBoolWidth();
+BoolAlign = HostTarget->getBoolAlign();
+IntWidth = HostTarget->getIntWidth();
+IntWidth = HostTarget->getIntWidth();
+HalfWidth = HostTarget->getHalfWidth();
+HalfWidth = HostTarget->getHalfWidth();
+FloatWidth = HostTarget->getFloatWidth();
+FloatWidth = HostTarget->getFloatWidth();
+DoubleWidth = HostTarget->getDoubleWidth();
+DoubleWidth = HostTarget->getDoubleWidth();
+LongWidth = HostTarget->getLongWidth();
+LongAlign = HostTarget->getLongAlign();
+LongLongWidth = HostTarget->getLongLongWidth();
+LongLongAlign = HostTarget->getLongLongAlign();
+MinGlobalAlign = HostTarget->getMinGlobalAlign();
+DefaultAlignForAttributeAligned =
+HostTarget->getDefaultAlignForAttributeAligned();
+SizeType = HostTarget->getSizeType();
+IntMaxType = HostTarget->getIntMaxType();
+PtrDiffType = HostTarget->getPtrDiffType(/* AddrSpace = */ 0);
+IntPtrType = HostTarget->getIntPtrType();
+WCharType = HostTarget->getWCharType();
+WIntType = HostTarget->getWIntType();
+Char16Type = HostTarget->getChar16Type();
+Char32Type = HostTarget->getChar32Type();
+Int64Type = HostTarget->getInt64Type();
+SigAtomicType = HostTarget->getSigAtomicType();
+ProcessIDType = HostTarget->getProcessIDType();
+
+UseBitFieldTypeAlignment = HostTarget->useBitFieldTypeAlignment();
+UseZeroLengthBitfieldAlignment =
+HostTarget->useZeroLengthBitfieldAlignment();
+UseExplicitBitFieldAlignment = HostTarget->useExplicitBitFieldAlignment();
+ZeroLengthBitfieldBoundary = HostTarget->getZeroLengthBitfieldBoundary();
+

I think we need to do more to make sure this list of fields is kept up to date 
as more of these values are added or changed.

Possible idea: could we have a test that builds with `-E -dM` in both host and 
device mode, greps for the `__*_TYPE__`, `__*_MAX__` (etc) predefines, and 
compares them across the two runs?


http://reviews.llvm.org/D19346



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


Re: [PATCH] D19687: Set PIELevel module flag

2016-04-28 Thread Reid Kleckner via cfe-commits
rnk added a comment.

still lgtm



Comment at: lib/CodeGen/CodeGenModule.cpp:480
@@ -479,8 +479,3 @@
   if (uint32_t PLevel = Context.getLangOpts().PICLevel) {
-llvm::PICLevel::Level PL = llvm::PICLevel::Default;
-switch (PLevel) {
-case 0: break;
-case 1: PL = llvm::PICLevel::Small; break;
-case 2: PL = llvm::PICLevel::Large; break;
-default: llvm_unreachable("Invalid PIC Level");
-}
+assert (PLevel < 3 && "Invalid PIC Level");
+getModule().setPICLevel(static_cast(PLevel));

formatting nit: no space between 'assert' and '('


http://reviews.llvm.org/D19687



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


Re: [PATCH] D19346: [CUDA] Copy host builtin types to NVPTXTargetInfo.

2016-04-28 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: lib/Basic/Targets.cpp:1642
@@ +1641,3 @@
+
+std::unique_ptr HostTarget(
+AllocateTarget(llvm::Triple(Opts.HostTriple), Opts));

You may want to make sure we don't recurse here if someone specifies host 
triple to be one of NVPTX variants.


http://reviews.llvm.org/D19346



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


Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-04-28 Thread John McCall via cfe-commits
rjmccall added a comment.

In http://reviews.llvm.org/D19678#416059, @hfinkel wrote:

> In http://reviews.llvm.org/D19678#415844, @rjmccall wrote:
>
> > I see what you're going for with "listing file", but I like ICC's option 
> > name much better, or at least something along those lines.
>
>
> Sounds good to me. Do you have a preference on -fopt-report vs. 
> -foptimization-report vs. something else? Do you have an opinion on the 
> default file-name extension for the report? Maybe I should name it 
> .opt-report (or something like that)?


I don't think we have a consistent abbreviation for that anywhere else in the 
options (other than -O, I guess), so my inclination would be to spell it out as 
-foptimization-report.

The extension is just appended to the original filename, so that it ends up 
something like foo.cpp.opt-report?  I don't have an objection to ".opt-report" 
or even ".lst".


http://reviews.llvm.org/D19678



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


[PATCH] D19693: [Clang][Darwin] Define __ARM_DWARF_EH__ for WatchABI

2016-04-28 Thread Chris Bieneman via cfe-commits
beanz created this revision.
beanz added a reviewer: t.p.northover.
beanz added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

The Darwin armv7k ABI uses Dwarf EH, so we need to set the OS define correctly. 
Without this the gcc_personality fails to build.

http://reviews.llvm.org/D19693

Files:
  lib/Basic/Targets.cpp

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -208,6 +208,10 @@
   if (Triple.isOSDarwin())
 Builder.defineMacro("__MACH__");
 
+  // The Watch ABI uses Dwarf EH.
+  if(Triple.isWatchABI())
+Builder.defineMacro("__ARM_DWARF_EH__");
+
   PlatformMinVersion = VersionTuple(Maj, Min, Rev);
 }
 
@@ -4931,7 +4935,7 @@
 Builder.defineMacro("__ARM_FP16_ARGS", "1");
 
 // ACLE 6.5.3 Fused multiply-accumulate (FMA)
-if (ArchVersion >= 7 && (FPU & VFP4FPU))
+if (ArchVersion >= 7 && (CPUProfile != "M" || CPUAttr == "7EM"))
   Builder.defineMacro("__ARM_FEATURE_FMA", "1");
 
 // Subtarget options.
@@ -4948,11 +4952,10 @@
   if (!getTriple().isOSDarwin() && !getTriple().isOSWindows())
 Builder.defineMacro("__ARM_EABI__");
   Builder.defineMacro("__ARM_PCS", "1");
-}
 
-if ((!SoftFloat && !SoftFloatABI) || ABI == "aapcs-vfp" ||
-ABI == "aapcs16")
-  Builder.defineMacro("__ARM_PCS_VFP", "1");
+  if ((!SoftFloat && !SoftFloatABI) || ABI == "aapcs-vfp")
+Builder.defineMacro("__ARM_PCS_VFP", "1");
+}
 
 if (SoftFloat)
   Builder.defineMacro("__SOFTFP__");
@@ -6549,16 +6552,6 @@
 .Default(false);
   }
 
-  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
-switch (CC) {
-case CC_C:
-case CC_Swift:
-  return CCCR_OK;
-default:
-  return CCCR_Warning;
-}
-  }
-
   StringRef getABI() const override {
 if (HasVector)
   return "vector";


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -208,6 +208,10 @@
   if (Triple.isOSDarwin())
 Builder.defineMacro("__MACH__");
 
+  // The Watch ABI uses Dwarf EH.
+  if(Triple.isWatchABI())
+Builder.defineMacro("__ARM_DWARF_EH__");
+
   PlatformMinVersion = VersionTuple(Maj, Min, Rev);
 }
 
@@ -4931,7 +4935,7 @@
 Builder.defineMacro("__ARM_FP16_ARGS", "1");
 
 // ACLE 6.5.3 Fused multiply-accumulate (FMA)
-if (ArchVersion >= 7 && (FPU & VFP4FPU))
+if (ArchVersion >= 7 && (CPUProfile != "M" || CPUAttr == "7EM"))
   Builder.defineMacro("__ARM_FEATURE_FMA", "1");
 
 // Subtarget options.
@@ -4948,11 +4952,10 @@
   if (!getTriple().isOSDarwin() && !getTriple().isOSWindows())
 Builder.defineMacro("__ARM_EABI__");
   Builder.defineMacro("__ARM_PCS", "1");
-}
 
-if ((!SoftFloat && !SoftFloatABI) || ABI == "aapcs-vfp" ||
-ABI == "aapcs16")
-  Builder.defineMacro("__ARM_PCS_VFP", "1");
+  if ((!SoftFloat && !SoftFloatABI) || ABI == "aapcs-vfp")
+Builder.defineMacro("__ARM_PCS_VFP", "1");
+}
 
 if (SoftFloat)
   Builder.defineMacro("__SOFTFP__");
@@ -6549,16 +6552,6 @@
 .Default(false);
   }
 
-  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
-switch (CC) {
-case CC_C:
-case CC_Swift:
-  return CCCR_OK;
-default:
-  return CCCR_Warning;
-}
-  }
-
   StringRef getABI() const override {
 if (HasVector)
   return "vector";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19048: Test for a module related crash in CGDebugInfo.cpp

2016-04-28 Thread Douglas Yung via cfe-commits
dyung updated this revision to Diff 55495.
dyung added a comment.

Fixed up test and check for that DIImportedEntity and DIModule are present in 
the generated output.


http://reviews.llvm.org/D19048

Files:
  test/Modules/Inputs/getSourceDescriptor-crash/h1.h
  test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
  test/Modules/getSourceDescriptor-crash.cpp

Index: test/Modules/getSourceDescriptor-crash.cpp
===
--- test/Modules/getSourceDescriptor-crash.cpp
+++ test/Modules/getSourceDescriptor-crash.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -I %S/Inputs/getSourceDescriptor-crash -S -emit-llvm 
-debug-info-kind=limited -fimplicit-module-maps %s -o - | FileCheck %s
+
+#include "h1.h"
+#include "h1.h"
+
+// CHECK: DIImportedEntity
+// CHECK: DIModule
+// CHECK-SAME: name: "foo"
Index: test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
===
--- test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
+++ test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
@@ -0,0 +1,3 @@
+module foo {
+   header "h1.h"
+}
Index: test/Modules/Inputs/getSourceDescriptor-crash/h1.h
===
--- test/Modules/Inputs/getSourceDescriptor-crash/h1.h
+++ test/Modules/Inputs/getSourceDescriptor-crash/h1.h
@@ -0,0 +1 @@
+#pragma once


Index: test/Modules/getSourceDescriptor-crash.cpp
===
--- test/Modules/getSourceDescriptor-crash.cpp
+++ test/Modules/getSourceDescriptor-crash.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -I %S/Inputs/getSourceDescriptor-crash -S -emit-llvm -debug-info-kind=limited -fimplicit-module-maps %s -o - | FileCheck %s
+
+#include "h1.h"
+#include "h1.h"
+
+// CHECK: DIImportedEntity
+// CHECK: DIModule
+// CHECK-SAME: name: "foo"
Index: test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
===
--- test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
+++ test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
@@ -0,0 +1,3 @@
+module foo {
+   header "h1.h"
+}
Index: test/Modules/Inputs/getSourceDescriptor-crash/h1.h
===
--- test/Modules/Inputs/getSourceDescriptor-crash/h1.h
+++ test/Modules/Inputs/getSourceDescriptor-crash/h1.h
@@ -0,0 +1 @@
+#pragma once
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-04-28 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Driver/ToolChains.cpp:722-733
@@ -700,1 +721,14 @@
+
+  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_sysroot)
+<< SDK << getPlatformFamily();
+}
+  }
 }

Can you share some of the code between the parsing the SDK version out of 
`-isysroot` here and above?


http://reviews.llvm.org/D18088



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


Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-04-28 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

In http://reviews.llvm.org/D19678#415844, @rjmccall wrote:

> I see what you're going for with "listing file", but I like ICC's option name 
> much better, or at least something along those lines.


Sounds good to me. Do you have a preference on -fopt-report vs. 
-foptimization-report vs. something else? Do you have an opinion on the default 
file-name extension for the report? Maybe I should name it .opt-report (or 
something like that)?


http://reviews.llvm.org/D19678



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


Re: [PATCH] D19175: Fix for PR27015 (variable template initialized with a generic lambda expression)

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

LGTM, thanks!


http://reviews.llvm.org/D19175



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


Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-04-28 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

In http://reviews.llvm.org/D19678#415902, @rsmith wrote:

> You give this example:
>
> >   343 | Loc = ConvertBackendLocation(D, 
> > Context->getSourceManager());
>
> >   I   |   ^
>
> >   I   | ^
>
>
> How does this look for a case like `p->Foo()->Bar()` (where one or both of 
> the calls are inlined)? Can we get the source location to point at the 
> function name instead of the start of the expression to reduce the scope for 
> ambiguity?


That does not currently work very well (I assume this needs a backend fix, but 
I'll check).

  $ cat /tmp/i.cpp
  void ext();
  
  struct Bar {
void bar() { ext(); }
  };
  
  struct Foo {
Bar *b;
  
Bar *foo() { return b; }
  };
  
  void test(Foo *f) {
f->foo()->bar();
  }

And we get:

  14 I   |   f->foo()->bar();

because both inlining remarks come from the backend with the same column number:

  $ clang -O3 -c -o /tmp/i.o /tmp/i.cpp -flisting -Rpass=inline
  /tmp/i.cpp:14:3: remark: _ZN3Foo3fooEv inlined into _Z4testP3Foo 
[-Rpass=inline]
f->foo()->bar();
^
  /tmp/i.cpp:14:3: remark: _ZN3Bar3barEv inlined into _Z4testP3Foo 
[-Rpass=inline]



Comment at: lib/CodeGen/CodeGenAction.cpp:665-761
@@ +664,99 @@
+
+void BackendConsumer::GenerateListingFile() {
+  if (CodeGenOpts.ListingFile.empty())
+return;
+
+  std::error_code EC;
+  llvm::raw_fd_ostream OS(CodeGenOpts.ListingFile, EC,
+  llvm::sys::fs::F_Text);
+  if (EC) {
+Diags.Report(diag::err_fe_error_opening) << CodeGenOpts.ListingFile <<
+EC.message();
+return;
+  }
+
+  SourceManager  = Context->getSourceManager();
+  std::set FileIDs;
+  for (auto  : ListingInfo)
+FileIDs.insert(SourceMgr.getFileID(I.first));
+
+  for (auto  : FileIDs) {
+SourceLocation FirstLoc = SourceMgr.getLocForStartOfFile(FID);
+OS << "< " << SourceMgr.getFilename(FirstLoc) << "\n";
+
+auto I = ListingInfo.lower_bound(FirstLoc);
+StringRef MB = SourceMgr.getBufferData(FID);
+const SrcMgr::ContentCache *
+  Content = SourceMgr.getSLocEntry(FID).getFile().getContentCache();
+unsigned LNDigits = llvm::utostr(Content->NumLines).size();
+for (unsigned L = 0; L < Content->NumLines - 1; ++L) {
+  unsigned LStartOff = Content->SourceLineCache[L];
+  unsigned LEndOff = (L == Content->NumLines) ?
+ Content->getSize() :
+ Content->SourceLineCache[L + 1];
+
+  std::map ColsInfo;
+  unsigned InlinedCols = 0, UnrolledCols = 0, VectorizedCols = 0;
+
+  ListingLineInfo LLI;
+  if (I != ListingInfo.end()) {
+auto DI = SourceMgr.getDecomposedLoc(I->first);
+while (I != ListingInfo.end() && DI.first == FID &&
+   DI.second < LStartOff) {
+  ++I;
+  if (I != ListingInfo.end())
+DI = SourceMgr.getDecomposedLoc(I->first);
+}
+
+while (I != ListingInfo.end() && DI.first == FID &&
+DI.second >= LStartOff && DI.second < LEndOff) {
+  unsigned Col = SourceMgr.getColumnNumber(FID, DI.second);
+  ColsInfo[Col] = I->second;
+  InlinedCols += I->second.Inlined.Analyzed;
+  UnrolledCols += I->second.Unrolled.Analyzed;
+  VectorizedCols += I->second.Vectorized.Analyzed;
+  LLI |= I->second;
+
+  ++I;
+  if (I != ListingInfo.end())
+DI = SourceMgr.getDecomposedLoc(I->first);
+}
+  }
+
+  // We try to keep the output as concise as possible. If only one thing on
+  // a given line could have been inlined, vectorized, etc. then we can put
+  // the marker on the source line itself. If there are multiple options
+  // then we want to distinguish them by placing the marker for each
+  // transformation on a separate line following the source line. When we
+  // do this, we use a '^' character to point to the appropriate column in
+  // the source line.
+
+  OS << llvm::format_decimal(L + 1, LNDigits) << " ";
+  OS << (LLI.Inlined.Transformed && InlinedCols < 2 ? "I" : " ");
+  OS << (LLI.Unrolled.Transformed && UnrolledCols < 2 ? "U" : " ");
+  OS << (LLI.Vectorized.Transformed && VectorizedCols < 2 ? "V" : " ");
+
+  OS << " | " << MB.slice(LStartOff, LEndOff);
+
+  for (auto  : ColsInfo) {
+if ((J.second.Inlined.Transformed && InlinedCols > 1) ||
+(J.second.Unrolled.Transformed && UnrolledCols > 1) ||
+(J.second.Vectorized.Transformed && VectorizedCols > 1)) {
+  OS << std::string(LNDigits + 1, ' ');
+  OS << (J.second.Inlined.Transformed &&
+ InlinedCols > 1 ? "I" : " ");
+  OS << (J.second.Unrolled.Transformed &&
+ UnrolledCols > 1 ? "U" : " ");
+  OS << (J.second.Vectorized.Transformed &&
+ VectorizedCols > 

Re: [PATCH] D19346: [CUDA] Copy host builtin types to NVPTXTargetInfo.

2016-04-28 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Richard, friendly ping?


http://reviews.llvm.org/D19346



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


Re: [PATCH] D19175: Fix for PR27015 (variable template initialized with a generic lambda expression)

2016-04-28 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 55484.
ahatanak added a comment.

- Defined a private overload of Scope::setFlags which is called from 
Scope::setFlags and Scope::Init.
- Stop checking TmplScope->isTemplateParamScope() in 
Sema::ActOnStartOfLambdaDefinition.
- Fix test case test/CXX/drs/dr1xx.cpp to check an error message (not a 
warning) is printed when it's compiled with -std=c++98.


http://reviews.llvm.org/D19175

Files:
  include/clang/Sema/Scope.h
  lib/Parse/ParseTemplate.cpp
  lib/Sema/Scope.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CXX/drs/dr1xx.cpp
  test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  test/SemaCXX/vartemplate-lambda.cpp

Index: test/SemaCXX/vartemplate-lambda.cpp
===
--- /dev/null
+++ test/SemaCXX/vartemplate-lambda.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+template  auto fn0 = [] {};
+template  void foo0() { fn0(); }
+
+template auto fn1 = [](auto a) { return a + T(1); };
+
+template 
+int foo2() {
+  X a = 0x61;
+  fn1(a);
+  return 0;
+}
+
+int main() {
+  foo2();
+}
Index: test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
===
--- test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
+++ test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
@@ -195,7 +195,7 @@
 namespace default_args {
 #ifdef CPP11ONLY
 namespace lambdas {
-template //expected-error 2{{constant expression}} expected-note{{constant expression}}
+template //expected-error {{constant expression}}
 int f();
 }
 #endif // CPP11ONLY
Index: test/CXX/drs/dr1xx.cpp
===
--- test/CXX/drs/dr1xx.cpp
+++ test/CXX/drs/dr1xx.cpp
@@ -902,7 +902,11 @@
 typedef int X;
   };
   template<> struct A {
+#if __cplusplus <= 199711
+typename B::X x; // expected-error {{'typename' occurs outside of a template}}
+#else
 typename B::X x;
+#endif
   };
 }
 
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3907,9 +3907,14 @@
   PushExpressionEvaluationContext(Sema::PotentiallyEvaluated, OldVar);
 
 // Instantiate the initializer.
-ExprResult Init =
-SubstInitializer(OldVar->getInit(), TemplateArgs,
- OldVar->getInitStyle() == VarDecl::CallInit);
+ExprResult Init;
+
+{
+  ContextRAII SwitchContext(*this, Var->getDeclContext());
+  Init = SubstInitializer(OldVar->getInit(), TemplateArgs,
+  OldVar->getInitStyle() == VarDecl::CallInit);
+}
+
 if (!Init.isInvalid()) {
   bool TypeMayContainAuto = true;
   Expr *InitExpr = Init.get();
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -814,9 +814,8 @@
   // The lambda-expression's closure type might be dependent even if its
   // semantic context isn't, if it appears within a default argument of a
   // function template.
-  if (Scope *TmplScope = CurScope->getTemplateParamParent())
-if (!TmplScope->decl_empty())
-  KnownDependent = true;
+  if (CurScope->getTemplateParamParent())
+KnownDependent = true;
 
   // Determine the signature of the call operator.
   TypeSourceInfo *MethodTyInfo;
Index: lib/Sema/Scope.cpp
===
--- lib/Sema/Scope.cpp
+++ lib/Sema/Scope.cpp
@@ -18,7 +18,7 @@
 
 using namespace clang;
 
-void Scope::Init(Scope *parent, unsigned flags) {
+void Scope::setFlags(Scope *parent, unsigned flags) {
   AnyParent = parent;
   Flags = flags;
 
@@ -83,6 +83,10 @@
 else
   incrementMSManglingNumber();
   }
+}
+
+void Scope::Init(Scope *parent, unsigned flags) {
+  setFlags(parent, flags);
 
   DeclsInScope.clear();
   UsingDirectives.clear();
Index: lib/Parse/ParseTemplate.cpp
===
--- lib/Parse/ParseTemplate.cpp
+++ lib/Parse/ParseTemplate.cpp
@@ -147,6 +147,9 @@
 }
   } while (Tok.isOneOf(tok::kw_export, tok::kw_template));
 
+  unsigned NewFlags = getCurScope()->getFlags() & ~Scope::TemplateParamScope;
+  ParseScopeFlags TemplateScopeFlags(this, NewFlags, isSpecialization);
+
   // Parse the actual template declaration.
   return ParseSingleDeclarationAfterTemplate(Context,
  ParsedTemplateInfo(,
Index: include/clang/Sema/Scope.h
===
--- include/clang/Sema/Scope.h
+++ include/clang/Sema/Scope.h
@@ -197,6 +197,8 @@
   /// this scope, or over-defined. The bit is true when over-defined.
   llvm::PointerIntPair NRVO;
 
+  void setFlags(Scope *Parent, unsigned F);
+
 public:
   

r267942 - [clang][AVX512][Builtin] Adding intrinsics for the SAD instruction set.

2016-04-28 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Thu Apr 28 16:21:08 2016
New Revision: 267942

URL: http://llvm.org/viewvc/llvm-project?rev=267942=rev
Log:
[clang][AVX512][Builtin] Adding intrinsics for the SAD instruction set.

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=267942=267941=267942=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Apr 28 16:21:08 2016
@@ -2214,6 +2214,10 @@ TARGET_BUILTIN(__builtin_ia32_movntps512
 TARGET_BUILTIN(__builtin_ia32_palignr512_mask, 
"V64cV64cV64ciV64cULLi","","avx512bw")
 TARGET_BUILTIN(__builtin_ia32_palignr128_mask, 
"V16cV16cV16ciV16cUs","","avx512bw,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_palignr256_mask, 
"V32cV32cV32ciV32cUi","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_dbpsadbw128_mask, 
"V8sV16cV16cIiV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_dbpsadbw256_mask, 
"V16sV32cV32cIiV16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_dbpsadbw512_mask, 
"V32sV64cV64cIiV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_psadbw512, "V8LLiV64cV64c","","avx512bw")
 
 
 #undef BUILTIN

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=267942=267941=267942=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Thu Apr 28 16:21:08 2016
@@ -2191,6 +2191,39 @@ __builtin_ia32_palignr512_mask ((__v8di)
  (__mmask64) __U);\
 })
 
+#define _mm512_dbsad_epu8( __A,  __B, __imm) __extension__ ({\
+__builtin_ia32_dbpsadbw512_mask ((__v64qi) __A,\
+(__v64qi) __B,\
+__imm,\
+(__v32hi) _mm512_undefined_epi32(),\
+(__mmask32) -1);\
+})
+
+#define _mm512_mask_dbsad_epu8( __W, __U, __A, __B, __imm) ({\
+__builtin_ia32_dbpsadbw512_mask ((__v64qi) __A,\
+(__v64qi) __B,\
+__imm,\
+(__v32hi) __W,\
+(__mmask32) __U);\
+})
+
+#define _mm512_maskz_dbsad_epu8( __U, __A, __B, __imm) ({\
+__builtin_ia32_dbpsadbw512_mask ((__v64qi) __A,\
+(__v64qi) __B,\
+__imm,\
+(__v32hi) _mm512_setzero_hi(),\
+(__mmask32) __U);\
+})
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_sad_epu8 (__m512i __A, __m512i __B)
+{
+ return (__m512i) __builtin_ia32_psadbw512 ((__v64qi) __A,
+   (__v64qi) __B);
+}
+
+
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif

Modified: cfe/trunk/lib/Headers/avx512vlbwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlbwintrin.h?rev=267942=267941=267942=diff
==
--- cfe/trunk/lib/Headers/avx512vlbwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlbwintrin.h Thu Apr 28 16:21:08 2016
@@ -3392,6 +3392,54 @@ __builtin_ia32_palignr256_mask ((__v4di)
(__mmask32)( __U));\
 })
 
+#define _mm_dbsad_epu8( __A, __B, __imm) __extension__ ({ \
+__builtin_ia32_dbpsadbw128_mask ((__v16qi)( __A),\
+(__v16qi)( __B),\
+( __imm),\
+(__v8hi) _mm_setzero_hi (),\
+(__mmask8) -1);\
+})
+
+#define _mm_mask_dbsad_epu8( __W, __U, __A, __B, __imm) __extension__ ({ \
+__builtin_ia32_dbpsadbw128_mask ((__v16qi)( __A),\
+(__v16qi)( __B),\
+( __imm),\
+(__v8hi)( __W),\
+(__mmask8)( __U));\
+})
+
+#define _mm_maskz_dbsad_epu8( __U, __A, __B, __imm) __extension__ ({ \
+__builtin_ia32_dbpsadbw128_mask ((__v16qi)( __A),\
+(__v16qi)( __B),\
+( __imm),\
+(__v8hi) _mm_setzero_si128 (),\
+(__mmask8)( __U));\
+})
+
+#define _mm256_dbsad_epu8( __A, __B, __imm) __extension__ ({ \
+__builtin_ia32_dbpsadbw256_mask ((__v32qi)( __A),\
+(__v32qi)( __B),\
+( __imm),\
+(__v16hi) _mm256_setzero_si256 (),\
+(__mmask16) -1);\
+})
+
+#define _mm256_mask_dbsad_epu8( __W, __U, __A, __B, __imm) __extension__ ({ \
+__builtin_ia32_dbpsadbw256_mask ((__v32qi)( __A),\
+(__v32qi)( __B),\

Re: [PATCH] D19385: [scan-build] fix logic error warnings emitted on clang code base

2016-04-28 Thread Apelete Seketeli via cfe-commits
apelete added a comment.

Thanks for your reviews.


http://reviews.llvm.org/D19385



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


Re: [PATCH] D19385: [scan-build] fix logic error warnings emitted on clang code base

2016-04-28 Thread Apelete Seketeli via cfe-commits
apelete updated this revision to Diff 55487.
apelete marked 3 inline comments as done.
apelete added a comment.

[scan-build] fix logic error warnings emitted on clang code base

Changes since last revision:

- lib/Format/AffectedRangeManager.cpp: fix the call to 
AffectedRangeManager::nonPPLineAffected() from 
AffectedRangeManager::computeAffectedLines() that was left out of previous 
revision somehow.


http://reviews.llvm.org/D19385

Files:
  lib/AST/DeclObjC.cpp
  lib/Format/AffectedRangeManager.cpp
  lib/Format/AffectedRangeManager.h
  lib/Frontend/CompilerInstance.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaLookup.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -297,6 +297,7 @@
   if (!Diags.empty())
 SM = ()->path.front()->getLocation().getManager();
 
+  assert(SM && "SourceManager is NULL, cannot iterate through the diagnostics");
 
   for (std::vector::iterator DI = Diags.begin(),
DE = Diags.end(); DI != DE; ++DI) {
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3744,6 +3744,7 @@
   bool AnyVisibleDecls = !NewDecls.empty();
 
   for (/**/; DI != DE; ++DI) {
+assert(*DI && "TypoCorrection iterator cannot be NULL");
 NamedDecl *VisibleDecl = *DI;
 if (!LookupResult::isVisible(SemaRef, *DI))
   VisibleDecl = findAcceptableDecl(SemaRef, *DI);
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -398,8 +398,10 @@
 SourceLocation TypeidLoc,
 Expr *E,
 SourceLocation RParenLoc) {
+  assert(E && "expression operand is NULL, cannot build C++ typeid expression");
+
   bool WasEvaluated = false;
-  if (E && !E->isTypeDependent()) {
+  if (!E->isTypeDependent()) {
 if (E->getType()->isPlaceholderType()) {
   ExprResult result = CheckPlaceholderExpr(E);
   if (result.isInvalid()) return ExprError();
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -742,7 +742,7 @@
 
   // Figure out where to get and map in the main file.
   if (InputFile != "-") {
-const FileEntry *File;
+const FileEntry *File = nullptr;
 if (Opts.FindPchSource.empty()) {
   File = FileMgr.getFile(InputFile, /*OpenFile=*/true);
 } else {
@@ -760,13 +760,14 @@
   SmallVector
   Includers;
   Includers.push_back(std::make_pair(FindFile, FindFile->getDir()));
-  File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
-/*FromDir=*/nullptr,
-/*CurDir=*/UnusedCurDir, Includers,
-/*SearchPath=*/nullptr,
-/*RelativePath=*/nullptr,
-/*RequestingModule=*/nullptr,
-/*SuggestedModule=*/nullptr, /*SkipCache=*/true);
+  if (HS)
+File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
+  /*FromDir=*/nullptr,
+  /*CurDir=*/UnusedCurDir, Includers,
+  /*SearchPath=*/nullptr,
+  /*RelativePath=*/nullptr,
+  /*RequestingModule=*/nullptr,
+  /*SuggestedModule=*/nullptr, /*SkipCache=*/true);
   // Also add the header to /showIncludes output.
   if (File)
 DepOpts.ShowIncludesPretendHeader = File->getName();
Index: lib/Format/AffectedRangeManager.h
===
--- lib/Format/AffectedRangeManager.h
+++ lib/Format/AffectedRangeManager.h
@@ -54,7 +54,7 @@
 
   // Determines whether 'Line' is affected by the SourceRanges given as input.
   // Returns \c true if line or one if its children is affected.
-  bool nonPPLineAffected(AnnotatedLine *Line,
+  bool nonPPLineAffected(AnnotatedLine ,
  const AnnotatedLine *PreviousLine);
   SourceManager 
   const SmallVector Ranges;
Index: lib/Format/AffectedRangeManager.cpp
===
--- lib/Format/AffectedRangeManager.cpp
+++ lib/Format/AffectedRangeManager.cpp
@@ -48,7 +48,7 @@
   continue;
 }
 
-if (nonPPLineAffected(Line, PreviousLine))
+if (nonPPLineAffected(*Line, PreviousLine))
   SomeLineAffected = true;
 
 PreviousLine = Line;
@@ -98,25 +98,28 @@
   }
 }
 
-bool 

Re: [PATCH] D19385: [scan-build] fix logic error warnings emitted on clang code base

2016-04-28 Thread Apelete Seketeli via cfe-commits
apelete updated this revision to Diff 55483.
apelete added a comment.

[scan-build] fix logic error warnings emitted on clang code base

Changes since last revison:

- lib/Format/AffectedRangeManager.h: fix declaration of nonPPLineAffected() to 
pass a reference to AnnotatedLine as first parameter.

- lib/Format/AffectedRangeManager.cpp: fix nonPPLineAffected() definition 
accordingly.


http://reviews.llvm.org/D19385

Files:
  lib/AST/DeclObjC.cpp
  lib/Format/AffectedRangeManager.cpp
  lib/Format/AffectedRangeManager.h
  lib/Frontend/CompilerInstance.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaLookup.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -297,6 +297,7 @@
   if (!Diags.empty())
 SM = ()->path.front()->getLocation().getManager();
 
+  assert(SM && "SourceManager is NULL, cannot iterate through the diagnostics");
 
   for (std::vector::iterator DI = Diags.begin(),
DE = Diags.end(); DI != DE; ++DI) {
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3744,6 +3744,7 @@
   bool AnyVisibleDecls = !NewDecls.empty();
 
   for (/**/; DI != DE; ++DI) {
+assert(*DI && "TypoCorrection iterator cannot be NULL");
 NamedDecl *VisibleDecl = *DI;
 if (!LookupResult::isVisible(SemaRef, *DI))
   VisibleDecl = findAcceptableDecl(SemaRef, *DI);
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -398,8 +398,10 @@
 SourceLocation TypeidLoc,
 Expr *E,
 SourceLocation RParenLoc) {
+  assert(E && "expression operand is NULL, cannot build C++ typeid expression");
+
   bool WasEvaluated = false;
-  if (E && !E->isTypeDependent()) {
+  if (!E->isTypeDependent()) {
 if (E->getType()->isPlaceholderType()) {
   ExprResult result = CheckPlaceholderExpr(E);
   if (result.isInvalid()) return ExprError();
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -742,7 +742,7 @@
 
   // Figure out where to get and map in the main file.
   if (InputFile != "-") {
-const FileEntry *File;
+const FileEntry *File = nullptr;
 if (Opts.FindPchSource.empty()) {
   File = FileMgr.getFile(InputFile, /*OpenFile=*/true);
 } else {
@@ -760,13 +760,14 @@
   SmallVector
   Includers;
   Includers.push_back(std::make_pair(FindFile, FindFile->getDir()));
-  File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
-/*FromDir=*/nullptr,
-/*CurDir=*/UnusedCurDir, Includers,
-/*SearchPath=*/nullptr,
-/*RelativePath=*/nullptr,
-/*RequestingModule=*/nullptr,
-/*SuggestedModule=*/nullptr, /*SkipCache=*/true);
+  if (HS)
+File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
+  /*FromDir=*/nullptr,
+  /*CurDir=*/UnusedCurDir, Includers,
+  /*SearchPath=*/nullptr,
+  /*RelativePath=*/nullptr,
+  /*RequestingModule=*/nullptr,
+  /*SuggestedModule=*/nullptr, /*SkipCache=*/true);
   // Also add the header to /showIncludes output.
   if (File)
 DepOpts.ShowIncludesPretendHeader = File->getName();
Index: lib/Format/AffectedRangeManager.h
===
--- lib/Format/AffectedRangeManager.h
+++ lib/Format/AffectedRangeManager.h
@@ -54,7 +54,7 @@
 
   // Determines whether 'Line' is affected by the SourceRanges given as input.
   // Returns \c true if line or one if its children is affected.
-  bool nonPPLineAffected(AnnotatedLine *Line,
+  bool nonPPLineAffected(AnnotatedLine ,
  const AnnotatedLine *PreviousLine);
   SourceManager 
   const SmallVector Ranges;
Index: lib/Format/AffectedRangeManager.cpp
===
--- lib/Format/AffectedRangeManager.cpp
+++ lib/Format/AffectedRangeManager.cpp
@@ -98,25 +98,28 @@
   }
 }
 
-bool AffectedRangeManager::nonPPLineAffected(
-AnnotatedLine *Line, const AnnotatedLine *PreviousLine) {
+bool AffectedRangeMLanager::nonPPLineAffected(
+AnnotatedLine , const AnnotatedLine *PreviousLine) {
   bool SomeLineAffected = false;
-  

[PATCH] D19689: Add Subjects to NoDebugAttr [NFC]

2016-04-28 Thread Paul Robinson via cfe-commits
probinson created this revision.
probinson added a reviewer: aaron.ballman.
probinson added a subscriber: cfe-commits.

The 'nodebug' attribute had hand-coded constraints; replace those with a 
Subjects line in Attr.td.
Also add a missing test to verify the attribute is okay on an Objective-C 
method.

http://reviews.llvm.org/D19689

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/attr-nodebug.c
  test/SemaObjC/attr-nodebug.m

Index: test/SemaObjC/attr-nodebug.m
===
--- test/SemaObjC/attr-nodebug.m
+++ test/SemaObjC/attr-nodebug.m
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+@interface NSObject
+- (void)doSomething __attribute__((nodebug));
+@end
Index: test/Sema/attr-nodebug.c
===
--- test/Sema/attr-nodebug.c
+++ test/Sema/attr-nodebug.c
@@ -3,7 +3,7 @@
 int a __attribute__((nodebug));
 
 void b() {
-  int b __attribute__((nodebug)); // expected-warning {{'nodebug' only applies 
to variables with static storage duration and functions}}
+  int b __attribute__((nodebug)); // expected-warning {{'nodebug' attribute 
only applies to functions and global variables}}
 }
 
 void t1() __attribute__((nodebug));
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3572,18 +3572,6 @@
 }
 
 static void handleNoDebugAttr(Sema , Decl *D, const AttributeList ) {
-  if (const VarDecl *VD = dyn_cast(D)) {
-if (!VD->hasGlobalStorage())
-  S.Diag(Attr.getLoc(),
- diag::warn_attribute_requires_functions_or_static_globals)
-<< Attr.getName();
-  } else if (!isFunctionOrMethod(D)) {
-S.Diag(Attr.getLoc(),
-   diag::warn_attribute_requires_functions_or_static_globals)
-  << Attr.getName();
-return;
-  }
-
   D->addAttr(::new (S.Context)
  NoDebugAttr(Attr.getRange(), S.Context,
  Attr.getAttributeSpellingListIndex()));
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2504,9 +2504,6 @@
 def warn_incomplete_encoded_type : Warning<
   "encoding of %0 type is incomplete because %1 component has unknown 
encoding">,
   InGroup>;
-def warn_attribute_requires_functions_or_static_globals : Warning<
-  "%0 only applies to variables with static storage duration and functions">,
-  InGroup;
 def warn_gnu_inline_attribute_requires_inline : Warning<
   "'gnu_inline' attribute requires function to be marked 'inline',"
   " attribute ignored">,
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -973,6 +973,8 @@
 
 def NoDebug : InheritableAttr {
   let Spellings = [GCC<"nodebug">];
+  let Subjects = SubjectList<[FunctionLike, ObjCMethod, GlobalVar], WarnDiag,
+  "ExpectedFunctionGlobalVarMethodOrProperty">;
   let Documentation = [NoDebugDocs];
 }
 


Index: test/SemaObjC/attr-nodebug.m
===
--- test/SemaObjC/attr-nodebug.m
+++ test/SemaObjC/attr-nodebug.m
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+@interface NSObject
+- (void)doSomething __attribute__((nodebug));
+@end
Index: test/Sema/attr-nodebug.c
===
--- test/Sema/attr-nodebug.c
+++ test/Sema/attr-nodebug.c
@@ -3,7 +3,7 @@
 int a __attribute__((nodebug));
 
 void b() {
-  int b __attribute__((nodebug)); // expected-warning {{'nodebug' only applies to variables with static storage duration and functions}}
+  int b __attribute__((nodebug)); // expected-warning {{'nodebug' attribute only applies to functions and global variables}}
 }
 
 void t1() __attribute__((nodebug));
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3572,18 +3572,6 @@
 }
 
 static void handleNoDebugAttr(Sema , Decl *D, const AttributeList ) {
-  if (const VarDecl *VD = dyn_cast(D)) {
-if (!VD->hasGlobalStorage())
-  S.Diag(Attr.getLoc(),
- diag::warn_attribute_requires_functions_or_static_globals)
-<< Attr.getName();
-  } else if (!isFunctionOrMethod(D)) {
-S.Diag(Attr.getLoc(),
-   diag::warn_attribute_requires_functions_or_static_globals)
-  << Attr.getName();
-return;
-  }
-
   D->addAttr(::new (S.Context)
  NoDebugAttr(Attr.getRange(), S.Context,
  

Re: [PATCH] D19048: Test for a module related crash in CGDebugInfo.cpp

2016-04-28 Thread Douglas Yung via cfe-commits
dyung added inline comments.


Comment at: test/Modules/getSourceDescriptor-crash.cpp:6
@@ +5,2 @@
+
+// CHECK: DIModule2

aprantl wrote:
> This doesn't actually appear in the output :-)
> You probably want to at least check for the correct name of the module and 
> for the DIImportedEntity.
Whoops! That was me trying to get it to fail to convince myself it was working 
and forgot to change it back. I'll restore it and modify the check to what you 
suggested. Thanks!


http://reviews.llvm.org/D19048



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


Re: [PATCH] D19687: Set PIELevel module flag

2016-04-28 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/CodeGen/CodeGenModule.cpp:492-498
@@ +491,9 @@
+  if (uint32_t PLevel = Context.getLangOpts().PIELevel) {
+llvm::PIELevel::Level PL = llvm::PIELevel::Default;
+switch (PLevel) {
+case 0: break;
+case 1: PL = llvm::PIELevel::Small; break;
+case 2: PL = llvm::PIELevel::Large; break;
+default: llvm_unreachable("Invalid PIE Level");
+}
+

This seems simpler as:
  assert(PLevel < 3 && "invalid PIE level");
  getModule().setPIELevel(static_cast(PLevel));


http://reviews.llvm.org/D19687



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


Re: [PATCH] D14274: Add alloc_size attribute to clang

2016-04-28 Thread George Burgess IV via cfe-commits
george.burgess.iv added inline comments.


Comment at: include/clang/Basic/Attr.td:753
@@ +752,3 @@
+  let Args = [IntArgument<"ElemSizeParam">, IntArgument<"NumElemsParam", 1>];
+  let TemplateDependent = 1;
+  let Documentation = [AllocSizeDocs];

aaron.ballman wrote:
> I don't see any C++ tests involving templates; can you add some?
Good catch


Comment at: test/SemaCXX/constant-expression-cxx11.cpp:1171
@@ -1170,3 +1170,3 @@
   int l : n3; // expected-error {{constant expression}} expected-note {{read 
of non-const variable}}
-  int m : t.n; // expected-error {{constant expression}} expected-note {{read 
of non-constexpr variable}}
+  int m : t.n; // expected-warning{{width of bit-field 'm' (42 bits)}}
 };

aaron.ballman wrote:
> This change seems out of place for a test that doesn't use alloc_size 
> anywhere. Can you explain why this test has changed?
Yup!

Clang's constexpr evaluator is conservative about `const` variables. If it kept 
this attitude, `alloc_size` evaluation can't happen in non-constexpr contexts 
in clang, even in cases like:

```
int foo() {
  void *const p = malloc(10);
  return __builtin_object_size(p, 0);
}
```

The change I made at ExprConstant.cpp:2789 (which Richard okayed when I talked 
with him offline) makes the constexpr evaluator more willing to look at const 
variables. With that, we can fold calls to `__builtin_object_size` like above 
in clang.

It also means that there are a few cases outside of `alloc_size` where the 
constexpr evaluator can be more aggressive. As it turns out, this is one of 
them (as is the change in test/CodeGenCXX/global-init.cpp, IIRC)


http://reviews.llvm.org/D14274



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


Re: [PATCH] D14274: Add alloc_size attribute to clang

2016-04-28 Thread George Burgess IV via cfe-commits
george.burgess.iv updated this revision to Diff 55478.
george.burgess.iv marked 2 inline comments as done.
george.burgess.iv added a comment.

Addressed all feedback


http://reviews.llvm.org/D14274

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/alloc-size.c
  test/CodeGenCXX/alloc-size.cpp
  test/CodeGenCXX/global-init.cpp
  test/Sema/alloc-size.c
  test/SemaCXX/constant-expression-cxx11.cpp

Index: test/SemaCXX/constant-expression-cxx11.cpp
===
--- test/SemaCXX/constant-expression-cxx11.cpp
+++ test/SemaCXX/constant-expression-cxx11.cpp
@@ -1156,7 +1156,7 @@
 constexpr int m2b = const_cast(n2); // expected-error {{constant expression}} expected-note {{read of volatile object 'n2'}}
 
 struct T { int n; };
-const T t = { 42 }; // expected-note {{declared here}}
+const T t = { 42 };
 
 constexpr int f(volatile int &) {
   return r; // expected-note {{read of volatile-qualified type 'volatile int'}}
@@ -1168,7 +1168,7 @@
   int j : f(0); // expected-error {{constant expression}} expected-note {{in call to 'f(0)'}}
   int k : g(0); // expected-error {{constant expression}} expected-note {{temporary created here}} expected-note {{in call to 'g(0)'}}
   int l : n3; // expected-error {{constant expression}} expected-note {{read of non-const variable}}
-  int m : t.n; // expected-error {{constant expression}} expected-note {{read of non-constexpr variable}}
+  int m : t.n; // expected-warning{{width of bit-field 'm' (42 bits)}}
 };
 
 }
Index: test/Sema/alloc-size.c
===
--- /dev/null
+++ test/Sema/alloc-size.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -verify
+
+void *fail1(int a) __attribute__((alloc_size)); //expected-error{{'alloc_size' attribute takes at least 1 argument}}
+void *fail2(int a) __attribute__((alloc_size())); //expected-error{{'alloc_size' attribute takes at least 1 argument}}
+
+void *fail3(int a) __attribute__((alloc_size(0))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}}
+void *fail4(int a) __attribute__((alloc_size(2))); //expected-error{{'alloc_size' attribute parameter 2 is out of bounds}}
+
+void *fail5(int a, int b) __attribute__((alloc_size(0, 1))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}}
+void *fail6(int a, int b) __attribute__((alloc_size(3, 1))); //expected-error{{'alloc_size' attribute parameter 3 is out of bounds}}
+
+void *fail7(int a, int b) __attribute__((alloc_size(1, 0))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}}
+void *fail8(int a, int b) __attribute__((alloc_size(1, 3))); //expected-error{{'alloc_size' attribute parameter 3 is out of bounds}}
+
+int fail9(int a) __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to return values that are pointers}}
+
+int fail10 __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to non-K functions}}
+
+void *fail11(void *a) __attribute__((alloc_size(1))); //expected-error{{'alloc_size' attribute argument may only refer to a function parameter of integer type}}
+
+void *fail12(int a) __attribute__((alloc_size("abc"))); //expected-error{{'alloc_size' attribute requires parameter 1 to be an integer constant}}
+void *fail12(int a) __attribute__((alloc_size(1, "abc"))); //expected-error{{'alloc_size' attribute requires parameter 2 to be an integer constant}}
+void *fail13(int a) __attribute__((alloc_size(1U<<31))); //expected-error{{integer constant expression evaluates to value 2147483648 that cannot be represented in a 32-bit signed integer type}}
Index: test/CodeGenCXX/global-init.cpp
===
--- test/CodeGenCXX/global-init.cpp
+++ test/CodeGenCXX/global-init.cpp
@@ -18,9 +18,6 @@
 // CHECK: @__dso_handle = external global i8
 // CHECK: @c = global %struct.C zeroinitializer, align 8
 
-// It's okay if we ever implement the IR-generation optimization to remove this.
-// CHECK: @_ZN5test3L3varE = internal constant i8* getelementptr inbounds ([7 x i8], [7 x i8]* 
-
 // PR6205: The casts should not require global initializers
 // CHECK: @_ZN6PR59741cE = external global %"struct.PR5974::C"
 // CHECK: @_ZN6PR59741aE = global %"struct.PR5974::A"* getelementptr inbounds (%"struct.PR5974::C", %"struct.PR5974::C"* @_ZN6PR59741cE, i32 0, i32 0)
Index: test/CodeGenCXX/alloc-size.cpp
===
--- /dev/null
+++ test/CodeGenCXX/alloc-size.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -O0 %s -o - 2>&1 -std=c++11 | FileCheck %s
+
+namespace templates {
+void *my_malloc(int N) __attribute__((alloc_size(1)));
+void *my_calloc(int N, int M) 

[clang-tools-extra] r267933 - [clang-tidy] cppcoreguidelines-pro-type-member-init should not complain about static variables

2016-04-28 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Apr 28 15:20:01 2016
New Revision: 267933

URL: http://llvm.org/viewvc/llvm-project?rev=267933=rev
Log:
[clang-tidy] cppcoreguidelines-pro-type-member-init should not complain about 
static variables

Summary:
Variables with static storage duration are zero-initialized per
[stmt.dcl]p4 and [basic.start.init]p2.

Reviewers: sbenza, aaron.ballman

Subscribers: michael_miller, flx, cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=267933=267932=267933=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Thu Apr 28 15:20:01 2016
@@ -281,6 +281,7 @@ void ProTypeMemberInitCheck::registerMat
isDefaultConstructor(), 
unless(isUserProvided());
   Finder->addMatcher(
   varDecl(isDefinition(), HasDefaultConstructor,
+  hasAutomaticStorageDuration(),
   hasType(recordDecl(has(fieldDecl()),
  isTriviallyDefaultConstructible(
   .bind("var"),

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst?rev=267933=267932=267933=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
 Thu Apr 28 15:20:01 2016
@@ -19,10 +19,10 @@ The check takes assignment of fields in
 account but generates false positives for fields initialized in
 methods invoked in the constructor body.
 
-The check also flags variables of record types without a user-provided
-constructor that are not initialized. The suggested fix is to zero
-initialize the variable via {} for C++11 and beyond or = {} for older
-versions.
+The check also flags variables with automatic storage duration that have record
+types without a user-provided constructor and are not initialized. The 
suggested
+fix is to zero initialize the variable via ``{}`` for C++11 and beyond or ``=
+{}`` for older language versions.
 
 IgnoreArrays option
 ---

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp?rev=267933=267932=267933=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 Thu Apr 28 15:20:01 2016
@@ -175,17 +175,14 @@ static void PositiveComplexNonTrivialTyp
   ComplexNonTrivialType T;
 }
 
-struct PositiveStaticMember {
+struct NegativeStaticMember {
   static NonTrivialType X;
   static NonTrivialType Y;
   static constexpr NonTrivialType Z{};
 };
 
-NonTrivialType PositiveStaticMember::X;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: uninitialized record type: 'X'
-// CHECK-FIXES: NonTrivialType PositiveStaticMember::X{};
-
-NonTrivialType PositiveStaticMember::Y{};
+NonTrivialType NegativeStaticMember::X;
+NonTrivialType NegativeStaticMember::Y{};
 
 struct PositiveMultipleConstructors {
   PositiveMultipleConstructors() {}
@@ -242,9 +239,7 @@ struct InheritedAggregate : public Negat
   int F;
 };
 
-static InheritedAggregate PositiveGlobal;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: uninitialized record type: 
'PositiveGlobal'
-// CHECK-FIXES: InheritedAggregate PositiveGlobal{};
+static InheritedAggregate NegativeGlobal;
 
 enum TestEnum {
   A,
@@ -280,6 +275,11 @@ static void PositiveCStructVariable() {
 }
 }
 
+static void NegativeStaticVariable() {
+  static NegativeCStruct S;
+  (void)S;
+}
+
 union NegativeUnionInClass {
   NegativeUnionInClass() {} // No message as a union can only initialize one 
member.
   int X = 0;


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


Re: [PATCH] D19672: [clang-tidy] cppcoreguidelines-pro-type-member-init should not complain about static variables

2016-04-28 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL267933: [clang-tidy] cppcoreguidelines-pro-type-member-init 
should not complain about… (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D19672?vs=55441=55476#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19672

Files:
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
===
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
@@ -19,10 +19,10 @@
 account but generates false positives for fields initialized in
 methods invoked in the constructor body.
 
-The check also flags variables of record types without a user-provided
-constructor that are not initialized. The suggested fix is to zero
-initialize the variable via {} for C++11 and beyond or = {} for older
-versions.
+The check also flags variables with automatic storage duration that have record
+types without a user-provided constructor and are not initialized. The 
suggested
+fix is to zero initialize the variable via ``{}`` for C++11 and beyond or ``=
+{}`` for older language versions.
 
 IgnoreArrays option
 ---
Index: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -175,17 +175,14 @@
   ComplexNonTrivialType T;
 }
 
-struct PositiveStaticMember {
+struct NegativeStaticMember {
   static NonTrivialType X;
   static NonTrivialType Y;
   static constexpr NonTrivialType Z{};
 };
 
-NonTrivialType PositiveStaticMember::X;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: uninitialized record type: 'X'
-// CHECK-FIXES: NonTrivialType PositiveStaticMember::X{};
-
-NonTrivialType PositiveStaticMember::Y{};
+NonTrivialType NegativeStaticMember::X;
+NonTrivialType NegativeStaticMember::Y{};
 
 struct PositiveMultipleConstructors {
   PositiveMultipleConstructors() {}
@@ -242,9 +239,7 @@
   int F;
 };
 
-static InheritedAggregate PositiveGlobal;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: uninitialized record type: 
'PositiveGlobal'
-// CHECK-FIXES: InheritedAggregate PositiveGlobal{};
+static InheritedAggregate NegativeGlobal;
 
 enum TestEnum {
   A,
@@ -280,6 +275,11 @@
 }
 }
 
+static void NegativeStaticVariable() {
+  static NegativeCStruct S;
+  (void)S;
+}
+
 union NegativeUnionInClass {
   NegativeUnionInClass() {} // No message as a union can only initialize one 
member.
   int X = 0;
Index: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -281,6 +281,7 @@
isDefaultConstructor(), 
unless(isUserProvided());
   Finder->addMatcher(
   varDecl(isDefinition(), HasDefaultConstructor,
+  hasAutomaticStorageDuration(),
   hasType(recordDecl(has(fieldDecl()),
  isTriviallyDefaultConstructible(
   .bind("var"),


Index: clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
@@ -19,10 +19,10 @@
 account but generates false positives for fields initialized in
 methods invoked in the constructor body.
 
-The check also flags variables of record types without a user-provided
-constructor that are not initialized. The suggested fix is to zero
-initialize the variable via {} for C++11 and beyond or = {} for older
-versions.
+The check also flags variables with automatic storage duration that have record
+types without a user-provided constructor and are not initialized. The suggested
+fix is to zero initialize the variable via ``{}`` for C++11 and beyond or ``=
+{}`` for older language versions.
 
 IgnoreArrays option
 ---
Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- 

Re: [PATCH] D19679: Method pool in modules: sync up out of date selectors before writing the module

2016-04-28 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.


Comment at: include/clang/Serialization/ASTReader.h:657
@@ +656,3 @@
+  /// Whether a selector is out of date. We mark a selector as out of date
+  // if we load another module after the method pool entry was pulled in.
+  llvm::DenseMap SelectorOutOfDate;

///


Comment at: test/Modules/method_pool_write.m:3
@@ +2,3 @@
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs %s -verify
+// expected-no-diagnostics
+

Is there anything meaningful that could be CHECKed in the output?


http://reviews.llvm.org/D19679



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


Re: [PATCH] D19048: Test for a module related crash in CGDebugInfo.cpp

2016-04-28 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.


Comment at: test/Modules/getSourceDescriptor-crash.cpp:6
@@ +5,2 @@
+
+// CHECK: DIModule2

This doesn't actually appear in the output :-)
You probably want to at least check for the correct name of the module and for 
the DIImportedEntity.


http://reviews.llvm.org/D19048



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


Re: [PATCH] D19175: Fix for PR27015 (variable template initialized with a generic lambda expression)

2016-04-28 Thread Richard Smith via cfe-commits
On Thu, Apr 28, 2016 at 1:14 PM, Akira Hatanaka via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> ahatanak added a comment.
>
> If I try calling Init(AnyParent, F) in Scope::setFlags, clang fails to
> compile the following code because it cannot find the definition of struct
> "foo":
>
>   void foo3(void)
> struct foo {
>   int a, f;
> };
> char *np = nullptr;
> int *ip = &(((struct foo *)np)->f);
> *ip = 0;
>   }
>
> I can fix this test if I add a boolean flag to Scope::Init, which tells
> the function to return early before DeclsInScope and other fields are
> cleared.
>

Instead of adding the bool parameter to `Init`, how about this: move
`setFlags` out of line, move the parts of `Init` that compute things based
on the flags into `setFlags`, and call `setFlags` from `Init`.


> All the other tests pass too except for test/CXX/drs/dr1xx.cpp:
>
>   namespace dr183 { // dr183: sup 382
> template struct A {};
> template struct B {
>   typedef int X;
> };
> template<> struct A {
>   typename B::X x;
> };
>   }
>
> clang used to compile this code without any warnings or errors, but it now
> issues the following warning if -std=c++98 is on the command line:
>
> dr1xx.cpp:7:5: warning: 'typename' occurs outside of a template
> [-Wc++11-extensions]
>
>   typename B::X x;
>   ^
>
> 1 warning generated.
>
> Is clang correct to issue the warning in this case?


Yes.


> http://reviews.llvm.org/D19175
>
>
>
> ___
> 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] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-04-28 Thread Richard Smith via cfe-commits
rsmith added a comment.

You give this example:

>   343 | Loc = ConvertBackendLocation(D, Context->getSourceManager());

>   I   |   ^

>   I   | ^


How does this look for a case like `p->Foo()->Bar()` (where one or both of the 
calls are inlined)? Can we get the source location to point at the function 
name instead of the start of the expression to reduce the scope for ambiguity?



Comment at: lib/CodeGen/CodeGenAction.cpp:665-761
@@ +664,99 @@
+
+void BackendConsumer::GenerateListingFile() {
+  if (CodeGenOpts.ListingFile.empty())
+return;
+
+  std::error_code EC;
+  llvm::raw_fd_ostream OS(CodeGenOpts.ListingFile, EC,
+  llvm::sys::fs::F_Text);
+  if (EC) {
+Diags.Report(diag::err_fe_error_opening) << CodeGenOpts.ListingFile <<
+EC.message();
+return;
+  }
+
+  SourceManager  = Context->getSourceManager();
+  std::set FileIDs;
+  for (auto  : ListingInfo)
+FileIDs.insert(SourceMgr.getFileID(I.first));
+
+  for (auto  : FileIDs) {
+SourceLocation FirstLoc = SourceMgr.getLocForStartOfFile(FID);
+OS << "< " << SourceMgr.getFilename(FirstLoc) << "\n";
+
+auto I = ListingInfo.lower_bound(FirstLoc);
+StringRef MB = SourceMgr.getBufferData(FID);
+const SrcMgr::ContentCache *
+  Content = SourceMgr.getSLocEntry(FID).getFile().getContentCache();
+unsigned LNDigits = llvm::utostr(Content->NumLines).size();
+for (unsigned L = 0; L < Content->NumLines - 1; ++L) {
+  unsigned LStartOff = Content->SourceLineCache[L];
+  unsigned LEndOff = (L == Content->NumLines) ?
+ Content->getSize() :
+ Content->SourceLineCache[L + 1];
+
+  std::map ColsInfo;
+  unsigned InlinedCols = 0, UnrolledCols = 0, VectorizedCols = 0;
+
+  ListingLineInfo LLI;
+  if (I != ListingInfo.end()) {
+auto DI = SourceMgr.getDecomposedLoc(I->first);
+while (I != ListingInfo.end() && DI.first == FID &&
+   DI.second < LStartOff) {
+  ++I;
+  if (I != ListingInfo.end())
+DI = SourceMgr.getDecomposedLoc(I->first);
+}
+
+while (I != ListingInfo.end() && DI.first == FID &&
+DI.second >= LStartOff && DI.second < LEndOff) {
+  unsigned Col = SourceMgr.getColumnNumber(FID, DI.second);
+  ColsInfo[Col] = I->second;
+  InlinedCols += I->second.Inlined.Analyzed;
+  UnrolledCols += I->second.Unrolled.Analyzed;
+  VectorizedCols += I->second.Vectorized.Analyzed;
+  LLI |= I->second;
+
+  ++I;
+  if (I != ListingInfo.end())
+DI = SourceMgr.getDecomposedLoc(I->first);
+}
+  }
+
+  // We try to keep the output as concise as possible. If only one thing on
+  // a given line could have been inlined, vectorized, etc. then we can put
+  // the marker on the source line itself. If there are multiple options
+  // then we want to distinguish them by placing the marker for each
+  // transformation on a separate line following the source line. When we
+  // do this, we use a '^' character to point to the appropriate column in
+  // the source line.
+
+  OS << llvm::format_decimal(L + 1, LNDigits) << " ";
+  OS << (LLI.Inlined.Transformed && InlinedCols < 2 ? "I" : " ");
+  OS << (LLI.Unrolled.Transformed && UnrolledCols < 2 ? "U" : " ");
+  OS << (LLI.Vectorized.Transformed && VectorizedCols < 2 ? "V" : " ");
+
+  OS << " | " << MB.slice(LStartOff, LEndOff);
+
+  for (auto  : ColsInfo) {
+if ((J.second.Inlined.Transformed && InlinedCols > 1) ||
+(J.second.Unrolled.Transformed && UnrolledCols > 1) ||
+(J.second.Vectorized.Transformed && VectorizedCols > 1)) {
+  OS << std::string(LNDigits + 1, ' ');
+  OS << (J.second.Inlined.Transformed &&
+ InlinedCols > 1 ? "I" : " ");
+  OS << (J.second.Unrolled.Transformed &&
+ UnrolledCols > 1 ? "U" : " ");
+  OS << (J.second.Vectorized.Transformed &&
+ VectorizedCols > 1 ? "V" : " ");
+
+  OS << " | " << std::string(J.first - 1, ' ') << "^\n";
+}
+  }
+
+  if (LEndOff == Content->getSize())
+OS << "\n";
+}
+  }
+}
+

I'd like this to be factored out and moved somewhere more appropriate (such as 
Frontend). It seems appropriate for CodeGen to generate the data structure 
here, but it should not be deciding how to format the report nor doing file IO 
to put it somewhere.

I would hope that we can combine this report information with the static 
analyzer's existing support for generating syntax-highlighted, annotated source 
code as HTML as a future extension.


http://reviews.llvm.org/D19678



___
cfe-commits mailing list

Re: [PATCH] D19175: Fix for PR27015 (variable template initialized with a generic lambda expression)

2016-04-28 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

If I try calling Init(AnyParent, F) in Scope::setFlags, clang fails to compile 
the following code because it cannot find the definition of struct "foo":

  void foo3(void) 
struct foo {
  int a, f;
};
char *np = nullptr;
int *ip = &(((struct foo *)np)->f);
*ip = 0;
  }

I can fix this test if I add a boolean flag to Scope::Init, which tells the 
function to return early before DeclsInScope and other fields are cleared.

All the other tests pass too except for test/CXX/drs/dr1xx.cpp:

  namespace dr183 { // dr183: sup 382
template struct A {};
template struct B {
  typedef int X;
};
template<> struct A {
  typename B::X x;
};
  }

clang used to compile this code without any warnings or errors, but it now 
issues the following warning if -std=c++98 is on the command line:

dr1xx.cpp:7:5: warning: 'typename' occurs outside of a template 
[-Wc++11-extensions]

  typename B::X x;
  ^

1 warning generated.

Is clang correct to issue the warning in this case?


http://reviews.llvm.org/D19175



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


Re: r267904 - Debug info: Apply an artificial debug location to __cyg_profile_func.* calls.

2016-04-28 Thread Adrian Prantl via cfe-commits

> On Apr 28, 2016, at 12:53 PM, David Blaikie  wrote:
> 
> 
> 
> On Thu, Apr 28, 2016 at 12:50 PM, Adrian Prantl  > wrote:
> 
>> On Apr 28, 2016, at 12:34 PM, David Blaikie > > wrote:
>> 
>> Should these have no/artificial location? It seems like perhaps they should 
>> have the same location as the scope they're for? (well, the beginning or end 
>> of that scope, respectively, etc)
> 
> While there is usually a single source location for the beginning of the 
> function, there can be more than one such location for the end of the 
> function, so I don’t think this is generally possible.
> 
> Seems to me like it would be - declare a variable with a non-trivial dtor at 
> the start of the function. Whichever line the dtor call is attributed to, 
> that's the end of the function. (I think we use the } for this, or perhaps 
> the final return statement if there is one and only one - I forget the 
> specifics)

Ah yes, I guess we could be using the cleanup location of the function for this.

>  
> The artificial location unambiguously marks the function call as something 
> that does not appear in source code. For a (terrible) example (given the 
> nature of these function calls :-p) if you look at a profile you wouldn’t 
> want these function calls to be misattributed to any line in the source code.
> 
> I'm not quite sure what the ramifications of that would be/why that would be 
> bad (or good) - could you explain further?

If the compiler generates code that does not have any meaningful source 
location (in this case one could argue that ‘{‘ and ‘}’ might be meaningful 
source locations?) then I wouldn’t want that code to be attributed to a source 
location just because the instructions immediately follow some completely 
unrelated instructions that happen to have a source location.
- Profiling: It shouldn't show up in a profile counted towards the source 
location of the instructions before it.
- Debugging: Since there is no source code for it a source-based debugger (you 
can still switch to disassembly) should treat the function call as transparent 
and skip over it as if it didn’t exist.

-- adrian

> 
> - Dave
>  
> 
> -- adrian
> 
>> 
>> On Thu, Apr 28, 2016 at 10:21 AM, Adrian Prantl via cfe-commits 
>> > wrote:
>> Author: adrian
>> Date: Thu Apr 28 12:21:56 2016
>> New Revision: 267904
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=267904=rev 
>> 
>> Log:
>> Debug info: Apply an artificial debug location to __cyg_profile_func.* calls.
>> The LLVM Verifier expects all inlinable calls in debuggable functions to
>> have a location.
>> 
>> rdar://problem/25818489 <>
>> 
>> Modified:
>> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>> cfe/trunk/test/CodeGen/instrument-functions.c
>> 
>> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=267904=267903=267904=diff
>>  
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Apr 28 12:21:56 2016
>> @@ -401,6 +401,7 @@ bool CodeGenFunction::ShouldInstrumentFu
>>  /// instrumentation function with the current function and the call site, if
>>  /// function instrumentation is enabled.
>>  void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) {
>> +  auto NL = ApplyDebugLocation::CreateArtificial(*this);
>>// void __cyg_profile_func_{enter,exit} (void *this_fn, void *call_site);
>>llvm::PointerType *PointerTy = Int8PtrTy;
>>llvm::Type *ProfileFuncArgs[] = { PointerTy, PointerTy };
>> 
>> Modified: cfe/trunk/test/CodeGen/instrument-functions.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/instrument-functions.c?rev=267904=267903=267904=diff
>>  
>> 
>> ==
>> --- cfe/trunk/test/CodeGen/instrument-functions.c (original)
>> +++ cfe/trunk/test/CodeGen/instrument-functions.c Thu Apr 28 12:21:56 2016
>> @@ -1,9 +1,9 @@
>> -// RUN: %clang_cc1 -S -emit-llvm -o - %s -finstrument-functions | FileCheck 
>> %s
>> +// RUN: %clang_cc1 -S -debug-info-kind=standalone -emit-llvm -o - %s 
>> -finstrument-functions | FileCheck %s
>> 
>>  // CHECK: @test1
>>  int test1(int x) {
>> -// CHECK: __cyg_profile_func_enter
>> -// CHECK: __cyg_profile_func_exit
>> +// CHECK: call void @__cyg_profile_func_enter({{.*}}, !dbg
>> +// CHECK: call void 

  1   2   3   >