Re: [PATCH] D9600: Add scan-build python implementation

2015-12-13 Thread Kim Gräsman via cfe-commits
kimgr added a subscriber: kimgr.
kimgr added a comment.

> 

>  Comment at: tools/scan-build-py/bin/analyze-cc:14

>  @@ +13,2 @@

>  +from libscanbuild.analyze import wrapper

>  +sys.exit(wrapper(False))

> 

>  

> 

> It is hard to figure out/search which functions actually get called from the 
> top level tools. Could you rename all of the public functions so that they

>  have unique names? For example, "wrapper" -> "scan_build_wrapper". This 
> would greatly improve searchability!


A nice pattern in Python is to avoid importing individual
functions/classes, and instead use the module name as a namespace,
e.g.

  from libscanbuild import analyze
  sys.exit(analyze.wrapper(False))

I don't know if that addresses your concern? I haven't looked at the
code in more detail.

- Kim


http://reviews.llvm.org/D9600



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


Re: [PATCH] D13001: [libclang] Handle AutoType in clang_getTypeDeclaration

2015-12-13 Thread Sergey Kalinichev via cfe-commits
skalinichev updated the summary for this revision.
skalinichev updated this revision to Diff 42654.
skalinichev added a comment.

Added tests


http://reviews.llvm.org/D13001

Files:
  test/Index/print-type-declaration.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -412,6 +412,12 @@
  .getAsTemplateDecl();
 break;
 
+  case Type::Auto:
+TP = cast(TP)->getDeducedType().getTypePtrOrNull();
+if (TP)
+  goto try_again;
+break;
+
   case Type::InjectedClassName:
 D = cast(TP)->getDecl();
 break;
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1506,6 +1506,22 @@
 }
 
 
/**/
+/* Type declaration testing   
*/
+/**/
+
+static enum CXChildVisitResult PrintTypeDeclaration(CXCursor cursor, CXCursor 
p,
+ CXClientData d) {
+  CXCursor typeDeclaration = 
clang_getTypeDeclaration(clang_getCursorType(cursor));
+
+  if (clang_isDeclaration(typeDeclaration.kind)) {
+PrintCursor(cursor, NULL);
+PrintTypeAndTypeKind(clang_getCursorType(typeDeclaration), " 
[typedeclaration=%s] [typekind=%s]\n");
+  }
+
+  return CXChildVisit_Recurse;
+}
+
+/**/
 /* Loading ASTs/source.   
*/
 
/**/
 
@@ -4114,6 +4130,7 @@
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
+"   c-index-test -test-print-type-declaration {}*\n"
 "   c-index-test -print-usr [ {}]*\n"
 "   c-index-test -print-usr-file \n"
 "   c-index-test -write-pch  \n");
@@ -4207,6 +4224,9 @@
   else if (argc > 2 && strcmp(argv[1], "-test-print-type-size") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintTypeSize, 0);
+  else if (argc > 2 && strcmp(argv[1], "-test-print-type-declaration") == 0)
+return perform_test_load_source(argc - 2, argv + 2, "all",
+PrintTypeDeclaration, 0);
   else if (argc > 2 && strcmp(argv[1], "-test-print-bitwidth") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintBitWidth, 0);
Index: test/Index/print-type-declaration.cpp
===
--- /dev/null
+++ test/Index/print-type-declaration.cpp
@@ -0,0 +1,12 @@
+
+class Test{};
+
+int main()
+{
+  auto a = Test();
+  auto b = a;
+}
+
+// RUN: c-index-test -test-print-type-declaration -std=c++11 %s | FileCheck %s
+// CHECK: VarDecl=a:6:8 (Definition) [typedeclaration=Test] [typekind=Record]
+// CHECK: VarDecl=b:7:8 (Definition) [typedeclaration=Test] [typekind=Record]


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -412,6 +412,12 @@
  .getAsTemplateDecl();
 break;
 
+  case Type::Auto:
+TP = cast(TP)->getDeducedType().getTypePtrOrNull();
+if (TP)
+  goto try_again;
+break;
+
   case Type::InjectedClassName:
 D = cast(TP)->getDecl();
 break;
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1506,6 +1506,22 @@
 }
 
 /**/
+/* Type declaration testing   */
+/**/
+
+static enum CXChildVisitResult PrintTypeDeclaration(CXCursor cursor, CXCursor p,
+ CXClientData d) {
+  CXCursor typeDeclaration = clang_getTypeDeclaration(clang_getCursorType(cursor));
+
+  if (clang_isDeclaration(typeDeclaration.kind)) {
+PrintCursor(cursor, NULL);
+PrintTypeAndTypeKind(clang_getCursorType(typeDeclaration), " [typedeclaration=%s] [typekind=%s]\n");
+  }
+
+  return CXChildVisit_Recurse;
+}
+
+/**/
 /* Loading ASTs/source.  

Re: [PATCH] D14329: Show inclusions from a preamble in clang_getInclusions.

2015-12-13 Thread Sergey Kalinichev via cfe-commits
skalinichev added a subscriber: skalinichev.
skalinichev added a comment.

I've seen this bug too. Generally this patch looks good to me.

Could you also add a test for includes half-way through a file case?



Comment at: tools/c-index-test/c-index-test.c:1567
@@ -1564,1 +1566,3 @@
 
+  if (getenv("CINDEXTEST_EDITING"))
+Repeats = 5;

This is not a very good idea to add this code here IMO. There are probably some 
tests that use this function with CINDEXTEST_EDITING set, which could  
potentially hide some parsing vs. reparsing bugs. I'd suggest to use something 
like perform_test_reparse_source instead.


http://reviews.llvm.org/D14329



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


[PATCH]: Allow the use of i386/darwin with ELF

2015-12-13 Thread Luboš Doležel via cfe-commits
Hello,

I'm the developer of Darling, a translation layer for running OS X
binaries on Linux.

I'm facing many difficulties due to the following differences in i386
ABI between Darwin and Linux:

* size_t on Darwin/i386 is 'unsigned long', but Linux/i386 uses
'unsigned int' (=> different mangled names).
* long double on Darwin/i386 is 128 bits long, but Linux/i386 uses only
96 bits.

This problem can be overcome by specifying '-target
i386-unknown-darwin-elf', but this currently fails due to a different
data layout string (Darwin specifies Mach-O).

The attached patch allows the use of ELF with the DarwinI386 target. It
is identical to what is already done in the WindowsX86_32 target.

Pretty please, include my patch, as it would be very helpful and it's a
rather small change.

Thanks,
-- 
Luboš Doležel
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp	(revision 255459)
+++ lib/Basic/Targets.cpp	(working copy)
@@ -3730,7 +3730,12 @@
   UseSignedCharForObjCBool = false;
 SizeType = UnsignedLong;
 IntPtrType = SignedLong;
-DataLayoutString = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128";
+
+bool IsMachO =
+getTriple().isOSDarwin() && getTriple().isOSBinFormatMachO();
+DescriptionString = IsMachO
+? "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
+: "e-m:e-p:32:32-f64:32:64-f80:128-n8:16:32-S128";
 HasAlignMac68kSupport = true;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15030: [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index

2015-12-13 Thread Matthias Gehre via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255470: [clang-tidy] add check 
cppcoreguidelines-pro-bounds-constant-array-index (authored by mgehre).

Changed prior to commit:
  http://reviews.llvm.org/D15030?vs=42338&id=42671#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15030

Files:
  clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
  
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-gslheader.cpp
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
@@ -0,0 +1,76 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-bounds-constant-array-index %t
+
+typedef unsigned int size_t;
+
+namespace std {
+  template
+  struct array {
+T& operator[](size_t n);
+T& at(size_t n);
+  };
+}
+
+
+namespace gsl {
+  template
+  T& at( T(&a)[N], size_t index );
+
+  template
+  T& at( std::array &a, size_t index );
+}
+
+constexpr int const_index(int base) {
+  return base + 3;
+}
+
+void f(std::array a, int pos) {
+  a [ pos / 2 /*comment*/] = 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
+  int j = a[pos - 1];
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead
+
+  a.at(pos-1) = 2; // OK, at() instead of []
+  gsl::at(a, pos-1) = 2; // OK, gsl::at() instead of []
+
+  a[-1] = 3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: std::array<> index -1 is negative [cppcoreguidelines-pro-bounds-constant-array-index]
+  a[10] = 4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: std::array<> index 10 is past the end of the array (which contains 10 elements) [cppcoreguidelines-pro-bounds-constant-array-index]
+
+  a[const_index(7)] = 3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: std::array<> index 10 is past the end of the array (which contains 10 elements)
+
+  a[0] = 3; // OK, constant index and inside bounds
+  a[1] = 3; // OK, constant index and inside bounds
+  a[9] = 3; // OK, constant index and inside bounds
+  a[const_index(6)] = 3; // OK, constant index and inside bounds
+}
+
+void g() {
+  int a[10];
+  for (int i = 0; i < 10; ++i) {
+a[i] = i;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead
+// CHECK-FIXES: gsl::at(a, i) = i;
+gsl::at(a, i) = i; // OK, gsl::at() instead of []
+  }
+
+  a[-1] = 3; // flagged by clang-diagnostic-array-bounds
+  a[10] = 4; // flagged by clang-diagnostic-array-bounds
+  a[const_index(7)] = 3; // flagged by clang-diagnostic-array-bounds
+
+  a[0] = 3; // OK, constant index and inside bounds
+  a[1] = 3; // OK, constant index and inside bounds
+  a[9] = 3; // OK, constant index and inside bounds
+  a[const_index(6)] = 3; // OK, constant index and inside bounds
+}
+
+struct S {
+  int& operator[](int i);
+};
+
+void customOperator() {
+  S s;
+  int i = 0;
+  s[i] = 3; // OK, custom operator
+}
Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-gslheader.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-gslheader.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-gslheader.cpp
@@ -0,0 +1,79 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-bounds-constant-array-index %t -- -config='{CheckOptions: [{key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader, value: "dir1/gslheader.h"}]}' -- -std=c++11
+// CHECK-FIXES: #include "dir1/gslheader.h"
+
+typedef unsigned int size_t;
+
+namespace std {
+  template
+  struct array {
+T& operator[](size_t n);
+T& at(size_t n);
+  };
+}
+
+
+namespace gsl {
+  template
+  T& at( T(&a)[N], size_t index );
+
+  template
+  T& at( std::array &a, size_t index );
+}
+
+constexpr int const_index(int base) {
+  ret

[clang-tools-extra] r255470 - [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index

2015-12-13 Thread Matthias Gehre via cfe-commits
Author: mgehre
Date: Sun Dec 13 16:08:26 2015
New Revision: 255470

URL: http://llvm.org/viewvc/llvm-project?rev=255470&view=rev
Log:
[clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index

Summary:
This is http://reviews.llvm.org/D13746 but instead of including ,
a stub is provided.
This check flags all array subscriptions on static arrays and
std::arrays that either have a non-compile-time-constant index or are
out of bounds.

Dynamic accesses into arrays are difficult for both tools and humans to
validate as safe. array_view is a bounds-checked, safe type for
accessing arrays of data. at() is another alternative that ensures
single accesses are bounds-checked. If iterators are needed to access an
array, use the iterators from an array_view constructed over the array.

This rule is part of the "Bounds safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds2-only-index-into-arrays-using-constant-expressions

Reviewers: alexfh, sbenza, bkramer, aaron.ballman

Subscribers: cfe-commits

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

Added:

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

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-gslheader.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt?rev=255470&r1=255469&r2=255470&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt Sun Dec 
13 16:08:26 2015
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS support)
 add_clang_library(clangTidyCppCoreGuidelinesModule
   CppCoreGuidelinesTidyModule.cpp
   ProBoundsArrayToPointerDecayCheck.cpp
+  ProBoundsConstantArrayIndexCheck.cpp
   ProBoundsPointerArithmeticCheck.cpp
   ProTypeConstCastCheck.cpp
   ProTypeCstyleCastCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=255470&r1=255469&r2=255470&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Sun Dec 13 16:08:26 2015
@@ -12,6 +12,7 @@
 #include "../ClangTidyModuleRegistry.h"
 #include "../misc/AssignOperatorSignatureCheck.h"
 #include "ProBoundsArrayToPointerDecayCheck.h"
+#include "ProBoundsConstantArrayIndexCheck.h"
 #include "ProBoundsPointerArithmeticCheck.h"
 #include "ProTypeConstCastCheck.h"
 #include "ProTypeCstyleCastCheck.h"
@@ -30,6 +31,8 @@ public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-bounds-array-to-pointer-decay");
+CheckFactories.registerCheck(
+"cppcoreguidelines-pro-bounds-constant-array-index");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-bounds-pointer-arithmetic");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp?rev=255470&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 (added)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 Sun Dec 13 16:08:26 2015
@@ -0,0 +1,132 @@
+//===--- ProBoundsConstantArrayIndexCheck.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 "ProBoundsConstantArrayIndexCheck.h"
+#include

[clang-tools-extra] r255475 - clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index*.cpp: Don't assume size_t were unsigned int.

2015-12-13 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Sun Dec 13 16:49:37 2015
New Revision: 255475

URL: http://llvm.org/viewvc/llvm-project?rev=255475&view=rev
Log:
clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index*.cpp:
 Don't assume size_t were unsigned int.

Modified:

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-gslheader.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-gslheader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-gslheader.cpp?rev=255475&r1=255474&r2=255475&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-gslheader.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-gslheader.cpp
 Sun Dec 13 16:49:37 2015
@@ -1,7 +1,7 @@
 // RUN: %check_clang_tidy %s cppcoreguidelines-pro-bounds-constant-array-index 
%t -- -config='{CheckOptions: [{key: 
cppcoreguidelines-pro-bounds-constant-array-index.GslHeader, value: 
"dir1/gslheader.h"}]}' -- -std=c++11
 // CHECK-FIXES: #include "dir1/gslheader.h"
 
-typedef unsigned int size_t;
+typedef __SIZE_TYPE__ size_t;
 
 namespace std {
   template

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp?rev=255475&r1=255474&r2=255475&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
 Sun Dec 13 16:49:37 2015
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s cppcoreguidelines-pro-bounds-constant-array-index 
%t
 
-typedef unsigned int size_t;
+typedef __SIZE_TYPE__ size_t;
 
 namespace std {
   template


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


Re: r255281 - Do not generate DW_TAG_imported_module for anonymous namespaces (even nested) for all the platforms except PS4.

2015-12-13 Thread David Blaikie via cfe-commits
On Thu, Dec 10, 2015 at 10:52 AM, Ekaterina Romanova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: kromanova
> Date: Thu Dec 10 12:52:50 2015
> New Revision: 255281
>
> URL: http://llvm.org/viewvc/llvm-project?rev=255281&view=rev
> Log:
> Do not generate DW_TAG_imported_module for anonymous namespaces (even
> nested) for all the platforms except PS4.
> For PS4, generate explicit import for anonymous namespaces and mark it by
> DW_AT_artificial attribute.
>
> Differential Revision: http://reviews.llvm.org/D12624
>
>
> Added:
> cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp
> Modified:
> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>
> Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=255281&r1=255280&r2=255281&view=diff
>
> ==
> --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Dec 10
> 12:52:50 2015
> @@ -166,6 +166,10 @@ CODEGENOPT(DebugColumnInfo, 1, 0) ///< W
>  CODEGENOPT(DebugTypeExtRefs, 1, 0) ///< Whether or not debug info should
> contain
> ///< external references to a PCH or
> module.
>
> +CODEGENOPT(DebugExplicitImport, 1, 0)  ///< Whether or not debug info
> should
> +   ///< contain explicit imports for
> +   ///< anonymous namespaces
> +
>  CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize
> use-lists.
>
>  /// The user specified number of registers to be used for integral
> arguments,
>
> Modified: cfe/trunk/include/clang/Parse/Parser.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=255281&r1=255280&r2=255281&view=diff
>
> ==
> --- cfe/trunk/include/clang/Parse/Parser.h (original)
> +++ cfe/trunk/include/clang/Parse/Parser.h Thu Dec 10 12:52:50 2015
> @@ -2337,8 +2337,8 @@ private:
>
>void DiagnoseUnexpectedNamespace(NamedDecl *Context);
>
> -  Decl *ParseNamespace(unsigned Context, SourceLocation &DeclEnd,
> -   SourceLocation InlineLoc = SourceLocation());
> +  DeclGroupPtrTy ParseNamespace(unsigned Context, SourceLocation &DeclEnd,
> +SourceLocation InlineLoc =
> SourceLocation());
>void ParseInnerNamespace(std::vector& IdentLoc,
> std::vector& Ident,
> std::vector& NamespaceLoc,
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=255281&r1=255280&r2=255281&view=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Dec 10 12:52:50 2015
> @@ -4093,7 +4093,8 @@ public:
> SourceLocation IdentLoc,
> IdentifierInfo *Ident,
> SourceLocation LBrace,
> -   AttributeList *AttrList);
> +   AttributeList *AttrList,
> +   UsingDirectiveDecl * &UsingDecl);
>void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
>
>NamespaceDecl *getStdNamespace() const;
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=255281&r1=255280&r2=255281&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Dec 10 12:52:50 2015
> @@ -3408,10 +3408,14 @@ llvm::DIScope *CGDebugInfo::getCurrentCo
>  void CGDebugInfo::EmitUsingDirective(const UsingDirectiveDecl &UD) {
>if (CGM.getCodeGenOpts().getDebugInfo() <
> CodeGenOptions::LimitedDebugInfo)
>  return;
> -  DBuilder.createImportedModule(
> -  getCurrentContextDescriptor(cast(UD.getDeclContext())),
> -  getOrCreateNameSpace(UD.getNominatedNamespace()),
> -  getLineNumber(UD.getLocation()));
> +  const NamespaceDecl *NSDecl = UD.getNominatedNamespace();
> +  if (!NSDecl->isAnonymousNamespace() ||
> +  CGM.getCodeGenOpts().DebugExplicitImport) {
> +DBuilder.createImportedModule(
> +getCurrentContextDescriptor(cast(UD.getDeclContext())),
> +getOrCr

Re: [patch] Let -Wdelete-non-virtual-dtor mention that making the class final is a good fix too

2015-12-13 Thread David Blaikie via cfe-commits
(attachment missing)

Cursory review based on description: Sounds reasonable to me. Would want to
check the C++98 behavior to ensure it is actually relevant/correct to imply
the possibility of 'final' being used to fix the issue.

On Sun, Dec 13, 2015 at 1:37 AM, Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi,
>
> the attached patch changes
>
>   delete called on 'dnvd::B' that has virtual functions but non-virtual
> destructor
>
> to
>
>   delete called on non-final 'dnvd::B' that has virtual functions but
> non-virtual destructor
>
> I'm not sure if it should only do this for c++11 and newer – the new
> message is true in c++98 as well and I think we support final as an
> extension in c++98. So this patch unconditionally changes the warning text.
>
> Nico
>
> ___
> 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: r255447 - Revert r255445: adding a new test case

2015-12-13 Thread David Blaikie via cfe-commits
On Sat, Dec 12, 2015 at 8:45 PM, Xinliang David Li via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: davidxl
> Date: Sat Dec 12 22:45:49 2015
> New Revision: 255447
>
> URL: http://llvm.org/viewvc/llvm-project?rev=255447&view=rev
> Log:
> Revert r255445: adding a new test case
>
> Removed:
> cfe/trunk/test/Profile/cxx-static.cpp
>
> Removed: cfe/trunk/test/Profile/cxx-static.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-static.cpp?rev=255446&view=auto
>
> ==
> --- cfe/trunk/test/Profile/cxx-static.cpp (original)
> +++ cfe/trunk/test/Profile/cxx-static.cpp (removed)
> @@ -1,11 +0,0 @@
> -// REQUIRES: x86-registered-target
> -// RUN: %clang -target i386-unknown-linux -std=c++11 -o %t.o -c
> -no-integrated-as -fprofile-instr-generate %s
>

What does this test case test? It looks like it goes all the way through
LLVM, which we usually don't do in Clang tests (& it doesn't test any
output, which is usually a sign that something's not right - if this is
meant to test that we no longer crash on some input, it should probably
test that we produce the correct output in that situation. Simply "not
crashing" doesn't really constrain the behavior to what we want)


> -
> -__attribute__((noinline)) static int bar() { return 1; }
> -
> -int foo(int a, int b) {
> -  auto Func = [](int a, int b) { return a > b; };
> -
> -  return Func(a, b) + bar();
> -}
> -
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D15485: [clang-format] BraceWrapping.BeforeElse is incorrect for BS_Linux

2015-12-13 Thread Kent Sutherland via cfe-commits
ksuther created this revision.
ksuther added reviewers: cfe-commits, djasper.
Herald added a subscriber: klimek.

The BraceWrapping of the Linux style is incorrect. This appeared in r248802 
when the custom BraceWrapping options were added.

This is what r248801 looked like:

clang-format -style="{BasedOnStyle: google,  BreakBeforeBraces: Linux}" 
~/Desktop/format.m 
void main()
{
  if (blah) {
stuff();
  } else {
more();
  }
}

This is what r248802 (and trunk) looks like:

clang-format -style="{BasedOnStyle: google,  BreakBeforeBraces: Linux}" 
~/Desktop/format.m 
void main()
{
  if (blah) {
stuff();
  }
  else {
more();
  }
}

The behavior before r248802 is correct based on the documentation:

BS_Linux (in configuration: Linux) Like Attach, but break before braces on 
function, namespace and class definitions.

I changed BraceWrapping.BeforeElse to false for Linux and added and else 
statement to the Linux brace test.

http://reviews.llvm.org/D15485

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9003,6 +9003,8 @@
"if (true) {\n"
"  a();\n"
"  b();\n"
+   "} else {\n"
+   "  c();\n"
"}\n"
"  }\n"
"  void g() { return; }\n"
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -396,7 +396,7 @@
 Expanded.BraceWrapping.AfterClass = true;
 Expanded.BraceWrapping.AfterFunction = true;
 Expanded.BraceWrapping.AfterNamespace = true;
-Expanded.BraceWrapping.BeforeElse = true;
+Expanded.BraceWrapping.BeforeElse = false;
 break;
   case FormatStyle::BS_Mozilla:
 Expanded.BraceWrapping.AfterClass = true;


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9003,6 +9003,8 @@
"if (true) {\n"
"  a();\n"
"  b();\n"
+   "} else {\n"
+   "  c();\n"
"}\n"
"  }\n"
"  void g() { return; }\n"
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -396,7 +396,7 @@
 Expanded.BraceWrapping.AfterClass = true;
 Expanded.BraceWrapping.AfterFunction = true;
 Expanded.BraceWrapping.AfterNamespace = true;
-Expanded.BraceWrapping.BeforeElse = true;
+Expanded.BraceWrapping.BeforeElse = false;
 break;
   case FormatStyle::BS_Mozilla:
 Expanded.BraceWrapping.AfterClass = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14877: Fix ICE on lowering of constexpr vector splats

2015-12-13 Thread George Burgess IV via cfe-commits
george.burgess.iv updated this revision to Diff 42683.
george.burgess.iv marked an inline comment as done.
george.burgess.iv added a comment.

> Changes to ExprConstant and CGExprConstant appear to be pure cleanups; please 
> check those in as a separate change


r255314, thanks.

> When this is done, you should also be able to remove the IgnoreImpCasts and 
> EmitScalarConversion calls in the CK_VectorSplat handling in 
> ScalarExprEmitter::VisitCastExpr.


Yup!

Aside: I can't figure out how to get c++11 constexpr evaluation in to work with 
OpenCL (vector expressions apparently aren't considered ICEs in non-c++11 
mode). So, the bit of special code in ExprConstant is untested at the moment. 
I'm open to suggestions for how to test it; I tried things like `int 
arr[((int4)true)[0] == -1 ? 1 : -1];`/tricks with `enable_if`, but wasn't quite 
able to get it to do what I wanted. :)


http://reviews.llvm.org/D14877

Files:
  include/clang/AST/OperationKinds.h
  include/clang/Sema/Sema.h
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaOverload.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenCXX/builtins-systemz-zvector.cpp
  test/CodeGenOpenCL/bool_cast.cl

Index: test/CodeGenOpenCL/bool_cast.cl
===
--- test/CodeGenOpenCL/bool_cast.cl
+++ test/CodeGenOpenCL/bool_cast.cl
@@ -2,7 +2,9 @@
 
 typedef unsigned char uchar4 __attribute((ext_vector_type(4)));
 typedef unsigned int int4 __attribute((ext_vector_type(4)));
+typedef float float4 __attribute((ext_vector_type(4)));
 
+// CHECK-LABEL: define void @ker()
 void kernel ker() {
   bool t = true;
   int4 vec4 = (int4)t;
@@ -24,4 +26,8 @@
   unsigned char c;
   c = (unsigned char)true;
 // CHECK: store i8 1, i8* %c, align 1
+
+  float4 vf;
+  vf = (float4)true;
+// CHECK: store <4 x float> 
 }
Index: test/CodeGenCXX/builtins-systemz-zvector.cpp
===
--- /dev/null
+++ test/CodeGenCXX/builtins-systemz-zvector.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z13 -triple s390x-linux-gnu \
+// RUN: -fzvector -fno-lax-vector-conversions -std=c++11 \
+// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
+
+bool gb;
+
+// There was an issue where we weren't properly converting constexprs to
+// vectors with elements of the appropriate width. (e.g.
+// (vector signed short)0 would be lowered as [4 x i32] in some cases)
+
+// CHECK-LABEL: @_Z8testIntsDv4_i
+void testInts(vector int VI) {
+  constexpr vector int CI1 = (vector int)0LL;
+  // CHECK: icmp
+  gb = (VI == CI1)[0];
+
+  // Likewise for float inits.
+  constexpr vector int CI2 = (vector int)char(0);
+  // CHECK: icmp
+  gb = (VI == CI2)[0];
+
+  constexpr vector int CF1 = (vector int)0.0;
+  // CHECK: icmp
+  gb = (VI == CF1)[0];
+
+  constexpr vector int CF2 = (vector int)0.0f;
+  // CHECK: icmp
+  gb = (VI == CF2)[0];
+}
+
+// CHECK-LABEL: @_Z10testFloatsDv2_d
+void testFloats(vector double VD) {
+  constexpr vector double CI1 = (vector double)0LL;
+  // CHECK: fcmp
+  gb = (VD == CI1)[0];
+
+  // Likewise for float inits.
+  constexpr vector double CI2 = (vector double)char(0);
+  // CHECK: fcmp
+  gb = (VD == CI2)[0];
+
+  constexpr vector double CF1 = (vector double)0.0;
+  // CHECK: fcmp
+  gb = (VD == CF1)[0];
+
+  constexpr vector double CF2 = (vector double)0.0f;
+  // CHECK: fcmp
+  gb = (VD == CF2)[0];
+}
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -317,6 +317,8 @@
   case CK_BitCast:
   case CK_AddressSpaceConversion:
   case CK_IntegralCast:
+  case CK_BooleanToSignedIntegral:
+  case CK_BooleanToSignedFloating:
   case CK_NullToPointer:
   case CK_IntegralToPointer:
   case CK_PointerToIntegral:
@@ -345,6 +347,10 @@
 // Delegate to SValBuilder to process.
 SVal V = state->getSVal(Ex, LCtx);
 V = svalBuilder.evalCast(V, T, ExTy);
+// Negate the result if we're treating the boolean as a signed i1
+if (CastE->getCastKind() == CK_BooleanToSignedFloating ||
+CastE->getCastKind() == CK_BooleanToSignedIntegral)
+  V = evalMinus(V);
 state = state->BindExpr(CastE, LCtx, V);
 Bldr.generateNode(CastE, Pred, state);
 continue;
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -258,6 +258,8 @@
 case CK_IntegralCast:
 case CK_I

Re: [PATCH] D14877: Fix ICE on lowering of constexpr vector splats

2015-12-13 Thread George Burgess IV via cfe-commits
george.burgess.iv added inline comments.


Comment at: lib/Sema/SemaExpr.cpp:5576
@@ +5575,3 @@
+return ExprError();
+  return ImpCastExprToType(CastExprRes.get(), DestElemTy, CK);
+}

rsmith wrote:
> Looking at `ScalarExprEmitter::VisitCastExpr`, it seems like we are supposed 
> to do something slightly bizarre if the source type is `bool` and we're in 
> OpenCL mode -- in that case we're supposed to convert `true` to -1 instead of 
> 1. In order for ExprConstant to get that case right, we should emit the 
> appropriate implicit cast for that conversion here -- maybe add a 
> `CK_SignedBooleanToIntegral` and a `CK_SignedBooleanToFloating`; I don't see 
> any nice way to express this with our existing cast kinds.
...And this behavior is only present when splatting. Joy.


http://reviews.llvm.org/D14877



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


Re: [PATCH] D14877: Fix ICE on lowering of constexpr vector splats

2015-12-13 Thread George Burgess IV via cfe-commits
george.burgess.iv updated this revision to Diff 42686.
george.burgess.iv added a comment.

TIL you can use OpenCL vectors in C++ files. Fixed a bug related to not knowing 
this + added tests for the constexpr cases.

Also, is there a better way to do the `bool` -> `APFloat` conversion in 
ExprConstant, lines 8108-8110? I'm assuming that float semantics matter, 
otherwise `Result = APFloat(-BoolResult)` seems nicer.


http://reviews.llvm.org/D14877

Files:
  include/clang/AST/OperationKinds.h
  include/clang/Sema/Sema.h
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaOverload.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenCXX/builtins-systemz-zvector.cpp
  test/CodeGenCXX/vector-splat-conversion.cpp
  test/CodeGenOpenCL/bool_cast.cl

Index: test/CodeGenOpenCL/bool_cast.cl
===
--- test/CodeGenOpenCL/bool_cast.cl
+++ test/CodeGenOpenCL/bool_cast.cl
@@ -2,7 +2,9 @@
 
 typedef unsigned char uchar4 __attribute((ext_vector_type(4)));
 typedef unsigned int int4 __attribute((ext_vector_type(4)));
+typedef float float4 __attribute((ext_vector_type(4)));
 
+// CHECK-LABEL: define void @ker()
 void kernel ker() {
   bool t = true;
   int4 vec4 = (int4)t;
@@ -24,4 +26,8 @@
   unsigned char c;
   c = (unsigned char)true;
 // CHECK: store i8 1, i8* %c, align 1
+
+  float4 vf;
+  vf = (float4)true;
+// CHECK: store <4 x float> 
 }
Index: test/CodeGenCXX/vector-splat-conversion.cpp
===
--- test/CodeGenCXX/vector-splat-conversion.cpp
+++ test/CodeGenCXX/vector-splat-conversion.cpp
@@ -1,19 +1,42 @@
 // RUN: %clang_cc1 %s -triple arm64-apple-ios8.1.0 -std=c++11 -emit-llvm -o - | FileCheck %s
-// rdar://2762
 
 typedef __attribute__((__ext_vector_type__(8))) float vector_float8;
 
 typedef vector_float8 float8;
 
-void MandelbrotPolyCalcSIMD8()
-{
-constexpr float8   v4 = 4.0;  // value to compare against abs(z)^2, to see if bounded
-float8 vABS;
-auto vLT  = vABS < v4;
+// rdar://2762
+// CHECK-LABEL: define void @_Z23MandelbrotPolyCalcSIMD8v
+void MandelbrotPolyCalcSIMD8() {
+  constexpr float8 v4 = 4.0;  // value to compare against abs(z)^2, to see if bounded
+  float8 vABS;
+  auto vLT  = vABS < v4;
+  // CHECK: store <8 x float> 
+  // CHECK: [[ZERO:%.*]] = load <8 x float>, <8 x float>* [[VARBS:%.*]]
+  // CHECK: [[CMP:%.*]] = fcmp olt <8 x float> [[ZERO]]
+  // CHECK: [[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i32>
+  // CHECK: store <8 x i32> [[SEXT]], <8 x i32>* [[VLT:%.*]]
 }
 
-// CHECK: store <8 x float> 
-// CHECK: [[ZERO:%.*]] = load <8 x float>, <8 x float>* [[VARBS:%.*]]
-// CHECK: [[CMP:%.*]] = fcmp olt <8 x float> [[ZERO]]
-// CHECK: [[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i32>
-// CHECK: store <8 x i32> [[SEXT]], <8 x i32>* [[VLT:%.*]]
+typedef __attribute__((__ext_vector_type__(4))) int int4;
+typedef __attribute__((__ext_vector_type__(4))) float float4;
+
+// CHECK-LABEL: define void @_Z14BoolConversionv
+void BoolConversion() {
+  // CHECK: store <4 x i32> 
+  int4 intsT = (int4)true;
+  // CHECK: store <4 x i32> zeroinitializer
+  int4 intsF = (int4)false;
+  // CHECK: store <4 x float> 
+  float4 floatsT = (float4)true;
+  // CHECK: store <4 x float> zeroinitializer
+  float4 floatsF = (float4)false;
+
+  // CHECK: store <4 x i32> 
+  constexpr int4 cIntsT = (int4)true;
+  // CHECK: store <4 x i32> zeroinitializer
+  constexpr int4 cIntsF = (int4)false;
+  // CHECK: store <4 x float> 
+  constexpr float4 cFloatsT = (float4)true;
+  // CHECK: store <4 x float> zeroinitializer
+  constexpr float4 cFloatsF = (float4)false;
+}
Index: test/CodeGenCXX/builtins-systemz-zvector.cpp
===
--- /dev/null
+++ test/CodeGenCXX/builtins-systemz-zvector.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z13 -triple s390x-linux-gnu \
+// RUN: -fzvector -fno-lax-vector-conversions -std=c++11 \
+// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
+
+bool gb;
+
+// There was an issue where we weren't properly converting constexprs to
+// vectors with elements of the appropriate width. (e.g.
+// (vector signed short)0 would be lowered as [4 x i32] in some cases)
+
+// CHECK-LABEL: @_Z8testIntsDv4_i
+void testInts(vector int VI) {
+  constexpr vector int CI1 = (vector int)0LL;
+  // CHECK: icmp
+  gb = (VI == CI1)[0];
+
+  // Likewise for float inits.
+  constexpr vector int CI2 = (vector int)char(0);
+  // CHECK: icmp
+  gb = (VI == CI2)[0];
+
+  constexpr vector int CF1 = (vector int)0.0;
+  // CHECK: icmp
+  gb = (VI == CF1)[0];
+
+  const

[PATCH] D15486: [RFC] Emit note pointing to a discarded qualifier [-Wincompatible-pointer-types-discards-qualifiers]

2015-12-13 Thread Adrian Zgorzałek via cfe-commits
adek05 created this revision.
adek05 added a reviewer: jroelofs.
adek05 added a subscriber: cfe-commits.

Finding original declaration which is suffering from discarding a qualifier is 
somewhat tricky and it doesn't always make sense in all of the contexts that 
DiagnoseAssignmentResult is called.
I haven't figured out yet how to make this change work for ObjC Setters which I 
think is the only place left which should handle this diagnostic.
Current approach is sort of best-effort, but doesn't really guarantee much.

Alternative way to go would be to factor this extra diagnostic out and write it 
in a similar fashion to DiagnoseSelfAssignment and call it in some of the 
contexts when note could be useful.
The problem I see with that, is that it would have issues with handling 
overriden assignment operators or would not work for non built-in types.

http://reviews.llvm.org/D15486

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaPseudoObject.cpp
  lib/Sema/SemaStmt.cpp

Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -2604,7 +2604,8 @@
 if (ExprRes.isInvalid())
   return StmtError();
 E = ExprRes.get();
-if (DiagnoseAssignmentResult(ConvTy, StarLoc, DestTy, ETy, E, AA_Passing))
+if (DiagnoseAssignmentResult(ConvTy, StarLoc, DestTy, nullptr, ETy, E,
+ AA_Passing))
   return StmtError();
   }
 
Index: lib/Sema/SemaPseudoObject.cpp
===
--- lib/Sema/SemaPseudoObject.cpp
+++ lib/Sema/SemaPseudoObject.cpp
@@ -746,7 +746,7 @@
   ExprResult opResult = op;
   Sema::AssignConvertType assignResult
 = S.CheckSingleAssignmentConstraints(paramType, opResult);
-  if (S.DiagnoseAssignmentResult(assignResult, opcLoc, paramType,
+  if (S.DiagnoseAssignmentResult(assignResult, opcLoc, paramType, nullptr,
  op->getType(), opResult.get(),
  Sema::AA_Assigning))
 return ExprError();
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -6638,11 +6638,11 @@
   CurInit = CurInitExprRes;
 
   bool Complained;
-  if (S.DiagnoseAssignmentResult(ConvTy, Kind.getLocation(),
- Step->Type, SourceType,
- InitialCurInit.get(),
- getAssignmentAction(Entity, true),
- &Complained)) {
+  if (S.DiagnoseAssignmentResult(
+  ConvTy, Kind.getLocation(), Step->Type,
+  Entity.getDecl() ? dyn_cast(Entity.getDecl()) : nullptr,
+  SourceType, InitialCurInit.get(),
+  getAssignmentAction(Entity, true), &Complained)) {
 PrintInitLocationNote(S, Entity);
 return ExprError();
   } else if (Complained)
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -9612,8 +9612,11 @@
 ConvTy = CheckAssignmentConstraints(Loc, LHSType, RHSType);
   }
 
-  if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType,
-   RHS.get(), AA_Assigning))
+  DeclRefExpr *DeclRef = dyn_cast(LHSExpr);
+  if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType,
+   DeclRef->getDecl() ? DeclRef->getDecl()
+  : nullptr,
+   RHSType, RHS.get(), AA_Assigning))
 return QualType();
 
   CheckForNullPointerDereference(*this, LHSExpr);
@@ -11864,8 +11867,8 @@
 }
 
 bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
-SourceLocation Loc,
-QualType DstType, QualType SrcType,
+SourceLocation Loc, QualType DstType,
+VarDecl *DstVarDecl, QualType SrcType,
 Expr *SrcExpr, AssignmentAction Action,
 bool *Complained) {
   if (Complained)
@@ -12051,6 +12054,16 @@
 HandleFunctionTypeMismatch(FDiag, SecondType, FirstType);
 
   Diag(Loc, FDiag);
+
+  // Emit original location of a variable declaration which is on the LHS
+  if (DiagKind == diag::ext_nested_pointer_qualifier_mismatch && DstVarDecl) {
+SourceRange DstVarDeclSR = DstVarDecl->getSourceRange();
+PartialDiagnostic Note =
+PDiag(diag::note_nested_pointer_discarded_qualifier);
+Note << DstVarDeclSR;
+Diag(DstVarDeclSR.getBegin(), Note);
+  }
+
   if (DiagKind == diag::warn_incompatible_qualified_id &&

Re: [PATCH] D14980: PR18513: make gcc compatible layout for bit-fields with explicit aligned attribute

2015-12-13 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

John and Richard,

I think this patch fixes important ABI compatibility issue with GCC and if 
there are no more comments, I think it makes sense to commit it. Could you 
please approve this CL?

Thanks,
Dmitry


http://reviews.llvm.org/D14980



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