[libunwind] r246143 - [libunwind] Remove unused includes.

2015-08-27 Thread Peter Zotov via cfe-commits
Author: whitequark
Date: Thu Aug 27 01:58:31 2015
New Revision: 246143

URL: http://llvm.org/viewvc/llvm-project?rev=246143&view=rev
Log:
[libunwind] Remove unused includes.

Modified:
libunwind/trunk/src/DwarfParser.hpp
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/src/DwarfParser.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=246143&r1=246142&r2=246143&view=diff
==
--- libunwind/trunk/src/DwarfParser.hpp (original)
+++ libunwind/trunk/src/DwarfParser.hpp Thu Aug 27 01:58:31 2015
@@ -18,8 +18,6 @@
 #include 
 #include 
 
-#include 
-
 #include "libunwind.h"
 #include "dwarf2.h"
 

Modified: libunwind/trunk/src/Registers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Registers.hpp?rev=246143&r1=246142&r2=246143&view=diff
==
--- libunwind/trunk/src/Registers.hpp (original)
+++ libunwind/trunk/src/Registers.hpp Thu Aug 27 01:58:31 2015
@@ -14,7 +14,6 @@
 #define __REGISTERS_HPP__
 
 #include 
-#include 
 #include 
 
 #include "libunwind.h"

Modified: libunwind/trunk/src/libunwind.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/libunwind.cpp?rev=246143&r1=246142&r2=246143&view=diff
==
--- libunwind/trunk/src/libunwind.cpp (original)
+++ libunwind/trunk/src/libunwind.cpp Thu Aug 27 01:58:31 2015
@@ -16,9 +16,6 @@
 #include  // getenv
 #endif
 #include 
-#include 
-#include 
-#include 
 #include 
 
 #include "libunwind_ext.h"


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


Re: [PATCH] D12366: Avoid unnecessarily storing vtable pointers in more destructor cases

2015-08-27 Thread scott douglass via cfe-commits
scott-0 added a comment.

Thanks for the review and advice; I'll give `undef` a try.  It's a much simpler 
approach.


http://reviews.llvm.org/D12366



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


[PATCH] D12400: Fix store detection for return value in CGCall

2015-08-27 Thread Jakub Kuderski via cfe-commits
kuhar created this revision.
kuhar added a subscriber: cfe-commits.
kuhar set the repository for this revision to rL LLVM.
Herald added subscribers: srhines, danalbert, tberghammer.

`findDominatingStoreToReturn` in CGCall.cpp didn't check if a candidate store 
instruction used the ReturnValue as pointer operand or value operand. This led 
to wrong code gen - in later stages (load-store elision code) the found store 
and its operand would be erased, causing ReturnValue to become a .

The patch adds a check that makes sure that ReturnValue is a pointer operand of 
store instruction. Regression test is also added.

This fixes PR24386.

Repository:
  rL LLVM

http://reviews.llvm.org/D12400

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGen/arm_function_epilog.cpp

Index: test/CodeGen/arm_function_epilog.cpp
===
--- /dev/null
+++ test/CodeGen/arm_function_epilog.cpp
@@ -0,0 +1,17 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple armv7-none-linux-androideabi -target-abi 
aapcs-linux -mfloat-abi hard -x c++ -emit-llvm %s -o - | FileCheck %s
+
+struct Vec2 {
+union { struct { float x, y; };
+float data[2];
+};
+};
+
+// CHECK: define arm_aapcs_vfpcc %struct.Vec2 @_Z7getVec2v()
+// CHECK: ret %struct.Vec2
+Vec2 getVec2() {
+Vec2 out;
+union { Vec2* v; unsigned char* u; } x;
+x.v = &out;
+return out;
+}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -2329,6 +2329,7 @@
   llvm::StoreInst *store =
 dyn_cast(CGF.ReturnValue->user_back());
   if (!store) return nullptr;
+  if (store->getPointerOperand() != CGF.ReturnValue) return nullptr;
 
   // These aren't actually possible for non-coerced returns, and we
   // only care about non-coerced returns on this code path.


Index: test/CodeGen/arm_function_epilog.cpp
===
--- /dev/null
+++ test/CodeGen/arm_function_epilog.cpp
@@ -0,0 +1,17 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple armv7-none-linux-androideabi -target-abi aapcs-linux -mfloat-abi hard -x c++ -emit-llvm %s -o - | FileCheck %s
+
+struct Vec2 {
+union { struct { float x, y; };
+float data[2];
+};
+};
+
+// CHECK: define arm_aapcs_vfpcc %struct.Vec2 @_Z7getVec2v()
+// CHECK: ret %struct.Vec2
+Vec2 getVec2() {
+Vec2 out;
+union { Vec2* v; unsigned char* u; } x;
+x.v = &out;
+return out;
+}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -2329,6 +2329,7 @@
   llvm::StoreInst *store =
 dyn_cast(CGF.ReturnValue->user_back());
   if (!store) return nullptr;
+  if (store->getPointerOperand() != CGF.ReturnValue) return nullptr;
 
   // These aren't actually possible for non-coerced returns, and we
   // only care about non-coerced returns on this code path.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const

2015-08-27 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki updated this revision to Diff 33307.
danielmarjamaki added a comment.

Thanks! I fixed that FP.


http://reviews.llvm.org/D12359

Files:
  include/clang/AST/DeclBase.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTReaderDecl.cpp
  test/Sema/warn-nonconst-parameter.c
  test/SemaCXX/warn-nonconst-parameter.cpp

Index: test/SemaCXX/warn-nonconst-parameter.cpp
===
--- test/SemaCXX/warn-nonconst-parameter.cpp
+++ test/SemaCXX/warn-nonconst-parameter.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -Wnonconst-parameter -verify %s
+//
+// Test that -Wnonconst-parameter does not warn for virtual functions.
+//
+
+// expected-no-diagnostics
+
+class Base {
+public:
+  virtual int f(int*p);
+};
+
+
+class Derived /* : public Base */ {
+public:
+  virtual int f(int*p){return 0;}
+};
Index: test/Sema/warn-nonconst-parameter.c
===
--- test/Sema/warn-nonconst-parameter.c
+++ test/Sema/warn-nonconst-parameter.c
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -fsyntax-only -Wnonconst-parameter -verify %s
+
+// Currently the -Wnonconst-parameter only warns about pointer arguments.
+//
+// It can be defined both that the data is const and that the pointer is const,
+// the -Wnonconst-parameter only checks if the data can be const-specified.
+//
+// It does not warn about pointers to records or function pointers.
+
+// Some external function where first argument is nonconst and second is const.
+char* strcpy1(char *dest, const char *src);
+
+
+int warn1(int *p) { // expected-warning {{parameter 'p' can be const}}
+  return *p;
+}
+
+void warn2(int *first, int *last) { // expected-warning {{parameter 'last' can be const}}
+  *first = 0;
+  if (first < last) {} // <- last can be const
+}
+
+void warn3(char *p) { // expected-warning {{parameter 'p' can be const}}
+  char buf[10];
+  strcpy1(buf, p);
+}
+
+int dontwarn1(const int *p) {
+  return *p;
+}
+
+void dontwarn2(int *p) {
+  *p = 0;
+}
+
+void dontwarn3(char *p) {
+  p[0] = 0;
+}
+
+void dontwarn4(int *p) {
+  int *q = p;
+  *q = 0;
+}
+
+void dontwarn5(float *p) {
+  int *q = (int *)p;
+}
+
+void dontwarn6(char *p) {
+  char *a, *b;
+  a = b = p;
+}
+
+void dontwarn7(int *p) {
+  int *i = p ? p : 0;
+}
+
+void dontwarn8(char *p) {
+  char *x;
+  x = (p ? p : "");
+}
+
+char *dontwarn9(char *p) {
+  char *x;
+  return p ? p : "";
+}
+
+void dontwarn10(int *p) {
+  ++(*p);
+}
+
+char dontwarn11(int *p) {
+  return ++(*p);
+}
+
+void dontwarn12(unsigned char *str, const unsigned int i) {
+unsigned char *p;
+for (p = str + i; *p; ) {}
+}
+
+void dontwarn13(char *p) {
+  strcpy1(p, "abc");
+}
+
+void dontwarn14(char *p) {
+  strcpy1(p+2, "abc");
+}
+
+char *dontwarn15(char *p) {
+  return strcpy1(p, "abc");
+}
+
+// Don't warn about nonconst function pointers that can be const.
+void functionpointer(double f(double), int x) {
+  f(x);
+}
+
+// Don't warn about nonconst record pointers that can be const.
+struct XY { int x; int y; };
+int recordpointer(struct XY *xy) {
+  return xy->x;
+}
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -500,6 +500,7 @@
   D->setImplicit(Record[Idx++]);
   D->Used = Record[Idx++];
   D->setReferenced(Record[Idx++]);
+  D->setWritten();
   D->setTopLevelDeclInObjCContainer(Record[Idx++]);
   D->setAccess((AccessSpecifier)Record[Idx++]);
   D->FromASTFile = true;
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3613,6 +3613,7 @@
 if (OldVar->isUsed(false))
   NewVar->setIsUsed();
 NewVar->setReferenced(OldVar->isReferenced());
+NewVar->setWritten();
   }
 
   // See if the old variable had a type-specifier that defined an anonymous tag.
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -466,6 +466,7 @@
  SourceLocation Loc,
  bool RefersToCapture = false) {
   D->setReferenced();
+  D->setWritten();
   D->markUsed(S.Context);
   return DeclRefExpr::Create(S.getASTContext(), NestedNameSpecifierLoc(),
  SourceLocation(), D, RefersToCapture, Loc, Ty,
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda

[PATCH] D12402: PR24595: clang-cl fails to compile vswriter.h header from Windows SDK 8.1 in 32 bit mode

2015-08-27 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added a reviewer: rnk.
andreybokhanko added a subscriber: cfe-commits.

As described in PR24595, clang-cl fails to compile vswriter.h header from 
Windows SDK 8.1 in 32 bit mode. This patch fixes this.

More on vswriter.h is here: 
https://msdn.microsoft.com/en-us/library/aa384627(v=vs.85).aspx

I'm not sure adding a new warning is the right approach -- maybe we should 
downgrade "err_conflicting_overriding_cc_attributes" to a Warning with 
DefaultError attribute?

http://reviews.llvm.org/D12402

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/virtual-override-x86.cpp

Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -12933,9 +12933,16 @@
   if (New->getStorageClass() == SC_Static)
 return false;
 
-  Diag(New->getLocation(),
-   diag::err_conflicting_overriding_cc_attributes)
-<< New->getDeclName() << New->getType() << Old->getType();
+  // vswriter.h header from Windows SDK violates this. Thus, we should just
+  // warn, not error on Windows.
+  if (getLangOpts().MSVCCompat)
+Diag(New->getLocation(),
+ diag::warn_conflicting_overriding_cc_attributes)
+  << New->getDeclName() << New->getType() << Old->getType();
+  else
+Diag(New->getLocation(),
+ diag::err_conflicting_overriding_cc_attributes)
+  << New->getDeclName() << New->getType() << Old->getType();
   Diag(Old->getLocation(), diag::note_overridden_virtual_function);
   return true;
 }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1403,6 +1403,11 @@
   "virtual function %0 has different calling convention attributes "
   "%diff{($) than the function it overrides (which has calling convention $)|"
   "than the function it overrides}1,2">;
+def warn_conflicting_overriding_cc_attributes : Warning<
+  "virtual function %0 has different calling convention attributes "
+  "%diff{($) than the function it overrides (which has calling convention $)|"
+  "than the function it overrides}1,2. New attribute ignored.">,
+  InGroup;
 
 def err_covariant_return_inaccessible_base : Error<
   "invalid covariant return for virtual function: %1 is a "
Index: test/SemaCXX/virtual-override-x86.cpp
===
--- test/SemaCXX/virtual-override-x86.cpp
+++ test/SemaCXX/virtual-override-x86.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -triple=i686-pc-win32 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -triple=i686-pc-win32 -fsyntax-only -verify %s -std=c++11 
-DTEST1
+// RUN: %clang_cc1 -triple=i386-pc-win32 -fms-compatibility -fsyntax-only 
-verify %s -std=c++11 -DTEST2
+
+#ifdef TEST1
 
 namespace PR14339 {
   class A {
@@ -31,3 +34,23 @@
 void g();  // expected-error{{virtual function 'g' has different calling 
convention attributes ('void () __attribute__((thiscall))') than the function 
it overrides (which has calling convention 'void () __attribute__((stdcall))'}}
   };
 }
+
+#elif TEST2
+
+// PR24595: This code is present in vswriter.h header file from Windows SDK 
8.1.
+// We should be able to compile it in 32 bit mode.
+class CVssWriter
+{
+public:
+  __stdcall CVssWriter() {}
+  virtual __stdcall ~CVssWriter() {} // expected-note {{overridden virtual 
function is here}}
+};
+
+class CVssWriterEx : public CVssWriter // expected-warning {{virtual function 
'~CVssWriterEx' has different calling convention attributes ('void () 
__attribute__((thiscall))') than the function it overrides (which has calling 
convention 'void () __attribute__((stdcall)) noexcept'). New attribute 
ignored.}}
+{};
+
+#else
+
+#error Unknown test
+
+#endif


Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -12933,9 +12933,16 @@
   if (New->getStorageClass() == SC_Static)
 return false;
 
-  Diag(New->getLocation(),
-   diag::err_conflicting_overriding_cc_attributes)
-<< New->getDeclName() << New->getType() << Old->getType();
+  // vswriter.h header from Windows SDK violates this. Thus, we should just
+  // warn, not error on Windows.
+  if (getLangOpts().MSVCCompat)
+Diag(New->getLocation(),
+ diag::warn_conflicting_overriding_cc_attributes)
+  << New->getDeclName() << New->getType() << Old->getType();
+  else
+Diag(New->getLocation(),
+ diag::err_conflicting_overriding_cc_attributes)
+  << New->getDeclName() << New->getType() << Old->getType();
   Diag(Old->getLocation(), diag::note_overridden_virtual_function);
   return true;
 }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- includ

Re: [PATCH] D12163: [Patch] [Analyzer] BugReporter.cpp:2869: Assertion failed: !RemainingNodes.empty() && "No error node found in the trimmed graph" (PR 24184)

2015-08-27 Thread Ying Yi via cfe-commits
MaggieYi added a comment.

Ping


http://reviews.llvm.org/D12163



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


[PATCH] D12401: Handling i686 architecture in makefiles for clang.

2015-08-27 Thread Nishanth H. Kottary via cfe-commits
nishanth-kottary created this revision.
nishanth-kottary added reviewers: samsonov, loladiro.
nishanth-kottary added a subscriber: cfe-commits.
nishanth-kottary set the repository for this revision to rL LLVM.

This is a part of D12316. Added i686 names for 32bit runtime configs so that 
built files will have the appropriate names.

Repository:
  rL LLVM

http://reviews.llvm.org/D12401

Files:
  runtime/compiler-rt/Makefile

Index: runtime/compiler-rt/Makefile
===
--- runtime/compiler-rt/Makefile
+++ runtime/compiler-rt/Makefile
@@ -121,13 +121,29 @@
 $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \
 echo $$?)
 
+# Finding CompilerTargetArch copied from clang_linux.mk
+CompilerTargetTriple := $(shell \
+   LANG=C $(CC) -v 2>&1 | grep 'Target:' | cut -d' ' -f2)
+ifeq ($(CompilerTargetTriple),)
+$(error "unable to infer compiler target triple for $(CC)")
+endif
+
+# Define configs only if arch in triple is i386 or x86_64
+CompilerTargetArch := $(firstword $(subst -, ,$(CompilerTargetTriple)))
+
 # We try to build 32-bit runtimes both on 32-bit hosts and 64-bit hosts.
-Runtime32BitConfigs = \
+Runtime32Bit-i386Configs = \
builtins-i386.a profile-i386.a
+Runtime32Bit-i686Configs = \
+   builtins-i686.a profile-i686.a
 
 # We currently only try to generate runtime libraries on x86.
 ifeq ($(ARCH),x86)
-RuntimeLibrary.linux.Configs += $(Runtime32BitConfigs)
+ifeq ($(CompilerTargetArch), i386)
+RuntimeLibrary.linux.Configs += $(Runtime32Bit-i386Configs)
+else ifeq ($(CompilerTargetArch), i686)
+RuntimeLibrary.linux.Configs += $(Runtime32Bit-i686Configs)
+endif
 endif
 
 ifeq ($(ARCH),x86_64)
@@ -139,7 +155,7 @@
 # executable.
 test_source = 
$(LLVM_SRC_ROOT)/tools/clang/runtime/compiler-rt/clang_linux_test_input.c
 ifeq ($(call TryCompile,$(ToolDir)/clang,$(test_source),-m32),0)
-RuntimeLibrary.linux.Configs += $(Runtime32BitConfigs)
+RuntimeLibrary.linux.Configs += $(Runtime32Bit-i386Configs)
 endif
 endif
 


Index: runtime/compiler-rt/Makefile
===
--- runtime/compiler-rt/Makefile
+++ runtime/compiler-rt/Makefile
@@ -121,13 +121,29 @@
 $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \
 echo $$?)
 
+# Finding CompilerTargetArch copied from clang_linux.mk
+CompilerTargetTriple := $(shell \
+	LANG=C $(CC) -v 2>&1 | grep 'Target:' | cut -d' ' -f2)
+ifeq ($(CompilerTargetTriple),)
+$(error "unable to infer compiler target triple for $(CC)")
+endif
+
+# Define configs only if arch in triple is i386 or x86_64
+CompilerTargetArch := $(firstword $(subst -, ,$(CompilerTargetTriple)))
+
 # We try to build 32-bit runtimes both on 32-bit hosts and 64-bit hosts.
-Runtime32BitConfigs = \
+Runtime32Bit-i386Configs = \
 	builtins-i386.a profile-i386.a
+Runtime32Bit-i686Configs = \
+	builtins-i686.a profile-i686.a
 
 # We currently only try to generate runtime libraries on x86.
 ifeq ($(ARCH),x86)
-RuntimeLibrary.linux.Configs += $(Runtime32BitConfigs)
+ifeq ($(CompilerTargetArch), i386)
+RuntimeLibrary.linux.Configs += $(Runtime32Bit-i386Configs)
+else ifeq ($(CompilerTargetArch), i686)
+RuntimeLibrary.linux.Configs += $(Runtime32Bit-i686Configs)
+endif
 endif
 
 ifeq ($(ARCH),x86_64)
@@ -139,7 +155,7 @@
 # executable.
 test_source = $(LLVM_SRC_ROOT)/tools/clang/runtime/compiler-rt/clang_linux_test_input.c
 ifeq ($(call TryCompile,$(ToolDir)/clang,$(test_source),-m32),0)
-RuntimeLibrary.linux.Configs += $(Runtime32BitConfigs)
+RuntimeLibrary.linux.Configs += $(Runtime32Bit-i386Configs)
 endif
 endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const

2015-08-27 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

I saw a FP when I looked through the logs today...

Example code:

  void dostuff(int *);
  
  void f(int *p) {
  #ifdef X
  dostuff(p);
  #endif
  
  if (*p == 0) {}
  }

As far as I know there is nothing I can do about this in the checker.

A user could for instance solve this with a macro:

  void dostuff(int *);
  
  #define NONCONST(p)   (void)(0 ? 0 : ++(*p))
  
  void f(int *p) {
  NONCONST(p);
  
  #ifdef X
  dostuff(p);
  #endif
  
  if (*p == 0) {}
  }

Or by using a second pointer:

  void dostuff(int *);
  void f(int *p) {
  int *p2 = p;
  
  #ifdef X
  dostuff(*p2);
  #endif
  
  if (*p2 == 0) {}
  }


http://reviews.llvm.org/D12359



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


r246146 - clang-format: Don't let a leading "template <..>" lead to wrapped initializers.

2015-08-27 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Thu Aug 27 06:59:31 2015
New Revision: 246146

URL: http://llvm.org/viewvc/llvm-project?rev=246146&view=rev
Log:
clang-format: Don't let a leading "template <..>" lead to wrapped initializers.

Before:
  Constructor() : initializer(0) {}

  template 
  Constructor()
  : initializer(0) {}

After:
  Constructor() : initializer(0) {}

  template 
  Constructor() : initializer(0) {}

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=246146&r1=246145&r2=246146&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Aug 27 06:59:31 2015
@@ -158,6 +158,9 @@ bool ContinuationIndenter::mustBreak(con
   getColumnLimit(State))
 return true;
   if (Current.is(TT_CtorInitializerColon) &&
+  (State.Column + State.Line->Last->TotalLength - Current.TotalLength + 2 >
+   getColumnLimit(State) ||
+   State.Stack.back().BreakBeforeParameter) &&
   ((Style.AllowShortFunctionsOnASingleLine != FormatStyle::SFS_All) ||
Style.BreakConstructorInitializersBeforeComma || Style.ColumnLimit != 
0))
 return true;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=246146&r1=246145&r2=246146&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Aug 27 06:59:31 2015
@@ -3519,6 +3519,10 @@ TEST_F(FormatTest, ConstructorInitialize
": Inttializer(FitsOnTheLine) {}",
getLLVMStyleWithColumns(43));
 
+  verifyFormat("template \n"
+   "Constructor() : Initializer(FitsOnTheLine) {}",
+   getLLVMStyleWithColumns(45));
+
   verifyFormat(
   "SomeClass::Constructor()\n"
   ": a(aa), aaa() {}");
@@ -3531,6 +3535,9 @@ TEST_F(FormatTest, ConstructorInitialize
   "SomeClass::Constructor()\n"
   ": aa(aa),\n"
   "  aaa() {}");
+  verifyFormat("Constructor(aa ,\n"
+   "aa )\n"
+   ": aa(aa) {}");
 
   verifyFormat("Constructor()\n"
": (aaa),\n"


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


Re: [PATCH] D11297: PR17829: Functions declared extern "C" with a name matching a mangled C++ function are allowed

2015-08-27 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 33316.
andreybokhanko added a comment.

All (but one) of John McCall's comments fixed.


http://reviews.llvm.org/D11297

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/duplicate-mangled-name.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -237,6 +237,20 @@
   }
 }
 
+void CodeGenModule::addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C) {
+  GlobalValReplacements.push_back(std::make_pair(GV, C));
+}
+
+void CodeGenModule::applyGlobalValReplacements() {
+  for (auto &I : GlobalValReplacements) {
+llvm::GlobalValue *GV = I.first;
+llvm::Constant *C = I.second;
+
+GV->replaceAllUsesWith(C);
+GV->eraseFromParent();
+  }
+}
+
 // This is only used in aliases that we created and we know they have a
 // linear structure.
 static const llvm::GlobalObject *getAliasedGlobal(const llvm::GlobalAlias &GA) {
@@ -339,6 +353,7 @@
 
 void CodeGenModule::Release() {
   EmitDeferred();
+  applyGlobalValReplacements();
   applyReplacements();
   checkAliases();
   EmitCXXGlobalInitFunc();
@@ -1108,9 +1123,16 @@
 llvm::GlobalValue *GV = G.GV;
 G.GV = nullptr;
 
-assert(!GV || GV == GetGlobalValue(getMangledName(D)));
-if (!GV)
-  GV = GetGlobalValue(getMangledName(D));
+// We should call GetAddrOfGlobal with IsForDefinition set to true in order
+// to get GlobalValue with exactly the type we need, not something that
+// might had been created for another decl with the same mangled name but
+// different type.
+// FIXME: Support for variables is not implemented yet.
+if (isa(D.getDecl()))
+  GV = cast(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
+else
+  if (!GV)
+GV = GetGlobalValue(getMangledName(D));
 
 // Check to see if we've already emitted this.  This is necessary
 // for a couple of reasons: first, decls can end up in the
@@ -1541,6 +1563,9 @@
   llvm_unreachable("Invalid argument to EmitGlobalDefinition()");
 }
 
+static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old,
+  llvm::Function *NewFn);
+
 /// GetOrCreateLLVMFunction - If the specified mangled name is not in the
 /// module, create and return an llvm Function with the specified type. If there
 /// is something in the module with the specified name, return it potentially
@@ -1553,7 +1578,8 @@
llvm::Type *Ty,
GlobalDecl GD, bool ForVTable,
bool DontDefer, bool IsThunk,
-   llvm::AttributeSet ExtraAttrs) {
+   llvm::AttributeSet ExtraAttrs,
+   bool IsForDefinition) {
   const Decl *D = GD.getDecl();
 
   // Lookup the entry, lazily creating it if necessary.
@@ -1569,11 +1595,37 @@
 if (D && !D->hasAttr() && !D->hasAttr())
   Entry->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass);
 
-if (Entry->getType()->getElementType() == Ty)
+// If there are two attempts to define the same mangled name, issue a
+// warning.
+//
+// Check that GD is not yet in ExplicitDefinitions is required to make sure
+// that we issue a warning only once.
+if (IsForDefinition && !Entry->isDeclaration() &&
+ExplicitDefinitions.find(GD) == ExplicitDefinitions.end()) {
+  GlobalDecl OtherGD;
+  if (lookupRepresentativeDecl(MangledName, OtherGD)) {
+getDiags().Report(D->getLocation(),
+  diag::warn_duplicate_mangled_name);
+getDiags().Report(OtherGD.getDecl()->getLocation(),
+  diag::note_previous_definition);
+  }
+}
+
+if ((isa(Entry) || isa(Entry)) &&
+(Entry->getType()->getElementType() == Ty)) {
+  // If we are explicitly requested to create a function for a definition,
+  // remember this.
+  if (IsForDefinition)
+ExplicitDefinitions.insert(GD);
+
   return Entry;
+}
 
 // Make sure the result is of the correct type.
-return llvm::ConstantExpr::getBitCast(Entry, Ty->getPointerTo());
+// (If function is requested for a definition, we always need to create a new
+// function, not just return a bitcast.)
+if (!IsForDefinition)
+  return llvm::ConstantExpr::getBitCast(Entry, Ty->getPointerTo());
   }
 
   // This function doesn't have a complete type (for example, the return
@@ -1588,10 +1640,41 @@
 FTy = llvm::FunctionType::get(VoidTy, false);
 IsIncompleteFunction = true;
   }
-  
-  llvm::Function *F = llvm::Function::Create(FTy,
- 

[PATCH] D12405: [clang-format-vs] Format the whole document if nothing is selected

2015-08-27 Thread Beren Minor via cfe-commits
berenm created this revision.
berenm added a reviewer: djasper.
berenm added a subscriber: cfe-commits.

By default, clang-format VS plugin only reformats the selected code.

To reformat the whole document, the user has to select everything before 
calling the reformat shortcut.


http://reviews.llvm.org/D12405

Files:
  tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs

Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -84,8 +84,13 @@
 // We're not in a text view.
 return;
 string text = view.TextBuffer.CurrentSnapshot.GetText();
-int start = 
view.Selection.Start.Position.GetContainingLine().Start.Position;
-int end = 
view.Selection.End.Position.GetContainingLine().End.Position;
+int start = 0;
+int end = text.Length;
+if (!view.Selection.IsEmpty)
+{
+start = 
view.Selection.Start.Position.GetContainingLine().Start.Position;
+end = 
view.Selection.End.Position.GetContainingLine().End.Position;
+}
 int length = end - start;
 // clang-format doesn't support formatting a range that starts at 
the end
 // of the file.


Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -84,8 +84,13 @@
 // We're not in a text view.
 return;
 string text = view.TextBuffer.CurrentSnapshot.GetText();
-int start = view.Selection.Start.Position.GetContainingLine().Start.Position;
-int end = view.Selection.End.Position.GetContainingLine().End.Position;
+int start = 0;
+int end = text.Length;
+if (!view.Selection.IsEmpty)
+{
+start = view.Selection.Start.Position.GetContainingLine().Start.Position;
+end = view.Selection.End.Position.GetContainingLine().End.Position;
+}
 int length = end - start;
 // clang-format doesn't support formatting a range that starts at the end
 // of the file.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12375: [PATCH] Relax parse ordering rules for attributes

2015-08-27 Thread Aaron Ballman via cfe-commits
aaron.ballman updated this revision to Diff 33318.
aaron.ballman added a comment.

I've updated the patch to disallow reordering of C++11 attributes with relation 
to other attribute syntaxes. Additionally, if there is a reordering issue 
found, we now warn the user.


http://reviews.llvm.org/D12375

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Parse/Parser.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/Parser.cpp
  test/Parser/attr-order.cpp

Index: test/Parser/attr-order.cpp
===
--- test/Parser/attr-order.cpp
+++ test/Parser/attr-order.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -std=c++14 -verify %s
+
+struct [[]] __attribute__((lockable)) __declspec(dllexport) A {}; // ok
+struct [[]] __declspec(dllexport) __attribute__((lockable)) B {}; // ok
+struct [[]] [[]] __declspec(dllexport) __attribute__((lockable)) C {}; // ok
+struct __declspec(dllexport) [[]] __attribute__((lockable)) D {}; // expected-warning {{C++11 attributes should precede all other attributes in an attribute list}}
+struct __declspec(dllexport) __attribute__((lockable)) [[]] E {}; // expected-warning {{C++11 attributes should precede all other attributes in an attribute list}}
+struct __attribute__((lockable)) __declspec(dllexport) [[]] F {}; // expected-warning {{C++11 attributes should precede all other attributes in an attribute list}}
+struct __attribute__((lockable)) [[]] __declspec(dllexport) G {}; // expected-warning {{C++11 attributes should precede all other attributes in an attribute list}}
+struct [[]] __attribute__((lockable)) [[]] __declspec(dllexport) H {}; // expected-warning {{C++11 attributes should precede all other attributes in an attribute list}}
+
+[[noreturn]] __attribute__((cdecl)) __declspec(dllexport) void a(); // ok
+[[noreturn]] __declspec(dllexport) __attribute__((cdecl)) void b(); // ok
+[[]] [[noreturn]] __attribute__((cdecl)) __declspec(dllexport) void c(); // ok
+
+// FIXME: The following cases should report the same warning diagnostic as
+// above. However, that requires changing the way we parse decl specifiers vs
+// top-level declarations. See PR24559 for more details.
+__declspec(dllexport) [[noreturn]] __attribute__((cdecl)) void d(); // expected-error {{an attribute list cannot appear here}}
+__declspec(dllexport) __attribute__((cdecl)) [[noreturn]] void e(); // expected-error {{an attribute list cannot appear here}}
+__attribute__((cdecl)) __declspec(dllexport) [[noreturn]] void f(); // expected-error {{an attribute list cannot appear here}}
+__attribute__((cdecl)) [[noreturn]] __declspec(dllexport) void g(); // expected-error {{an attribute list cannot appear here}}
+[[noreturn]] __attribute__((cdecl)) [[]] __declspec(dllexport) void h(); // expected-error {{an attribute list cannot appear here}}
Index: lib/Parse/Parser.cpp
===
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -586,8 +586,7 @@
   }
 
   ParsedAttributesWithRange attrs(AttrFactory);
-  MaybeParseCXX11Attributes(attrs);
-  MaybeParseMicrosoftAttributes(attrs);
+  MaybeParseAttributes(PAKM_CXX11 | PAKM_Microsoft, attrs);
 
   Result = ParseExternalDeclaration(attrs);
   return false;
@@ -1962,8 +1961,7 @@
   // FIXME: Support module import within __if_exists?
   while (Tok.isNot(tok::r_brace) && !isEofOrEom()) {
 ParsedAttributesWithRange attrs(AttrFactory);
-MaybeParseCXX11Attributes(attrs);
-MaybeParseMicrosoftAttributes(attrs);
+MaybeParseAttributes(PAKM_CXX11 | PAKM_Microsoft, attrs);
 DeclGroupPtrTy Result = ParseExternalDeclaration(attrs);
 if (Result && !getCurScope()->getParent())
   Actions.getASTConsumer().HandleTopLevelDecl(Result.get());
Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -1090,14 +1090,10 @@
 SourceLocation RParenLoc = T.getCloseLocation();
 DeclEndLoc = RParenLoc;
 
-// GNU-style attributes must be parsed before the mutable specifier to be
-// compatible with GCC.
-MaybeParseGNUAttributes(Attr, &DeclEndLoc);
+// GNU-style and __declspec attributes must be parsed before the mutable
+// specifier to be compatible with GCC/MSVC.
+MaybeParseAttributes(PAKM_GNU | PAKM_Declspec, Attr, &DeclEndLoc);
 
-// MSVC-style attributes must be parsed before the mutable specifier to be
-// compatible with MSVC.
-MaybeParseMicrosoftDeclSpecs(Attr, &DeclEndLoc);
-
 // Parse 'mutable'[opt].
 SourceLocation MutableLoc;
 if (TryConsumeToken(tok::kw_mutable, MutableLoc))
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -212,8 +212,7 @@
   if (index == Ident.size()) {
 while (Tok.

Re: [PATCH] D11297: PR17829: Functions declared extern "C" with a name matching a mangled C++ function are allowed

2015-08-27 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked 3 inline comments as done.
andreybokhanko added a comment.

John,

Thank you for the review!

All your comments but one are fixed. See below for details on the single one I 
didn't manage to get fixed.

Andrey



Comment at: lib/CodeGen/CodeGenModule.h:354
@@ +353,3 @@
+  /// call).
+  llvm::DenseSet ExplicitDefinitions;
+

Checking that a GlobalDecl is not in ExplicitDefinitions yet is actually 
required to avoid printing multiple identical warnings.

In my example:

```
1: struct T {
2:   ~T() {}
3: };
4: 
5: extern "C" void _ZN1TD1Ev();
6: 
7: int main() {
8:   _ZN1TD1Ev();
9:   T t;
10: }
```

~T() is added to the list of deferred decls twice. Judging from this comment in 
"EmitDeferred" method:

// Check to see if we've already emitted this.  This is necessary
// for a couple of reasons: first, decls can end up in the
// deferred-decls queue multiple times, and second, decls can end
// up with definitions in unusual ways (e.g. by an extern inline
// function acquiring a strong function redefinition).  Just
// ignore these cases.

this is pretty normal ("decls can end up in the deferred-decls queue multiple 
times").

This means that we can call "GetOrCreateLLVMFunction"(..., 
/*IsForDefinition*/=true) for duplicated decls several times, which is fine in 
general, *but* will print the "duplicated mangled names" diagnostic multiple 
times as well -- unless we check that we already printed a warning on 
duplicated mangled names for given decl.

As for not emitting diagnostics for different globals -- this won't happen, as 
we will call "GetOrCreateLLVMFunction" at least once for each global with a 
definition, and thus, will print a warning for everyone.

I thought really hard (honestly!) on how to prevent duplicated diagnostics 
without usage of an additional set, but didn't found any solution. If you have 
any hints here, they would be much appreciated.


http://reviews.llvm.org/D11297



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


Re: [PATCH] D12405: [clang-format-vs] Format the whole document if nothing is selected

2015-08-27 Thread Daniel Jasper via cfe-commits
If nothing is selected, clang-format should format the current line.. At
least that's the intended behavior. Doesn't it do that?
On Aug 27, 2015 3:21 PM, "Beren Minor"  wrote:

> berenm created this revision.
> berenm added a reviewer: djasper.
> berenm added a subscriber: cfe-commits.
>
> By default, clang-format VS plugin only reformats the selected code.
>
> To reformat the whole document, the user has to select everything before
> calling the reformat shortcut.
>
>
> http://reviews.llvm.org/D12405
>
> Files:
>   tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
>
> Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
> ===
> --- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
> +++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
> @@ -84,8 +84,13 @@
>  // We're not in a text view.
>  return;
>  string text = view.TextBuffer.CurrentSnapshot.GetText();
> -int start =
> view.Selection.Start.Position.GetContainingLine().Start.Position;
> -int end =
> view.Selection.End.Position.GetContainingLine().End.Position;
> +int start = 0;
> +int end = text.Length;
> +if (!view.Selection.IsEmpty)
> +{
> +start =
> view.Selection.Start.Position.GetContainingLine().Start.Position;
> +end =
> view.Selection.End.Position.GetContainingLine().End.Position;
> +}
>  int length = end - start;
>  // clang-format doesn't support formatting a range that
> starts at the end
>  // of the file.
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12405: [clang-format-vs] Format the whole document if nothing is selected

2015-08-27 Thread Aaron Ballman via cfe-commits
On Thu, Aug 27, 2015 at 9:34 AM, Daniel Jasper via cfe-commits
 wrote:
> If nothing is selected, clang-format should format the current line.. At
> least that's the intended behavior. Doesn't it do that?

It currently reformats the current line (possibly extended if the
expression spans multiple lines) for me.

~Aaron

>
> On Aug 27, 2015 3:21 PM, "Beren Minor"  wrote:
>>
>> berenm created this revision.
>> berenm added a reviewer: djasper.
>> berenm added a subscriber: cfe-commits.
>>
>> By default, clang-format VS plugin only reformats the selected code.
>>
>> To reformat the whole document, the user has to select everything before
>> calling the reformat shortcut.
>>
>>
>> http://reviews.llvm.org/D12405
>>
>> Files:
>>   tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
>>
>> Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
>> ===
>> --- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
>> +++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
>> @@ -84,8 +84,13 @@
>>  // We're not in a text view.
>>  return;
>>  string text = view.TextBuffer.CurrentSnapshot.GetText();
>> -int start =
>> view.Selection.Start.Position.GetContainingLine().Start.Position;
>> -int end =
>> view.Selection.End.Position.GetContainingLine().End.Position;
>> +int start = 0;
>> +int end = text.Length;
>> +if (!view.Selection.IsEmpty)
>> +{
>> +start =
>> view.Selection.Start.Position.GetContainingLine().Start.Position;
>> +end =
>> view.Selection.End.Position.GetContainingLine().End.Position;
>> +}
>>  int length = end - start;
>>  // clang-format doesn't support formatting a range that
>> starts at the end
>>  // of the file.
>>
>>
>
> ___
> 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] D12405: [clang-format-vs] Format the whole document if nothing is selected

2015-08-27 Thread Beren Minor via cfe-commits
Alright, my bad. It does indeed.

I was trying to add a "Reformat all on save" feature in the plugin, and
after struggling with VSSDK I thought this would be an easy first step.

--
Beren Minor

On Thu, Aug 27, 2015 at 3:36 PM, Aaron Ballman 
wrote:

> On Thu, Aug 27, 2015 at 9:34 AM, Daniel Jasper via cfe-commits
>  wrote:
> > If nothing is selected, clang-format should format the current line.. At
> > least that's the intended behavior. Doesn't it do that?
>
> It currently reformats the current line (possibly extended if the
> expression spans multiple lines) for me.
>
> ~Aaron
>
> >
> > On Aug 27, 2015 3:21 PM, "Beren Minor" 
> wrote:
> >>
> >> berenm created this revision.
> >> berenm added a reviewer: djasper.
> >> berenm added a subscriber: cfe-commits.
> >>
> >> By default, clang-format VS plugin only reformats the selected code.
> >>
> >> To reformat the whole document, the user has to select everything before
> >> calling the reformat shortcut.
> >>
> >>
> >> http://reviews.llvm.org/D12405
> >>
> >> Files:
> >>   tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
> >>
> >> Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
> >> ===
> >> --- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
> >> +++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
> >> @@ -84,8 +84,13 @@
> >>  // We're not in a text view.
> >>  return;
> >>  string text = view.TextBuffer.CurrentSnapshot.GetText();
> >> -int start =
> >> view.Selection.Start.Position.GetContainingLine().Start.Position;
> >> -int end =
> >> view.Selection.End.Position.GetContainingLine().End.Position;
> >> +int start = 0;
> >> +int end = text.Length;
> >> +if (!view.Selection.IsEmpty)
> >> +{
> >> +start =
> >> view.Selection.Start.Position.GetContainingLine().Start.Position;
> >> +end =
> >> view.Selection.End.Position.GetContainingLine().End.Position;
> >> +}
> >>  int length = end - start;
> >>  // clang-format doesn't support formatting a range that
> >> starts at the end
> >>  // of the file.
> >>
> >>
> >
> > ___
> > 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] D12405: [clang-format-vs] Format the whole document if nothing is selected

2015-08-27 Thread Daniel Jasper via cfe-commits
I see.. I think we'll want to keep the current behavior there..
On Aug 27, 2015 3:38 PM, "Beren Minor"  wrote:

> Alright, my bad. It does indeed.
>
> I was trying to add a "Reformat all on save" feature in the plugin, and
> after struggling with VSSDK I thought this would be an easy first step.
>
> --
> Beren Minor
>
> On Thu, Aug 27, 2015 at 3:36 PM, Aaron Ballman 
> wrote:
>
>> On Thu, Aug 27, 2015 at 9:34 AM, Daniel Jasper via cfe-commits
>>  wrote:
>> > If nothing is selected, clang-format should format the current line.. At
>> > least that's the intended behavior. Doesn't it do that?
>>
>> It currently reformats the current line (possibly extended if the
>> expression spans multiple lines) for me.
>>
>> ~Aaron
>>
>> >
>> > On Aug 27, 2015 3:21 PM, "Beren Minor" 
>> wrote:
>> >>
>> >> berenm created this revision.
>> >> berenm added a reviewer: djasper.
>> >> berenm added a subscriber: cfe-commits.
>> >>
>> >> By default, clang-format VS plugin only reformats the selected code.
>> >>
>> >> To reformat the whole document, the user has to select everything
>> before
>> >> calling the reformat shortcut.
>> >>
>> >>
>> >> http://reviews.llvm.org/D12405
>> >>
>> >> Files:
>> >>   tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
>> >>
>> >> Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
>> >> ===
>> >> --- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
>> >> +++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
>> >> @@ -84,8 +84,13 @@
>> >>  // We're not in a text view.
>> >>  return;
>> >>  string text = view.TextBuffer.CurrentSnapshot.GetText();
>> >> -int start =
>> >> view.Selection.Start.Position.GetContainingLine().Start.Position;
>> >> -int end =
>> >> view.Selection.End.Position.GetContainingLine().End.Position;
>> >> +int start = 0;
>> >> +int end = text.Length;
>> >> +if (!view.Selection.IsEmpty)
>> >> +{
>> >> +start =
>> >> view.Selection.Start.Position.GetContainingLine().Start.Position;
>> >> +end =
>> >> view.Selection.End.Position.GetContainingLine().End.Position;
>> >> +}
>> >>  int length = end - start;
>> >>  // clang-format doesn't support formatting a range that
>> >> starts at the end
>> >>  // of the file.
>> >>
>> >>
>> >
>> > ___
>> > 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] D12368: Add a clang release note about raising the minimum Windows version for the next major release

2015-08-27 Thread Greg Bedwell via cfe-commits
gbedwell added a comment.

In http://reviews.llvm.org/D12368#233680, @hans wrote:

> Committed in r246090.


Thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D12368



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


[PATCH] D12406: [Analyzer] Add -analyzer-config option for function size the inliner considers as large

2015-08-27 Thread Sean Eveson via cfe-commits
seaneveson created this revision.
seaneveson added a subscriber: cfe-commits.

Dear All,

I would like to propose a small patch to add an option (-analyzer-config 
min-blocks-for-inline-large=14) to control the function size the inliner 
considers as large, in relation to "max-times-inline-large". In my patch the 
option defaults to the original hard coded behaviour, which I believe should be 
adjustable with the other inlining settings.

The analyzer-config test has been modified so that the analyzer will reach the 
getMinBlocksForInlineLarge() method and store the result in the ConfigTable, to 
ensure it is dumped by the debug checker.

Regards,

Sean Eveson
SN Systems - Sony Computer Entertainment Group


http://reviews.llvm.org/D12406

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp

Index: test/Analysis/analyzer-config.cpp
===
--- test/Analysis/analyzer-config.cpp
+++ test/Analysis/analyzer-config.cpp
@@ -1,8 +1,14 @@
-// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper > %t 2>&1
+// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper -Xclang -analyzer-max-loop -Xclang 34 > %t 2>&1
 // RUN: FileCheck --input-file=%t %s
 
 void bar() {}
-void foo() { bar(); }
+void foo() { 
+  // Call bar 33 times so max-times-inline-large is met and
+  // min-blocks-for-inline-large is checked
+  for (int i = 0; i < 34; ++i) {
+bar();
+  }
+}
 
 class Foo {
 public:
@@ -26,7 +32,8 @@
 // CHECK-NEXT: max-inlinable-size = 50
 // CHECK-NEXT: max-nodes = 15
 // CHECK-NEXT: max-times-inline-large = 32
+// CHECK-NEXT: min-blocks-for-inline-large = 14
 // CHECK-NEXT: mode = deep
 // CHECK-NEXT: region-store-small-struct-limit = 2
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 17
+// CHECK-NEXT: num-entries = 18
Index: test/Analysis/analyzer-config.c
===
--- test/Analysis/analyzer-config.c
+++ test/Analysis/analyzer-config.c
@@ -1,8 +1,14 @@
-// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper > %t 2>&1
+// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper -Xclang -analyzer-max-loop -Xclang 34 > %t 2>&1
 // RUN: FileCheck --input-file=%t %s
 
 void bar() {}
-void foo() { bar(); }
+void foo() { 
+  // Call bar 33 times so max-times-inline-large is met and
+  // min-blocks-for-inline-large is checked
+  for (int i = 0; i < 34; ++i) {
+bar();
+  }
+}
 
 // CHECK: [config]
 // CHECK-NEXT: cfg-conditional-static-initializers = true
@@ -15,8 +21,9 @@
 // CHECK-NEXT: max-inlinable-size = 50
 // CHECK-NEXT: max-nodes = 15
 // CHECK-NEXT: max-times-inline-large = 32
+// CHECK-NEXT: min-blocks-for-inline-large = 14
 // CHECK-NEXT: mode = deep
 // CHECK-NEXT: region-store-small-struct-limit = 2
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 12
+// CHECK-NEXT: num-entries = 13
 
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -870,7 +870,7 @@
   // Do not inline large functions too many times.
   if ((Engine.FunctionSummaries->getNumTimesInlined(D) >
Opts.getMaxTimesInlineLarge()) &&
-  CalleeCFG->getNumBlockIDs() > 13) {
+  CalleeCFG->getNumBlockIDs() >= Opts.getMinBlocksForInlineLarge()) {
 NumReachedInlineCountMax++;
 return false;
   }
Index: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -295,6 +295,13 @@
   return MaxTimesInlineLarge.getValue();
 }
 
+unsigned AnalyzerOptions::getMinBlocksForInlineLarge() {
+  if (!MinBlocksForInlineLarge.hasValue())
+MinBlocksForInlineLarge = getOptionAsInteger("min-blocks-for-inline-large",
+ 14);
+  return MinBlocksForInlineLarge.getValue();
+}
+
 unsigned AnalyzerOptions::getMaxNodesPerTopLevelFunction() {
   if (!MaxNodesPerTopLevelFunction.hasValue()) {
 int DefaultValue = 0;
Index: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===
--- include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -253,6 +253,9 @@
   /// \sa getMaxTimesInlineLarge
   Optional MaxTimesInlineLarge;
 
+  /// \sa getMinBlocksForInlineLarge
+  Optional MinBlocksForInlineLarge;
+
   /// \

[libcxx] r246150 - Remove a switch statement, and replace with a bunch of ifs to silence a warning about 'all the enumeration values covered'. No functional change.

2015-08-27 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Aug 27 09:37:22 2015
New Revision: 246150

URL: http://llvm.org/viewvc/llvm-project?rev=246150&view=rev
Log:
Remove a switch statement, and replace with a bunch of ifs to silence a warning 
about 'all the enumeration values covered'. No functional change.

Modified:
libcxx/trunk/include/locale

Modified: libcxx/trunk/include/locale
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=246150&r1=246149&r2=246150&view=diff
==
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Thu Aug 27 09:37:22 2015
@@ -4316,18 +4316,9 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::s
 int __width = __cv_->encoding();
 if (__cv_ == 0 || __bufptr_ == 0 || (__width <= 0 && __off != 0) || sync())
 return pos_type(off_type(-1));
-// __width > 0 || __off == 0
-switch (__way)
-{
-case ios_base::beg:
-break;
-case ios_base::cur:
-break;
-case ios_base::end:
-break;
-default:
+// __width > 0 || __off == 0, now check __way
+if (__way != ios_base::beg && __way != ios_base::cur && __way != 
ios_base::end)
 return pos_type(off_type(-1));
-}
 pos_type __r = __bufptr_->pubseekoff(__width * __off, __way, __om);
 __r.state(__st_);
 return __r;


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


Re: [PATCH] D12355: [libcxx] Optimize away unneeded length calculation in basic_string::compare(const char*)

2015-08-27 Thread Marshall Clow via cfe-commits
mclow.lists added inline comments.


Comment at: include/string:3801
@@ -3799,1 +3800,3 @@
+if (__lhs_len != __rhs.size()) return false;
+return _Traits::compare(__rhs.data(), __lhs, _VSTD::min(__lhs_len, 
__rhs.size())) == 0;
 }

If the lengths are the same (and they are), you don't need the `min` of them


Comment at: include/string:3802
@@ -3799,2 +3801,3 @@
+return _Traits::compare(__rhs.data(), __lhs, _VSTD::min(__lhs_len, 
__rhs.size())) == 0;
 }
 

Also, you should not call `traits::compare` here. You should call 
`__rhs.compare(0, npos, __lhs, __lhs_len)`

which is what `__rhs.compare(__lhs)` does.



http://reviews.llvm.org/D12355



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


Re: [PATCH] D11832: [Patch] [Analyzer] false positive: Potential leak connected with memcpy (PR 22954)

2015-08-27 Thread pierre gousseau via cfe-commits
pgousseau updated this revision to Diff 33326.
pgousseau added a comment.

Following Devin's review:

Modified 'IsFirstBufInBound()' to return a bool instead of a state.
Removed redundant checks in 'IsFirstBufInBound'.
Added tests to exercise 'IsFirstBufInBound' more.
Removed if/else to avoid indentation.
Removed copy paste error.
Inverted guards in 'VisitCluster' to decrease indentation.
Added comments regarding 0 elements/0-sized elements arrays.
Fixed unused var warning with isa instead of dyn_cast.
Fixed test typo and added sizeof test.

Please let me know if this is an acceptable change ?

Regards,

Pierre


http://reviews.llvm.org/D11832

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/pr22954.c

Index: test/Analysis/pr22954.c
===
--- /dev/null
+++ test/Analysis/pr22954.c
@@ -0,0 +1,697 @@
+// Given code 'struct aa { char s1[4]; char * s2;} a; memcpy(a.s1, ...);',
+// this test checks that the CStringChecker only invalidates the destination buffer array a.s1 (instead of a.s1 and a.s2).
+// At the moment the whole of the destination array content is invalidated.
+// If a.s1 region has a symbolic offset, the whole region of 'a' is invalidated.
+// Specific triple set to test structures of size 0.
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s
+
+typedef __typeof(sizeof(int)) size_t;
+
+char *strdup(const char *s);
+void free(void *);
+void *memcpy(void *dst, const void *src, size_t n); // expected-note{{passing argument to parameter 'dst' here}}
+void *malloc(size_t n);
+
+void clang_analyzer_eval(int);
+
+struct aa {
+char s1[4];
+char *s2;
+};
+
+// Test different types of structure initialisation.
+int f0() {
+  struct aa a0 = {{1, 2, 3, 4}, 0};
+  a0.s2 = strdup("hello");
+  char input[] = {'a', 'b', 'c', 'd'};
+  memcpy(a0.s1, input, 4);
+  clang_analyzer_eval(a0.s1[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a0.s1[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a0.s1[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a0.s1[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a0.s2 == 0); // expected-warning{{UNKNOWN}}
+  free(a0.s2); // no warning
+  return 0;
+}
+
+int f1() {
+  struct aa a1;
+  a1.s2 = strdup("hello");
+  char input[] = {'a', 'b', 'c', 'd'};
+  memcpy(a1.s1, input, 4);
+  clang_analyzer_eval(a1.s1[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a1.s1[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a1.s1[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a1.s1[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a1.s2 == 0); // expected-warning{{UNKNOWN}}
+  free(a1.s2); // no warning
+  return 0;
+}
+
+int f2() {
+  struct aa a2 = {{1, 2}};
+  a2.s2 = strdup("hello");
+  char input[] = {'a', 'b', 'c', 'd'};
+  memcpy(a2.s1, input, 4);
+  clang_analyzer_eval(a2.s1[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a2.s1[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a2.s1[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a2.s1[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a2.s2 == 0); // expected-warning{{UNKNOWN}}
+  free(a2.s2); // no warning
+  return 0;
+}
+
+int f3() {
+  struct aa a3 = {{1, 2, 3, 4}, 0};
+  a3.s2 = strdup("hello");
+  char input[] = {'a', 'b', 'c', 'd'};
+  int * dest = (int*)a3.s1;
+  memcpy(dest, input, 4);
+  clang_analyzer_eval(a3.s1[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a3.s1[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a3.s1[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a3.s1[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a3.s2 == 0); // expected-warning{{UNKNOWN}}
+  free(a3.s2); // no warning
+  return 0;
+}
+
+struct bb {
+  struct aa a;
+  char * s2;
+};
+
+int f4() {
+  struct bb b0 = {{1, 2, 3, 4}, 0};
+  b0.s2 = strdup("hello");
+  b0.a.s2 = strdup("hola");
+  char input[] = {'a', 'b', 'c', 'd'};
+  char * dest = (char*)(b0.a.s1);
+  memcpy(dest, input, 4);
+  clang_analyzer_eval(b0.a.s1[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b0.a.s1[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b0.a.s1[2] == 'c'); //

Re: [PATCH] D9639: Do not include pthread.h and sched.h when threads are disabled

2015-08-27 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

@blastrock have you committed this yet?


http://reviews.llvm.org/D9639



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


Re: [libcxx] r246150 - Remove a switch statement, and replace with a bunch of ifs to silence a warning about 'all the enumeration values covered'. No functional change.

2015-08-27 Thread David Blaikie via cfe-commits
On Aug 27, 2015 7:38 AM, "Marshall Clow via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:
>
> Author: marshall
> Date: Thu Aug 27 09:37:22 2015
> New Revision: 246150
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246150&view=rev
> Log:
> Remove a switch statement, and replace with a bunch of ifs to silence a
warning about 'all the enumeration values covered'. No functional change.

Just for the record you can also supports this'd warning by casting the
switch expression to an integer type. (If I've correctly understood the
warning your getting)

>
> Modified:
> libcxx/trunk/include/locale
>
> Modified: libcxx/trunk/include/locale
> URL:
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=246150&r1=246149&r2=246150&view=diff
>
==
> --- libcxx/trunk/include/locale (original)
> +++ libcxx/trunk/include/locale Thu Aug 27 09:37:22 2015
> @@ -4316,18 +4316,9 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::s
>  int __width = __cv_->encoding();
>  if (__cv_ == 0 || __bufptr_ == 0 || (__width <= 0 && __off != 0) ||
sync())
>  return pos_type(off_type(-1));
> -// __width > 0 || __off == 0
> -switch (__way)
> -{
> -case ios_base::beg:
> -break;
> -case ios_base::cur:
> -break;
> -case ios_base::end:
> -break;
> -default:
> +// __width > 0 || __off == 0, now check __way
> +if (__way != ios_base::beg && __way != ios_base::cur && __way !=
ios_base::end)
>  return pos_type(off_type(-1));
> -}
>  pos_type __r = __bufptr_->pubseekoff(__width * __off, __way, __om);
>  __r.state(__st_);
>  return __r;
>
>
> ___
> 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] D12358: [Analyzer] Handling constant bound loops

2015-08-27 Thread Sean Eveson via cfe-commits
seaneveson added a comment.

In http://reviews.llvm.org/D12358#233983, @zaks.anna wrote:

> This will leave us in a state that is wrong and will likely lead to false 
> positives and inconsistencies, avoiding which is extremely important.


I accept that my current patch is not a comprehensive solution to the problem 
and that it may introduce false positives, however I do think it is an 
improvement, where it is preferable to have false positives over doing no 
analysis after the loop.

In http://reviews.llvm.org/D12358#234016, @krememek wrote:

> My recommendation is that we still unroll loops a couple times, getting full 
> precision, and then employ a widening technique like the ones being discussed 
> to allow the last loop iteration to act as the last one, but as a 
> conservative over-approximation.


In the patch, constant bound loops are unrolled with the “max-loop” setting 
(default of 4), (i = 0, 1, 2, 99) rather than (i = 0, 1, 2, 3); as such, we 
analyze the same number of paths through the loop body.

In my experience, constant bound loops are normally used to make simple 
modifications to fixed length collections of data, I think the behaviour of the 
majority of these loops will be represented by the first and last iteration.

In http://reviews.llvm.org/D12358#234016, @krememek wrote:

> Another, more principled hack, would be to look at all DeclRefExprs within a 
> loop and invalidate all memory in the cone-of-influence of those variables 
> (i.e., values they point to, etc.), but that's it.


Could this be done easily with a visitor and the existing invalidate methods? 
In cases where the anaylzer is unsure which values might be modified by the 
loop, it could fall back to invalidating all the values in the state.

In http://reviews.llvm.org/D12358#234016, @krememek wrote:

> Then there is the problem of called functions within the loop, as they won't 
> be analyzed. Those could interfere with the ability of a checker to do its 
> job.
>
> My recommendation is that we still unroll loops a couple times, getting full 
> precision, and then employ a widening technique like the ones being discussed 
> to allow the last loop iteration to act as the last one, but as a 
> conservative over-approximation.


Wouldn’t widening before the last iteration result in more paths being explored 
than additional unrolling? i.e. as a result of values in conditions being 
unknown.

Regards,

Sean Eveson
SN Systems - Sony Computer Entertainment Group


http://reviews.llvm.org/D12358



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


Re: [PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk

2015-08-27 Thread Daniel Jasper via cfe-commits
djasper added a comment.

I know nothing of Visual Studio, so I have added better reviewers.


http://reviews.llvm.org/D12407



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


Re: [PATCH] D12402: PR24595: clang-cl fails to compile vswriter.h header from Windows SDK 8.1 in 32 bit mode

2015-08-27 Thread Reid Kleckner via cfe-commits
rnk added a comment.

MSVC appears to ignore __stdcall on virtual destructors, and I think the 
correct fix is for us to do the same.

See this test case:

  $ cat t.cpp
  struct A { virtual __stdcall ~A(); };
  A::~A() {}
  $ cl -c t.cpp
  Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  t.cpp
  $ dumpbin /symbols t.obj | grep ~A
  00B  SECT3  notype ()External | ??1A@@UAE@XZ (public: virtual 
__thiscall A::~A(void))

Notice the "__thiscall" part of the symbol name. The assembly also shows that 
it pulls 'this' from ecx.


http://reviews.llvm.org/D12402



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


Re: [PATCH] D12278: [X86] Add MSVC-compatible intrinsics for clac, stac, lgdt and sgdt

2015-08-27 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: lib/Headers/Intrin.h:961
@@ +960,3 @@
+static __inline__ void __DEFAULT_FN_ATTRS _lgdt(void *__ptr) {
+  __builtin_ia32_lgdt(__ptr);
+}

compnerd wrote:
> mkuper wrote:
> > compnerd wrote:
> > > Why does this need a builtin?  Is an inline assembly block using lgdt 
> > > insufficient for some reason?
> > I think using a builtin is, generally, cleaner.
> > I'm ok with using inline asm (and abandoning the LLVM part of the patch), 
> > if that's the more popular option.
> Yes, that is the preference in my experience.  Please do switch to the inline 
> asm option.
I guess the distinction between these operations and others is that it isn't 
useful for the compiler to try to reason about these instructions, in the way 
that it's useful for it to reason about vector intrinsics. I'm happy with 
either LLVM intrinsics or inline asm.


http://reviews.llvm.org/D12278



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


Re: [PATCH] D11433: [Static Analyzer] Make NonNullParamChecker emit implicit null dereference events.

2015-08-27 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 5.
xazax.hun added a comment.

- Updated to latest trunk.
- Added a new field to the event with documentation.
- Rebased the patch on the top of nullability checker.
- Added covered cases to the nullability checker tests.


http://reviews.llvm.org/D11433

Files:
  include/clang/StaticAnalyzer/Core/Checker.h
  lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
  lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  test/Analysis/nullability.mm

Index: test/Analysis/nullability.mm
===
--- test/Analysis/nullability.mm
+++ test/Analysis/nullability.mm
@@ -50,6 +50,8 @@
 
 template  T *eraseNullab(T *p) { return p; }
 
+void takesAttrNonnull(Dummy *p) __attribute((nonnull(1)));
+
 void testBasicRules() {
   Dummy *p = returnsNullable();
   int *ptr = returnsNullableInt();
@@ -73,10 +75,8 @@
 Dummy dd(d);
 break;
   }
-  // Here the copy constructor is called, so a reference is initialized with the
-  // value of p. No ImplicitNullDereference event will be dispatched for this
-  // case. A followup patch is expected to fix this in NonNullParamChecker.
-  default: { Dummy d = *p; } break; // No warning.
+  case 5: takesAttrNonnull(p); break; // expected-warning {{Nullable pointer is passed to}}
+  default: { Dummy d = *p; } break; // expected-warning {{Nullable pointer is dereferenced}}
   }
   if (p) {
 takesNonnull(p);
Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -335,7 +335,10 @@
   if (Filter.CheckNullableDereferenced &&
   TrackedNullability->getValue() == Nullability::Nullable) {
 BugReporter &BR = *Event.BR;
-reportBug(ErrorKind::NullableDereferenced, Event.SinkNode, Region, BR);
+if (Event.IsDirectDereference)
+  reportBug(ErrorKind::NullableDereferenced, Event.SinkNode, Region, BR);
+else
+  reportBug(ErrorKind::NullablePassedToNonnull, Event.SinkNode, Region, BR);
   }
 }
 
Index: lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
@@ -28,7 +28,7 @@
 
 namespace {
 class NonNullParamChecker
-  : public Checker< check::PreCall > {
+  : public Checker< check::PreCall, EventDispatcher > {
   mutable std::unique_ptr BTAttrNonNull;
   mutable std::unique_ptr BTNullRefArg;
 
@@ -139,26 +139,34 @@
 ProgramStateRef stateNotNull, stateNull;
 std::tie(stateNotNull, stateNull) = CM.assumeDual(state, *DV);
 
-if (stateNull && !stateNotNull) {
-  // Generate an error node.  Check for a null node in case
-  // we cache out.
-  if (ExplodedNode *errorNode = C.generateSink(stateNull)) {
+if (stateNull) {
+  if (!stateNotNull) {
+// Generate an error node.  Check for a null node in case
+// we cache out.
+if (ExplodedNode *errorNode = C.generateSink(stateNull)) {
 
-std::unique_ptr R;
-if (haveAttrNonNull)
-  R = genReportNullAttrNonNull(errorNode, ArgE);
-else if (haveRefTypeParam)
-  R = genReportReferenceToNullPointer(errorNode, ArgE);
+  std::unique_ptr R;
+  if (haveAttrNonNull)
+R = genReportNullAttrNonNull(errorNode, ArgE);
+  else if (haveRefTypeParam)
+R = genReportReferenceToNullPointer(errorNode, ArgE);
 
-// Highlight the range of the argument that was null.
-R->addRange(Call.getArgSourceRange(idx));
+  // Highlight the range of the argument that was null.
+  R->addRange(Call.getArgSourceRange(idx));
 
-// Emit the bug report.
-C.emitReport(std::move(R));
-  }
+  // Emit the bug report.
+  C.emitReport(std::move(R));
+}
 
-  // Always return.  Either we cached out or we just emitted an error.
-  return;
+// Always return.  Either we cached out or we just emitted an error.
+return;
+  }
+  if (ExplodedNode *N = C.generateSink(stateNull)) {
+ImplicitNullDerefEvent event = {
+V, false, N, &C.getBugReporter(),
+/*IsDirectDereference=*/haveRefTypeParam};
+dispatchEvent(event);
+  }
 }
 
 // If a pointer value passed the check we should assume that it is
Index: lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
+++ lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
@@ -220,7 +220,8 @@
 // null or not-null.  Record the error node as an "implicit" null
 // dereference.
 if (ExplodedNode *N = C.generateSink(nullState)) {
-

Re: [PATCH] D12358: [Analyzer] Handling constant bound loops

2015-08-27 Thread Ted Kremenek via cfe-commits




> On Aug 27, 2015, at 8:57 AM, Sean Eveson  wrote:
> 
> I accept that my current patch is not a comprehensive solution to the problem 
> and that it may introduce false positives, however I do think it is an 
> improvement, where it is preferable to have false positives over doing no 
> analysis after the loop.

Hi Sean,

I'll take another closer look at your patch tonight and come back with more 
feedback. I completely understand your eagerness to push this forward.  I don't 
think that anybody disagrees with you that we want to do analysis of more code, 
especially the code that's currently not being analyzed all because of our 
current handling of loops. That said, if the solution is not precise enough it 
may cause a flurry of false positives, which then renders the efficacy of the 
tool impotent.  It doesn't matter if the tool has more coverage if it produces 
a high-volume of false positives.  I'm not saying that your patch will result 
in that happening all the time, but we should not just land the patch without 
understanding its implications.  I also think that with some relatively small 
enhancements most of our concerns can be addressed.

Because of the way the analyzer works, false positives often happen because of 
"correlated conditions" that are improperly truck by the analyzer.  
Essentially, if an event that happened earlier in a path would have had an 
anti-correlation with something happening later in the path then reporting an 
issue along that path related to those two conditions would be a false 
positive.  We go to great lengths in the analyzer to handle correlated 
conditions; that is why it is a path sensitive analysis, which is very 
expensive.  When we drop information on the floor, we lose precision and for 
some kinds of code can greatly increase the chance of producing false positives.

We do drop information on the floor all the time, but when we do we try to make 
those decisions quite deliberate and understand their implications.  Some 
checkers also are written with the mindset that if there is insufficient 
information to report an issue with high confidence than no issue is reported 
at all.  But the problem here by not invalidating values possibly touched by 
the loop is that there is a incorrect perception that the information is 
precise when indeed it is not.

Thanks again for pushing on this; handling loops better is something I have 
wanted us to tackle for a very long time but never found the time to do it.  
I'll circle back with you tonight with more feedback.

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


Re: [PATCH] D9639: Do not include pthread.h and sched.h when threads are disabled

2015-08-27 Thread Philippe Daouadi via cfe-commits
blastrock added a comment.

Sorry, I'm not sure I got what is the workflow on this platform. This patch is 
now "accepted", but do I need to do something else here? The only relevant 
action I can do seems to be "close revision", should I do that?

The developper policy page 
 does not seem to 
indicate what to do after a patch has been accepted (or did I miss it?).


http://reviews.llvm.org/D9639



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


Re: [PATCH] D9639: Do not include pthread.h and sched.h when threads are disabled

2015-08-27 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

Ah, usually the process is that you get your patch through review, and when 
someone accepts it, then you can commit it. If you do not have commit rights, 
then you can get someone else to commit it for you.

Accepted => "ok to commit"
Closed => "I've committed it"

Do you need me to commit it for you?


http://reviews.llvm.org/D9639



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


Re: [PATCH] D9639: Do not include pthread.h and sched.h when threads are disabled

2015-08-27 Thread Philippe Daouadi via cfe-commits
blastrock added a comment.

Oh I see! Indeed, I don't have commit rights, so I would help me if you could 
do it :)


http://reviews.llvm.org/D9639



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


Re: r245779 - [modules] Rearrange how redeclaration chains are loaded, to remove a walk over

2015-08-27 Thread Justin Bogner via cfe-commits
Richard Smith via cfe-commits  writes:
> Author: rsmith
> Date: Fri Aug 21 20:47:18 2015
> New Revision: 245779
>
> URL: http://llvm.org/viewvc/llvm-project?rev=245779&view=rev
> Log:
> [modules] Rearrange how redeclaration chains are loaded, to remove a walk over
> all modules and reduce the number of declarations we load when loading a
> redeclaration chain.

It looks like ASTDeclWriter::AddFirstDeclFromEachModule is called with a
null `this` since this change, which has been causing ubsan failures on
76 tests since it went in:

  ASTWriterDecl.cpp:170:18: runtime error: member call on null pointer of type 
'clang::ASTReader'

Logs and other failures here:

  http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/146/

I guess you must've missed the failure email. Could you please take a
look?

> The new approach is:
>  * when loading the first declaration of an entity within a module file, we
>first load all declarations of the entity that were imported into that
>module file, and then load all the other declarations of that entity from
>that module file and build a suitable decl chain from them
>  * when loading any other declaration of an entity, we first load the first
>declaration from the same module file
>
> As before, we complete redecl chains through name lookup where necessary.
>
> To make this work, I also had to change the way that template specializations
> are stored -- it no longer suffices to track only canonical specializations; 
> we
> now emit all "first local" declarations when emitting a list of 
> specializations
> for a template.
>
> On one testcase with several thousand imported module files, this reduces the
> total runtime by 72%.
>
> Modified:
> cfe/trunk/include/clang/Serialization/ASTWriter.h
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
> cfe/trunk/test/Modules/cxx-templates.cpp
>
> Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=245779&r1=245778&r2=245779&view=diff
> ==
> --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Fri Aug 21 20:47:18 2015
> @@ -405,6 +405,10 @@ private:
>/// \brief The set of declarations that may have redeclaration chains that
>/// need to be serialized.
>llvm::SmallVector Redeclarations;
> +
> +  /// \brief A cache of the first local declaration for "interesting"
> +  /// redeclaration chains.
> +  llvm::DenseMap FirstLocalDeclCache;
>
>/// \brief Statements that we've encountered while serializing a
>/// declaration or type.
> @@ -676,6 +680,10 @@ public:
>const ASTTemplateArgumentListInfo *ASTTemplArgList,
>RecordDataImpl &Record);
>  
> +  /// \brief Find the first local declaration of a given local redeclarable
> +  /// decl.
> +  const Decl *getFirstLocalDecl(const Decl *D);
> +
>/// \brief Emit a reference to a declaration.
>void AddDeclRef(const Decl *D, RecordDataImpl &Record);
>  
> @@ -857,12 +865,6 @@ public:
>void CompletedTagDefinition(const TagDecl *D) override;
>void AddedVisibleDecl(const DeclContext *DC, const Decl *D) override;
>void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) 
> override;
> -  void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD,
> - const ClassTemplateSpecializationDecl *D) 
> override;
> -  void AddedCXXTemplateSpecialization(const VarTemplateDecl *TD,
> -   const VarTemplateSpecializationDecl *D) 
> override;
> -  void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
> -  const FunctionDecl *D) override;
>void ResolvedExceptionSpec(const FunctionDecl *FD) override;
>void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) 
> override;
>void ResolvedOperatorDelete(const CXXDestructorDecl *DD,
>
> Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=245779&r1=245778&r2=245779&view=diff
> ==
> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Aug 21 20:47:18 2015
> @@ -8123,11 +8123,8 @@ void ASTReader::finishPendingActions() {
>  PendingIncompleteDeclChains.clear();
>  
>  // Load pending declaration chains.
> -for (unsigned I = 0; I != PendingDeclChains.size(); ++I) {
> -  PendingDeclChainsKnown.erase(PendingDeclChains[I]);
> +for (unsigned 

[libcxx] r246168 - Do not include pthread.h and sched.h when threads are disabled

2015-08-27 Thread Jonathan Roelofs via cfe-commits
Author: jroelofs
Date: Thu Aug 27 12:47:34 2015
New Revision: 246168

URL: http://llvm.org/viewvc/llvm-project?rev=246168&view=rev
Log:
Do not include pthread.h and sched.h when threads are disabled

Patch by Philippe Daouadi!

http://reviews.llvm.org/D9639

Modified:
libcxx/trunk/include/__mutex_base
libcxx/trunk/include/mutex

Modified: libcxx/trunk/include/__mutex_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__mutex_base?rev=246168&r1=246167&r2=246168&view=diff
==
--- libcxx/trunk/include/__mutex_base (original)
+++ libcxx/trunk/include/__mutex_base Thu Aug 27 12:47:34 2015
@@ -14,7 +14,9 @@
 #include <__config>
 #include 
 #include 
+#ifndef _LIBCPP_HAS_NO_THREADS
 #include 
+#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header

Modified: libcxx/trunk/include/mutex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/mutex?rev=246168&r1=246167&r2=246168&view=diff
==
--- libcxx/trunk/include/mutex (original)
+++ libcxx/trunk/include/mutex Thu Aug 27 12:47:34 2015
@@ -179,7 +179,9 @@ template
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 #include 
 #endif
+#ifndef _LIBCPP_HAS_NO_THREADS
 #include 
+#endif
 
 #include <__undef_min_max>
 


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


Re: [PATCH] D9639: Do not include pthread.h and sched.h when threads are disabled

2015-08-27 Thread Jonathan Roelofs via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.

r246168


http://reviews.llvm.org/D9639



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


[clang-tools-extra] r246169 - [clang-tidy] Update docs for clang-tidy checks. NFC

2015-08-27 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Aug 27 13:01:58 2015
New Revision: 246169

URL: http://llvm.org/viewvc/llvm-project?rev=246169&view=rev
Log:
[clang-tidy] Update docs for clang-tidy checks. NFC

Changes mostly address formatting and unification of the style. Use
MarkDown style for inline code snippets and lists. Added some text
for a few checks.

The idea is to move most of the documentation out to separate rST files and have
implementation files refer to the corresponding documentation files.

Modified:
clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h
clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h
clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.h
clang-tools-extra/trunk/clang-tidy/google/IntegerTypesCheck.h
clang-tools-extra/trunk/clang-tidy/google/MemsetZeroLengthCheck.h
clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.h
clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.h
clang-tools-extra/trunk/clang-tidy/google/TodoCommentCheck.h
clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.h
clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.h
clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h
clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.h
clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.h
clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.h
clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.h
clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.h
clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.h
clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.h
clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.h
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.h
clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h
clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.h
clang-tools-extra/trunk/clang-tidy/misc/SwappedArgumentsCheck.h
clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.h
clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.h
clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.h
clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.h
clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.h
clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.h
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.h
clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.h
clang-tools-extra/trunk/clang-tidy/readability/ElseAfterReturnCheck.h
clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.h
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h
clang-tools-extra/trunk/clang-tidy/readability/NamedParameterCheck.h
clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.h
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.h
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.h
clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.h
clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.h
clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.h

Modified: clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h?rev=246169&r1=246168&r2=246169&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h Thu Aug 
27 13:01:58 2015
@@ -17,14 +17,15 @@ namespace tidy {
 namespace google {
 namespace readability {
 
-/// \brief Finds usages of C-style casts.
+/// Finds usages of C-style casts.
 ///
 /// 
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Casting#Casting
+///
 /// Corresponding cpplint.py check name: 'readability/casting'.
 ///
-/// This check is similar to -Wold-style-cast, but it will suggest automated
-/// fixes eventually. The reported locations should not be different from the
-/// ones generated by -Wold-style-cast.
+/// This check is similar to `-Wold-style-cast`, but it suggests automated 
fixes
+/// in some cases. The reported locations should not be different from the
+/// ones generated by `-Wold-style-cast`.
 class AvoidCStyleCastsCheck : public ClangTidyCheck {
 public:
   AvoidCStyleCastsCheck(StringRef Name, ClangTidyContext *Context)

Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h
URL: 
http

[clang-tools-extra] r246170 - [clang-tidy] Renamed a test file to .cpp.

2015-08-27 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Aug 27 13:03:37 2015
New Revision: 246170

URL: http://llvm.org/viewvc/llvm-project?rev=246170&view=rev
Log:
[clang-tidy] Renamed a test file to .cpp.

Added:
clang-tools-extra/trunk/test/clang-tidy/misc-argument-comment.cpp
  - copied unchanged from r245699, 
clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp
Removed:
clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp

Removed: clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp?rev=246169&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp (removed)
@@ -1,40 +0,0 @@
-// RUN: %python %S/check_clang_tidy.py %s misc-argument-comment %t
-
-// FIXME: clang-tidy should provide a -verify mode to make writing these checks
-// easier and more accurate.
-
-void (int , int );
-
-void f(int x, int y);
-void g() {
-  // CHECK-MESSAGES: [[@LINE+4]]:5: warning: argument name 'y' in comment does 
not match parameter name 'x'
-  // CHECK-MESSAGES: :[[@LINE-3]]:12: note: 'x' declared here
-  // CHECK-MESSAGES: [[@LINE+2]]:14: warning: argument name 'z' in comment 
does not match parameter name 'y'
-  // CHECK-MESSAGES: :[[@LINE-5]]:19: note: 'y' declared here
-  f(/*y=*/0, /*z=*/0);
-}
-
-struct Closure {};
-
-template 
-Closure *NewCallback(void (*f)(T1, T2), T1 arg1, T2 arg2) { return nullptr; }
-
-template 
-Closure *NewPermanentCallback(void (*f)(T1, T2), T1 arg1, T2 arg2) { return 
nullptr; }
-
-void h() {
-  (void)NewCallback(&, /*=*/11, /*=*/22);
-  (void)NewPermanentCallback(&, /*=*/11, /*=*/22);
-}
-
-template
-void variadic(Args&&... args);
-
-template
-void variadic2(int zzz, Args&&... args);
-
-void templates() {
-  variadic(/*xxx=*/0, /*yyy=*/1);
-  variadic2(/*zzZ=*/0, /*xxx=*/1, /*yyy=*/2);
-  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: argument name 'zzZ' in comment 
does not match parameter name 'zzz'
-}


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


[clang-tools-extra] r246173 - [clang-tidy] Move clang-tidy docs to a separate directory. Create doc files for checks

2015-08-27 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Aug 27 13:10:07 2015
New Revision: 246173

URL: http://llvm.org/viewvc/llvm-project?rev=246173&view=rev
Log:
[clang-tidy] Move clang-tidy docs to a separate directory. Create doc files for 
checks

The doc files for checks have been generated from the corresponding header files
using the docs/clang-tidy/tools/dump_check_docs.py script. Committing the script
as well, but the intention is to move all the user-facing docs from header files
to the rST files and add links to .h files appropriately.

Added:
clang-tools-extra/trunk/docs/clang-tidy/
clang-tools-extra/trunk/docs/clang-tidy/checks/

clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-explicit-make-pair.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-namespaces.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-using-namespace.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-explicit-constructor.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-braces-around-statements.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-casting.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-function-size.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-namespace-comments.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-redundant-smartptr-get.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-todo.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-int.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-member-string-references.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-memset.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-operator.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-header-guard.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-include-order.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-namespace-comment.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-twine-local.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-assert-side-effect.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-assign-operator-signature.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-bool-pointer-implicit-conversion.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inaccurate-erase.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inefficient-algorithm.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-macro-parentheses.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-macro-repeated-side-effects.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-constructor-init.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-static-assert.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-swapped-arguments.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-undelegated-constructor.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-uniqueptr-reset-release.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-alias-decls.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-parameters.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-raii.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-braces-around-statements.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-container-size-empty.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-else-after-return.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-function-size.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-named-parameter.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-smartptr-get.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-shrink-to-fit.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-simplify-boolean-expr.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst
  - copied, changed from r246170, 
clang-tools-extra/trunk/docs/clang-tidy.rst
clang-tools-extra

r246174 - [CUDA] Improve CUDA compilation pipeline creation.

2015-08-27 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Aug 27 13:10:41 2015
New Revision: 246174

URL: http://llvm.org/viewvc/llvm-project?rev=246174&view=rev
Log:
[CUDA] Improve CUDA compilation pipeline creation.

Current implementation tries to guess which Action will result in a
job which needs to incorporate device-side GPU binaries. The guessing
was attempting to work around the fact that multiple actions may be
combined into a single compiler invocation. If CudaHostAction ends up
being combined (and thus bypassed during action list traversal) no
device-side actions it pointed to were processed. The guessing worked
for most of the usual cases, but fell apart when external assembler
was used.

This change removes the guessing and makes sure we create and pass
device-side jobs regardless of how the jobs get combined.

* CudaHostAction is always inserted either at Compile phase or the
  FinalPhase of current compilation, whichever happens first.
* If selectToolForJob combines CudaHostAction with other actions, it
  passes info about CudaHostAction up to the caller
* When it sees that CudaHostAction got combined with other actions
  (and hence will never be passed to BuildJobsForActions),
  BuildJobsForActions creates device-side jobs the same way they would
  be created if CudaHostAction was passed to BuildJobsForActions
  directly.
* Added two more test cases to make sure GPU binaries are passed to
  correct jobs.

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

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/cuda-options.cu

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=246174&r1=246173&r2=246174&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Aug 27 13:10:41 2015
@@ -1233,11 +1233,13 @@ void Driver::BuildInputs(const ToolChain
   }
 }
 
-// For each unique --cuda-gpu-arch= argument creates a TY_CUDA_DEVICE input
-// action and then wraps each in CudaDeviceAction paired with appropriate GPU
-// arch name. If we're only building device-side code, each action remains
-// independent. Otherwise we pass device-side actions as inputs to a new
-// CudaHostAction which combines both host and device side actions.
+// For each unique --cuda-gpu-arch= argument creates a TY_CUDA_DEVICE
+// input action and then wraps each in CudaDeviceAction paired with
+// appropriate GPU arch name. In case of partial (i.e preprocessing
+// only) or device-only compilation, each device action is added to /p
+// Actions and /p Current is released. Otherwise the function creates
+// and returns a new CudaHostAction which wraps /p Current and device
+// side actions.
 static std::unique_ptr
 buildCudaActions(const Driver &D, const ToolChain &TC, DerivedArgList &Args,
  const Arg *InputArg, std::unique_ptr HostAction,
@@ -1421,22 +1423,14 @@ void Driver::BuildActions(const ToolChai
 }
 
 phases::ID CudaInjectionPhase;
-if (isSaveTempsEnabled()) {
-  // All phases are done independently, inject GPU blobs during compilation
-  // phase as that's where we generate glue code to init them.
-  CudaInjectionPhase = phases::Compile;
-} else {
-  // Assumes that clang does everything up until linking phase, so we 
inject
-  // cuda device actions at the last step before linking. Otherwise CUDA
-  // host action forces preprocessor into a separate invocation.
-  CudaInjectionPhase = FinalPhase;
-  if (FinalPhase == phases::Link)
-for (auto PI = PL.begin(), PE = PL.end(); PI != PE; ++PI) {
-  auto next = PI + 1;
-  if (next != PE && *next == phases::Link)
-CudaInjectionPhase = *PI;
-}
-}
+bool InjectCuda = (InputType == types::TY_CUDA &&
+   !Args.hasArg(options::OPT_cuda_host_only));
+CudaInjectionPhase = FinalPhase;
+for (auto &Phase : PL)
+  if (Phase <= FinalPhase && Phase == phases::Compile) {
+CudaInjectionPhase = Phase;
+break;
+  }
 
 // Build the pipeline for this file.
 std::unique_ptr Current(new InputAction(*InputArg, InputType));
@@ -1464,8 +1458,7 @@ void Driver::BuildActions(const ToolChai
   // Otherwise construct the appropriate action.
   Current = ConstructPhaseAction(TC, Args, Phase, std::move(Current));
 
-  if (InputType == types::TY_CUDA && Phase == CudaInjectionPhase &&
-  !Args.hasArg(options::OPT_cuda_host_only)) {
+  if (InjectCuda && Phase == CudaInjectionPhase) {
 Current = buildCudaActions(*this, TC, Args, InputArg,
std::move(Current), Actions);
 if (!Current)
@@ -1679,10 +1672,17 @@ void Driver::BuildJobs(Compilation &C) c
   }
 }
 
-static const Tool *SelectToolForJob(Compilation &C, bool SaveTemps,
+// Returns a Tool for a given JobAction.  In case the action and its

Re: [PATCH] D11280: [CUDA] Improve CUDA compilation pipeline creation.

2015-08-27 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246174: [CUDA] Improve CUDA compilation pipeline creation. 
(authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D11280?vs=29947&id=33341#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11280

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/cuda-options.cu

Index: cfe/trunk/test/Driver/cuda-options.cu
===
--- cfe/trunk/test/Driver/cuda-options.cu
+++ cfe/trunk/test/Driver/cuda-options.cu
@@ -6,16 +6,16 @@
 // Simple compilation case:
 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
 // Compile device-side to PTX assembly and make sure we use it on the host side.
-// RUN:   | FileCheck -check-prefix CUDA-D1 \
+// RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
 // Then compile host side and incorporate device code.
 // RUN:   -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
 // Make sure we don't link anything.
 // RUN:   -check-prefix CUDA-NL %s
 
 // Typical compilation + link case:
 // RUN: %clang -### -target x86_64-linux-gnu %s 2>&1 \
 // Compile device-side to PTX assembly and make sure we use it on the host side
-// RUN:   | FileCheck -check-prefix CUDA-D1 \
+// RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
 // Then compile host side and incorporate device code.
 // RUN:   -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
 // Then link things.
@@ -33,15 +33,15 @@
 // Verify that -cuda-no-host disables host-side compilation and linking
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \
 // Compile device-side to PTX assembly
-// RUN:   | FileCheck -check-prefix CUDA-D1 \
+// RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
 // Make sure there are no host cmpilation or linking.
 // RUN:   -check-prefix CUDA-NH -check-prefix CUDA-NL %s
 
 // Verify that with -S we compile host and device sides to assembly
 // and incorporate device code on the host side.
 // RUN: %clang -### -target x86_64-linux-gnu -S -c %s 2>&1 \
 // Compile device-side to PTX assembly
-// RUN:   | FileCheck -check-prefix CUDA-D1 \
+// RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
 // Then compile host side and incorporate GPU code.
 // RUN:  -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
 // Make sure we don't link anything.
@@ -51,24 +51,56 @@
 // archtecture info to device compilation.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
 // Compile device-side to PTX assembly.
-// RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1-SM35 \
+// RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS \
+// RUN:   -check-prefix CUDA-D1-SM35 \
 // Then compile host side and incorporate GPU code.
 // RUN:   -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
 // Make sure we don't link anything.
 // RUN:   -check-prefix CUDA-NL %s
 
 // Verify that there is device-side compilation per --cuda-gpu-arch args
 // and that all results are included on the host side.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:--cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
 // Compile both device-sides to PTX assembly
 // RUN:   | FileCheck \
-// RUN: -check-prefix CUDA-D1 -check-prefix CUDA-D1-SM35 \
+// RUN: -check-prefix CUDA-D1 -check-prefix CUDA-D1NS -check-prefix CUDA-D1-SM35 \
 // RUN: -check-prefix CUDA-D2 -check-prefix CUDA-D2-SM30 \
 // Then compile host side and incorporate both device-side outputs
-// RUN:   -check-prefix CUDA-H -check-prefix CUDA-H-I1 -check-prefix CUDA-H-I2 \
+// RUN:   -check-prefix CUDA-H -check-prefix CUDA-HNS \
+// RUN:   -check-prefix CUDA-H-I1 -check-prefix CUDA-H-I2 \
 // Make sure we don't link anything.
 // RUN:   -check-prefix CUDA-NL %s
 
+// Verify that device-side results are passed to correct tool when
+// -save-temps is used
+// RUN: %clang -### -target x86_64-linux-gnu -save-temps -c %s 2>&1 \
+// Compile device-side to PTX assembly and make sure we use it on the host side.
+// RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1S \
+// Then compile host side and incorporate device code.
+// RUN:   -check-prefix CUDA-H -check-prefix CUDA-HS -check-prefix CUDA-HS-I1 \
+// Make sure we don't link anything.
+// RUN:   -check-prefix CUDA-NL %s
+
+// Verify that device-side results are passed to correct tool when
+// -fno-integrated-as is used
+// RUN: %clang -### -target x86_64-linux-gnu -fno-integrated-as -c %s 2>&1 \
+// Compile device-side to PTX assembly and make sure we use it on the host side.
+// RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS \
+// Then compile host side and incorporate device code.
+// RUN:   -check-prefix CUDA-H -check-prefix CUDA-HNS -check-prefix CUDA-HS-I1 \
+// RUN:   -check-prefix CUDA-H-AS \

Re: [PATCH] D12134: Improve debug info for implicitly captured vars in lambdas

2015-08-27 Thread David Blaikie via cfe-commits
On Tue, Aug 25, 2015 at 10:50 AM, Bataev, Alexey 
wrote:

> Guys, talking about implicitly captured variables we have to deal with 2
> locations: 1) point of real capturing (it is the point of '=' or '&'
> symbols in lambda capture-list);


I'm not sure that's "the point of real capturing" if it's an implicit
capture - nature of it being implicit is that there is no point where the
variable is explicitly captured.


> 2) a point of first use of variable inside lambda's body.
> When we're talking about diagnostic for implicitly captured variables we
> have to deal with the second point, not the first one, because of usability.


That's what I'm trying to understand - why is (2) relevant for diagnostic
usability, but not for debugger usability?


> I don't think that the "diagnostic consumer" would be happy to see a
> message like "unnamed variable cannot be implicitly captured in a lambda
> expression" pointing to '=' or '&'. Here we have to emit the diagnostic at
> the point of the very first use of the variable we're going to capture to
> make diagnostic more user-friendly. But actual point of capturing is still
> a point, where we have '=' or '&' symbols in capture-list.
>
> Best regards,
> Alexey Bataev
> =
> Software Engineer
> Intel Compiler Team
>
> 25.08.2015 19:00, Eric Christopher пишет:
>
>>
>> Yeah. I can't see a difference here being useful, and more likely harmful.
>>
>>
>> On Tue, Aug 25, 2015, 8:48 AM David Blaikie > dblai...@gmail.com>> wrote:
>>
>> On Tue, Aug 25, 2015 at 8:44 AM, Bataev, Alexey
>> mailto:a.bat...@hotmail.com>> wrote:
>>
>> Debug info points to the real place where it is captured,
>> while diagnostics points to the first use of implicitly
>> captured variable.
>>
>>
>> Right, but I'm trying to understand the justification for why
>> that's the right thing to do. Why the debug info user would want a
>> different experience than the compiler diagnostic consumer would want.
>>
>>
>> - David
>>
>>
>>
>> Best regards,
>> Alexey Bataev
>> =
>> Software Engineer
>> Intel Compiler Team
>>
>> 25.08.2015 18 :22, David Blaikie пишет:
>>
>>
>>
>> On Tue, Aug 25, 2015 at 8:18 AM, Bataev, Alexey
>> mailto:a.bat...@hotmail.com>
>> >
>> >> wrote:
>>
>> I though about this. I think it will be more
>> convenient for user
>> to see the diagnostic on the first use of the variable
>> rather than
>> on '=' or '&' symbol.
>>
>>
>> Why the difference between the diagnostic & the debug
>> info, then?
>>
>>
>> Best regards,
>> Alexey Bataev
>> =
>> Software Engineer
>> Intel Compiler Team
>>
>> 25.08.2015 18 
>> :07, David Blaikie пишет:
>>
>>
>>
>> On Tue, Aug 18, 2015 at 9:05 PM, Alexey Bataev via
>> cfe-commits
>> > 
>> > >
>> > 
>>
>> > >
>> ABataev created this revision.
>> ABataev added reviewers: echristo, rjmccall,
>> rsmith.
>> ABataev added a subscriber: cfe-commits.
>>
>> When variables are implicitly captured in
>> lambdas, debug info
>> generated for captured variables points to
>> location where
>> they are
>> used first.  This patch makes debug info to
>> point to capture
>> default location.
>>
>>
>> Not sure if this is the right tradeoff, or if it
>> is, perhaps
>> we should reconsider how our diagnostics work too?
>>
>> Currently if you, say, capture a variable by value
>> and that
>> variable doesn't have an accessible copy ctor, the
>> diagnostic
>> points to the first use. Should we change that too?
>>
>>
>> http://reviews.llvm.org/D12134
>>
>> Files:
>>   lib/Sema/SemaLambda.cpp
>> test/CodeGenCXX/debug-lambda-expressions.cpp
>>
>> Index: lib/Sema/SemaLambda.cpp
>>
>> ===
>> --- lib/Sema/S

Re: [PATCH] D11297: PR17829: Functions declared extern "C" with a name matching a mangled C++ function are allowed

2015-08-27 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/CodeGen/CodeGenModule.h:354
@@ +353,3 @@
+  /// call).
+  llvm::DenseSet ExplicitDefinitions;
+

andreybokhanko wrote:
> Checking that a GlobalDecl is not in ExplicitDefinitions yet is actually 
> required to avoid printing multiple identical warnings.
> 
> In my example:
> 
> ```
> 1: struct T {
> 2:   ~T() {}
> 3: };
> 4: 
> 5: extern "C" void _ZN1TD1Ev();
> 6: 
> 7: int main() {
> 8:   _ZN1TD1Ev();
> 9:   T t;
> 10: }
> ```
> 
> ~T() is added to the list of deferred decls twice. Judging from this comment 
> in "EmitDeferred" method:
> 
> // Check to see if we've already emitted this.  This is necessary
> // for a couple of reasons: first, decls can end up in the
> // deferred-decls queue multiple times, and second, decls can end
> // up with definitions in unusual ways (e.g. by an extern inline
> // function acquiring a strong function redefinition).  Just
> // ignore these cases.
> 
> this is pretty normal ("decls can end up in the deferred-decls queue multiple 
> times").
> 
> This means that we can call "GetOrCreateLLVMFunction"(..., 
> /*IsForDefinition*/=true) for duplicated decls several times, which is fine 
> in general, *but* will print the "duplicated mangled names" diagnostic 
> multiple times as well -- unless we check that we already printed a warning 
> on duplicated mangled names for given decl.
> 
> As for not emitting diagnostics for different globals -- this won't happen, 
> as we will call "GetOrCreateLLVMFunction" at least once for each global with 
> a definition, and thus, will print a warning for everyone.
> 
> I thought really hard (honestly!) on how to prevent duplicated diagnostics 
> without usage of an additional set, but didn't found any solution. If you 
> have any hints here, they would be much appreciated.
Okay, that's fine.  Can you at least make sure you only add to the set when you 
emit the warning?

As a minor optimization, you can add it to the set and check whether it was 
already there in the same operation, so that this would look like:

  if (LookupRepresentativeDecl(...) && 
DiagnosedConflictingDefinitions.insert(GD).second) {
...
  }


http://reviews.llvm.org/D11297



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


Re: [PATCH] D12389: Conditionalize X86 Darwin MaxVectorAlign on the presence of AVX.

2015-08-27 Thread John McCall via cfe-commits
rjmccall added a comment.

Okay, and you're doing the avx512 part of this in a separate commit?  LGTM.


http://reviews.llvm.org/D12389



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


Re: [PATCH] D9639: Do not include pthread.h and sched.h when threads are disabled

2015-08-27 Thread Philippe Daouadi via cfe-commits
blastrock added a comment.

Thank you!


http://reviews.llvm.org/D9639



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


Re: [PATCH] D11433: [Static Analyzer] Make NonNullParamChecker emit implicit null dereference events.

2015-08-27 Thread Anna Zaks via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

Thanks!


http://reviews.llvm.org/D11433



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


r246180 - const-ify TargetInfo::handleUserFeatures.

2015-08-27 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Aug 27 13:42:57 2015
New Revision: 246180

URL: http://llvm.org/viewvc/llvm-project?rev=246180&view=rev
Log:
const-ify TargetInfo::handleUserFeatures.

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=246180&r1=246179&r2=246180&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Thu Aug 27 13:42:57 2015
@@ -788,7 +788,7 @@ public:
   /// \return False on error.
   virtual bool handleUserFeatures(llvm::StringMap &Features,
  std::vector &UserFeatures,
- DiagnosticsEngine &Diags) {
+ DiagnosticsEngine &Diags) const {
 for (const auto &F : UserFeatures) {
   const char *Name = F.c_str();
   // Apply the feature via the target.

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=246180&r1=246179&r2=246180&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Aug 27 13:42:57 2015
@@ -870,7 +870,7 @@ public:
 DiagnosticsEngine &Diags) override;
   bool handleUserFeatures(llvm::StringMap &Features,
   std::vector &UserFeatures,
-  DiagnosticsEngine &Diags) override;
+  DiagnosticsEngine &Diags) const override;
   bool hasFeature(StringRef Feature) const override;
   void setFeatureEnabled(llvm::StringMap &Features, StringRef Name,
  bool Enabled) const override;
@@ -1051,7 +1051,7 @@ bool PPCTargetInfo::handleTargetFeatures
 
 bool PPCTargetInfo::handleUserFeatures(llvm::StringMap &Features,
std::vector &UserFeatures,
-   DiagnosticsEngine &Diags) {
+   DiagnosticsEngine &Diags) const {
 
   // Handle explicit options being passed to the compiler here: if we've
   // explicitly turned off vsx and turned on power8-vector or direct-move then


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


Re: [PATCH] D12390: Also enable the avx/avx512 ABIs for i386, not just x86_64.

2015-08-27 Thread John McCall via cfe-commits
rjmccall added a comment.

This gives no-MMX priority over turning on SSE, which sounds like a major 
change in behavior to me.  There are definitely clients that specifically never 
want to use MMX but do care deeply about SSE; my understanding is that modern 
microarchitectures heavily punish casual use of MMX.


http://reviews.llvm.org/D12390



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


Re: [PATCH] D11433: [Static Analyzer] Make NonNullParamChecker emit implicit null dereference events.

2015-08-27 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246182: [Static Analyzer] Make NonNullParamChecker emit 
implicit null dereference… (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D11433?vs=5&id=33344#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11433

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  cfe/trunk/test/Analysis/nullability.mm

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
@@ -514,6 +514,10 @@
   bool IsLoad;
   ExplodedNode *SinkNode;
   BugReporter *BR;
+  // When true, the dereference is in the source code directly. When false, the
+  // dereference might happen later (for example pointer passed to a parameter
+  // that is marked with nonnull attribute.)
+  bool IsDirectDereference;
 };
 
 /// \brief A helper class which wraps a boolean value set to false by default.
Index: cfe/trunk/test/Analysis/nullability.mm
===
--- cfe/trunk/test/Analysis/nullability.mm
+++ cfe/trunk/test/Analysis/nullability.mm
@@ -50,6 +50,8 @@
 
 template  T *eraseNullab(T *p) { return p; }
 
+void takesAttrNonnull(Dummy *p) __attribute((nonnull(1)));
+
 void testBasicRules() {
   Dummy *p = returnsNullable();
   int *ptr = returnsNullableInt();
@@ -73,10 +75,8 @@
 Dummy dd(d);
 break;
   }
-  // Here the copy constructor is called, so a reference is initialized with the
-  // value of p. No ImplicitNullDereference event will be dispatched for this
-  // case. A followup patch is expected to fix this in NonNullParamChecker.
-  default: { Dummy d = *p; } break; // No warning.
+  case 5: takesAttrNonnull(p); break; // expected-warning {{Nullable pointer is passed to}}
+  default: { Dummy d = *p; } break; // expected-warning {{Nullable pointer is dereferenced}}
   }
   if (p) {
 takesNonnull(p);
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
@@ -28,7 +28,7 @@
 
 namespace {
 class NonNullParamChecker
-  : public Checker< check::PreCall > {
+  : public Checker< check::PreCall, EventDispatcher > {
   mutable std::unique_ptr BTAttrNonNull;
   mutable std::unique_ptr BTNullRefArg;
 
@@ -139,26 +139,34 @@
 ProgramStateRef stateNotNull, stateNull;
 std::tie(stateNotNull, stateNull) = CM.assumeDual(state, *DV);
 
-if (stateNull && !stateNotNull) {
-  // Generate an error node.  Check for a null node in case
-  // we cache out.
-  if (ExplodedNode *errorNode = C.generateSink(stateNull)) {
-
-std::unique_ptr R;
-if (haveAttrNonNull)
-  R = genReportNullAttrNonNull(errorNode, ArgE);
-else if (haveRefTypeParam)
-  R = genReportReferenceToNullPointer(errorNode, ArgE);
+if (stateNull) {
+  if (!stateNotNull) {
+// Generate an error node.  Check for a null node in case
+// we cache out.
+if (ExplodedNode *errorNode = C.generateSink(stateNull)) {
+
+  std::unique_ptr R;
+  if (haveAttrNonNull)
+R = genReportNullAttrNonNull(errorNode, ArgE);
+  else if (haveRefTypeParam)
+R = genReportReferenceToNullPointer(errorNode, ArgE);
+
+  // Highlight the range of the argument that was null.
+  R->addRange(Call.getArgSourceRange(idx));
+
+  // Emit the bug report.
+  C.emitReport(std::move(R));
+}
 
-// Highlight the range of the argument that was null.
-R->addRange(Call.getArgSourceRange(idx));
-
-// Emit the bug report.
-C.emitReport(std::move(R));
+// Always return.  Either we cached out or we just emitted an error.
+return;
+  }
+  if (ExplodedNode *N = C.generateSink(stateNull)) {
+ImplicitNullDerefEvent event = {
+V, false, N, &C.getBugReporter(),
+/*IsDirectDereference=*/haveRefTypeParam};
+dispatchEvent(event);
   }
-
-  // Always return.  Either we cached out or we just emitted an error.
-  return;
 }
 
 // If a pointer value passed the check we should assume that it is
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -335,7 +335,10 @@
   if (Filter.Check

r246183 - [Tests] Modified Lit Tests to be C++11 compatibile

2015-08-27 Thread Charles Li via cfe-commits
Author: lcharles
Date: Thu Aug 27 13:49:15 2015
New Revision: 246183

URL: http://llvm.org/viewvc/llvm-project?rev=246183&view=rev
Log:
[Tests] Modified Lit Tests to be C++11 compatibile

This 2nd patch should not change the test results, but it is useful if clang's
default C++ language is ever changed from gnu++98.


Added:
cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp
Modified:
cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp
cfe/trunk/test/CodeCompletion/ordinary-name.cpp
cfe/trunk/test/Sema/switch-1.c
cfe/trunk/test/Sema/thread-specifier.c

Modified: cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp?rev=246183&r1=246182&r2=246183&view=diff
==
--- cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp (original)
+++ cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp Thu Aug 27 13:49:15 
2015
@@ -1,6 +1,8 @@
 // RUN: rm -f %t
-// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -analyzer-config 
cfg-temporary-dtors=true %s > %t 2>&1
-// RUN: FileCheck --input-file=%t %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -analyzer-config 
cfg-temporary-dtors=true -std=c++98 %s > %t 2>&1
+// RUN: FileCheck --input-file=%t -check-prefix=CXX98 -check-prefix=CHECK %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -analyzer-config 
cfg-temporary-dtors=true -std=c++11 %s > %t 2>&1
+// RUN: FileCheck --input-file=%t -check-prefix=CXX11 -check-prefix=CHECK %s
 
 class A {
 public:
@@ -671,15 +673,23 @@ int testConsistencyNestedNormalReturn(bo
 // CHECK: Succs (1): B0
 // CHECK:   [B3]
 // CHECK: 1: D() (CXXConstructExpr, struct D)
-// CHECK: 2: [B3.1] (ImplicitCastExpr, NoOp, const struct D)
-// CHECK: 3: [B3.2]
-// CHECK: 4: [B3.3] (CXXConstructExpr, struct D)
-// CHECK: 5: D d = D();
-// CHECK: 6: d
-// CHECK: 7: [B3.6].operator bool
-// CHECK: 8: [B3.6]
-// CHECK: 9: [B3.8] (ImplicitCastExpr, UserDefinedConversion, _Bool)
-// CHECK: T: if [B3.9]
+// CXX98: 2: [B3.1] (ImplicitCastExpr, NoOp, const struct D)
+// CXX98: 3: [B3.2]
+// CXX98: 4: [B3.3] (CXXConstructExpr, struct D)
+// CXX98: 5: D d = D();
+// CXX98: 6: d
+// CXX98: 7: [B3.6].operator bool
+// CXX98: 8: [B3.6]
+// CXX98: 9: [B3.8] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CXX98: T: if [B3.9]
+// CXX11: 2: [B3.1]
+// CXX11: 3: [B3.2] (CXXConstructExpr, struct D)
+// CXX11: 4: D d = D();
+// CXX11: 5: d
+// CXX11: 6: [B3.5].operator bool
+// CXX11: 7: [B3.5]
+// CXX11: 8: [B3.7] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CXX11: T: if [B3.8]
 // CHECK: Preds (1): B4
 // CHECK: Succs (2): B2 B1
 // CHECK:   [B0 (EXIT)]

Added: cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp?rev=246183&view=auto
==
--- cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp (added)
+++ cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp Thu Aug 27 13:49:15 
2015
@@ -0,0 +1,252 @@
+struct X { int x; };
+void z(int);
+typedef struct t TYPEDEF;
+
+void foo() {
+  int y = 17;
+  // RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -code-completion-patterns 
-code-completion-at=%s:6:14 -std=gnu++11 %s -o - | FileCheck 
-check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: COMPLETION: bool
+  // CHECK-CC1-NEXT: COMPLETION: char
+  // CHECK-CC1-NEXT: COMPLETION: char16
+  // CHECK-CC1-NEXT: COMPLETION: char32
+  // CHECK-CC1-NEXT: COMPLETION: class
+  // CHECK-CC1-NEXT: COMPLETION: const
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : const_cast<<#type#>>(<#expression#>)
+  // CHECK-CC1: COMPLETION: Pattern : [#void#]delete <#expression#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : [#void#]delete [] <#expression#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : do{<#statements#>
+  // CHECK-CC1: COMPLETION: double
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : 
dynamic_cast<<#type#>>(<#expression#>)
+  // CHECK-CC1-NEXT: COMPLETION: enum
+  // CHECK-CC1-NEXT: COMPLETION: extern
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : [#bool#]false
+  // CHECK-CC1-NEXT: COMPLETION: float
+  // CHECK-CC1-NEXT: COMPLETION: foo : [#void#]foo()
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : 
for(<#init-statement#>;<#condition#>;<#inc-expression#>){
+  // CHECK-CC1: COMPLETION: Pattern : goto <#label#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : if(<#condition#>){<#statements#>
+  // CHECK-CC1: COMPLETION: int
+  // CHECK-CC1-NEXT: COMPLETION: long
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : new <#type#>(<#expressions#>)
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : new 
<#type#>[<#size#>](<#expressions#>)
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : [#bool#]noexcept(<#expre

r246182 - [Static Analyzer] Make NonNullParamChecker emit implicit null dereference events.

2015-08-27 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Thu Aug 27 13:49:07 2015
New Revision: 246182

URL: http://llvm.org/viewvc/llvm-project?rev=246182&view=rev
Log:
[Static Analyzer] Make NonNullParamChecker emit implicit null dereference 
events.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/test/Analysis/nullability.mm

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h?rev=246182&r1=246181&r2=246182&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h Thu Aug 27 13:49:07 
2015
@@ -514,6 +514,10 @@ struct ImplicitNullDerefEvent {
   bool IsLoad;
   ExplodedNode *SinkNode;
   BugReporter *BR;
+  // When true, the dereference is in the source code directly. When false, the
+  // dereference might happen later (for example pointer passed to a parameter
+  // that is marked with nonnull attribute.)
+  bool IsDirectDereference;
 };
 
 /// \brief A helper class which wraps a boolean value set to false by default.

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp?rev=246182&r1=246181&r2=246182&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp Thu Aug 27 
13:49:07 2015
@@ -220,7 +220,8 @@ void DereferenceChecker::checkLocation(S
 // null or not-null.  Record the error node as an "implicit" null
 // dereference.
 if (ExplodedNode *N = C.generateSink(nullState)) {
-  ImplicitNullDerefEvent event = { l, isLoad, N, &C.getBugReporter() };
+  ImplicitNullDerefEvent event = {l, isLoad, N, &C.getBugReporter(),
+  /*IsDirectDereference=*/false};
   dispatchEvent(event);
 }
   }
@@ -257,8 +258,9 @@ void DereferenceChecker::checkBind(SVal
 // At this point the value could be either null or non-null.
 // Record this as an "implicit" null dereference.
 if (ExplodedNode *N = C.generateSink(StNull)) {
-  ImplicitNullDerefEvent event = { V, /*isLoad=*/true, N,
-   &C.getBugReporter() };
+  ImplicitNullDerefEvent event = {V, /*isLoad=*/true, N,
+  &C.getBugReporter(),
+  /*IsDirectDereference=*/false};
   dispatchEvent(event);
 }
   }

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp?rev=246182&r1=246181&r2=246182&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp Thu Aug 27 
13:49:07 2015
@@ -28,7 +28,7 @@ using namespace ento;
 
 namespace {
 class NonNullParamChecker
-  : public Checker< check::PreCall > {
+  : public Checker< check::PreCall, EventDispatcher > {
   mutable std::unique_ptr BTAttrNonNull;
   mutable std::unique_ptr BTNullRefArg;
 
@@ -139,26 +139,34 @@ void NonNullParamChecker::checkPreCall(c
 ProgramStateRef stateNotNull, stateNull;
 std::tie(stateNotNull, stateNull) = CM.assumeDual(state, *DV);
 
-if (stateNull && !stateNotNull) {
-  // Generate an error node.  Check for a null node in case
-  // we cache out.
-  if (ExplodedNode *errorNode = C.generateSink(stateNull)) {
-
-std::unique_ptr R;
-if (haveAttrNonNull)
-  R = genReportNullAttrNonNull(errorNode, ArgE);
-else if (haveRefTypeParam)
-  R = genReportReferenceToNullPointer(errorNode, ArgE);
+if (stateNull) {
+  if (!stateNotNull) {
+// Generate an error node.  Check for a null node in case
+// we cache out.
+if (ExplodedNode *errorNode = C.generateSink(stateNull)) {
+
+  std::unique_ptr R;
+  if (haveAttrNonNull)
+R = genReportNullAttrNonNull(errorNode, ArgE);
+  else if (haveRefTypeParam)
+R = genReportReferenceToNullPointer(errorNode, ArgE);
+
+  // Highlight the range of the argument that was null.
+  R->addRange(Call.getArgSourceRange(idx));
+
+  // Emit the bug report.
+  C.emitReport(std::move(R));
+}
 
-// Highlight the range of the argument t

r246188 - [Static Analyzer] BugReporter.cpp:2869: Assertion failed: !RemainingNodes.empty() && "No error node found in the trimmed graph"

2015-08-27 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Thu Aug 27 13:57:00 2015
New Revision: 246188

URL: http://llvm.org/viewvc/llvm-project?rev=246188&view=rev
Log:
[Static Analyzer] BugReporter.cpp:2869: Assertion failed: 
!RemainingNodes.empty() && "No error node found in the trimmed graph"

The assertion is caused by reusing a “filler” ExplodedNode as an error node.
The “filler” nodes are only used for intermediate processing and are not
essential for analyzer history, so they can be reclaimed when the
ExplodedGraph is trimmed by the “collectNode” function. When a checker finds a
bug, they generate a new transition in the ExplodedGraph. The analyzer will
try to reuse the existing predecessor node. If it cannot, it creates a new
ExplodedNode, which always has a tag to uniquely identify the creation site.
The assertion is caused when the analyzer reuses a “filler” node.

In the test case, some “filler” nodes were reused and then reclaimed later
when the ExplodedGraph was trimmed. This caused an assertion because the node
was needed to generate the report. The “filler” nodes should not be reused as
error nodes. The patch adds a constraint to prevent this happening, which
solves the problem and makes the test cases pass.

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

Patch by Ying Yi!

Added:
cfe/trunk/test/Analysis/PR24184.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
cfe/trunk/test/Analysis/malloc.c

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h?rev=246188&r1=246187&r2=246188&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h 
Thu Aug 27 13:57:00 2015
@@ -287,7 +287,10 @@ private:
  bool MarkAsSink,
  ExplodedNode *P = nullptr,
  const ProgramPointTag *Tag = nullptr) {
-if (!State || (State == Pred->getState() && !Tag && !MarkAsSink))
+// It may not be safe to use the "Pred" node with no tag because the "Pred"
+// node may be recycled in the reclamation function.
+if (!State || (State == Pred->getState() && !Tag && !MarkAsSink &&
+   Pred->getLocation().getTag()))
   return Pred;
 
 Changed = true;

Added: cfe/trunk/test/Analysis/PR24184.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/PR24184.cpp?rev=246188&view=auto
==
--- cfe/trunk/test/Analysis/PR24184.cpp (added)
+++ cfe/trunk/test/Analysis/PR24184.cpp Thu Aug 27 13:57:00 2015
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -w -analyze -analyzer-eagerly-assume -fcxx-exceptions 
-analyzer-checker=core 
-analyzer-checker=alpha.core.PointerArithm,alpha.core.CastToStruct 
-analyzer-max-loop 64 -verify %s
+// RUN: %clang_cc1 -w -analyze -analyzer-checker=core 
-analyzer-checker=cplusplus -fcxx-exceptions -analyzer-checker 
alpha.core.PointerArithm,alpha.core.CastToStruct -analyzer-max-loop 63 -verify 
%s
+
+// These tests used to hit an assertion in the bug report. Test case from 
http://llvm.org/PR24184.
+typedef struct {
+  int cbData;
+  unsigned pbData;
+} CRYPT_DATA_BLOB;
+
+typedef enum { DT_NONCE_FIXED } DATA_TYPE;
+int a;
+typedef int *vcreate_t(int *, DATA_TYPE, int, int);
+void fn1(unsigned, unsigned) {
+  char b = 0;
+  for (; 1; a++, &b + a * 0) // expected-warning{{Pointer arithmetic done on 
non-array variables means reliance on memory layout, which is dangerous}}
+;
+}
+
+vcreate_t fn2;
+struct A {
+  CRYPT_DATA_BLOB value;
+  int m_fn1() {
+int c;
+value.pbData == 0;
+fn1(0, 0);
+  }
+};
+struct B {
+  A IkeHashAlg;
+  A IkeGType;
+  A NoncePhase1_r;
+};
+class C {
+  int m_fn2(B *);
+  void m_fn3(B *, int, int, int);
+};
+int C::m_fn2(B *p1) {
+  int *d;
+  int e = p1->IkeHashAlg.m_fn1();
+  unsigned f = p1->IkeGType.m_fn1(), h;
+  int g;
+  d = fn2(0, DT_NONCE_FIXED, (char)0, p1->NoncePhase1_r.value.cbData);
+  h = 0 | 0;
+  m_fn3(p1, 0, 0, 0);
+}
+
+// case 2:
+typedef struct {
+  int cbData;
+  unsigned char *pbData;
+} CRYPT_DATA_BLOB_1;
+typedef unsigned uint32_t;
+void fn1_1(void *p1, const void *p2) { p1 != p2; }
+
+void fn2_1(uint32_t *p1, unsigned char *p2, uint32_t p3) {
+  unsigned i = 0;
+  for (0; i < p3; i++)
+fn1_1(p1 + i, p2 + i * 0);// expected-warning{{Pointer arithmetic done 
on non-array variables means reliance on memory layout, which is dangerous}}
+}
+
+struct A_1 {
+  CRYPT_DATA_BLOB_1 value;
+  uint32_t m_fn1() {
+uint32_t a;
+if (value.pbData)
+  fn2_1(&a, value.pbData, value.cbData);
+return 0;
+  }
+};
+struct {
+  A_1 HashAlgId;
+} *b;
+void fn3() {
+  uint32_t c,

r246189 - Improve options printed on vectorization analysis diagnostics.

2015-08-27 Thread Tyler Nowicki via cfe-commits
Author: tnowicki
Date: Thu Aug 27 13:58:34 2015
New Revision: 246189

URL: http://llvm.org/viewvc/llvm-project?rev=246189&view=rev
Log:
Improve options printed on vectorization analysis diagnostics.

The LLVM patch changes the analysis diagnostics produced when loops with

floating-point recurrences or memory operations are identified. The new messages
say "cannot prove it is safe to reorder * operations; allow reordering by   
specifying #pragma clang loop vectorize(enable)". Depending on the type of  
diagnostic the message will include additional options such as ffast-math or
__restrict__.   

Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/test/Frontend/optimization-remark-options.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=246189&r1=246188&r2=246189&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Thu Aug 27 
13:58:34 2015
@@ -46,13 +46,14 @@ def remark_fe_backend_optimization_remar
 def remark_fe_backend_optimization_remark_analysis : Remark<"%0">, BackendInfo,
 InGroup;
 def remark_fe_backend_optimization_remark_analysis_fpcommute : Remark<"%0; "
-"allow commutativity by specifying '#pragma clang loop vectorize(enable)' "
-"before the loop or by providing the compiler option '-ffast-math'">,
+"allow reordering by specifying '#pragma clang loop vectorize(enable)' "
+"before the loop or by providing the compiler option '-ffast-math'.">,
 BackendInfo, InGroup;
 def remark_fe_backend_optimization_remark_analysis_aliasing : Remark<"%0; "
-"avoid runtime pointer checking when you know the arrays will always be "
-"independent by specifying '#pragma clang loop vectorize(assume_safety)' "
-"before the loop or by specifying 'restrict' on the array arguments. "
+"allow reordering by specifying '#pragma clang loop vectorize(enable)' "
+"before the loop. If the arrays will always be independent specify "
+"'#pragma clang loop vectorize(assume_safety)' before the loop or provide "
+"the '__restrict__' qualifier with the independent array arguments. "
 "Erroneous results will occur if these options are incorrectly applied!">,
 BackendInfo, InGroup;
 def warn_fe_backend_optimization_failure : Warning<"%0">, BackendInfo,

Modified: cfe/trunk/test/Frontend/optimization-remark-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-options.c?rev=246189&r1=246188&r2=246189&view=diff
==
--- cfe/trunk/test/Frontend/optimization-remark-options.c (original)
+++ cfe/trunk/test/Frontend/optimization-remark-options.c Thu Aug 27 13:58:34 
2015
@@ -1,6 +1,6 @@
 // RUN: %clang -O1 -fvectorize -target x86_64-unknown-unknown 
-Rpass-analysis=loop-vectorize -emit-llvm -S %s -o - 2>&1 | FileCheck %s
 
-// CHECK: {{.*}}:9:11: remark: loop not vectorized: vectorization requires 
changes in the order of operations, however IEEE 754 floating-point operations 
are not commutative; allow commutativity by specifying '#pragma clang loop 
vectorize(enable)' before the loop or by providing the compiler option 
'-ffast-math'
+// CHECK: {{.*}}:9:11: remark: loop not vectorized: cannot prove it is safe to 
reorder floating-point operations; allow reordering by specifying '#pragma 
clang loop vectorize(enable)' before the loop or by providing the compiler 
option '-ffast-math'.
 
 double foo(int N) {
   double v = 0.0;
@@ -11,7 +11,7 @@ double foo(int N) {
   return v;
 }
 
-// CHECK: {{.*}}:18:13: remark: loop not vectorized: cannot prove pointers 
refer to independent arrays in memory. The loop requires 9 runtime independence 
checks to vectorize the loop, but that would exceed the limit of 8 checks; 
avoid runtime pointer checking when you know the arrays will always be 
independent by specifying '#pragma clang loop vectorize(assume_safety)' before 
the loop or by specifying 'restrict' on the array arguments. Erroneous results 
will occur if these options are incorrectly applied!
+// CHECK: {{.*}}:18:13: remark: loop not vectorized: cannot prove it is safe 
to reorder memory operations; allow reordering by specifying '#pragma clang 
loop vectorize(enable)' before the loop. If the arrays will always be 
independent specify '#pragma clang loop vectorize(assume_safety)' before the 
loop or provide the '__restrict__' qualifier with the independent array 
arguments. Erroneous results will occur if these options are incorrectly 
applied!
 
 void foo2(int *dw, int *uw, int *A, int *B, int *C, int *D, int N) {
   for (int i = 0; i < N; i++) {


__

Re: [PATCH] D12163: [Patch] [Analyzer] BugReporter.cpp:2869: Assertion failed: !RemainingNodes.empty() && "No error node found in the trimmed graph" (PR 24184)

2015-08-27 Thread Gábor Horváth via cfe-commits
xazax.hun added a subscriber: xazax.hun.
xazax.hun closed this revision.
xazax.hun added a comment.

Committed in http://reviews.llvm.org/rL246188.

Thanks for the patch.


http://reviews.llvm.org/D12163



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


[PATCH] D12411: [PATCH] Expose AST language options to checkers

2015-08-27 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: alexfh, djasper.
aaron.ballman added a subscriber: cfe-commits.

Some of the checkers need to know what language options are enabled in order to 
behave sensibly. For instance, the modernize-use-nullptr checker should not 
suggest use of nullptr when the file being checked is a C file, not a C++ file.

This patch exposes the language options to checkers, and corrects the bug with 
modernize-use-nullptr by only registering the matcher if C++11 language 
features are enabled.

~Aaron

http://reviews.llvm.org/D12411

Files:
  clang-tidy/ClangTidy.h
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/modernize/UseNullptrCheck.cpp
  test/clang-tidy/modernize-use-nullptr.c

Index: test/clang-tidy/modernize-use-nullptr.c
===
--- test/clang-tidy/modernize-use-nullptr.c
+++ test/clang-tidy/modernize-use-nullptr.c
@@ -0,0 +1,10 @@
+// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
+
+// Note: this test expects no diagnostics, but FileCheck cannot handle that,
+// hence the use of | count 0.
+
+#define NULL 0
+void f(void) {
+  char *str = NULL; // ok
+  (void)str;
+}
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -453,7 +453,9 @@
 }
 
 void UseNullptrCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(makeCastSequenceMatcher(), this);
+  // Only register the matcher for C++11.
+  if (getLangOpts().CPlusPlus11)
+Finder->addMatcher(makeCastSequenceMatcher(), this);
 }
 
 void UseNullptrCheck::check(const MatchFinder::MatchResult &Result) {
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -149,6 +149,9 @@
   /// \brief Sets ASTContext for the current translation unit.
   void setASTContext(ASTContext *Context);
 
+  /// \brief Gets the language options from the AST context
+  LangOptions getLangOpts() const { return LangOpts; }
+
   /// \brief Returns the name of the clang-tidy check which produced this
   /// diagnostic ID.
   StringRef getCheckName(unsigned DiagnosticID) const;
@@ -198,6 +201,8 @@
   ClangTidyOptions CurrentOptions;
   std::unique_ptr CheckFilter;
 
+  LangOptions LangOpts;
+
   ClangTidyStats Stats;
 
   llvm::DenseMap CheckNamesByDiagnosticID;
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -212,6 +212,7 @@
 
 void ClangTidyContext::setASTContext(ASTContext *Context) {
   DiagEngine->SetArgToStringFn(&FormatASTNodeDiagnosticArgument, Context);
+  LangOpts = Context->getLangOpts();
 }
 
 const ClangTidyGlobalOptions &ClangTidyContext::getGlobalOptions() const {
Index: clang-tidy/ClangTidy.h
===
--- clang-tidy/ClangTidy.h
+++ clang-tidy/ClangTidy.h
@@ -158,6 +158,8 @@
   OptionsView Options;
   /// \brief Returns the main file name of the current translation unit.
   StringRef getCurrentMainFile() const { return Context->getCurrentFile(); }
+  /// \brief Returns the language options from the context.
+  LangOptions getLangOpts() const { return Context->getLangOpts(); }
 };
 
 class ClangTidyCheckFactories;


Index: test/clang-tidy/modernize-use-nullptr.c
===
--- test/clang-tidy/modernize-use-nullptr.c
+++ test/clang-tidy/modernize-use-nullptr.c
@@ -0,0 +1,10 @@
+// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
+
+// Note: this test expects no diagnostics, but FileCheck cannot handle that,
+// hence the use of | count 0.
+
+#define NULL 0
+void f(void) {
+  char *str = NULL; // ok
+  (void)str;
+}
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -453,7 +453,9 @@
 }
 
 void UseNullptrCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(makeCastSequenceMatcher(), this);
+  // Only register the matcher for C++11.
+  if (getLangOpts().CPlusPlus11)
+Finder->addMatcher(makeCastSequenceMatcher(), this);
 }
 
 void UseNullptrCheck::check(const MatchFinder::MatchResult &Result) {
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -149,6 +149,9 @@
   /// \brief Sets ASTContext for the current translation unit.
   void setASTContext(ASTConte

r246192 - Add a -gmodules option to the driver and a -dwarf-ext-refs to cc1

2015-08-27 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Aug 27 14:46:20 2015
New Revision: 246192

URL: http://llvm.org/viewvc/llvm-project?rev=246192&view=rev
Log:
Add a -gmodules option to the driver and a -dwarf-ext-refs to cc1
to enable the use of external type references in the debug info
(a.k.a. module debugging).

The driver expands -gmodules to "-g -fmodule-format=obj -dwarf-ext-refs"
and passes that to cc1. All this does at the moment is set a flag
codegenopts.

http://reviews.llvm.org/D11958

Modified:
cfe/trunk/docs/CommandGuide/clang.rst
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/test/Driver/debug-options.c
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/docs/CommandGuide/clang.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=246192&r1=246191&r2=246192&view=diff
==
--- cfe/trunk/docs/CommandGuide/clang.rst (original)
+++ cfe/trunk/docs/CommandGuide/clang.rst Thu Aug 27 14:46:20 2015
@@ -257,6 +257,13 @@ Code Generation Options
 
   Generate debug information.  Note that Clang debug information works best at 
-O0.
 
+.. option:: -gmodules
+
+  Generate debug information that contains external references to
+  types defined in clang modules or precompiled headers instead of
+  emitting redundant debug type information into every object file.
+  This option implies `-fmodule-format=obj`.
+  
 .. option:: -fstandalone-debug -fno-standalone-debug
 
   Clang supports a number of optimizations to reduce the size of debug

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=246192&r1=246191&r2=246192&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Aug 27 14:46:20 2015
@@ -167,6 +167,9 @@ def gnu_pubnames : Flag<["-"], "gnu-pubn
   HelpText<"Emit newer GNU style pubnames">;
 def arange_sections : Flag<["-"], "arange_sections">,
   HelpText<"Emit DWARF .debug_arange sections">;
+def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">,
+  HelpText<"Generate debug info with external references to clang modules"
+   " or precompiled headers">;
 def fforbid_guard_variables : Flag<["-"], "fforbid-guard-variables">,
   HelpText<"Emit an error if a C++ static local initializer would need a guard 
variable">;
 def no_implicit_float : Flag<["-"], "no-implicit-float">,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=246192&r1=246191&r2=246192&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Aug 27 14:46:20 2015
@@ -1133,6 +1133,9 @@ def gno_column_info : Flag<["-"], "gno-c
 def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group;
 def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group;
 def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group;
+def gmodules : Flag <["-"], "gmodules">, Group,
+  HelpText<"Generate debug info with external references to clang modules"
+   " or precompiled headers">;
 def headerpad__max__install__names : Joined<["-"], 
"headerpad_max_install_names">;
 def help : Flag<["-", "--"], "help">, Flags<[CC1Option,CC1AsOption]>,
   HelpText<"Display available options">;

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=246192&r1=246191&r2=246192&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu Aug 27 14:46:20 2015
@@ -728,8 +728,8 @@ public:
   static std::unique_ptr LoadFromASTFile(
   const std::string &Filename, const PCHContainerReader &PCHContainerRdr,
   IntrusiveRefCntPtr Diags,
-  const FileSystemOptions &FileSystemOpts, bool OnlyLocalDecls = false,
-  ArrayRef RemappedFiles = None,
+  const FileSystemOptions &FileSystemOpts, bool UseDebugInfo = false,
+  bool OnlyLocalDecls = false, ArrayRef RemappedFiles = None,
   bool CaptureDiagnostics = false, bool AllowPCHWit

Re: [PATCH] D12313: Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-08-27 Thread hfin...@anl.gov via cfe-commits
hfinkel added a comment.

I also like this intrinsic approach better than the type attribute.

The fact that it does not work with builtin vector types, however, is quite 
unfortunate. Plus, I don't understand why you're implementing another place in 
CodeGen that generates IR to load and store scalar values. Can't you enhance 
EmitLoadOfScalar/EmitStoreOfScalar and then use those functions? If nothing 
else, you're already missing setting of TBAA metadata and other things that 
these functions do.


http://reviews.llvm.org/D12313



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


[PATCH] D12412: [CodeGen] Point empty %invoke.cont block to successor

2015-08-27 Thread Vedant Kumar via cfe-commits
vsk created this revision.
vsk added reviewers: ygao, rsmith.
vsk added a subscriber: cfe-commits.

When partially initializing a global, exception-handling code in the frontend 
emits a placeholder `%invoke.cont` block with no terminator. This commit adds a 
suitable BranchInst to the block to prevent "malformed BasicBlock" errors.

A test case is included.

Note: I have been struggling to understand why throwing an error in a 
destructor causes exception-handling code to be generated when invoking the 
constructor [esp. when the constructor does not throw anything]. This patch is 
meant as a workaround until the 'real' issue can be addressed.

http://reviews.llvm.org/D12412

Files:
  lib/CodeGen/CGExprAgg.cpp
  test/CodeGenCXX/partial-init.cpp

Index: test/CodeGenCXX/partial-init.cpp
===
--- /dev/null
+++ test/CodeGenCXX/partial-init.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-obj -std=c++11 -x c++ \
+// RUN: -fcxx-exceptions -fexceptions -S -emit-llvm -o - %s | FileCheck %s
+
+namespace std {
+  struct string {
+const char *p;
+string(const char *s) : p(s) {}
+~string() { throw 0; }
+  };
+}
+
+struct Bar {
+  int a;
+};
+
+struct Foo {
+  int b;
+  std::string c;
+  Bar d[32];
+};
+
+static Foo table[] = {
+  { 0, "blerg" },
+};
+
+// CHECK-NOT: does not have terminator
+// CHECK-NOT: Broken function found, compilation aborted
Index: lib/CodeGen/CGExprAgg.cpp
===
--- lib/CodeGen/CGExprAgg.cpp
+++ lib/CodeGen/CGExprAgg.cpp
@@ -493,6 +493,12 @@
 llvm::BasicBlock *entryBB = Builder.GetInsertBlock();
 llvm::BasicBlock *bodyBB = CGF.createBasicBlock("arrayinit.body");
 
+// The exception-handling code in VisitInitListExpr may mark entryBB as
+// a placeholder with an UnreachableInst. Branch to bodyBB as intended.
+if (dyn_cast_or_null(entryBB->getTerminator())) {
+  llvm::BranchInst::Create(bodyBB, entryBB);
+}
+
 // Jump into the body.
 CGF.EmitBlock(bodyBB);
 llvm::PHINode *currentElement =


Index: test/CodeGenCXX/partial-init.cpp
===
--- /dev/null
+++ test/CodeGenCXX/partial-init.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-obj -std=c++11 -x c++ \
+// RUN: -fcxx-exceptions -fexceptions -S -emit-llvm -o - %s | FileCheck %s
+
+namespace std {
+  struct string {
+const char *p;
+string(const char *s) : p(s) {}
+~string() { throw 0; }
+  };
+}
+
+struct Bar {
+  int a;
+};
+
+struct Foo {
+  int b;
+  std::string c;
+  Bar d[32];
+};
+
+static Foo table[] = {
+  { 0, "blerg" },
+};
+
+// CHECK-NOT: does not have terminator
+// CHECK-NOT: Broken function found, compilation aborted
Index: lib/CodeGen/CGExprAgg.cpp
===
--- lib/CodeGen/CGExprAgg.cpp
+++ lib/CodeGen/CGExprAgg.cpp
@@ -493,6 +493,12 @@
 llvm::BasicBlock *entryBB = Builder.GetInsertBlock();
 llvm::BasicBlock *bodyBB = CGF.createBasicBlock("arrayinit.body");
 
+// The exception-handling code in VisitInitListExpr may mark entryBB as
+// a placeholder with an UnreachableInst. Branch to bodyBB as intended.
+if (dyn_cast_or_null(entryBB->getTerminator())) {
+  llvm::BranchInst::Create(bodyBB, entryBB);
+}
+
 // Jump into the body.
 CGF.EmitBlock(bodyBB);
 llvm::PHINode *currentElement =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11950: [CUDA] Check register names on appropriate side of cuda compilation only.

2015-08-27 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246193: [CUDA] Check register names on appropriate side of 
cuda compilation only. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D11950?vs=32611&id=33348#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11950

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaStmtAsm.cpp
  cfe/trunk/test/SemaCUDA/asm-constraints-mixed.cu

Index: cfe/trunk/test/SemaCUDA/asm-constraints-mixed.cu
===
--- cfe/trunk/test/SemaCUDA/asm-constraints-mixed.cu
+++ cfe/trunk/test/SemaCUDA/asm-constraints-mixed.cu
@@ -1,15 +1,39 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
 // RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -fcuda-is-device -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
-// expected-no-diagnostics
+
+__attribute__((device)) register long global_dev_reg asm("r0");
+__attribute__((device)) register long
+global_dev_hreg asm("rax"); // device-side error
+
+register long global_host_reg asm("rax");
+register long global_host_dreg asm("r0"); // host-side error
 
 __attribute__((device)) void df() {
+  register long local_dev_reg asm("r0");
+  register long local_host_reg asm("rax"); // device-side error
   short h;
   // asm with PTX constraints. Some of them are PTX-specific.
-  __asm__("dont care" : "=h"(h): "f"(0.0), "d"(0.0), "h"(0), "r"(0), "l"(0));
+  __asm__("dont care" : "=h"(h) : "f"(0.0), "d"(0.0), "h"(0), "r"(0), "l"(0));
 }
 
 void hf() {
+  register long local_dev_reg asm("r0"); // host-side error
+  register long local_host_reg asm("rax");
   int a;
-  // Asm with x86 constraints that are not supported by PTX.
-  __asm__("dont care" : "=a"(a): "a"(0), "b"(0), "c"(0));
+  // Asm with x86 constraints and registers that are not supported by PTX.
+  __asm__("dont care" : "=a"(a) : "a"(0), "b"(0), "c"(0) : "flags");
 }
+
+// Check errors in named register variables.
+// We should only see errors relevant to current compilation mode.
+#if defined(__CUDA_ARCH__)
+// Device-side compilation:
+// expected-error@8 {{unknown register name 'rax' in asm}}
+// expected-error@15 {{unknown register name 'rax' in asm}}
+#else
+// Host-side compilation:
+// expected-error@11 {{unknown register name 'r0' in asm}}
+// expected-error@22 {{unknown register name 'r0' in asm}}
+#endif
Index: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
===
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp
@@ -155,8 +155,14 @@
   // The parser verifies that there is a string literal here.
   assert(AsmString->isAscii());
 
-  bool ValidateConstraints =
-  DeclAttrsMatchCUDAMode(getLangOpts(), getCurFunctionDecl());
+  // If we're compiling CUDA file and function attributes indicate that it's not
+  // for this compilation side, skip all the checks.
+  if (!DeclAttrsMatchCUDAMode(getLangOpts(), getCurFunctionDecl())) {
+GCCAsmStmt *NS = new (Context) GCCAsmStmt(
+Context, AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs, Names,
+Constraints, Exprs.data(), AsmString, NumClobbers, Clobbers, RParenLoc);
+return NS;
+  }
 
   for (unsigned i = 0; i != NumOutputs; i++) {
 StringLiteral *Literal = Constraints[i];
@@ -167,8 +173,7 @@
   OutputName = Names[i]->getName();
 
 TargetInfo::ConstraintInfo Info(Literal->getString(), OutputName);
-if (ValidateConstraints &&
-!Context.getTargetInfo().validateOutputConstraint(Info))
+if (!Context.getTargetInfo().validateOutputConstraint(Info))
   return StmtError(Diag(Literal->getLocStart(),
 diag::err_asm_invalid_output_constraint)
<< Info.getConstraintStr());
@@ -247,8 +252,7 @@
   InputName = Names[i]->getName();
 
 TargetInfo::ConstraintInfo Info(Literal->getString(), InputName);
-if (ValidateConstraints &&
-!Context.getTargetInfo().validateInputConstraint(
+if (!Context.getTargetInfo().validateInputConstraint(
 OutputConstraintInfos.data(), NumOutputs, Info)) {
   return StmtError(Diag(Literal->getLocStart(),
 diag::err_asm_invalid_input_constraint)
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -5998,7 +5998,8 @@
 break;
   case SC_Register:
 // Local Named register
-if (!Context.getTargetInfo().isValidGCCRegisterName(Label))
+if (!Context.getTargetInfo().isValidGCCRegisterName(Label) &&
+DeclAttrsMatchCUDAMode(getLangOpts(), getCurFunctionDecl()))
   Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
 break;
   case SC_Static:
@@ -6009,7 +6010,8 @@
   

r246193 - [CUDA] Check register names on appropriate side of cuda compilation only.

2015-08-27 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Aug 27 14:54:21 2015
New Revision: 246193

URL: http://llvm.org/viewvc/llvm-project?rev=246193&view=rev
Log:
[CUDA] Check register names on appropriate side of cuda compilation only.

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
cfe/trunk/test/SemaCUDA/asm-constraints-mixed.cu

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=246193&r1=246192&r2=246193&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Aug 27 14:54:21 2015
@@ -5998,7 +5998,8 @@ Sema::ActOnVariableDeclarator(Scope *S,
 break;
   case SC_Register:
 // Local Named register
-if (!Context.getTargetInfo().isValidGCCRegisterName(Label))
+if (!Context.getTargetInfo().isValidGCCRegisterName(Label) &&
+DeclAttrsMatchCUDAMode(getLangOpts(), getCurFunctionDecl()))
   Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
 break;
   case SC_Static:
@@ -6009,7 +6010,8 @@ Sema::ActOnVariableDeclarator(Scope *S,
   }
 } else if (SC == SC_Register) {
   // Global Named register
-  if (!Context.getTargetInfo().isValidGCCRegisterName(Label))
+  if (!Context.getTargetInfo().isValidGCCRegisterName(Label) &&
+  DeclAttrsMatchCUDAMode(getLangOpts(), NewVD))
 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
   if (!R->isIntegralType(Context) && !R->isPointerType()) {
 Diag(D.getLocStart(), diag::err_asm_bad_register_type);

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=246193&r1=246192&r2=246193&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Thu Aug 27 14:54:21 2015
@@ -155,8 +155,14 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
   // The parser verifies that there is a string literal here.
   assert(AsmString->isAscii());
 
-  bool ValidateConstraints =
-  DeclAttrsMatchCUDAMode(getLangOpts(), getCurFunctionDecl());
+  // If we're compiling CUDA file and function attributes indicate that it's 
not
+  // for this compilation side, skip all the checks.
+  if (!DeclAttrsMatchCUDAMode(getLangOpts(), getCurFunctionDecl())) {
+GCCAsmStmt *NS = new (Context) GCCAsmStmt(
+Context, AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs, Names,
+Constraints, Exprs.data(), AsmString, NumClobbers, Clobbers, 
RParenLoc);
+return NS;
+  }
 
   for (unsigned i = 0; i != NumOutputs; i++) {
 StringLiteral *Literal = Constraints[i];
@@ -167,8 +173,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
   OutputName = Names[i]->getName();
 
 TargetInfo::ConstraintInfo Info(Literal->getString(), OutputName);
-if (ValidateConstraints &&
-!Context.getTargetInfo().validateOutputConstraint(Info))
+if (!Context.getTargetInfo().validateOutputConstraint(Info))
   return StmtError(Diag(Literal->getLocStart(),
 diag::err_asm_invalid_output_constraint)
<< Info.getConstraintStr());
@@ -247,8 +252,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
   InputName = Names[i]->getName();
 
 TargetInfo::ConstraintInfo Info(Literal->getString(), InputName);
-if (ValidateConstraints &&
-!Context.getTargetInfo().validateInputConstraint(
+if (!Context.getTargetInfo().validateInputConstraint(
 OutputConstraintInfos.data(), NumOutputs, Info)) {
   return StmtError(Diag(Literal->getLocStart(),
 diag::err_asm_invalid_input_constraint)

Modified: cfe/trunk/test/SemaCUDA/asm-constraints-mixed.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/asm-constraints-mixed.cu?rev=246193&r1=246192&r2=246193&view=diff
==
--- cfe/trunk/test/SemaCUDA/asm-constraints-mixed.cu (original)
+++ cfe/trunk/test/SemaCUDA/asm-constraints-mixed.cu Thu Aug 27 14:54:21 2015
@@ -1,15 +1,39 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
 // RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -fcuda-is-device 
-verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
-// expected-no-diagnostics
+
+__attribute__((device)) register long global_dev_reg asm("r0");
+__attribute__((device)) register long
+global_dev_hreg asm("rax"); // device-side error
+
+register long global_host_reg asm("rax");
+register long global_host_dreg asm("r0"); // host-side error
 
 __attribute__((device)) void df() {
+  register long local_dev_reg asm("r0");
+  register long loca

r246195 - Rewrite the code generation handling for function feature and cpu attributes.

2015-08-27 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Aug 27 14:59:34 2015
New Revision: 246195

URL: http://llvm.org/viewvc/llvm-project?rev=246195&view=rev
Log:
Rewrite the code generation handling for function feature and cpu attributes.

A couple of changes here:

a) Do less work in the case where we don't have a target attribute on the
function. We've already canonicalized the attributes for the function -
no need to do more work.

b) Use the newer canonicalized feature adding functions from TargetInfo
to do the work when we do have a target attribute. This enables us to diagnose
some warnings in the case of conflicting written attributes (only ppc does
this today) and also make sure to get all of the features for a cpu that's
listed rather than just change the cpu.

Updated all testcases accordingly and added a new testcase to verify that we'll
error out on ppc if we have some incompatible options using the existing 
diagnosis
framework there.

Added:
cfe/trunk/test/CodeGen/attr-target-ppc.c
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGen/attr-target.c

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=246195&r1=246194&r2=246195&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Aug 27 14:59:34 2015
@@ -1496,70 +1496,78 @@ void CodeGenModule::ConstructAttributeLi
 // we have a decl for the function and it has a target attribute then
 // parse that and add it to the feature set.
 StringRef TargetCPU = getTarget().getTargetOpts().CPU;
-
-// TODO: Features gets us the features on the command line including
-// feature dependencies. For canonicalization purposes we might want to
-// avoid putting features in the target-features set if we know it'll be
-// one of the default features in the backend, e.g. corei7-avx and +avx or
-// figure out non-explicit dependencies.
-// Canonicalize the existing features in a new feature map.
-// TODO: Migrate the existing backends to keep the map around rather than
-// the vector.
-llvm::StringMap FeatureMap;
-for (auto F : getTarget().getTargetOpts().Features) {
-  const char *Name = F.c_str();
-  bool Enabled = Name[0] == '+';
-  getTarget().setFeatureEnabled(FeatureMap, Name + 1, Enabled);
-}
-
 const FunctionDecl *FD = dyn_cast_or_null(TargetDecl);
-if (FD) {
-  if (const auto *TD = FD->getAttr()) {
-StringRef FeaturesStr = TD->getFeatures();
-SmallVector AttrFeatures;
-FeaturesStr.split(AttrFeatures, ",");
-
-// Grab the various features and prepend a "+" to turn on the feature 
to
-// the backend and add them to our existing set of features.
-for (auto &Feature : AttrFeatures) {
-  // Go ahead and trim whitespace rather than either erroring or
-  // accepting it weirdly.
-  Feature = Feature.trim();
-
-  // While we're here iterating check for a different target cpu.
-  if (Feature.startswith("arch="))
-TargetCPU = Feature.split("=").second.trim();
-  else if (Feature.startswith("tune="))
-// We don't support cpu tuning this way currently.
-;
-  else if (Feature.startswith("fpmath="))
-// TODO: Support the fpmath option this way. It will require 
checking
-// overall feature validity for the function with the rest of the
-// attributes on the function.
-;
-  else if (Feature.startswith("mno-"))
-getTarget().setFeatureEnabled(FeatureMap, 
Feature.split("-").second,
-  false);
-  else
-getTarget().setFeatureEnabled(FeatureMap, Feature, true);
-}
+if (FD && FD->getAttr()) {
+  llvm::StringMap FeatureMap;
+  const auto *TD = FD->getAttr();
+
+  // Make a copy of the features as passed on the command line.
+  std::vector FnFeatures(
+  getTarget().getTargetOpts().FeaturesAsWritten);
+
+  // Grab the target attribute string.
+  StringRef FeaturesStr = TD->getFeatures();
+  SmallVector AttrFeatures;
+  FeaturesStr.split(AttrFeatures, ",");
+
+  // Grab the various features and prepend a "+" to turn on the feature to
+  // the backend and add them to our existing set of features.
+  for (auto &Feature : AttrFeatures) {
+// Go ahead and trim whitespace rather than either erroring or
+// accepting it weirdly.
+Feature = Feature.trim();
+
+// While we're here iterating check for a different target cpu.
+if (Feature.startswith("arch="))
+  TargetCPU = Feature.split("=").second.trim();
+else if (Feature.startswith("tune="))
+  // We don't support cpu tuning this way currently.
+  ;
+else if (Fea

Re: [PATCH] D12385: Generating Assumption loads fix

2015-08-27 Thread Piotr Padlewski via cfe-commits
Prazek marked an inline comment as done.
Prazek added a comment.

http://reviews.llvm.org/D12385



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


Re: [PATCH] D12390: Also enable the avx/avx512 ABIs for i386, not just x86_64.

2015-08-27 Thread Ahmed Bougacha via cfe-commits
ab added a comment.

Unless I'm misunderstanding, I believe this has much less impact than you're 
thinking; there are three cases:

- x86_64: no change (-mno-mmx is guarded by x86)
- x86, with -mno-mmx: no change (because previously, we'd only set avx/avx512 
for x86_64)
- x86, without -mno-mmx: this will use an avx/avx512 ABI string where we'd have 
used "", letting us use the better alignment (only for OpenMP and vectors, I 
think).


http://reviews.llvm.org/D12390



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


Re: [PATCH] D12389: Conditionalize X86 Darwin MaxVectorAlign on the presence of AVX.

2015-08-27 Thread Ahmed Bougacha via cfe-commits
ab accepted this revision.
ab added a reviewer: ab.
ab added a comment.
This revision is now accepted and ready to land.

Yep, thanks!


http://reviews.llvm.org/D12389



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


r246197 - Target attribute syntax compatibility fix - gcc uses no- rather than mno-.

2015-08-27 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Aug 27 15:05:48 2015
New Revision: 246197

URL: http://llvm.org/viewvc/llvm-project?rev=246197&view=rev
Log:
Target attribute syntax compatibility fix - gcc uses no- rather than mno-.

Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGen/attr-target-ppc.c
cfe/trunk/test/CodeGen/attr-target-x86.c

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=246197&r1=246196&r2=246197&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Aug 27 15:05:48 2015
@@ -1528,7 +1528,7 @@ void CodeGenModule::ConstructAttributeLi
   // overall feature validity for the function with the rest of the
   // attributes on the function.
   ;
-else if (Feature.startswith("mno-"))
+else if (Feature.startswith("no-"))
   FnFeatures.push_back("-" + Feature.split("-").second.str());
 else
   FnFeatures.push_back("+" + Feature.str());

Modified: cfe/trunk/test/CodeGen/attr-target-ppc.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-ppc.c?rev=246197&r1=246196&r2=246197&view=diff
==
--- cfe/trunk/test/CodeGen/attr-target-ppc.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-ppc.c Thu Aug 27 15:05:48 2015
@@ -1,4 +1,4 @@
 // RUN: not %clang_cc1 -triple powerpc64le-linux-gnu -emit-llvm %s -o -
 
-long __attribute__((target("power8-vector,mno-vsx"))) foo (void) { return 0; } 
 // expected-error {{option '-mpower8-vector' cannot be specified with 
'-mno-vsx'}}
+long __attribute__((target("power8-vector,no-vsx"))) foo (void) { return 0; }  
// expected-error {{option '-mpower8-vector' cannot be specified with 
'-mno-vsx'}}
 

Modified: cfe/trunk/test/CodeGen/attr-target-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-x86.c?rev=246197&r1=246196&r2=246197&view=diff
==
--- cfe/trunk/test/CodeGen/attr-target-x86.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-x86.c Thu Aug 27 15:05:48 2015
@@ -7,14 +7,14 @@ int __attribute__((target("avx,sse4.2,ar
 int __attribute__((target("tune=sandybridge"))) walrus(int a) { return 4; }
 int __attribute__((target("fpmath=387"))) koala(int a) { return 4; }
 
-int __attribute__((target("mno-sse2"))) echidna(int a) { return 4; }
+int __attribute__((target("no-sse2"))) echidna(int a) { return 4; }
 
 int __attribute__((target("sse4"))) panda(int a) { return 4; }
 
 int bar(int a) { return baz(a) + foo(a); }
 
 int __attribute__((target("avx,  sse4.2,  arch=   ivybridge"))) 
qux(int a) { return 4; }
-int __attribute__((target("mno-aes, arch=ivybridge"))) qax(int a) { return 4; }
+int __attribute__((target("no-aes, arch=ivybridge"))) qax(int a) { return 4; }
 
 // Check that we emit the additional subtarget and cpu features for foo and 
not for baz or bar.
 // CHECK: baz{{.*}} #0


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


r246196 - Rename this file to have a processor suffix to help identify.

2015-08-27 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Aug 27 15:05:46 2015
New Revision: 246196

URL: http://llvm.org/viewvc/llvm-project?rev=246196&view=rev
Log:
Rename this file to have a processor suffix to help identify.

Added:
cfe/trunk/test/CodeGen/attr-target-x86.c
  - copied, changed from r246195, cfe/trunk/test/CodeGen/attr-target.c
Removed:
cfe/trunk/test/CodeGen/attr-target.c

Copied: cfe/trunk/test/CodeGen/attr-target-x86.c (from r246195, 
cfe/trunk/test/CodeGen/attr-target.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-x86.c?p2=cfe/trunk/test/CodeGen/attr-target-x86.c&p1=cfe/trunk/test/CodeGen/attr-target.c&r1=246195&r2=246196&rev=246196&view=diff
==
(empty)

Removed: cfe/trunk/test/CodeGen/attr-target.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target.c?rev=246195&view=auto
==
--- cfe/trunk/test/CodeGen/attr-target.c (original)
+++ cfe/trunk/test/CodeGen/attr-target.c (removed)
@@ -1,34 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -target-cpu x86-64 -emit-llvm %s 
-o - | FileCheck %s
-
-int baz(int a) { return 4; }
-
-int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(int a) { return 
4; }
-
-int __attribute__((target("tune=sandybridge"))) walrus(int a) { return 4; }
-int __attribute__((target("fpmath=387"))) koala(int a) { return 4; }
-
-int __attribute__((target("mno-sse2"))) echidna(int a) { return 4; }
-
-int __attribute__((target("sse4"))) panda(int a) { return 4; }
-
-int bar(int a) { return baz(a) + foo(a); }
-
-int __attribute__((target("avx,  sse4.2,  arch=   ivybridge"))) 
qux(int a) { return 4; }
-int __attribute__((target("mno-aes, arch=ivybridge"))) qax(int a) { return 4; }
-
-// Check that we emit the additional subtarget and cpu features for foo and 
not for baz or bar.
-// CHECK: baz{{.*}} #0
-// CHECK: foo{{.*}} #1
-// We ignore the tune attribute so walrus should be identical to baz and bar.
-// CHECK: walrus{{.*}} #0
-// We're currently ignoring the fpmath attribute so koala should be identical 
to baz and bar.
-// CHECK: koala{{.*}} #0
-// CHECK: echidna{{.*}} #2
-// CHECK: bar{{.*}} #0
-// CHECK: qux{{.*}} #1
-// CHECK: qax{{.*}} #4
-// CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+sse,+sse2"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+pclmul,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
-// CHECK: #2 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+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"
-// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
-// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+pclmul,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,-aes"


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


Re: [PATCH] D12163: [Patch] [Analyzer] BugReporter.cpp:2869: Assertion failed: !RemainingNodes.empty() && "No error node found in the trimmed graph" (PR 24184)

2015-08-27 Thread Ying Yi via cfe-commits
MaggieYi added a comment.

Thanks for helping me review and submit the patch.


http://reviews.llvm.org/D12163



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


Re: [PATCH] D12401: Handling i686 architecture in makefiles for clang.

2015-08-27 Thread Alexey Samsonov via cfe-commits
samsonov added a comment.

See my comment in a different CL - I would strongly prefer to not touch 
autoconf build system unless absolutely necessary.


Repository:
  rL LLVM

http://reviews.llvm.org/D12401



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


Re: r246027 - Convert a bunch of loops to ranged-for and clean up accordingly.

2015-08-27 Thread Justin Bogner via cfe-commits
Eric Christopher via cfe-commits  writes:
> Author: echristo
> Date: Wed Aug 26 03:21:55 2015
> New Revision: 246027
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246027&view=rev
> Log:
> Convert a bunch of loops to ranged-for and clean up accordingly.
>
> Modified:
> cfe/trunk/lib/Basic/Targets.cpp
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=246027&r1=246026&r2=246027&view=diff
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Wed Aug 26 03:21:55 2015
> @@ -1023,53 +1023,24 @@ const Builtin::Info PPCTargetInfo::Built
>  /// configured set of features.
>  bool PPCTargetInfo::handleTargetFeatures(std::vector &Features,
>   DiagnosticsEngine &Diags) {
> -  for (unsigned i = 0, e = Features.size(); i !=e; ++i) {
> -// Ignore disabled features.
> -if (Features[i][0] == '-')
> -  continue;
> -
> -StringRef Feature = StringRef(Features[i]).substr(1);
> -
> -if (Feature == "vsx") {
> +  for (const auto &Feature : Features) {
> +if (Feature == "+vsx") {
>HasVSX = true;
> -  continue;
> -}
> -
> -if (Feature == "bpermd") {
> +} else if (Feature == "+bpermd") {
>HasBPERMD = true;
> -  continue;
> -}
> -
> -if (Feature == "extdiv") {
> +} else if (Feature == "+extdiv") {
>HasExtDiv = true;
> -  continue;
> -}
> -
> -if (Feature == "power8-vector") {
> +} else if (Feature == "+power8-vector") {
>HasP8Vector = true;
> -  continue;
> -}
> -
> -if (Feature == "crypto") {
> +} else if (Feature == "+crypto") {
>HasP8Crypto = true;
> -  continue;
> -}
> -
> -if (Feature == "direct-move") {
> +} else if (Feature == "+direct-move") {
>HasDirectMove = true;
> -  continue;
> -}
> -
> -if (Feature == "qpx") {
> +} else if (Feature == "+qpx") {
>HasQPX = true;
> -  continue;
> -}
> -
> -if (Feature == "htm") {
> +} else if (Feature == "+htm") {
>HasHTM = true;
> -  continue;
>  }
> -
>  // TODO: Finish this list and add an assert that we've handled them
>  // all.
>}
> @@ -2886,155 +2857,84 @@ void X86TargetInfo::setFeatureEnabledImp
>  /// configured set of features.
>  bool X86TargetInfo::handleTargetFeatures(std::vector &Features,
>   DiagnosticsEngine &Diags) {
> -  // Remember the maximum enabled sselevel.
> -  for (unsigned i = 0, e = Features.size(); i !=e; ++i) {
> -// Ignore disabled features.
> -if (Features[i][0] == '-')
> +  for (const auto &Feature : Features) {
> +if (Feature[0] != '+')
>continue;
>  
> -StringRef Feature = StringRef(Features[i]).substr(1);
> -
> -if (Feature == "aes") {
> +if (Feature == "+aes") {
>HasAES = true;
> -  continue;
> -}
> -
> -if (Feature == "pclmul") {
> +} else if (Feature == "+pclmul") {
>HasPCLMUL = true;
> -  continue;
> -}
> -
> -if (Feature == "lzcnt") {
> +} else if (Feature == "+lzcnt") {
>HasLZCNT = true;
> -  continue;
> -}
> -
> -if (Feature == "rdrnd") {
> +} else if (Feature == "+rdrnd") {
>HasRDRND = true;
> -  continue;
> -}
> -
> -if (Feature == "fsgsbase") {
> +} else if (Feature == "+fsgsbase") {
>HasFSGSBASE = true;
> -  continue;
> -}
> -
> -if (Feature == "bmi") {
> +} else if (Feature == "+bmi") {
>HasBMI = true;
> -  continue;
> -}
> -
> -if (Feature == "bmi2") {
> +} else if (Feature == "+bmi2") {
>HasBMI2 = true;
> -  continue;
> -}
> -
> -if (Feature == "popcnt") {
> +} else if (Feature == "+popcnt") {
>HasPOPCNT = true;
> -  continue;
> -}
> -
> -if (Feature == "rtm") {
> +} else if (Feature == "+rtm") {
>HasRTM = true;
> -  continue;
> -}
> -
> -if (Feature == "prfchw") {
> +} else if (Feature == "+prfchw") {
>HasPRFCHW = true;
> -  continue;
> -}
> -
> -if (Feature == "rdseed") {
> +} else if (Feature == "+rdseed") {
>HasRDSEED = true;
> -  continue;
> -}
> -
> -if (Feature == "adx") {
> +} else if (Feature == "+adx") {
>HasADX = true;
> -  continue;
> -}
> -
> -if (Feature == "tbm") {
> +} else if (Feature == "+tbm") {
>HasTBM = true;
> -  continue;
> -}
> -
> -if (Feature == "fma") {
> +} else if (Feature == "+fma") {
>HasFMA = true;
> -  continue;
> -}
> -
> -if (Feature == "f16c") {
> +} else if (Feature == "+f16c") {
>HasF16C = true;
> -  continue;
> -}
> -
> -if (Feature == "avx512cd") {
> +} else if (Feature == "+avx512cd") {
>HasAVX512CD = true;
> -  con

Re: r246027 - Convert a bunch of loops to ranged-for and clean up accordingly.

2015-08-27 Thread Eric Christopher via cfe-commits
>
>
> > -assert(Features[i][0] == '+' && "Invalid target feature!");
> > +assert(Feature[0] == '+' && "Invalid target feature!");
>
> This assert is kind of pointless now, since we'll have continued in that
> case and the following code will DTRT anyway.
>
>
Was fairly pointless to begin with. I'll remove it :)

-eric


> >  X86SSEEnum Level = llvm::StringSwitch(Feature)
> > -  .Case("avx512f", AVX512F)
> > -  .Case("avx2", AVX2)
> > -  .Case("avx", AVX)
> > -  .Case("sse4.2", SSE42)
> > -  .Case("sse4.1", SSE41)
> > -  .Case("ssse3", SSSE3)
> > -  .Case("sse3", SSE3)
> > -  .Case("sse2", SSE2)
> > -  .Case("sse", SSE1)
> > +  .Case("+avx512f", AVX512F)
> > +  .Case("+avx2", AVX2)
> > +  .Case("+avx", AVX)
> > +  .Case("+sse4.2", SSE42)
> > +  .Case("+sse4.1", SSE41)
> > +  .Case("+ssse3", SSSE3)
> > +  .Case("+sse3", SSE3)
> > +  .Case("+sse2", SSE2)
> > +  .Case("+sse", SSE1)
> >.Default(NoSSE);
> >  SSELevel = std::max(SSELevel, Level);
> >
> >  MMX3DNowEnum ThreeDNowLevel =
> >llvm::StringSwitch(Feature)
> > -.Case("3dnowa", AMD3DNowAthlon)
> > -.Case("3dnow", AMD3DNow)
> > -.Case("mmx", MMX)
> > +.Case("+3dnowa", AMD3DNowAthlon)
> > +.Case("+3dnow", AMD3DNow)
> > +.Case("+mmx", MMX)
> >  .Default(NoMMX3DNow);
> >  MMX3DNowLevel = std::max(MMX3DNowLevel, ThreeDNowLevel);
> >
> >  XOPEnum XLevel = llvm::StringSwitch(Feature)
> > -.Case("xop", XOP)
> > -.Case("fma4", FMA4)
> > -.Case("sse4a", SSE4A)
> > +.Case("+xop", XOP)
> > +.Case("+fma4", FMA4)
> > +.Case("+sse4a", SSE4A)
> >  .Default(NoXOP);
> >  XOPLevel = std::max(XOPLevel, XLevel);
> >}
> > @@ -5247,12 +5147,12 @@ public:
> >  FPU = FPUMode;
> >  CRC = 0;
> >  Crypto = 0;
> > -for (unsigned i = 0, e = Features.size(); i != e; ++i) {
> > -  if (Features[i] == "+neon")
> > +for (const auto &Feature : Features) {
> > +  if (Feature == "+neon")
> >  FPU = NeonMode;
> > -  if (Features[i] == "+crc")
> > +  if (Feature == "+crc")
> >  CRC = 1;
> > -  if (Features[i] == "+crypto")
> > +  if (Feature == "+crypto")
> >  Crypto = 1;
> >  }
> >
> > @@ -5926,10 +5826,10 @@ public:
> >bool handleTargetFeatures(std::vector &Features,
> >  DiagnosticsEngine &Diags) override {
> >  HasTransactionalExecution = false;
> > -for (unsigned i = 0, e = Features.size(); i != e; ++i) {
> > -  if (Features[i] == "+transactional-execution")
> > +for (const auto &Feature : Features) {
> > +  if (Feature == "+transactional-execution")
> >  HasTransactionalExecution = true;
> > -  if (Features[i] == "+vector")
> > +  else if (Feature == "+vector")
> >  HasVector = true;
> >  }
> >  // If we use the vector ABI, vector types are 64-bit aligned.
> > @@ -6477,29 +6377,28 @@ public:
> >  DspRev = NoDSP;
> >  HasFP64 = isFP64Default();
> >
> > -for (std::vector::iterator it = Features.begin(),
> > - ie = Features.end(); it != ie; ++it) {
> > -  if (*it == "+single-float")
> > +for (const auto &Feature : Features) {
> > +  if (Feature == "+single-float")
> >  IsSingleFloat = true;
> > -  else if (*it == "+soft-float")
> > +  else if (Feature == "+soft-float")
> >  FloatABI = SoftFloat;
> > -  else if (*it == "+mips16")
> > +  else if (Feature == "+mips16")
> >  IsMips16 = true;
> > -  else if (*it == "+micromips")
> > +  else if (Feature == "+micromips")
> >  IsMicromips = true;
> > -  else if (*it == "+dsp")
> > +  else if (Feature == "+dsp")
> >  DspRev = std::max(DspRev, DSP1);
> > -  else if (*it == "+dspr2")
> > +  else if (Feature == "+dspr2")
> >  DspRev = std::max(DspRev, DSP2);
> > -  else if (*it == "+msa")
> > +  else if (Feature == "+msa")
> >  HasMSA = true;
> > -  else if (*it == "+fp64")
> > +  else if (Feature == "+fp64")
> >  HasFP64 = true;
> > -  else if (*it == "-fp64")
> > +  else if (Feature == "-fp64")
> >  HasFP64 = false;
> > -  else if (*it == "+nan2008")
> > +  else if (Feature == "+nan2008")
> >  IsNan2008 = true;
> > -  else if (*it == "-nan2008")
> > +  else if (Feature == "-nan2008")
> >  IsNan2008 = 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


r246200 - [X86] Add __builtin_ia32_undef* intrinsics to test

2015-08-27 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Aug 27 15:29:13 2015
New Revision: 246200

URL: http://llvm.org/viewvc/llvm-project?rev=246200&view=rev
Log:
[X86] Add __builtin_ia32_undef* intrinsics to test

Minor tweak to rL246083

Modified:
cfe/trunk/test/CodeGen/builtins-x86.c

Modified: cfe/trunk/test/CodeGen/builtins-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-x86.c?rev=246200&r1=246199&r2=246200&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-x86.c (original)
+++ cfe/trunk/test/CodeGen/builtins-x86.c Thu Aug 27 15:29:13 2015
@@ -102,6 +102,9 @@ void f0() {
   const V4d* tmp_V4dCp;
   const V8f* tmp_V8fCp;
 
+  tmp_V2LLi = __builtin_ia32_undef128();
+  tmp_V4LLi = __builtin_ia32_undef256();
+
   tmp_i = __builtin_ia32_comieq(tmp_V4f, tmp_V4f);
   tmp_i = __builtin_ia32_comilt(tmp_V4f, tmp_V4f);
   tmp_i = __builtin_ia32_comile(tmp_V4f, tmp_V4f);


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


r246202 - Remove a dead assert, we'd have gotten the case above.

2015-08-27 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Aug 27 15:32:24 2015
New Revision: 246202

URL: http://llvm.org/viewvc/llvm-project?rev=246202&view=rev
Log:
Remove a dead assert, we'd have gotten the case above.

Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=246202&r1=246201&r2=246202&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Aug 27 15:32:24 2015
@@ -2917,7 +2917,6 @@ bool X86TargetInfo::handleTargetFeatures
   HasCX16 = true;
 }
 
-assert(Feature[0] == '+' && "Invalid target feature!");
 X86SSEEnum Level = llvm::StringSwitch(Feature)
   .Case("+avx512f", AVX512F)
   .Case("+avx2", AVX2)


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


Re: r246027 - Convert a bunch of loops to ranged-for and clean up accordingly.

2015-08-27 Thread Eric Christopher via cfe-commits
On Thu, Aug 27, 2015 at 1:29 PM Eric Christopher  wrote:

>
>> > -assert(Features[i][0] == '+' && "Invalid target feature!");
>> > +assert(Feature[0] == '+' && "Invalid target feature!");
>>
>> This assert is kind of pointless now, since we'll have continued in that
>> case and the following code will DTRT anyway.
>>
>>
> Was fairly pointless to begin with. I'll remove it :)
>

dzur:~/sources/llvm/tools/clang> git svn dcommit
Committing to https://llvm.org/svn/llvm-project/cfe/trunk ...
M lib/Basic/Targets.cpp
Committed r246202

Thanks!

-eric


>
> -eric
>
>
>> >  X86SSEEnum Level = llvm::StringSwitch(Feature)
>> > -  .Case("avx512f", AVX512F)
>> > -  .Case("avx2", AVX2)
>> > -  .Case("avx", AVX)
>> > -  .Case("sse4.2", SSE42)
>> > -  .Case("sse4.1", SSE41)
>> > -  .Case("ssse3", SSSE3)
>> > -  .Case("sse3", SSE3)
>> > -  .Case("sse2", SSE2)
>> > -  .Case("sse", SSE1)
>> > +  .Case("+avx512f", AVX512F)
>> > +  .Case("+avx2", AVX2)
>> > +  .Case("+avx", AVX)
>> > +  .Case("+sse4.2", SSE42)
>> > +  .Case("+sse4.1", SSE41)
>> > +  .Case("+ssse3", SSSE3)
>> > +  .Case("+sse3", SSE3)
>> > +  .Case("+sse2", SSE2)
>> > +  .Case("+sse", SSE1)
>> >.Default(NoSSE);
>> >  SSELevel = std::max(SSELevel, Level);
>> >
>> >  MMX3DNowEnum ThreeDNowLevel =
>> >llvm::StringSwitch(Feature)
>> > -.Case("3dnowa", AMD3DNowAthlon)
>> > -.Case("3dnow", AMD3DNow)
>> > -.Case("mmx", MMX)
>> > +.Case("+3dnowa", AMD3DNowAthlon)
>> > +.Case("+3dnow", AMD3DNow)
>> > +.Case("+mmx", MMX)
>> >  .Default(NoMMX3DNow);
>> >  MMX3DNowLevel = std::max(MMX3DNowLevel, ThreeDNowLevel);
>> >
>> >  XOPEnum XLevel = llvm::StringSwitch(Feature)
>> > -.Case("xop", XOP)
>> > -.Case("fma4", FMA4)
>> > -.Case("sse4a", SSE4A)
>> > +.Case("+xop", XOP)
>> > +.Case("+fma4", FMA4)
>> > +.Case("+sse4a", SSE4A)
>> >  .Default(NoXOP);
>> >  XOPLevel = std::max(XOPLevel, XLevel);
>> >}
>> > @@ -5247,12 +5147,12 @@ public:
>> >  FPU = FPUMode;
>> >  CRC = 0;
>> >  Crypto = 0;
>> > -for (unsigned i = 0, e = Features.size(); i != e; ++i) {
>> > -  if (Features[i] == "+neon")
>> > +for (const auto &Feature : Features) {
>> > +  if (Feature == "+neon")
>> >  FPU = NeonMode;
>> > -  if (Features[i] == "+crc")
>> > +  if (Feature == "+crc")
>> >  CRC = 1;
>> > -  if (Features[i] == "+crypto")
>> > +  if (Feature == "+crypto")
>> >  Crypto = 1;
>> >  }
>> >
>> > @@ -5926,10 +5826,10 @@ public:
>> >bool handleTargetFeatures(std::vector &Features,
>> >  DiagnosticsEngine &Diags) override {
>> >  HasTransactionalExecution = false;
>> > -for (unsigned i = 0, e = Features.size(); i != e; ++i) {
>> > -  if (Features[i] == "+transactional-execution")
>> > +for (const auto &Feature : Features) {
>> > +  if (Feature == "+transactional-execution")
>> >  HasTransactionalExecution = true;
>> > -  if (Features[i] == "+vector")
>> > +  else if (Feature == "+vector")
>> >  HasVector = true;
>> >  }
>> >  // If we use the vector ABI, vector types are 64-bit aligned.
>> > @@ -6477,29 +6377,28 @@ public:
>> >  DspRev = NoDSP;
>> >  HasFP64 = isFP64Default();
>> >
>> > -for (std::vector::iterator it = Features.begin(),
>> > - ie = Features.end(); it != ie; ++it) {
>> > -  if (*it == "+single-float")
>> > +for (const auto &Feature : Features) {
>> > +  if (Feature == "+single-float")
>> >  IsSingleFloat = true;
>> > -  else if (*it == "+soft-float")
>> > +  else if (Feature == "+soft-float")
>> >  FloatABI = SoftFloat;
>> > -  else if (*it == "+mips16")
>> > +  else if (Feature == "+mips16")
>> >  IsMips16 = true;
>> > -  else if (*it == "+micromips")
>> > +  else if (Feature == "+micromips")
>> >  IsMicromips = true;
>> > -  else if (*it == "+dsp")
>> > +  else if (Feature == "+dsp")
>> >  DspRev = std::max(DspRev, DSP1);
>> > -  else if (*it == "+dspr2")
>> > +  else if (Feature == "+dspr2")
>> >  DspRev = std::max(DspRev, DSP2);
>> > -  else if (*it == "+msa")
>> > +  else if (Feature == "+msa")
>> >  HasMSA = true;
>> > -  else if (*it == "+fp64")
>> > +  else if (Feature == "+fp64")
>> >  HasFP64 = true;
>> > -  else if (*it == "-fp64")
>> > +  else if (Feature == "-fp64")
>> >  HasFP64 = false;
>> > -  else if (*it == "+nan2008")
>> > +  else if (Feature == "+nan2008")
>> >  IsNan2008 = true;
>> > -  else if (*it == "-nan2008")
>> > +  else if (Feature == "-nan2008")
>> >  IsNan2008 = false;
>> >  }
>> >
>> >
>> >
>> > ___
>> > cfe-commits mailing list
>> >

r246204 - [X86][F16C] Added debug codegen test for F16C intrinsics

2015-08-27 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Aug 27 15:34:02 2015
New Revision: 246204

URL: http://llvm.org/viewvc/llvm-project?rev=246204&view=rev
Log:
[X86][F16C] Added debug codegen test for F16C intrinsics

Part of PR24590

Modified:
cfe/trunk/test/CodeGen/f16c-builtins.c

Modified: cfe/trunk/test/CodeGen/f16c-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/f16c-builtins.c?rev=246204&r1=246203&r2=246204&view=diff
==
--- cfe/trunk/test/CodeGen/f16c-builtins.c (original)
+++ cfe/trunk/test/CodeGen/f16c-builtins.c Thu Aug 27 15:34:02 2015
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +f16c 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +f16c 
-emit-llvm -o - -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +f16c -S 
-o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
 
 // Don't include mm_malloc.h, it's system specific.
 #define __MM_MALLOC_H
@@ -7,20 +8,24 @@
 
 __m128 test_mm_cvtph_ps(__m128i a) {
   // CHECK: @llvm.x86.vcvtph2ps.128
+  // CHECK-ASM: vcvtph2ps %xmm{{.*}}, %xmm{{.*}}
   return _mm_cvtph_ps(a);
 }
 
 __m256 test_mm256_cvtph_ps(__m128i a) {
   // CHECK: @llvm.x86.vcvtph2ps.256
+  // CHECK-ASM: vcvtph2ps %xmm{{.*}}, %ymm{{.*}}
   return _mm256_cvtph_ps(a);
 }
 
 __m128i test_mm_cvtps_ph(__m128 a) {
   // CHECK: @llvm.x86.vcvtps2ph.128
+  // CHECK-ASM: vcvtps2ph $0, %xmm{{.*}}, %xmm{{.*}}
   return _mm_cvtps_ph(a, 0);
 }
 
 __m128i test_mm256_cvtps_ph(__m256 a) {
   // CHECK: @llvm.x86.vcvtps2ph.256
+  // CHECK-ASM: vcvtps2ph $0, %ymm{{.*}}, %xmm{{.*}}
   return _mm256_cvtps_ph(a, 0);
 }


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


r246206 - [X86][FMA4] Added debug codegen test for FMA4 intrinsics

2015-08-27 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Aug 27 15:41:45 2015
New Revision: 246206

URL: http://llvm.org/viewvc/llvm-project?rev=246206&view=rev
Log:
[X86][FMA4] Added debug codegen test for FMA4 intrinsics

Part of PR24590

Modified:
cfe/trunk/test/CodeGen/fma4-builtins.c

Modified: cfe/trunk/test/CodeGen/fma4-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/fma4-builtins.c?rev=246206&r1=246205&r2=246206&view=diff
==
--- cfe/trunk/test/CodeGen/fma4-builtins.c (original)
+++ cfe/trunk/test/CodeGen/fma4-builtins.c Thu Aug 27 15:41:45 2015
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +fma4 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +fma4 
-emit-llvm -o - -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +fma4 -S 
-o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
 
 // Don't include mm_malloc.h, it's system specific.
 #define __MM_MALLOC_H
@@ -7,160 +8,192 @@
 
 __m128 test_mm_macc_ps(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfmadd.ps
+  // CHECK-ASM: vfmaddps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macc_ps(a, b, c);
 }
 
 __m128d test_mm_macc_pd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfmadd.pd
+  // CHECK-ASM: vfmaddpd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macc_pd(a, b, c);
 }
 
 __m128 test_mm_macc_ss(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfmadd.ss
+  // CHECK-ASM: vfmaddss %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macc_ss(a, b, c);
 }
 
 __m128d test_mm_macc_sd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfmadd.sd
+  // CHECK-ASM: vfmaddsd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macc_sd(a, b, c);
 }
 
 __m128 test_mm_msub_ps(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfmsub.ps
+  // CHECK-ASM: vfmsubps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_msub_ps(a, b, c);
 }
 
 __m128d test_mm_msub_pd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfmsub.pd
+  // CHECK-ASM: vfmsubpd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_msub_pd(a, b, c);
 }
 
 __m128 test_mm_msub_ss(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfmsub.ss
+  // CHECK-ASM: vfmsubss %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_msub_ss(a, b, c);
 }
 
 __m128d test_mm_msub_sd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfmsub.sd
+  // CHECK-ASM: vfmsubsd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_msub_sd(a, b, c);
 }
 
 __m128 test_mm_nmacc_ps(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfnmadd.ps
+  // CHECK-ASM: vfnmaddps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmacc_ps(a, b, c);
 }
 
 __m128d test_mm_nmacc_pd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfnmadd.pd
+  // CHECK-ASM: vfnmaddpd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmacc_pd(a, b, c);
 }
 
 __m128 test_mm_nmacc_ss(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfnmadd.ss
+  // CHECK-ASM: vfnmaddss %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmacc_ss(a, b, c);
 }
 
 __m128d test_mm_nmacc_sd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfnmadd.sd
+  // CHECK-ASM: vfnmaddsd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmacc_sd(a, b, c);
 }
 
 __m128 test_mm_nmsub_ps(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfnmsub.ps
+  // CHECK-ASM: vfnmsubps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmsub_ps(a, b, c);
 }
 
 __m128d test_mm_nmsub_pd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfnmsub.pd
+  // CHECK-ASM: vfnmsubpd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmsub_pd(a, b, c);
 }
 
 __m128 test_mm_nmsub_ss(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfnmsub.ss
+  // CHECK-ASM: vfnmsubss %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmsub_ss(a, b, c);
 }
 
 __m128d test_mm_nmsub_sd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfnmsub.sd
+  // CHECK-ASM: vfnmsubsd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmsub_sd(a, b, c);
 }
 
 __m128 test_mm_maddsub_ps(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfmaddsub.ps
+  // CHECK-ASM: vfmaddsubps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maddsub_ps(a, b, c);
 }
 
 __m128d test_mm_maddsub_pd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfmaddsub.pd
+  // CHECK-ASM: vfmaddsubpd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maddsub_pd(a, b, c);
 }
 
 __m128 test_mm_msubadd_ps(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfmsubadd.ps
+  // CHECK-ASM: vfmsubaddps %xmm{{.*}}, %

Re: [PATCH] D12390: Also enable the avx/avx512 ABIs for i386, not just x86_64.

2015-08-27 Thread John McCall via cfe-commits
rjmccall added a comment.

In http://reviews.llvm.org/D12390#234458, @ab wrote:

> Unless I'm misunderstanding, I believe this has much less impact than you're 
> thinking; there are three cases:
>
> - x86_64: no change (-mno-mmx is guarded by x86)
> - x86, with -mno-mmx: no change (because previously, we'd only set avx/avx512 
> for x86_64)
> - x86, without -mno-mmx: this will use an avx/avx512 ABI string where we'd 
> have used "", letting us use the better alignment (only for OpenMP and 
> vectors, I think).


Ok, I see.

The outcome we want is that things like the max vector alignment should be 
properly honoring whatever target features are actually enabled.  Specifically, 
if AVX is enabled, we should be setting the max vector alignment to the maximum 
enabled AVX alignment, regardless of whether MMX is enabled.

This ABI string is an artifact of the interface between the AST and IRGen 
TargetInfos.  We should probably just remove it in favor of some kind of 
openly-extensible query interface so that IRGen can just directly ask things 
like whether AVX is enabled instead of parsing some random string.  But for 
this patch, let's just leave it as it is, and instead just set the max vector 
alignment directly from the target features.


http://reviews.llvm.org/D12390



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


Re: [PATCH] D12411: [PATCH] Expose AST language options to checkers

2015-08-27 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good .Thanks for fixing this!

BTW, there are other checks that use LangOpts in the check() method. IIRC, 
misc-use-override, google-readabiity-casting and maybe something else. We need 
to fix those as well.


http://reviews.llvm.org/D12411



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


[clang-tools-extra] r246209 - Expose language options to the checkers; disable UseNullptrCheck when not compiling in C++11 mode.

2015-08-27 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Aug 27 16:17:47 2015
New Revision: 246209

URL: http://llvm.org/viewvc/llvm-project?rev=246209&view=rev
Log:
Expose language options to the checkers; disable UseNullptrCheck when not 
compiling in C++11 mode.

Added:
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.c
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.h
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.h?rev=246209&r1=246208&r2=246209&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.h Thu Aug 27 16:17:47 2015
@@ -158,6 +158,8 @@ protected:
   OptionsView Options;
   /// \brief Returns the main file name of the current translation unit.
   StringRef getCurrentMainFile() const { return Context->getCurrentFile(); }
+  /// \brief Returns the language options from the context.
+  LangOptions getLangOpts() const { return Context->getLangOpts(); }
 };
 
 class ClangTidyCheckFactories;

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=246209&r1=246208&r2=246209&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Thu Aug 
27 16:17:47 2015
@@ -212,6 +212,7 @@ void ClangTidyContext::setCurrentFile(St
 
 void ClangTidyContext::setASTContext(ASTContext *Context) {
   DiagEngine->SetArgToStringFn(&FormatASTNodeDiagnosticArgument, Context);
+  LangOpts = Context->getLangOpts();
 }
 
 const ClangTidyGlobalOptions &ClangTidyContext::getGlobalOptions() const {

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h?rev=246209&r1=246208&r2=246209&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h Thu Aug 27 
16:17:47 2015
@@ -149,6 +149,9 @@ public:
   /// \brief Sets ASTContext for the current translation unit.
   void setASTContext(ASTContext *Context);
 
+  /// \brief Gets the language options from the AST context
+  LangOptions getLangOpts() const { return LangOpts; }
+
   /// \brief Returns the name of the clang-tidy check which produced this
   /// diagnostic ID.
   StringRef getCheckName(unsigned DiagnosticID) const;
@@ -198,6 +201,8 @@ private:
   ClangTidyOptions CurrentOptions;
   std::unique_ptr CheckFilter;
 
+  LangOptions LangOpts;
+
   ClangTidyStats Stats;
 
   llvm::DenseMap CheckNamesByDiagnosticID;

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=246209&r1=246208&r2=246209&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Thu Aug 27 
16:17:47 2015
@@ -453,7 +453,9 @@ void UseNullptrCheck::storeOptions(Clang
 }
 
 void UseNullptrCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(makeCastSequenceMatcher(), this);
+  // Only register the matcher for C++11.
+  if (getLangOpts().CPlusPlus11)
+Finder->addMatcher(makeCastSequenceMatcher(), this);
 }
 
 void UseNullptrCheck::check(const MatchFinder::MatchResult &Result) {

Added: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.c
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.c?rev=246209&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.c (added)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.c Thu Aug 27 
16:17:47 2015
@@ -0,0 +1,10 @@
+// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
+
+// Note: this test expects no diagnostics, but FileCheck cannot handle that,
+// hence the use of | count 0.
+
+#define NULL 0
+void f(void) {
+  char *str = NULL; // ok
+  (void)str;
+}


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

Re: [PATCH] D12411: [PATCH] Expose AST language options to checkers

2015-08-27 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thanks! I've commit in r246209.

I plan to do a more thorough search of clang-tidy to see what else can make use 
of this feature, this just happened to be low-hanging fruit that I found today 
by accident.

~Aaron


http://reviews.llvm.org/D12411



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


r246210 - CGDebugInfo: Factor out a getOrCreateStandaloneType() method.

2015-08-27 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Aug 27 16:21:19 2015
New Revision: 246210

URL: http://llvm.org/viewvc/llvm-project?rev=246210&view=rev
Log:
CGDebugInfo: Factor out a getOrCreateStandaloneType() method.

Usually debug info is created on the fly while during codegen.
With this API it becomes possible to create standalone debug info
for types that are not referenced by any code, such as emitting debug info
for a clang module or for implementing something like -gfull.
Because on-the-fly debug info generation may still insert retained types
on top of them, all RetainedTypes are uniqued in CGDebugInfo::finalize().

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=246210&r1=246209&r2=246210&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Aug 27 16:21:19 2015
@@ -1398,8 +1398,15 @@ llvm::DIType *CGDebugInfo::getOrCreateRe
 
 llvm::DIType *CGDebugInfo::getOrCreateInterfaceType(QualType D,
 SourceLocation Loc) {
+  return getOrCreateStandaloneType(D, Loc);
+}
+
+llvm::DIType *CGDebugInfo::getOrCreateStandaloneType(QualType D,
+ SourceLocation Loc) {
   assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
+  assert(!D.isNull() && "null type");
   llvm::DIType *T = getOrCreateType(D, getOrCreateFile(Loc));
+  assert(T && "could not create debug info for type");
   RetainedTypes.push_back(D.getAsOpaquePtr());
   return T;
 }
@@ -3360,9 +3367,14 @@ void CGDebugInfo::finalize() {
 
   // We keep our own list of retained types, because we need to look
   // up the final type in the type cache.
-  for (std::vector::const_iterator RI = RetainedTypes.begin(),
- RE = RetainedTypes.end(); RI != RE; ++RI)
-DBuilder.retainType(cast(TypeCache[*RI]));
+  llvm::DenseSet UniqueTypes;
+  UniqueTypes.resize(RetainedTypes.size() * 2);
+  for (auto &RT : RetainedTypes) {
+if (!UniqueTypes.insert(RT).second)
+  continue;
+if (auto MD = TypeCache[RT])
+  DBuilder.retainType(cast(MD));
+  }
 
   DBuilder.finalize();
 }

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=246210&r1=246209&r2=246210&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Aug 27 16:21:19 2015
@@ -344,6 +344,9 @@ public:
   /// Emit an Objective-C interface type standalone debug info.
   llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc);
 
+  /// Emit standalone debug info for a type.
+  llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);
+
   void completeType(const EnumDecl *ED);
   void completeType(const RecordDecl *RD);
   void completeRequiredType(const RecordDecl *RD);


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


Re: r246210 - CGDebugInfo: Factor out a getOrCreateStandaloneType() method.

2015-08-27 Thread David Blaikie via cfe-commits
On Thu, Aug 27, 2015 at 2:21 PM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Thu Aug 27 16:21:19 2015
> New Revision: 246210
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246210&view=rev
> Log:
> CGDebugInfo: Factor out a getOrCreateStandaloneType() method.
>
> Usually debug info is created on the fly while during codegen.
> With this API it becomes possible to create standalone debug info
> for types that are not referenced by any code, such as emitting debug info
> for a clang module or for implementing something like -gfull.
> Because on-the-fly debug info generation may still insert retained types
> on top of them, all RetainedTypes are uniqued in CGDebugInfo::finalize().
>

I don't quite understand why the new uniquing code is required - what is it
about this new codepath that necessitates that?


>
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.h
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=246210&r1=246209&r2=246210&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Aug 27 16:21:19 2015
> @@ -1398,8 +1398,15 @@ llvm::DIType *CGDebugInfo::getOrCreateRe
>
>  llvm::DIType *CGDebugInfo::getOrCreateInterfaceType(QualType D,
>  SourceLocation Loc) {
> +  return getOrCreateStandaloneType(D, Loc);
> +}
> +
> +llvm::DIType *CGDebugInfo::getOrCreateStandaloneType(QualType D,
> + SourceLocation Loc) {
>assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
> +  assert(!D.isNull() && "null type");
>llvm::DIType *T = getOrCreateType(D, getOrCreateFile(Loc));
> +  assert(T && "could not create debug info for type");
>RetainedTypes.push_back(D.getAsOpaquePtr());
>return T;
>  }
> @@ -3360,9 +3367,14 @@ void CGDebugInfo::finalize() {
>
>// We keep our own list of retained types, because we need to look
>// up the final type in the type cache.
> -  for (std::vector::const_iterator RI = RetainedTypes.begin(),
> - RE = RetainedTypes.end(); RI != RE; ++RI)
> -DBuilder.retainType(cast(TypeCache[*RI]));
> +  llvm::DenseSet UniqueTypes;
> +  UniqueTypes.resize(RetainedTypes.size() * 2);
> +  for (auto &RT : RetainedTypes) {
> +if (!UniqueTypes.insert(RT).second)
> +  continue;
> +if (auto MD = TypeCache[RT])
> +  DBuilder.retainType(cast(MD));
> +  }
>
>DBuilder.finalize();
>  }
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=246210&r1=246209&r2=246210&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Aug 27 16:21:19 2015
> @@ -344,6 +344,9 @@ public:
>/// Emit an Objective-C interface type standalone debug info.
>llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc);
>
> +  /// Emit standalone debug info for a type.
> +  llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation
> Loc);
> +
>void completeType(const EnumDecl *ED);
>void completeType(const RecordDecl *RD);
>void completeRequiredType(const RecordDecl *RD);
>
>
> ___
> 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] D12247: [libc++] remove possible trailing padding from aligned_storage

2015-08-27 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

So this patch LGTM. Sorry for being slow to understand it. However I want to 
see two things before it lands.

1. I would like to see a test of some sort that the resulting type has the same 
size and alignment requirements it did before the change. I'm not sure what the 
best way to test this is.
2. I would like @mclow.lists to approve this as well. I just want to be 
cautious.


http://reviews.llvm.org/D12247



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


r246211 - [X86][XOP] Added debug codegen test for XOP intrinsics

2015-08-27 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Aug 27 16:32:03 2015
New Revision: 246211

URL: http://llvm.org/viewvc/llvm-project?rev=246211&view=rev
Log:
[X86][XOP] Added debug codegen test for XOP intrinsics

Part of PR24590

Modified:
cfe/trunk/test/CodeGen/xop-builtins.c

Modified: cfe/trunk/test/CodeGen/xop-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xop-builtins.c?rev=246211&r1=246210&r2=246211&view=diff
==
--- cfe/trunk/test/CodeGen/xop-builtins.c (original)
+++ cfe/trunk/test/CodeGen/xop-builtins.c Thu Aug 27 16:32:03 2015
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +xop 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +xop 
-emit-llvm -o - -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +xop -S 
-o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
 
 // Don't include mm_malloc.h, it's system specific.
 #define __MM_MALLOC_H
@@ -7,320 +8,384 @@
 
 __m128i test_mm_maccs_epi16(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacssww
+  // CHECK-ASM: vpmacssww %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maccs_epi16(a, b, c);
 }
 
 __m128i test_mm_macc_epi16(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacsww
+  // CHECK-ASM: vpmacsww %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macc_epi16(a, b, c);
 }
 
 __m128i test_mm_maccsd_epi16(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacsswd
+  // CHECK-ASM: vpmacsswd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maccsd_epi16(a, b, c);
 }
 
 __m128i test_mm_maccd_epi16(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacswd
+  // CHECK-ASM: vpmacswd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maccd_epi16(a, b, c);
 }
 
 __m128i test_mm_maccs_epi32(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacssdd
+  // CHECK-ASM: vpmacssdd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maccs_epi32(a, b, c);
 }
 
 __m128i test_mm_macc_epi32(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacsdd
+  // CHECK-ASM: vpmacsdd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macc_epi32(a, b, c);
 }
 
 __m128i test_mm_maccslo_epi32(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacssdql
+  // CHECK-ASM: vpmacssdql %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maccslo_epi32(a, b, c);
 }
 
 __m128i test_mm_macclo_epi32(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacsdql
+  // CHECK-ASM: vpmacsdql %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macclo_epi32(a, b, c);
 }
 
 __m128i test_mm_maccshi_epi32(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacssdqh
+  // CHECK-ASM: vpmacssdqh %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maccshi_epi32(a, b, c);
 }
 
 __m128i test_mm_macchi_epi32(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacsdqh
+  // CHECK-ASM: vpmacsdqh %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macchi_epi32(a, b, c);
 }
 
 __m128i test_mm_maddsd_epi16(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmadcsswd
+  // CHECK-ASM: vpmadcsswd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maddsd_epi16(a, b, c);
 }
 
 __m128i test_mm_maddd_epi16(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmadcswd
+  // CHECK-ASM: vpmadcswd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maddd_epi16(a, b, c);
 }
 
 __m128i test_mm_haddw_epi8(__m128i a) {
   // CHECK: @llvm.x86.xop.vphaddbw
+  // CHECK-ASM: vphaddbw %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddw_epi8(a);
 }
 
 __m128i test_mm_haddd_epi8(__m128i a) {
   // CHECK: @llvm.x86.xop.vphaddbd
+  // CHECK-ASM: vphaddbd %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddd_epi8(a);
 }
 
 __m128i test_mm_haddq_epi8(__m128i a) {
   // CHECK: @llvm.x86.xop.vphaddbq
+  // CHECK-ASM: vphaddbq %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddq_epi8(a);
 }
 
 __m128i test_mm_haddd_epi16(__m128i a) {
   // CHECK: @llvm.x86.xop.vphaddwd
+  // CHECK-ASM: vphaddwd %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddd_epi16(a);
 }
 
 __m128i test_mm_haddq_epi16(__m128i a) {
   // CHECK: @llvm.x86.xop.vphaddwq
+  // CHECK-ASM: vphaddwq %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddq_epi16(a);
 }
 
 __m128i test_mm_haddq_epi32(__m128i a) {
   // CHECK: @llvm.x86.xop.vphadddq
+  // CHECK-ASM: vphadddq %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddq_epi32(a);
 }
 
 __m128i test_mm_haddw_epu8(__m128i a) {
   // CHECK: @llvm.x86.xop.vphaddubw
+  // CHECK-ASM: vphaddubw %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddw_epu8(a);
 }
 
 __m128i test_mm_haddd_epu8(__m128i a) {
   // CHECK: @llvm.x86.xop.vphaddubd
+  // CHECK-ASM: vphaddubd %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddd_epu8(a);
 }
 
 __

Re: [PATCH] D12375: [PATCH] Relax parse ordering rules for attributes

2015-08-27 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Parse/ParseDeclCXX.cpp:3923
@@ +3922,3 @@
+
+void Parser::MaybeParseAttributes(unsigned WhichAttrKinds,
+  ParsedAttributesWithRange &Attrs,

Please provide an inlineable wrapper for this that checks if the current token 
is `[`, `__declspec`, or `__attribute__` before calling into this, as we do for 
the existing `MaybeParse*` functions.


Comment at: lib/Parse/ParseDeclCXX.cpp:3942-3946
@@ +3941,7 @@
+  MoreToParse |= MaybeParseCXX11Attributes(Attrs, End);
+  // If C++11 attributes are not allowed because other attributes have
+  // already been parsed, we should diagnose if such an attribute was
+  // parsed.
+  if (MoreToParse && !CXX11AttrAllowed)
+Diag(AttrStartLoc, diag::warn_attribute_ordering);
+}

I'm not convinced this is right. It seems like there are two different cases:

1) Some context accepts a sequence of attributes before other things, such as:

  struct __attribute__((blah)) [[blah]] S;

There doesn't seem to be a principled reason to reject this.

2) Different attributes appear as different components of the grammar, such as:

  [[before_declaration]] __attribute__((im_a_decl_specifier)) int n;
  __attribute__((im_a_decl_specifier)) [[i_dont_go_here]] int n;

Only the second case should be rejected here. (And I think we should provide an 
error not just a warning if we don't like this case.)

I think the right thing to do is probably to always parse all attribute 
syntaxes (except for MS attributes, which are ambiguous with other constructs), 
and give a nicely-worded error if we see an unexpected syntax.


Comment at: lib/Parse/ParseDeclCXX.cpp:3956-3959
@@ +3955,6 @@
+}
+if (WhichAttrKinds & PAKM_Microsoft) {
+  MoreToParse |= MaybeParseMicrosoftAttributes(Attrs, End);
+  CXX11AttrAllowed = false;
+}
+  } while (MoreToParse);

This seems wrong: given `[[foo]] [[bar]]`, we'll now parse the second one as an 
MS attribute in a context where both are allowed.


http://reviews.llvm.org/D12375



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


Re: r246210 - CGDebugInfo: Factor out a getOrCreateStandaloneType() method.

2015-08-27 Thread Adrian Prantl via cfe-commits

> On Aug 27, 2015, at 2:25 PM, David Blaikie  wrote:
> 
> 
> 
> On Thu, Aug 27, 2015 at 2:21 PM, Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Thu Aug 27 16:21:19 2015
> New Revision: 246210
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=246210&view=rev 
> 
> Log:
> CGDebugInfo: Factor out a getOrCreateStandaloneType() method.
> 
> Usually debug info is created on the fly while during codegen.
> With this API it becomes possible to create standalone debug info
> for types that are not referenced by any code, such as emitting debug info
> for a clang module or for implementing something like -gfull.
> Because on-the-fly debug info generation may still insert retained types
> on top of them, all RetainedTypes are uniqued in CGDebugInfo::finalize().
> 
> I don't quite understand why the new uniquing code is required - what is it 
> about this new codepath that necessitates that?

getOrCreateStandaloneType() invokes getOrCreateType() and adds the DIType to 
RetainedTypes so it doesn’t get lost. If getOrCreateType() was in fact a cache 
hit, it is possible that the type was already retained when it was initially 
created. Thinking of it, it is probably better to make 
getOrCreateStandalaoneType() replicate getOrCreateType()’s logic and have it 
only retain the type if it was a cache miss. I’ll fix that.

-- adrian

>  
> 
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.h
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=246210&r1=246209&r2=246210&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Aug 27 16:21:19 2015
> @@ -1398,8 +1398,15 @@ llvm::DIType *CGDebugInfo::getOrCreateRe
> 
>  llvm::DIType *CGDebugInfo::getOrCreateInterfaceType(QualType D,
>  SourceLocation Loc) {
> +  return getOrCreateStandaloneType(D, Loc);
> +}
> +
> +llvm::DIType *CGDebugInfo::getOrCreateStandaloneType(QualType D,
> + SourceLocation Loc) {
>assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
> +  assert(!D.isNull() && "null type");
>llvm::DIType *T = getOrCreateType(D, getOrCreateFile(Loc));
> +  assert(T && "could not create debug info for type");
>RetainedTypes.push_back(D.getAsOpaquePtr());
>return T;
>  }
> @@ -3360,9 +3367,14 @@ void CGDebugInfo::finalize() {
> 
>// We keep our own list of retained types, because we need to look
>// up the final type in the type cache.
> -  for (std::vector::const_iterator RI = RetainedTypes.begin(),
> - RE = RetainedTypes.end(); RI != RE; ++RI)
> -DBuilder.retainType(cast(TypeCache[*RI]));
> +  llvm::DenseSet UniqueTypes;
> +  UniqueTypes.resize(RetainedTypes.size() * 2);
> +  for (auto &RT : RetainedTypes) {
> +if (!UniqueTypes.insert(RT).second)
> +  continue;
> +if (auto MD = TypeCache[RT])
> +  DBuilder.retainType(cast(MD));
> +  }
> 
>DBuilder.finalize();
>  }
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=246210&r1=246209&r2=246210&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Aug 27 16:21:19 2015
> @@ -344,6 +344,9 @@ public:
>/// Emit an Objective-C interface type standalone debug info.
>llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc);
> 
> +  /// Emit standalone debug info for a type.
> +  llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);
> +
>void completeType(const EnumDecl *ED);
>void completeType(const 

r246213 - Generating assumption loads of vptr after ctor call (fixed)

2015-08-27 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Thu Aug 27 16:35:37 2015
New Revision: 246213

URL: http://llvm.org/viewvc/llvm-project?rev=246213&view=rev
Log:
Generating assumption loads of vptr after ctor call (fixed)

Generating call assume(icmp %vtable, %global_vtable) after constructor
call for devirtualization purposes.

For more info go to:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

Edit:
Fixed version because of PR24479.

http://reviews.llvm.org/D11859

Added:
cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCXXABI.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGen/available-externally-hidden.cpp
cfe/trunk/test/CodeGenCXX/ctor-globalopt.cpp
cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
cfe/trunk/test/CodeGenCXX/thunks.cpp
cfe/trunk/test/CodeGenCXX/virtual-base-ctor.cpp
cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.h?rev=246213&r1=246212&r2=246213&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCXXABI.h (original)
+++ cfe/trunk/lib/CodeGen/CGCXXABI.h Thu Aug 27 16:35:37 2015
@@ -346,13 +346,25 @@ public:
   virtual void emitVTableDefinitions(CodeGenVTables &CGVT,
  const CXXRecordDecl *RD) = 0;
 
+  /// Checks if ABI requires extra virtual offset for vtable field.
+  virtual bool
+  isVirtualOffsetNeededForVTableField(CodeGenFunction &CGF,
+  CodeGenFunction::VPtr Vptr) = 0;
+
+  /// Checks if ABI requires to initilize vptrs for given dynamic class.
+  virtual bool doStructorsInitializeVPtrs(const CXXRecordDecl *VTableClass) = 
0;
+
+  /// Get the address point of the vtable for the given base subobject.
+  virtual llvm::Constant *
+  getVTableAddressPoint(BaseSubobject Base,
+const CXXRecordDecl *VTableClass) = 0;
+
   /// Get the address point of the vtable for the given base subobject while
-  /// building a constructor or a destructor. On return, NeedsVirtualOffset
-  /// tells if a virtual base adjustment is needed in order to get the offset
-  /// of the base subobject.
-  virtual llvm::Value *getVTableAddressPointInStructor(
-  CodeGenFunction &CGF, const CXXRecordDecl *RD, BaseSubobject Base,
-  const CXXRecordDecl *NearestVBase, bool &NeedsVirtualOffset) = 0;
+  /// building a constructor or a destructor.
+  virtual llvm::Value *
+  getVTableAddressPointInStructor(CodeGenFunction &CGF, const CXXRecordDecl 
*RD,
+  BaseSubobject Base,
+  const CXXRecordDecl *NearestVBase) = 0;
 
   /// Get the address point of the vtable for the given base subobject while
   /// building a constexpr.

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=246213&r1=246212&r2=246213&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Aug 27 16:35:37 2015
@@ -1412,7 +1412,8 @@ void CodeGenModule::ConstructAttributeLi
 
 if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) {
   const FunctionProtoType *FPT = Fn->getType()->getAs();
-  if (FPT && FPT->isNothrow(getContext()))
+  if (FPT && !isUnresolvedExceptionSpec(FPT->getExceptionSpecType()) &&
+  FPT->isNothrow(getContext()))
 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
   // Don't use [[noreturn]] or _Noreturn for a call to a virtual function.
   // These attributes are not inherited by overloads.

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=246213&r1=246212&r2=246213&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Aug 27 16:35:37 2015
@@ -1806,12 +1806,14 @@ void CodeGenFunction::EmitCXXConstructor
  bool ForVirtualBase,
  bool Delegating, llvm::Value 
*This,
  const CXXConstructExpr *E) {
+  const CXXRecordDecl *ClassDecl = D->getParent();
+
   // C++11 [class.mfct.non-static]p2:
   //   If a non-static member function of a class X is called for an object 
that
   //   is not of type X, or of a type derived from X, the behavior is 
undefined.
   // FIXME: Provide a source location here.
   EmitTypeCheck(CodeGenFunction::TCK_ConstructorCall, SourceLocation(), This,
-   

r246214 - Assume loads fix #2

2015-08-27 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Thu Aug 27 16:35:41 2015
New Revision: 246214

URL: http://llvm.org/viewvc/llvm-project?rev=246214&view=rev
Log:
Assume loads fix #2

There was linker problem, and it turns out that it is not always safe
to refer to vtable. If the vtable is used, then we can refer to it
without any problem, but because we don't know when it will be used or
not, we can only check if vtable is external or it is safe to to emit it
speculativly (when class it doesn't have any inline virtual functions).
It should be fixed in the future.

http://reviews.llvm.org/D12385

Modified:
cfe/trunk/lib/CodeGen/CGCXXABI.h
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
cfe/trunk/test/CodeGenCXX/thunks.cpp
cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp
cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.h?rev=246214&r1=246213&r2=246214&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCXXABI.h (original)
+++ cfe/trunk/lib/CodeGen/CGCXXABI.h Thu Aug 27 16:35:41 2015
@@ -218,8 +218,10 @@ public:
   virtual void emitThrow(CodeGenFunction &CGF, const CXXThrowExpr *E) = 0;
   virtual llvm::GlobalVariable *getThrowInfo(QualType T) { return nullptr; }
 
-  virtual bool canEmitAvailableExternallyVTable(
-  const CXXRecordDecl *RD) const = 0;
+  /// \brief Determine whether it's possible to emit a vtable for \p RD, even
+  /// though we do not know that the vtable has been marked as used by semantic
+  /// analysis.
+  virtual bool canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const = 0;
 
   virtual void emitBeginCatch(CodeGenFunction &CGF, const CXXCatchStmt *C) = 0;
 

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=246214&r1=246213&r2=246214&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Aug 27 16:35:41 2015
@@ -1857,8 +1857,15 @@ void CodeGenFunction::EmitCXXConstructor
   // with a vtable.  We don't do this for base subobjects for two reasons:
   // first, it's incorrect for classes with virtual bases, and second, we're
   // about to overwrite the vptrs anyway.
+  // We also have to make sure if we can refer to vtable:
+  // - If vtable is external then it's safe to use it (for available_externally
+  //   CGVTables will make sure if it can emit it).
+  // - Otherwise we can refer to vtable if it's safe to speculatively emit.
+  // FIXME: If vtable is used by ctor/dtor, we are always safe to refer to it.
   if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
-  ClassDecl->isDynamicClass() && Type != Ctor_Base)
+  ClassDecl->isDynamicClass() && Type != Ctor_Base &&
+  (CGM.getVTables().isVTableExternal(ClassDecl) ||
+   CGM.getCXXABI().canSpeculativelyEmitVTable(ClassDecl)))
 EmitVTableAssumptionLoads(ClassDecl, This);
 }
 

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=246214&r1=246213&r2=246214&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Thu Aug 27 16:35:41 2015
@@ -682,7 +682,7 @@ CodeGenVTables::GenerateConstructionVTab
 static bool shouldEmitAvailableExternallyVTable(const CodeGenModule &CGM,
 const CXXRecordDecl *RD) {
   return CGM.getCodeGenOpts().OptimizationLevel > 0 &&
-CGM.getCXXABI().canEmitAvailableExternallyVTable(RD);
+CGM.getCXXABI().canSpeculativelyEmitVTable(RD);
 }
 
 /// Compute the required linkage of the v-table for the given class.
@@ -832,11 +832,11 @@ bool CodeGenVTables::isVTableExternal(co
 /// we define that v-table?
 static bool shouldEmitVTableAtEndOfTranslationUnit(CodeGenModule &CGM,
const CXXRecordDecl *RD) {
-  // If vtable is internal then it has to be done
+  // If vtable is internal then it has to be done.
   if (!CGM.getVTables().isVTableExternal(RD))
 return true;
 
-  // If it's external then maybe we will need it as available_externally
+  // If it's external then maybe we will need it as available_externally.
   return shouldEmitAvailableExternallyVTable(CGM, RD);
 }
 

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=246214&r1=246213&r2=246214&view=diff
==
--- cfe/trunk

Re: r245779 - [modules] Rearrange how redeclaration chains are loaded, to remove a walk over

2015-08-27 Thread Richard Smith via cfe-commits
On Thu, Aug 27, 2015 at 10:47 AM, Justin Bogner 
wrote:

> Richard Smith via cfe-commits  writes:
> > Author: rsmith
> > Date: Fri Aug 21 20:47:18 2015
> > New Revision: 245779
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=245779&view=rev
> > Log:
> > [modules] Rearrange how redeclaration chains are loaded, to remove a
> walk over
> > all modules and reduce the number of declarations we load when loading a
> > redeclaration chain.
>
> It looks like ASTDeclWriter::AddFirstDeclFromEachModule is called with a
> null `this` since this change, which has been causing ubsan failures on
> 76 tests since it went in:
>
>   ASTWriterDecl.cpp:170:18: runtime error: member call on null pointer of
> type 'clang::ASTReader'
>
> Logs and other failures here:
>
>   http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/146/
>
> I guess you must've missed the failure email. Could you please take a
> look?


Thanks, fixed in r246215.


> > The new approach is:
> >  * when loading the first declaration of an entity within a module file,
> we
> >first load all declarations of the entity that were imported into that
> >module file, and then load all the other declarations of that entity
> from
> >that module file and build a suitable decl chain from them
> >  * when loading any other declaration of an entity, we first load the
> first
> >declaration from the same module file
> >
> > As before, we complete redecl chains through name lookup where necessary.
> >
> > To make this work, I also had to change the way that template
> specializations
> > are stored -- it no longer suffices to track only canonical
> specializations; we
> > now emit all "first local" declarations when emitting a list of
> specializations
> > for a template.
> >
> > On one testcase with several thousand imported module files, this
> reduces the
> > total runtime by 72%.
> >
> > Modified:
> > cfe/trunk/include/clang/Serialization/ASTWriter.h
> > cfe/trunk/lib/Serialization/ASTReader.cpp
> > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> > cfe/trunk/lib/Serialization/ASTWriter.cpp
> > cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
> > cfe/trunk/test/Modules/cxx-templates.cpp
> >
> > Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=245779&r1=245778&r2=245779&view=diff
> >
> ==
> > --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
> > +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Fri Aug 21
> 20:47:18 2015
> > @@ -405,6 +405,10 @@ private:
> >/// \brief The set of declarations that may have redeclaration chains
> that
> >/// need to be serialized.
> >llvm::SmallVector Redeclarations;
> > +
> > +  /// \brief A cache of the first local declaration for "interesting"
> > +  /// redeclaration chains.
> > +  llvm::DenseMap FirstLocalDeclCache;
> >
> >/// \brief Statements that we've encountered while serializing a
> >/// declaration or type.
> > @@ -676,6 +680,10 @@ public:
> >const ASTTemplateArgumentListInfo
> *ASTTemplArgList,
> >RecordDataImpl &Record);
> >
> > +  /// \brief Find the first local declaration of a given local
> redeclarable
> > +  /// decl.
> > +  const Decl *getFirstLocalDecl(const Decl *D);
> > +
> >/// \brief Emit a reference to a declaration.
> >void AddDeclRef(const Decl *D, RecordDataImpl &Record);
> >
> > @@ -857,12 +865,6 @@ public:
> >void CompletedTagDefinition(const TagDecl *D) override;
> >void AddedVisibleDecl(const DeclContext *DC, const Decl *D) override;
> >void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D)
> override;
> > -  void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD,
> > - const ClassTemplateSpecializationDecl *D)
> override;
> > -  void AddedCXXTemplateSpecialization(const VarTemplateDecl *TD,
> > -   const VarTemplateSpecializationDecl *D)
> override;
> > -  void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
> > -  const FunctionDecl *D) override;
> >void ResolvedExceptionSpec(const FunctionDecl *FD) override;
> >void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType)
> override;
> >void ResolvedOperatorDelete(const CXXDestructorDecl *DD,
> >
> > Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=245779&r1=245778&r2=245779&view=diff
> >
> ==
> > --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
> > +++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Aug 21 20:47:18 2015
> > @@ -8123,11 +8123,8 @@ void ASTReader::finishPendingActio

r246215 - Don't call a member function on a null pointer.

2015-08-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Aug 27 16:38:25 2015
New Revision: 246215

URL: http://llvm.org/viewvc/llvm-project?rev=246215&view=rev
Log:
Don't call a member function on a null pointer.

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=246215&r1=246214&r2=246215&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Thu Aug 27 16:38:25 2015
@@ -165,9 +165,12 @@ namespace clang {
 void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
   llvm::MapVector Firsts;
   // FIXME: We can skip entries that we know are implied by others.
-  for (const Decl *R = D->getMostRecentDecl(); R; R = R->getPreviousDecl())
-if (IncludeLocal || R->isFromASTFile())
+  for (const Decl *R = D->getMostRecentDecl(); R; R = 
R->getPreviousDecl()) {
+if (R->isFromASTFile())
   Firsts[Writer.Chain->getOwningModuleFile(R)] = R;
+else if (IncludeLocal)
+  Firsts[nullptr] = R;
+  }
   for (const auto &F : Firsts)
 Writer.AddDeclRef(F.second, Record);
 }


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


Re: r245779 - [modules] Rearrange how redeclaration chains are loaded, to remove a walk over

2015-08-27 Thread Richard Smith via cfe-commits
On Sat, Aug 22, 2015 at 1:16 AM, Vassil Vassilev  wrote:

> On 22/08/15 03:47, Richard Smith via cfe-commits wrote:
>
>> Author: rsmith
>> Date: Fri Aug 21 20:47:18 2015
>> New Revision: 245779
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=245779&view=rev
>> Log:
>> [modules] Rearrange how redeclaration chains are loaded, to remove a walk
>> over
>> all modules and reduce the number of declarations we load when loading a
>> redeclaration chain.
>>
>> The new approach is:
>>   * when loading the first declaration of an entity within a module file,
>> we
>> first load all declarations of the entity that were imported into that
>> module file, and then load all the other declarations of that entity
>> from
>> that module file and build a suitable decl chain from them
>>   * when loading any other declaration of an entity, we first load the
>> first
>> declaration from the same module file
>>
>> As before, we complete redecl chains through name lookup where necessary.
>>
>> To make this work, I also had to change the way that template
>> specializations
>> are stored -- it no longer suffices to track only canonical
>> specializations; we
>> now emit all "first local" declarations when emitting a list of
>> specializations
>> for a template.
>>
>> On one testcase with several thousand imported module files, this reduces
>> the
>> total runtime by 72%.
>>
> Very nice!
> Does it reduce the depth of the redecl chains when merging? I.e. does this
> mean memory footprint reduction too?


I wouldn't expect any difference there, and in any case, I think this would
only affect the stack depth, which is typically bounded anyway since we
normally build modules on a separate thread.


> Modified:
>>  cfe/trunk/include/clang/Serialization/ASTWriter.h
>>  cfe/trunk/lib/Serialization/ASTReader.cpp
>>  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>>  cfe/trunk/lib/Serialization/ASTWriter.cpp
>>  cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>>  cfe/trunk/test/Modules/cxx-templates.cpp
>>
>> Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=245779&r1=245778&r2=245779&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
>> +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Fri Aug 21 20:47:18
>> 2015
>> @@ -405,6 +405,10 @@ private:
>> /// \brief The set of declarations that may have redeclaration chains
>> that
>> /// need to be serialized.
>> llvm::SmallVector Redeclarations;
>> +
>> +  /// \brief A cache of the first local declaration for "interesting"
>> +  /// redeclaration chains.
>> +  llvm::DenseMap FirstLocalDeclCache;
>> /// \brief Statements that
>> we've encountered while serializing a
>> /// declaration or type.
>> @@ -676,6 +680,10 @@ public:
>> const ASTTemplateArgumentListInfo
>> *ASTTemplArgList,
>> RecordDataImpl &Record);
>>   +  /// \brief Find the first local declaration of a given local
>> redeclarable
>> +  /// decl.
>> +  const Decl *getFirstLocalDecl(const Decl *D);
>> +
>> /// \brief Emit a reference to a declaration.
>> void AddDeclRef(const Decl *D, RecordDataImpl &Record);
>>   @@ -857,12 +865,6 @@ public:
>> void CompletedTagDefinition(const TagDecl *D) override;
>> void AddedVisibleDecl(const DeclContext *DC, const Decl *D) override;
>> void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D)
>> override;
>> -  void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD,
>> - const ClassTemplateSpecializationDecl *D)
>> override;
>> -  void AddedCXXTemplateSpecialization(const VarTemplateDecl *TD,
>> -   const VarTemplateSpecializationDecl *D)
>> override;
>> -  void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
>> -  const FunctionDecl *D) override;
>> void ResolvedExceptionSpec(const FunctionDecl *FD) override;
>> void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType)
>> override;
>> void ResolvedOperatorDelete(const CXXDestructorDecl *DD,
>>
>> Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=245779&r1=245778&r2=245779&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
>> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Aug 21 20:47:18 2015
>> @@ -8123,11 +8123,8 @@ void ASTReader::finishPendingActions() {
>>   PendingIncompleteDeclChains.clear();
>> // Load pending declaration chains.
>> -for (unsigned I = 0; I != PendingDeclChains.size

Re: [PATCH] D11740: ABI versioning macros for libc++

2015-08-27 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Thanks for doing all of this work. It's really appreciated.

First, I don't really think we should have the notion of a "minor" ABI version. 
It will be hard enough to maintain 2 major versions and I don't understand what 
a minor ABI version buys us.

In my opinion libc++ should support the following ABI configurations:

1. Previous: The previous major ABI version.
2. Default:   The current major ABI version.
3. Unstable: The current major ABI version + all pending ABI breaking changes.

I would like to see the ABI minor version replaced with `_LIBCPP_ABI_UNSTABLE` 
macro that @mclow.lists originally proposed.


http://reviews.llvm.org/D11740



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


Re: [PATCH] D11740: ABI versioning macros for libc++

2015-08-27 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D11740#234552, @EricWF wrote:

> Thanks for doing all of this work. It's really appreciated.
>
> First, I don't really think we should have the notion of a "minor" ABI 
> version. It will be hard enough to maintain 2 major versions and I don't 
> understand what a minor ABI version buys us.


Woops, I realize now that I suggested a minor version originally. My apologies 
for being misleading.

One big problem with this patch is that it prevents the libc++ headers in 
libcxx/include from being used directly. This restriction seems artificial to 
me. If you want the "default" ABI configuration then you should be able to use 
the headers in the source tree. Only if you want some custom configuration 
(either the previous ABI version or _LIBCPP_ABI_UNSTABLE) should you have to 
use the headers in the build directory. In this case we should use the 
mechanism in http://reviews.llvm.org/D11963 (whatever that ends up being after 
review) and not add a `__config_version`.


http://reviews.llvm.org/D11740



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


Re: [PATCH] D12312: Emiting invariant.group.barrier and adding -fstrict-vptrs

2015-08-27 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: lib/CodeGen/CGClass.cpp:1279
@@ +1278,3 @@
+  if (CGM.getCodeGenOpts().StrictVPtrs && BaseVPtrsInitialized)
+CXXThisValue = Builder.CreateInvariantGroupBarrier(LoadCXXThis());
+

rjmccall wrote:
> Should this just be in InitializeVTablePointers?
I want to add invariant.group.barrier only if it's needed. F.e. I don't want to 
put before I initialize vptrs for base, or when my class doesn't inherit frome 
anything. I want emit barrier after I will initialize some other vptrs.

InitializeVptrs is called in EmitBaseInitializer, and also I woudnt want to put 
some extra flag if it must produce barrier or not (because it is hard to 
distinguish it from inside)


http://reviews.llvm.org/D12312



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


Re: [PATCH] D12247: [libc++] remove possible trailing padding from aligned_storage

2015-08-27 Thread Yiran Wang via cfe-commits
yiranwang added a comment.

In http://reviews.llvm.org/D12247#234533, @EricWF wrote:

> So this patch LGTM. Sorry for being slow to understand it. However I want to 
> see two things before it lands.
>
> 1. I would like to see a test of some sort that the resulting type has the 
> same size and alignment requirements it did before the change. I'm not sure 
> what the best way to test this is.
> 2. I would like @mclow.lists to approve this as well. I just want to be 
> cautious.


I think now we are on the same page about these bugs. 
Also, thanks for your review and findings (hopefully fix it soon too).

For the test, we compile it with -O3 -fstrict-aliasing -finline-limit=300, and 
as mentioned before the target is AARCH64+ANDROID.


http://reviews.llvm.org/D12247



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


Re: [PATCH] D11740: ABI versioning macros for libc++

2015-08-27 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

Yes, not being able to use headers in the libcxx source tree is quite 
unpleasant. It can be fixed by providing a __config_version in libcxx/include 
with the default version values. Or, in the approach of 
http://reviews.llvm.org/D11963, do something smart in __config to default to 
the right version numbers.

Why do we need _LIBCPP_ABI_UNSTABLE at all? How is it different from setting 
LIBCPP_ABI_MAJOR_VERSION to the current default version + 1?


http://reviews.llvm.org/D11740



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


Re: [PATCH] D12181: [sanitizer] Add -fsanitize-trap-function.

2015-08-27 Thread Josh Gao via cfe-commits
jmgao added a comment.

Ping, I think @samsonov was waiting on @rsmith's feedback on the following:

In http://reviews.llvm.org/D12181#229493, @jmgao wrote:

> In http://reviews.llvm.org/D12181#229467, @rsmith wrote:
>
> > In http://reviews.llvm.org/D12181#229358, @rsmith wrote:
> >
> > > Can you please give a brief description of the motivation for this 
> > > change? When would it be appropriate to use this rather than 
> > > `-ftrap-function`?
> >
> >
> > I'd still like an answer to this. It's not clear to me what the purpose of 
> > this is, and why you'd want a custom runtime hook for sanitizer traps but 
> > not other traps. The only time we emit a trap using `-ftrap-function` where 
> > there is no corresponding sanitizer is for `__builtin_trap()`; is the 
> > intention that you still want a normal trap for that builtin?
>
>
> The goal is to be able to give a useful fsanitize-specific error message 
> ("fsanitize trap occurred"), while not lying and saying this for non-sanitize 
> traps.





http://reviews.llvm.org/D12181



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


Re: r246210 - CGDebugInfo: Factor out a getOrCreateStandaloneType() method.

2015-08-27 Thread David Blaikie via cfe-commits
On Thu, Aug 27, 2015 at 2:35 PM, Adrian Prantl  wrote:

>
> On Aug 27, 2015, at 2:25 PM, David Blaikie  wrote:
>
>
>
> On Thu, Aug 27, 2015 at 2:21 PM, Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Thu Aug 27 16:21:19 2015
>> New Revision: 246210
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=246210&view=rev
>> 
>> Log:
>> CGDebugInfo: Factor out a getOrCreateStandaloneType() method.
>>
>> Usually debug info is created on the fly while during codegen.
>> With this API it becomes possible to create standalone debug info
>> for types that are not referenced by any code, such as emitting debug info
>> for a clang module or for implementing something like -gfull.
>> Because on-the-fly debug info generation may still insert retained types
>> on top of them, all RetainedTypes are uniqued in CGDebugInfo::finalize().
>>
>
> I don't quite understand why the new uniquing code is required - what is
> it about this new codepath that necessitates that?
>
>
> getOrCreateStandaloneType() invokes getOrCreateType() and adds the DIType
> to RetainedTypes so it doesn’t get lost. If getOrCreateType() was in fact a
> cache hit, it is possible that the type was already retained when it was
> initially created. Thinking of it, it is probably better to make
> getOrCreateStandalaoneType() replicate getOrCreateType()’s logic and have
> it only retain the type if it was a cache miss. I’ll fix that.
>

Why are both functions checking the cache, though? (or does getOrCreateType
only retain types that use DIRefs? & then you need to retain the other ones
too?)


>
> -- adrian
>
>
>
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CGDebugInfo.h
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=246210&r1=246209&r2=246210&view=diff
>> 
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Aug 27 16:21:19 2015
>> @@ -1398,8 +1398,15 @@ llvm::DIType *CGDebugInfo::getOrCreateRe
>>
>>  llvm::DIType *CGDebugInfo::getOrCreateInterfaceType(QualType D,
>>  SourceLocation Loc) {
>> +  return getOrCreateStandaloneType(D, Loc);
>> +}
>> +
>> +llvm::DIType *CGDebugInfo::getOrCreateStandaloneType(QualType D,
>> + SourceLocation Loc)
>> {
>>assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
>> +  assert(!D.isNull() && "null type");
>>llvm::DIType *T = getOrCreateType(D, getOrCreateFile(Loc));
>> +  assert(T && "could not create debug info for type");
>>RetainedTypes.push_back(D.getAsOpaquePtr());
>>return T;
>>  }
>> @@ -3360,9 +3367,14 @@ void CGDebugInfo::finalize() {
>>
>>// We keep our own list of retained types, because we need to look
>>// up the final type in the type cache.
>> -  for (std::vector::const_iterator RI = RetainedTypes.begin(),
>> - RE = RetainedTypes.end(); RI != RE; ++RI)
>> -DBuilder.retainType(cast(TypeCache[*RI]));
>> +  llvm::DenseSet UniqueTypes;
>> +  UniqueTypes.resize(RetainedTypes.size() * 2);
>> +  for (auto &RT : RetainedTypes) {
>> +if (!UniqueTypes.insert(RT).second)
>> +  continue;
>> +if (auto MD = TypeCache[RT])
>> +  DBuilder.retainType(cast(MD));
>> +  }
>>
>>DBuilder.finalize();
>>  }
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=246210&r1=246209&r2=246210&view=diff
>> 
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Aug 27 16:21:19 2015
>> @@ -344,6 +344,9 @@ public:
>>/// Emit an Objective-C interface type standalone debug inf

Re: [PATCH] D12247: [libc++] remove possible trailing padding from aligned_storage

2015-08-27 Thread Xinliang David Li via cfe-commits
On Thu, Aug 27, 2015 at 2:57 PM, Yiran Wang  wrote:
> yiranwang added a comment.
>
> In http://reviews.llvm.org/D12247#234533, @EricWF wrote:
>
>> So this patch LGTM. Sorry for being slow to understand it. However I want to 
>> see two things before it lands.
>>
>> 1. I would like to see a test of some sort that the resulting type has the 
>> same size and alignment requirements it did before the change. I'm not sure 
>> what the best way to test this is.
>> 2. I would like @mclow.lists to approve this as well. I just want to be 
>> cautious.

Re. testing, I think what Eric means is to add some compile time
assertion to make sure the size does not change before and after.

>
>
> I think now we are on the same page about these bugs.
> Also, thanks for your review and findings (hopefully fix it soon too).
>
> For the test, we compile it with -O3 -fstrict-aliasing -finline-limit=300, 
> and as mentioned before the target is AARCH64+ANDROID.
>
>
> http://reviews.llvm.org/D12247
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11832: [Patch] [Analyzer] false positive: Potential leak connected with memcpy (PR 22954)

2015-08-27 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Other than one teeny nit, looks good to me.



Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:863
@@ +862,3 @@
+
+  const ElementRegion *ER = dyn_cast(R);
+  // Cast is safe as BufVal's region is a FieldRegion.

You can use cast(R) here, which will assert that R is an 
ElementRegion, and remove the assert below.


http://reviews.llvm.org/D11832



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


r246223 - [X86][3DNow] Added debug codegen test for 3DNow! intrinsics

2015-08-27 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Aug 27 17:18:09 2015
New Revision: 246223

URL: http://llvm.org/viewvc/llvm-project?rev=246223&view=rev
Log:
[X86][3DNow] Added debug codegen test for 3DNow! intrinsics

Part of PR24590

Modified:
cfe/trunk/test/CodeGen/3dnow-builtins.c

Modified: cfe/trunk/test/CodeGen/3dnow-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/3dnow-builtins.c?rev=246223&r1=246222&r2=246223&view=diff
==
--- cfe/trunk/test/CodeGen/3dnow-builtins.c (original)
+++ cfe/trunk/test/CodeGen/3dnow-builtins.c Thu Aug 27 17:18:09 2015
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -O3 -triple=x86_64-unknown-unknown -target-feature 
+3dnow -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-unknown-unknown -target-feature 
+3dnow -emit-llvm -o - -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-unknown-unknown -target-feature 
+3dnow -S -o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
 
 // Don't include mm_malloc.h, it's system specific.
 #define __MM_MALLOC_H
@@ -8,108 +9,126 @@
 __m64 test_m_pavgusb(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pavgusb
   // CHECK: @llvm.x86.3dnow.pavgusb
+  // CHECK-ASM: pavgusb %mm{{.*}}, %mm{{.*}}
   return _m_pavgusb(m1, m2);
 }
 
 __m64 test_m_pf2id(__m64 m) {
   // CHECK-LABEL: define i64 @test_m_pf2id
   // CHECK: @llvm.x86.3dnow.pf2id
+  // CHECK-ASM: pf2id %mm{{.*}}, %mm{{.*}}
   return _m_pf2id(m);
 }
 
 __m64 test_m_pfacc(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfacc
   // CHECK: @llvm.x86.3dnow.pfacc
+  // CHECK-ASM: pfacc %mm{{.*}}, %mm{{.*}}
   return _m_pfacc(m1, m2);
 }
 
 __m64 test_m_pfadd(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfadd
   // CHECK: @llvm.x86.3dnow.pfadd
+  // CHECK-ASM: pfadd %mm{{.*}}, %mm{{.*}}
   return _m_pfadd(m1, m2);
 }
 
 __m64 test_m_pfcmpeq(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfcmpeq
   // CHECK: @llvm.x86.3dnow.pfcmpeq
+  // CHECK-ASM: pfcmpeq %mm{{.*}}, %mm{{.*}}
   return _m_pfcmpeq(m1, m2);
 }
 
 __m64 test_m_pfcmpge(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfcmpge
   // CHECK: @llvm.x86.3dnow.pfcmpge
+  // CHECK-ASM: pfcmpge %mm{{.*}}, %mm{{.*}}
   return _m_pfcmpge(m1, m2);
 }
 
 __m64 test_m_pfcmpgt(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfcmpgt
   // CHECK: @llvm.x86.3dnow.pfcmpgt
+  // CHECK-ASM: pfcmpgt %mm{{.*}}, %mm{{.*}}
   return _m_pfcmpgt(m1, m2);
 }
 
 __m64 test_m_pfmax(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfmax
   // CHECK: @llvm.x86.3dnow.pfmax
+  // CHECK-ASM: pfmax %mm{{.*}}, %mm{{.*}}
   return _m_pfmax(m1, m2);
 }
 
 __m64 test_m_pfmin(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfmin
   // CHECK: @llvm.x86.3dnow.pfmin
+  // CHECK-ASM: pfmin %mm{{.*}}, %mm{{.*}}
   return _m_pfmin(m1, m2);
 }
 
 __m64 test_m_pfmul(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfmul
   // CHECK: @llvm.x86.3dnow.pfmul
+  // CHECK-ASM: pfmul %mm{{.*}}, %mm{{.*}}
   return _m_pfmul(m1, m2);
 }
 
 __m64 test_m_pfrcp(__m64 m) {
   // CHECK-LABEL: define i64 @test_m_pfrcp
   // CHECK: @llvm.x86.3dnow.pfrcp
+  // CHECK-ASM: pfrcp %mm{{.*}}, %mm{{.*}}
   return _m_pfrcp(m);
 }
 
 __m64 test_m_pfrcpit1(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfrcpit1
   // CHECK: @llvm.x86.3dnow.pfrcpit1
+  // CHECK-ASM: pfrcpit1 %mm{{.*}}, %mm{{.*}}
   return _m_pfrcpit1(m1, m2);
 }
 
 __m64 test_m_pfrcpit2(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfrcpit2
   // CHECK: @llvm.x86.3dnow.pfrcpit2
+  // CHECK-ASM: pfrcpit2 %mm{{.*}}, %mm{{.*}}
   return _m_pfrcpit2(m1, m2);
 }
 
 __m64 test_m_pfrsqrt(__m64 m) {
   // CHECK-LABEL: define i64 @test_m_pfrsqrt
   // CHECK: @llvm.x86.3dnow.pfrsqrt
+  // CHECK-ASM: pfrsqrt %mm{{.*}}, %mm{{.*}}
   return _m_pfrsqrt(m);
 }
 
 __m64 test_m_pfrsqrtit1(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfrsqrtit1
   // CHECK: @llvm.x86.3dnow.pfrsqit1
+  // CHECK-ASM: pfrsqit1 %mm{{.*}}, %mm{{.*}}
   return _m_pfrsqrtit1(m1, m2);
 }
 
 __m64 test_m_pfsub(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfsub
   // CHECK: @llvm.x86.3dnow.pfsub
+  // CHECK-ASM: pfsub %mm{{.*}}, %mm{{.*}}
   return _m_pfsub(m1, m2);
 }
 
 __m64 test_m_pfsubr(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfsubr
   // CHECK: @llvm.x86.3dnow.pfsubr
+  // CHECK-ASM: pfsubr %mm{{.*}}, %mm{{.*}}
   return _m_pfsubr(m1, m2);
 }
 
 __m64 test_m_pi2fd(__m64 m) {
   // CHECK-LABEL: define i64 @test_m_pi2fd
   // CHECK: @llvm.x86.3dnow.pi2fd
+  // CHECK-ASM: pi2fd %mm{{.*}}, %mm{{.*}}
   return _m_pi2fd(m);
 }
 
@@ -122,35 +141,41 @@ __m64 test_m_pmulhrw(__m64 m1, __m64 m2)
 __m64 test_m_pf2iw(__m64 m) {
   // CHECK-LABEL: define i64 @test_m_pf2iw
   // CHECK: @llvm.x86.3dnowa.pf2iw
+  // CHECK-ASM: pf2iw %mm{{.*}}, %mm{{.*}}
   return _m_pf2iw(m);
 }
 
 __m64 test_m_pfn

  1   2   >