Re: [PATCH] D17385: clang-format: [JS] single quote double quoted strings.

2016-02-24 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/Format.cpp:1579
@@ +1578,3 @@
+  // The width of the extra \ escapes is taken into account in getNextToken.
+  void requoteJSStringLiterals(tooling::Replacements &Replaces,
+   FormatToken *Current) {

What's the reason not to do this in FormatTokenLexer, ideally at the same time 
when increasing the length?


Comment at: lib/Format/Format.cpp:1585
@@ +1584,3 @@
+  StringRef Input = Current->TokenText;
+  std::stringstream Res;
+  Res << '\'';

LLVM comes with its own string stream implementation. Use that: 
raw_string_ostream.


http://reviews.llvm.org/D17385



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


Re: [PATCH] D13980: Add "x87" in x86 target feature map

2016-02-24 Thread Andrey Turetskiy via cfe-commits
aturetsk updated this revision to Diff 48904.
aturetsk added a comment.

Rebased.


http://reviews.llvm.org/D13980

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/attr-target-x86-mmx.c
  test/CodeGen/attr-target-x86.c

Index: test/CodeGen/attr-target-x86.c
===
--- test/CodeGen/attr-target-x86.c
+++ test/CodeGen/attr-target-x86.c
@@ -31,9 +31,9 @@
 // CHECK: qux{{.*}} #1
 // CHECK: qax{{.*}} #4
 // CHECK: qq{{.*}} #5
-// CHECK: #0 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+sse2"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt"
-// CHECK: #2 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
-// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
-// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt,-aes"
-// CHECK: #5 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+sse,+sse2,-3dnow,-3dnowa,-mmx"
+// CHECK: #0 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+sse2,+x87"
+// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+// CHECK: #2 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+x87,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
+// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
+// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt,-aes"
+// CHECK: #5 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+sse,+sse2,+x87,-3dnow,-3dnowa,-mmx"
Index: test/CodeGen/attr-target-x86-mmx.c
===
--- test/CodeGen/attr-target-x86-mmx.c
+++ test/CodeGen/attr-target-x86-mmx.c
@@ -19,4 +19,4 @@
   _mm_srai_pi32(a, c);
 }
 
-// CHECK: "target-features"="+mmx,+sse"
+// CHECK: "target-features"="+mmx,+sse,+x87"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2594,6 +2594,9 @@
   if (getTriple().getArch() == llvm::Triple::x86_64)
 setFeatureEnabledImpl(Features, "sse2", true);
 
+  // Enable X87 for all X86 processors.
+  setFeatureEnabledImpl(Features, "x87", true);
+
   switch (getCPUKind(CPU)) {
   case CK_Generic:
   case CK_i386:


Index: test/CodeGen/attr-target-x86.c
===
--- test/CodeGen/attr-target-x86.c
+++ test/CodeGen/attr-target-x86.c
@@ -31,9 +31,9 @@
 // CHECK: qux{{.*}} #1
 // CHECK: qax{{.*}} #4
 // CHECK: qq{{.*}} #5
-// CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt"
-// CHECK: #2 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
-// CHECK: #3 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
-// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt,-aes"
-// CHECK: #5 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+sse,+sse2,-3dnow,-3dnowa,-mmx"
+// CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87"
+// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+// CHECK: #2 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+x87,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
+// CHECK: #3 = {{.*}}"target-cpu"="x86-64" "targe

Re: [PATCH] D13980: Add "x87" in x86 target feature map

2016-02-24 Thread Andrey Turetskiy via cfe-commits
aturetsk added a comment.

Hi,
The related LLVM patch (http://reviews.llvm.org/D13979) was approved. Is this 
patch ok for commit?


http://reviews.llvm.org/D13980



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


[PATCH] D17567: [GCC] Sema part of attrbute abi_tag support

2016-02-24 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added a reviewer: aaron.ballman.
DmitryPolukhin added subscribers: cfe-commits, stbuehler.

Original patch by Stefan Bühler http://reviews.llvm.org/D12834

Difference between original and this one:
- fixed all comments in original code review
- added more tests, all new diagnostics now covered by tests
- moved abi_tag on re-declaration checks to Sema::mergeDeclAttributes where 
they actually may work as designed
- clang-format + other stylistic changes

Mangle part will be sent for review as a separate patch.

http://reviews.llvm.org/D17567

Files:
  docs/ItaniumMangleAbiTags.rst
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCXX/attr-abi-tag-syntax.cpp

Index: test/SemaCXX/attr-abi-tag-syntax.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-abi-tag-syntax.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+namespace N1 {
+
+namespace __attribute__((__abi_tag__)) {}
+// expected-warning@-1 {{'abi_tag' attribute on non-inline namespace ignored}}
+
+namespace N __attribute__((__abi_tag__)) {}
+// expected-warning@-1 {{'abi_tag' attribute on non-inline namespace ignored}}
+
+} // namespace N1
+
+namespace N2 {
+
+inline namespace __attribute__((__abi_tag__)) {}
+// expected-warning@-1 {{'abi_tag' attribute on anonymous namespace ignored}}
+
+inline namespace N __attribute__((__abi_tag__)) {}
+// FIXME: remove this warning as soon as attribute fully supported.
+// expected-warning@-2 {{'__abi_tag__' attribute ignored}}
+
+} // namespcace N2
+
+__attribute__((abi_tag("B", "A"))) extern int a1;
+// FIXME: remove this warning as soon as attribute fully supported.
+// expected-warning@-2 {{'abi_tag' attribute ignored}}
+
+__attribute__((abi_tag("A", "B"))) extern int a1;
+// expected-note@-1 {{previous declaration is here}}
+// FIXME: remove this warning as soon as attribute fully supported.
+// expected-warning@-3 {{'abi_tag' attribute ignored}}
+
+__attribute__((abi_tag("A", "C"))) extern int a1;
+// expected-error@-1 {{'abi_tag' C missing in original declaration}}
+// FIXME: remove this warning as soon as attribute fully supported.
+// expected-warning@-3 {{'abi_tag' attribute ignored}}
+
+extern int a2;
+// expected-note@-1 {{previous declaration is here}}
+__attribute__((abi_tag("A")))extern int a2;
+// expected-error@-1 {{cannot add 'abi_tag' attribute in redeclaration}}
+// FIXME: remove this warning as soon as attribute fully supported.
+// expected-warning@-3 {{'abi_tag' attribute ignored}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4493,6 +4493,42 @@
   Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleAbiTagAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  SmallVector Tags;
+  for (unsigned I = 0, E = Attr.getNumArgs(); I != E; ++I) {
+StringRef Tag;
+if (!S.checkStringLiteralArgumentAttr(Attr, I, Tag))
+  return;
+Tags.push_back(Tag);
+  }
+
+  if (const auto *NS = dyn_cast(D)) {
+if (!NS->isInline()) {
+  S.Diag(Attr.getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
+  return;
+}
+if (NS->isAnonymousNamespace()) {
+  S.Diag(Attr.getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
+  return;
+}
+if (Attr.getNumArgs() == 0)
+  Tags.push_back(NS->getName());
+  } else if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+return;
+
+  // Store tags sorted and without duplicates.
+  std::sort(Tags.begin(), Tags.end());
+  Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
+
+  D->addAttr(::new (S.Context)
+ AbiTagAttr(Attr.getRange(), S.Context, Tags.data(), Tags.size(),
+Attr.getAttributeSpellingListIndex()));
+
+  // FIXME: remove this warning as soon as mangled part is ready.
+  S.Diag(Attr.getRange().getBegin(), diag::warn_attribute_ignored)
+<< Attr.getName();
+}
+
 static void handleARMInterruptAttr(Sema &S, Decl *D,
const AttributeList &Attr) {
   // Check the attribute arguments.
@@ -5466,6 +5502,9 @@
   case AttributeList::AT_Thread:
 handleDeclspecThreadAttr(S, D, Attr);
 break;
+  case AttributeList::AT_AbiTag:
+handleAbiTagAttr(S, D, Attr);
+break;
 
   // Thread safety attributes:
   case AttributeList::AT_AssertExclusiveLock:
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2398,6 +2398,24 @@
 }
   }
 
+  // Re-declaration cannot add abi_tag's.
+  if (const auto *NewAbiTagAttr = New->getAttr()) {
+if (const auto *OldAbiTagAttr = Old->getAttr()) {
+  for 

Re: [PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-24 Thread Kirill Bobyrev via cfe-commits
omtcyf0 updated this revision to Diff 48905.
omtcyf0 added a comment.

replaced few explicit casts to llvm::Twine with implicit ones


http://reviews.llvm.org/D17484

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  clang-tidy/modernize/DeprecatedHeadersCheck.h
  clang-tidy/modernize/ModernizeTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-deprecated-headers.rst
  test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
  test/clang-tidy/modernize-deprecated-headers-cxx11.cpp

Index: test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
@@ -0,0 +1,163 @@
+// RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- -std=c++11 -isystem %S/Inputs/Headers
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'complex.h'; consider using 'ccomplex' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'ctype.h'; consider using 'cctype' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'errno.h'; consider using 'cerrno' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'fenv.h'; consider using 'cfenv' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'float.h'; consider using 'cfloat' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'inttypes.h'; consider using 'cinttypes' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'iso646.h'; consider using 'ciso646' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'limits.h'; consider using 'climits' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'locale.h'; consider using 'clocale' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'setjmp.h'; consider using 'csetjmp' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'signal.h'; consider using 'csignal' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdalign.h'; consider using 'cstdalign' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdarg.h'; consider using 'cstdarg' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdbool.h'; consider using 'cstdbool' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stddef.h'; consider using 'cstddef' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdint.h'; consider using 'cstdint' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdlib.h'; consider using 'cstdlib' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'string.h'; consider using 'cstring' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'tgmath.h'; consider using 'ctgmath' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'time.h'; consider using 'ctime' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'uchar.h'; consider using 'cuchar' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'wchar.h'; consider using 'cwchar' instead
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'wctype.h'; consider using 'cwctype' instead
+
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK

Re: [PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-24 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

In http://reviews.llvm.org/D17484#359634, @alexfh wrote:

> Looks good with one nit.
>
> Let me know if you need me to commit the patch for you.


Yes, commit please!


http://reviews.llvm.org/D17484



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


Re: [PATCH] D16376: clang-tidy check: misc-deprecated-special-member-functions

2016-02-24 Thread Jonathan B Coe via cfe-commits
jbcoe added a comment.

The Sema diagnostic warning is only produced if a deprecated special member 
function is used whereas I want to find places where it would be 
compiler-generated and explicitly delete them. This is useful for library code 
where I don't have control over the warnings my users will run with.

The AST Matcher I use are simple enough and I'm not convinced that it's worth 
refactoring Sema to expose what I need. If someone (Richard?) with a deeper 
understanding can point me in the right direction I'm happy to be corrected.


http://reviews.llvm.org/D16376



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


Re: r261717 - Default vaarg lowering should support indirect struct types.

2016-02-24 Thread Joerg Sonnenberger via cfe-commits
On Wed, Feb 24, 2016 at 03:03:32AM -, James Y Knight via cfe-commits wrote:
> Author: jyknight
> Date: Tue Feb 23 20:59:33 2016
> New Revision: 261717
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=261717&view=rev
> Log:
> Default vaarg lowering should support indirect struct types.
> 
> Fixes PR11517 for SPARC.

It would be nice to get the PPC32 and XCore parts finished by those
involved with the platforms, but I would like to see this merged into
the 3.8 branch at some point after 3.8.0. It is one of the missing basic
codegen items for SPARC.

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


[clang-tools-extra] r261737 - [clang-tidy] Added a check for forward declaration in the potentially wrong namespace

2016-02-24 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Feb 24 07:35:32 2016
New Revision: 261737

URL: http://llvm.org/viewvc/llvm-project?rev=261737&view=rev
Log:
[clang-tidy] Added a check for forward declaration in the potentially wrong 
namespace

Adds a new check "misc-forward-declaration-namespace".
In check, A forward declaration is considerred in a potentially wrong namespace
if there is any definition/declaration with the same name exists in a different
namespace.

Reviewers: akuegel, hokein, alexfh

Patch by Eric Liu!

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

Added:
clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-forward-declaration-namespace.rst

clang-tools-extra/trunk/test/clang-tidy/misc-forward-declaration-namespace.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=261737&r1=261736&r2=261737&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Wed Feb 24 07:35:32 
2016
@@ -6,6 +6,7 @@ add_clang_library(clangTidyMiscModule
   AssignOperatorSignatureCheck.cpp
   BoolPointerImplicitConversionCheck.cpp
   DefinitionsInHeadersCheck.cpp
+  ForwardDeclarationNamespaceCheck.cpp
   InaccurateEraseCheck.cpp
   IncorrectRoundings.cpp
   InefficientAlgorithmCheck.cpp

Added: 
clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp?rev=261737&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp 
(added)
+++ 
clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp 
Wed Feb 24 07:35:32 2016
@@ -0,0 +1,174 @@
+//===--- ForwardDeclarationNamespaceCheck.cpp - clang-tidy --*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ForwardDeclarationNamespaceCheck.h"
+#include 
+#include 
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+void ForwardDeclarationNamespaceCheck::registerMatchers(MatchFinder *Finder) {
+  // Match all class declarations/definitions *EXCEPT*
+  // 1. implicit classes, e.g. `class A {};` has implicit `class A` inside `A`.
+  // 2. nested classes declared/defined inside another class.
+  // 3. template class declaration, template instantiation or
+  //specialization (NOTE: extern specialization is filtered out by
+  //`unless(hasAncestor(cxxRecordDecl()))`).
+  auto IsInSpecialization = hasAncestor(
+  decl(anyOf(cxxRecordDecl(isExplicitTemplateSpecialization()),
+ functionDecl(isExplicitTemplateSpecialization();
+  Finder->addMatcher(
+  cxxRecordDecl(
+  hasParent(decl(anyOf(namespaceDecl(), translationUnitDecl(,
+  unless(isImplicit()), unless(hasAncestor(cxxRecordDecl())),
+  unless(isInstantiated()), unless(IsInSpecialization),
+  unless(classTemplateSpecializationDecl()))
+  .bind("record_decl"),
+  this);
+
+  // Match all friend declarations. Classes used in friend declarations are not
+  // marked as referenced in AST. We need to record all record classes used in
+  // friend declarations.
+  Finder->addMatcher(friendDecl().bind("friend_decl"), this);
+}
+
+void ForwardDeclarationNamespaceCheck::check(
+const MatchFinder::MatchResult &Result) {
+  if (const auto *RecordDecl =
+  Result.Nodes.getNodeAs("record_decl")) {
+StringRef DeclName = RecordDecl->getName();
+if (RecordDecl->isThisDeclarationADefinition()) {
+  DeclNameToDefinitions[DeclName].push_back(RecordDecl);
+} else {
+  // If a declaration has no definition, the definition could be in another
+  // namespace (a wrong namespace).
+  // NOTE: even a declaration does have definition, we still need it to
+  // compare with other declarations.
+  DeclNameToDeclarations[DeclName].push_back(RecordDecl);
+}
+  } else {
+const auto *Decl = Result.Nod

[clang-tools-extra] r261738 - [clang-tidy] introduce modernize-deprecated-headers check

2016-02-24 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Feb 24 07:36:34 2016
New Revision: 261738

URL: http://llvm.org/viewvc/llvm-project?rev=261738&view=rev
Log:
[clang-tidy] introduce modernize-deprecated-headers check

Summary:
This patch introduces the modernize-deprecated-headers check, which is supposed 
to replace deprecated C library headers with the C++ STL-ones.

For information see documentation; for exmaples see the test cases.

Reviewers: Eugene.Zelenko, LegalizeAdulthood, alexfh

Subscribers: cfe-commits

Patch by Kirill Bobyrev!

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

Added:
clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=261738&r1=261737&r2=261738&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Wed Feb 24 
07:36:34 2016
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyModernizeModule
+  DeprecatedHeadersCheck.cpp
   LoopConvertCheck.cpp
   LoopConvertUtils.cpp
   MakeUniqueCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp?rev=261738&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp Wed 
Feb 24 07:36:34 2016
@@ -0,0 +1,110 @@
+//===--- DeprecatedHeadersCheck.cpp - 
clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DeprecatedHeadersCheck.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+#include "llvm/ADT/StringMap.h"
+
+#include 
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+namespace {
+class IncludeModernizePPCallbacks : public PPCallbacks {
+public:
+  explicit IncludeModernizePPCallbacks(ClangTidyCheck &Check,
+   LangOptions LangOpts);
+
+  void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
+  StringRef FileName, bool IsAngled,
+  CharSourceRange FilenameRange, const FileEntry *File,
+  StringRef SearchPath, StringRef RelativePath,
+  const Module *Imported) override;
+
+private:
+  ClangTidyCheck &Check;
+  LangOptions LangOpts;
+  llvm::StringMap CStyledHeaderToCxx;
+};
+} // namespace
+
+void DeprecatedHeadersCheck::registerPPCallbacks(CompilerInstance &Compiler) {
+  if (this->getLangOpts().CPlusPlus) {
+Compiler.getPreprocessor().addPPCallbacks(
+::llvm::make_unique(*this,
+ this->getLangOpts()));
+  }
+}
+
+IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(ClangTidyCheck &Check,
+ LangOptions LangOpts)
+: Check(Check), LangOpts(LangOpts),
+  CStyledHeaderToCxx({{"assert.h", "cassert"},
+  {"complex.h", "ccomplex"},
+  {"ctype.h", "cctype"},
+  {"errno.h", "cerrno"},
+  {"float.h", "cfloat"},
+  {"inttypes.h", "cinttypes"},
+  {"iso646.h", "ciso646"},
+  {"limits.h", "climits"},
+  {"locale.h", "clocale"},
+  {"math.h", "cmath"},
+  {"setjmp.h", "csetjmp"},
+  {"signal.h", "csignal"},
+  {"stdarg.h", "cstdarg"},
+  {"stddef.h", "cstddef"},
+  {"stdint.h", "cstdint"},
+  {"stdio.h", "cstdio"},
+   

Re: [PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-24 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261738: [clang-tidy] introduce modernize-deprecated-headers 
check (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D17484?vs=48905&id=48919#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17484

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
  clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst
  clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
+++ clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
@@ -0,0 +1,42 @@
+//===--- DeprecatedHeadersCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_C_HEADERS_TO_CXX_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_C_HEADERS_TO_CXX_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+/// This check replaces deprecated C library headers with their C++ STL
+/// alternatives.
+///
+/// Before:
+///   #include 
+/// After:
+///   #include 
+///
+/// Example:  => 
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/modernize-deprecated-headers.html
+class DeprecatedHeadersCheck : public ClangTidyCheck {
+public:
+  DeprecatedHeadersCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerPPCallbacks(CompilerInstance &Compiler) override;
+};
+
+} // namespace modernize
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_C_HEADERS_TO_CXX_H
Index: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyModernizeModule
+  DeprecatedHeadersCheck.cpp
   LoopConvertCheck.cpp
   LoopConvertUtils.cpp
   MakeUniqueCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "DeprecatedHeadersCheck.h"
 #include "LoopConvertCheck.h"
 #include "MakeUniqueCheck.h"
 #include "PassByValueCheck.h"
@@ -30,6 +31,8 @@
 class ModernizeModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"modernize-deprecated-headers");
 CheckFactories.registerCheck("modernize-loop-convert");
 CheckFactories.registerCheck("modernize-make-unique");
 CheckFactories.registerCheck("modernize-pass-by-value");
Index: clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -0,0 +1,110 @@
+//===--- DeprecatedHeadersCheck.cpp - clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DeprecatedHeadersCheck.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+#include "llvm/ADT/StringMap.h"
+
+#include 
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+namespace {
+class IncludeModernizePPCallbacks : public PPCallbacks {
+public:
+  explicit IncludeModernizePPCallbacks(ClangTidyCheck &C

Re: [PATCH] D17244: [clang-tidy] readability-ternary-operator new check

2016-02-24 Thread Kirill Bobyrev via cfe-commits
omtcyf0 marked 3 inline comments as done.
omtcyf0 added a comment.

Thanks for the review!

I'll fix these issues as soon as I manage to get time for that!


http://reviews.llvm.org/D17244



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


Re: [PATCH] D15539: [libcxxabi] Reducing stack usage of test

2016-02-24 Thread Ben Craig via cfe-commits
bcraig added a comment.

@mclow.lists ping


http://reviews.llvm.org/D15539



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


Re: [PATCH] D16545: [libcxxabi] Enable testing for static libc++abi

2016-02-24 Thread Ben Craig via cfe-commits
bcraig added a comment.

ping


http://reviews.llvm.org/D16545



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


Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi

2016-02-24 Thread Ben Craig via cfe-commits
bcraig added a comment.

ping


http://reviews.llvm.org/D16544



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


Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-02-24 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 48924.
hokein added a comment.

Update:

- Update test to apply multiple files and fixes.
- Make it work with multiple files.


http://reviews.llvm.org/D17335

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/Inputs/compilation-database/template.json
  test/clang-tidy/clang-tidy-run-with-database.cpp

Index: test/clang-tidy/clang-tidy-run-with-database.cpp
===
--- /dev/null
+++ test/clang-tidy/clang-tidy-run-with-database.cpp
@@ -0,0 +1,26 @@
+// REQUIRES: shell
+// RUN: mkdir -p %T/compilation-database-test
+// RUN: mkdir -p %T/compilation-database-test/a
+// RUN: mkdir -p %T/compilation-database-test/b
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: sed 's|pointer|AA|g' %t.cpp > %T/compilation-database-test/a/a.cpp
+// RUN: sed 's|pointer|AA|g' %s > %T/compilation-database-test/a/a.cpp.msg
+// RUN: sed 's|pointer|AB|g' %t.cpp > %T/compilation-database-test/a/b.cpp
+// RUN: sed 's|pointer|AB|g' %s > %T/compilation-database-test/a/b.cpp.msg
+// RUN: sed 's|pointer|BB|g' %t.cpp > %T/compilation-database-test/b/b.cpp
+// RUN: sed 's|pointer|BB|g' %s > %T/compilation-database-test/b/b.cpp.msg
+// RUN: sed 's|pointer|BC|g' %t.cpp > %T/compilation-database-test/b/c.cpp
+// RUN: sed 's|pointer|BC|g' %s > %T/compilation-database-test/b/c.cpp.msg
+// RUN: sed 's|test_dir|%T/compilation-database-test|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.*
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp %T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp -header-filter=.* -fix
+// RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/a.cpp.msg -check-prefix=CHECK-FIX
+// RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %T/compilation-database-test/a/b.cpp.msg -check-prefix=CHECK-FIX
+// RUN: FileCheck -input-file=%T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/b.cpp.msg -check-prefix=CHECK-FIX
+// RUN: FileCheck -input-file=%T/compilation-database-test/b/c.cpp %T/compilation-database-test/b/c.cpp.msg -check-prefix=CHECK-FIX
+
+#define NULL 0
+
+int *pointer = NULL;
+// CHECK-FIX: int *pointer = nullptr;
+// CHECK: warning: use nullptr [modernize-use-nullpt]
Index: test/clang-tidy/Inputs/compilation-database/template.json
===
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/template.json
@@ -0,0 +1,27 @@
+[
+{
+  "directory": "test_dir/a",
+  "command": "clang++ -o test.o test_dir/a/a.cpp",
+  "file": "test_dir/a/a.cpp"
+},
+{
+  "directory": "test_dir/a",
+  "command": "clang++ -o test.o test_dir/a/b.cpp",
+  "file": "test_dir/a/b.cpp"
+},
+{
+  "directory": "test_dir/",
+  "command": "clang++ -o test.o test_dir/b/b.cpp",
+  "file": "test_dir/b/b.cpp"
+},
+{
+  "directory": "test_dir/",
+  "command": "clang++ -o test.o test_dir/b/c.cpp",
+  "file": "test_dir/b/c.cpp"
+},
+{
+  "directory": "test_dir/",
+  "command": "clang++ -o test.o test_dir/b/not-exist.cpp",
+  "file": "test_dir/b/not-exist.cpp"
+}
+]
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -342,11 +342,13 @@
 
   ProfileData Profile;
 
-  std::vector Errors;
-  ClangTidyStats Stats =
-  runClangTidy(std::move(OptionsProvider), OptionsParser.getCompilations(),
-   PathList, &Errors,
-   EnableCheckProfile ? &Profile : nullptr);
+  clang::tidy::ClangTidyContext Context(std::move(OptionsProvider));
+  /// If Profile provided, it enables check profile collection in
+  /// MatchFinder, and will contain the result of the profile.
+  if (EnableCheckProfile)
+Context.setCheckProfileData(&Profile);
+  runClangTidy(Context, OptionsParser.getCompilations(), PathList);
+  const std::vector &Errors = Context.getErrors();
   bool FoundErrors =
   std::find_if(Errors.begin(), Errors.end(), [](const ClangTidyError &E) {
 return E.DiagLevel == ClangTidyError::Error;
@@ -369,7 +371,7 @@
 exportReplacements(Errors, OS);
   }
 
-  printStats(Stats);
+  printStats(Context.getStats());
   if (DisableFixes)
 llvm::errs()
 << "Found compiler errors, but -fix-errors was not specified.\n"
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -57,13 +57,24 @@
 Error = Diagnos

Re: [PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-02-24 Thread Ziv Izhar via cfe-commits
zizhar added a comment.

You understood corectly :)

After going a bit through the log, I think that there is no reason for clang to 
not detect it, probably the check was just forgotten.

This patch is the check.

"r" constraint means (taken from the spec:) A register operand is allowed 
provided that it is in a general register.
("%rcx") means - use the register rcx.


http://reviews.llvm.org/D15075



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


r261744 - [docs] Change non-c++ code blocks to 'text' format to fix a sphinx warning.

2016-02-24 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Feb 24 09:07:48 2016
New Revision: 261744

URL: http://llvm.org/viewvc/llvm-project?rev=261744&view=rev
Log:
[docs] Change non-c++ code blocks to 'text' format to fix a sphinx warning.

Modified:
cfe/trunk/docs/InternalsManual.rst

Modified: cfe/trunk/docs/InternalsManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/InternalsManual.rst?rev=261744&r1=261743&r2=261744&view=diff
==
--- cfe/trunk/docs/InternalsManual.rst (original)
+++ cfe/trunk/docs/InternalsManual.rst Wed Feb 24 09:07:48 2016
@@ -57,7 +57,7 @@ driver, but diagnostics can be :ref:`ren
 ` depending on how the ``DiagnosticClient`` interface is
 implemented.  A representative example of a diagnostic is:
 
-.. code-block:: c++
+.. code-block:: text
 
   t.c:38:15: error: invalid operands to binary expression ('int *' and 
'_Complex float')
   P = (P-42) + Gamma*4;
@@ -374,7 +374,7 @@ use of a deprecated construct into somet
 example from the C++ front end, where we warn about the right-shift operator
 changing meaning from C++98 to C++11:
 
-.. code-block:: c++
+.. code-block:: text
 
   test.cpp:3:7: warning: use of right-shift operator ('>>') in template 
argument
  will require parentheses in C++11
@@ -514,7 +514,7 @@ Clang represents most source ranges by [
 each point to the beginning of their respective tokens.  For example consider
 the ``SourceRange`` of the following statement:
 
-.. code-block:: c++
+.. code-block:: text
 
   x = foo + bar;
   ^first^last
@@ -837,7 +837,7 @@ typedefs.  For example, consider this co
 The code above is illegal, and thus we expect there to be diagnostics emitted
 on the annotated lines.  In this example, we expect to get:
 
-.. code-block:: c++
+.. code-block:: text
 
   test.c:6:1: error: indirection requires pointer operand ('foo' invalid)
 *X; // error
@@ -1422,7 +1422,7 @@ pretty-printed version of the CFG to sta
 when one is using a debugger such as gdb.  For example, here is the output of
 ``FooCFG->dump()``:
 
-.. code-block:: c++
+.. code-block:: text
 
  [ B5 (ENTRY) ]
 Predecessors (0):


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


Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.

2016-02-24 Thread Logan Chien via cfe-commits
logan added inline comments.


Comment at: lib/Headers/unwind.h:61
@@ +60,3 @@
+#define _UNWIND_ARM_EHABI 0
+#endif
+

logan wrote:
> compnerd wrote:
> > logan wrote:
> > > compnerd wrote:
> > > > logan wrote:
> > > > > Since this is `unwind.h`, I feel that we can get a step further and 
> > > > > use `__ARM_EABI_UNWINDER__` to get more compatibility to GCC's 
> > > > > unwind.h.
> > > > > 
> > > > > Here's the change:
> > > > > 
> > > > > ```
> > > > > #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
> > > > > !defined(__ARM_DWARF_EH__)
> > > > > #define __ARM_EABI_UNWINDER__ 1
> > > > > #endif
> > > > > ```
> > > > I dont know if we really need to imitate GCC's macros here.  Am I 
> > > > mistaken in that they assume that `__ARM_EABI_UNWINDER__` has been set 
> > > > to 1 externally if targeting such an environment?  I think that it is 
> > > > better to use the reserved namespace and intrude into libunwind's 
> > > > namespace as already done here.
> > > > Am I mistaken in that they assume that `__ARM_EABI_UNWINDER__` has been 
> > > > set to 1 externally if targeting such an environment?
> > > 
> > > Although this is an implementation detail, it was defined by `unwind.h` 
> > > in the implementation of GCC.
> > > 
> > > Remark: `__ARM_EABI_UNWINDER__` is not a pre-defined macro in GCC and 
> > > Clang (can be checked with ` gcc -dM -E - < /dev/null`.)
> > > 
> > > BTW, some applications or libraries need this macro to be defined after 
> > > including `` (such as uclibc, boost, or libc++abi 3.0.)  I 
> > > remembered that someone suggested to use `__ARM_EABI_UNWINDER__` instead 
> > > of  `LIBCXXABI_ARM_EHABI` when I was fixing libc++abi several years ago.  
> > > I chose `LIBCXXABI_ARM_EHABI` simply because `__ARM_EABI_UNWINDER__` 
> > > wasn't provided by clang at that time.
> > > 
> > > I am less concerned to namespace pollution, because this is already the 
> > > de facto implementation in GCC world and the macro names start with 
> > > underscores are reserved for compiler or standard libraries by convention.
> > > 
> > > Since this is file a public header and will be used for a long time, I 
> > > personally believe that it will be better to use an existing name with 
> > > the same meaning instead of introducing a new name.  In addition, this 
> > > will make it easier to port the application between gcc and clang.
> > I just checked, libc++abi has no use of this macro, nor does boost 1.60.  
> > uclibc only defines `__ARM_EABI_UNWINDER__`, but does not use it.  I also 
> > checked glibc and musl, and glibc like uclibc defines it while musl has no 
> > references to it.  This is injecting itself into the compiler namespace and 
> > is misleading, so I think I would really rather prefer the current patch as 
> > is.
> > I just checked, libc++abi has no use of this macro, nor does boost 1.60. 
> > uclibc only defines __ARM_EABI_UNWINDER__, but does not use it. I also 
> > checked glibc and musl, and glibc like uclibc defines it while musl has no 
> > references to it.
> 
> For uClibc++ and Boost I only did a simple Google search while writing the 
> previous reply.  Sorry for the brevity.
> 
> Although uClibc++ itself does not use `__ARM_EABI_UNWINDER__`, some 
> third-party ARM ports are using this macro.  For example, 
> [toyroot](https://github.com/luckboy/toyroot), a small build system for small 
> linux distribution, is maintaining a [local 
> patch](https://github.com/luckboy/toyroot/blob/master/patch/uClibc%2B%2B-0.2.4-arm-eabi-unwinder.patch).
>   Yet another example, [Aboriginal Linux](http://landley.net/aboriginal/) has 
> [another 
> patch](http://www.landley.net/hg/aboriginal/file/tip/sources/patches/uClibc%2B%2B-unwind-cxx.patch)
>  that requires this macro.  Someone even sent a 
> [patch](http://lists.uclibc.org/pipermail/uclibc/2012-June/046915.html) to 
> uClibc++ mailing list.
> 
> For Boost, I am referring to [this 
> thread](http://lists.boost.org/Archives/boost/2008/04/136332.php), although 
> it seems not being committed.
> 
> For libc++abi, I am referring to the [earlier 
> version](http://llvm.org/klaus/libcxxabi/blob/8b547a338373b6e149d8ceed34bbf6a979a1e10d/src/cxa_exception.hpp)
>  (roughly 3.4.)  You won't find `__ARM_EABI_UNWINDER__` in libc++abi master 
> branch because I removed it in 
> [05d51bcf07](http://llvm.org/klaus/libcxxabi/commit/05d51bcf07d0ec1c40785b4a860fd917410b4be1/)
>  when I was implementing the ARM EHABI support.  I remembered in the [review 
> comments](http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140414/103125.html)
>  Jonathan even suggested me to use `__ARM_EABI_UNWINDER__` instead.  I 
> couldn't do  so because `__ARM_EABI_UNWINDER__` was not defined by 
> `/lib/Headers/unwind.h`.
> 
> The main purpose to mention these projects is to demonstrate that 
> `__ARM_EABI_UNWINDER__` is a common knownledge between unwinder or 
> personality developers.  Many of us will come up with `__ARM_E

Re: [PATCH] D17385: clang-format: [JS] single quote double quoted strings.

2016-02-24 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 48945.
mprobst marked an inline comment as done.
mprobst added a comment.

- Move code closer together by piping Replacements into the FormatTokenLexer.


http://reviews.llvm.org/D17385

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

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -250,7 +250,7 @@
   verifyFormat("f({'a': [{}]});");
 }
 
-TEST_F(FormatTestJS, SingleQuoteStrings) {
+TEST_F(FormatTestJS, SingleQuotedStrings) {
   verifyFormat("this.function('', true);");
 }
 
@@ -1085,5 +1085,16 @@
getGoogleJSStyleWithColumns(20)));
 }
 
+TEST_F(FormatTestJS, RequoteDoubleQuotedStrings) {
+  EXPECT_EQ("var x = 'foo';", format("var x = \"foo\";"));
+  EXPECT_EQ("var x = 'fo\\'o\\'';", format("var x = \"fo'o'\";"));
+  EXPECT_EQ("var x = 'fo\\'o\\'';", format("var x = \"fo\\'o'\";"));
+  EXPECT_EQ("var x =\n"
+"'foo\\'';",
+// Code below is 15 chars wide, doesn't fit into the line with the
+// \ escape added.
+format("var x = \"foo'\";", getGoogleJSStyleWithColumns(15)));
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/YAMLTraits.h"
 #include 
+#include 
 #include 
 
 #define DEBUG_TYPE "format-formatter"
@@ -766,13 +767,13 @@
 class FormatTokenLexer {
 public:
   FormatTokenLexer(SourceManager &SourceMgr, FileID ID, FormatStyle &Style,
-   encoding::Encoding Encoding)
+   encoding::Encoding Encoding, tooling::Replacements &Replaces)
   : FormatTok(nullptr), IsFirstToken(true), GreaterStashed(false),
 LessStashed(false), Column(0), TrailingWhitespace(0),
 SourceMgr(SourceMgr), ID(ID), Style(Style),
 IdentTable(getFormattingLangOpts(Style)), Keywords(IdentTable),
-Encoding(Encoding), FirstInLineIndex(0), FormattingDisabled(false),
-MacroBlockBeginRegex(Style.MacroBlockBegin),
+Encoding(Encoding), Replaces(Replaces), FirstInLineIndex(0),
+FormattingDisabled(false), MacroBlockBeginRegex(Style.MacroBlockBegin),
 MacroBlockEndRegex(Style.MacroBlockEnd) {
 Lex.reset(new Lexer(ID, SourceMgr.getBuffer(ID), SourceMgr,
 getFormattingLangOpts(Style)));
@@ -791,6 +792,8 @@
   if (Style.Language == FormatStyle::LK_JavaScript)
 tryParseJSRegexLiteral();
   tryMergePreviousTokens();
+  if (Style.Language == FormatStyle::LK_JavaScript)
+tryRequoteJSStringLiteral();
   if (Tokens.back()->NewlinesBefore > 0 || Tokens.back()->IsMultiline)
 FirstInLineIndex = Tokens.size() - 1;
 } while (Tokens.back()->Tok.isNot(tok::eof));
@@ -1061,6 +1064,48 @@
 return false;
   }
 
+  // If the last token is a double-quoted string literal, generates a
+  // replacement with a single quoted string literal, escaping the contents in
+  // the process.
+  void tryRequoteJSStringLiteral() {
+FormatToken *FormatTok = Tokens.back();
+if (!FormatTok->isStringLiteral() || !FormatTok->TokenText.startswith("\""))
+  return;
+
+StringRef Input = FormatTok->TokenText;
+size_t ColumnWidth = FormatTok->TokenText.size();
+std::string Res("'");
+llvm::raw_string_ostream Out(Res);
+bool Escaped = false;
+for (size_t i = 1; i < Input.size() - 1; i++) {
+  switch (Input[i]) {
+  case '\\':
+Escaped = !Escaped;
+break;
+  case '\'':
+if (!Escaped) {
+  Out << '\\';
+  ColumnWidth++;
+}
+Escaped = false;
+break;
+  default:
+Escaped = false;
+break;
+  }
+  Out << Input[i];
+}
+Out << '\'';
+
+// For formatting, count the number of non-escaped single quotes in them
+// and adjust ColumnWidth to take the added escapes into account.
+FormatTok->ColumnWidth = ColumnWidth;
+
+SourceRange Range(FormatTok->Tok.getLocation(), FormatTok->Tok.getEndLoc());
+Replaces.insert(tooling::Replacement(
+SourceMgr, CharSourceRange::getCharRange(Range), Out.str()));
+  }
+
   bool tryMerge_TMacro() {
 if (Tokens.size() < 4)
   return false;
@@ -1359,6 +1404,7 @@
   IdentifierTable IdentTable;
   AdditionalKeywords Keywords;
   encoding::Encoding Encoding;
+  tooling::Replacements &Replaces;
   llvm::SpecificBumpPtrAllocator Allocator;
   // Index (in 'Tokens') of the last token that starts a new line.
   unsigned FirstInLineIndex;
@@ -1443,7 +1489,7 @@
 
   tooling::Replacements format(bool *IncompleteFormat) {
 tooling::Replacements Result;
-FormatTokenLexer Tokens(SourceMgr, ID, Style, Encoding);
+FormatTokenLexer Tokens

Re: [PATCH] D17385: clang-format: [JS] single quote double quoted strings.

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


Comment at: lib/Format/Format.cpp:1579
@@ +1578,3 @@
+  // The width of the extra \ escapes is taken into account in getNextToken.
+  void requoteJSStringLiterals(tooling::Replacements &Replaces,
+   FormatToken *Current) {

djasper wrote:
> What's the reason not to do this in FormatTokenLexer, ideally at the same 
> time when increasing the length?
Done. I initially wanted to avoid having FormatTokenLexer generate 
Replacements, but this seems cleaner indeed.


http://reviews.llvm.org/D17385



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


Re: [PATCH] D17385: clang-format: [JS] single quote double quoted strings.

2016-02-24 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 48946.
mprobst marked an inline comment as done.
mprobst added a comment.

- Move code closer together by piping Replacements into the FormatTokenLexer.
- remove sstream import


http://reviews.llvm.org/D17385

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

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -250,7 +250,7 @@
   verifyFormat("f({'a': [{}]});");
 }
 
-TEST_F(FormatTestJS, SingleQuoteStrings) {
+TEST_F(FormatTestJS, SingleQuotedStrings) {
   verifyFormat("this.function('', true);");
 }
 
@@ -1085,5 +1085,16 @@
getGoogleJSStyleWithColumns(20)));
 }
 
+TEST_F(FormatTestJS, RequoteDoubleQuotedStrings) {
+  EXPECT_EQ("var x = 'foo';", format("var x = \"foo\";"));
+  EXPECT_EQ("var x = 'fo\\'o\\'';", format("var x = \"fo'o'\";"));
+  EXPECT_EQ("var x = 'fo\\'o\\'';", format("var x = \"fo\\'o'\";"));
+  EXPECT_EQ("var x =\n"
+"'foo\\'';",
+// Code below is 15 chars wide, doesn't fit into the line with the
+// \ escape added.
+format("var x = \"foo'\";", getGoogleJSStyleWithColumns(15)));
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -766,13 +766,13 @@
 class FormatTokenLexer {
 public:
   FormatTokenLexer(SourceManager &SourceMgr, FileID ID, FormatStyle &Style,
-   encoding::Encoding Encoding)
+   encoding::Encoding Encoding, tooling::Replacements &Replaces)
   : FormatTok(nullptr), IsFirstToken(true), GreaterStashed(false),
 LessStashed(false), Column(0), TrailingWhitespace(0),
 SourceMgr(SourceMgr), ID(ID), Style(Style),
 IdentTable(getFormattingLangOpts(Style)), Keywords(IdentTable),
-Encoding(Encoding), FirstInLineIndex(0), FormattingDisabled(false),
-MacroBlockBeginRegex(Style.MacroBlockBegin),
+Encoding(Encoding), Replaces(Replaces), FirstInLineIndex(0),
+FormattingDisabled(false), MacroBlockBeginRegex(Style.MacroBlockBegin),
 MacroBlockEndRegex(Style.MacroBlockEnd) {
 Lex.reset(new Lexer(ID, SourceMgr.getBuffer(ID), SourceMgr,
 getFormattingLangOpts(Style)));
@@ -791,6 +791,8 @@
   if (Style.Language == FormatStyle::LK_JavaScript)
 tryParseJSRegexLiteral();
   tryMergePreviousTokens();
+  if (Style.Language == FormatStyle::LK_JavaScript)
+tryRequoteJSStringLiteral();
   if (Tokens.back()->NewlinesBefore > 0 || Tokens.back()->IsMultiline)
 FirstInLineIndex = Tokens.size() - 1;
 } while (Tokens.back()->Tok.isNot(tok::eof));
@@ -1061,6 +1063,48 @@
 return false;
   }
 
+  // If the last token is a double-quoted string literal, generates a
+  // replacement with a single quoted string literal, escaping the contents in
+  // the process.
+  void tryRequoteJSStringLiteral() {
+FormatToken *FormatTok = Tokens.back();
+if (!FormatTok->isStringLiteral() || !FormatTok->TokenText.startswith("\""))
+  return;
+
+StringRef Input = FormatTok->TokenText;
+size_t ColumnWidth = FormatTok->TokenText.size();
+std::string Res("'");
+llvm::raw_string_ostream Out(Res);
+bool Escaped = false;
+for (size_t i = 1; i < Input.size() - 1; i++) {
+  switch (Input[i]) {
+  case '\\':
+Escaped = !Escaped;
+break;
+  case '\'':
+if (!Escaped) {
+  Out << '\\';
+  ColumnWidth++;
+}
+Escaped = false;
+break;
+  default:
+Escaped = false;
+break;
+  }
+  Out << Input[i];
+}
+Out << '\'';
+
+// For formatting, count the number of non-escaped single quotes in them
+// and adjust ColumnWidth to take the added escapes into account.
+FormatTok->ColumnWidth = ColumnWidth;
+
+SourceRange Range(FormatTok->Tok.getLocation(), FormatTok->Tok.getEndLoc());
+Replaces.insert(tooling::Replacement(
+SourceMgr, CharSourceRange::getCharRange(Range), Out.str()));
+  }
+
   bool tryMerge_TMacro() {
 if (Tokens.size() < 4)
   return false;
@@ -1359,6 +1403,7 @@
   IdentifierTable IdentTable;
   AdditionalKeywords Keywords;
   encoding::Encoding Encoding;
+  tooling::Replacements &Replaces;
   llvm::SpecificBumpPtrAllocator Allocator;
   // Index (in 'Tokens') of the last token that starts a new line.
   unsigned FirstInLineIndex;
@@ -1443,7 +1488,7 @@
 
   tooling::Replacements format(bool *IncompleteFormat) {
 tooling::Replacements Result;
-FormatTokenLexer Tokens(SourceMgr, ID, Style, Encoding);
+FormatTokenLexer Tokens(SourceMgr, ID, Style, Encoding, Result);
 
 UnwrappedLineParser Parser(Style, Tokens.getKeywords(), Tokens.lex(),

Re: [PATCH] D16044: getVariableName() for MemRegion

2016-02-24 Thread Alexander Droste via cfe-commits
Alexander_Droste updated this revision to Diff 48940.
Alexander_Droste added a comment.

Changes:

- remove `if (VariableName.size() && VariableName.back() == '\'')` check
- call `getVariableName` for index if Region is no `ConcreteInt`

Hi Gábor,
sorry about the delay! Here's the updated patch.
Is it really possible to reduce string copying in this case, with the help of 
`llvm::Twine`?
The problem with `llvm::Twine` seems to me that it cannot be modified after 
initialisation. 
So there's no way to do sth. like: `Twine t("a" + "b"); t += "c"`. A new Twine 
object needs to
be created for each subsequent concatenation. Do you have an idea how twine 
could be
applied here? Else I would claim that this function gets only used for 
diagnostics why 
this level of efficiency might not be required.


http://reviews.llvm.org/D16044

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

Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -632,6 +632,48 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName{""};
+  std::string ArrayIndices{""};
+  const clang::ento::MemRegion *R = this;
+  llvm::SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const clang::ento::ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+std::string idx{""};
+// Index is a ConcreteInt.
+if (auto CI = ER->getIndex().getAs()) {
+  llvm::SmallString<2> intValAsString;
+  CI->getValue().toString(intValAsString);
+  idx = {intValAsString.begin(), intValAsString.end()};
+}
+// If not a ConcreteInt, try to obtain the variable
+// name by calling 'getVariableName()' recursively.
+else {
+  idx = R->getVariableName();
+  if (!idx.empty()) {
+// Exclude single quotes surrounding the index var name.
+idx = idx.substr(1, idx.size() - 2);
+  }
+}
+ArrayIndices += "]" + idx + "[";
+R = ER->getSuperRegion();
+  }
+  std::reverse(ArrayIndices.begin(), ArrayIndices.end());
+
+  // Get variable name.
+  if (R && R->canPrintPretty()) {
+R->printPretty(os);
+VariableName = os.str();
+// Combine variable name with indices.
+VariableName.insert(VariableName.size() - 1, ArrayIndices);
+  }
+
+  return VariableName;
+}
+
 
//===--===//
 // MemRegionManager methods.
 
//===--===//


Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -632,6 +632,48 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName{""};
+  std::string ArrayIndices{""};
+  const clang::ento::MemRegion *R = this;
+  llvm::SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  co

Re: [PATCH][modules][PR26237]

2016-02-24 Thread Vassil Vassilev via cfe-commits


On 24/02/16 02:05, Richard Smith wrote:

Calling getMostRecentDecl seems like a slightly fragile way to avoid
iterator invalidation here. Instead...

@@ -214,6 +212,19 @@ namespace clang {
unsigned I = Record.size();
Record.push_back(0);

+  auto &Specializations = Common->Specializations;
+  auto &&PartialSpecializations = getPartialSpecializations(Common);
+
+  // AddFirstDeclFromEachModule might trigger deserialization, invalidating
+  // *Specializations iterators. Force the deserialization in advance.
+  llvm::SmallVector Specs;
+  for (auto &Entry : Specializations)
+ Specs.push_back(getSpecializationDecl(Entry));
+  for (auto &Entry : PartialSpecializations)
+ Specs.push_back(getSpecializationDecl(Entry));
+  for (auto *D : Specs)
+ D->getMostRecentDecl();

... delete these two lines, and...

+
for (auto &Entry : Specializations) {

... iterate over "Specs" here

  auto *D = getSpecializationDecl(Entry);

... and you don't need this line any more.

  assert(D->isCanonicalDecl() && "non-canonical decl in set");

You can then remove the following, identical, PartialSpecializations loop.

Done.


You also have some tabs in your patch (on the Specs.push_back lines);

Sorry about the tabs, they came from a brand new VM and unconfigured emacs.

please fix those prior to commit. With those changes, this LGTM.

Would it make sense to ask for commit perms?


On Mon, Feb 22, 2016 at 7:11 AM, Vassil Vassilev  wrote:

ping...

On 30/01/16 21:13, Vassil Vassilev wrote:

On 30/01/16 18:36, David Blaikie wrote:



On Sat, Jan 30, 2016 at 9:00 AM, Vassil Vassilev 
wrote:

AFAICT the making a test case independent on STL is the hard part. I think
it will be always failing due to the relocation of the memory region of the
underlying SmallVector.


Sorry, I think I didn't explain myself well. What I mean is - due to the
instability of test cases for UB (especially library UB), we don't usually
commit test cases for them - we just fix them without tests. About the only
time I think committing a test is helpful for UB (especially library UB) is
if we have a reliable way to test/catch the UB (eg: the sanitizers or a
checking STL that fails fast on validation violations). So, while it would
be good to provide/demonstrate your test case, I would not commit the test
case unless it's a minimal reproduction in the presence of one of those
tools (sanitizers or checking STL) - and would just commit the fix without a
test case, usually.

(I'm not actually reviewing this patch - I don't know much about the modules
code, but just providing a bit of context and first-pass-review)

Got it. Thanks!
--Vassil




On 30/01/16 17:37, David Blaikie wrote:

Yeah, it's good to have a reproduction, but I wouldn't actually commit one
- unless you have a checked stl to test against that always fails on
possibly-invalidating sequences of operations, then you'd have a fairly
simple reproduction

On Jan 30, 2016 8:23 AM, "Vassil Vassilev"  wrote:

Sorry.

Our module builds choke on merging several modules, containing
declarations from STL (we are using libc++, no modulemaps).

When writing a new module containing the definition of a STL
reverse_iterator, it collects all its template specializations. Some of the
specializations need to be deserialized from a third module. This triggers
an iterator invalidation bug because of the deserialization happening when
iterating the specializations container itself. This happens only when the
container's capacity is exceeded and the relocation invalidates the
iterators and at best causes a crash (see valgrind reports in the bug
report). Unfortunately I haven't been able to make the reproducer
independent on STL.

--Vassil

On 30/01/16 17:08, David Blaikie wrote:

It might be handy to give an overview of the issue in the review (&
certainly in the commit) message rather than only citing the bug number

On Jan 30, 2016 6:49 AM, "Vassil Vassilev via cfe-commits"
 wrote:

Attaching a fix to https://llvm.org/bugs/show_bug.cgi?id=26237

Please review.

Many thanks!
--Vassil

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






From a90e8ec1bd8eeb7d35e43d29a2aab47fc444e12e Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Sat, 30 Jan 2016 14:50:06 +0100
Subject: [PATCH] Writing out template specializations might trigger
 deserialization.

Rebuilding a redecl chain of template (partial) specialization might be trigger
deserialization. If the container's capacity is exceeded the relocation
invalidates the iterators and at best causes a crash. Force deserialization by
copying the collections before iterating.

Fixes PR26237 (https://llvm.org/bugs/show_bug.cgi?id=26237)

I haven't been successful in reducing a reasonable testcase. It should contain
multimodule setup and at least 8 specializations being deserializaed in a very
s

Re: [PATCH] D16044: getVariableName() for MemRegion

2016-02-24 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

In http://reviews.llvm.org/D16044#360737, @Alexander_Droste wrote:

> Hi Gábor,
>  Is it really possible to reduce string copying in this case, with the help 
> of `llvm::Twine`?
>  The problem with `llvm::Twine` seems to me that it cannot be modified after 
> initialisation. 
>  So there's no way to do sth. like: `Twine t("a" + "b"); t += "c"`. A new 
> Twine object needs to
>  be created for each subsequent concatenation. Do you have an idea how twine 
> could be
>  applied here? Else I would claim that this function gets only used for 
> diagnostics why 
>  this level of efficiency might not be required.


Hi!

It works the following way:

If you write something like A = B + C + D; it will create two temporary 
strings, all of them might allocate memory.
If you write something like A = (Twine(B) + C + D).str(); it will only do one 
temporary string and one allocation. 
So basically twine creates a data structure of pointers that points to the 
strings that you would like to concatenate, and once you do the conversion to 
string, it will do all the concatenations with one allocation.


http://reviews.llvm.org/D16044



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


Re: [PATCH] D16044: getVariableName() for MemRegion

2016-02-24 Thread Alexander Droste via cfe-commits
Alexander_Droste updated this revision to Diff 48949.
Alexander_Droste added a comment.

- Changed  `idx = R->getVariableName();` to  `idx = ER->getVariableName();` as 
it better describes what is happening on a semantic level.


http://reviews.llvm.org/D16044

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

Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -632,6 +632,48 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName{""};
+  std::string ArrayIndices{""};
+  const clang::ento::MemRegion *R = this;
+  llvm::SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const clang::ento::ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+std::string idx{""};
+// Index is a ConcreteInt.
+if (auto CI = ER->getIndex().getAs()) {
+  llvm::SmallString<2> intValAsString;
+  CI->getValue().toString(intValAsString);
+  idx = {intValAsString.begin(), intValAsString.end()};
+}
+// If not a ConcreteInt, try to obtain the variable
+// name by calling 'getVariableName()' recursively.
+else {
+  idx = ER->getVariableName();
+  if (!idx.empty()) {
+// Exclude single quotes surrounding the index var name.
+idx = idx.substr(1, idx.size() - 2);
+  }
+}
+ArrayIndices += "]" + idx + "[";
+R = ER->getSuperRegion();
+  }
+  std::reverse(ArrayIndices.begin(), ArrayIndices.end());
+
+  // Get variable name.
+  if (R && R->canPrintPretty()) {
+R->printPretty(os);
+VariableName = os.str();
+// Combine variable name with indices.
+VariableName.insert(VariableName.size() - 1, ArrayIndices);
+  }
+
+  return VariableName;
+}
+
 
//===--===//
 // MemRegionManager methods.
 
//===--===//


Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -632,6 +632,48 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName{""};
+  std::string ArrayIndices{""};
+  const clang::ento::MemRegion *R = this;
+  llvm::SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const clang::ento::ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+std::string idx{""};
+// Index is a ConcreteInt.
+if (auto CI = ER->getIndex().getAs()) {
+  llvm::SmallString<2> intValAsString;
+  CI->getValue().toString(intValAsString);
+  idx = {intValAsString.begin(), intValAsString.end()};
+}
+// If not a ConcreteInt, try to obtain the variable
+// name by calling 'getVariableName()' recursively.
+else {
+  idx = ER->getVariableName();
+  if (!idx.empty()) {
+// Exclude single quotes surrounding 

Re: r261717 - Default vaarg lowering should support indirect struct types.

2016-02-24 Thread Hans Wennborg via cfe-commits
On Wed, Feb 24, 2016 at 5:11 AM, Joerg Sonnenberger via cfe-commits
 wrote:
> On Wed, Feb 24, 2016 at 03:03:32AM -, James Y Knight via cfe-commits 
> wrote:
>> Author: jyknight
>> Date: Tue Feb 23 20:59:33 2016
>> New Revision: 261717
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=261717&view=rev
>> Log:
>> Default vaarg lowering should support indirect struct types.
>>
>> Fixes PR11517 for SPARC.
>
> It would be nice to get the PPC32 and XCore parts finished by those
> involved with the platforms, but I would like to see this merged into
> the 3.8 branch at some point after 3.8.0. It is one of the missing basic
> codegen items for SPARC.

I've put it on the list.

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


Re: [PATCH] D16044: getVariableName() for MemRegion

2016-02-24 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:636
@@ +635,3 @@
+std::string MemRegion::getVariableName() const {
+  std::string VariableName{""};
+  std::string ArrayIndices{""};

Small nit, I prefer to call the default constructor here.


Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:638
@@ +637,3 @@
+  std::string ArrayIndices{""};
+  const clang::ento::MemRegion *R = this;
+  llvm::SmallString<50> buf;

Small nit: the mentioning the namespaces explicitly here and for smallstring 
and at some other places is redundant.


http://reviews.llvm.org/D16044



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


r261751 - [WinEH] Make sure terminate handlers have funclet operands

2016-02-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Feb 24 11:02:45 2016
New Revision: 261751

URL: http://llvm.org/viewvc/llvm-project?rev=261751&view=rev
Log:
[WinEH] Make sure terminate handlers have funclet operands

Calls to the terminate handler must be annotated within the exception
region they are within.

Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=261751&r1=261750&r2=261751&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Feb 24 11:02:45 2016
@@ -3064,16 +3064,6 @@ CodeGenFunction::EmitRuntimeCall(llvm::V
   return EmitRuntimeCall(callee, None, name);
 }
 
-/// Emits a simple call (never an invoke) to the given runtime function.
-llvm::CallInst *
-CodeGenFunction::EmitRuntimeCall(llvm::Value *callee,
- ArrayRef args,
- const llvm::Twine &name) {
-  llvm::CallInst *call = Builder.CreateCall(callee, args, name);
-  call->setCallingConv(getRuntimeCC());
-  return call;
-}
-
 // Calls which may throw must have operand bundles indicating which funclet
 // they are nested within.
 static void
@@ -3092,6 +3082,19 @@ getBundlesForFunclet(llvm::Value *Callee
   BundleList.emplace_back("funclet", CurrentFuncletPad);
 }
 
+/// Emits a simple call (never an invoke) to the given runtime function.
+llvm::CallInst *
+CodeGenFunction::EmitRuntimeCall(llvm::Value *callee,
+ ArrayRef args,
+ const llvm::Twine &name) {
+  SmallVector BundleList;
+  getBundlesForFunclet(callee, CurrentFuncletPad, BundleList);
+
+  llvm::CallInst *call = Builder.CreateCall(callee, args, BundleList, name);
+  call->setCallingConv(getRuntimeCC());
+  return call;
+}
+
 /// Emits a call or invoke to the given noreturn runtime function.
 void CodeGenFunction::EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee,
ArrayRef args) {

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=261751&r1=261750&r2=261751&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Wed Feb 24 11:02:45 2016
@@ -1326,11 +1326,13 @@ llvm::BasicBlock *CodeGenFunction::getTe
   TerminateHandler = createBasicBlock("terminate.handler");
   Builder.SetInsertPoint(TerminateHandler);
   llvm::Value *Exn = nullptr;
+  SaveAndRestore RestoreCurrentFuncletPad(
+  CurrentFuncletPad);
   if (EHPersonality::get(*this).usesFuncletPads()) {
 llvm::Value *ParentPad = CurrentFuncletPad;
 if (!ParentPad)
   ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext());
-Builder.CreateCleanupPad(ParentPad);
+CurrentFuncletPad = Builder.CreateCleanupPad(ParentPad);
   } else {
 if (getLangOpts().CPlusPlus)
   Exn = getExceptionFromSlot();

Modified: cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp?rev=261751&r1=261750&r2=261751&view=diff
==
--- cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp Wed Feb 24 11:02:45 2016
@@ -72,6 +72,6 @@ void test_cleanup() {
 // CHECK:   ret void
 
 // CHECK: [[TERMINATE]]
-// CHECK:   cleanuppad within none []
-// CHECK-NEXT:   call void @"\01?terminate@@YAXXZ"()
+// CHECK:   %[[CLEANUPPAD:.*]] = cleanuppad within none []
+// CHECK-NEXT:   call void @"\01?terminate@@YAXXZ"() {{.*}} [ "funclet"(token 
%[[CLEANUPPAD]]) ]
 

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp?rev=261751&r1=261750&r2=261751&view=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp Wed Feb 24 
11:02:45 2016
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - 
-triple=x86_64-pc-windows-msvc -mconstructor-aliases -fexceptions 
-fcxx-exceptions -fms-compatibility-version=18.00 | FileCheck 
-check-prefix=MSVC2013 %s
-// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - 
-triple=x86_64-pc-windows-msvc -mconstructor-aliases -fexceptions 
-fcxx-exceptions -fms-compatibility-version=19.00 | FileCheck 
-check-prefix=MSVC2015 %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - 
-tri

Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.

2016-02-24 Thread Saleem Abdulrasool via cfe-commits
compnerd added inline comments.


Comment at: lib/Headers/unwind.h:61
@@ +60,3 @@
+#define _UNWIND_ARM_EHABI 0
+#endif
+

logan wrote:
> logan wrote:
> > compnerd wrote:
> > > logan wrote:
> > > > compnerd wrote:
> > > > > logan wrote:
> > > > > > Since this is `unwind.h`, I feel that we can get a step further and 
> > > > > > use `__ARM_EABI_UNWINDER__` to get more compatibility to GCC's 
> > > > > > unwind.h.
> > > > > > 
> > > > > > Here's the change:
> > > > > > 
> > > > > > ```
> > > > > > #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
> > > > > > !defined(__ARM_DWARF_EH__)
> > > > > > #define __ARM_EABI_UNWINDER__ 1
> > > > > > #endif
> > > > > > ```
> > > > > I dont know if we really need to imitate GCC's macros here.  Am I 
> > > > > mistaken in that they assume that `__ARM_EABI_UNWINDER__` has been 
> > > > > set to 1 externally if targeting such an environment?  I think that 
> > > > > it is better to use the reserved namespace and intrude into 
> > > > > libunwind's namespace as already done here.
> > > > > Am I mistaken in that they assume that `__ARM_EABI_UNWINDER__` has 
> > > > > been set to 1 externally if targeting such an environment?
> > > > 
> > > > Although this is an implementation detail, it was defined by `unwind.h` 
> > > > in the implementation of GCC.
> > > > 
> > > > Remark: `__ARM_EABI_UNWINDER__` is not a pre-defined macro in GCC and 
> > > > Clang (can be checked with ` gcc -dM -E - < /dev/null`.)
> > > > 
> > > > BTW, some applications or libraries need this macro to be defined after 
> > > > including `` (such as uclibc, boost, or libc++abi 3.0.)  I 
> > > > remembered that someone suggested to use `__ARM_EABI_UNWINDER__` 
> > > > instead of  `LIBCXXABI_ARM_EHABI` when I was fixing libc++abi several 
> > > > years ago.  I chose `LIBCXXABI_ARM_EHABI` simply because 
> > > > `__ARM_EABI_UNWINDER__` wasn't provided by clang at that time.
> > > > 
> > > > I am less concerned to namespace pollution, because this is already the 
> > > > de facto implementation in GCC world and the macro names start with 
> > > > underscores are reserved for compiler or standard libraries by 
> > > > convention.
> > > > 
> > > > Since this is file a public header and will be used for a long time, I 
> > > > personally believe that it will be better to use an existing name with 
> > > > the same meaning instead of introducing a new name.  In addition, this 
> > > > will make it easier to port the application between gcc and clang.
> > > I just checked, libc++abi has no use of this macro, nor does boost 1.60.  
> > > uclibc only defines `__ARM_EABI_UNWINDER__`, but does not use it.  I also 
> > > checked glibc and musl, and glibc like uclibc defines it while musl has 
> > > no references to it.  This is injecting itself into the compiler 
> > > namespace and is misleading, so I think I would really rather prefer the 
> > > current patch as is.
> > > I just checked, libc++abi has no use of this macro, nor does boost 1.60. 
> > > uclibc only defines __ARM_EABI_UNWINDER__, but does not use it. I also 
> > > checked glibc and musl, and glibc like uclibc defines it while musl has 
> > > no references to it.
> > 
> > For uClibc++ and Boost I only did a simple Google search while writing the 
> > previous reply.  Sorry for the brevity.
> > 
> > Although uClibc++ itself does not use `__ARM_EABI_UNWINDER__`, some 
> > third-party ARM ports are using this macro.  For example, 
> > [toyroot](https://github.com/luckboy/toyroot), a small build system for 
> > small linux distribution, is maintaining a [local 
> > patch](https://github.com/luckboy/toyroot/blob/master/patch/uClibc%2B%2B-0.2.4-arm-eabi-unwinder.patch).
> >   Yet another example, [Aboriginal Linux](http://landley.net/aboriginal/) 
> > has [another 
> > patch](http://www.landley.net/hg/aboriginal/file/tip/sources/patches/uClibc%2B%2B-unwind-cxx.patch)
> >  that requires this macro.  Someone even sent a 
> > [patch](http://lists.uclibc.org/pipermail/uclibc/2012-June/046915.html) to 
> > uClibc++ mailing list.
> > 
> > For Boost, I am referring to [this 
> > thread](http://lists.boost.org/Archives/boost/2008/04/136332.php), although 
> > it seems not being committed.
> > 
> > For libc++abi, I am referring to the [earlier 
> > version](http://llvm.org/klaus/libcxxabi/blob/8b547a338373b6e149d8ceed34bbf6a979a1e10d/src/cxa_exception.hpp)
> >  (roughly 3.4.)  You won't find `__ARM_EABI_UNWINDER__` in libc++abi master 
> > branch because I removed it in 
> > [05d51bcf07](http://llvm.org/klaus/libcxxabi/commit/05d51bcf07d0ec1c40785b4a860fd917410b4be1/)
> >  when I was implementing the ARM EHABI support.  I remembered in the 
> > [review 
> > comments](http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140414/103125.html)
> >  Jonathan even suggested me to use `__ARM_EABI_UNWINDER__` instead.  I 
> > couldn't do  so because `__ARM_EABI_UNWINDER__` was not defined by 
> > `/lib/Headers/unwind.h`.
> > 

Re: [PATCH] D16044: getVariableName() for MemRegion

2016-02-24 Thread Alexander Droste via cfe-commits
Alexander_Droste updated this revision to Diff 48953.
Alexander_Droste added a comment.

- remove string idx variable -> remove string copy assignments
- use Twine to reduce temporary string objects, built during concatenation

Is `ArrayIndices = llvm::Twine(ArrayIndices + "]" + intValAsString.str() + 
"[").str();`
preferable to: `ArrayIndices += llvm::Twine("]" + intValAsString.str() + 
"[").str();`
with respect to efficiency? If not, I would prefer the second version, as it is 
a bit more concise.


http://reviews.llvm.org/D16044

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

Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -632,6 +632,49 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName;
+  std::string ArrayIndices;
+  const MemRegion *R = this;
+  SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+// Index is a ConcreteInt.
+if (auto CI = ER->getIndex().getAs()) {
+  llvm::SmallString<2> intValAsString;
+  CI->getValue().toString(intValAsString);
+  ArrayIndices =
+  llvm::Twine(ArrayIndices + "]" + intValAsString.str() + "[").str();
+}
+// If not a ConcreteInt, try to obtain the variable
+// name by calling 'getVariableName()' recursively.
+else {
+  std::string idx = ER->getVariableName();
+  if (!idx.empty()) {
+// Substring to exclude single quotes surrounding the index var name.
+ArrayIndices = llvm::Twine(ArrayIndices + "]" +
+   idx.substr(1, idx.size() - 2) + "[")
+   .str();
+  }
+}
+R = ER->getSuperRegion();
+  }
+  std::reverse(ArrayIndices.begin(), ArrayIndices.end());
+
+  // Get variable name.
+  if (R && R->canPrintPretty()) {
+R->printPretty(os);
+VariableName = os.str();
+// Combine variable name with indices.
+VariableName.insert(VariableName.size() - 1, ArrayIndices);
+  }
+
+  return VariableName;
+}
+
 
//===--===//
 // MemRegionManager methods.
 
//===--===//


Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -632,6 +632,49 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName;
+  std::string ArrayIndices;
+  const MemRegion *R = this;
+  SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+// Index is a ConcreteInt.
+if (auto CI = ER->getIndex().getAs()) {
+  llvm::SmallString<2> intValAsString;
+  CI->getValue().toString(intValAsString);
+  Arra

Re: [PATCH] D16044: getVariableName() for MemRegion

2016-02-24 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

Since we went with the twine solution, I think we can get rid of the reverse 
stuff.

Note that:
Twine should be used like: (Twine(A) + B + C).str()
So the operator+ has twine as one of the operands.

Once these are fixed, it looks good to me.
Do you have commit access or do you need someone to commit this for you?


http://reviews.llvm.org/D16044



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


Re: [PATCH] D16044: getVariableName() for MemRegion

2016-02-24 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:672
@@ +671,3 @@
+// Combine variable name with indices.
+VariableName.insert(VariableName.size() - 1, ArrayIndices);
+  }

nit: this is in fact an append. It is cleaner instead of using insert.


http://reviews.llvm.org/D16044



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


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-02-24 Thread David Li via cfe-commits
davidxl added a comment.

Looks good to me -- and it makes the profile-gen and profile-use's cc1 option 
handling consistent.  Please check with Sean or Justin just in case before 
proceeding.


http://reviews.llvm.org/D15829



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


r261755 - [CLANG] [AVX512] [BUILTIN] Adding PSHUF{L|H}W{128|256|512} builtin to clang .

2016-02-24 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Wed Feb 24 11:39:35 2016
New Revision: 261755

URL: http://llvm.org/viewvc/llvm-project?rev=261755&view=rev
Log:
[CLANG] [AVX512] [BUILTIN] Adding PSHUF{L|H}W{128|256|512} builtin to clang .

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

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

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=261755&r1=261754&r2=261755&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Feb 24 11:39:35 2016
@@ -1632,6 +1632,12 @@ TARGET_BUILTIN(__builtin_ia32_prorvd128_
 TARGET_BUILTIN(__builtin_ia32_prorvd256_mask, "V8iV8iV8iV8iUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_prorvq128_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_prorvq256_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pshufhw512_mask, 
"V32sV32sIiV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pshuflw512_mask, 
"V32sV32sIiV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pshufhw128_mask, 
"V8sV8sIiV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pshufhw256_mask, 
"V16sV16sIiV16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pshuflw128_mask, 
"V8sV8sIiV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pshuflw256_mask, 
"V16sV16sIiV16sUs","","avx512bw,avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=261755&r1=261754&r2=261755&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Wed Feb 24 11:39:35 2016
@@ -1589,6 +1589,54 @@ _mm512_maskz_cvtepu8_epi16 (__mmask32 __
   (__v32hi)(__m512i)(b), \
   (p), (__mmask32)(m)); })
 
+#define _mm512_shufflehi_epi16( __A, __imm) __extension__ ({ \
+__builtin_ia32_pshufhw512_mask ((__v32hi)( __A),\
+  ( __imm),\
+   (__v32hi)\
+   _mm512_setzero_hi (),\
+   (__mmask32) -1);\
+})
+
+#define _mm512_mask_shufflehi_epi16( __W, __U, __A ,__imm) __extension__ ({ \
+__builtin_ia32_pshufhw512_mask ((__v32hi) (__A),\
+   (__imm),\
+   (__v32hi)( __W),\
+   (__mmask32)( __U));\
+})
+
+
+#define _mm512_maskz_shufflehi_epi16( __U, __A ,__imm) __extension__ ({ \
+__builtin_ia32_pshufhw512_mask ((__v32hi) (__A),\
+   (__imm),\
+   (__v32hi)\
+   _mm512_setzero_hi (),\
+   (__mmask32)( __U));\
+})
+
+#define _mm512_shufflelo_epi16( __A, __imm) __extension__ ({ \
+__builtin_ia32_pshuflw512_mask ((__v32hi)( __A),\
+  ( __imm),\
+   (__v32hi)\
+   _mm512_setzero_hi (),\
+   (__mmask32) -1);\
+})
+
+
+#define _mm512_mask_shufflelo_epi16( __W, __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshuflw512_mask ((__v32hi) (__A),\
+   (__imm),\
+   (__v32hi)( __W),\
+   (__mmask32)( __U));\
+})
+
+
+#define _mm512_maskz_shufflelo_epi16( __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshuflw512_mask ((__v32hi) (__A),\
+   (__imm),\
+   (__v32hi)\
+   _mm512_setzero_hi (),\
+   (__mmask32)( __U));\
+})
 
 #undef __DEFAULT_FN_ATTRS
 

Modified: cfe/trunk/lib/Headers/avx512vlbwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlbwintrin.h?rev=261755&r1=261754&r2=261755&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlbwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlbwintrin.h Wed Feb 24 11:39:35 2016
@@ -31,6 +31,11 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("avx512vl,avx512bw")))
 
+static  __inline __m128i __DEFAULT_FN_ATTRS
+_mm_setzero_hi(void){
+return (__m128i){ 0LL, 0LL };
+}
+
 /* Integer compare */
 
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
@@ -2401,6 +2406,67 @@ _mm256_maskz_cvtepu8_epi16 (__mmask16 __
   (__v16hi)(__m256i)(b), \
   (p), (__mmask16)(m)); })
 
+#define _mm_mask_shufflehi_epi16( __W, __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshufhw128_mask ((__v8hi) __A, (__imm),\
+   (__v8hi)( __W),\
+   (__mmas

Re: [PATCH] D16040: [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr

2016-02-24 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: include/clang/Basic/AttrDocs.td:1572
@@ +1571,3 @@
+The __read_only, __write_only, __read_write, read_only, write_only and
+read_write names are reserved for use as access qualifiers and shall not be
+used otherwise.

Anastasia wrote:
> what about __read_write?
Oh, I see it now. May be we could group 
  __read_only/read_only, __write_only/write_only ...


http://reviews.llvm.org/D16040



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


Re: [PATCH] D17438: [OpenCL] Add Sema checks for atomics and implicit declaration

2016-02-24 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Yes, I think it deserves clarification. Could you submit a bug to Khronos then?


http://reviews.llvm.org/D17438



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


r261756 - Objective-C: Add a size field to non-fragile category metadata.

2016-02-24 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Feb 24 11:49:50 2016
New Revision: 261756

URL: http://llvm.org/viewvc/llvm-project?rev=261756&view=rev
Log:
Objective-C: Add a size field to non-fragile category metadata.

This is mainly for extensibility. Note that fragile category metadata,
metadata for classes and protocols all have a size field.

Initial patch was provided by Greg Parker.

rdar://problem/24804226

Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/metadata-class-properties.m

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=261756&r1=261755&r2=261756&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Wed Feb 24 11:49:50 2016
@@ -5581,6 +5581,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFra
   //   const struct _protocol_list_t * const protocols;
   //   const struct _prop_list_t * const properties;
   //   const struct _prop_list_t * const class_properties;
+  //   const uint32_t size;
   // }
   CategorynfABITy = llvm::StructType::create("struct._category_t",
  Int8PtrTy, ClassnfABIPtrTy,
@@ -5589,6 +5590,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFra
  ProtocolListnfABIPtrTy,
  PropertyListPtrTy,
  PropertyListPtrTy,
+ IntTy,
  nullptr);
 
   // New types for nonfragile abi messaging.
@@ -6140,6 +6142,7 @@ llvm::Value *CGObjCNonFragileABIMac::Gen
 ///   const struct _protocol_list_t * const protocols;
 ///   const struct _prop_list_t * const properties;
 ///   const struct _prop_list_t * const class_properties;
+///   const uint32_t size;
 /// }
 ///
 void CGObjCNonFragileABIMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) 
{
@@ -6154,7 +6157,7 @@ void CGObjCNonFragileABIMac::GenerateCat
   llvm::SmallString<64> ExtClassName(getClassSymbolPrefix());
   ExtClassName += Interface->getObjCRuntimeNameAsString();
 
-  llvm::Constant *Values[7];
+  llvm::Constant *Values[8];
   Values[0] = GetClassName(OCD->getIdentifier()->getName());
   // meta-class entry symbol
   llvm::GlobalVariable *ClassGV =
@@ -6212,6 +6215,9 @@ void CGObjCNonFragileABIMac::GenerateCat
 Values[6] = llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy);
   }
 
+  unsigned Size = 
CGM.getDataLayout().getTypeAllocSize(ObjCTypes.CategorynfABITy);
+  Values[7] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
+
   llvm::Constant *Init =
 llvm::ConstantStruct::get(ObjCTypes.CategorynfABITy,
   Values);

Modified: cfe/trunk/test/CodeGenObjC/metadata-class-properties.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/metadata-class-properties.m?rev=261756&r1=261755&r2=261756&view=diff
==
--- cfe/trunk/test/CodeGenObjC/metadata-class-properties.m (original)
+++ cfe/trunk/test/CodeGenObjC/metadata-class-properties.m Wed Feb 24 11:49:50 
2016
@@ -4,7 +4,7 @@
 // CHECK: @"\01l_OBJC_$_CLASS_PROP_LIST_Proto" = private global {{.*}} section 
"__DATA, __objc_const", align 8
 // CHECK: @"\01l_OBJC_PROTOCOL_$_Proto" = {{.*}} global %struct._protocol_t { 
{{.*}} i32 96, i32 {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_Proto" {{.*}} }
 // CHECK: @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_$_Category" = private global 
{{.*}} section "__DATA, __objc_const", align 8
-// CHECK: @"\01l_OBJC_$_CATEGORY_Foo_$_Category" = private global 
%struct._category_t { {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_$_Category" 
{{.*}} }, section "__DATA, __objc_const", align 8
+// CHECK: @"\01l_OBJC_$_CATEGORY_Foo_$_Category" = private global 
%struct._category_t { {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_$_Category" 
{{.*}}, i32 64 }, section "__DATA, __objc_const", align 8
 
 // CHECK: @"\01l_OBJC_$_CLASS_PROP_LIST_C" = private global {{.*}} section 
"__DATA, __objc_const", align 8
 // CHECK: @"\01l_OBJC_METACLASS_RO_$_C" = private global %struct._class_ro_t { 
{{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_C" {{.*}} }, section "__DATA, 
__objc_const", align 8


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


Re: [PATCH] D16044: getVariableName() for MemRegion

2016-02-24 Thread Alexander Droste via cfe-commits
Alexander_Droste updated this revision to Diff 48959.
Alexander_Droste added a comment.

- removed `reverse`
- fixed twine usage

I think `VariableName.insert(VariableName.size() - 1, ArrayIndices);` is needed 
here. 
varName, indices -> 'varname[...]' If append would be used, the second single 
quote would be before the indices, like this: 'varname'[...]

I don't have commit access, so I need someone to commit this for me.


http://reviews.llvm.org/D16044

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

Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -632,6 +632,50 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName;
+  std::string ArrayIndices;
+  const MemRegion *R = this;
+  SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+// Index is a ConcreteInt.
+if (auto CI = ER->getIndex().getAs()) {
+  llvm::SmallString<2> intValAsString;
+  CI->getValue().toString(intValAsString);
+  ArrayIndices =
+  (llvm::Twine("[") + intValAsString.str() + "]" + ArrayIndices).str();
+}
+// If not a ConcreteInt, try to obtain the variable
+// name by calling 'getVariableName()' recursively.
+else {
+  std::string idx = ER->getVariableName();
+  if (!idx.empty()) {
+// Substring to exclude single quotes surrounding the index var name.
+ArrayIndices = (llvm::Twine("[") + idx.substr(1, idx.size() - 2) + "]" 
+
+ArrayIndices)
+   .str();
+  }
+}
+R = ER->getSuperRegion();
+  }
+
+  // Get variable name.
+  if (R && R->canPrintPretty()) {
+R->printPretty(os);
+VariableName = os.str();
+// Combine variable name with indices. Place indices before second single
+// quote created by printPretty. 'varName' + [..] -> 'varName[..]'
+VariableName.insert(VariableName.size() - 1, ArrayIndices);
+  }
+
+  return VariableName;
+}
+
+
 
//===--===//
 // MemRegionManager methods.
 
//===--===//


Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -632,6 +632,50 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName;
+  std::string ArrayIndices;
+  const MemRegion *R = this;
+  SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+// Index is a ConcreteInt.
+if (auto CI = ER->getIndex().getAs()) {
+  llvm::SmallString<2> intValAsString;
+  CI->getValue().toString(intValAsString);
+  ArrayIndices =
+  (llvm::Twin

Re: [PATCH] D17345: [OpenCL] Improve diagnostics of address spaces for variables inside function

2016-02-24 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/storageclass-cl20.cl:11
@@ -10,3 +10,3 @@
   static global int S2 = 5;
-  static private int S3 = 5;// expected-error{{program scope variable must 
reside in global or constant address space}}
+  static private int S3 = 5;   // expected-error{{program scope variable must 
reside in global or constant address space}}
 

yaxunl wrote:
> this error msg is confusing. better say 'function scope variable with static 
> storage must ...'
Yes, I agree. The error message is not ideal. I will think of better wording 
here.


http://reviews.llvm.org/D17345



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


Re: [PATCH] SemaCXX: Support templates in availability attributes

2016-02-24 Thread Aaron Ballman via cfe-commits
On Tue, Feb 23, 2016 at 6:39 PM, Duncan P. N. Exon Smith
 wrote:
>
>> On 2016-Feb-23, at 11:18, Aaron Ballman  wrote:
>>
>> On Tue, Feb 23, 2016 at 1:52 PM, Manman Ren  wrote:
>>> This patch looks good to me. But I am not sure if Aaron has any comment.
>>>
>>> On Feb 22, 2016, at 6:19 PM, Duncan P. N. Exon Smith 
>>> wrote:
>>>
>>>
>>> On 2016-Feb-22, at 17:24, Manman Ren  wrote:
>>>
>>>
>>>
>>> On Feb 8, 2016, at 8:17 PM, Duncan P. N. Exon Smith 
>>> wrote:
>>>
>>> This patch adds support for templates in availability attributes.
>>> - If the context for an availability diagnostic is a
>>> `FunctionTemplateDecl`, look through it to the `FunctionDecl`.
>>>
>>>
>>> AvailabilityResult Decl::getAvailability(std::string *Message) const {
>>> +  if (auto *FTD = dyn_cast(this))
>>> +return FTD->getTemplatedDecl()->getAvailability(Message);
>>> +
>>> AvailabilityResult Result = AR_Available;
>>>
>>>
>>> This looks generally correct to me.
>>> The UnavailableAttr is attached to the FunctionDecl, not the
>>> FunctionTemplateDecl, so looking through sounds right.
>>>
>>> - Add `__has_feature(attribute_availability_in_templates)`.
>>>
>>>
>>> @Aaron, any comment on this?
>>> This patch adds extra support for Availability attribute (similar to
>>> attribute_availability_with_strict in r261548).
>>> Not sure if has_attribute can be used for this purpose.
>>
>> Given that we're already using __has_feature for the rest of the
>> availability attribute stuff, I think it's better to keep it all
>> grouped together instead of checking for some features with
>> __has_feature and others with __has_attribute.
>
> Besides that argument, this isn't adding any attributes, just checking
> how they behave.
>
>> If I understand
>> properly, this is taking code that would have previously been
>> ill-formed and making it well-formed, and that's why the feature
>> testing macro is required?
>
> Exactly.  Previously this was ill-formed:
> ```
> class Unavail __attribute__((unavailable));
>
> template 
> void foo(Unavail&) __attribute__((unavailable));
> ```
>
> Same for `__attribute((availability(macosx,unavailable)))`, and other
> triggers of "unavailable".

Okay, this makes sense to me, thank you for the explanation. LGTM!

~Aaron
>
>>
>> Thanks!
>>
>> ~Aaron
>>
>>>
>>> Manman
>>>
>>>
>>> Is there anything else I should be testing to be sure availability
>>> works correctly in templates?
>>>
>>>
>>> Maybe
>>> test()
>>> calling unavailable function from an unavailable template function
>>> calling an unavailable template function
>>>
>>> I think these all work with the current compiler. But I am not sure if we
>>> have existing test coverage.
>>>
>>>
>>> Thanks for the ideas; let me know if you have any others.
>>>
>>> Can you have a look at the new patch?
>>>
>>> Cheers,
>>> Manman
>>>
>>> I'm working on a patch to add
>>> availability markup to the libc++ headers, and this is the only
>>> problem I've hit so far.  Anyone have thoughts on other things I
>>> should test?
>>>
>>>
>>> <0001-SemaCXX-Support-templates-in-availability-attributes.patch>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261758 - AArch64: fix Cyclone CPU features list.

2016-02-24 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed Feb 24 11:57:48 2016
New Revision: 261758

URL: http://llvm.org/viewvc/llvm-project?rev=261758&view=rev
Log:
AArch64: fix Cyclone CPU features list.

It turns out we don't have CRC after all. Who knew?

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Preprocessor/aarch64-target-features.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=261758&r1=261757&r2=261758&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Feb 24 11:57:48 2016
@@ -2124,12 +2124,15 @@ static bool DecodeAArch64Mcpu(const Driv
   std::vector &Features) {
   std::pair Split = Mcpu.split("+");
   CPU = Split.first;
-  if (CPU == "cyclone" || CPU == "cortex-a53" || CPU == "cortex-a57" ||
+  if (CPU == "cortex-a53" || CPU == "cortex-a57" ||
   CPU == "cortex-a72" || CPU == "cortex-a35" || CPU == "exynos-m1" ||
   CPU == "kryo") {
 Features.push_back("+neon");
 Features.push_back("+crc");
 Features.push_back("+crypto");
+  } else if (CPU == "cyclone") {
+Features.push_back("+neon");
+Features.push_back("+crypto");
   } else if (CPU == "generic") {
 Features.push_back("+neon");
   } else {

Modified: cfe/trunk/test/Preprocessor/aarch64-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/aarch64-target-features.c?rev=261758&r1=261757&r2=261758&view=diff
==
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c Wed Feb 24 11:57:48 
2016
@@ -94,7 +94,7 @@
 // RUN: %clang -target aarch64 -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-A72 %s
 // RUN: %clang -target aarch64 -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-M1 %s
 // RUN: %clang -target aarch64 -mcpu=kryo -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-KRYO %s
-// CHECK-MCPU-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" 
"-target-feature" "+zcm" "-target-feature" "+zcz"
+// CHECK-MCPU-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+crypto" "-target-feature" "+zcm" 
"-target-feature" "+zcz"
 // CHECK-MCPU-A35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
@@ -103,7 +103,7 @@
 // CHECK-MCPU-KRYO: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
-// CHECK-ARCH-ARM64: "-target-cpu" "cyclone" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+zcm" 
"-target-feature" "+zcz"
+// CHECK-ARCH-ARM64: "-target-cpu" "cyclone" "-target-feature" "+neon" 
"-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz"
 
 // RUN: %clang -target aarch64 -march=armv8-a+fp+simd+crc+crypto -### -c %s 
2>&1 | FileCheck -check-prefix=CHECK-MARCH-1 %s
 // RUN: %clang -target aarch64 
-march=armv8-a+nofp+nosimd+nocrc+nocrypto+fp+simd+crc+crypto -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-MARCH-1 %s
@@ -125,7 +125,7 @@
 // RUN: %clang -target aarch64 -mcpu=generic+Crc -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-2 %s
 // RUN: %clang -target aarch64 -mcpu=GENERIC+nocrc+CRC -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-MCPU-2 %s
 // RUN: %clang -target aarch64 -mcpu=cortex-a53+noSIMD -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-MCPU-3 %s
-// CHECK-MCPU-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "-crypto" "-target-feature" 
"+zcm" "-target-feature" "+zcz"
+// CHECK-MCPU-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "-crypto" "-target-feature" "+zcm" "-target-feature" 
"+zcz"
 // CHECK-MCPU-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc"
 // CHECK-MCPU-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"-neon"
 


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


Re: [PATCH] D17561: [CUDA] Add conversion operators for threadIdx, blockIdx, gridDim, and blockDim to uint3 and dim3.

2016-02-24 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: lib/Headers/cuda_builtin_vars.h:72
@@ -66,1 +71,3 @@
+  // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator uint3() const;
 private:

Considering that built-in variables are never instantiated, I wonder how it's 
going to work as the operator will presumably need 'this' pointing *somewhere*, 
even if we don't use it. Unused 'this' would probably get optimized away with 
optimizations on, but -O0 may cause problems.


http://reviews.llvm.org/D17561



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


[PATCH] D17575: Determine if there's a getDecl member function using less hacks

2016-02-24 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: sbenza, klimek.
aaron.ballman added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

ASTMatchersInternal uses a custom type trait to determine the presence or 
absence of a getDecl member function. While the current implementation works, 
it requires compiler-specific hackery to work around some MSVC issues. This 
patch replaces the original implementation with one that requires less 
compiler-specific work.

http://reviews.llvm.org/D17575

Files:
  include/clang/ASTMatchers/ASTMatchersInternal.h

Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -569,32 +569,21 @@
   return false;
 }
 
-// Metafunction to determine if type T has a member called
-// getDecl.
-#if defined(_MSC_VER) && !defined(__clang__)
-// For MSVC, we use a weird nonstandard __if_exists statement, as it
-// is not standards-conformant enough to properly compile the standard
-// code below. (At least up through MSVC 2015 require this workaround)
-template  struct has_getDecl {
-  __if_exists(T::getDecl) {
-enum { value = 1 };
-  }
-  __if_not_exists(T::getDecl) {
-enum { value = 0 };
-  }
+// Metafunction to determine if type T has a member called getDecl.
+template 
+class has_getDecl {
+  typedef char yes[1];
+  typedef char no[2];
+
+  template 
+  static yes& test(Inner *I, decltype(I->getDecl()) * = nullptr);
+
+  template 
+  static no& test(...);
+
+public:
+  static const bool value = sizeof(test(nullptr)) == sizeof(yes);
 };
-#else
-// There is a default template inheriting from "false_type". Then, a
-// partial specialization inherits from "true_type". However, this
-// specialization will only exist when the call to getDecl() isn't an
-// error -- it vanishes by SFINAE when the member doesn't exist.
-template  struct type_sink_to_void { typedef void type; };
-template  struct has_getDecl : std::false_type {};
-template 
-struct has_getDecl<
-T, typename type_sink_to_void().getDecl())>::type>
-: std::true_type {};
-#endif
 
 /// \brief Matches overloaded operators with a specific name.
 ///


Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -569,32 +569,21 @@
   return false;
 }
 
-// Metafunction to determine if type T has a member called
-// getDecl.
-#if defined(_MSC_VER) && !defined(__clang__)
-// For MSVC, we use a weird nonstandard __if_exists statement, as it
-// is not standards-conformant enough to properly compile the standard
-// code below. (At least up through MSVC 2015 require this workaround)
-template  struct has_getDecl {
-  __if_exists(T::getDecl) {
-enum { value = 1 };
-  }
-  __if_not_exists(T::getDecl) {
-enum { value = 0 };
-  }
+// Metafunction to determine if type T has a member called getDecl.
+template 
+class has_getDecl {
+  typedef char yes[1];
+  typedef char no[2];
+
+  template 
+  static yes& test(Inner *I, decltype(I->getDecl()) * = nullptr);
+
+  template 
+  static no& test(...);
+
+public:
+  static const bool value = sizeof(test(nullptr)) == sizeof(yes);
 };
-#else
-// There is a default template inheriting from "false_type". Then, a
-// partial specialization inherits from "true_type". However, this
-// specialization will only exist when the call to getDecl() isn't an
-// error -- it vanishes by SFINAE when the member doesn't exist.
-template  struct type_sink_to_void { typedef void type; };
-template  struct has_getDecl : std::false_type {};
-template 
-struct has_getDecl<
-T, typename type_sink_to_void().getDecl())>::type>
-: std::true_type {};
-#endif
 
 /// \brief Matches overloaded operators with a specific name.
 ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261762 - Fix typo in test/CodeGen/object-size.c CHECK line.

2016-02-24 Thread Bob Wilson via cfe-commits
Author: bwilson
Date: Wed Feb 24 12:38:35 2016
New Revision: 261762

URL: http://llvm.org/viewvc/llvm-project?rev=261762&view=rev
Log:
Fix typo in test/CodeGen/object-size.c CHECK line.

Modified:
cfe/trunk/test/CodeGen/object-size.c

Modified: cfe/trunk/test/CodeGen/object-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/object-size.c?rev=261762&r1=261761&r2=261762&view=diff
==
--- cfe/trunk/test/CodeGen/object-size.c (original)
+++ cfe/trunk/test/CodeGen/object-size.c Wed Feb 24 12:38:35 2016
@@ -505,7 +505,7 @@ void test31() {
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
   gi = __builtin_object_size(ds1[9].snd, 1);
 
-  // CHECH: store i32 2
+  // CHECK: store i32 2
   gi = __builtin_object_size(&ss[9].snd[0], 1);
 
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)


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


Re: r261762 - Fix typo in test/CodeGen/object-size.c CHECK line.

2016-02-24 Thread Eric Christopher via cfe-commits
Nice catch. :)

On Wed, Feb 24, 2016, 10:43 AM Bob Wilson via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: bwilson
> Date: Wed Feb 24 12:38:35 2016
> New Revision: 261762
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261762&view=rev
> Log:
> Fix typo in test/CodeGen/object-size.c CHECK line.
>
> Modified:
> cfe/trunk/test/CodeGen/object-size.c
>
> Modified: cfe/trunk/test/CodeGen/object-size.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/object-size.c?rev=261762&r1=261761&r2=261762&view=diff
>
> ==
> --- cfe/trunk/test/CodeGen/object-size.c (original)
> +++ cfe/trunk/test/CodeGen/object-size.c Wed Feb 24 12:38:35 2016
> @@ -505,7 +505,7 @@ void test31() {
>// CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
>gi = __builtin_object_size(ds1[9].snd, 1);
>
> -  // CHECH: store i32 2
> +  // CHECK: store i32 2
>gi = __builtin_object_size(&ss[9].snd[0], 1);
>
>// CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
>
>
> ___
> 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: r261297 - Implement the likely resolution of core issue 253.

2016-02-24 Thread Nico Weber via cfe-commits
Thanks for patiently explaining this. The attached patch is your email in
diff form. Does this look alright?

Since you mention C++98: We emit this diagnostic in C++98 mode (before and
after my change). The rule is new in C+++11, right? Should I add a check
for CPlusPlus11 before emitting this diagnostic (in a separate change)?

I first forgot to undo my isDefaultCtor() change, and all the tests pass
both with and without it. Can you think of a test case that fails with the
isDefaultCtor() patch? (The new tests fail with _just_ the isDefaultCtor()
change.)

On Tue, Feb 23, 2016 at 2:41 PM, Richard Smith 
wrote:

> On Sat, Feb 20, 2016 at 6:53 AM, Nico Weber  wrote:
> > On Fri, Feb 19, 2016 at 10:32 PM, Nico Weber 
> wrote:
> >>
> >> On Fri, Feb 19, 2016 at 10:02 PM, Nico Weber 
> wrote:
> >>>
> >>> On Fri, Feb 19, 2016 at 8:01 PM, Richard Smith 
> >>> wrote:
> 
>  On Fri, Feb 19, 2016 at 4:41 PM, Nico Weber 
> wrote:
>  > On Fri, Feb 19, 2016 at 4:29 PM, Richard Smith via cfe-commits
>  >  wrote:
>  >>
>  >> On Thu, Feb 18, 2016 at 5:52 PM, Nico Weber via cfe-commits
>  >>  wrote:
>  >> > Author: nico
>  >> > Date: Thu Feb 18 19:52:46 2016
>  >> > New Revision: 261297
>  >> >
>  >> > URL: http://llvm.org/viewvc/llvm-project?rev=261297&view=rev
>  >> > Log:
>  >> > Implement the likely resolution of core issue 253.
>  >> >
>  >> > C++11 requires const objects to have a user-provided constructor,
>  >> > even
>  >> > for
>  >> > classes without any fields. DR 253 relaxes this to say "If the
>  >> > implicit
>  >> > default
>  >> > constructor initializes all subobjects, no initializer should be
>  >> > required."
>  >> >
>  >> > clang is currently the only compiler that implements this C++11
>  >> > rule,
>  >> > and e.g.
>  >> > libstdc++ relies on something like DR 253 to compile in newer
>  >> > versions.
>  >> > This
>  >> > change  makes it possible to build code that says `const
>  >> > vector v;'
>  >> > again
>  >> > when using libstdc++5.2 and _GLIBCXX_DEBUG
>  >> > (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60284).
>  >> >
>  >> > Fixes PR23381.
>  >> >
>  >> > http://reviews.llvm.org/D16552
>  >> >
>  >> > Modified:
>  >> > cfe/trunk/include/clang/AST/DeclCXX.h
>  >> > cfe/trunk/lib/AST/ASTImporter.cpp
>  >> > cfe/trunk/lib/AST/DeclCXX.cpp
>  >> > cfe/trunk/lib/Sema/SemaInit.cpp
>  >> > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>  >> > cfe/trunk/lib/Serialization/ASTWriter.cpp
>  >> >
>  >> >
> cfe/trunk/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
>  >> > cfe/trunk/test/CXX/dcl.decl/dcl.init/p6.cpp
>  >> > cfe/trunk/test/CXX/drs/dr4xx.cpp
>  >> > cfe/trunk/test/SemaCXX/attr-selectany.cpp
>  >> > cfe/trunk/test/SemaCXX/constexpr-value-init.cpp
>  >> > cfe/trunk/test/SemaCXX/cxx0x-cursory-default-delete.cpp
>  >> > cfe/trunk/test/SemaCXX/illegal-member-initialization.cpp
>  >> > cfe/trunk/www/cxx_dr_status.html
>  >> >
>  >> > Modified: cfe/trunk/include/clang/AST/DeclCXX.h
>  >> > URL:
>  >> >
>  >> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=261297&r1=261296&r2=261297&view=diff
>  >> >
>  >> >
>  >> >
> ==
>  >> > --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
>  >> > +++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Feb 18 19:52:46
> 2016
>  >> > @@ -378,6 +378,10 @@ class CXXRecordDecl : public RecordDecl
>  >> >  /// even if the class has a trivial default constructor.
>  >> >  bool HasUninitializedReferenceMember : 1;
>  >> >
>  >> > +/// \brief True if any non-mutable field whose type doesn't
>  >> > have a
>  >> > user-
>  >> > +/// provided default ctor also doesn't have an in-class
>  >> > initializer.
>  >> > +bool HasUninitializedFields : 1;
>  >> > +
>  >> >  /// \brief These flags are \c true if a defaulted
>  >> > corresponding
>  >> > special
>  >> >  /// member can't be fully analyzed without performing
> overload
>  >> > resolution.
>  >> >  /// @{
>  >> > @@ -1270,6 +1274,13 @@ public:
>  >> >  return !(data().HasTrivialSpecialMembers & SMF_Destructor);
>  >> >}
>  >> >
>  >> > +  /// \brief Determine whether declaring a const variable with
>  >> > this
>  >> > type is ok
>  >> > +  /// per core issue 253.
>  >> > +  bool allowConstDefaultInit() const {
>  >> > +return !data().HasUninitializedFields ||
>  >> > +   hasUserProvidedDefaultConstructor();
>  >>
>  >> hasUserProvidedDefaultConstructor() here is subtly incorrect. We
>  >> shouldn't care whether there's a 

[PATCH] D17576: Fix assertion failure on MaybeODRUseExprs.

2016-02-24 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added reviewers: rsmith, EricWF, faisalv.
manmanren added a subscriber: cfe-commits.

In VisitNonTypeTemplateParamDecl, before SubstExpr with the default argument,
we should create a ConstantEvaluated ExpressionEvaluationContext. Without this,
it is possible to use a PotentiallyEvaluated ExpressionEvaluationContext; and
MaybeODRUseExprs will not be cleared when popping the context, causing
assertion failure.

This is similar to how we handle the context before SubstExpr with the
default argument, in SubstDefaultTemplateArgument.

Part of PR13986.
rdar://24480205

http://reviews.llvm.org/D17576

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaTemplate/default-arguments-cxx0x.cpp

Index: test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- test/SemaTemplate/default-arguments-cxx0x.cpp
+++ test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -75,3 +75,13 @@
 g();
   }
 }
+
+// rdar://problem/24480205
+namespace PR13986 {
+  constexpr unsigned Dynamic = 0;
+  template  class A { template  void m_fn1(); };
+  class Test {
+~Test() {}
+A<1> m_target;
+  };
+}
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2110,6 +2110,8 @@
 Param->setInvalidDecl();
 
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
+EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+   
Sema::ConstantEvaluated);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), 
TemplateArgs);
 if (!Value.isInvalid())
   Param->setDefaultArgument(Value.get());


Index: test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- test/SemaTemplate/default-arguments-cxx0x.cpp
+++ test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -75,3 +75,13 @@
 g();
   }
 }
+
+// rdar://problem/24480205
+namespace PR13986 {
+  constexpr unsigned Dynamic = 0;
+  template  class A { template  void m_fn1(); };
+  class Test {
+~Test() {}
+A<1> m_target;
+  };
+}
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2110,6 +2110,8 @@
 Param->setInvalidDecl();
 
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
+EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+   Sema::ConstantEvaluated);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), TemplateArgs);
 if (!Value.isInvalid())
   Param->setDefaultArgument(Value.get());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17561: [CUDA] Add conversion operators for threadIdx, blockIdx, gridDim, and blockDim to uint3 and dim3.

2016-02-24 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: lib/Headers/cuda_builtin_vars.h:72
@@ -66,1 +71,3 @@
+  // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator uint3() const;
 private:

tra wrote:
> Considering that built-in variables are never instantiated, I wonder how it's 
> going to work as the operator will presumably need 'this' pointing 
> *somewhere*, even if we don't use it. Unused 'this' would probably get 
> optimized away with optimizations on, but -O0 may cause problems.
This is interesting.  In the ptx, threadIdx actually gets instantiated, as a 
non-weak global:

  .global .align 1 .b8 threadIdx[1];

Then we take the address of this thing.

At -O2, we don't emit a threadIdx global at all.

I think this is basically fine.  It's actually not right to change extern to 
static in the decl, because then we try to construct a 
__cuda_builtin_threadIdx_t, and the default constructor is deleted.  :)


http://reviews.llvm.org/D17561



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


Re: [PATCH] D17562: [CUDA] Add hack so code which includes "curand.h" doesn't break.

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

OK.


http://reviews.llvm.org/D17562



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


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

2016-02-24 Thread Aaron En Ye Shi via cfe-commits
ashi1 created this revision.
ashi1 added reviewers: Anastasia, pxli168, yaxunl.
ashi1 added subscribers: pekka.jaaskelainen, tstellarAMD, cfe-commits.

This patch will allow the cast of 0 to event_t type.

http://reviews.llvm.org/D17578

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCast.cpp
  test/CodeGenOpenCL/event_t.cl

Index: test/CodeGenOpenCL/event_t.cl
===
--- test/CodeGenOpenCL/event_t.cl
+++ test/CodeGenOpenCL/event_t.cl
@@ -9,4 +9,6 @@
 // CHECK: call {{.*}}void @foo(%opencl.event_t* %
   foo(0);
 // CHECK: call {{.*}}void @foo(%opencl.event_t* null)
+  foo((event_t)0);
+// CHECK: call {{.*}}void @foo(%opencl.event_t* null)
 }
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -2313,6 +2313,23 @@
   return;
 }
 
+// for OpenCL, allow casts from '0' to event_t type
+if ((Self.getLangOpts().OpenCL) && DestType->isEventT()) {
+  llvm::APSInt intValue;
+  if(SrcExpr.get()->EvaluateAsInt(intValue, Self.getASTContext())) {
+if(0 == intValue) {
+  Kind = CK_IntegralToPointer;
+  return;
+} else {
+Self.Diag(OpRange.getBegin(),
+  diag::error_opencl_cast_non_zero_to_event_t)
+  << intValue.toString(10) << SrcExpr.get()->getSourceRange();
+SrcExpr = ExprError();
+return;
+}
+  }
+}
+
 // Reject any other conversions to non-scalar types.
 Self.Diag(OpRange.getBegin(), diag::err_typecheck_cond_expect_scalar)
   << DestType << SrcExpr.get()->getSourceRange();
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7676,7 +7676,9 @@
 def err_sampler_argument_required : Error<
   "sampler_t variable required - got %0">;
 def err_wrong_sampler_addressspace: Error<
-  "sampler type cannot be used with the __local and __global address space 
qualifiers">;
+  "sampler type cannot be used with the __local and __global address space 
qualifiers">;
+def error_opencl_cast_non_zero_to_event_t : Error<
+  "cannot cast non-zero value '%0' to 'event_t'">;
 def err_opencl_global_invalid_addr_space : Error<
   "program scope variable must reside in %0 address space">;
 def err_missing_actual_pipe_type : Error<


Index: test/CodeGenOpenCL/event_t.cl
===
--- test/CodeGenOpenCL/event_t.cl
+++ test/CodeGenOpenCL/event_t.cl
@@ -9,4 +9,6 @@
 // CHECK: call {{.*}}void @foo(%opencl.event_t* %
   foo(0);
 // CHECK: call {{.*}}void @foo(%opencl.event_t* null)
+  foo((event_t)0);
+// CHECK: call {{.*}}void @foo(%opencl.event_t* null)
 }
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -2313,6 +2313,23 @@
   return;
 }
 
+// for OpenCL, allow casts from '0' to event_t type
+if ((Self.getLangOpts().OpenCL) && DestType->isEventT()) {
+  llvm::APSInt intValue;
+  if(SrcExpr.get()->EvaluateAsInt(intValue, Self.getASTContext())) {
+if(0 == intValue) {
+  Kind = CK_IntegralToPointer;
+  return;
+} else {
+Self.Diag(OpRange.getBegin(),
+  diag::error_opencl_cast_non_zero_to_event_t)
+  << intValue.toString(10) << SrcExpr.get()->getSourceRange();
+SrcExpr = ExprError();
+return;
+}
+  }
+}
+
 // Reject any other conversions to non-scalar types.
 Self.Diag(OpRange.getBegin(), diag::err_typecheck_cond_expect_scalar)
   << DestType << SrcExpr.get()->getSourceRange();
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7676,7 +7676,9 @@
 def err_sampler_argument_required : Error<
   "sampler_t variable required - got %0">;
 def err_wrong_sampler_addressspace: Error<
-  "sampler type cannot be used with the __local and __global address space qualifiers">;
+  "sampler type cannot be used with the __local and __global address space qualifiers">;
+def error_opencl_cast_non_zero_to_event_t : Error<
+  "cannot cast non-zero value '%0' to 'event_t'">;
 def err_opencl_global_invalid_addr_space : Error<
   "program scope variable must reside in %0 address space">;
 def err_missing_actual_pipe_type : Error<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17576: Fix assertion failure on MaybeODRUseExprs.

2016-02-24 Thread Faisal Vali via cfe-commits
faisalv added inline comments.


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:2114
@@ -2113,1 +2113,3 @@
+EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+   
Sema::ConstantEvaluated);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), 
TemplateArgs);

Looks reasonable to me - since it is consistent with the other changes I had 
made.  But somewhat orthogonal to your fix, I wouldn't mind Richard commenting 
on why constant expression evaluation does not have 
IsPotentiallyEvaluatedContext return false (and avoid adding an entry to 
MaybeODRUse)
Also, just as SubstituteDefaultTemplateArgument does, Perhaps we should add an 
InstantiatingTemplate on the stack that marks this as a substitution into  
default arguments.  It would be nice if we could refactor both into a call to 
the same function (i.e SubstittueDefaultTempalteArgument) - but looking at the 
code for it, that would be a little tricky.
My 2 cents.


http://reviews.llvm.org/D17576



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


Re: [PATCH] D17412: PR19957: [OpenCL] incorrectly accepts implicit address space conversion with ternary operator

2016-02-24 Thread Yaxun Liu via cfe-commits
yaxunl updated the summary for this revision.
yaxunl removed a reviewer: pekka.jaaskelainen.
yaxunl added a subscriber: pekka.jaaskelainen.
yaxunl set the repository for this revision to rL LLVM.
yaxunl updated this revision to Diff 48967.
yaxunl marked 5 inline comments as done.
yaxunl added a comment.

Revised as Anastasia suggested.

Modified ASTContext::mergeTypes to handle types with different address space 
properly.
Added more sema tests.


Repository:
  rL LLVM

http://reviews.llvm.org/D17412

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGenOpenCL/address-spaces-conversions.cl
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl

Index: test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
===
--- test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
+++ test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
@@ -206,6 +206,38 @@
 // expected-error@-2{{arithmetic operation with operands of type  ('__constant int *' and '__generic int *') which are pointers to non-overlapping address spaces}}
 #endif
 
+  AS int *var_cond;
+  arg_gen = 0 ? var_cond : arg_glob;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__global int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  arg_gen = 0 ? var_cond : arg_loc;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__local int *') which are pointers to non-overlapping address spaces}}
+#elif defined(GLOBAL)
+// expected-error@-4{{conditional operator with the second and third operands of type  ('__global int *' and '__local int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  var_cond = 0 ? var_cond : arg_const;
+#ifdef GENERIC
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__generic int *' and '__constant int *') which are pointers to non-overlapping address spaces}}
+#elif defined(GLOBAL)
+// expected-error@-4{{conditional operator with the second and third operands of type  ('__global int *' and '__constant int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  arg_gen = 0 ? var_cond : arg_priv;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and 'int *') which are pointers to non-overlapping address spaces}}
+#elif defined(GLOBAL)
+// expected-error@-4{{conditional operator with the second and third operands of type  ('__global int *' and 'int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  arg_gen = 0 ? var_cond : arg_gen;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__generic int *') which are pointers to non-overlapping address spaces}}
+#endif
+
   f_glob(var_sub);
 #ifndef GLOBAL
 // expected-error-re@-2{{passing '__{{constant|generic}} int *' to parameter of type '__global int *' changes address space of pointer}}
Index: test/CodeGenOpenCL/address-spaces-conversions.cl
===
--- test/CodeGenOpenCL/address-spaces-conversions.cl
+++ test/CodeGenOpenCL/address-spaces-conversions.cl
@@ -19,4 +19,6 @@
   // CHECK: %{{.*}} = ptrtoint i32 addrspace(1)* %{{.*}} to i64
   var_priv = arg_gen > arg_glob; // comparison
   // CHECK: %{{[0-9]+}} = addrspacecast i32 addrspace(1)* %{{[0-9]+}} to i32 addrspace(4)*
+  arg_gen = arg_glob ? arg_gen : arg_glob; // conditional operator
+  // CHECK: %{{[0-9]+}} = addrspacecast i32 addrspace(1)* %{{[0-9]+}} to i32 addrspace(4)*
 }
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -171,7 +171,6 @@
   // Don't do this for enums, they can't be redeclared.
   if (isa(D) || isa(D))
 break;
- 
   bool Warn = !AA->isInherited();
   // Objective-C method declarations in categories are not modelled as
   // redeclarations, so manually look for a redeclaration in a category
@@ -6168,27 +6167,69 @@
   QualType CompositeTy = S.Context.mergeTypes(lhptee, rhptee);
 
   if (CompositeTy.isNull()) {
-S.Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
-  << LHSTy << RHSTy << LHS.get()->getSourceRange()
-  << RHS.get()->getSourceRange();
 // In this situation, we assume void* type. No especially good
 // reason, but this is what gcc does, and we do have to pick
 // to get a consistent AST.
-QualType incompatTy = S.Context.getPointerType(S.Context.VoidTy);
-LHS = S.ImpCastExprToType(LHS.get(), incompatTy, CK_BitCast);
-RHS = S.ImpCastExprToType(RHS.get(), incompatTy, CK_BitCast);
+QualType incompatTy;
+if (S.getLangOpts().OpenCL) {
+   

RE: [PATCH] D17550: Adding doxygen comments to the LLVM intrinsics (part 6, popcntintrin.h)

2016-02-24 Thread Romanova, Katya via cfe-commits
Hello,

I don’t think it will too hard to convert C++ style doxygen comments into C 
style doxygen comments by writing a post-processing python script. However, at 
first we need to decide if we really want to do that. If so, we need to settle 
on the exact format. After that, I need to make sure that the comments in the 
new format will be rendered correctly in MS Tooltips, XCode, online 
documentation and PS4 internal documentation. This discussion + investigation 
might take a few days.

Before we start discussing the exact format, I want to make sure that we really 
want to change to C-style doxygen comments.
Here are my not-so-strong arguments against it:

-There currently are 257 occurrences C++ style comments in 14 other 
header files in /llvm/tools/clang/lib/Headers directory (I’m talking about the 
files that I didn’t touch). C++ style comments were there for AGES and nobody 
complained so far. If we decide to change C++ style doxygen comments -> 
C-style, we also need to change all regular C++ comments to C-style in these 
header files.

-c99 (and later) supports C++ style comments, while I c89 doesn’t. I’m 
not sure if we have users that still use c89 format and x86 intrinsic headers 
at the same time.

-C++ style doxygen comments are more pretty and readable compared to 
C-style comment (though it might be my subjective opinion).

Let me know what you think.

I will try to get Dmitri Gribenko’s opinion. He did a lot of work on doxygen in 
LLVM. I’m curious what he thinks about Javadoc style format.

Katya.


From: Eric Christopher [mailto:echri...@gmail.com]
Sent: Tuesday, February 23, 2016 10:51 PM
To: reviews+d17550+public+bc8ce213fd9db...@reviews.llvm.org; Romanova, Katya; 
Gao, Yunzhong; griboz...@gmail.com; craig.top...@gmail.com; Robinson, Paul
Cc: Bedwell, Greg; cfe-commits@lists.llvm.org
Subject: Re: [PATCH] D17550: Adding doxygen comments to the LLVM intrinsics 
(part 6, popcntintrin.h)


Yeah, we should be doing this. Nice catch Paul and Greg.

On Tue, Feb 23, 2016, 10:34 PM Greg Bedwell 
mailto:greg_bedw...@sn.scee.net>> wrote:
gbedwell added a subscriber: gbedwell.
gbedwell added a comment.

In http://reviews.llvm.org/D17550#360177, @probinson wrote:

> One question I have, which shouldn't block this (as we've done several like 
> this already):
>  Is is okay to be using C++ style comments in these headers?
>  (Is there a C-style comment that Doxygen recognizes?)


There are a few various formats that Doxygen supports.  Looking at headers from 
llvm-c the most common convention appears to be JavaDoc style, although there 
are a few examples of other supported styles floating around the codebase.  
E.g. from include/llvm-c/lto.h using JavaDoc style:

/**

- Diagnostic handler type.
- \p severity defines the severity.
- \p diag is the actual diagnostic.
- The diagnostic is not prefixed by any of severity keyword, e.g., 'error: '.
- \p ctxt is used to pass the context set with the diagnostic handler. *
- \since LTO_API_VERSION=7 */

-Greg


Repository:
  rL LLVM

http://reviews.llvm.org/D17550


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


r261767 - Add whole-program vtable optimization feature to Clang.

2016-02-24 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Wed Feb 24 14:46:36 2016
New Revision: 261767

URL: http://llvm.org/viewvc/llvm-project?rev=261767&view=rev
Log:
Add whole-program vtable optimization feature to Clang.

This patch introduces the -fwhole-program-vtables flag, which enables the
whole-program vtable optimization feature (D16795) in Clang.

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

Added:
cfe/trunk/runtime/vtables_blacklist.txt
cfe/trunk/test/CodeGenCXX/bitset-blacklist.cpp
  - copied, changed from r261762, 
cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp
cfe/trunk/test/CodeGenCXX/bitsets.cpp
  - copied, changed from r261762, cfe/trunk/test/CodeGenCXX/cfi-vcall.cpp
cfe/trunk/test/Driver/Inputs/resource_dir/vtables_blacklist.txt
cfe/trunk/test/Driver/whole-program-vtables.c
Removed:
cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp
cfe/trunk/test/CodeGenCXX/cfi-vcall.cpp
Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=261767&r1=261766&r2=261767&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Wed Feb 24 14:46:36 2016
@@ -1053,6 +1053,21 @@ are listed below.
the behavior of sanitizers in the ``cfi`` group to allow checking
of cross-DSO virtual and indirect calls.
 
+.. option:: -fwhole-program-vtables
+
+   Enable whole-program vtable optimizations, such as single-implementation
+   devirtualization and virtual constant propagation. Requires ``-flto``.
+
+   By default, the compiler will assume that all type hierarchies are
+   closed except those in the ``std`` namespace, the ``stdext`` namespace
+   and classes with the ``__declspec(uuid())`` attribute.
+
+.. option:: -fwhole-program-vtables-blacklist=path
+
+   Allows the user to specify the path to a list of additional classes to
+   blacklist from whole-program vtable optimizations. This list is in the
+   :ref:`CFI blacklist ` format.
+
 .. option:: -fno-assume-sane-operator-new
 
Don't assume that the C++'s new operator is sane.

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=261767&r1=261766&r2=261767&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Feb 24 14:46:36 2016
@@ -1124,6 +1124,13 @@ def fvisibility_inlines_hidden : Flag<["
 def fvisibility_ms_compat : Flag<["-"], "fvisibility-ms-compat">, 
Group,
   HelpText<"Give global types 'default' visibility and global functions and "
"variables 'hidden' visibility by default">;
+def fwhole_program_vtables : Flag<["-"], "fwhole-program-vtables">, 
Group,
+  Flags<[CC1Option]>,
+  HelpText<"Enables whole-program vtable optimization. Requires -flto">;
+def fno_whole_program_vtables : Flag<["-"], "fno-whole-program-vtables">, 
Group;
+def fwhole_program_vtables_blacklist_EQ : Joined<["-"], 
"fwhole-program-vtables-blacklist=">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Path to a blacklist file for whole-program vtable optimization">;
 def fwrapv : Flag<["-"], "fwrapv">, Group, Flags<[CC1Option]>,
   HelpText<"Treat signed integer overflow as two's complement">;
 def fwritable_strings : Flag<["-"], "fwritable-strings">, Group, 
Flags<[CC1Option]>,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=261767&r1=261766&r2=261767&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Feb 24 14:46:36 2016
@@ -179,6 +179,9 @@ CODEGENOPT(DebugExplicitImport, 1, 0)  /
 
 CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
 
+CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program
+  ///  vtable optimization.
+
 /// The user specified number of registers to be used for integral arguments,
 /// or 0 if unspecified.
 VALUE_CODEGENOPT(NumRegisterParameters,

Re: [PATCH] D16821: Add whole-program vtable optimization feature to Clang.

2016-02-24 Thread Peter Collingbourne via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261767: Add whole-program vtable optimization feature to 
Clang. (authored by pcc).

Changed prior to commit:
  http://reviews.llvm.org/D16821?vs=46697&id=48968#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16821

Files:
  cfe/trunk/docs/UsersManual.rst
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/include/clang/Frontend/CodeGenOptions.h
  cfe/trunk/lib/CodeGen/CGClass.cpp
  cfe/trunk/lib/CodeGen/CGExprCXX.cpp
  cfe/trunk/lib/CodeGen/CGVTables.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/runtime/CMakeLists.txt
  cfe/trunk/runtime/vtables_blacklist.txt
  cfe/trunk/test/CodeGenCXX/bitset-blacklist.cpp
  cfe/trunk/test/CodeGenCXX/bitsets.cpp
  cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp
  cfe/trunk/test/CodeGenCXX/cfi-vcall.cpp
  cfe/trunk/test/Driver/Inputs/resource_dir/vtables_blacklist.txt
  cfe/trunk/test/Driver/whole-program-vtables.c

Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -1053,6 +1053,21 @@
the behavior of sanitizers in the ``cfi`` group to allow checking
of cross-DSO virtual and indirect calls.
 
+.. option:: -fwhole-program-vtables
+
+   Enable whole-program vtable optimizations, such as single-implementation
+   devirtualization and virtual constant propagation. Requires ``-flto``.
+
+   By default, the compiler will assume that all type hierarchies are
+   closed except those in the ``std`` namespace, the ``stdext`` namespace
+   and classes with the ``__declspec(uuid())`` attribute.
+
+.. option:: -fwhole-program-vtables-blacklist=path
+
+   Allows the user to specify the path to a list of additional classes to
+   blacklist from whole-program vtable optimizations. This list is in the
+   :ref:`CFI blacklist ` format.
+
 .. option:: -fno-assume-sane-operator-new
 
Don't assume that the C++'s new operator is sane.
Index: cfe/trunk/runtime/CMakeLists.txt
===
--- cfe/trunk/runtime/CMakeLists.txt
+++ cfe/trunk/runtime/CMakeLists.txt
@@ -134,3 +134,13 @@
   VERBATIM)
   endif()
 endif()
+
+set(src "${CMAKE_CURRENT_SOURCE_DIR}/vtables_blacklist.txt")
+set(dst "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/vtables_blacklist.txt")
+add_custom_command(OUTPUT ${dst}
+   DEPENDS ${src}
+   COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+   COMMENT "Copying vtables blacklist")
+add_custom_target(vtables_blacklist DEPENDS ${dst})
+add_dependencies(clang vtables_blacklist)
+install(FILES ${src} DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
Index: cfe/trunk/runtime/vtables_blacklist.txt
===
--- cfe/trunk/runtime/vtables_blacklist.txt
+++ cfe/trunk/runtime/vtables_blacklist.txt
@@ -0,0 +1,8 @@
+# Standard library types.
+type:std::*
+
+# The stdext namespace contains Microsoft standard library extensions.
+type:stdext::*
+
+# Types with a uuid attribute, i.e. COM types.
+type:attr:uuid
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -179,6 +179,9 @@
 
 CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
 
+CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program
+  ///  vtable optimization.
+
 /// The user specified number of registers to be used for integral arguments,
 /// or 0 if unspecified.
 VALUE_CODEGENOPT(NumRegisterParameters, 32, 0)
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h
@@ -201,6 +201,9 @@
   /// \brief A list of all -fno-builtin-* function names (e.g., memset).
   std::vector NoBuiltinFuncs;
 
+  /// List of blacklist files for the whole-program vtable optimization feature.
+  std::vector WholeProgramVTablesBlacklistFiles;
+
 public:
   // Define accessors/mutators for code generation options of enumeration type.
 #define CODEGENOPT(Name, Bits, Default)
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -

Re: r261297 - Implement the likely resolution of core issue 253.

2016-02-24 Thread Richard Smith via cfe-commits
On Wed, Feb 24, 2016 at 10:47 AM, Nico Weber  wrote:
> Thanks for patiently explaining this. The attached patch is your email in
> diff form. Does this look alright?

Yes, it looks great. Thanks for the excellent test cases.

> Since you mention C++98: We emit this diagnostic in C++98 mode (before and
> after my change). The rule is new in C+++11, right? Should I add a check for
> CPlusPlus11 before emitting this diagnostic (in a separate change)?

The rule was present (although worded differently), in paragraph 9:
"If no initializer is specified for an object, and the object is of
(possibly cv-qualified) non-POD class type (or array thereof), the
object shall be default-initialized; if the object is of
const-qualified type, the underlying class type shall have a
user-declared default constructor."

> I first forgot to undo my isDefaultCtor() change, and all the tests pass
> both with and without it. Can you think of a test case that fails with the
> isDefaultCtor() patch? (The new tests fail with _just_ the isDefaultCtor()
> change.)

Looking through the uses, there seem to be roughly four different
things going on:

1) Checks for a trivial default constructor. These are unaffected by
your change because a templated default constructor can never be
trivial.
2) Checks for a default constructor for diagnostic purposes. I think
they'd be surprised if we called a constructor template a default
constructor, especially if it's being passed arguments (the same is
true in the default argument case, though).
3) Checks for a default constructor for type traits and the like.
These aren't really all that meaningful, but we probably shouldn't
change their outcomes (we're emlating GCC behavior).
4) A very small number of language semantic checks; the ones whose
outcomes change seem to mostly be wrong (they want to find the
constructor that overload resolution would actually select for a
0-argument call).

The easiest way to test this would probably be to static_assert that a
class with a constructor template returns false for __is_trivial:

struct X { template X(T...); };
static_assert(!__is_trivial(X), "");

> On Tue, Feb 23, 2016 at 2:41 PM, Richard Smith 
> wrote:
>>
>> On Sat, Feb 20, 2016 at 6:53 AM, Nico Weber  wrote:
>> > On Fri, Feb 19, 2016 at 10:32 PM, Nico Weber 
>> > wrote:
>> >>
>> >> On Fri, Feb 19, 2016 at 10:02 PM, Nico Weber 
>> >> wrote:
>> >>>
>> >>> On Fri, Feb 19, 2016 at 8:01 PM, Richard Smith 
>> >>> wrote:
>> 
>>  On Fri, Feb 19, 2016 at 4:41 PM, Nico Weber 
>>  wrote:
>>  > On Fri, Feb 19, 2016 at 4:29 PM, Richard Smith via cfe-commits
>>  >  wrote:
>>  >>
>>  >> On Thu, Feb 18, 2016 at 5:52 PM, Nico Weber via cfe-commits
>>  >>  wrote:
>>  >> > Author: nico
>>  >> > Date: Thu Feb 18 19:52:46 2016
>>  >> > New Revision: 261297
>>  >> >
>>  >> > URL: http://llvm.org/viewvc/llvm-project?rev=261297&view=rev
>>  >> > Log:
>>  >> > Implement the likely resolution of core issue 253.
>>  >> >
>>  >> > C++11 requires const objects to have a user-provided
>>  >> > constructor,
>>  >> > even
>>  >> > for
>>  >> > classes without any fields. DR 253 relaxes this to say "If the
>>  >> > implicit
>>  >> > default
>>  >> > constructor initializes all subobjects, no initializer should be
>>  >> > required."
>>  >> >
>>  >> > clang is currently the only compiler that implements this C++11
>>  >> > rule,
>>  >> > and e.g.
>>  >> > libstdc++ relies on something like DR 253 to compile in newer
>>  >> > versions.
>>  >> > This
>>  >> > change  makes it possible to build code that says `const
>>  >> > vector v;'
>>  >> > again
>>  >> > when using libstdc++5.2 and _GLIBCXX_DEBUG
>>  >> > (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60284).
>>  >> >
>>  >> > Fixes PR23381.
>>  >> >
>>  >> > http://reviews.llvm.org/D16552
>>  >> >
>>  >> > Modified:
>>  >> > cfe/trunk/include/clang/AST/DeclCXX.h
>>  >> > cfe/trunk/lib/AST/ASTImporter.cpp
>>  >> > cfe/trunk/lib/AST/DeclCXX.cpp
>>  >> > cfe/trunk/lib/Sema/SemaInit.cpp
>>  >> > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>>  >> > cfe/trunk/lib/Serialization/ASTWriter.cpp
>>  >> >
>>  >> >
>>  >> > cfe/trunk/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
>>  >> > cfe/trunk/test/CXX/dcl.decl/dcl.init/p6.cpp
>>  >> > cfe/trunk/test/CXX/drs/dr4xx.cpp
>>  >> > cfe/trunk/test/SemaCXX/attr-selectany.cpp
>>  >> > cfe/trunk/test/SemaCXX/constexpr-value-init.cpp
>>  >> > cfe/trunk/test/SemaCXX/cxx0x-cursory-default-delete.cpp
>>  >> > cfe/trunk/test/SemaCXX/illegal-member-initialization.cpp
>>  >> > cfe/trunk/www/cxx_dr_status.html
>>  >> >
>>  >> > Modified: cfe/trunk/include/clang/AST/DeclCXX.h
>>  >> > URL:
>>  >> >
>>  >> >
>>  >> > http://llvm.org/viewvc/llv

r261770 - Fix rejects-valid caused by r261297.

2016-02-24 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Feb 24 14:58:14 2016
New Revision: 261770

URL: http://llvm.org/viewvc/llvm-project?rev=261770&view=rev
Log:
Fix rejects-valid caused by r261297.

r261297 called hasUserProvidedDefaultConstructor() to check if defining a
const object is ok.  This is incorrect for this example:

  struct X { template X(T...); int n; };
  const X x; // formerly OK, now bogus error

Instead, track if a class has a defaulted default constructor, and disallow
a const object for classes that either have defaulted default constructors or
if they need an implicit constructor.

Bug report and fix approach by Richard Smith, thanks!

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/SemaCXX/cxx0x-cursory-default-delete.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=261770&r1=261769&r2=261770&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Feb 24 14:58:14 2016
@@ -421,6 +421,10 @@ class CXXRecordDecl : public RecordDecl
 /// constructor which is neither the copy nor move constructor.
 bool HasConstexprNonCopyMoveConstructor : 1;
 
+/// \brief True if this class has a (possibly implicit) defaulted default
+/// constructor.
+bool HasDefaultedDefaultConstructor : 1;
+
 /// \brief True if a defaulted default constructor for this class would
 /// be constexpr.
 bool DefaultedDefaultConstructorIsConstexpr : 1;
@@ -1278,7 +1282,8 @@ public:
   /// per core issue 253.
   bool allowConstDefaultInit() const {
 return !data().HasUninitializedFields ||
-   hasUserProvidedDefaultConstructor();
+   !(data().HasDefaultedDefaultConstructor ||
+ needsImplicitDefaultConstructor());
   }
 
   /// \brief Determine whether this class has a destructor which has no

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=261770&r1=261769&r2=261770&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Feb 24 14:58:14 2016
@@ -2040,6 +2040,8 @@ bool ASTNodeImporter::ImportDefinition(R
 ToData.HasIrrelevantDestructor = FromData.HasIrrelevantDestructor;
 ToData.HasConstexprNonCopyMoveConstructor
   = FromData.HasConstexprNonCopyMoveConstructor;
+ToData.HasDefaultedDefaultConstructor
+  = FromData.HasDefaultedDefaultConstructor;
 ToData.DefaultedDefaultConstructorIsConstexpr
   = FromData.DefaultedDefaultConstructorIsConstexpr;
 ToData.HasConstexprDefaultConstructor

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=261770&r1=261769&r2=261770&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Wed Feb 24 14:58:14 2016
@@ -61,6 +61,7 @@ CXXRecordDecl::DefinitionData::Definitio
   DefaultedDestructorIsDeleted(false), HasTrivialSpecialMembers(SMF_All),
   DeclaredNonTrivialSpecialMembers(0), HasIrrelevantDestructor(true),
   HasConstexprNonCopyMoveConstructor(false),
+  HasDefaultedDefaultConstructor(false),
   DefaultedDefaultConstructorIsConstexpr(true),
   HasConstexprDefaultConstructor(false),
   HasNonLiteralTypeFieldsOrBases(false), ComputedVisibleConversions(false),
@@ -497,6 +498,8 @@ void CXXRecordDecl::addedMember(Decl *D)
 data().UserProvidedDefaultConstructor = true;
   if (Constructor->isConstexpr())
 data().HasConstexprDefaultConstructor = true;
+  if (Constructor->isDefaulted())
+data().HasDefaultedDefaultConstructor = true;
 }
 
 if (!FunTmpl) {

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=261770&r1=261769&r2=261770&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Feb 24 14:58:14 2016
@@ -1423,6 +1423,7 @@ void ASTDeclReader::ReadCXXDefinitionDat
   Data.DeclaredNonTrivialSpecialMembers = Record[Idx++];
   Data.HasIrrelevantDestructor = Record[Idx++];
   Data.HasConstexprNonCopyMoveConstructor = Record[Idx++];
+  Data.HasDefaultedDefaultConstructor = Record[Idx++];
   Data.DefaultedDefaultConstructorIsConstexpr = Record[Idx++];
   Data.HasConstexprDefaultConstructor = Record[Idx++];
   Data.HasNonLiteralTypeFieldsOrBases = Record[Id

Re: r261297 - Implement the likely resolution of core issue 253.

2016-02-24 Thread Nico Weber via cfe-commits
On Wed, Feb 24, 2016 at 3:53 PM, Richard Smith 
wrote:

> On Wed, Feb 24, 2016 at 10:47 AM, Nico Weber  wrote:
> > Thanks for patiently explaining this. The attached patch is your email in
> > diff form. Does this look alright?
>
> Yes, it looks great. Thanks for the excellent test cases.
>

r261770, thanks!


>
> > Since you mention C++98: We emit this diagnostic in C++98 mode (before
> and
> > after my change). The rule is new in C+++11, right? Should I add a check
> for
> > CPlusPlus11 before emitting this diagnostic (in a separate change)?
>
> The rule was present (although worded differently), in paragraph 9:
> "If no initializer is specified for an object, and the object is of
> (possibly cv-qualified) non-POD class type (or array thereof), the
> object shall be default-initialized; if the object is of
> const-qualified type, the underlying class type shall have a
> user-declared default constructor."
>
> > I first forgot to undo my isDefaultCtor() change, and all the tests pass
> > both with and without it. Can you think of a test case that fails with
> the
> > isDefaultCtor() patch? (The new tests fail with _just_ the
> isDefaultCtor()
> > change.)
>
> Looking through the uses, there seem to be roughly four different
> things going on:
>
> 1) Checks for a trivial default constructor. These are unaffected by
> your change because a templated default constructor can never be
> trivial.
> 2) Checks for a default constructor for diagnostic purposes. I think
> they'd be surprised if we called a constructor template a default
> constructor, especially if it's being passed arguments (the same is
> true in the default argument case, though).
> 3) Checks for a default constructor for type traits and the like.
> These aren't really all that meaningful, but we probably shouldn't
> change their outcomes (we're emlating GCC behavior).
> 4) A very small number of language semantic checks; the ones whose
> outcomes change seem to mostly be wrong (they want to find the
> constructor that overload resolution would actually select for a
> 0-argument call).
>
> The easiest way to test this would probably be to static_assert that a
> class with a constructor template returns false for __is_trivial:
>
> struct X { template X(T...); };
> static_assert(!__is_trivial(X), "");
>

I had tried something like that (I think it was the
`static_assert(__has_nothrow_constructor(X), "");` upthread), but I can't
manage to behave it differently by changing isDefaultConstructor(). A
mystery for another day, I suppose :-) Thanks again!


>
> > On Tue, Feb 23, 2016 at 2:41 PM, Richard Smith 
> > wrote:
> >>
> >> On Sat, Feb 20, 2016 at 6:53 AM, Nico Weber 
> wrote:
> >> > On Fri, Feb 19, 2016 at 10:32 PM, Nico Weber 
> >> > wrote:
> >> >>
> >> >> On Fri, Feb 19, 2016 at 10:02 PM, Nico Weber 
> >> >> wrote:
> >> >>>
> >> >>> On Fri, Feb 19, 2016 at 8:01 PM, Richard Smith <
> rich...@metafoo.co.uk>
> >> >>> wrote:
> >> 
> >>  On Fri, Feb 19, 2016 at 4:41 PM, Nico Weber 
> >>  wrote:
> >>  > On Fri, Feb 19, 2016 at 4:29 PM, Richard Smith via cfe-commits
> >>  >  wrote:
> >>  >>
> >>  >> On Thu, Feb 18, 2016 at 5:52 PM, Nico Weber via cfe-commits
> >>  >>  wrote:
> >>  >> > Author: nico
> >>  >> > Date: Thu Feb 18 19:52:46 2016
> >>  >> > New Revision: 261297
> >>  >> >
> >>  >> > URL: http://llvm.org/viewvc/llvm-project?rev=261297&view=rev
> >>  >> > Log:
> >>  >> > Implement the likely resolution of core issue 253.
> >>  >> >
> >>  >> > C++11 requires const objects to have a user-provided
> >>  >> > constructor,
> >>  >> > even
> >>  >> > for
> >>  >> > classes without any fields. DR 253 relaxes this to say "If the
> >>  >> > implicit
> >>  >> > default
> >>  >> > constructor initializes all subobjects, no initializer should
> be
> >>  >> > required."
> >>  >> >
> >>  >> > clang is currently the only compiler that implements this
> C++11
> >>  >> > rule,
> >>  >> > and e.g.
> >>  >> > libstdc++ relies on something like DR 253 to compile in newer
> >>  >> > versions.
> >>  >> > This
> >>  >> > change  makes it possible to build code that says `const
> >>  >> > vector v;'
> >>  >> > again
> >>  >> > when using libstdc++5.2 and _GLIBCXX_DEBUG
> >>  >> > (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60284).
> >>  >> >
> >>  >> > Fixes PR23381.
> >>  >> >
> >>  >> > http://reviews.llvm.org/D16552
> >>  >> >
> >>  >> > Modified:
> >>  >> > cfe/trunk/include/clang/AST/DeclCXX.h
> >>  >> > cfe/trunk/lib/AST/ASTImporter.cpp
> >>  >> > cfe/trunk/lib/AST/DeclCXX.cpp
> >>  >> > cfe/trunk/lib/Sema/SemaInit.cpp
> >>  >> > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> >>  >> > cfe/trunk/lib/Serialization/ASTWriter.cpp
> >>  >> >
> >>  >> >
> >>  >> >
> cfe/trunk/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
> >>

Re: [PATCH] D17575: Determine if there's a getDecl member function using less hacks

2016-02-24 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

I assume you checked that the new trait works on MSVC.
Aren't both the same type of expression SFINAE? Is somehow one supported but 
not the other?


http://reviews.llvm.org/D17575



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


Re: [PATCH] D17575: Determine if there's a getDecl member function using less hacks

2016-02-24 Thread Aaron Ballman via cfe-commits
On Wed, Feb 24, 2016 at 4:14 PM, Samuel Benzaquen via cfe-commits
 wrote:
> sbenza added a comment.
>
> I assume you checked that the new trait works on MSVC.

Yes. It's also used in ThreadSafety.cpp, so maybe at some point we may
want to consider generalizing the trait.

> Aren't both the same type of expression SFINAE?

I believe so, yes.

> Is somehow one supported but not the other?

Compiler bugs, most likely. The one I am proposing has the benefit of
working everywhere we care about, at least as far as it's been used in
thread safety analysis for a few releases (so it also works with MSVC
2013 as well as MSVC 2015).

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


Re: [clang-tools-extra] r261738 - [clang-tidy] introduce modernize-deprecated-headers check

2016-02-24 Thread Nico Weber via cfe-commits
This broke the Windows bot:
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10093/steps/build%20stage%201/logs/stdio

FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP /DWIN32
/D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291
-wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624
-wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702
-wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204
-wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /Zc:inline /Oi
/Zc:rvalueCast /MD /O2 /Ob2 -Itools\clang\tools\extra\clang-tidy\modernize
-ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize
-ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\include
-Itools\clang\include -Iinclude
-ID:\buildslave\clang-x64-ninja-win7\llvm\include-UNDEBUG  /EHs-c- /GR-
/showIncludes -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER
-DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0
-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
-D_DEBUG_POINTER_IMPL="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
/Fotools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\DeprecatedHeadersCheck.cpp.obj
/Fdtools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\
/FS -c
D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp
D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp(72)
: error C2668:
'llvm::StringMap::StringMap' : ambiguous
call to overloaded function

D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(399):
could be
'llvm::StringMap::StringMap(const
llvm::StringMap &)'

D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(242):
or
'llvm::StringMap::StringMap(llvm::StringMap
&&)'

D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(235):
or
'llvm::StringMap::StringMap(std::initializer_list>)'
with
[
ValueTy=std::string
]

D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(228):
or
'llvm::StringMap::StringMap(AllocatorTy)'
with
[
AllocatorTy=llvm::MallocAllocator
]

D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(225):
or
'llvm::StringMap::StringMap(unsigned
int)'
while trying to match the argument list '(initializer-list)'
   Creating library lib\libclang.lib and object lib\libclang.exp


On Wed, Feb 24, 2016 at 8:36 AM, Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: alexfh
> Date: Wed Feb 24 07:36:34 2016
> New Revision: 261738
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261738&view=rev
> Log:
> [clang-tidy] introduce modernize-deprecated-headers check
>
> Summary:
> This patch introduces the modernize-deprecated-headers check, which is
> supposed to replace deprecated C library headers with the C++ STL-ones.
>
> For information see documentation; for exmaples see the test cases.
>
> Reviewers: Eugene.Zelenko, LegalizeAdulthood, alexfh
>
> Subscribers: cfe-commits
>
> Patch by Kirill Bobyrev!
>
> Differential Revision: http://reviews.llvm.org/D17484
>
> Added:
> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
>
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst
>
> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
>
> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=261738&r1=261737&r2=261738&view=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Wed Feb 24
> 07:36:34 2016
> @@ -1,6 +1,7 @@
>  set(LLVM_LINK_COMPONENTS support)
>
>  add_clang_library(clangTidyModernizeModule
> +  DeprecatedHeadersCheck.cpp
>LoopConvertCheck.cpp
>LoopConvertUtils.cpp
>MakeUniqueCheck.cpp
>
> Added:
> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp?rev=261738&view

Re: [clang-tools-extra] r261738 - [clang-tidy] introduce modernize-deprecated-headers check

2016-02-24 Thread Alexander Kornienko via cfe-commits
Looking into this...

On Wed, Feb 24, 2016 at 10:21 PM, Nico Weber  wrote:

> This broke the Windows bot:
> http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10093/steps/build%20stage%201/logs/stdio
>
> FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP /DWIN32
> /D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291
> -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624
> -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702
> -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204
> -wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /Zc:inline /Oi
> /Zc:rvalueCast /MD /O2 /Ob2 -Itools\clang\tools\extra\clang-tidy\modernize
> -ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize
> -ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\include
> -Itools\clang\include -Iinclude
> -ID:\buildslave\clang-x64-ninja-win7\llvm\include-UNDEBUG  /EHs-c- /GR-
> /showIncludes -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER
> -DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0
> -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
> -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
> -D_DEBUG_POINTER_IMPL="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
> -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> /Fotools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\DeprecatedHeadersCheck.cpp.obj
> /Fdtools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\
> /FS -c
> D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp
> D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp(72)
> : error C2668:
> 'llvm::StringMap::StringMap' : ambiguous
> call to overloaded function
>
> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(399):
> could be
> 'llvm::StringMap::StringMap(const
> llvm::StringMap &)'
>
> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(242):
> or
> 'llvm::StringMap::StringMap(llvm::StringMap
> &&)'
>
> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(235):
> or
> 'llvm::StringMap::StringMap(std::initializer_list>)'
> with
> [
> ValueTy=std::string
> ]
>
> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(228):
> or
> 'llvm::StringMap::StringMap(AllocatorTy)'
> with
> [
> AllocatorTy=llvm::MallocAllocator
> ]
>
> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(225):
> or
> 'llvm::StringMap::StringMap(unsigned
> int)'
> while trying to match the argument list '(initializer-list)'
>Creating library lib\libclang.lib and object lib\libclang.exp
>
>
> On Wed, Feb 24, 2016 at 8:36 AM, Alexander Kornienko via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: alexfh
>> Date: Wed Feb 24 07:36:34 2016
>> New Revision: 261738
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=261738&view=rev
>> Log:
>> [clang-tidy] introduce modernize-deprecated-headers check
>>
>> Summary:
>> This patch introduces the modernize-deprecated-headers check, which is
>> supposed to replace deprecated C library headers with the C++ STL-ones.
>>
>> For information see documentation; for exmaples see the test cases.
>>
>> Reviewers: Eugene.Zelenko, LegalizeAdulthood, alexfh
>>
>> Subscribers: cfe-commits
>>
>> Patch by Kirill Bobyrev!
>>
>> Differential Revision: http://reviews.llvm.org/D17484
>>
>> Added:
>>
>> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
>>
>> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst
>>
>> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
>>
>> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
>> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=261738&r1=261737&r2=261738&view=diff
>>
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
>> +++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Wed Feb
>> 24 07:36:34 2016
>> @@ -1,6 +1,7 @@
>>  set(LLVM_LINK_COMPONENTS support)
>>
>>  add_clang_library(clangTidyModernizeModule
>> +  DeprecatedHeadersCheck.cpp
>>LoopConvertCheck.cpp
>>LoopConvertU

[PATCH] D17581: [CUDA] disable attribute-based overloading for __global__ functions.

2016-02-24 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added a reviewer: jlebar.
tra added a subscriber: cfe-commits.

__global__ functions are present on both host and device side,
so providing __host__ or __device__ overloads is not going to
do anything useful.

http://reviews.llvm.org/D17581

Files:
  lib/Sema/SemaOverload.cpp
  test/SemaCUDA/function-overload.cu

Index: test/SemaCUDA/function-overload.cu
===
--- test/SemaCUDA/function-overload.cu
+++ test/SemaCUDA/function-overload.cu
@@ -302,3 +302,13 @@
   __host__ __device__ void operator delete(void *ptr) {} // expected-note 
{{previous declaration is here}}
   __device__ void operator delete(void *ptr) {} // expected-error {{class 
member cannot be redeclared}}
 };
+
+// __global__ functions can't be overloaded based on attribute
+// difference.
+struct G {
+  friend void friend_of_g(G &arg);
+private:
+  int x;
+};
+__global__ void friend_of_g(G &arg) { int x = arg.x; } // expected-note 
{{previous definition is here}}
+void friend_of_g(G &arg) { int x = arg.x; } // expected-error {{redefinition 
of 'friend_of_g'}}
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -1129,7 +1129,10 @@
 // Don't allow mixing of HD with other kinds. This guarantees that
 // we have only one viable function with this signature on any
 // side of CUDA compilation .
-if ((NewTarget == CFT_HostDevice) || (OldTarget == CFT_HostDevice))
+// __global__ functions can't be overloaded based on attribute
+// difference because, like HD, they also exist on both sides.
+if ((NewTarget == CFT_HostDevice) || (OldTarget == CFT_HostDevice) ||
+(NewTarget == CFT_Global) || (OldTarget == CFT_Global))
   return false;
 
 // Allow overloading of functions with same signature, but


Index: test/SemaCUDA/function-overload.cu
===
--- test/SemaCUDA/function-overload.cu
+++ test/SemaCUDA/function-overload.cu
@@ -302,3 +302,13 @@
   __host__ __device__ void operator delete(void *ptr) {} // expected-note {{previous declaration is here}}
   __device__ void operator delete(void *ptr) {} // expected-error {{class member cannot be redeclared}}
 };
+
+// __global__ functions can't be overloaded based on attribute
+// difference.
+struct G {
+  friend void friend_of_g(G &arg);
+private:
+  int x;
+};
+__global__ void friend_of_g(G &arg) { int x = arg.x; } // expected-note {{previous definition is here}}
+void friend_of_g(G &arg) { int x = arg.x; } // expected-error {{redefinition of 'friend_of_g'}}
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -1129,7 +1129,10 @@
 // Don't allow mixing of HD with other kinds. This guarantees that
 // we have only one viable function with this signature on any
 // side of CUDA compilation .
-if ((NewTarget == CFT_HostDevice) || (OldTarget == CFT_HostDevice))
+// __global__ functions can't be overloaded based on attribute
+// difference because, like HD, they also exist on both sides.
+if ((NewTarget == CFT_HostDevice) || (OldTarget == CFT_HostDevice) ||
+(NewTarget == CFT_Global) || (OldTarget == CFT_Global))
   return false;
 
 // Allow overloading of functions with same signature, but
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17216: Make test/Driver/output-file-cleanup.c hermetic.

2016-02-24 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Upon further consideration, I think I'm going to push this with post-submit 
review, as we know this test is quite broken, and I think this change is 
unlikely to make the situation worse.


http://reviews.llvm.org/D17216



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


Re: [PATCH] D17056: Mark all CUDA device-side function defs and decls as convergent.

2016-02-24 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Friendly ping -- are we happy with this?


http://reviews.llvm.org/D17056



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


Re: [PATCH] D17217: Bail on compilation as soon as a job fails.

2016-02-24 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Upon further consideration, I'm going to push this with post-submit review -- 
the only difference from what echristo reviewed is an obvious change to 
output-file-cleanup.c.


http://reviews.llvm.org/D17217



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


Re: [PATCH] D17561: [CUDA] Add conversion operators for threadIdx, blockIdx, gridDim, and blockDim to uint3 and dim3.

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

OK.


http://reviews.llvm.org/D17561



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


Re: [PATCH][modules][PR26237]

2016-02-24 Thread Richard Smith via cfe-commits
On Wed, Feb 24, 2016 at 8:10 AM, Vassil Vassilev  wrote:
>
> On 24/02/16 02:05, Richard Smith wrote:
>>
>> Calling getMostRecentDecl seems like a slightly fragile way to avoid
>> iterator invalidation here. Instead...
>>
>> @@ -214,6 +212,19 @@ namespace clang {
>> unsigned I = Record.size();
>> Record.push_back(0);
>>
>> +  auto &Specializations = Common->Specializations;
>> +  auto &&PartialSpecializations = getPartialSpecializations(Common);
>> +
>> +  // AddFirstDeclFromEachModule might trigger deserialization,
>> invalidating
>> +  // *Specializations iterators. Force the deserialization in
>> advance.
>> +  llvm::SmallVector Specs;
>> +  for (auto &Entry : Specializations)
>> + Specs.push_back(getSpecializationDecl(Entry));
>> +  for (auto &Entry : PartialSpecializations)
>> + Specs.push_back(getSpecializationDecl(Entry));
>> +  for (auto *D : Specs)
>> + D->getMostRecentDecl();
>>
>> ... delete these two lines, and...
>>
>> +
>> for (auto &Entry : Specializations) {
>>
>> ... iterate over "Specs" here
>>
>>   auto *D = getSpecializationDecl(Entry);
>>
>> ... and you don't need this line any more.
>>
>>   assert(D->isCanonicalDecl() && "non-canonical decl in set");
>>
>> You can then remove the following, identical, PartialSpecializations loop.
>
> Done.

+  // *Specializations iterators. Force the deserialization in advance.

Drop the second sentence of this comment, since it's no longer accurate.

>> You also have some tabs in your patch (on the Specs.push_back lines);
>
> Sorry about the tabs, they came from a brand new VM and unconfigured emacs.
>>
>> please fix those prior to commit. With those changes, this LGTM.
>
> Would it make sense to ask for commit perms?

Yes, please see the instructions here:
http://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

>> On Mon, Feb 22, 2016 at 7:11 AM, Vassil Vassilev 
>> wrote:
>>>
>>> ping...
>>>
>>> On 30/01/16 21:13, Vassil Vassilev wrote:
>>>
>>> On 30/01/16 18:36, David Blaikie wrote:
>>>
>>>
>>>
>>> On Sat, Jan 30, 2016 at 9:00 AM, Vassil Vassilev 
>>> wrote:

 AFAICT the making a test case independent on STL is the hard part. I
 think
 it will be always failing due to the relocation of the memory region of
 the
 underlying SmallVector.
>>>
>>>
>>> Sorry, I think I didn't explain myself well. What I mean is - due to the
>>> instability of test cases for UB (especially library UB), we don't
>>> usually
>>> commit test cases for them - we just fix them without tests. About the
>>> only
>>> time I think committing a test is helpful for UB (especially library UB)
>>> is
>>> if we have a reliable way to test/catch the UB (eg: the sanitizers or a
>>> checking STL that fails fast on validation violations). So, while it
>>> would
>>> be good to provide/demonstrate your test case, I would not commit the
>>> test
>>> case unless it's a minimal reproduction in the presence of one of those
>>> tools (sanitizers or checking STL) - and would just commit the fix
>>> without a
>>> test case, usually.
>>>
>>> (I'm not actually reviewing this patch - I don't know much about the
>>> modules
>>> code, but just providing a bit of context and first-pass-review)
>>>
>>> Got it. Thanks!
>>> --Vassil
>>>
>>>

 On 30/01/16 17:37, David Blaikie wrote:

 Yeah, it's good to have a reproduction, but I wouldn't actually commit
 one
 - unless you have a checked stl to test against that always fails on
 possibly-invalidating sequences of operations, then you'd have a fairly
 simple reproduction

 On Jan 30, 2016 8:23 AM, "Vassil Vassilev" 
 wrote:
>
> Sorry.
>
> Our module builds choke on merging several modules, containing
> declarations from STL (we are using libc++, no modulemaps).
>
> When writing a new module containing the definition of a STL
> reverse_iterator, it collects all its template specializations. Some of
> the
> specializations need to be deserialized from a third module. This
> triggers
> an iterator invalidation bug because of the deserialization happening
> when
> iterating the specializations container itself. This happens only when
> the
> container's capacity is exceeded and the relocation invalidates the
> iterators and at best causes a crash (see valgrind reports in the bug
> report). Unfortunately I haven't been able to make the reproducer
> independent on STL.
>
> --Vassil
>
> On 30/01/16 17:08, David Blaikie wrote:
>
> It might be handy to give an overview of the issue in the review (&
> certainly in the commit) message rather than only citing the bug number
>
> On Jan 30, 2016 6:49 AM, "Vassil Vassilev via cfe-commits"
>  wrote:
>>
>> Attaching a fix to https://llvm.org/bugs/show_bug.cgi?id=26237
>>
>> Please review.
>>
>> Many thanks!
>> --Vassil
>>
>

r261774 - Bail on compilation as soon as a job fails.

2016-02-24 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Feb 24 15:49:28 2016
New Revision: 261774

URL: http://llvm.org/viewvc/llvm-project?rev=261774&view=rev
Log:
Bail on compilation as soon as a job fails.

Summary:
(Re-land of r260448, which was reverted in r260522 due to a test failure
in Driver/output-file-cleanup.c that only showed up in fresh builds.)

Previously we attempted to be smart; if one job failed, we'd run all
jobs that didn't depend on the failing job.

Problem is, this doesn't work well for e.g. CUDA compilation without
-save-temps.  In this case, the device-side and host-side Assemble
actions (which actually are responsible for preprocess, compile,
backend, and assemble, since we're not saving temps) are necessarily
distinct.  So our clever heuristic doesn't help us, and we repeat every
error message once for host and once for each device arch.

The main effect of this change, other than fixing CUDA, is that if you
pass multiple cc files to one instance of clang and you get a compile
error, we'll stop when the first cc1 job fails.

Reviewers: echristo

Subscribers: cfe-commits, jhen, echristo, tra, rafael

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

Modified:
cfe/trunk/lib/Driver/Compilation.cpp
cfe/trunk/test/Driver/output-file-cleanup.c

Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=261774&r1=261773&r2=261774&view=diff
==
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Wed Feb 24 15:49:28 2016
@@ -163,39 +163,17 @@ int Compilation::ExecuteCommand(const Co
   return ExecutionFailed ? 1 : Res;
 }
 
-typedef SmallVectorImpl< std::pair > FailingCommandList;
-
-static bool ActionFailed(const Action *A,
- const FailingCommandList &FailingCommands) {
-
-  if (FailingCommands.empty())
-return false;
-
-  for (FailingCommandList::const_iterator CI = FailingCommands.begin(),
- CE = FailingCommands.end(); CI != CE; ++CI)
-if (A == &(CI->second->getSource()))
-  return true;
-
-  for (const Action *AI : A->inputs())
-if (ActionFailed(AI, FailingCommands))
-  return true;
-
-  return false;
-}
-
-static bool InputsOk(const Command &C,
- const FailingCommandList &FailingCommands) {
-  return !ActionFailed(&C.getSource(), FailingCommands);
-}
-
-void Compilation::ExecuteJobs(const JobList &Jobs,
-  FailingCommandList &FailingCommands) const {
+void Compilation::ExecuteJobs(
+const JobList &Jobs,
+SmallVectorImpl> &FailingCommands) const {
   for (const auto &Job : Jobs) {
-if (!InputsOk(Job, FailingCommands))
-  continue;
 const Command *FailingCommand = nullptr;
-if (int Res = ExecuteCommand(Job, FailingCommand))
+if (int Res = ExecuteCommand(Job, FailingCommand)) {
   FailingCommands.push_back(std::make_pair(Res, FailingCommand));
+  // Bail as soon as one command fails, so we don't output duplicate error
+  // messages if we die on e.g. the same file.
+  return;
+}
   }
 }
 

Modified: cfe/trunk/test/Driver/output-file-cleanup.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/output-file-cleanup.c?rev=261774&r1=261773&r2=261774&view=diff
==
--- cfe/trunk/test/Driver/output-file-cleanup.c (original)
+++ cfe/trunk/test/Driver/output-file-cleanup.c Wed Feb 24 15:49:28 2016
@@ -38,6 +38,9 @@ invalid C code
 // RUN: test -f %t1.s
 // RUN: test ! -f %t2.s
 
+// When given multiple .c files to compile, clang compiles them in order until
+// it hits an error, at which point it stops.
+//
 // RUN: touch %t1.c
 // RUN: echo "invalid C code" > %t2.c
 // RUN: touch %t3.c
@@ -46,6 +49,6 @@ invalid C code
 // RUN: cd %T && not %clang -S %t1.c %t2.c %t3.c %t4.c %t5.c
 // RUN: test -f %t1.s
 // RUN: test ! -f %t2.s
-// RUN: test -f %t3.s
+// RUN: test ! -f %t3.s
 // RUN: test ! -f %t4.s
-// RUN: test -f %t5.s
+// RUN: test ! -f %t5.s


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


r261775 - [CUDA] Don't specify exact line numbers in cuda-builtin-vars.cu.

2016-02-24 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Feb 24 15:49:30 2016
New Revision: 261775

URL: http://llvm.org/viewvc/llvm-project?rev=261775&view=rev
Log:
[CUDA] Don't specify exact line numbers in cuda-builtin-vars.cu.

This makes the test less fragile to changes to cuda_builtin_vars.h.

Test-only change.

Modified:
cfe/trunk/test/SemaCUDA/cuda-builtin-vars.cu

Modified: cfe/trunk/test/SemaCUDA/cuda-builtin-vars.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/cuda-builtin-vars.cu?rev=261775&r1=261774&r2=261775&view=diff
==
--- cfe/trunk/test/SemaCUDA/cuda-builtin-vars.cu (original)
+++ cfe/trunk/test/SemaCUDA/cuda-builtin-vars.cu Wed Feb 24 15:49:30 2016
@@ -34,20 +34,20 @@ void kernel(int *out) {
 
   out[i++] = warpSize;
   warpSize = 0; // expected-error {{cannot assign to variable 'warpSize' with 
const-qualified type 'const int'}}
-  // expected-note@cuda_builtin_vars.h:104 {{variable 'warpSize' declared 
const here}}
+  // expected-note@cuda_builtin_vars.h:* {{variable 'warpSize' declared const 
here}}
 
   // Make sure we can't construct or assign to the special variables.
   __cuda_builtin_threadIdx_t x; // expected-error {{calling a private 
constructor of class '__cuda_builtin_threadIdx_t'}}
-  // expected-note@cuda_builtin_vars.h:67 {{declared private here}}
+  // expected-note@cuda_builtin_vars.h:* {{declared private here}}
 
   __cuda_builtin_threadIdx_t y = threadIdx; // expected-error {{calling a 
private constructor of class '__cuda_builtin_threadIdx_t'}}
-  // expected-note@cuda_builtin_vars.h:67 {{declared private here}}
+  // expected-note@cuda_builtin_vars.h:* {{declared private here}}
 
   threadIdx = threadIdx; // expected-error {{'operator=' is a private member 
of '__cuda_builtin_threadIdx_t'}}
-  // expected-note@cuda_builtin_vars.h:67 {{declared private here}}
+  // expected-note@cuda_builtin_vars.h:* {{declared private here}}
 
   void *ptr = &threadIdx; // expected-error {{'operator&' is a private member 
of '__cuda_builtin_threadIdx_t'}}
-  // expected-note@cuda_builtin_vars.h:67 {{declared private here}}
+  // expected-note@cuda_builtin_vars.h:* {{declared private here}}
 
   // Following line should've caused an error as one is not allowed to
   // take address of a built-in variable in CUDA. Alas there's no way


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


r261776 - [CUDA] Add hack so code which includes "curand.h" doesn't break.

2016-02-24 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Feb 24 15:49:31 2016
New Revision: 261776

URL: http://llvm.org/viewvc/llvm-project?rev=261776&view=rev
Log:
[CUDA] Add hack so code which includes "curand.h" doesn't break.

Summary:
curand.h includes curand_mtgp32_kernel.h.  In host mode, this header
redefines threadIdx and blockDim, giving them their "proper" types of
uint3 and dim3, respectively.

clang has its own plan for these variables -- their types are magic
builtin classes.  So these redefinitions are incompatible.

As a hack, we force-include the offending CUDA header and use #defines
to get the right types for threadIdx and blockDim.

Reviewers: tra

Subscribers: echristo, cfe-commits

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

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

Modified: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h?rev=261776&r1=261775&r2=261776&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Wed Feb 24 15:49:31 
2016
@@ -247,5 +247,19 @@ __device__ static inline void *malloc(si
 
 #include <__clang_cuda_cmath.h>
 
+// curand_mtgp32_kernel helpfully redeclares blockDim and threadIdx in host
+// mode, giving them their "proper" types of dim3 and uint3.  This is
+// incompatible with the types we give in cuda_builtin_vars.h.  As as hack,
+// force-include the header (nvcc doesn't include it by default) but redefine
+// dim3 and uint3 to our builtin types.  (Thankfully dim3 and uint3 are only
+// used here for the redeclarations of blockDim and threadIdx.)
+#pragma push_macro("dim3")
+#pragma push_macro("uint3")
+#define dim3 __cuda_builtin_blockDim_t
+#define uint3 __cuda_builtin_threadIdx_t
+#include "curand_mtgp32_kernel.h"
+#pragma pop_macro("dim3")
+#pragma pop_macro("uint3")
+
 #endif // __CUDA__
 #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__


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


r261773 - Make test/Driver/output-file-cleanup.c hermetic.

2016-02-24 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Feb 24 15:49:26 2016
New Revision: 261773

URL: http://llvm.org/viewvc/llvm-project?rev=261773&view=rev
Log:
Make test/Driver/output-file-cleanup.c hermetic.

Summary:
It checks that certain files do and exist, so make sure that they don't
exist at the beginning of the test.

This hid a failure in r260448; to see the failure, you had to run the test with
a clean-ish objdir.

Subscribers: cfe-commits

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

Modified:
cfe/trunk/test/Driver/output-file-cleanup.c

Modified: cfe/trunk/test/Driver/output-file-cleanup.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/output-file-cleanup.c?rev=261773&r1=261772&r2=261773&view=diff
==
--- cfe/trunk/test/Driver/output-file-cleanup.c (original)
+++ cfe/trunk/test/Driver/output-file-cleanup.c Wed Feb 24 15:49:26 2016
@@ -1,3 +1,5 @@
+// RUN: rm -f "%t.d" "%t1.s" "%t2.s" "%t3.s" "%t4.s" "%t5.s"
+//
 // RUN: touch %t.s
 // RUN: not %clang -S -DCRASH -o %t.s -MMD -MF %t.d %s
 // RUN: test ! -f %t.s


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


r261777 - [CUDA] Add conversion operators for threadIdx, blockIdx, gridDim, and blockDim to uint3 and dim3.

2016-02-24 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Feb 24 15:49:33 2016
New Revision: 261777

URL: http://llvm.org/viewvc/llvm-project?rev=261777&view=rev
Log:
[CUDA] Add conversion operators for threadIdx, blockIdx, gridDim, and blockDim 
to uint3 and dim3.

Summary:
This lets you write, e.g.

  uint3 a = threadIdx;
  uint3 b = blockIdx;
  dim3 c = gridDim;
  dim3 d = blockDim;

which is legal in nvcc, but was not legal in clang.

The fact that e.g. the type of threadIdx is not actually uint3 is still
observable, but now you have to try to observe it.

Reviewers: tra

Subscribers: echristo, cfe-commits

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
cfe/trunk/lib/Headers/cuda_builtin_vars.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h?rev=261777&r1=261776&r2=261777&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Wed Feb 24 15:49:33 
2016
@@ -245,6 +245,33 @@ __device__ static inline void *malloc(si
 }
 } // namespace std
 
+// Out-of-line implementations from cuda_builtin_vars.h.  These need to come
+// after we've pulled in the definition of uint3 and dim3.
+
+__device__ inline __cuda_builtin_threadIdx_t::operator uint3() const {
+  uint3 ret;
+  ret.x = x;
+  ret.y = y;
+  ret.z = z;
+  return ret;
+}
+
+__device__ inline __cuda_builtin_blockIdx_t::operator uint3() const {
+  uint3 ret;
+  ret.x = x;
+  ret.y = y;
+  ret.z = z;
+  return ret;
+}
+
+__device__ inline __cuda_builtin_blockDim_t::operator dim3() const {
+  return dim3(x, y, z);
+}
+
+__device__ inline __cuda_builtin_gridDim_t::operator dim3() const {
+  return dim3(x, y, z);
+}
+
 #include <__clang_cuda_cmath.h>
 
 // curand_mtgp32_kernel helpfully redeclares blockDim and threadIdx in host

Modified: cfe/trunk/lib/Headers/cuda_builtin_vars.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/cuda_builtin_vars.h?rev=261777&r1=261776&r2=261777&view=diff
==
--- cfe/trunk/lib/Headers/cuda_builtin_vars.h (original)
+++ cfe/trunk/lib/Headers/cuda_builtin_vars.h Wed Feb 24 15:49:33 2016
@@ -24,10 +24,14 @@
 #ifndef __CUDA_BUILTIN_VARS_H
 #define __CUDA_BUILTIN_VARS_H
 
+// Forward declares from vector_types.h.
+struct uint3;
+struct dim3;
+
 // The file implements built-in CUDA variables using __declspec(property).
 // https://msdn.microsoft.com/en-us/library/yhfk0thd.aspx
 // All read accesses of built-in variable fields get converted into calls to a
-// getter function which in turn would call appropriate builtin to fetch the
+// getter function which in turn calls the appropriate builtin to fetch the
 // value.
 //
 // Example:
@@ -63,6 +67,9 @@ struct __cuda_builtin_threadIdx_t {
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_tid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_tid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_tid_z());
+  // threadIdx should be convertible to uint3 (in fact in nvcc, it *is* a
+  // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator uint3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_threadIdx_t);
 };
@@ -71,6 +78,9 @@ struct __cuda_builtin_blockIdx_t {
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_ctaid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_ctaid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_ctaid_z());
+  // blockIdx should be convertible to uint3 (in fact in nvcc, it *is* a
+  // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator uint3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockIdx_t);
 };
@@ -79,6 +89,9 @@ struct __cuda_builtin_blockDim_t {
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_ntid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_ntid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_ntid_z());
+  // blockDim should be convertible to dim3 (in fact in nvcc, it *is* a
+  // dim3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator dim3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockDim_t);
 };
@@ -87,6 +100,9 @@ struct __cuda_builtin_gridDim_t {
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_nctaid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_nctaid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_nctaid_z());
+  // gridDim should be convertible to dim3 (in fact in nvcc, it *is* a
+  // dim3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator dim3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_gridDim_t);
 };


___

Re: [PATCH] D17562: [CUDA] Add hack so code which includes "curand.h" doesn't break.

2016-02-24 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261776: [CUDA] Add hack so code which includes "curand.h" 
doesn't break. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D17562?vs=48885&id=48977#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17562

Files:
  cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -247,5 +247,19 @@
 
 #include <__clang_cuda_cmath.h>
 
+// curand_mtgp32_kernel helpfully redeclares blockDim and threadIdx in host
+// mode, giving them their "proper" types of dim3 and uint3.  This is
+// incompatible with the types we give in cuda_builtin_vars.h.  As as hack,
+// force-include the header (nvcc doesn't include it by default) but redefine
+// dim3 and uint3 to our builtin types.  (Thankfully dim3 and uint3 are only
+// used here for the redeclarations of blockDim and threadIdx.)
+#pragma push_macro("dim3")
+#pragma push_macro("uint3")
+#define dim3 __cuda_builtin_blockDim_t
+#define uint3 __cuda_builtin_threadIdx_t
+#include "curand_mtgp32_kernel.h"
+#pragma pop_macro("dim3")
+#pragma pop_macro("uint3")
+
 #endif // __CUDA__
 #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__


Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -247,5 +247,19 @@
 
 #include <__clang_cuda_cmath.h>
 
+// curand_mtgp32_kernel helpfully redeclares blockDim and threadIdx in host
+// mode, giving them their "proper" types of dim3 and uint3.  This is
+// incompatible with the types we give in cuda_builtin_vars.h.  As as hack,
+// force-include the header (nvcc doesn't include it by default) but redefine
+// dim3 and uint3 to our builtin types.  (Thankfully dim3 and uint3 are only
+// used here for the redeclarations of blockDim and threadIdx.)
+#pragma push_macro("dim3")
+#pragma push_macro("uint3")
+#define dim3 __cuda_builtin_blockDim_t
+#define uint3 __cuda_builtin_threadIdx_t
+#include "curand_mtgp32_kernel.h"
+#pragma pop_macro("dim3")
+#pragma pop_macro("uint3")
+
 #endif // __CUDA__
 #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17216: Make test/Driver/output-file-cleanup.c hermetic.

2016-02-24 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261773: Make test/Driver/output-file-cleanup.c hermetic. 
(authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D17216?vs=47857&id=48975#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17216

Files:
  cfe/trunk/test/Driver/output-file-cleanup.c

Index: cfe/trunk/test/Driver/output-file-cleanup.c
===
--- cfe/trunk/test/Driver/output-file-cleanup.c
+++ cfe/trunk/test/Driver/output-file-cleanup.c
@@ -1,3 +1,5 @@
+// RUN: rm -f "%t.d" "%t1.s" "%t2.s" "%t3.s" "%t4.s" "%t5.s"
+//
 // RUN: touch %t.s
 // RUN: not %clang -S -DCRASH -o %t.s -MMD -MF %t.d %s
 // RUN: test ! -f %t.s


Index: cfe/trunk/test/Driver/output-file-cleanup.c
===
--- cfe/trunk/test/Driver/output-file-cleanup.c
+++ cfe/trunk/test/Driver/output-file-cleanup.c
@@ -1,3 +1,5 @@
+// RUN: rm -f "%t.d" "%t1.s" "%t2.s" "%t3.s" "%t4.s" "%t5.s"
+//
 // RUN: touch %t.s
 // RUN: not %clang -S -DCRASH -o %t.s -MMD -MF %t.d %s
 // RUN: test ! -f %t.s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17217: Bail on compilation as soon as a job fails.

2016-02-24 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261774: Bail on compilation as soon as a job fails. 
(authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D17217?vs=47858&id=48976#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17217

Files:
  cfe/trunk/lib/Driver/Compilation.cpp
  cfe/trunk/test/Driver/output-file-cleanup.c

Index: cfe/trunk/lib/Driver/Compilation.cpp
===
--- cfe/trunk/lib/Driver/Compilation.cpp
+++ cfe/trunk/lib/Driver/Compilation.cpp
@@ -163,39 +163,17 @@
   return ExecutionFailed ? 1 : Res;
 }
 
-typedef SmallVectorImpl< std::pair > FailingCommandList;
-
-static bool ActionFailed(const Action *A,
- const FailingCommandList &FailingCommands) {
-
-  if (FailingCommands.empty())
-return false;
-
-  for (FailingCommandList::const_iterator CI = FailingCommands.begin(),
- CE = FailingCommands.end(); CI != CE; ++CI)
-if (A == &(CI->second->getSource()))
-  return true;
-
-  for (const Action *AI : A->inputs())
-if (ActionFailed(AI, FailingCommands))
-  return true;
-
-  return false;
-}
-
-static bool InputsOk(const Command &C,
- const FailingCommandList &FailingCommands) {
-  return !ActionFailed(&C.getSource(), FailingCommands);
-}
-
-void Compilation::ExecuteJobs(const JobList &Jobs,
-  FailingCommandList &FailingCommands) const {
+void Compilation::ExecuteJobs(
+const JobList &Jobs,
+SmallVectorImpl> &FailingCommands) const {
   for (const auto &Job : Jobs) {
-if (!InputsOk(Job, FailingCommands))
-  continue;
 const Command *FailingCommand = nullptr;
-if (int Res = ExecuteCommand(Job, FailingCommand))
+if (int Res = ExecuteCommand(Job, FailingCommand)) {
   FailingCommands.push_back(std::make_pair(Res, FailingCommand));
+  // Bail as soon as one command fails, so we don't output duplicate error
+  // messages if we die on e.g. the same file.
+  return;
+}
   }
 }
 
Index: cfe/trunk/test/Driver/output-file-cleanup.c
===
--- cfe/trunk/test/Driver/output-file-cleanup.c
+++ cfe/trunk/test/Driver/output-file-cleanup.c
@@ -38,14 +38,17 @@
 // RUN: test -f %t1.s
 // RUN: test ! -f %t2.s
 
+// When given multiple .c files to compile, clang compiles them in order until
+// it hits an error, at which point it stops.
+//
 // RUN: touch %t1.c
 // RUN: echo "invalid C code" > %t2.c
 // RUN: touch %t3.c
 // RUN: echo "invalid C code" > %t4.c
 // RUN: touch %t5.c
 // RUN: cd %T && not %clang -S %t1.c %t2.c %t3.c %t4.c %t5.c
 // RUN: test -f %t1.s
 // RUN: test ! -f %t2.s
-// RUN: test -f %t3.s
+// RUN: test ! -f %t3.s
 // RUN: test ! -f %t4.s
-// RUN: test -f %t5.s
+// RUN: test ! -f %t5.s


Index: cfe/trunk/lib/Driver/Compilation.cpp
===
--- cfe/trunk/lib/Driver/Compilation.cpp
+++ cfe/trunk/lib/Driver/Compilation.cpp
@@ -163,39 +163,17 @@
   return ExecutionFailed ? 1 : Res;
 }
 
-typedef SmallVectorImpl< std::pair > FailingCommandList;
-
-static bool ActionFailed(const Action *A,
- const FailingCommandList &FailingCommands) {
-
-  if (FailingCommands.empty())
-return false;
-
-  for (FailingCommandList::const_iterator CI = FailingCommands.begin(),
- CE = FailingCommands.end(); CI != CE; ++CI)
-if (A == &(CI->second->getSource()))
-  return true;
-
-  for (const Action *AI : A->inputs())
-if (ActionFailed(AI, FailingCommands))
-  return true;
-
-  return false;
-}
-
-static bool InputsOk(const Command &C,
- const FailingCommandList &FailingCommands) {
-  return !ActionFailed(&C.getSource(), FailingCommands);
-}
-
-void Compilation::ExecuteJobs(const JobList &Jobs,
-  FailingCommandList &FailingCommands) const {
+void Compilation::ExecuteJobs(
+const JobList &Jobs,
+SmallVectorImpl> &FailingCommands) const {
   for (const auto &Job : Jobs) {
-if (!InputsOk(Job, FailingCommands))
-  continue;
 const Command *FailingCommand = nullptr;
-if (int Res = ExecuteCommand(Job, FailingCommand))
+if (int Res = ExecuteCommand(Job, FailingCommand)) {
   FailingCommands.push_back(std::make_pair(Res, FailingCommand));
+  // Bail as soon as one command fails, so we don't output duplicate error
+  // messages if we die on e.g. the same file.
+  return;
+}
   }
 }
 
Index: cfe/trunk/test/Driver/output-file-cleanup.c
===
--- cfe/trunk/test/Driver/output-file-cleanup.c
+++ cfe/trunk/test/Driver/output-file-cleanup.c
@@ -38,14 +38,17 @@
 // RUN: test -f %t1.s
 // RUN: test ! -f %t2.s
 
+// When given multiple .c files to compile, clang compiles them in order until
+// it hits an error, at which point it stops.
+//

Re: [PATCH] D17561: [CUDA] Add conversion operators for threadIdx, blockIdx, gridDim, and blockDim to uint3 and dim3.

2016-02-24 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261777: [CUDA] Add conversion operators for threadIdx, 
blockIdx, gridDim, and… (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D17561?vs=48884&id=48978#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17561

Files:
  cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
  cfe/trunk/lib/Headers/cuda_builtin_vars.h

Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -245,6 +245,33 @@
 }
 } // namespace std
 
+// Out-of-line implementations from cuda_builtin_vars.h.  These need to come
+// after we've pulled in the definition of uint3 and dim3.
+
+__device__ inline __cuda_builtin_threadIdx_t::operator uint3() const {
+  uint3 ret;
+  ret.x = x;
+  ret.y = y;
+  ret.z = z;
+  return ret;
+}
+
+__device__ inline __cuda_builtin_blockIdx_t::operator uint3() const {
+  uint3 ret;
+  ret.x = x;
+  ret.y = y;
+  ret.z = z;
+  return ret;
+}
+
+__device__ inline __cuda_builtin_blockDim_t::operator dim3() const {
+  return dim3(x, y, z);
+}
+
+__device__ inline __cuda_builtin_gridDim_t::operator dim3() const {
+  return dim3(x, y, z);
+}
+
 #include <__clang_cuda_cmath.h>
 
 // curand_mtgp32_kernel helpfully redeclares blockDim and threadIdx in host
Index: cfe/trunk/lib/Headers/cuda_builtin_vars.h
===
--- cfe/trunk/lib/Headers/cuda_builtin_vars.h
+++ cfe/trunk/lib/Headers/cuda_builtin_vars.h
@@ -24,10 +24,14 @@
 #ifndef __CUDA_BUILTIN_VARS_H
 #define __CUDA_BUILTIN_VARS_H
 
+// Forward declares from vector_types.h.
+struct uint3;
+struct dim3;
+
 // The file implements built-in CUDA variables using __declspec(property).
 // https://msdn.microsoft.com/en-us/library/yhfk0thd.aspx
 // All read accesses of built-in variable fields get converted into calls to a
-// getter function which in turn would call appropriate builtin to fetch the
+// getter function which in turn calls the appropriate builtin to fetch the
 // value.
 //
 // Example:
@@ -63,30 +67,42 @@
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_tid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_tid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_tid_z());
+  // threadIdx should be convertible to uint3 (in fact in nvcc, it *is* a
+  // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator uint3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_threadIdx_t);
 };
 
 struct __cuda_builtin_blockIdx_t {
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_ctaid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_ctaid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_ctaid_z());
+  // blockIdx should be convertible to uint3 (in fact in nvcc, it *is* a
+  // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator uint3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockIdx_t);
 };
 
 struct __cuda_builtin_blockDim_t {
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_ntid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_ntid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_ntid_z());
+  // blockDim should be convertible to dim3 (in fact in nvcc, it *is* a
+  // dim3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator dim3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockDim_t);
 };
 
 struct __cuda_builtin_gridDim_t {
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_nctaid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_nctaid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_nctaid_z());
+  // gridDim should be convertible to dim3 (in fact in nvcc, it *is* a
+  // dim3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator dim3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_gridDim_t);
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17056: Mark all CUDA device-side function defs and decls as convergent.

2016-02-24 Thread David Majnemer via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D17056



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


Re: [PATCH] D17056: Mark all CUDA device-side function defs and decls as convergent.

2016-02-24 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261779: [CUDA] Mark all CUDA device-side function defs, 
decls, and calls as convergent. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D17056?vs=48261&id=48979#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17056

Files:
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/test/CodeGenCUDA/convergent.cu
  cfe/trunk/test/CodeGenCUDA/device-var-init.cu

Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -1595,6 +1595,14 @@
 }
   }
 
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
+// Conservatively, mark all functions and calls in CUDA as convergent
+// (meaning, they may call an intrinsically convergent op, such as
+// __syncthreads(), and so can't have certain optimizations applied around
+// them).  LLVM will remove this attribute where it safely can.
+FuncAttrs.addAttribute(llvm::Attribute::Convergent);
+  }
+
   ClangToLLVMArgMapping IRFunctionArgs(getContext(), FI);
 
   QualType RetTy = FI.getReturnType();
Index: cfe/trunk/test/CodeGenCUDA/convergent.cu
===
--- cfe/trunk/test/CodeGenCUDA/convergent.cu
+++ cfe/trunk/test/CodeGenCUDA/convergent.cu
@@ -0,0 +1,39 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix DEVICE %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | \
+// RUN:  FileCheck -check-prefix HOST %s
+
+#include "Inputs/cuda.h"
+
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3foov
+__device__ void foo() {}
+
+// HOST: Function Attrs:
+// HOST-NOT: convergent
+// HOST-NEXT: define void @_Z3barv
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3barv
+__host__ __device__ void baz();
+__host__ __device__ void bar() {
+  // DEVICE: call void @_Z3bazv() [[CALL_ATTR:#[0-9]+]]
+  baz();
+}
+
+// DEVICE: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// DEVICE: attributes [[BAZ_ATTR]] = {
+// DEVICE-SAME: convergent
+// DEVICE-SAME: }
+// DEVICE: attributes [[CALL_ATTR]] = { convergent }
+
+// HOST: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// HOST: attributes [[BAZ_ATTR]] = {
+// HOST-NOT: convergent
+// NOST-SAME: }
Index: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
===
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu
@@ -382,7 +382,7 @@
 // CHECK:   call void @_ZN4NETCC1IJEEEDpT_(%struct.NETC* %netc)
 // CHECK:   call void @_ZN7EC_I_ECC1Ev(%struct.EC_I_EC* %ec_i_ec)
 // CHECK:   call void @_ZN8EC_I_EC1C1Ev(%struct.EC_I_EC1* %ec_i_ec1)
-// CHECK:   call void @_ZN5T_V_TC1Ev(%struct.T_V_T* %t_v_t) #3
+// CHECK:   call void @_ZN5T_V_TC1Ev(%struct.T_V_T* %t_v_t)
 // CHECK:   call void @_ZN7T_B_NECC1Ev(%struct.T_B_NEC* %t_b_nec)
 // CHECK:   call void @_ZN7T_F_NECC1Ev(%struct.T_F_NEC* %t_f_nec)
 // CHECK:   call void @_ZN8T_FA_NECC1Ev(%struct.T_FA_NEC* %t_fa_nec)


Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -1595,6 +1595,14 @@
 }
   }
 
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
+// Conservatively, mark all functions and calls in CUDA as convergent
+// (meaning, they may call an intrinsically convergent op, such as
+// __syncthreads(), and so can't have certain optimizations applied around
+// them).  LLVM will remove this attribute where it safely can.
+FuncAttrs.addAttribute(llvm::Attribute::Convergent);
+  }
+
   ClangToLLVMArgMapping IRFunctionArgs(getContext(), FI);
 
   QualType RetTy = FI.getReturnType();
Index: cfe/trunk/test/CodeGenCUDA/convergent.cu
===
--- cfe/trunk/test/CodeGenCUDA/convergent.cu
+++ cfe/trunk/test/CodeGenCUDA/convergent.cu
@@ -0,0 +1,39 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix DEVICE %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | \
+// RUN:  FileCheck -check-prefix HOST %s
+
+#include "Inputs/cuda.h"
+
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3foov
+__device__ void foo() {}
+
+// HOST: Function Attrs:
+// HOST-NOT: convergent
+// HOST-NEXT: define void @_Z3barv
+// DEVICE: Fu

r261779 - [CUDA] Mark all CUDA device-side function defs, decls, and calls as convergent.

2016-02-24 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Feb 24 15:55:11 2016
New Revision: 261779

URL: http://llvm.org/viewvc/llvm-project?rev=261779&view=rev
Log:
[CUDA] Mark all CUDA device-side function defs, decls, and calls as convergent.

Summary:
This is important for e.g. the following case:

  void sync() { __syncthreads(); }
  void foo() {
do_something();
sync();
do_something_else():
  }

Without this change, if the optimizer does not inline sync() (which it
won't because __syncthreads is also marked as noduplicate, for now
anyway), it is free to perform optimizations on sync() that it would not
be able to perform on __syncthreads(), because sync() is not marked as
convergent.

Similarly, we need a notion of convergent calls, since in the case when
we can't statically determine a call's target(s), we need to know
whether it's safe to perform optimizations around the call.

This change is conservative; the optimizer will remove these attrs where
it can, see r260318, r260319.

Reviewers: majnemer

Subscribers: cfe-commits, jhen, echristo, tra

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

Added:
cfe/trunk/test/CodeGenCUDA/convergent.cu
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGenCUDA/device-var-init.cu

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=261779&r1=261778&r2=261779&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Feb 24 15:55:11 2016
@@ -1595,6 +1595,14 @@ void CodeGenModule::ConstructAttributeLi
 }
   }
 
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
+// Conservatively, mark all functions and calls in CUDA as convergent
+// (meaning, they may call an intrinsically convergent op, such as
+// __syncthreads(), and so can't have certain optimizations applied around
+// them).  LLVM will remove this attribute where it safely can.
+FuncAttrs.addAttribute(llvm::Attribute::Convergent);
+  }
+
   ClangToLLVMArgMapping IRFunctionArgs(getContext(), FI);
 
   QualType RetTy = FI.getReturnType();

Added: cfe/trunk/test/CodeGenCUDA/convergent.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/convergent.cu?rev=261779&view=auto
==
--- cfe/trunk/test/CodeGenCUDA/convergent.cu (added)
+++ cfe/trunk/test/CodeGenCUDA/convergent.cu Wed Feb 24 15:55:11 2016
@@ -0,0 +1,39 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix DEVICE %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | \
+// RUN:  FileCheck -check-prefix HOST %s
+
+#include "Inputs/cuda.h"
+
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3foov
+__device__ void foo() {}
+
+// HOST: Function Attrs:
+// HOST-NOT: convergent
+// HOST-NEXT: define void @_Z3barv
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3barv
+__host__ __device__ void baz();
+__host__ __device__ void bar() {
+  // DEVICE: call void @_Z3bazv() [[CALL_ATTR:#[0-9]+]]
+  baz();
+}
+
+// DEVICE: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// DEVICE: attributes [[BAZ_ATTR]] = {
+// DEVICE-SAME: convergent
+// DEVICE-SAME: }
+// DEVICE: attributes [[CALL_ATTR]] = { convergent }
+
+// HOST: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// HOST: attributes [[BAZ_ATTR]] = {
+// HOST-NOT: convergent
+// NOST-SAME: }

Modified: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/device-var-init.cu?rev=261779&r1=261778&r2=261779&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu Wed Feb 24 15:55:11 2016
@@ -382,7 +382,7 @@ __device__ void df() {
 // CHECK:   call void @_ZN4NETCC1IJEEEDpT_(%struct.NETC* %netc)
 // CHECK:   call void @_ZN7EC_I_ECC1Ev(%struct.EC_I_EC* %ec_i_ec)
 // CHECK:   call void @_ZN8EC_I_EC1C1Ev(%struct.EC_I_EC1* %ec_i_ec1)
-// CHECK:   call void @_ZN5T_V_TC1Ev(%struct.T_V_T* %t_v_t) #3
+// CHECK:   call void @_ZN5T_V_TC1Ev(%struct.T_V_T* %t_v_t)
 // CHECK:   call void @_ZN7T_B_NECC1Ev(%struct.T_B_NEC* %t_b_nec)
 // CHECK:   call void @_ZN7T_F_NECC1Ev(%struct.T_F_NEC* %t_f_nec)
 // CHECK:   call void @_ZN8T_FA_NECC1Ev(%struct.T_FA_NEC* %t_fa_nec)


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


r261778 - [CUDA] do not allow attribute-based overloading for __global__ functions.

2016-02-24 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Feb 24 15:54:45 2016
New Revision: 261778

URL: http://llvm.org/viewvc/llvm-project?rev=261778&view=rev
Log:
[CUDA] do not allow attribute-based overloading for __global__ functions.

__global__ functions are present on both host and device side,
so providing __host__ or __device__ overloads is not going to
do anything useful.

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCUDA/function-overload.cu

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=261778&r1=261777&r2=261778&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Feb 24 15:54:45 2016
@@ -1129,7 +1129,10 @@ bool Sema::IsOverload(FunctionDecl *New,
 // Don't allow mixing of HD with other kinds. This guarantees that
 // we have only one viable function with this signature on any
 // side of CUDA compilation .
-if ((NewTarget == CFT_HostDevice) || (OldTarget == CFT_HostDevice))
+// __global__ functions can't be overloaded based on attribute
+// difference because, like HD, they also exist on both sides.
+if ((NewTarget == CFT_HostDevice) || (OldTarget == CFT_HostDevice) ||
+(NewTarget == CFT_Global) || (OldTarget == CFT_Global))
   return false;
 
 // Allow overloading of functions with same signature, but

Modified: cfe/trunk/test/SemaCUDA/function-overload.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/function-overload.cu?rev=261778&r1=261777&r2=261778&view=diff
==
--- cfe/trunk/test/SemaCUDA/function-overload.cu (original)
+++ cfe/trunk/test/SemaCUDA/function-overload.cu Wed Feb 24 15:54:45 2016
@@ -302,3 +302,13 @@ struct m_hdd {
   __host__ __device__ void operator delete(void *ptr) {} // expected-note 
{{previous declaration is here}}
   __device__ void operator delete(void *ptr) {} // expected-error {{class 
member cannot be redeclared}}
 };
+
+// __global__ functions can't be overloaded based on attribute
+// difference.
+struct G {
+  friend void friend_of_g(G &arg);
+private:
+  int x;
+};
+__global__ void friend_of_g(G &arg) { int x = arg.x; } // expected-note 
{{previous definition is here}}
+void friend_of_g(G &arg) { int x = arg.x; } // expected-error {{redefinition 
of 'friend_of_g'}}


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


r261780 - Don't convert a char to a const char *

2016-02-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Feb 24 15:55:58 2016
New Revision: 261780

URL: http://llvm.org/viewvc/llvm-project?rev=261780&view=rev
Log:
Don't convert a char to a const char *

This fixes PR26728.

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

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=261780&r1=261779&r2=261780&view=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Feb 24 15:55:58 2016
@@ -1226,7 +1226,7 @@ void Preprocessor::HandleUserDiagnosticD
 
   // Find the first non-whitespace character, so that we can make the
   // diagnostic more succinct.
-  StringRef Msg = StringRef(Message).ltrim(' ');
+  StringRef Msg = StringRef(Message).ltrim(" ");
 
   if (isWarning)
 Diag(Tok, diag::pp_hash_warning) << Msg;


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


Re: [PATCH] D17576: Fix assertion failure on MaybeODRUseExprs.

2016-02-24 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
This revision is now accepted and ready to land.


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:2114
@@ -2113,1 +2113,3 @@
+EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+   
Sema::ConstantEvaluated);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), 
TemplateArgs);

faisalv wrote:
> Looks reasonable to me - since it is consistent with the other changes I had 
> made.  But somewhat orthogonal to your fix, I wouldn't mind Richard 
> commenting on why constant expression evaluation does not have 
> IsPotentiallyEvaluatedContext return false (and avoid adding an entry to 
> MaybeODRUse)
> Also, just as SubstituteDefaultTemplateArgument does, Perhaps we should add 
> an InstantiatingTemplate on the stack that marks this as a substitution into  
> default arguments.  It would be nice if we could refactor both into a call to 
> the same function (i.e SubstittueDefaultTempalteArgument) - but looking at 
> the code for it, that would be a little tricky.
> My 2 cents.
"Potentially evaluated" is a term defined in the standard; it would be 
confusing for us to use it to mean something else. Constant expressions *are* 
evaluated (typically only during compilation), and they can result in odr-use. 
The cases where they don't do so are somewhat specialized.

I don't think we need or want a separate entry on the instantiation stack, as 
we're still instantiating pieces of the same entity, with the same 
instantiation semantics.


http://reviews.llvm.org/D17576



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


Re: [PATCH][modules][PR26237]

2016-02-24 Thread Vassil Vassilev via cfe-commits

On 24/02/16 22:50, Richard Smith wrote:

On Wed, Feb 24, 2016 at 8:10 AM, Vassil Vassilev  wrote:

On 24/02/16 02:05, Richard Smith wrote:

Calling getMostRecentDecl seems like a slightly fragile way to avoid
iterator invalidation here. Instead...

@@ -214,6 +212,19 @@ namespace clang {
 unsigned I = Record.size();
 Record.push_back(0);

+  auto &Specializations = Common->Specializations;
+  auto &&PartialSpecializations = getPartialSpecializations(Common);
+
+  // AddFirstDeclFromEachModule might trigger deserialization,
invalidating
+  // *Specializations iterators. Force the deserialization in
advance.
+  llvm::SmallVector Specs;
+  for (auto &Entry : Specializations)
+ Specs.push_back(getSpecializationDecl(Entry));
+  for (auto &Entry : PartialSpecializations)
+ Specs.push_back(getSpecializationDecl(Entry));
+  for (auto *D : Specs)
+ D->getMostRecentDecl();

... delete these two lines, and...

+
 for (auto &Entry : Specializations) {

... iterate over "Specs" here

   auto *D = getSpecializationDecl(Entry);

... and you don't need this line any more.

   assert(D->isCanonicalDecl() && "non-canonical decl in set");

You can then remove the following, identical, PartialSpecializations loop.

Done.

+  // *Specializations iterators. Force the deserialization in advance.

Drop the second sentence of this comment, since it's no longer accurate.

oops... thanks!



You also have some tabs in your patch (on the Specs.push_back lines);

Sorry about the tabs, they came from a brand new VM and unconfigured emacs.

please fix those prior to commit. With those changes, this LGTM.

Would it make sense to ask for commit perms?

Yes, please see the instructions here:
http://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

Will do. Could you check this patch in meanwhile, please?



On Mon, Feb 22, 2016 at 7:11 AM, Vassil Vassilev 
wrote:

ping...

On 30/01/16 21:13, Vassil Vassilev wrote:

On 30/01/16 18:36, David Blaikie wrote:



On Sat, Jan 30, 2016 at 9:00 AM, Vassil Vassilev 
wrote:

AFAICT the making a test case independent on STL is the hard part. I
think
it will be always failing due to the relocation of the memory region of
the
underlying SmallVector.


Sorry, I think I didn't explain myself well. What I mean is - due to the
instability of test cases for UB (especially library UB), we don't
usually
commit test cases for them - we just fix them without tests. About the
only
time I think committing a test is helpful for UB (especially library UB)
is
if we have a reliable way to test/catch the UB (eg: the sanitizers or a
checking STL that fails fast on validation violations). So, while it
would
be good to provide/demonstrate your test case, I would not commit the
test
case unless it's a minimal reproduction in the presence of one of those
tools (sanitizers or checking STL) - and would just commit the fix
without a
test case, usually.

(I'm not actually reviewing this patch - I don't know much about the
modules
code, but just providing a bit of context and first-pass-review)

Got it. Thanks!
--Vassil



On 30/01/16 17:37, David Blaikie wrote:

Yeah, it's good to have a reproduction, but I wouldn't actually commit
one
- unless you have a checked stl to test against that always fails on
possibly-invalidating sequences of operations, then you'd have a fairly
simple reproduction

On Jan 30, 2016 8:23 AM, "Vassil Vassilev" 
wrote:

Sorry.

Our module builds choke on merging several modules, containing
declarations from STL (we are using libc++, no modulemaps).

When writing a new module containing the definition of a STL
reverse_iterator, it collects all its template specializations. Some of
the
specializations need to be deserialized from a third module. This
triggers
an iterator invalidation bug because of the deserialization happening
when
iterating the specializations container itself. This happens only when
the
container's capacity is exceeded and the relocation invalidates the
iterators and at best causes a crash (see valgrind reports in the bug
report). Unfortunately I haven't been able to make the reproducer
independent on STL.

--Vassil

On 30/01/16 17:08, David Blaikie wrote:

It might be handy to give an overview of the issue in the review (&
certainly in the commit) message rather than only citing the bug number

On Jan 30, 2016 6:49 AM, "Vassil Vassilev via cfe-commits"
 wrote:

Attaching a fix to https://llvm.org/bugs/show_bug.cgi?id=26237

Please review.

Many thanks!
--Vassil

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





From 22c67c14843f119f0cdb64c3fa0ab3ef272f7b5f Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Sat, 30 Jan 2016 14:50:06 +0100
Subject: [PATCH] Writing out template specializations might trigger
 deserialization.

Rebuilding a redecl chain of template (partial) specializa

Re: [PATCH] Canonicalize UnaryTransformType types when they don't have a known underlying type

2016-02-24 Thread Vassil Vassilev via cfe-commits

ping...
On 07/01/16 08:09, Vassil Vassilev via cfe-commits wrote:

Hi all,
  I am attaching a fix for https://llvm.org/bugs/show_bug.cgi?id=26014
  To which type should I tie the canonical type of the unknown 
underlying type? Currently it is tied to its BaseType.


  Please review.
--Vassil


___
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] D17313: [CUDA] Annotate all calls in CUDA device mode as convergent.

2016-02-24 Thread Justin Lebar via cfe-commits
jlebar abandoned this revision.
jlebar added a comment.

Subsumed by http://reviews.llvm.org/D17056.


http://reviews.llvm.org/D17313



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


r261781 - PR26237: Fix iterator invalidation bug that occurs if serializing

2016-02-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Feb 24 15:59:10 2016
New Revision: 261781

URL: http://llvm.org/viewvc/llvm-project?rev=261781&view=rev
Log:
PR26237: Fix iterator invalidation bug that occurs if serializing
specializations of a template manages to trigger deserialization of more
specializations of the same template.

No test case provided: this is hard to reliably test due to standard library
differences.

Patch by Vassil Vassilev!

Modified:
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=261781&r1=261780&r2=261781&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Wed Feb 24 15:59:10 2016
@@ -192,8 +192,8 @@ namespace clang {
   return None;
 }
 
-template
-void AddTemplateSpecializations(Decl *D) {
+template
+void AddTemplateSpecializations(DeclTy *D) {
   auto *Common = D->getCommonPtr();
 
   // If we have any lazy specializations, and the external AST source is
@@ -205,8 +205,6 @@ namespace clang {
 assert(!Common->LazySpecializations);
   }
 
-  auto &Specializations = Common->Specializations;
-  auto &&PartialSpecializations = getPartialSpecializations(Common);
   ArrayRef LazySpecializations;
   if (auto *LS = Common->LazySpecializations)
 LazySpecializations = llvm::makeArrayRef(LS + 1, LS[0]);
@@ -215,13 +213,15 @@ namespace clang {
   unsigned I = Record.size();
   Record.push_back(0);
 
-  for (auto &Entry : Specializations) {
-auto *D = getSpecializationDecl(Entry);
-assert(D->isCanonicalDecl() && "non-canonical decl in set");
-AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
-  }
-  for (auto &Entry : PartialSpecializations) {
-auto *D = getSpecializationDecl(Entry);
+  // AddFirstDeclFromEachModule might trigger deserialization, invalidating
+  // *Specializations iterators.
+  llvm::SmallVector Specs;
+  for (auto &Entry : Common->Specializations)
+Specs.push_back(getSpecializationDecl(Entry));
+  for (auto &Entry : getPartialSpecializations(Common))
+Specs.push_back(getSpecializationDecl(Entry));
+
+  for (auto *D : Specs) {
 assert(D->isCanonicalDecl() && "non-canonical decl in set");
 AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
   }


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


Re: [PATCH][modules][PR26237]

2016-02-24 Thread Richard Smith via cfe-commits
On Wed, Feb 24, 2016 at 2:01 PM, Vassil Vassilev  wrote:
> On 24/02/16 22:50, Richard Smith wrote:
>>
>> On Wed, Feb 24, 2016 at 8:10 AM, Vassil Vassilev 
>> wrote:
>>>
>>> On 24/02/16 02:05, Richard Smith wrote:

 Calling getMostRecentDecl seems like a slightly fragile way to avoid
 iterator invalidation here. Instead...

 @@ -214,6 +212,19 @@ namespace clang {
  unsigned I = Record.size();
  Record.push_back(0);

 +  auto &Specializations = Common->Specializations;
 +  auto &&PartialSpecializations =
 getPartialSpecializations(Common);
 +
 +  // AddFirstDeclFromEachModule might trigger deserialization,
 invalidating
 +  // *Specializations iterators. Force the deserialization in
 advance.
 +  llvm::SmallVector Specs;
 +  for (auto &Entry : Specializations)
 + Specs.push_back(getSpecializationDecl(Entry));
 +  for (auto &Entry : PartialSpecializations)
 + Specs.push_back(getSpecializationDecl(Entry));
 +  for (auto *D : Specs)
 + D->getMostRecentDecl();

 ... delete these two lines, and...

 +
  for (auto &Entry : Specializations) {

 ... iterate over "Specs" here

auto *D = getSpecializationDecl(Entry);

 ... and you don't need this line any more.

assert(D->isCanonicalDecl() && "non-canonical decl in set");

 You can then remove the following, identical, PartialSpecializations
 loop.
>>>
>>> Done.
>>
>> +  // *Specializations iterators. Force the deserialization in
>> advance.
>>
>> Drop the second sentence of this comment, since it's no longer accurate.
>
> oops... thanks!
>>
>>
 You also have some tabs in your patch (on the Specs.push_back lines);
>>>
>>> Sorry about the tabs, they came from a brand new VM and unconfigured
>>> emacs.

 please fix those prior to commit. With those changes, this LGTM.
>>>
>>> Would it make sense to ask for commit perms?
>>
>> Yes, please see the instructions here:
>> http://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access
>
> Will do. Could you check this patch in meanwhile, please?

r261781. Thanks!

 On Mon, Feb 22, 2016 at 7:11 AM, Vassil Vassilev
 
 wrote:
>
> ping...
>
> On 30/01/16 21:13, Vassil Vassilev wrote:
>
> On 30/01/16 18:36, David Blaikie wrote:
>
>
>
> On Sat, Jan 30, 2016 at 9:00 AM, Vassil Vassilev
> 
> wrote:
>>
>> AFAICT the making a test case independent on STL is the hard part. I
>> think
>> it will be always failing due to the relocation of the memory region
>> of
>> the
>> underlying SmallVector.
>
>
> Sorry, I think I didn't explain myself well. What I mean is - due to
> the
> instability of test cases for UB (especially library UB), we don't
> usually
> commit test cases for them - we just fix them without tests. About the
> only
> time I think committing a test is helpful for UB (especially library
> UB)
> is
> if we have a reliable way to test/catch the UB (eg: the sanitizers or a
> checking STL that fails fast on validation violations). So, while it
> would
> be good to provide/demonstrate your test case, I would not commit the
> test
> case unless it's a minimal reproduction in the presence of one of those
> tools (sanitizers or checking STL) - and would just commit the fix
> without a
> test case, usually.
>
> (I'm not actually reviewing this patch - I don't know much about the
> modules
> code, but just providing a bit of context and first-pass-review)
>
> Got it. Thanks!
> --Vassil
>
>
>> On 30/01/16 17:37, David Blaikie wrote:
>>
>> Yeah, it's good to have a reproduction, but I wouldn't actually commit
>> one
>> - unless you have a checked stl to test against that always fails on
>> possibly-invalidating sequences of operations, then you'd have a
>> fairly
>> simple reproduction
>>
>> On Jan 30, 2016 8:23 AM, "Vassil Vassilev" 
>> wrote:
>>>
>>> Sorry.
>>>
>>> Our module builds choke on merging several modules, containing
>>> declarations from STL (we are using libc++, no modulemaps).
>>>
>>> When writing a new module containing the definition of a STL
>>> reverse_iterator, it collects all its template specializations. Some
>>> of
>>> the
>>> specializations need to be deserialized from a third module. This
>>> triggers
>>> an iterator invalidation bug because of the deserialization happening
>>> when
>>> iterating the specializations container itself. This happens only
>>> when
>>> the
>>> container's capacity is exceeded and the relocation invalidates the
>>> iterators and at best causes a crash (see valgrind reports in the bug
>>> report). Unfortunate

Re: [PATCH][modules][PR26237]

2016-02-24 Thread Vassil Vassilev via cfe-commits

On 24/02/16 23:03, Richard Smith wrote:

On Wed, Feb 24, 2016 at 2:01 PM, Vassil Vassilev  wrote:

On 24/02/16 22:50, Richard Smith wrote:

On Wed, Feb 24, 2016 at 8:10 AM, Vassil Vassilev 
wrote:

On 24/02/16 02:05, Richard Smith wrote:

Calling getMostRecentDecl seems like a slightly fragile way to avoid
iterator invalidation here. Instead...

@@ -214,6 +212,19 @@ namespace clang {
  unsigned I = Record.size();
  Record.push_back(0);

+  auto &Specializations = Common->Specializations;
+  auto &&PartialSpecializations =
getPartialSpecializations(Common);
+
+  // AddFirstDeclFromEachModule might trigger deserialization,
invalidating
+  // *Specializations iterators. Force the deserialization in
advance.
+  llvm::SmallVector Specs;
+  for (auto &Entry : Specializations)
+ Specs.push_back(getSpecializationDecl(Entry));
+  for (auto &Entry : PartialSpecializations)
+ Specs.push_back(getSpecializationDecl(Entry));
+  for (auto *D : Specs)
+ D->getMostRecentDecl();

... delete these two lines, and...

+
  for (auto &Entry : Specializations) {

... iterate over "Specs" here

auto *D = getSpecializationDecl(Entry);

... and you don't need this line any more.

assert(D->isCanonicalDecl() && "non-canonical decl in set");

You can then remove the following, identical, PartialSpecializations
loop.

Done.

+  // *Specializations iterators. Force the deserialization in
advance.

Drop the second sentence of this comment, since it's no longer accurate.

oops... thanks!



You also have some tabs in your patch (on the Specs.push_back lines);

Sorry about the tabs, they came from a brand new VM and unconfigured
emacs.

please fix those prior to commit. With those changes, this LGTM.

Would it make sense to ask for commit perms?

Yes, please see the instructions here:
http://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

Will do. Could you check this patch in meanwhile, please?

r261781. Thanks!

Thanks a lot!



On Mon, Feb 22, 2016 at 7:11 AM, Vassil Vassilev

wrote:

ping...

On 30/01/16 21:13, Vassil Vassilev wrote:

On 30/01/16 18:36, David Blaikie wrote:



On Sat, Jan 30, 2016 at 9:00 AM, Vassil Vassilev

wrote:

AFAICT the making a test case independent on STL is the hard part. I
think
it will be always failing due to the relocation of the memory region
of
the
underlying SmallVector.


Sorry, I think I didn't explain myself well. What I mean is - due to
the
instability of test cases for UB (especially library UB), we don't
usually
commit test cases for them - we just fix them without tests. About the
only
time I think committing a test is helpful for UB (especially library
UB)
is
if we have a reliable way to test/catch the UB (eg: the sanitizers or a
checking STL that fails fast on validation violations). So, while it
would
be good to provide/demonstrate your test case, I would not commit the
test
case unless it's a minimal reproduction in the presence of one of those
tools (sanitizers or checking STL) - and would just commit the fix
without a
test case, usually.

(I'm not actually reviewing this patch - I don't know much about the
modules
code, but just providing a bit of context and first-pass-review)

Got it. Thanks!
--Vassil



On 30/01/16 17:37, David Blaikie wrote:

Yeah, it's good to have a reproduction, but I wouldn't actually commit
one
- unless you have a checked stl to test against that always fails on
possibly-invalidating sequences of operations, then you'd have a
fairly
simple reproduction

On Jan 30, 2016 8:23 AM, "Vassil Vassilev" 
wrote:

Sorry.

Our module builds choke on merging several modules, containing
declarations from STL (we are using libc++, no modulemaps).

When writing a new module containing the definition of a STL
reverse_iterator, it collects all its template specializations. Some
of
the
specializations need to be deserialized from a third module. This
triggers
an iterator invalidation bug because of the deserialization happening
when
iterating the specializations container itself. This happens only
when
the
container's capacity is exceeded and the relocation invalidates the
iterators and at best causes a crash (see valgrind reports in the bug
report). Unfortunately I haven't been able to make the reproducer
independent on STL.

--Vassil

On 30/01/16 17:08, David Blaikie wrote:

It might be handy to give an overview of the issue in the review (&
certainly in the commit) message rather than only citing the bug
number

On Jan 30, 2016 6:49 AM, "Vassil Vassilev via cfe-commits"
 wrote:

Attaching a fix to https://llvm.org/bugs/show_bug.cgi?id=26237

Please review.

Many thanks!
--Vassil

___
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/list

Re: r261780 - Don't convert a char to a const char *

2016-02-24 Thread Benjamin Kramer via cfe-commits
Were you able to reproduce this build failure? ltrim has overloads for
"char" and "StringRef", the former being very new. From the error
message I suspect out of sync LLVM and Clang checkouts.

On Wed, Feb 24, 2016 at 10:55 PM, David Majnemer via cfe-commits
 wrote:
> Author: majnemer
> Date: Wed Feb 24 15:55:58 2016
> New Revision: 261780
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261780&view=rev
> Log:
> Don't convert a char to a const char *
>
> This fixes PR26728.
>
> Modified:
> cfe/trunk/lib/Lex/PPDirectives.cpp
>
> Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=261780&r1=261779&r2=261780&view=diff
> ==
> --- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
> +++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Feb 24 15:55:58 2016
> @@ -1226,7 +1226,7 @@ void Preprocessor::HandleUserDiagnosticD
>
>// Find the first non-whitespace character, so that we can make the
>// diagnostic more succinct.
> -  StringRef Msg = StringRef(Message).ltrim(' ');
> +  StringRef Msg = StringRef(Message).ltrim(" ");
>
>if (isWarning)
>  Diag(Tok, diag::pp_hash_warning) << Msg;
>
>
> ___
> 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


r261782 - Fix build by using hasFlag instead of hasArg.

2016-02-24 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Wed Feb 24 16:03:06 2016
New Revision: 261782

URL: http://llvm.org/viewvc/llvm-project?rev=261782&view=rev
Log:
Fix build by using hasFlag instead of hasArg.

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

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=261782&r1=261781&r2=261782&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Feb 24 16:03:06 2016
@@ -4270,8 +4270,8 @@ void Clang::ConstructJob(Compilation &C,
 CmdArgs.push_back("-ffunction-sections");
   }
 
-  if (Args.hasArg(options::OPT_fwhole_program_vtables,
-  options::OPT_fno_whole_program_vtables, false)) {
+  if (Args.hasFlag(options::OPT_fwhole_program_vtables,
+   options::OPT_fno_whole_program_vtables, false)) {
 if (!D.isUsingLTO())
   D.Diag(diag::err_drv_argument_only_allowed_with)
   << "-fwhole-program-vtables"


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


Re: [PATCH] Canonicalize UnaryTransformType types when they don't have a known underlying type

2016-02-24 Thread Richard Smith via cfe-commits
A UnaryTransformType should itself be a canonical type if its BaseType
is dependent -- that is, its CanonicalType should be QualType(this,
0). It should definitely not be treated as being canonically
equivalent to its BaseType.

On Wed, Feb 24, 2016 at 2:03 PM, Vassil Vassilev  wrote:
> ping...
>
> On 07/01/16 08:09, Vassil Vassilev via cfe-commits wrote:
>
> Hi all,
>   I am attaching a fix for https://llvm.org/bugs/show_bug.cgi?id=26014
>   To which type should I tie the canonical type of the unknown underlying
> type? Currently it is tied to its BaseType.
>
>   Please review.
> --Vassil
>
>
> ___
> 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: r261780 - Don't convert a char to a const char *

2016-02-24 Thread David Majnemer via cfe-commits
Ah, good point.  I assumed that the report was valid because they aren't
showing up in the doxygen:
http://llvm.org/docs/doxygen/html/classllvm_1_1StringRef.html

I'll go ahead and revert.

On Wed, Feb 24, 2016 at 2:06 PM, Benjamin Kramer 
wrote:

> Were you able to reproduce this build failure? ltrim has overloads for
> "char" and "StringRef", the former being very new. From the error
> message I suspect out of sync LLVM and Clang checkouts.
>
> On Wed, Feb 24, 2016 at 10:55 PM, David Majnemer via cfe-commits
>  wrote:
> > Author: majnemer
> > Date: Wed Feb 24 15:55:58 2016
> > New Revision: 261780
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=261780&view=rev
> > Log:
> > Don't convert a char to a const char *
> >
> > This fixes PR26728.
> >
> > Modified:
> > cfe/trunk/lib/Lex/PPDirectives.cpp
> >
> > Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=261780&r1=261779&r2=261780&view=diff
> >
> ==
> > --- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
> > +++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Feb 24 15:55:58 2016
> > @@ -1226,7 +1226,7 @@ void Preprocessor::HandleUserDiagnosticD
> >
> >// Find the first non-whitespace character, so that we can make the
> >// diagnostic more succinct.
> > -  StringRef Msg = StringRef(Message).ltrim(' ');
> > +  StringRef Msg = StringRef(Message).ltrim(" ");
> >
> >if (isWarning)
> >  Diag(Tok, diag::pp_hash_warning) << Msg;
> >
> >
> > ___
> > 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


r261784 - Revert "Don't convert a char to a const char *"

2016-02-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Feb 24 16:07:26 2016
New Revision: 261784

URL: http://llvm.org/viewvc/llvm-project?rev=261784&view=rev
Log:
Revert "Don't convert a char to a const char *"

This reverts commit r261780.  It turns out the original code was just
fine.  An overload for ltrim which takes char was added but the Doxygen
docs haven't seemed to pick it up.

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

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=261784&r1=261783&r2=261784&view=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Feb 24 16:07:26 2016
@@ -1226,7 +1226,7 @@ void Preprocessor::HandleUserDiagnosticD
 
   // Find the first non-whitespace character, so that we can make the
   // diagnostic more succinct.
-  StringRef Msg = StringRef(Message).ltrim(" ");
+  StringRef Msg = StringRef(Message).ltrim(' ');
 
   if (isWarning)
 Diag(Tok, diag::pp_hash_warning) << Msg;


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


r261798 - Minor cleanup of Sema::CheckEnableIf. NFC.

2016-02-24 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Feb 24 16:31:14 2016
New Revision: 261798

URL: http://llvm.org/viewvc/llvm-project?rev=261798&view=rev
Log:
Minor cleanup of Sema::CheckEnableIf. NFC.

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

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=261798&r1=261797&r2=261798&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Feb 24 16:31:14 2016
@@ -5958,34 +5958,27 @@ EnableIfAttr *Sema::CheckEnableIf(Functi
   bool ContainsValueDependentExpr = false;
 
   // Convert the arguments.
-  for (unsigned i = 0, e = Args.size(); i != e; ++i) {
-if (i == 0 && !MissingImplicitThis && isa(Function) &&
+  for (unsigned I = 0, E = Args.size(); I != E; ++I) {
+ExprResult R;
+if (I == 0 && !MissingImplicitThis && isa(Function) &&
 !cast(Function)->isStatic() &&
 !isa(Function)) {
   CXXMethodDecl *Method = cast(Function);
-  ExprResult R =
-PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/nullptr,
-Method, Method);
-  if (R.isInvalid()) {
-InitializationFailed = true;
-break;
-  }
-  ContainsValueDependentExpr |= R.get()->isValueDependent();
-  ConvertedArgs.push_back(R.get());
+  R = PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/nullptr,
+  Method, Method);
 } else {
-  ExprResult R =
-PerformCopyInitialization(InitializedEntity::InitializeParameter(
-Context,
-Function->getParamDecl(i)),
-  SourceLocation(),
-  Args[i]);
-  if (R.isInvalid()) {
-InitializationFailed = true;
-break;
-  }
-  ContainsValueDependentExpr |= R.get()->isValueDependent();
-  ConvertedArgs.push_back(R.get());
+  R = PerformCopyInitialization(InitializedEntity::InitializeParameter(
+Context, Function->getParamDecl(I)),
+SourceLocation(), Args[I]);
 }
+
+if (R.isInvalid()) {
+  InitializationFailed = true;
+  break;
+}
+
+ContainsValueDependentExpr |= R.get()->isValueDependent();
+ConvertedArgs.push_back(R.get());
   }
 
   if (InitializationFailed || Trap.hasErrorOccurred())


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


Re: [PATCH] D17576: Fix assertion failure on MaybeODRUseExprs.

2016-02-24 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261803: Fix assertion failure on MaybeODRUseExprs. (authored 
by mren).

Changed prior to commit:
  http://reviews.llvm.org/D17576?vs=48963&id=48986#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17576

Files:
  cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
  cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp

Index: cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
+++ cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -75,3 +75,13 @@
 g();
   }
 }
+
+// rdar://problem/24480205
+namespace PR13986 {
+  constexpr unsigned Dynamic = 0;
+  template  class A { template  void m_fn1(); };
+  class Test {
+~Test() {}
+A<1> m_target;
+  };
+}
Index: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2110,6 +2110,8 @@
 Param->setInvalidDecl();
 
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
+EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+   
Sema::ConstantEvaluated);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), 
TemplateArgs);
 if (!Value.isInvalid())
   Param->setDefaultArgument(Value.get());


Index: cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
+++ cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -75,3 +75,13 @@
 g();
   }
 }
+
+// rdar://problem/24480205
+namespace PR13986 {
+  constexpr unsigned Dynamic = 0;
+  template  class A { template  void m_fn1(); };
+  class Test {
+~Test() {}
+A<1> m_target;
+  };
+}
Index: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2110,6 +2110,8 @@
 Param->setInvalidDecl();
 
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
+EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+   Sema::ConstantEvaluated);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), TemplateArgs);
 if (!Value.isInvalid())
   Param->setDefaultArgument(Value.get());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261803 - Fix assertion failure on MaybeODRUseExprs.

2016-02-24 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Feb 24 17:05:43 2016
New Revision: 261803

URL: http://llvm.org/viewvc/llvm-project?rev=261803&view=rev
Log:
Fix assertion failure on MaybeODRUseExprs.

In VisitNonTypeTemplateParamDecl, before SubstExpr with the default argument,
we should create a ConstantEvaluated ExpressionEvaluationContext. Without this,
it is possible to use a PotentiallyEvaluated ExpressionEvaluationContext; and
MaybeODRUseExprs will not be cleared when popping the context, causing
assertion failure.

This is similar to how we handle the context before SubstExpr with the
default argument, in SubstDefaultTemplateArgument.

Part of PR13986.
rdar://24480205

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

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=261803&r1=261802&r2=261803&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Feb 24 17:05:43 2016
@@ -2110,6 +2110,8 @@ Decl *TemplateDeclInstantiator::VisitNon
 Param->setInvalidDecl();
 
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
+EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+   
Sema::ConstantEvaluated);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), 
TemplateArgs);
 if (!Value.isInvalid())
   Param->setDefaultArgument(Value.get());

Modified: cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp?rev=261803&r1=261802&r2=261803&view=diff
==
--- cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp Wed Feb 24 17:05:43 
2016
@@ -75,3 +75,13 @@ namespace rdar23810407 {
 g();
   }
 }
+
+// rdar://problem/24480205
+namespace PR13986 {
+  constexpr unsigned Dynamic = 0;
+  template  class A { template  void m_fn1(); };
+  class Test {
+~Test() {}
+A<1> m_target;
+  };
+}


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


Re: [clang-tools-extra] r261738 - [clang-tidy] introduce modernize-deprecated-headers check

2016-02-24 Thread Alexander Kornienko via cfe-commits
I have a couple ideas, will try on the buildbot, since I don't have MSVC to
try fixes locally.

On Wed, Feb 24, 2016 at 10:27 PM, Alexander Kornienko 
wrote:

> Looking into this...
>
>
> On Wed, Feb 24, 2016 at 10:21 PM, Nico Weber  wrote:
>
>> This broke the Windows bot:
>> http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10093/steps/build%20stage%201/logs/stdio
>>
>> FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP /DWIN32
>> /D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291
>> -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624
>> -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702
>> -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204
>> -wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /Zc:inline /Oi
>> /Zc:rvalueCast /MD /O2 /Ob2 -Itools\clang\tools\extra\clang-tidy\modernize
>> -ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize
>> -ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\include
>> -Itools\clang\include -Iinclude
>> -ID:\buildslave\clang-x64-ninja-win7\llvm\include-UNDEBUG  /EHs-c- /GR-
>> /showIncludes -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER
>> -DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0
>> -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
>> -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
>> -D_DEBUG_POINTER_IMPL="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
>> -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
>> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
>> /Fotools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\DeprecatedHeadersCheck.cpp.obj
>> /Fdtools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\
>> /FS -c
>> D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp
>> D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp(72)
>> : error C2668:
>> 'llvm::StringMap::StringMap' : ambiguous
>> call to overloaded function
>>
>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(399):
>> could be
>> 'llvm::StringMap::StringMap(const
>> llvm::StringMap &)'
>>
>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(242):
>> or
>> 'llvm::StringMap::StringMap(llvm::StringMap
>> &&)'
>>
>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(235):
>> or
>> 'llvm::StringMap::StringMap(std::initializer_list>)'
>> with
>> [
>> ValueTy=std::string
>> ]
>>
>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(228):
>> or
>> 'llvm::StringMap::StringMap(AllocatorTy)'
>> with
>> [
>> AllocatorTy=llvm::MallocAllocator
>> ]
>>
>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(225):
>> or
>> 'llvm::StringMap::StringMap(unsigned
>> int)'
>> while trying to match the argument list '(initializer-list)'
>>Creating library lib\libclang.lib and object lib\libclang.exp
>>
>>
>> On Wed, Feb 24, 2016 at 8:36 AM, Alexander Kornienko via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: alexfh
>>> Date: Wed Feb 24 07:36:34 2016
>>> New Revision: 261738
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=261738&view=rev
>>> Log:
>>> [clang-tidy] introduce modernize-deprecated-headers check
>>>
>>> Summary:
>>> This patch introduces the modernize-deprecated-headers check, which is
>>> supposed to replace deprecated C library headers with the C++ STL-ones.
>>>
>>> For information see documentation; for exmaples see the test cases.
>>>
>>> Reviewers: Eugene.Zelenko, LegalizeAdulthood, alexfh
>>>
>>> Subscribers: cfe-commits
>>>
>>> Patch by Kirill Bobyrev!
>>>
>>> Differential Revision: http://reviews.llvm.org/D17484
>>>
>>> Added:
>>>
>>> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
>>> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
>>>
>>> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst
>>>
>>> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
>>>
>>> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
>>> Modified:
>>> clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>>> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
>>> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>>>
>>> Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=261738&r1=261737&r2=261738&view=diff
>>>
>>> ==
>>> --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>>> (original)

[clang-tools-extra] r261806 - Trying to fix MSVC build

2016-02-24 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Feb 24 17:48:24 2016
New Revision: 261806

URL: http://llvm.org/viewvc/llvm-project?rev=261806&view=rev
Log:
Trying to fix MSVC build

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp?rev=261806&r1=261805&r2=261806&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp Wed 
Feb 24 17:48:24 2016
@@ -49,36 +49,27 @@ void DeprecatedHeadersCheck::registerPPC
 IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(ClangTidyCheck &Check,
  LangOptions LangOpts)
 : Check(Check), LangOpts(LangOpts),
-  CStyledHeaderToCxx({{"assert.h", "cassert"},
-  {"complex.h", "ccomplex"},
-  {"ctype.h", "cctype"},
-  {"errno.h", "cerrno"},
-  {"float.h", "cfloat"},
-  {"inttypes.h", "cinttypes"},
-  {"iso646.h", "ciso646"},
-  {"limits.h", "climits"},
-  {"locale.h", "clocale"},
-  {"math.h", "cmath"},
-  {"setjmp.h", "csetjmp"},
-  {"signal.h", "csignal"},
-  {"stdarg.h", "cstdarg"},
-  {"stddef.h", "cstddef"},
-  {"stdint.h", "cstdint"},
-  {"stdio.h", "cstdio"},
-  {"stdlib.h", "cstdlib"},
-  {"string.h", "cstring"},
-  {"time.h", "ctime"},
-  {"wchar.h", "cwchar"},
-  {"wctype.h", "cwctype"}}) {
+  CStyledHeaderToCxx{{"assert.h", "cassert"}, {"complex.h", "ccomplex"},
+ {"ctype.h", "cctype"},   {"errno.h", "cerrno"},
+ {"float.h", "cfloat"},   {"inttypes.h", "cinttypes"},
+ {"iso646.h", "ciso646"}, {"limits.h", "climits"},
+ {"locale.h", "clocale"}, {"math.h", "cmath"},
+ {"setjmp.h", "csetjmp"}, {"signal.h", "csignal"},
+ {"stdarg.h", "cstdarg"}, {"stddef.h", "cstddef"},
+ {"stdint.h", "cstdint"}, {"stdio.h", "cstdio"},
+ {"stdlib.h", "cstdlib"}, {"string.h", "cstring"},
+ {"time.h", "ctime"}, {"wchar.h", "cwchar"},
+ {"wctype.h", "cwctype"}} {
   // Add C++ 11 headers.
   if (LangOpts.CPlusPlus11) {
-for (const auto &it : std::vector>(
+for (const auto &KeyValue :
+ std::vector>(
  {{"fenv.h", "cfenv"},
   {"stdalign.h", "cstdalign"},
   {"stdbool.h", "cstdbool"},
   {"tgmath.h", "ctgmath"},
   {"uchar.h", "cuchar"}})) {
-  CStyledHeaderToCxx.insert(it);
+  CStyledHeaderToCxx.insert(KeyValue);
 }
   }
 }


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


  1   2   >