r246422 - [OPENMP 4.0] Codegen for array sections.

2015-08-31 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Aug 31 02:32:19 2015
New Revision: 246422

URL: http://llvm.org/viewvc/llvm-project?rev=246422&view=rev
Log:
[OPENMP 4.0] Codegen for array sections.
Added codegen for array section in 'depend' clause of 'task' directive. It 
emits to pointers, one for the begin of array section and another for the end 
of array section. Size of the section is calculated as (end + 1 - start) * 
sizeof(basic_element_type).

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/OpenMP/task_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=246422&r1=246421&r2=246422&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Aug 31 02:32:19 2015
@@ -911,6 +911,8 @@ LValue CodeGenFunction::EmitLValue(const
 return EmitUnaryOpLValue(cast(E));
   case Expr::ArraySubscriptExprClass:
 return EmitArraySubscriptExpr(cast(E));
+  case Expr::OMPArraySectionExprClass:
+return EmitOMPArraySectionExpr(cast(E));
   case Expr::ExtVectorElementExprClass:
 return EmitExtVectorElementExpr(cast(E));
   case Expr::MemberExprClass:
@@ -2559,6 +2561,155 @@ LValue CodeGenFunction::EmitArraySubscri
   return LV;
 }
 
+LValue CodeGenFunction::EmitOMPArraySectionExpr(const OMPArraySectionExpr *E,
+bool IsLowerBound) {
+  LValue Base;
+  if (auto *ASE =
+  dyn_cast(E->getBase()->IgnoreParenImpCasts()))
+Base = EmitOMPArraySectionExpr(ASE, IsLowerBound);
+  else
+Base = EmitLValue(E->getBase());
+  QualType BaseTy = Base.getType();
+  llvm::Value *Idx = nullptr;
+  QualType ResultExprTy;
+  if (auto *AT = getContext().getAsArrayType(BaseTy))
+ResultExprTy = AT->getElementType();
+  else
+ResultExprTy = BaseTy->getPointeeType();
+  if (IsLowerBound || (!IsLowerBound && E->getColonLoc().isInvalid())) {
+// Requesting lower bound or upper bound, but without provided length and
+// without ':' symbol for the default length -> length = 1.
+// Idx = LowerBound ?: 0;
+if (auto *LowerBound = E->getLowerBound()) {
+  Idx = Builder.CreateIntCast(
+  EmitScalarExpr(LowerBound), IntPtrTy,
+  LowerBound->getType()->hasSignedIntegerRepresentation());
+} else
+  Idx = llvm::ConstantInt::getNullValue(IntPtrTy);
+  } else {
+// Try to emit length or lower bound as constant. If this is possible, 1 is
+// subtracted from constant length or lower bound. Otherwise, emit LLVM IR
+// (LB + Len) - 1.
+auto &C = CGM.getContext();
+auto *Length = E->getLength();
+llvm::APSInt ConstLength;
+if (Length) {
+  // Idx = LowerBound + Length - 1;
+  if (Length->isIntegerConstantExpr(ConstLength, C)) {
+ConstLength = ConstLength.zextOrTrunc(PointerWidthInBits);
+Length = nullptr;
+  }
+  auto *LowerBound = E->getLowerBound();
+  llvm::APSInt ConstLowerBound(PointerWidthInBits, /*isUnsigned=*/false);
+  if (LowerBound && LowerBound->isIntegerConstantExpr(ConstLowerBound, C)) 
{
+ConstLowerBound = ConstLowerBound.zextOrTrunc(PointerWidthInBits);
+LowerBound = nullptr;
+  }
+  if (!Length)
+--ConstLength;
+  else if (!LowerBound)
+--ConstLowerBound;
+
+  if (Length || LowerBound) {
+auto *LowerBoundVal =
+LowerBound
+? Builder.CreateIntCast(
+  EmitScalarExpr(LowerBound), IntPtrTy,
+  LowerBound->getType()->hasSignedIntegerRepresentation())
+: llvm::ConstantInt::get(IntPtrTy, ConstLowerBound);
+auto *LengthVal =
+Length
+? Builder.CreateIntCast(
+  EmitScalarExpr(Length), IntPtrTy,
+  Length->getType()->hasSignedIntegerRepresentation())
+: llvm::ConstantInt::get(IntPtrTy, ConstLength);
+Idx = Builder.CreateAdd(LowerBoundVal, LengthVal, "lb_add_len",
+/*HasNUW=*/false,
+!getLangOpts().isSignedOverflowDefined());
+if (Length && LowerBound) {
+  Idx = Builder.CreateSub(
+  Idx, llvm::ConstantInt::get(IntPtrTy, /*V=*/1), "idx_sub_1",
+  /*HasNUW=*/false, !getLangOpts().isSignedOverflowDefined());
+}
+  } else
+Idx = llvm::ConstantInt::get(IntPtrTy, ConstLength + ConstLowerBound);
+} else {
+  // Idx = ArraySize - 1;
+  if (auto *VAT = C.getAsVariableArrayType(BaseTy)) {
+Length = VAT->getSizeExpr();
+if (Length->isIntegerConstantExpr(ConstLength, C))
+  Length = nullptr;
+  } else {
+auto *CAT = C.getAsConstantArrayType(BaseTy);
+ConstLength = CAT->getSize();

Re: [PATCH] fix parentheses location in a CXXConstructExpr

2015-08-31 Thread Manuel Klimek via cfe-commits
On Sat, Aug 29, 2015 at 12:23 PM Olivier Goffart via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi,
>
> Please review the attached patch.
>
> In Sema::BuildCXXFunctionalCastExpr, if the class has a destructor, the
> Op.SrcExpr might be a CXXBindTemporaryExpr which we need to unwrap.
>
> In the testcase, the first new CHECK worked (because A does not have a
> destructor),  but the second CHECK failed (did not include the last
> parenthese) because D has a destructor.
>
> I used dyn_cast_or_null just to be safe, becasue i don't know if it is
> possible for the BindExpr->getSubExpr() to be null.
>

Do you know why the added test for A says 'class foo::A' instead of
'foo::A' as the other tests do in that file?


>
> Thanks
> --
> Olivier
> ___
> 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


[libunwind] r246413 - [libunwind] Add support for OpenRISC 1000.

2015-08-31 Thread Peter Zotov via cfe-commits
Author: whitequark
Date: Mon Aug 31 00:26:37 2015
New Revision: 246413

URL: http://llvm.org/viewvc/llvm-project?rev=246413&view=rev
Log:
[libunwind] Add support for OpenRISC 1000.

This patch makes no assumptions on ABI past the ABI defined in
the OpenRISC 1000 spec except that the DWARF register numbers will
be 0-31 for registers r0-r31, which is true for both gcc and
clang at the moment.

Modified:
libunwind/trunk/include/libunwind.h
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/UnwindCursor.hpp
libunwind/trunk/src/UnwindRegistersRestore.S
libunwind/trunk/src/UnwindRegistersSave.S
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=246413&r1=246412&r2=246413&view=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Mon Aug 31 00:26:37 2015
@@ -497,4 +497,40 @@ enum {
   // 8192-16383 -- Unspecified vendor co-processor register.
 };
 
+// OpenRISC1000 register numbers
+enum {
+  UNW_OR1K_R0  = 0,
+  UNW_OR1K_R1  = 1,
+  UNW_OR1K_R2  = 2,
+  UNW_OR1K_R3  = 3,
+  UNW_OR1K_R4  = 4,
+  UNW_OR1K_R5  = 5,
+  UNW_OR1K_R6  = 6,
+  UNW_OR1K_R7  = 7,
+  UNW_OR1K_R8  = 8,
+  UNW_OR1K_R9  = 9,
+  UNW_OR1K_R10 = 10,
+  UNW_OR1K_R11 = 11,
+  UNW_OR1K_R12 = 12,
+  UNW_OR1K_R13 = 13,
+  UNW_OR1K_R14 = 14,
+  UNW_OR1K_R15 = 15,
+  UNW_OR1K_R16 = 16,
+  UNW_OR1K_R17 = 17,
+  UNW_OR1K_R18 = 18,
+  UNW_OR1K_R19 = 19,
+  UNW_OR1K_R20 = 20,
+  UNW_OR1K_R21 = 21,
+  UNW_OR1K_R22 = 22,
+  UNW_OR1K_R23 = 23,
+  UNW_OR1K_R24 = 24,
+  UNW_OR1K_R25 = 25,
+  UNW_OR1K_R26 = 26,
+  UNW_OR1K_R27 = 27,
+  UNW_OR1K_R28 = 28,
+  UNW_OR1K_R29 = 29,
+  UNW_OR1K_R30 = 30,
+  UNW_OR1K_R31 = 31,
+};
+
 #endif

Modified: libunwind/trunk/src/Registers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Registers.hpp?rev=246413&r1=246412&r2=246413&view=diff
==
--- libunwind/trunk/src/Registers.hpp (original)
+++ libunwind/trunk/src/Registers.hpp Mon Aug 31 00:26:37 2015
@@ -1711,7 +1711,187 @@ inline v128 Registers_arm::getVectorRegi
 inline void Registers_arm::setVectorRegister(int, v128) {
   _LIBUNWIND_ABORT("ARM vector support not implemented");
 }
+/// Registers_or1k holds the register state of a thread in an OpenRISC1000
+/// process.
+class _LIBUNWIND_HIDDEN Registers_or1k {
+public:
+  Registers_or1k();
+  Registers_or1k(const void *registers);
 
+  boolvalidRegister(int num) const;
+  uint32_tgetRegister(int num) const;
+  voidsetRegister(int num, uint32_t value);
+  boolvalidFloatRegister(int num) const;
+  double  getFloatRegister(int num) const;
+  voidsetFloatRegister(int num, double value);
+  boolvalidVectorRegister(int num) const;
+  v128getVectorRegister(int num) const;
+  voidsetVectorRegister(int num, v128 value);
+  const char *getRegisterName(int num);
+  voidjumpto();
+  static int  lastDwarfRegNum() { return 31; }
+
+  uint64_t  getSP() const { return _registers.__r[1]; }
+  void  setSP(uint32_t value) { _registers.__r[1] = value; }
+  uint64_t  getIP() const { return _registers.__r[9]; }
+  void  setIP(uint32_t value) { _registers.__r[9] = value; }
+
+private:
+  struct or1k_thread_state_t {
+unsigned int __r[32];
+  };
+
+  or1k_thread_state_t _registers;
+};
+
+inline Registers_or1k::Registers_or1k(const void *registers) {
+  static_assert(sizeof(Registers_or1k) < sizeof(unw_context_t),
+"or1k registers do not fit into unw_context_t");
+  memcpy(&_registers, static_cast(registers),
+ sizeof(_registers));
+}
+
+inline Registers_or1k::Registers_or1k() {
+  memset(&_registers, 0, sizeof(_registers));
+}
+
+inline bool Registers_or1k::validRegister(int regNum) const {
+  if (regNum == UNW_REG_IP)
+return true;
+  if (regNum == UNW_REG_SP)
+return true;
+  if (regNum < 0)
+return false;
+  if (regNum <= UNW_OR1K_R31)
+return true;
+  return false;
+}
+
+inline uint32_t Registers_or1k::getRegister(int regNum) const {
+  if (regNum >= UNW_OR1K_R0 && regNum <= UNW_OR1K_R31)
+return _registers.__r[regNum - UNW_OR1K_R0];
+
+  switch (regNum) {
+  case UNW_REG_IP:
+return _registers.__r[9];
+  case UNW_REG_SP:
+return _registers.__r[1];
+  }
+  _LIBUNWIND_ABORT("unsupported or1k register");
+}
+
+inline void Registers_or1k::setRegister(int regNum, uint32_t value) {
+  if (regNum >= UNW_OR1K_R0 && regNum <= UNW_OR1K_R31) {
+_registers.__r[regNum - UNW_OR1K_R0] = value;
+return;
+  }
+
+  switch (regNum) {
+  case UNW_REG_IP:
+_registers.__r[9] = value;
+return;
+  case UNW_REG_SP:
+_registers.__r[1] = value;
+return;
+  }
+  _LIBUNWIND_ABORT("unsupported or1k register");
+}
+
+inline bool Registers_or1k::val

Re: [PATCH] D11976: [libclang] Return deduced type for auto type, not the one written in the source.

2015-08-31 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

Yes, please submit it.


http://reviews.llvm.org/D11976



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


r246430 - AVX-512: Changed cnt parameter in valignq/d intrinsic from i8 to i32 according to the Intel Spec

2015-08-31 Thread Igor Breger via cfe-commits
Author: ibreger
Date: Mon Aug 31 06:15:06 2015
New Revision: 246430

URL: http://llvm.org/viewvc/llvm-project?rev=246430&view=rev
Log:
AVX-512: Changed cnt parameter in valignq/d intrinsic from i8 to i32 according 
to the Intel Spec

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=246430&r1=246429&r2=246430&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Aug 31 06:15:06 2015
@@ -1030,8 +1030,8 @@ TARGET_BUILTIN(__builtin_ia32_vpermt2var
 TARGET_BUILTIN(__builtin_ia32_vpermt2varq512_mask, "V8LLiV8LLiV8LLiV8LLiUc", 
"", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_vpermt2varps512_mask, "V16fV16iV16fV16fUs", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_vpermt2varpd512_mask, "V8dV8LLiV8dV8dUc", "", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_alignq512_mask, "V8LLiV8LLiV8LLiIcV8LLiUc", "", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_alignd512_mask, "V16iV16iV16iIcV16iUs", "", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_alignq512_mask, "V8LLiV8LLiV8LLiIiV8LLiUc", "", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_alignd512_mask, "V16iV16iV16iIiV16iUs", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_extractf64x4_mask, "V4dV8dIcV4dUc", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_extractf32x4_mask, "V4fV16fIcV4fUc", "", 
"avx512f")
 


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


Re: [PATCH] D12301: [PATCH] New checker for UB in handler of a function-try-block

2015-08-31 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D12301#232100, @aaron.ballman wrote:

> This patch completely reworks the way the warning is implemented by moving it 
> into the frontend instead of clang-tidy.


Ping

~Aaron


http://reviews.llvm.org/D12301



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


Re: [PATCH] D12458: [clang] add __builtin_unpredictable and convert to metadata

2015-08-31 Thread Krzysztof Parzyszek via cfe-commits
kparzysz added inline comments.


Comment at: lib/CodeGen/CodeGenFunction.cpp:1238
@@ -1217,3 +1237,3 @@
   }
-  Builder.CreateCondBr(CondV, TrueBlock, FalseBlock, Weights);
+  Builder.CreateCondBr(CondV, TrueBlock, FalseBlock, Weights, Unpredictable);
 }

Is the definition of CreateCondBr actually updated somewhere?  I didn't see it 
in any other patch.


http://reviews.llvm.org/D12458



___
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-31 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki updated this revision to Diff 33575.
danielmarjamaki added a comment.

Fixed 2 false positives found in python source code.


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,113 @@
+// 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);
+}
+
+char *dontwarn12(char *s) {
+  return s;
+}
+
+void dontwarn13(unsigned char *str, const unsigned int i) {
+unsigned char *p;
+for (p = str + i; *p; ) {}
+}
+
+void dontwarn14(int *buf) {
+  int i, *p;
+  for (i=0, p=buf; i<10; i++, p++) {
+*p = 1;
+  }
+}
+
+void dontwarn15(char *p) {
+  strcpy1(p, "abc");
+}
+
+void dontwarn16(char *p) {
+  strcpy1(p+2, "abc");
+}
+
+char *dontwarn17(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(),

[PATCH] D12492: [Clang-Format] Add AlwaysBreakBeforeElse Style to avoid cuddled else

2015-08-31 Thread Paul Hoad via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: nikola, djasper, poiru, klimek.
MyDeveloperDay added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Implementation of Jarkko Hietaniemi original AlwaysBreakBeforeElse to avoid 
cuddled braces on an "else" statement.

WebKit Style + Linux BreakBeforeBraces style gives cuddled else brackets, this 
patch adds an AlwaysBreakBeforeElse style to allow required brace style such 
that the else is placed on a newline after the closing brace of the if

Patch by: Jarkko Hietaniemi

http://reviews.llvm.org/D12492

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9131,6 +9131,33 @@
WebKitBraceStyle);
 }
 
+TEST_F(FormatTest, AlwaysBreakBeforeElse) {
+FormatStyle BeforeElse = getLLVMStyle();
+BeforeElse.AlwaysBreakBeforeElse = true;
+verifyFormat("void foo() {\n"
+"  if (a) {\n"
+"a();\n"
+"  }\n"
+"  else {\n"
+"b();\n"
+"  }\n"
+"}\n",
+BeforeElse);
+
+verifyFormat("void foo() {\n"
+"  if (a) {\n"
+"a();\n"
+"  }\n"
+"  else if (b) {\n"
+"b();\n"
+"  }\n"
+"  else {\n"
+"b();\n"
+"  }\n"
+"}\n",
+BeforeElse);
+}
+
 TEST_F(FormatTest, CatchExceptionReferenceBinding) {
   verifyFormat("void f() {\n"
"  try {\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1272,8 +1272,11 @@
 --Line->Level;
   }
   if (FormatTok->Tok.is(tok::kw_else)) {
-if (Style.BreakBeforeBraces == FormatStyle::BS_Stroustrup)
+if (Style.BreakBeforeBraces == FormatStyle::BS_Stroustrup ||
+Style.AlwaysBreakBeforeElse) {
   addUnwrappedLine();
+}
+
 nextToken();
 if (FormatTok->Tok.is(tok::l_brace)) {
   CompoundStatementIndenter Indenter(this, Style, Line->Level);
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -217,6 +217,8 @@
Style.AlwaysBreakAfterDefinitionReturnType);
 IO.mapOptional("AlwaysBreakBeforeMultilineStrings",
Style.AlwaysBreakBeforeMultilineStrings);
+IO.mapOptional("AlwaysBreakBeforeElse",
+   Style.AlwaysBreakBeforeElse);
 IO.mapOptional("AlwaysBreakTemplateDeclarations",
Style.AlwaysBreakTemplateDeclarations);
 IO.mapOptional("BinPackArguments", Style.BinPackArguments);
@@ -357,6 +359,7 @@
   LLVMStyle.AllowShortLoopsOnASingleLine = false;
   LLVMStyle.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
   LLVMStyle.AlwaysBreakBeforeMultilineStrings = false;
+  LLVMStyle.AlwaysBreakBeforeElse = false;
   LLVMStyle.AlwaysBreakTemplateDeclarations = false;
   LLVMStyle.BinPackParameters = true;
   LLVMStyle.BinPackArguments = true;
@@ -420,6 +423,7 @@
   GoogleStyle.AllowShortIfStatementsOnASingleLine = true;
   GoogleStyle.AllowShortLoopsOnASingleLine = true;
   GoogleStyle.AlwaysBreakBeforeMultilineStrings = true;
+  GoogleStyle.AlwaysBreakBeforeElse = false;
   GoogleStyle.AlwaysBreakTemplateDeclarations = true;
   GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
   GoogleStyle.DerivePointerAlignment = true;
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -138,6 +138,9 @@
   /// template declaration.
   bool AlwaysBreakTemplateDeclarations;
 
+  /// \brief If \c true, always break before 'else'.
+  bool AlwaysBreakBeforeElse;
+
   /// \brief If \c false, a function call's arguments will either be all on the
   /// same line or will have one line each.
   bool BinPackArguments;
@@ -465,6 +468,8 @@
R.AlwaysBreakBeforeMultilineStrings &&
AlwaysBreakTemplateDeclarations ==
R.AlwaysBreakTemplateDeclarations &&
+   AlwaysBreakBeforeElse ==
+   R.AlwaysBreakBeforeElse &&
BinPackArguments == R.BinPackArguments &&
BinPackParameters == R.BinPackParameters &&
BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&
Index: docs/ClangFormatStyleOptions.rst
===
--- docs/ClangFormatStyleOptions.rst
+++ docs/ClangFormatStyleOptions.rst
@@ -244,6 +244,9 @@
   If ``true``, always break after the ``template<...>`` of a
   template declaration.
 
+**AlwaysBrea

[clang-tools-extra] r246437 - [clang-tidy] Move misc-use-override and readability-shrink-to-fit to "modernize/"

2015-08-31 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Aug 31 08:17:43 2015
New Revision: 246437

URL: http://llvm.org/viewvc/llvm-project?rev=246437&view=rev
Log:
[clang-tidy] Move misc-use-override and readability-shrink-to-fit to 
"modernize/"

These checks are focusing on migrating the code from C++98/03 to C++11, so they
belong to the modernize module.

Added:
clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp
  - copied, changed from r246432, 
clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.h
  - copied, changed from r246432, 
clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.h
clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp
  - copied, changed from r246432, 
clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.h
  - copied, changed from r246432, 
clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-shrink-to-fit.rst
  - copied unchanged from r246432, 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-shrink-to-fit.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-override.rst
  - copied, changed from r246432, 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-shrink-to-fit.cpp
  - copied, changed from r246432, 
clang-tools-extra/trunk/test/clang-tidy/readability-shrink-to-fit.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-cxx98.cpp
  - copied, changed from r246432, 
clang-tools-extra/trunk/test/clang-tidy/misc-use-override-cxx98.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp
  - copied, changed from r246432, 
clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
Removed:
clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.h
clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-shrink-to-fit.rst
clang-tools-extra/trunk/test/clang-tidy/misc-use-override-cxx98.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-shrink-to-fit.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=246437&r1=246436&r2=246437&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Mon Aug 31 08:17:43 
2015
@@ -19,7 +19,6 @@ add_clang_library(clangTidyMiscModule
   UnusedParametersCheck.cpp
   UnusedRAIICheck.cpp
   UniqueptrResetReleaseCheck.cpp
-  UseOverrideCheck.cpp
 
   LINK_LIBS
   clangAST

Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=246437&r1=246436&r2=246437&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Mon Aug 31 
08:17:43 2015
@@ -27,7 +27,6 @@
 #include "UnusedAliasDeclsCheck.h"
 #include "UnusedParametersCheck.h"
 #include "UnusedRAIICheck.h"
-#include "UseOverrideCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -68,7 +67,6 @@ public:
 CheckFactories.registerCheck(
 "misc-unused-parameters");
 CheckFactories.registerCheck("misc-unused-raii");
-CheckFactories.registerCheck("misc-use-override");
   }
 };
 

Removed: clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp?rev=246436&view=auto
=

r246438 - PR17829: Proper diagnostic of mangled names conflicts

2015-08-31 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Mon Aug 31 08:20:44 2015
New Revision: 246438

URL: http://llvm.org/viewvc/llvm-project?rev=246438&view=rev
Log:
PR17829: Proper diagnostic of mangled names conflicts

Proper diagnostic and resolution of mangled names conflicts between C++ methods
and C functions. This patch implements support for functions/methods only;
support for variables is coming separately.

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

Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=246438&r1=246437&r2=246438&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Mon Aug 31 08:20:44 2015
@@ -207,7 +207,8 @@ llvm::Function *CodeGenModule::codegenCX
   const CGFunctionInfo &FnInfo =
   getTypes().arrangeCXXStructorDeclaration(MD, Type);
   auto *Fn = cast(
-  getAddrOfCXXStructor(MD, Type, &FnInfo, nullptr, true));
+  getAddrOfCXXStructor(MD, Type, &FnInfo, /*FnType=*/nullptr,
+   /*DontDefer=*/true, /*IsForDefinition=*/true));
 
   GlobalDecl GD;
   if (const auto *DD = dyn_cast(MD)) {
@@ -226,9 +227,9 @@ llvm::Function *CodeGenModule::codegenCX
   return Fn;
 }
 
-llvm::GlobalValue *CodeGenModule::getAddrOfCXXStructor(
+llvm::Constant *CodeGenModule::getAddrOfCXXStructor(
 const CXXMethodDecl *MD, StructorType Type, const CGFunctionInfo *FnInfo,
-llvm::FunctionType *FnType, bool DontDefer) {
+llvm::FunctionType *FnType, bool DontDefer, bool IsForDefinition) {
   GlobalDecl GD;
   if (auto *CD = dyn_cast(MD)) {
 GD = GlobalDecl(CD, toCXXCtorType(Type));
@@ -236,19 +237,15 @@ llvm::GlobalValue *CodeGenModule::getAdd
 GD = GlobalDecl(cast(MD), toCXXDtorType(Type));
   }
 
-  StringRef Name = getMangledName(GD);
-  if (llvm::GlobalValue *Existing = GetGlobalValue(Name))
-return Existing;
-
   if (!FnType) {
 if (!FnInfo)
   FnInfo = &getTypes().arrangeCXXStructorDeclaration(MD, Type);
 FnType = getTypes().GetFunctionType(*FnInfo);
   }
 
-  return cast(GetOrCreateLLVMFunction(Name, FnType, GD,
-  /*ForVTable=*/false,
-  DontDefer));
+  return GetOrCreateLLVMFunction(
+  getMangledName(GD), FnType, GD, /*ForVTable=*/false, DontDefer,
+  /*isThunk=*/false, /*ExtraAttrs=*/llvm::AttributeSet(), IsForDefinition);
 }
 
 static llvm::Value *BuildAppleKextVirtualCall(CodeGenFunction &CGF,

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=246438&r1=246437&r2=246438&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Aug 31 08:20:44 2015
@@ -237,6 +237,20 @@ void CodeGenModule::applyReplacements()
   }
 }
 
+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 InstrProfStats::reportDiagnostics(D
 
 void CodeGenModule::Release() {
   EmitDeferred();
+  applyGlobalValReplacements();
   applyReplacements();
   checkAliases();
   EmitCXXGlobalInitFunc();
@@ -1108,9 +1123,16 @@ void CodeGenModule::EmitDeferred() {
 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
@@ -1579,6 +1601,9 @@ void CodeGenModule::EmitGlobalDefinition
  

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

2015-08-31 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246438: PR17829: Proper diagnostic of mangled names 
conflicts (authored by asbokhan).

Changed prior to commit:
  http://reviews.llvm.org/D11297?vs=33401&id=33577#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11297

Files:
  cfe/trunk/lib/CodeGen/CGCXX.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp

Index: cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp
===
--- cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp
+++ cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only %s -verify
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only %s -verify -DTEST1
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only %s -verify -DTEST2
+
+#ifdef TEST1
 
 // rdar://15522601
 class MyClass {
@@ -8,3 +11,34 @@
 extern "C" {
   void _ZN7MyClass4methEv() { } // expected-error {{definition with same mangled name as another definition}}
 }
+
+#elif TEST2
+
+// We expect no warnings here, as there is only declaration of _ZN1TD1Ev function, no definitions.
+extern "C" void _ZN1TD1Ev();
+struct T {
+  ~T() {}
+};
+
+void foo() {
+  _ZN1TD1Ev();
+  T t;
+}
+
+extern "C" void _ZN2T2D2Ev() {}; // expected-note {{previous definition is here}}
+
+struct T2 {
+  ~T2() {} // expected-error {{definition with same mangled name as another definition}}
+};
+
+void bar() {
+  _ZN2T2D2Ev();
+  T2 t;
+}
+
+#else
+
+#error Unknwon test
+
+#endif
+
Index: cfe/trunk/lib/CodeGen/CodeGenModule.h
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.h
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h
@@ -342,6 +342,17 @@
   typedef llvm::StringMap > ReplacementsTy;
   ReplacementsTy Replacements;
 
+  /// List of global values to be replaced with something else. Used when we
+  /// want to replace a GlobalValue but can't identify it by its mangled name
+  /// anymore (because the name is already taken).
+  llvm::SmallVector, 8>
+GlobalValReplacements;
+
+  /// Set of global decls for which we already diagnosed mangled name conflict.
+  /// Required to not issue a warning (on a mangling conflict) multiple times
+  /// for the same decl.
+  llvm::DenseSet DiagnosedConflictingDefinitions;
+
   /// A queue of (optional) vtables to consider emitting.
   std::vector DeferredVTables;
 
@@ -682,18 +693,7 @@
 llvm_unreachable("unknown visibility!");
   }
 
-  llvm::Constant *GetAddrOfGlobal(GlobalDecl GD) {
-if (isa(GD.getDecl()))
-  return getAddrOfCXXStructor(cast(GD.getDecl()),
-  getFromCtorType(GD.getCtorType()));
-else if (isa(GD.getDecl()))
-  return getAddrOfCXXStructor(cast(GD.getDecl()),
-  getFromDtorType(GD.getDtorType()));
-else if (isa(GD.getDecl()))
-  return GetAddrOfFunction(GD);
-else
-  return GetAddrOfGlobalVar(cast(GD.getDecl()));
-  }
+  llvm::Constant *GetAddrOfGlobal(GlobalDecl GD, bool IsForDefinition = false);
 
   /// Will return a global variable of the given type. If a variable with a
   /// different type already exists then a new  variable with the right type
@@ -725,7 +725,8 @@
   /// function will use the specified type if it has to create it.
   llvm::Constant *GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty = 0,
 bool ForVTable = false,
-bool DontDefer = false);
+bool DontDefer = false,
+bool IsForDefinition = false);
 
   /// Get the address of the RTTI descriptor for the given type.
   llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false);
@@ -847,11 +848,11 @@
  StructorType Type);
 
   /// Return the address of the constructor/destructor of the given type.
-  llvm::GlobalValue *
+  llvm::Constant *
   getAddrOfCXXStructor(const CXXMethodDecl *MD, StructorType Type,
const CGFunctionInfo *FnInfo = nullptr,
llvm::FunctionType *FnType = nullptr,
-   bool DontDefer = false);
+   bool DontDefer = false, bool IsForDefinition = false);
 
   /// Given a builtin id for a function like "__builtin_fabsf", return a
   /// Function* for "fabsf".
@@ -1122,6 +1123,8 @@
 
   void addReplacement(StringRef Name, llvm::Constant *C);
 
+  void addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C);
+
   /// \brief Emit a code for threadprivate directive.
   /// \param D Threadprivate declaration.
   void EmitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D);
@@ -1148,7 +1151,8 @@
   GetOrCreateLLVMFu

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

2015-08-31 Thread pierre gousseau via cfe-commits
pgousseau added a comment.

In http://reviews.llvm.org/D11832#235301, @dcoughlin wrote:

> I will commit. Thanks for your work on this, Pierre!


Much appreciated ! Thanks for your help.


Repository:
  rL LLVM

http://reviews.llvm.org/D11832



___
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-31 Thread Paul Hoad via cfe-commits
MyDeveloperDay added a subscriber: MyDeveloperDay.
MyDeveloperDay added a comment.

This is definitely a nice to have, it would be nice in the future to have an 
option that only reformatted the changed lines only, nice idea though


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] D11297: PR17829: Functions declared extern "C" with a name matching a mangled C++ function are allowed

2015-08-31 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

In http://reviews.llvm.org/D11297#235525, @rjmccall wrote:

> Yes, please make it an error.


Done.

John, thank you for all your patience and explanations! -- I understand that 
this particular review and patch author required more than the usual measure. 
:-(

> And the obvious test changes are fine. :)


I asked because after switching from warning to error, I had to introduce a new 
run line in the test -- effectively transforming it into two.

Andrey


Repository:
  rL LLVM

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] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const

2015-08-31 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a comment.

I have concerns about this being a frontend warning. The true positive rate 
seems rather high given the benign nature of the diagnostic, and the false 
negative rate is quite high. This seems like it would make more sense as a 
path-sensitive static analyzer warning instead of a frontend warning, as that 
would justify the slightly high true positive rate, and rectify quite a bit of 
the false negative rate.

Have you tried running this over the Clang and LLVM code bases? How many 
diagnostics does it produce?

~Aaron



Comment at: include/clang/AST/DeclBase.h:276
@@ -275,1 +275,3 @@
 
+  /// \brief Whether the declared symbol is written. Either directly or
+  /// indirectly. This makes it possible to see if a nonconst declaration can

Incomplete sentence: ... is written, either directly or...


Comment at: include/clang/AST/DeclBase.h:545
@@ -540,1 +544,3 @@
 
+  /// \brief Whether the declared symbol is written.
+  bool isWritten() const { return Written; }

What does it mean for a declared symbol to be written? We have a 
similar-sounding function in CXXCtorInitializer that means the initializer was 
explicitly written, but I don't think the same applies here?


Comment at: include/clang/Parse/Parser.h:1397
@@ -1396,1 +1396,3 @@
 private:
+  // Mark symbols in expression as written.
+  static void MarkWritten(Expr *E);

Use \brief for this comment?


Comment at: lib/Parse/ParseStmt.cpp:376
@@ +375,3 @@
+// Mark symbols in r-value expression as written.
+void Parser::MarkWritten(Expr *E) {
+  E = E->IgnoreParenCasts();

Why is this functionality part of the parser instead of Sema? For instance, 
what if the parser does not run, such as with serialized ASTs?


Comment at: lib/Parse/ParseStmt.cpp:379
@@ +378,3 @@
+  if (auto *B = dyn_cast(E)) {
+if (B->isAdditiveOp()) {
+  // p + 2

Why does addition count as "writing?"


Comment at: lib/Parse/ParseStmt.cpp:401
@@ +400,3 @@
+  } else if (auto *C = dyn_cast(E)) {
+MarkWritten(C->getTrueExpr());
+MarkWritten(C->getFalseExpr());

Again, why?


Comment at: lib/Parse/ParseStmt.cpp:451
@@ +450,3 @@
+  // Mark symbols in the expression as written.
+  MarkWritten(Expr.get()->IgnoreParenCasts());
+

No need for IgnoreParenImpCasts(), MarkWritten() already does that.


Comment at: lib/Sema/SemaDecl.cpp:8880
@@ -8879,1 +8879,3 @@
 
+static void MarkWritten(Expr *E) {
+  E = E->IgnoreParenCasts();

I'm not keen on this having the same name as the parser static method when it 
does different things. For instance, the parser only marks inc/dec derefs as 
being written, and this marks any unary operand that results in a DeclRefExpr 
as being written.

Also, missing function comments.


Comment at: lib/Sema/SemaDecl.cpp:10318
@@ -10303,1 +10317,3 @@
 
+void Sema::DiagnoseNonConstParameters(ParmVarDecl *const *Param,
+  ParmVarDecl *const *ParamEnd) {

Perhaps this should be named DiagnoseNonConstPointerParameters()?


Comment at: lib/Sema/SemaDecl.cpp:10323
@@ +10322,3 @@
+return;
+  for (; Param != ParamEnd; ++Param) {
+if (!(*Param)->isReferenced() || (*Param)->isWritten())

Could be a bit cleaner with a range-based for loop:

for (const auto *Param : llvm::make_range(P, E)) {

}


Comment at: lib/Sema/SemaDecl.cpp:10334
@@ +10333,3 @@
+  continue;
+// To start with we don't warn about structs.
+if (T->getPointeeType().getTypePtr()->isRecordType())

This seems *really* limiting (especially for C++ code), why the restriction?


Comment at: lib/Sema/SemaDecl.cpp:10917
@@ -10875,2 +10916,3 @@
 DiagnoseUnusedParameters(FD->param_begin(), FD->param_end());
+  DiagnoseNonConstParameters(FD->param_begin(), FD->param_end());
   DiagnoseSizeOfParametersAndReturnValue(FD->param_begin(), 
FD->param_end(),

Should this be triggered on deleted or defaulted functions?


Comment at: lib/Sema/SemaExpr.cpp:9518
@@ -9517,1 +9517,3 @@
 
+// Mark symbols in l-value expression as written.
+static void MarkWritten(Expr *E) {

Use \brief comments. Also, I don't see how this applies to lvalue expressions?

Also, this function is almost identical to the one in SemaDecl.cpp, except for 
array subscripts. Why the differences?


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3616
@@ -3615,2 +3615,3 @@
 NewVar->setReferenced(OldVar->isReferenced());
+NewVar->setWritten();
   }

Should this rely on OldVar->isWritten()?


Comment at: lib/Serialization/ASTReaderDec

Re: [PATCH] D11582: Fix assertion failure in TransformOpaqueValueExpr

2015-08-31 Thread Rachel Craik via cfe-commits
rcraik added a comment.

Ping 3!


http://reviews.llvm.org/D11582



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


Re: [PATCH] D12446: [PATCH] Enable clang-tidy misc-static-assert for C11

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

No longer worrying about static_assert() vs _Static_assert(). Corrected Python 
script.


http://reviews.llvm.org/D12446

Files:
  clang-tidy/misc/StaticAssertCheck.cpp
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/misc-static-assert-c11.c
  test/clang-tidy/misc-static-assert-c99.c

Index: test/clang-tidy/misc-static-assert-c99.c
===
--- test/clang-tidy/misc-static-assert-c99.c
+++ test/clang-tidy/misc-static-assert-c99.c
@@ -0,0 +1,24 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-static-assert %t -- -std=c99
+
+void abort() {}
+#ifdef NDEBUG
+#define assert(x) 1
+#else
+#define assert(x)  \
+  if (!(x))\
+  abort()
+#endif
+
+void f(void) {
+  int x = 1;
+  assert(x == 0);
+  // CHECK-FIXES: {{^  }}assert(x == 0);
+
+  #define static_assert(x, msg) _Static_assert(x, msg)
+  assert(11 == 5 + 6);
+  // CHECK-FIXES: {{^  }}assert(11 == 5 + 6);
+  #undef static_assert
+
+  assert(10 == 5 + 5);
+  // CHECK-FIXES: {{^  }}assert(10 == 5 + 5);
+}
Index: test/clang-tidy/misc-static-assert-c11.c
===
--- test/clang-tidy/misc-static-assert-c11.c
+++ test/clang-tidy/misc-static-assert-c11.c
@@ -0,0 +1,26 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-static-assert %t -- -std=c11
+
+void abort() {}
+#ifdef NDEBUG
+#define assert(x) 1
+#else
+#define assert(x)  \
+  if (!(x))\
+  abort()
+#endif
+
+void f(void) {
+  int x = 1;
+  assert(x == 0);
+  // CHECK-FIXES: {{^  }}assert(x == 0);
+
+  #define static_assert(x, msg) _Static_assert(x, msg)
+  assert(11 == 5 + 6);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
+  // CHECK-FIXES: {{^  }}static_assert(11 == 5 + 6, "");
+  #undef static_assert
+
+  assert(10 == 5 + 5);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
+  // CHECK-FIXES: {{^  }}static_assert(10 == 5 + 5, "");
+}
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -38,12 +38,16 @@
 sys.exit('Not enough arguments.')
 
   input_file_name = sys.argv[1]
+  extension = '.cpp'
+  if (input_file_name.endswith('.c')):
+extension = '.c'
+
   check_name = sys.argv[2]
-  temp_file_name = sys.argv[3] + '.cpp'
+  temp_file_name = sys.argv[3] + extension
 
   clang_tidy_extra_args = sys.argv[4:]
   if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--', '--std=c++11']
+clang_tidy_extra_args = ['--', '--std=c++11'] if extension == '.cpp' else ['--']
 
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()
Index: clang-tidy/misc/StaticAssertCheck.cpp
===
--- clang-tidy/misc/StaticAssertCheck.cpp
+++ clang-tidy/misc/StaticAssertCheck.cpp
@@ -27,10 +27,9 @@
 : ClangTidyCheck(Name, Context) {}
 
 void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
-  // FIXME: I don't see why this checker couldn't also be interesting for
-  // _Static_assert in C11, or static_assert if  has been included, 
-  // but it is currently only enabled for C++11. Investigate.
-  if (getLangOpts().CPlusPlus11) {
+  // This checker only makes sense for languages that have static assertion
+  // capabilities: C++11 and C11.
+  if (getLangOpts().CPlusPlus11 || getLangOpts().C11) {
 auto IsAlwaysFalse = expr(ignoringParenImpCasts(
 expr(anyOf(boolLiteral(equals(false)), integerLiteral(equals(0)),
nullPtrLiteralExpr(), gnuNullExpr()))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12446: [PATCH] Enable clang-tidy misc-static-assert for C11

2015-08-31 Thread Aaron Ballman via cfe-commits
aaron.ballman marked an inline comment as done.


Comment at: test/clang-tidy/misc-static-assert-c99.c:2
@@ +1,3 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-static-assert %t -- -std=c99
+
+void abort() {}

I am not certain how to accomplish this with the python script. Or are you 
thinking I should run clang-tidy directly and use "| count 0" ?


http://reviews.llvm.org/D12446



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


Re: [PATCH] D12446: [PATCH] Enable clang-tidy misc-static-assert for C11

2015-08-31 Thread Aaron Ballman via cfe-commits
It seems Phab doesn't give you any context for this comment. For
reference, this is in response to the comment:

Instead of duplicating the test, you could add a second run line in
the other test and just verify that clang-tidy doesn't generate any
warnings when run with -std=c99. The invariant "no warnings == no
fixes" is pretty basic for clang-tidy, so you can rely on it in the
tests.

~Aaron

On Mon, Aug 31, 2015 at 10:17 AM, Aaron Ballman  wrote:
> aaron.ballman marked an inline comment as done.
>
> 
> Comment at: test/clang-tidy/misc-static-assert-c99.c:2
> @@ +1,3 @@
> +// RUN: %python %S/check_clang_tidy.py %s misc-static-assert %t -- -std=c99
> +
> +void abort() {}
> 
> I am not certain how to accomplish this with the python script. Or are you 
> thinking I should run clang-tidy directly and use "| count 0" ?
>
>
> http://reviews.llvm.org/D12446
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r246444 - Using an early return as it is more clear; NFC.

2015-08-31 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Aug 31 09:23:21 2015
New Revision: 246444

URL: http://llvm.org/viewvc/llvm-project?rev=246444&view=rev
Log:
Using an early return as it is more clear; NFC.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp?rev=246444&r1=246443&r2=246444&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp 
Mon Aug 31 09:23:21 2015
@@ -21,35 +21,35 @@ void AssignOperatorSignatureCheck::regis
 ast_matchers::MatchFinder *Finder) {
   // Only register the matchers for C++; the functionality currently does not
   // provide any benefit to other languages, despite being benign.
-  if (getLangOpts().CPlusPlus) {
-const auto HasGoodReturnType = methodDecl(returns(lValueReferenceType(
-pointee(unless(isConstQualified()),
-hasDeclaration(equalsBoundNode("class"));
-
-const auto IsSelf = qualType(anyOf(
-hasDeclaration(equalsBoundNode("class")),
-referenceType(pointee(hasDeclaration(equalsBoundNode("class"));
-const auto IsSelfAssign =
-methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
-   hasName("operator="), ofClass(recordDecl().bind("class")),
-   hasParameter(0, parmVarDecl(hasType(IsSelf
-.bind("method");
-
-Finder->addMatcher(
-methodDecl(IsSelfAssign, unless(HasGoodReturnType)).bind("ReturnType"),
-this);
-
-const auto BadSelf = referenceType(
-anyOf(lValueReferenceType(pointee(unless(isConstQualified(,
-  rValueReferenceType(pointee(isConstQualified();
-
-Finder->addMatcher(
-methodDecl(IsSelfAssign, hasParameter(0, 
parmVarDecl(hasType(BadSelf
-.bind("ArgumentType"),
-this);
+  if (!getLangOpts().CPlusPlus)
+return;
 
-Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"), 
this);
-  }
+  const auto HasGoodReturnType = 
methodDecl(returns(lValueReferenceType(pointee(
+  unless(isConstQualified()), hasDeclaration(equalsBoundNode("class"));
+
+  const auto IsSelf = qualType(
+  anyOf(hasDeclaration(equalsBoundNode("class")),
+referenceType(pointee(hasDeclaration(equalsBoundNode("class"));
+  const auto IsSelfAssign =
+  methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
+ hasName("operator="), ofClass(recordDecl().bind("class")),
+ hasParameter(0, parmVarDecl(hasType(IsSelf
+  .bind("method");
+
+  Finder->addMatcher(
+  methodDecl(IsSelfAssign, unless(HasGoodReturnType)).bind("ReturnType"),
+  this);
+
+  const auto BadSelf = referenceType(
+  anyOf(lValueReferenceType(pointee(unless(isConstQualified(,
+rValueReferenceType(pointee(isConstQualified();
+
+  Finder->addMatcher(
+  methodDecl(IsSelfAssign, hasParameter(0, parmVarDecl(hasType(BadSelf
+  .bind("ArgumentType"),
+  this);
+
+  Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"), this);
 }
 
 


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


Re: [PATCH] D11815: Pass subtarget feature "force-align-stack"

2015-08-31 Thread Vasileios Kalintiris via cfe-commits
vkalintiris added a subscriber: vkalintiris.
vkalintiris added a comment.

In http://reviews.llvm.org/D11815#235394, @ahatanak wrote:

> The cc1 option "-mstackrealign" now means "force stack realignment" rather 
> than "allow stack realignment" and causes function attribute "stackrealign" 
> to be attached to the functions in the IR.


Please, correct me if I'm wrong but I believe that the -force-align-stack 
option. which was removed in http://reviews.llvm.org/D11814, was x86-specific 
(in the sense that it was only really tested in X86) and almost always 
accompanied by a -stack-alignment value that was equal or greater than the 
requirements of the ABI.

With this change the -mstackrealign option will attach the "stackrealign" 
attribute on every function definition (and declaration) without specifying a 
valid -stack-alignment value.

I suspect that this option will be broken for every Target that relies only on 
the maximum alignment provided by MachineFrameInfo (see 
X86FrameLowering::calculateMaxStackAlign() for the correct way to handle this).

Is this the intended behaviour here? I'm a little bit cautious because this 
option would be exposed from the Clang frontend and our users would generate 
bad code if they were to try this option.

For example, on a Mips target, where the O32 ABI requires either way an 8-byte 
alignment, we would generate redundant code for realigning the stack to a 
4-byte alignment if a function contains objects with maximum alignment of 
4-bytes (see attached files to get an idea).

F803573: main.s 

F803574: main.c 

F803575: main.ll 


http://reviews.llvm.org/D11815



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


[libcxx] r246445 - Remove unused code. NFC

2015-08-31 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Aug 31 09:43:41 2015
New Revision: 246445

URL: http://llvm.org/viewvc/llvm-project?rev=246445&view=rev
Log:
Remove unused code. NFC

Modified:
libcxx/trunk/include/type_traits

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=246445&r1=246444&r2=246445&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Mon Aug 31 09:43:41 2015
@@ -1337,18 +1337,6 @@ public:
 template 
 class __promote : public __promote_imp<_A1, _A2, _A3> {};
 
-#ifdef _LIBCPP_STORE_AS_OPTIMIZATION
-
-// __transform
-
-template ::value> 
struct __transform {typedef _Tp type;};
-template  struct __transform<_Tp, 1, true> {typedef unsigned char   
   type;};
-template  struct __transform<_Tp, 2, true> {typedef unsigned short  
   type;};
-template  struct __transform<_Tp, 4, true> {typedef unsigned int
   type;};
-template  struct __transform<_Tp, 8, true> {typedef unsigned long 
long type;};
-
-#endif  // _LIBCPP_STORE_AS_OPTIMIZATION
-
 // make_signed / make_unsigned
 
 typedef


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


[clang-tools-extra] r246446 - [clang-tidy] misc-assert-side-effect: support assert macros defined through other macros

2015-08-31 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Aug 31 09:47:14 2015
New Revision: 246446

URL: http://llvm.org/viewvc/llvm-project?rev=246446&view=rev
Log:
[clang-tidy] misc-assert-side-effect: support assert macros defined through 
other macros

Modified:
clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-assert-side-effect.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp?rev=246446&r1=246445&r2=246446&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp Mon Aug 
31 09:47:14 2015
@@ -96,22 +96,26 @@ void AssertSideEffectCheck::registerMatc
 }
 
 void AssertSideEffectCheck::check(const MatchFinder::MatchResult &Result) {
-  const ASTContext *ASTCtx = Result.Context;
-  const auto *CondStmt = Result.Nodes.getNodeAs("condStmt");
-  SourceLocation Loc = CondStmt->getLocStart();
-
-  if (!Loc.isValid() || !Loc.isMacroID())
-return;
-
-  StringRef MacroName = Lexer::getImmediateMacroName(
-  Loc, ASTCtx->getSourceManager(), ASTCtx->getLangOpts());
-
-  // Check if this macro is an assert.
-  if (std::find(AssertMacros.begin(), AssertMacros.end(), MacroName) ==
-  AssertMacros.end())
+  const SourceManager &SM = *Result.SourceManager;
+  const LangOptions LangOpts = Result.Context->getLangOpts();
+  SourceLocation Loc = Result.Nodes.getNodeAs("condStmt")->getLocStart();
+
+  StringRef AssertMacroName;
+  while (Loc.isValid() && Loc.isMacroID()) {
+StringRef MacroName = Lexer::getImmediateMacroName(Loc, SM, LangOpts);
+
+// Check if this macro is an assert.
+if (std::find(AssertMacros.begin(), AssertMacros.end(), MacroName) !=
+AssertMacros.end()) {
+  AssertMacroName = MacroName;
+  break;
+}
+Loc = SM.getImmediateMacroCallerLoc(Loc);
+  }
+  if (AssertMacroName.empty())
 return;
 
-  diag(Loc, "found " + MacroName.str() + "() with side effect");
+  diag(Loc, "found " + AssertMacroName.str() + "() with side effect");
 }
 
 } // namespace tidy

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-assert-side-effect.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-assert-side-effect.cpp?rev=246446&r1=246445&r2=246446&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-assert-side-effect.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-assert-side-effect.cpp Mon Aug 
31 09:47:14 2015
@@ -1,4 +1,4 @@
-// RUN: %python %S/check_clang_tidy.py %s misc-assert-side-effect %t 
-config="{CheckOptions: [{key: misc-assert-side-effect.CheckFunctionCalls, 
value: 1}, {key: misc-assert-side-effect.AssertMacros, value: 
'assert,assert2,my_assert'}]}" -- -fexceptions
+// RUN: %python %S/check_clang_tidy.py %s misc-assert-side-effect %t 
-config="{CheckOptions: [{key: misc-assert-side-effect.CheckFunctionCalls, 
value: 1}, {key: misc-assert-side-effect.AssertMacros, value: 
'assert,assert2,my_assert,convoluted_assert'}]}" -- -fexceptions
 
 //===--- assert definition block 
--===//
 int abort() { return 0; }
@@ -29,6 +29,12 @@ void print(...);
   if (!(x))
\
   (void)abort()
 #endif
+
+#define real_assert(x) ((void)((x) ? 1 : abort()))
+#define wrap1(x) real_assert(x)
+#define wrap2(x) wrap1(x)
+#define convoluted_assert(x) wrap2(x)
+
 
//===--===//
 
 class MyClass {
@@ -59,6 +65,8 @@ int main() {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect 
[misc-assert-side-effect]
   my_assert(X = 1);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found my_assert() with side 
effect
+  convoluted_assert(X = 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found convoluted_assert() with 
side effect
   not_my_assert(X = 1);
 
   assert(++X);


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


Re: [PATCH] D11963: Create a __config_site file to capture configuration decisions.

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

In http://reviews.llvm.org/D11963#236045, @EricWF wrote:

> So that's not what happens but that's because libc++ builds using the headers 
> in the source directory. During the build all of the macros in the 
> __config_site file are manually defined on the command line so that we don't 
> need to use the generated headers. NOTE: The tests still use the generated 
> headers though.


Oh, I didn't catch that you were setting this up to build from the headers in 
the source directory.


http://reviews.llvm.org/D11963



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


Re: r246384 - [OpenMP] Make the filetered clause iterator a real iterator and type safe.

2015-08-31 Thread David Blaikie via cfe-commits
Any chance this would be improved/further simplified by basing it on the
adapter_iterator helper in LLVM's STL Utilities?

On Sun, Aug 30, 2015 at 8:12 AM, Benjamin Kramer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: d0k
> Date: Sun Aug 30 10:12:28 2015
> New Revision: 246384
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246384&view=rev
> Log:
> [OpenMP] Make the filetered clause iterator a real iterator and type safe.
>
> This replaces the filtered generic iterator with a type-specfic one based
> on dyn_cast instead of comparing the kind enum. This allows us to use
> range-based for loops and eliminates casts. No functionality change
> intended.
>
> Modified:
> cfe/trunk/include/clang/AST/StmtOpenMP.h
> cfe/trunk/lib/AST/Stmt.cpp
> cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
>
> Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=246384&r1=246383&r2=246384&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
> +++ cfe/trunk/include/clang/AST/StmtOpenMP.h Sun Aug 30 10:12:28 2015
> @@ -92,65 +92,91 @@ public:
>/// \brief Iterates over a filtered subrange of clauses applied to a
>/// directive.
>///
> -  /// This iterator visits only those declarations that meet some run-time
> -  /// criteria.
> -  template  class filtered_clause_iterator {
> -  protected:
> +  /// This iterator visits only clauses of type SpecificClause.
> +  template 
> +  class specific_clause_iterator
> +  : public std::iterator SpecificClause *,
> + ptrdiff_t, const SpecificClause *,
> + const SpecificClause *> {
>  ArrayRef::const_iterator Current;
>  ArrayRef::const_iterator End;
> -FilterPredicate Pred;
> +
>  void SkipToNextClause() {
> -  while (Current != End && !Pred(*Current))
> +  while (Current != End && !isa(*Current))
>  ++Current;
>  }
>
>public:
> -typedef const OMPClause *value_type;
> -filtered_clause_iterator() : Current(), End() {}
> -filtered_clause_iterator(ArrayRef Arr, FilterPredicate
> Pred)
> -: Current(Arr.begin()), End(Arr.end()), Pred(std::move(Pred)) {
> +explicit specific_clause_iterator(ArrayRef Clauses)
> +: Current(Clauses.begin()), End(Clauses.end()) {
>SkipToNextClause();
>  }
> -value_type operator*() const { return *Current; }
> -value_type operator->() const { return *Current; }
> -filtered_clause_iterator &operator++() {
> +
> +const SpecificClause *operator*() const {
> +  return cast(*Current);
> +}
> +const SpecificClause *operator->() const {
> +  return cast(*Current);
> +}
> +
> +specific_clause_iterator &operator++() {
>++Current;
>SkipToNextClause();
>return *this;
>  }
> -
> -filtered_clause_iterator operator++(int) {
> -  filtered_clause_iterator tmp(*this);
> +specific_clause_iterator operator++(int) {
> +  specific_clause_iterator tmp(*this);
>++(*this);
>return tmp;
>  }
>
> -bool operator!() { return Current == End; }
> -explicit operator bool() { return Current != End; }
> -bool empty() const { return Current == End; }
> +bool operator==(const specific_clause_iterator &RHS) const {
> +  assert(End == RHS.End && "Comparing iterators of different
> directives!");
> +  return Current == RHS.Current;
> +}
> +bool operator!=(const specific_clause_iterator &RHS) const {
> +  return !(*this == RHS);
> +}
>};
>
> -  template 
> -  filtered_clause_iterator getFilteredClauses(Fn &&fn) const {
> -return filtered_clause_iterator(clauses(), std::move(fn));
> +  template 
> +  static llvm::iterator_range>
> +  getClausesOfKind(ArrayRef Clauses) {
> +return {specific_clause_iterator(Clauses),
> +specific_clause_iterator(
> +llvm::makeArrayRef(Clauses.end(), 0))};
>}
> -  struct ClauseKindFilter {
> -OpenMPClauseKind Kind;
> -bool operator()(const OMPClause *clause) const {
> -  return clause->getClauseKind() == Kind;
> -}
> -  };
> -  filtered_clause_iterator
> -  getClausesOfKind(OpenMPClauseKind Kind) const {
> -return getFilteredClauses(ClauseKindFilter{Kind});
> +
> +  template 
> +  llvm::iterator_range>
> +  getClausesOfKind() const {
> +return getClausesOfKind(clauses());
>}
>
> -  /// \brief Gets a single clause of the specified kind \a K associated
> with the
> +  /// Gets a single clause of the specified kind associated with the
>/// current directive iff there is only one clause of this kind (and
> assertion
>/// is fired if there is more than one clause is associated with the
> -  /// directive). Returns nullptr if no clause of kind \a K is associated
> with
> +

Re: [clang-tools-extra] r246444 - Using an early return as it is more clear; NFC.

2015-08-31 Thread Alexander Kornienko via cfe-commits
Thanks! Could you do the same for the other files changed in that revision?

On Mon, Aug 31, 2015 at 4:23 PM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Mon Aug 31 09:23:21 2015
> New Revision: 246444
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246444&view=rev
> Log:
> Using an early return as it is more clear; NFC.
>
> Modified:
>
> clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp?rev=246444&r1=246443&r2=246444&view=diff
>
> ==
> ---
> clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
> (original)
> +++
> clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
> Mon Aug 31 09:23:21 2015
> @@ -21,35 +21,35 @@ void AssignOperatorSignatureCheck::regis
>  ast_matchers::MatchFinder *Finder) {
>// Only register the matchers for C++; the functionality currently does
> not
>// provide any benefit to other languages, despite being benign.
> -  if (getLangOpts().CPlusPlus) {
> -const auto HasGoodReturnType = methodDecl(returns(lValueReferenceType(
> -pointee(unless(isConstQualified()),
> -hasDeclaration(equalsBoundNode("class"));
> -
> -const auto IsSelf = qualType(anyOf(
> -hasDeclaration(equalsBoundNode("class")),
> -
> referenceType(pointee(hasDeclaration(equalsBoundNode("class"));
> -const auto IsSelfAssign =
> -methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
> -   hasName("operator="),
> ofClass(recordDecl().bind("class")),
> -   hasParameter(0, parmVarDecl(hasType(IsSelf
> -.bind("method");
> -
> -Finder->addMatcher(
> -methodDecl(IsSelfAssign,
> unless(HasGoodReturnType)).bind("ReturnType"),
> -this);
> -
> -const auto BadSelf = referenceType(
> -anyOf(lValueReferenceType(pointee(unless(isConstQualified(,
> -  rValueReferenceType(pointee(isConstQualified();
> -
> -Finder->addMatcher(
> -methodDecl(IsSelfAssign, hasParameter(0,
> parmVarDecl(hasType(BadSelf
> -.bind("ArgumentType"),
> -this);
> +  if (!getLangOpts().CPlusPlus)
> +return;
>
> -Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"),
> this);
> -  }
> +  const auto HasGoodReturnType =
> methodDecl(returns(lValueReferenceType(pointee(
> +  unless(isConstQualified()),
> hasDeclaration(equalsBoundNode("class"));
> +
> +  const auto IsSelf = qualType(
> +  anyOf(hasDeclaration(equalsBoundNode("class")),
> +
> referenceType(pointee(hasDeclaration(equalsBoundNode("class"));
> +  const auto IsSelfAssign =
> +  methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
> + hasName("operator="),
> ofClass(recordDecl().bind("class")),
> + hasParameter(0, parmVarDecl(hasType(IsSelf
> +  .bind("method");
> +
> +  Finder->addMatcher(
> +  methodDecl(IsSelfAssign,
> unless(HasGoodReturnType)).bind("ReturnType"),
> +  this);
> +
> +  const auto BadSelf = referenceType(
> +  anyOf(lValueReferenceType(pointee(unless(isConstQualified(,
> +rValueReferenceType(pointee(isConstQualified();
> +
> +  Finder->addMatcher(
> +  methodDecl(IsSelfAssign, hasParameter(0,
> parmVarDecl(hasType(BadSelf
> +  .bind("ArgumentType"),
> +  this);
> +
> +  Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"),
> this);
>  }
>
>
>
>
> ___
> 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: [clang-tools-extra] r246444 - Using an early return as it is more clear; NFC.

2015-08-31 Thread Aaron Ballman via cfe-commits
On Mon, Aug 31, 2015 at 11:18 AM, Alexander Kornienko  wrote:
> Thanks! Could you do the same for the other files changed in that revision?

Can do.

~Aaron

>
>
> On Mon, Aug 31, 2015 at 4:23 PM, Aaron Ballman via cfe-commits
>  wrote:
>>
>> Author: aaronballman
>> Date: Mon Aug 31 09:23:21 2015
>> New Revision: 246444
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=246444&view=rev
>> Log:
>> Using an early return as it is more clear; NFC.
>>
>> Modified:
>>
>> clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
>>
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp?rev=246444&r1=246443&r2=246444&view=diff
>>
>> ==
>> ---
>> clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
>> (original)
>> +++
>> clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp Mon
>> Aug 31 09:23:21 2015
>> @@ -21,35 +21,35 @@ void AssignOperatorSignatureCheck::regis
>>  ast_matchers::MatchFinder *Finder) {
>>// Only register the matchers for C++; the functionality currently does
>> not
>>// provide any benefit to other languages, despite being benign.
>> -  if (getLangOpts().CPlusPlus) {
>> -const auto HasGoodReturnType =
>> methodDecl(returns(lValueReferenceType(
>> -pointee(unless(isConstQualified()),
>> -hasDeclaration(equalsBoundNode("class"));
>> -
>> -const auto IsSelf = qualType(anyOf(
>> -hasDeclaration(equalsBoundNode("class")),
>> -
>> referenceType(pointee(hasDeclaration(equalsBoundNode("class"));
>> -const auto IsSelfAssign =
>> -methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
>> -   hasName("operator="),
>> ofClass(recordDecl().bind("class")),
>> -   hasParameter(0, parmVarDecl(hasType(IsSelf
>> -.bind("method");
>> -
>> -Finder->addMatcher(
>> -methodDecl(IsSelfAssign,
>> unless(HasGoodReturnType)).bind("ReturnType"),
>> -this);
>> -
>> -const auto BadSelf = referenceType(
>> -anyOf(lValueReferenceType(pointee(unless(isConstQualified(,
>> -  rValueReferenceType(pointee(isConstQualified();
>> -
>> -Finder->addMatcher(
>> -methodDecl(IsSelfAssign, hasParameter(0,
>> parmVarDecl(hasType(BadSelf
>> -.bind("ArgumentType"),
>> -this);
>> +  if (!getLangOpts().CPlusPlus)
>> +return;
>>
>> -Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"),
>> this);
>> -  }
>> +  const auto HasGoodReturnType =
>> methodDecl(returns(lValueReferenceType(pointee(
>> +  unless(isConstQualified()),
>> hasDeclaration(equalsBoundNode("class"));
>> +
>> +  const auto IsSelf = qualType(
>> +  anyOf(hasDeclaration(equalsBoundNode("class")),
>> +
>> referenceType(pointee(hasDeclaration(equalsBoundNode("class"));
>> +  const auto IsSelfAssign =
>> +  methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
>> + hasName("operator="),
>> ofClass(recordDecl().bind("class")),
>> + hasParameter(0, parmVarDecl(hasType(IsSelf
>> +  .bind("method");
>> +
>> +  Finder->addMatcher(
>> +  methodDecl(IsSelfAssign,
>> unless(HasGoodReturnType)).bind("ReturnType"),
>> +  this);
>> +
>> +  const auto BadSelf = referenceType(
>> +  anyOf(lValueReferenceType(pointee(unless(isConstQualified(,
>> +rValueReferenceType(pointee(isConstQualified();
>> +
>> +  Finder->addMatcher(
>> +  methodDecl(IsSelfAssign, hasParameter(0,
>> parmVarDecl(hasType(BadSelf
>> +  .bind("ArgumentType"),
>> +  this);
>> +
>> +  Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"),
>> this);
>>  }
>>
>>
>>
>>
>> ___
>> 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


[clang-tools-extra] r246447 - Using an early return as it is more clear; NFC.

2015-08-31 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Aug 31 10:28:57 2015
New Revision: 246447

URL: http://llvm.org/viewvc/llvm-project?rev=246447&view=rev
Log:
Using an early return as it is more clear; NFC.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp
clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp?rev=246447&r1=246446&r2=246447&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp Mon Aug 31 
10:28:57 2015
@@ -21,25 +21,26 @@ namespace misc {
 void InaccurateEraseCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++; the functionality currently does not
   // provide any benefit to other languages, despite being benign.
-  if (getLangOpts().CPlusPlus) {
-const auto CheckForEndCall = hasArgument(
-1, anyOf(constructExpr(
- has(memberCallExpr(callee(methodDecl(hasName("end"
- .bind("InaccEndCall"))),
- anything()));
+  if (!getLangOpts().CPlusPlus)
+return;
 
-Finder->addMatcher(
-memberCallExpr(
-on(hasType(namedDecl(matchesName("^::std::",
-callee(methodDecl(hasName("erase"))), argumentCountIs(1),
-hasArgument(0, has(callExpr(callee(functionDecl(matchesName(
-
"^::std::(remove(_if)?|unique)$"))),
-CheckForEndCall)
-   .bind("InaccAlgCall"))),
-unless(isInTemplateInstantiation()))
-.bind("InaccErase"),
-this);
-  }
+  const auto CheckForEndCall = hasArgument(
+  1,
+  
anyOf(constructExpr(has(memberCallExpr(callee(methodDecl(hasName("end"
+  .bind("InaccEndCall"))),
+anything()));
+
+  Finder->addMatcher(
+  memberCallExpr(
+  on(hasType(namedDecl(matchesName("^::std::",
+  callee(methodDecl(hasName("erase"))), argumentCountIs(1),
+  hasArgument(0, has(callExpr(callee(functionDecl(matchesName(
+  "^::std::(remove(_if)?|unique)$"))),
+  CheckForEndCall)
+ .bind("InaccAlgCall"))),
+  unless(isInTemplateInstantiation()))
+  .bind("InaccErase"),
+  this);
 }
 
 void InaccurateEraseCheck::check(const MatchFinder::MatchResult &Result) {

Modified: clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp?rev=246447&r1=246446&r2=246447&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp Mon 
Aug 31 10:28:57 2015
@@ -30,33 +30,34 @@ static bool areTypesCompatible(QualType
 void InefficientAlgorithmCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++; the functionality currently does not
   // provide any benefit to other languages, despite being benign.
-  if (getLangOpts().CPlusPlus) {
-const std::string Algorithms =
-"^::std::(find|count|equal_range|lower_bound|upper_bound)$";
-const auto ContainerMatcher = classTemplateSpecializationDecl(
-matchesName("^::std::(unordered_)?(multi)?(set|map)$"));
-const auto Matcher =
-callExpr(
-callee(functionDecl(matchesName(Algorithms))),
-hasArgument(
-0, constructExpr(has(memberCallExpr(
-   callee(methodDecl(hasName("begin"))),
-   on(declRefExpr(
-  hasDeclaration(decl().bind("IneffContObj")),
-  
anyOf(hasType(ContainerMatcher.bind("IneffCont")),
-hasType(pointsTo(ContainerMatcher.bind(
-"IneffContPtr")
-  .bind("IneffContExpr")),

Re: [PATCH] D12458: [clang] add __builtin_unpredictable and convert to metadata

2015-08-31 Thread Sanjay Patel via cfe-commits
spatel added inline comments.


Comment at: lib/CodeGen/CodeGenFunction.cpp:1238
@@ -1217,3 +1237,3 @@
   }
-  Builder.CreateCondBr(CondV, TrueBlock, FalseBlock, Weights);
+  Builder.CreateCondBr(CondV, TrueBlock, FalseBlock, Weights, Unpredictable);
 }

spatel wrote:
> kparzysz wrote:
> > Is the definition of CreateCondBr actually updated somewhere?  I didn't see 
> > it in any other patch.
> Yes - please see the 2nd hunk in IRBuilder.h in D12341.
[the previous reply didn't make it to the commits list...trying again]
Yes - please see the 2nd hunk in IRBuilder.h in D12341.


http://reviews.llvm.org/D12458



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


Re: [PATCH] D12446: [PATCH] Enable clang-tidy misc-static-assert for C11

2015-08-31 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: test/clang-tidy/misc-static-assert-c99.c:2
@@ +1,3 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-static-assert %t -- -std=c99
+
+void abort() {}

aaron.ballman wrote:
> I am not certain how to accomplish this with the python script. Or are you 
> thinking I should run clang-tidy directly and use "| count 0" ?
I was thinking about testing c11 mode using the script and c99 mode can run 
clang-tidy directly (without `-fix`) and use `| count 0`, `| grep -v 
'warning:'` or anything else with the same meaning.


http://reviews.llvm.org/D12446



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


Re: [PATCH] D12446: [PATCH] Enable clang-tidy misc-static-assert for C11

2015-08-31 Thread Manuel Klimek via cfe-commits
klimek added a subscriber: klimek.


Comment at: test/clang-tidy/misc-static-assert-c99.c:2
@@ +1,3 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-static-assert %t -- -std=c99
+
+void abort() {}

aaron.ballman wrote:
> I am not certain how to accomplish this with the python script. Or are you 
> thinking I should run clang-tidy directly and use "| count 0" ?
Phab test.


http://reviews.llvm.org/D12446



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


Re: [PATCH] D12446: [PATCH] Enable clang-tidy misc-static-assert for C11

2015-08-31 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: test/clang-tidy/misc-static-assert-c99.c:1
@@ +1,2 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-static-assert %t -- -std=c99
+

alexfh wrote:
> Instead of duplicating the test, you could add a second run line in the other 
> test and just verify that clang-tidy doesn't generate any warnings when run 
> with `-std=c99`. The invariant "no warnings == no fixes" is pretty basic for 
> clang-tidy, so you can rely on it in the tests.
Phab test 2.


http://reviews.llvm.org/D12446



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


Re: [PATCH] D12446: [PATCH] Enable clang-tidy misc-static-assert for C11

2015-08-31 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: test/clang-tidy/misc-static-assert-c99.c:2
@@ +1,3 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-static-assert %t -- -std=c99
+
+void abort() {}

alexfh wrote:
> klimek wrote:
> > aaron.ballman wrote:
> > > I am not certain how to accomplish this with the python script. Or are 
> > > you thinking I should run clang-tidy directly and use "| count 0" ?
> > Phab test.
> I was thinking about testing c11 mode using the script and c99 mode can run 
> clang-tidy directly (without `-fix`) and use `| count 0`, `| grep -v 
> 'warning:'` or anything else with the same meaning.
Phab test.


http://reviews.llvm.org/D12446



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


Re: [PATCH] D12458: [clang] add __builtin_unpredictable and convert to metadata

2015-08-31 Thread Krzysztof Parzyszek via cfe-commits
kparzysz added a comment.

LGTM



Comment at: lib/CodeGen/CodeGenFunction.cpp:1238
@@ -1217,3 +1237,3 @@
   }
-  Builder.CreateCondBr(CondV, TrueBlock, FalseBlock, Weights);
+  Builder.CreateCondBr(CondV, TrueBlock, FalseBlock, Weights, Unpredictable);
 }

spatel wrote:
> spatel wrote:
> > kparzysz wrote:
> > > Is the definition of CreateCondBr actually updated somewhere?  I didn't 
> > > see it in any other patch.
> > Yes - please see the 2nd hunk in IRBuilder.h in D12341.
> [the previous reply didn't make it to the commits list...trying again]
> Yes - please see the 2nd hunk in IRBuilder.h in D12341.
You're right.  I see it.


http://reviews.llvm.org/D12458



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


Re: [PATCH] D12473: [clang-tidy] Add old style function check

2015-08-31 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

A high-level comment:

It seems that the scope of the check is artificially made too narrow. The check 
could actually look at any POD variables declared unnecessarily far from their 
initialization and usages. And here the value of the check would also be much 
higher, if it can automatically fix the code.

I'll review the code more thoroughly later.


http://reviews.llvm.org/D12473



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


Re: [PATCH] D12446: [PATCH] Enable clang-tidy misc-static-assert for C11

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

Only use a single test file with two RUN lines.


http://reviews.llvm.org/D12446

Files:
  clang-tidy/misc/StaticAssertCheck.cpp
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/misc-static-assert.c

Index: test/clang-tidy/misc-static-assert.c
===
--- test/clang-tidy/misc-static-assert.c
+++ test/clang-tidy/misc-static-assert.c
@@ -0,0 +1,27 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-static-assert %t -- -std=c11
+// RUN: clang-tidy %s -checks=-*,misc-static-assert -- -std=c99 | count 0
+
+void abort() {}
+#ifdef NDEBUG
+#define assert(x) 1
+#else
+#define assert(x)  
\
+  if (!(x))
\
+  abort()
+#endif
+
+void f(void) {
+  int x = 1;
+  assert(x == 0);
+  // CHECK-FIXES: {{^  }}assert(x == 0);
+
+  #define static_assert(x, msg) _Static_assert(x, msg)
+  assert(11 == 5 + 6);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
+  // CHECK-FIXES: {{^  }}static_assert(11 == 5 + 6, "");
+  #undef static_assert
+
+  assert(10 == 5 + 5);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
+  // CHECK-FIXES: {{^  }}static_assert(10 == 5 + 5, "");
+}
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -38,12 +38,16 @@
 sys.exit('Not enough arguments.')
 
   input_file_name = sys.argv[1]
+  extension = '.cpp'
+  if (input_file_name.endswith('.c')):
+extension = '.c'
+
   check_name = sys.argv[2]
-  temp_file_name = sys.argv[3] + '.cpp'
+  temp_file_name = sys.argv[3] + extension
 
   clang_tidy_extra_args = sys.argv[4:]
   if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--', '--std=c++11']
+clang_tidy_extra_args = ['--', '--std=c++11'] if extension == '.cpp' else 
['--']
 
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()
Index: clang-tidy/misc/StaticAssertCheck.cpp
===
--- clang-tidy/misc/StaticAssertCheck.cpp
+++ clang-tidy/misc/StaticAssertCheck.cpp
@@ -27,10 +27,9 @@
 : ClangTidyCheck(Name, Context) {}
 
 void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
-  // FIXME: I don't see why this checker couldn't also be interesting for
-  // _Static_assert in C11, or static_assert if  has been included, 
-  // but it is currently only enabled for C++11. Investigate.
-  if (!getLangOpts().CPlusPlus11)
+  // This checker only makes sense for languages that have static assertion
+  // capabilities: C++11 and C11.
+  if (!(getLangOpts().CPlusPlus11 || getLangOpts().C11))
 return;
 
   auto IsAlwaysFalse = expr(ignoringParenImpCasts(


Index: test/clang-tidy/misc-static-assert.c
===
--- test/clang-tidy/misc-static-assert.c
+++ test/clang-tidy/misc-static-assert.c
@@ -0,0 +1,27 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-static-assert %t -- -std=c11
+// RUN: clang-tidy %s -checks=-*,misc-static-assert -- -std=c99 | count 0
+
+void abort() {}
+#ifdef NDEBUG
+#define assert(x) 1
+#else
+#define assert(x)  \
+  if (!(x))\
+  abort()
+#endif
+
+void f(void) {
+  int x = 1;
+  assert(x == 0);
+  // CHECK-FIXES: {{^  }}assert(x == 0);
+
+  #define static_assert(x, msg) _Static_assert(x, msg)
+  assert(11 == 5 + 6);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
+  // CHECK-FIXES: {{^  }}static_assert(11 == 5 + 6, "");
+  #undef static_assert
+
+  assert(10 == 5 + 5);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
+  // CHECK-FIXES: {{^  }}static_assert(10 == 5 + 5, "");
+}
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -38,12 +38,16 @@
 sys.exit('Not enough arguments.')
 
   input_file_name = sys.argv[1]
+  extension = '.cpp'
+  if (input_file_name.endswith('.c')):
+extension = '.c'
+
   check_name = sys.argv[2]
-  temp_file_name = sys.argv[3] + '.cpp'
+  temp_file_name = sys.argv[3] + extension
 
   clang_tidy_extra_args = sys.argv[4:]
   if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--', '--std=c++11']
+clang_tidy_extra_args = ['--', '--std=c++11'] if extension == '.cpp' else ['--']
 
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()
Index: clang-tidy/misc/StaticAssertCheck.cpp

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

2015-08-31 Thread Hans Wennborg via cfe-commits
hans added a comment.

I also don't know anything about how this plugin works, I just build it :) I'm 
hoping Manuel can take a look.


http://reviews.llvm.org/D12407



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


r246452 - [OpenMP] base specific_clause_iterator on iterator_adaptor_base.

2015-08-31 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Aug 31 11:45:35 2015
New Revision: 246452

URL: http://llvm.org/viewvc/llvm-project?rev=246452&view=rev
Log:
[OpenMP] base specific_clause_iterator on iterator_adaptor_base.

Removes some boilerplate code. No functionality change intended.

Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=246452&r1=246451&r2=246452&view=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Mon Aug 31 11:45:35 2015
@@ -95,48 +95,35 @@ public:
   /// This iterator visits only clauses of type SpecificClause.
   template 
   class specific_clause_iterator
-  : public std::iterator {
-ArrayRef::const_iterator Current;
+  : public llvm::iterator_adaptor_base<
+specific_clause_iterator,
+ArrayRef::const_iterator, std::forward_iterator_tag,
+const SpecificClause *, ptrdiff_t, const SpecificClause *,
+const SpecificClause *> {
 ArrayRef::const_iterator End;
 
 void SkipToNextClause() {
-  while (Current != End && !isa(*Current))
-++Current;
+  while (this->I != End && !isa(*this->I))
+++this->I;
 }
 
   public:
 explicit specific_clause_iterator(ArrayRef Clauses)
-: Current(Clauses.begin()), End(Clauses.end()) {
+: specific_clause_iterator::iterator_adaptor_base(Clauses.begin()),
+  End(Clauses.end()) {
   SkipToNextClause();
 }
 
 const SpecificClause *operator*() const {
-  return cast(*Current);
-}
-const SpecificClause *operator->() const {
-  return cast(*Current);
+  return cast(*this->I);
 }
+const SpecificClause *operator->() const { return **this; }
 
 specific_clause_iterator &operator++() {
-  ++Current;
+  ++this->I;
   SkipToNextClause();
   return *this;
 }
-specific_clause_iterator operator++(int) {
-  specific_clause_iterator tmp(*this);
-  ++(*this);
-  return tmp;
-}
-
-bool operator==(const specific_clause_iterator &RHS) const {
-  assert(End == RHS.End && "Comparing iterators of different directives!");
-  return Current == RHS.Current;
-}
-bool operator!=(const specific_clause_iterator &RHS) const {
-  return !(*this == RHS);
-}
   };
 
   template 


___
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-31 Thread Manuel Klimek via cfe-commits
I'll need to try to build / install it. I'll take a couple of days, I'm
currently swamped. Hope that's ok.

On Mon, Aug 31, 2015 at 6:25 PM Hans Wennborg  wrote:

> hans added a comment.
>
> I also don't know anything about how this plugin works, I just build it :)
> I'm hoping Manuel can take a look.
>
>
> 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] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk

2015-08-31 Thread Manuel Klimek via cfe-commits
klimek added a subscriber: klimek.
klimek added a comment.

I'll need to try to build / install it. I'll take a couple of days, I'm
currently swamped. Hope that's ok.


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: r246384 - [OpenMP] Make the filetered clause iterator a real iterator and type safe.

2015-08-31 Thread Benjamin Kramer via cfe-commits
On Mon, Aug 31, 2015 at 5:12 PM, David Blaikie  wrote:

> Any chance this would be improved/further simplified by basing it on the
> adapter_iterator helper in LLVM's STL Utilities?
>

Fair enough, r246452. I was a bit nervous because this iterator overrides
operator++ but iterator_adaptor_base seems to be doing the right thing even
when ++ is overridden.

- Ben


> On Sun, Aug 30, 2015 at 8:12 AM, Benjamin Kramer via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: d0k
>> Date: Sun Aug 30 10:12:28 2015
>> New Revision: 246384
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=246384&view=rev
>> Log:
>> [OpenMP] Make the filetered clause iterator a real iterator and type safe.
>>
>> This replaces the filtered generic iterator with a type-specfic one based
>> on dyn_cast instead of comparing the kind enum. This allows us to use
>> range-based for loops and eliminates casts. No functionality change
>> intended.
>>
>> Modified:
>> cfe/trunk/include/clang/AST/StmtOpenMP.h
>> cfe/trunk/lib/AST/Stmt.cpp
>> cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
>> cfe/trunk/lib/Sema/SemaOpenMP.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=246384&r1=246383&r2=246384&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
>> +++ cfe/trunk/include/clang/AST/StmtOpenMP.h Sun Aug 30 10:12:28 2015
>> @@ -92,65 +92,91 @@ public:
>>/// \brief Iterates over a filtered subrange of clauses applied to a
>>/// directive.
>>///
>> -  /// This iterator visits only those declarations that meet some
>> run-time
>> -  /// criteria.
>> -  template  class filtered_clause_iterator {
>> -  protected:
>> +  /// This iterator visits only clauses of type SpecificClause.
>> +  template 
>> +  class specific_clause_iterator
>> +  : public std::iterator> SpecificClause *,
>> + ptrdiff_t, const SpecificClause *,
>> + const SpecificClause *> {
>>  ArrayRef::const_iterator Current;
>>  ArrayRef::const_iterator End;
>> -FilterPredicate Pred;
>> +
>>  void SkipToNextClause() {
>> -  while (Current != End && !Pred(*Current))
>> +  while (Current != End && !isa(*Current))
>>  ++Current;
>>  }
>>
>>public:
>> -typedef const OMPClause *value_type;
>> -filtered_clause_iterator() : Current(), End() {}
>> -filtered_clause_iterator(ArrayRef Arr, FilterPredicate
>> Pred)
>> -: Current(Arr.begin()), End(Arr.end()), Pred(std::move(Pred)) {
>> +explicit specific_clause_iterator(ArrayRef Clauses)
>> +: Current(Clauses.begin()), End(Clauses.end()) {
>>SkipToNextClause();
>>  }
>> -value_type operator*() const { return *Current; }
>> -value_type operator->() const { return *Current; }
>> -filtered_clause_iterator &operator++() {
>> +
>> +const SpecificClause *operator*() const {
>> +  return cast(*Current);
>> +}
>> +const SpecificClause *operator->() const {
>> +  return cast(*Current);
>> +}
>> +
>> +specific_clause_iterator &operator++() {
>>++Current;
>>SkipToNextClause();
>>return *this;
>>  }
>> -
>> -filtered_clause_iterator operator++(int) {
>> -  filtered_clause_iterator tmp(*this);
>> +specific_clause_iterator operator++(int) {
>> +  specific_clause_iterator tmp(*this);
>>++(*this);
>>return tmp;
>>  }
>>
>> -bool operator!() { return Current == End; }
>> -explicit operator bool() { return Current != End; }
>> -bool empty() const { return Current == End; }
>> +bool operator==(const specific_clause_iterator &RHS) const {
>> +  assert(End == RHS.End && "Comparing iterators of different
>> directives!");
>> +  return Current == RHS.Current;
>> +}
>> +bool operator!=(const specific_clause_iterator &RHS) const {
>> +  return !(*this == RHS);
>> +}
>>};
>>
>> -  template 
>> -  filtered_clause_iterator getFilteredClauses(Fn &&fn) const {
>> -return filtered_clause_iterator(clauses(), std::move(fn));
>> +  template 
>> +  static llvm::iterator_range>
>> +  getClausesOfKind(ArrayRef Clauses) {
>> +return {specific_clause_iterator(Clauses),
>> +specific_clause_iterator(
>> +llvm::makeArrayRef(Clauses.end(), 0))};
>>}
>> -  struct ClauseKindFilter {
>> -OpenMPClauseKind Kind;
>> -bool operator()(const OMPClause *clause) const {
>> -  return clause->getClauseKind() == Kind;
>> -}
>> -  };
>> -  filtered_clause_iterator
>> -  getClausesOfKind(OpenMPClauseKind Kind) const {
>> -return getFilteredClauses(ClauseKindFilter{Kind});
>> +
>> +  template 
>> +  llvm::iterator_range>
>> +  getClausesOfKind() const {
>> +return getClausesOfKind(clauses());
>>}
>>
>> -  /// \brief Gets a sing

Re: r246384 - [OpenMP] Make the filetered clause iterator a real iterator and type safe.

2015-08-31 Thread David Blaikie via cfe-commits
On Mon, Aug 31, 2015 at 9:48 AM, Benjamin Kramer 
wrote:

>
>
> On Mon, Aug 31, 2015 at 5:12 PM, David Blaikie  wrote:
>
>> Any chance this would be improved/further simplified by basing it on the
>> adapter_iterator helper in LLVM's STL Utilities?
>>
>
> Fair enough, r246452. I was a bit nervous because this iterator overrides
> operator++ but iterator_adaptor_base seems to be doing the right thing even
> when ++ is overridden.
>

Neat - thanks a bunch! :D


>
> - Ben
>
>
>> On Sun, Aug 30, 2015 at 8:12 AM, Benjamin Kramer via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: d0k
>>> Date: Sun Aug 30 10:12:28 2015
>>> New Revision: 246384
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=246384&view=rev
>>> Log:
>>> [OpenMP] Make the filetered clause iterator a real iterator and type
>>> safe.
>>>
>>> This replaces the filtered generic iterator with a type-specfic one based
>>> on dyn_cast instead of comparing the kind enum. This allows us to use
>>> range-based for loops and eliminates casts. No functionality change
>>> intended.
>>>
>>> Modified:
>>> cfe/trunk/include/clang/AST/StmtOpenMP.h
>>> cfe/trunk/lib/AST/Stmt.cpp
>>> cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
>>> cfe/trunk/lib/Sema/SemaOpenMP.cpp
>>>
>>> Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=246384&r1=246383&r2=246384&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
>>> +++ cfe/trunk/include/clang/AST/StmtOpenMP.h Sun Aug 30 10:12:28 2015
>>> @@ -92,65 +92,91 @@ public:
>>>/// \brief Iterates over a filtered subrange of clauses applied to a
>>>/// directive.
>>>///
>>> -  /// This iterator visits only those declarations that meet some
>>> run-time
>>> -  /// criteria.
>>> -  template  class filtered_clause_iterator {
>>> -  protected:
>>> +  /// This iterator visits only clauses of type SpecificClause.
>>> +  template 
>>> +  class specific_clause_iterator
>>> +  : public std::iterator>> SpecificClause *,
>>> + ptrdiff_t, const SpecificClause *,
>>> + const SpecificClause *> {
>>>  ArrayRef::const_iterator Current;
>>>  ArrayRef::const_iterator End;
>>> -FilterPredicate Pred;
>>> +
>>>  void SkipToNextClause() {
>>> -  while (Current != End && !Pred(*Current))
>>> +  while (Current != End && !isa(*Current))
>>>  ++Current;
>>>  }
>>>
>>>public:
>>> -typedef const OMPClause *value_type;
>>> -filtered_clause_iterator() : Current(), End() {}
>>> -filtered_clause_iterator(ArrayRef Arr, FilterPredicate
>>> Pred)
>>> -: Current(Arr.begin()), End(Arr.end()), Pred(std::move(Pred)) {
>>> +explicit specific_clause_iterator(ArrayRef Clauses)
>>> +: Current(Clauses.begin()), End(Clauses.end()) {
>>>SkipToNextClause();
>>>  }
>>> -value_type operator*() const { return *Current; }
>>> -value_type operator->() const { return *Current; }
>>> -filtered_clause_iterator &operator++() {
>>> +
>>> +const SpecificClause *operator*() const {
>>> +  return cast(*Current);
>>> +}
>>> +const SpecificClause *operator->() const {
>>> +  return cast(*Current);
>>> +}
>>> +
>>> +specific_clause_iterator &operator++() {
>>>++Current;
>>>SkipToNextClause();
>>>return *this;
>>>  }
>>> -
>>> -filtered_clause_iterator operator++(int) {
>>> -  filtered_clause_iterator tmp(*this);
>>> +specific_clause_iterator operator++(int) {
>>> +  specific_clause_iterator tmp(*this);
>>>++(*this);
>>>return tmp;
>>>  }
>>>
>>> -bool operator!() { return Current == End; }
>>> -explicit operator bool() { return Current != End; }
>>> -bool empty() const { return Current == End; }
>>> +bool operator==(const specific_clause_iterator &RHS) const {
>>> +  assert(End == RHS.End && "Comparing iterators of different
>>> directives!");
>>> +  return Current == RHS.Current;
>>> +}
>>> +bool operator!=(const specific_clause_iterator &RHS) const {
>>> +  return !(*this == RHS);
>>> +}
>>>};
>>>
>>> -  template 
>>> -  filtered_clause_iterator getFilteredClauses(Fn &&fn) const {
>>> -return filtered_clause_iterator(clauses(), std::move(fn));
>>> +  template 
>>> +  static llvm::iterator_range>
>>> +  getClausesOfKind(ArrayRef Clauses) {
>>> +return {specific_clause_iterator(Clauses),
>>> +specific_clause_iterator(
>>> +llvm::makeArrayRef(Clauses.end(), 0))};
>>>}
>>> -  struct ClauseKindFilter {
>>> -OpenMPClauseKind Kind;
>>> -bool operator()(const OMPClause *clause) const {
>>> -  return clause->getClauseKind() == Kind;
>>> -}
>>> -  };
>>> -  filtered_clause_iterator
>>> -  getClausesOfKind(OpenMPClauseKind Ki

Re: [PATCH][Solaris] Clang/Driver, stop hardcoding GCC paths in crt/ld.so lookup

2015-08-31 Thread Rafael Espíndola via cfe-commits
Do you have a version with the last suggestions? I lgtmed it conditional on
it.   Do you need someone to commit it for you?
On Aug 23, 2015 7:07 PM, "Rafael Espíndola" 
wrote:

> SolarisScanLibDirForGCCTriple should start with a lower case. Starting
> it with "scan" would probably also be more in line with the code
> style.
>
> LGTM
>
> On 11 August 2015 at 16:33, Xan López  wrote:
> > Hi,
> >
> > thanks for the review, I was not even aware that this could be
> > tested. Adding a test helped to fix me a couple extra issues (plus the
> > one you already mentioned). New patch attached.
> >
> > Xan
> >
> > On Wed, Aug 05, 2015 at 09:14:30AM -0400, Rafael Espíndola wrote:
> >> Please git-clang-format this patch.
> >>
> >> +  // /usr/gcc/./lib/gcc/../,
> >>
> >> The code appends a triple after the "/lib/gcc". Is the comment missing
> it?
> >>
> >> The inner loop has no version comparison. Are you depending on the
> >> directory iteration order?
> >>
> >> Can you add a testcase?
> >>
> >>
> >> On 28 July 2015 at 12:35, Xan López  wrote:
> >> > Here it is.
> >> >
> >> > On Tue, Jul 28, 2015 at 01:21:06PM +0200, Xan López wrote:
> >> >> On Tue, Jul 28, 2015 at 01:55:23PM +0300, Yaron Keren wrote:
> >> >> > +cfe-commits
> >> >> >
> >> >> > This is a very large Solaris special case in
> ScanLibDirForGCCTriple which
> >> >> > shares almost no code with the function.
> >> >> > How about splitting it out to a helper function or
> >> >> > making ScanLibDirForGCCTriple virtual and overriding on Solaris?
> >> >>
> >> >> Yep, at least a helper function makes sense, you are right. I'll send
> >> >> another patch with either of those suggestions later today.
> >> >>
> >> >>
> >> >> Xan
> >> >> ___
> >> >> llvm-commits mailing list
> >> >> llvm-comm...@cs.uiuc.edu
> >> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >> >
> >> > ___
> >> > llvm-commits mailing list
> >> > llvm-comm...@cs.uiuc.edu
> >> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12435: [Concepts] Add diagnostic; invalid specifier on function or variable concept declaration

2015-08-31 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 33587.
nwilson added a comment.

Change the wording of diagnostic message and quote the invalid specifier. Add 
'friend' as an invalid specifier and diagnose function concepts when 'friend' 
is specified. Reorder the list of invalid specifiers and corresponding checks 
in the code to match the TS.


http://reviews.llvm.org/D12435

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
@@ -0,0 +1,13 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template concept thread_local bool VCTL = true; // expected-error 
{{variable concept cannot be declared 'thread_local'}}
+
+template concept constexpr bool VCC = true; // expected-error 
{{variable concept cannot be declared 'constexpr'}}
+
+template concept inline bool FCI() { return true; } // 
expected-error {{function concept cannot be declared 'inline'}}
+
+struct X {
+  template concept friend bool FCF() { return true; } // 
expected-error {{function concept cannot be declared 'friend'}}
+};
+
+template concept constexpr bool FCC() { return true; } // 
expected-error {{function concept cannot be declared 'constexpr'}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5871,8 +5871,26 @@
 if (D.getDeclSpec().isConstexprSpecified())
   NewVD->setConstexpr(true);
 
-if (D.getDeclSpec().isConceptSpecified())
+if (D.getDeclSpec().isConceptSpecified()) {
   NewVD->setConcept(true);
+
+  // C++ Concepts TS [dcl.spec.concept]p2: A concept definition shall not
+  // be declared with the thread_local, inline, friend, or constexpr
+  // specifiers, [...]
+  if (D.getDeclSpec().getThreadStorageClassSpec() == TSCS_thread_local) {
+Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
+ diag::err_concept_decl_invalid_specifiers)
+<< 0 << 0;
+NewVD->setInvalidDecl(true);
+  }
+
+  if (D.getDeclSpec().isConstexprSpecified()) {
+Diag(D.getDeclSpec().getConstexprSpecLoc(),
+ diag::err_concept_decl_invalid_specifiers)
+<< 0 << 3;
+NewVD->setInvalidDecl(true);
+  }
+}
   }
 
   // Set the lexical context. If the declarator has a C++ scope specifier, the
@@ -7497,6 +7515,30 @@
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
   // implicity defined to be a constexpr declaration (implicitly inline)
   NewFD->setImplicitlyInline();
+
+  // C++ Concepts TS [dcl.spec.concept]p2: A concept definition shall not
+  // be declared with the thread_local, inline, friend, or constexpr
+  // specifiers, [...]
+  if (isInline) {
+Diag(D.getDeclSpec().getInlineSpecLoc(),
+ diag::err_concept_decl_invalid_specifiers)
+<< 1 << 1;
+NewFD->setInvalidDecl(true);
+  }
+
+  if (isFriend) {
+Diag(D.getDeclSpec().getFriendSpecLoc(),
+ diag::err_concept_decl_invalid_specifiers)
+<< 1 << 2;
+NewFD->setInvalidDecl(true);
+  }
+
+  if (isConstexpr) {
+Diag(D.getDeclSpec().getConstexprSpecLoc(),
+ diag::err_concept_decl_invalid_specifiers)
+<< 1 << 3;
+NewFD->setInvalidDecl(true);
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1979,6 +1979,9 @@
   "variable concept declaration must be initialized">;
 def err_function_concept_exception_spec : Error<
   "function concept cannot have exception specification">;
+def err_concept_decl_invalid_specifiers : Error<
+  "%select{variable|function}0 concept cannot be declared "
+  "'%select{thread_local|inline|friend|constexpr}1'">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<


Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
@@ -0,0 +1,13 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template concept thread_local bool VCTL = true; // expected-error {{variable concept cannot be declared 'thread_local'}}
+
+template concept constexpr bool VCC = true; // expected-error {{variable concept cannot be declared 'constexpr'}}
+
+template concept inline bool FCI() { return true; } // expected-error {{function concept cannot be declared 'inline'}}
+
+struct

Re: [PATCH] D12462: [PATCH] [clang-tidy] Add inconsistent declaration parameter name check

2015-08-31 Thread Piotr Dziwinski via cfe-commits
piotrdz added a comment.

@alexfh: Thanks for reviewing my code. The amount of comments makes it pretty 
clear that it's my first contribution here :-). But no worries, I'll address 
each issue.

> This check seems pretty similar to the check implemented in 
> clang-tidy/readability/NamedParameterCheck.h/.cpp. Having both doesn't make 
> much sense, so one of them will have to die (probably, the other one). 
> Nothing should be done to this effect now, we'll figure out after this check 
> is polished enough.


Ah, I only now noticed it. It's kind of "opposite" to my check - it checks for 
unnamed parameters that should have their names in comments, while my check 
completely ignores unnamed parameters and checks the named ones. Anyways, I 
agree, that it would be good to merge them and have one check do both things.


http://reviews.llvm.org/D12462



___
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-31 Thread Beren Minor via cfe-commits
berenm added a comment.

Sure, no worries.


http://reviews.llvm.org/D12407



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


r246455 - [CUDA] fix codegen for __nvvm_atom_min/max_gen_u*

2015-08-31 Thread Jingyue Wu via cfe-commits
Author: jingyue
Date: Mon Aug 31 12:25:51 2015
New Revision: 246455

URL: http://llvm.org/viewvc/llvm-project?rev=246455&view=rev
Log:
[CUDA] fix codegen for __nvvm_atom_min/max_gen_u*

Summary: Clang should emit "atomicrmw umin/umax" instead of "atomicrmw min/max".

Reviewers: eliben, tra

Subscribers: llvm-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins-nvptx.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=246455&r1=246454&r2=246455&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Aug 31 12:25:51 2015
@@ -6985,18 +6985,22 @@ Value *CodeGenFunction::EmitNVPTXBuiltin
   case NVPTX::BI__nvvm_atom_max_gen_i:
   case NVPTX::BI__nvvm_atom_max_gen_l:
   case NVPTX::BI__nvvm_atom_max_gen_ll:
+return MakeBinaryAtomicValue(*this, llvm::AtomicRMWInst::Max, E);
+
   case NVPTX::BI__nvvm_atom_max_gen_ui:
   case NVPTX::BI__nvvm_atom_max_gen_ul:
   case NVPTX::BI__nvvm_atom_max_gen_ull:
-return MakeBinaryAtomicValue(*this, llvm::AtomicRMWInst::Max, E);
+return MakeBinaryAtomicValue(*this, llvm::AtomicRMWInst::UMax, E);
 
   case NVPTX::BI__nvvm_atom_min_gen_i:
   case NVPTX::BI__nvvm_atom_min_gen_l:
   case NVPTX::BI__nvvm_atom_min_gen_ll:
+return MakeBinaryAtomicValue(*this, llvm::AtomicRMWInst::Min, E);
+
   case NVPTX::BI__nvvm_atom_min_gen_ui:
   case NVPTX::BI__nvvm_atom_min_gen_ul:
   case NVPTX::BI__nvvm_atom_min_gen_ull:
-return MakeBinaryAtomicValue(*this, llvm::AtomicRMWInst::Min, E);
+return MakeBinaryAtomicValue(*this, llvm::AtomicRMWInst::UMin, E);
 
   case NVPTX::BI__nvvm_atom_cas_gen_i:
   case NVPTX::BI__nvvm_atom_cas_gen_l:

Modified: cfe/trunk/test/CodeGen/builtins-nvptx.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-nvptx.c?rev=246455&r1=246454&r2=246455&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-nvptx.c (original)
+++ cfe/trunk/test/CodeGen/builtins-nvptx.c Mon Aug 31 12:25:51 2015
@@ -234,30 +234,30 @@ __device__ void nvvm_atom(float *fp, flo
   // CHECK: atomicrmw xchg
   __nvvm_atom_xchg_gen_ll(&sll, ll);
 
-  // CHECK: atomicrmw max
+  // CHECK: atomicrmw max i32*
   __nvvm_atom_max_gen_i(ip, i);
-  // CHECK: atomicrmw max
+  // CHECK: atomicrmw umax i32*
   __nvvm_atom_max_gen_ui((unsigned int *)ip, i);
   // CHECK: atomicrmw max
   __nvvm_atom_max_gen_l(&dl, l);
-  // CHECK: atomicrmw max
+  // CHECK: atomicrmw umax
   __nvvm_atom_max_gen_ul((unsigned long *)&dl, l);
-  // CHECK: atomicrmw max
+  // CHECK: atomicrmw max i64*
   __nvvm_atom_max_gen_ll(&sll, ll);
-  // CHECK: atomicrmw max
+  // CHECK: atomicrmw umax i64*
   __nvvm_atom_max_gen_ull((unsigned long long *)&sll, ll);
 
-  // CHECK: atomicrmw min
+  // CHECK: atomicrmw min i32*
   __nvvm_atom_min_gen_i(ip, i);
-  // CHECK: atomicrmw min
+  // CHECK: atomicrmw umin i32*
   __nvvm_atom_min_gen_ui((unsigned int *)ip, i);
   // CHECK: atomicrmw min
   __nvvm_atom_min_gen_l(&dl, l);
-  // CHECK: atomicrmw min
+  // CHECK: atomicrmw umin
   __nvvm_atom_min_gen_ul((unsigned long *)&dl, l);
-  // CHECK: atomicrmw min
+  // CHECK: atomicrmw min i64*
   __nvvm_atom_min_gen_ll(&sll, ll);
-  // CHECK: atomicrmw min
+  // CHECK: atomicrmw umin i64*
   __nvvm_atom_min_gen_ull((unsigned long long *)&sll, ll);
 
   // CHECK: cmpxchg


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


Re: [PATCH][Solaris] Clang/Driver, stop hardcoding GCC paths in crt/ld.so lookup

2015-08-31 Thread Xan López via cfe-commits
Oops, missed this. Here is the updated patch.

And yes please, commit the patch for me.

Cheers,

Xan

On Mon, Aug 31, 2015 at 01:07:35PM -0400, Rafael Espíndola wrote:
> Do you have a version with the last suggestions? I lgtmed it conditional on
> it.   Do you need someone to commit it for you?
> On Aug 23, 2015 7:07 PM, "Rafael Espíndola" 
> wrote:
> 
> > SolarisScanLibDirForGCCTriple should start with a lower case. Starting
> > it with "scan" would probably also be more in line with the code
> > style.
> >
> > LGTM
> >
> > On 11 August 2015 at 16:33, Xan López  wrote:
> > > Hi,
> > >
> > > thanks for the review, I was not even aware that this could be
> > > tested. Adding a test helped to fix me a couple extra issues (plus the
> > > one you already mentioned). New patch attached.
> > >
> > > Xan
> > >
> > > On Wed, Aug 05, 2015 at 09:14:30AM -0400, Rafael Espíndola wrote:
> > >> Please git-clang-format this patch.
> > >>
> > >> +  // /usr/gcc/./lib/gcc/../,
> > >>
> > >> The code appends a triple after the "/lib/gcc". Is the comment missing
> > it?
> > >>
> > >> The inner loop has no version comparison. Are you depending on the
> > >> directory iteration order?
> > >>
> > >> Can you add a testcase?
> > >>
> > >>
> > >> On 28 July 2015 at 12:35, Xan López  wrote:
> > >> > Here it is.
> > >> >
> > >> > On Tue, Jul 28, 2015 at 01:21:06PM +0200, Xan López wrote:
> > >> >> On Tue, Jul 28, 2015 at 01:55:23PM +0300, Yaron Keren wrote:
> > >> >> > +cfe-commits
> > >> >> >
> > >> >> > This is a very large Solaris special case in
> > ScanLibDirForGCCTriple which
> > >> >> > shares almost no code with the function.
> > >> >> > How about splitting it out to a helper function or
> > >> >> > making ScanLibDirForGCCTriple virtual and overriding on Solaris?
> > >> >>
> > >> >> Yep, at least a helper function makes sense, you are right. I'll send
> > >> >> another patch with either of those suggestions later today.
> > >> >>
> > >> >>
> > >> >> Xan
> > >> >> ___
> > >> >> llvm-commits mailing list
> > >> >> llvm-comm...@cs.uiuc.edu
> > >> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> > >> >
> > >> > ___
> > >> > llvm-commits mailing list
> > >> > llvm-comm...@cs.uiuc.edu
> > >> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> > >> >
> >
>From 750f40d3ae1c00e9eea1f44c5f0d4c32dd21d659 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Xan=20L=C3=B3pez?= 
Date: Fri, 24 Jul 2015 19:17:51 +0200
Subject: [PATCH 1/4] [Solaris] Stop hardcoding the location of the c runtime
 files

This refactors the GCC installation detection to work properly on
Solaris (which is a bit of a special case compared to Linux
distributions), and adds the proper /usr/lib/... logic in the
Driver. That way we can just use ToolChain::GetFilePath to locate all
crt*.o files instead of hardcoding their location.
---
 lib/Driver/ToolChains.cpp  | 106 +++--
 lib/Driver/ToolChains.h|   6 ++
 lib/Driver/Tools.cpp   |  54 ---
 .../4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crt1.o |   0
 .../lib/gcc/sparc-sun-solaris2.11/4.8.2/crtbegin.o |   0
 .../lib/gcc/sparc-sun-solaris2.11/4.8.2/crtend.o   |   0
 .../Inputs/sparc-sun-solaris2.11/usr/lib/crti.o|   0
 .../Inputs/sparc-sun-solaris2.11/usr/lib/crtn.o|   0
 .../Inputs/sparc-sun-solaris2.11/usr/lib/ld.so.1   |   0
 test/Driver/solaris-ld.c   |  16 
 10 files changed, 139 insertions(+), 43 deletions(-)
 create mode 100644 
test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crt1.o
 create mode 100644 
test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtbegin.o
 create mode 100644 
test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtend.o
 create mode 100644 test/Driver/Inputs/sparc-sun-solaris2.11/usr/lib/crti.o
 create mode 100644 test/Driver/Inputs/sparc-sun-solaris2.11/usr/lib/crtn.o
 create mode 100644 test/Driver/Inputs/sparc-sun-solaris2.11/usr/lib/ld.so.1
 create mode 100644 test/Driver/solaris-ld.c

diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 54201aa..a703a92 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -1340,9 +1340,21 @@ bool 
Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const {
   "s390x-linux-gnu", "s390x-unknown-linux-gnu", "s390x-ibm-linux-gnu",
   "s390x-suse-linux", "s390x-redhat-linux"};
 
+  // Solaris.
+  static const char *const SolarisSPARCLibDirs[] = {"/gcc"};
+  static const char *const SolarisSPARCTriples[] = {"sparc-sun-solaris2.11",
+"i386-pc-solaris2.11"};
+
   using std::begin;
   using std::end;
 
+  if (TargetTriple.getOS() == llvm::Triple::Solaris) {
+LibDirs.append(begin(SolarisSPARCLibDirs)

r246468 - Pull the target attribute parsing out of CGCall and onto TargetInfo.

2015-08-31 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Mon Aug 31 13:39:22 2015
New Revision: 246468

URL: http://llvm.org/viewvc/llvm-project?rev=246468&view=rev
Log:
Pull the target attribute parsing out of CGCall and onto TargetInfo.

Also:
  - Add a typedef to make working with the result easier.
  - Update callers to use the new function.
  - Make initFeatureMap out of line.

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

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=246468&r1=246467&r2=246468&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Mon Aug 31 13:39:22 2015
@@ -15,7 +15,9 @@
 #ifndef LLVM_CLANG_BASIC_TARGETINFO_H
 #define LLVM_CLANG_BASIC_TARGETINFO_H
 
+#include "clang/AST/Attr.h"
 #include "clang/Basic/AddressSpaces.h"
+#include "clang/Basic/Attributes.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Basic/TargetCXXABI.h"
@@ -740,21 +742,18 @@ public:
   /// language options which change the target configuration.
   virtual void adjust(const LangOptions &Opts);
 
+  /// \brief Parse a __target__ attribute and get the cpu/feature strings
+  /// out of it for later use.
+  typedef std::pair> ParsedTargetAttr;
+  ParsedTargetAttr parseTargetAttr(const TargetAttr *TA) const;
+
   /// \brief Initialize the map with the default set of target features for the
   /// CPU this should include all legal feature strings on the target.
   ///
   /// \return False on error (invalid features).
   virtual bool initFeatureMap(llvm::StringMap &Features,
   DiagnosticsEngine &Diags, StringRef CPU,
-  std::vector &FeatureVec) const {
-for (const auto &F : FeatureVec) {
-  const char *Name = F.c_str();
-  // Apply the feature via the target.
-  bool Enabled = Name[0] == '+';
-  setFeatureEnabled(Features, Name + 1, Enabled);
-}
-return true;
-  }
+  std::vector &FeatureVec) const;
 
   /// \brief Get the ABI currently in use.
   virtual StringRef getABI() const { return StringRef(); }

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=246468&r1=246467&r2=246468&view=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Mon Aug 31 13:39:22 2015
@@ -650,3 +650,50 @@ bool TargetInfo::validateInputConstraint
 
   return true;
 }
+
+bool TargetInfo::initFeatureMap(llvm::StringMap &Features,
+DiagnosticsEngine &Diags, StringRef CPU,
+std::vector &FeatureVec) const {
+  for (const auto &F : FeatureVec) {
+const char *Name = F.c_str();
+// Apply the feature via the target.
+bool Enabled = Name[0] == '+';
+setFeatureEnabled(Features, Name + 1, Enabled);
+  }
+  return true;
+}
+
+TargetInfo::ParsedTargetAttr
+TargetInfo::parseTargetAttr(const TargetAttr *TA) const {
+  std::pair> RetPair;
+
+  // Grab the target attribute string.
+  StringRef FeaturesStr = TA->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="))
+  RetPair.first = 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("no-"))
+  RetPair.second.push_back("-" + Feature.split("-").second.str());
+else
+  RetPair.second.push_back("+" + Feature.str());
+  }
+  return RetPair;
+}

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=246468&r1=246467&r2=246468&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Aug 31 13:39:22 2015
@@ -1499,45 +1499,19 @@ void CodeGenModule::ConstructAttributeLi
 const FunctionDecl *FD = dyn_cast_or_null(Tar

r246467 - Pull out the ppc incompatible features check into a separate function.

2015-08-31 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Mon Aug 31 13:39:16 2015
New Revision: 246467

URL: http://llvm.org/viewvc/llvm-project?rev=246467&view=rev
Log:
Pull out the ppc incompatible features check into a separate function.

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=246467&r1=246466&r2=246467&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Aug 31 13:39:16 2015
@@ -1226,9 +1226,36 @@ void PPCTargetInfo::getTargetDefines(con
   //   __NO_FPRS__
 }
 
-bool PPCTargetInfo::initFeatureMap(
-llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU,
-std::vector &FeaturesVec) 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
+// go ahead and error since the customer has expressed a somewhat incompatible
+// set of options.
+static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags,
+ std::vector &FeaturesVec) {
+
+  if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "-vsx") !=
+  FeaturesVec.end()) {
+if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+power8-vector") !=
+FeaturesVec.end()) {
+  Diags.Report(diag::err_opt_not_valid_with_opt) << "-mpower8-vector"
+ << "-mno-vsx";
+  return false;
+}
+
+if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+direct-move") !=
+FeaturesVec.end()) {
+  Diags.Report(diag::err_opt_not_valid_with_opt) << "-mdirect-move"
+ << "-mno-vsx";
+  return false;
+}
+  }
+
+  return true;
+}
+
+bool PPCTargetInfo::initFeatureMap(llvm::StringMap &Features,
+   DiagnosticsEngine &Diags, StringRef CPU,
+   std::vector &FeaturesVec) 
const {
   Features["altivec"] = llvm::StringSwitch(CPU)
 .Case("7400", true)
 .Case("g4", true)
@@ -1272,26 +1299,9 @@ bool PPCTargetInfo::initFeatureMap(
 .Case("pwr7", true)
 .Default(false);
 
-  // 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
-  // go ahead and error since the customer has expressed a somewhat 
incompatible
-  // set of options.
-  if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "-vsx") !=
-  FeaturesVec.end()) {
-if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+power8-vector") !=
-FeaturesVec.end()) {
-  Diags.Report(diag::err_opt_not_valid_with_opt) << "-mpower8-vector"
- << "-mno-vsx";
-  return false;
-}
+  if (!ppcUserFeaturesCheck(Diags, FeaturesVec))
+return false;
 
-if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+direct-move") !=
-FeaturesVec.end()) {
-  Diags.Report(diag::err_opt_not_valid_with_opt) << "-mdirect-move"
- << "-mno-vsx";
-  return false;
-}
-  }
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
 }
 
@@ -2492,7 +2502,6 @@ bool X86TargetInfo::initFeatureMap(
 llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU,
 std::vector &FeaturesVec) const {
   // FIXME: This *really* should not be here.
-
   // X86_64 always has SSE2.
   if (getTriple().getArch() == llvm::Triple::x86_64)
 setFeatureEnabledImpl(Features, "sse2", true);
@@ -5830,8 +5839,8 @@ public:
 return CPUKnown;
   }
   bool initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine 
&Diags,
-StringRef CPU,
-std::vector &FeaturesVec) const override {
+  StringRef CPU,
+  std::vector &FeaturesVec) const override {
 if (CPU == "zEC12")
   Features["transactional-execution"] = true;
 if (CPU == "z13") {
@@ -6200,8 +6209,8 @@ public:
   }
   const std::string& getCPU() const { return CPU; }
   bool initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine 
&Diags,
-StringRef CPU,
-std::vector &FeaturesVec) const override {
+  StringRef CPU,
+  std::vector &FeaturesVec) const override {
 if (CPU == "octeon")
   Features["mips64r2"] = Features["cnmips"] = true;
 else


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


r246469 - [MS ABI] Correctly mangle classes without names for linkage purposes

2015-08-31 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Aug 31 13:48:39 2015
New Revision: 246469

URL: http://llvm.org/viewvc/llvm-project?rev=246469&view=rev
Log:
[MS ABI] Correctly mangle classes without names for linkage purposes

A class without a name for linkage purposes gets a name along the lines
of  where foo is either the name of a declarator which
defined it (like a variable or field) or a
typedef-name (like a typedef or alias-declaration).

We handled the declarator case correctly but it would fall down during
template instantiation if the declarator didn't share the tag's type.
We failed to handle the typedef-name case at all.

Instead, keep track of the association between the two and keep it up to
date in the face of template instantiation.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/CXXABI.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/ItaniumCXXABI.cpp
cfe/trunk/lib/AST/MicrosoftCXXABI.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=246469&r1=246468&r2=246469&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Aug 31 13:48:39 2015
@@ -2311,6 +2311,14 @@ public:
   Expr *getDefaultArgExprForConstructor(const CXXConstructorDecl *CD,
 unsigned ParmIdx);
 
+  void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND);
+
+  TypedefNameDecl *getTypedefNameForUnnamedTagDecl(const TagDecl *TD);
+
+  void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD);
+
+  DeclaratorDecl *getDeclaratorForUnnamedTagDecl(const TagDecl *TD);
+
   void setManglingNumber(const NamedDecl *ND, unsigned Number);
   unsigned getManglingNumber(const NamedDecl *ND) const;
 

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=246469&r1=246468&r2=246469&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Aug 31 13:48:39 2015
@@ -2778,12 +2778,12 @@ private:
   /// declaration specifier for variables, it points to the first VarDecl (used
   /// for mangling);
   /// otherwise, it is a null (TypedefNameDecl) pointer.
-  llvm::PointerUnion NamedDeclOrQualifier;
+  llvm::PointerUnion TypedefNameDeclOrQualifier;
 
-  bool hasExtInfo() const { return NamedDeclOrQualifier.is(); }
-  ExtInfo *getExtInfo() { return NamedDeclOrQualifier.get(); }
+  bool hasExtInfo() const { return TypedefNameDeclOrQualifier.is(); 
}
+  ExtInfo *getExtInfo() { return TypedefNameDeclOrQualifier.get(); }
   const ExtInfo *getExtInfo() const {
-return NamedDeclOrQualifier.get();
+return TypedefNameDeclOrQualifier.get();
   }
 
 protected:
@@ -2794,7 +2794,7 @@ protected:
 TagDeclKind(TK), IsCompleteDefinition(false), IsBeingDefined(false),
 IsEmbeddedInDeclarator(false), IsFreeStanding(false),
 IsCompleteDefinitionRequired(false),
-NamedDeclOrQualifier((NamedDecl *)nullptr) {
+TypedefNameDeclOrQualifier((TypedefNameDecl *)nullptr) {
 assert((DK != Enum || TK == TTK_Enum) &&
"EnumDecl not matched with TTK_Enum");
 setPreviousDecl(PrevDecl);
@@ -2941,22 +2941,11 @@ public:
 return (getDeclName() || getTypedefNameForAnonDecl());
   }
 
-  bool hasDeclaratorForAnonDecl() const {
-return dyn_cast_or_null(
-NamedDeclOrQualifier.get());
-  }
-  DeclaratorDecl *getDeclaratorForAnonDecl() const {
-return hasExtInfo() ? nullptr : dyn_cast_or_null(
-  NamedDeclOrQualifier.get());
-  }
-
   TypedefNameDecl *getTypedefNameForAnonDecl() const {
-return hasExtInfo() ? nullptr : dyn_cast_or_null(
-  NamedDeclOrQualifier.get());
+return hasExtInfo() ? nullptr
+: TypedefNameDeclOrQualifier.get();
   }
 
-  void setDeclaratorForAnonDecl(DeclaratorDecl *DD) { NamedDeclOrQualifier = 
DD; }
-
   void setTypedefNameForAnonDecl(TypedefNameDecl *TDD);
 
   /// \brief Retrieve the nested-name-specifier that qualifies the name of this

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=246469&r1=246468&r2=246469&view=diff
==
--- cfe/trunk/lib/A

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

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

In http://reviews.llvm.org/D12359#236334, @aaron.ballman wrote:

> I have concerns about this being a frontend warning. The true positive rate 
> seems rather high given the benign nature of the diagnostic, and the false 
> negative rate is quite high. This seems like it would make more sense as a 
> path-sensitive static analyzer warning instead of a frontend warning, as that 
> would justify the slightly high true positive rate, and rectify quite a bit 
> of the false negative rate.


I don't understand. The checker is path sensitive, isn't it? Do you see some 
problem that I don't?

It will warn if there is no write anywhere in the function. Except as I wrote, 
for some cases where #ifdef is used, but moving it to static analysis won't 
help.

> Have you tried running this over the Clang and LLVM code bases? How many 
> diagnostics does it produce?


Not yet. I'll do that.



Comment at: test/Sema/warn-nonconst-parameter.c:8
@@ +7,3 @@
+//
+// It does not warn about pointers to records or function pointers.
+

aaron.ballman wrote:
> How does it handle cases like:
> 
> void g(int);
> void f(volatile int *p) {
>   int j = *p; // Should not warn
>   int i = p[0]; // Should not warn
>   g(*p); // Should not warn
> }
> 
> void h(int *p) {
>   int i = p ? *p : 0; // Should warn
> }
> 
ok interesting. I have never seen a volatile pointer argument before. but 
technically I believe we should warn about f(). the function only reads p. 
maybe for stylistic reasons it would look weird to say that it's both volatile 
and const, is that why we should not warn?


http://reviews.llvm.org/D12359



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


Re: [PATCH] D8178: [libcxx] Fix PR22806 - Tuple incorrectly selects copy/move constructor when storing nested tuple-like types.

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

In http://reviews.llvm.org/D8178#236180, @EricWF wrote:

> I think this patch is actually pretty close to correct but thinking about 
> tuple hurts my brain.
>
> @mclow.lists can you start reviewing this when you have time.


@mclow.lists Nevermind I think I have a better fix to this.


http://reviews.llvm.org/D8178



___
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-31 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

Hi!

With this patch committed I noticed a regression in the static analyzer.

I analyzed openssl-1.0.0d (using the test suite in 
utils/analyzer/SATestBuild.py).
I got the following assertion error:
(lldb) bt

- thread #1: tid = 0xa1fcb, 0x7fff943e50ae 
libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', 
stop reason = signal SIGABRT
  - frame #0: 0x7fff943e50ae libsystem_kernel.dylib`__pthread_kill + 10 
frame #1: 0x7fff943f25fd libsystem_pthread.dylib`pthread_kill + 90 frame 
#2: 0x000100960106 clang`::abort() [inlined] raise(sig=6) + 18 at 
Signals.inc:504 frame #3: 0x0001009600f4 clang`::abort() + 4 at 
Signals.inc:521 frame #4: 0x0001009600e1 
clang`::__assert_rtn(func=, file=, 
line=, expr=) + 81 at Signals.inc:517 frame #5: 
0x0001018fc418 clang`(anonymous 
namespace)::CStringChecker::InvalidateBuffer(clang::ento::CheckerContext&, 
llvm::IntrusiveRefCntPtr, clang::Expr const*, 
clang::ento::SVal, bool, clang::Expr const*) [inlined] clang::ento::NonLoc 
clang::ento::SVal::castAs() const + 1448 at SVals.h:76 
frame #6: 0x0001018fc3f9 clang`(anonymous 
namespace)::CStringChecker::InvalidateBuffer(clang::ento::CheckerContext&, 
llvm::IntrusiveRefCntPtr, clang::Expr const*, 
clang::ento::SVal, bool, clang::Expr const*) [inlined] (anonymous 
namespace)::CStringChecker::IsFirstBufInBound(state=clang::ento::ProgramStateRef
 @ 0x000103bf2080, FirstBuf=0x000103a86768) at CStringChecker.cpp:842 
frame #7: 0x0001018fc3f9 clang`(anonymous 
namespace)::CStringChecker::InvalidateBuffer(C=, 
state=, E=0x000103a86768, V=, 
IsSourceBuffer=, Size=) + 1417 at 
CStringChecker.cpp:920 frame #8: 0x0001018fadf7 clang`(anonymous 
namespace)::CStringChecker::evalCopyCommon(this=0x000103212fb0, 
C=0x7fff5fbfc1a0, CE=, state=clang::ento::ProgramStateRef @ 
0x7fff5fbfc0c0, Size=0x000103a867b0, Dest=0x000103a86768, 
Source=, Restricted=, IsMempcpy=) const 
+ 3991 at CStringChecker.cpp:1079 frame #9: 0x0001018f8ad8 clang`(anonymous 
namespace)::CStringChecker::evalMemcpy(this=0x000103212fb0, 
C=0x7fff5fbfc1a0, CE=0x000103a86720) const + 248 at 
CStringChecker.cpp:1101 frame #10: 0x0001018f89b6 clang`bool 
clang::ento::eval::Call::_evalCall<(anonymous 
namespace)::CStringChecker>(void*, clang::CallExpr const*, 
clang::ento::CheckerContext&) [inlined] (anonymous 
namespace)::CStringChecker::evalCall(CE=0x000103a86720, 
C=0x7fff5fbfc1a0) const + 655 at CStringChecker.cpp:2002 frame #11: 
0x0001018f8727 clang`bool clang::ento::eval::Call::_evalCall<(anonymous 
namespace)::CStringChecker>(checker=0x000103212fb0, CE=0x000103a86720, 
C=0x7fff5fbfc1a0) + 23 at Checker.h:438 frame #12: 0x000101a0417d 
clang`clang::ento::CheckerManager::runCheckersForEvalCall(clang::ento::ExplodedNodeSet&,
 clang::ento::ExplodedNodeSet const&, clang::ento::CallEvent const&, 
clang::ento::ExprEngine&) [inlined] clang::ento::CheckerFn::operator(this=, 
ps=)(clang::CallExpr const*, clang::ento::CheckerContext&) const + 
653 at CheckerManager.h:58 frame #13: 0x000101a0416b 
clang`clang::ento::CheckerManager::runCheckersForEvalCall(this=0x000103211950,
 Dst=0x7fff5fbfc2d8, Src=, Call=0x000103ac2070, 
Eng=0x7fff5fbfcd90) + 635 at CheckerManager.cpp:549 frame #14: 
0x000101a361af 
clang`clang::ento::ExprEngine::evalCall(this=0x7fff5fbfcd90, 
Dst=0x7fff5fbfc448, Pred=, Call=0x000103ac2070) + 383 at 
ExprEngineCallAndReturn.cpp:527 frame #15: 0x000101a35ee0 
clang`clang::ento::ExprEngine::VisitCallExpr(this=0x7fff5fbfcd90, 
CE=0x000103a86720, Pred=, dst=0x7fff5fbfc9b8) + 528 at 
ExprEngineCallAndReturn.cpp:499 frame #16: 0x000101a1b4a0 
clang`clang::ento::ExprEngine::Visit(this=0x7fff5fbfcd90, 
S=0x000103a86720, Pred=, DstTop=) + 12224 at 
ExprEngine.cpp:1075 frame #17: 0x000101a16c30 
clang`clang::ento::ExprEngine::ProcessStmt(this=0x7fff5fbfcd90, 
S=, Pred=) + 880 at ExprEngine.cpp:446 frame #18: 
0x000101a1681e 
clang`clang::ento::ExprEngine::processCFGElement(this=, 
E=, Pred=0x000103bf1be0, StmtIdx=, 
Ctx=0x7fff5fbfcc98) + 190 at ExprEngine.cpp:295 frame #19: 
0x000101a0c128 
clang`clang::ento::CoreEngine::HandlePostStmt(this=, 
B=, StmtIdx=, Pred=) + 136 at 
CoreEngine.cpp:503 frame #20: 0x000101a0b71b 
clang`clang::ento::CoreEngine::ExecuteWorkList(this=0x7fff5fbfcda8, 
L=, Steps=15, InitState=clang::ento::ProgramStateRef @ 
0x7fff5fbfd120) + 491 at CoreEngine.cpp:223 frame #21: 0x0001012698a0 
clang`(anonymous namespace)::AnalysisConsumer::ActionExprEngine(clang::Decl*, 
bool, clang::ento::ExprEngine::InliningModes, llvm::DenseSet >*) [inlined] 
clang::ento::ExprEngine::ExecuteWorkList(L=0x0001032c84a0, 
Steps=) + 35 at ExprEngine.h:109 frame #22: 0x00010126987d 
clang`(anonymous 
namespace)::AnalysisConsumer::ActionExprEngine(this=0x000103211090, 
D=0x0001039b8418

r246473 - Stop hardcoding GCC paths in crt/ld.so lookup.

2015-08-31 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Mon Aug 31 14:17:51 2015
New Revision: 246473

URL: http://llvm.org/viewvc/llvm-project?rev=246473&view=rev
Log:
Stop hardcoding GCC paths in crt/ld.so lookup.

This patch refactors the code to use the GCC installation detector
(modified so that it works in Solaris), and uses
ToolChain::GetFilePath everywhere once it works.

Patch by Xan López !

Added:
cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/
cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/usr/
cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/
cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/
cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/
cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/

cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/

cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/

cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crt1.o

cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtbegin.o

cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtend.o
cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/usr/lib/
cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/usr/lib/crti.o
cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/usr/lib/crtn.o
cfe/trunk/test/Driver/Inputs/sparc-sun-solaris2.11/usr/lib/ld.so.1
cfe/trunk/test/Driver/solaris-ld.c
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=246473&r1=246472&r2=246473&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Aug 31 14:17:51 2015
@@ -1340,9 +1340,21 @@ bool Generic_GCC::GCCInstallationDetecto
   "s390x-linux-gnu", "s390x-unknown-linux-gnu", "s390x-ibm-linux-gnu",
   "s390x-suse-linux", "s390x-redhat-linux"};
 
+  // Solaris.
+  static const char *const SolarisSPARCLibDirs[] = {"/gcc"};
+  static const char *const SolarisSPARCTriples[] = {"sparc-sun-solaris2.11",
+"i386-pc-solaris2.11"};
+
   using std::begin;
   using std::end;
 
+  if (TargetTriple.getOS() == llvm::Triple::Solaris) {
+LibDirs.append(begin(SolarisSPARCLibDirs), end(SolarisSPARCLibDirs));
+TripleAliases.append(begin(SolarisSPARCTriples), end(SolarisSPARCTriples));
+
+return;
+  }
+
   switch (TargetTriple.getArch()) {
   case llvm::Triple::aarch64:
 LibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
@@ -1907,6 +1919,54 @@ static bool findBiarchMultilibs(const ll
   return true;
 }
 
+void Generic_GCC::GCCInstallationDetector::scanLibDirForGCCTripleSolaris(
+const llvm::Triple &TargetArch, const llvm::opt::ArgList &Args,
+const std::string &LibDir, StringRef CandidateTriple,
+bool NeedsBiarchSuffix) {
+  // Solaris is a special case. The GCC installation is under
+  // /usr/gcc/./lib/gcc//../, so we
+  // need to iterate twice.
+  std::error_code EC;
+  for (llvm::sys::fs::directory_iterator LI(LibDir, EC), LE; !EC && LI != LE;
+   LI = LI.increment(EC)) {
+StringRef VersionText = llvm::sys::path::filename(LI->path());
+GCCVersion CandidateVersion = GCCVersion::Parse(VersionText);
+
+if (CandidateVersion.Major != -1) // Filter obviously bad entries.
+  if (!CandidateGCCInstallPaths.insert(LI->path()).second)
+continue; // Saw this path before; no need to look at it again.
+if (CandidateVersion.isOlderThan(4, 1, 1))
+  continue;
+if (CandidateVersion <= Version)
+  continue;
+
+GCCInstallPath =
+LibDir + "/" + VersionText.str() + "/lib/gcc/" + CandidateTriple.str();
+if (!llvm::sys::fs::exists(GCCInstallPath))
+  continue;
+
+// If we make it here there has to be at least one GCC version, let's just
+// use the latest one.
+std::error_code EEC;
+for (llvm::sys::fs::directory_iterator LLI(GCCInstallPath, EEC), LLE;
+ !EEC && LLI != LLE; LLI = LLI.increment(EEC)) {
+
+  StringRef SubVersionText = llvm::sys::path::filename(LLI->path());
+  GCCVersion CandidateSubVersion = GCCVersion::Parse(SubVersionText);
+
+  if (CandidateSubVersion > Version)
+Version = CandidateSubVersion;
+}
+
+GCCTriple.setTriple(CandidateTriple);
+
+GCCInstallPath += "/" + Version.Text;
+GCCParentLibPath = GCCInstallPath + "/../../../../";
+
+IsValid = true;
+  }
+}
+
 void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
 const llvm::Triple &TargetTriple, const ArgList &Args,
 const

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

2015-08-31 Thread Aaron Ballman via cfe-commits
On Mon, Aug 31, 2015 at 2:58 PM, Daniel Marjamäki
 wrote:
> danielmarjamaki added a comment.
>
> In http://reviews.llvm.org/D12359#236334, @aaron.ballman wrote:
>
>> I have concerns about this being a frontend warning. The true positive rate 
>> seems rather high given the benign nature of the diagnostic, and the false 
>> negative rate is quite high. This seems like it would make more sense as a 
>> path-sensitive static analyzer warning instead of a frontend warning, as 
>> that would justify the slightly high true positive rate, and rectify quite a 
>> bit of the false negative rate.
>
>
> I don't understand. The checker is path sensitive, isn't it? Do you see some 
> problem that I don't?

The checker isn't currently path sensitive as it doesn't pay attention
to control flow graphs or how pointer values flow through a function
body. I suppose this is a matter of scope more than anything; I see a
logical extension of this functionality being with local variables as
well as parameters. So, for instance:

void f(int *p) {
  int *i = p;
  std::cout << *i;
}

I think code like the above should tell the user that both p and i can be const.

> It will warn if there is no write anywhere in the function. Except as I 
> wrote, for some cases where #ifdef is used, but moving it to static analysis 
> won't help.

This is true, for the current design of the patch, static analysis is
less useful because the path sensitivity doesn't matter. But that also
suggests if we wanted to add such a thing to the static analyzer
someday, we'd have two ways of getting the same information if we
stuck this in the frontend. It seems more logical to me to set this up
as a static analysis checker so that we can extend it to be path
sensitive under the same flag.

>
>> Have you tried running this over the Clang and LLVM code bases? How many 
>> diagnostics does it produce?
>
>
> Not yet. I'll do that.
>
>
> 
> Comment at: test/Sema/warn-nonconst-parameter.c:8
> @@ +7,3 @@
> +//
> +// It does not warn about pointers to records or function pointers.
> +
> 
> aaron.ballman wrote:
>> How does it handle cases like:
>>
>> void g(int);
>> void f(volatile int *p) {
>>   int j = *p; // Should not warn
>>   int i = p[0]; // Should not warn
>>   g(*p); // Should not warn
>> }
>>
>> void h(int *p) {
>>   int i = p ? *p : 0; // Should warn
>> }
>>
> ok interesting. I have never seen a volatile pointer argument before. but 
> technically I believe we should warn about f(). the function only reads p. 
> maybe for stylistic reasons it would look weird to say that it's both 
> volatile and const, is that why we should not warn?

I was thinking that we should not warn in those cases because volatile
values can be changed in ways unknown to the implementation. But now
that I'm a bit more awake, I'm not as convinced of that as I
previously was. I'm not certain that const plays into that.

Btw, since I forgot to mention it before, I think this is a great idea
in general, thank you for working on it! :-)

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


Re: [PATCH] D11815: Pass subtarget feature "force-align-stack"

2015-08-31 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

In http://reviews.llvm.org/D11815#236368, @vkalintiris wrote:

> In http://reviews.llvm.org/D11815#235394, @ahatanak wrote:
>
> > The cc1 option "-mstackrealign" now means "force stack realignment" rather 
> > than "allow stack realignment" and causes function attribute "stackrealign" 
> > to be attached to the functions in the IR.
>
>
> Please, correct me if I'm wrong but I believe that the -force-align-stack 
> option. which was removed in http://reviews.llvm.org/D11814, was x86-specific 
> (in the sense that it was only really tested in X86) and almost always 
> accompanied by a -stack-alignment value that was equal or greater than the 
> requirements of the ABI.
>
> With this change the -mstackrealign option will attach the "stackrealign" 
> attribute on every function definition (and declaration) without specifying a 
> valid -stack-alignment value.


-force-align-stack used to be an x86 option but has been a target independent 
option since r242727 (see the discussion in http://reviews.llvm.org/D11160). 
The purpose of this patch is to make sure -mstackrealign works when doing LTO. 
It is not intended to change the way -mstackrealign is handled by clang and 
llvm (except that -mno-stackrealign has a different meaning now).

> I suspect that this option will be broken for every Target that relies only 
> on the maximum alignment provided by MachineFrameInfo (see 
> X86FrameLowering::calculateMaxStackAlign() for the correct way to handle 
> this).

> 

> Is this the intended behaviour here? I'm a little bit cautious because this 
> option would be exposed from the Clang frontend and our users would generate 
> bad code if they were to try this option.


I'm not sure if this is the intended behavior, but it looks like it deviates 
from gcc's -mstackrealign.

> For example, on a Mips target, where the O32 ABI requires either way an 
> 8-byte alignment, we would generate redundant code for realigning the stack 
> to a 4-byte alignment if a function contains objects with maximum alignment 
> of 4-bytes (see attached files to get an idea).


According to the link below, originally -mstackrealign was used to keep the 
stack aligned to 16-bytes when there was a possibility that the calling 
function's stack was only 4-byte aligned. For mips, I don't know what the right 
thing to do is, but its seems pointless to align the stack to 4-bytes when the 
default alignment is 8-byte.

https://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/i386-and-x86_002d64-Options.html

> F803573: main.s 

> 

> F803574: main.c 

> 

> F803575: main.ll 



http://reviews.llvm.org/D11815



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


Re: [PATCH] D12002: Initial WebAssembly support in clang

2015-08-31 Thread Dan Gohman via cfe-commits
sunfish updated this revision to Diff 33611.
sunfish marked 2 inline comments as done.
sunfish added a comment.
Herald added a subscriber: dschuff.

Minor updates to keep the patch building and working as code changes around it. 
Also enabled -mthread-model.


Repository:
  rL LLVM

http://reviews.llvm.org/D12002

Files:
  include/clang/Basic/BuiltinsWebAssembly.def
  include/clang/Basic/TargetBuiltins.h
  include/clang/Basic/TargetCXXABI.h
  include/clang/Driver/Options.td
  include/clang/module.modulemap
  lib/AST/ASTContext.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/CodeGen/align-wasm.c
  test/CodeGen/builtins-wasm.c
  test/CodeGen/target-data.c
  test/CodeGen/wasm-arguments.c
  test/CodeGen/wasm-regparm.c
  test/CodeGenCXX/constructor-destructor-return-this.cpp
  test/CodeGenCXX/member-alignment.cpp
  test/CodeGenCXX/member-function-pointers.cpp
  test/CodeGenCXX/static-init-wasm.cpp
  test/CodeGenCXX/wasm-args-returns.cpp
  test/Driver/thread-model.c
  test/Driver/wasm32-unknown-unknown.cpp
  test/Driver/wasm64-unknown-unknown.cpp
  test/Preprocessor/init.c
  test/Preprocessor/wasm-target-features.c

Index: test/Preprocessor/wasm-target-features.c
===
--- test/Preprocessor/wasm-target-features.c
+++ test/Preprocessor/wasm-target-features.c
@@ -0,0 +1,35 @@
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -msimd128 \
+// RUN:   | FileCheck %s -check-prefix=SIMD128
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -msimd128 \
+// RUN:   | FileCheck %s -check-prefix=SIMD128
+//
+// SIMD128:#define __wasm_simd128__ 1{{$}}
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mcpu=mvp \
+// RUN:   | FileCheck %s -check-prefix=MVP
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mcpu=mvp \
+// RUN:   | FileCheck %s -check-prefix=MVP
+//
+// MVP-NOT:#define __wasm_simd128__
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mcpu=bleeding-edge \
+// RUN:   | FileCheck %s -check-prefix=BLEEDING_EDGE
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mcpu=bleeding-edge \
+// RUN:   | FileCheck %s -check-prefix=BLEEDING_EDGE
+//
+// BLEEDING_EDGE:#define __wasm_simd128__ 1{{$}}
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mcpu=bleeding-edge -mno-simd128 \
+// RUN:   | FileCheck %s -check-prefix=BLEEDING_EDGE_NO_SIMD128
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mcpu=bleeding-edge -mno-simd128 \
+// RUN:   | FileCheck %s -check-prefix=BLEEDING_EDGE_NO_SIMD128
+//
+// BLEEDING_EDGE_NO_SIMD128-NOT:#define __wasm_simd128__
Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8419,3 +8419,635 @@
 // XCORE:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
 // XCORE:#define __LITTLE_ENDIAN__ 1
 // XCORE:#define __XS1B__ 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=wasm32-unknown-unknown \
+// RUN:   < /dev/null \
+// RUN:   | FileCheck -check-prefix=WEBASSEMBLY32 %s
+//
+// WEBASSEMBLY32:#define _ILP32 1{{$}}
+// WEBASSEMBLY32-NOT:#define _LP64
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_ACQUIRE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_ACQ_REL 4{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_CONSUME 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_RELAXED 0{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_RELEASE 3{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_SEQ_CST 5{{$}}
+// WEBASSEMBLY32-NEXT:#define __BIGGEST_ALIGNMENT__ 16{{$}}
+// WEBASSEMBLY32-NEXT:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__{{$}}
+// WEBASSEMBLY32-NEXT:#define __CHAR16_TYPE__ unsigned short{{$}}
+// WEBASSEMBLY32-NEXT:#define __CHAR32_TYPE__ unsigned int{{$}}
+// WEBASSEMBLY32-NEXT:#define __CHAR_BIT__ 8{{$}}
+// WEBASSEMBLY32-NOT:#define __CHAR_UNSIGNED__
+// WEBASSEMBLY32-NEXT:#define __CONSTANT_CFSTRINGS__ 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_DECIMAL_DIG__ 17{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_DIG__ 15{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_EPSILON__ 2.2204460492503131e-16{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_HAS_DENORM__ 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_HAS_INFINITY__ 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_HAS_QUIET_NAN__ 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_MANT_DIG__ 53{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_MAX_10_EXP__ 308{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_MAX_EXP__ 1024{{$}}
+// WEBAS

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

2015-08-31 Thread inż . Piotr Zegar via cfe-commits
I also got crash with this commit:

0x00f52d4b in (anonymous
namespace)::CStringChecker::InvalidateBuffer(clang::ento::CheckerContext&,
llvm::IntrusiveRefCntPtr, clang::Expr
const*, clang::ento::SVal, bool, clang::Expr const*) () at
llvm/tools/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:859
859   const MemRegion *R = BufEnd.getAsRegion();


#0  0x00f52d4b in (anonymous
namespace)::CStringChecker::InvalidateBuffer(clang::ento::CheckerContext&,
llvm::IntrusiveRefCntPtr, clang::Expr
const*, clang::ento::SVal, bool, clang::Expr const*) () at
llvm/tools/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:859
#1  0x00f54a52 in (anonymous
namespace)::CStringChecker::evalCopyCommon(clang::ento::CheckerContext&,
clang::CallExpr const*, llvm::IntrusiveRefCntPtr, clang::Expr const*, clang::Expr const*, clang::Expr const*, bool,
bool) const ()
at llvm/tools/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1079
#2  0x00f559fc in (anonymous
namespace)::CStringChecker::evalMemcpy(clang::ento::CheckerContext&,
clang::CallExpr const*) const ()
at llvm/tools/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1101
#3  0x00f51e5d in bool
clang::ento::eval::Call::_evalCall<(anonymous
namespace)::CStringChecker>(void*, clang::CallExpr const*,
clang::ento::CheckerContext&) ()
at llvm/tools/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2002
#4  0x00fae631 in
clang::ento::CheckerManager::runCheckersForEvalCall(clang::ento::ExplodedNodeSet&,
clang::ento::ExplodedNodeSet const&, clang::ento::CallEvent const&,
clang::ento::ExprEngine&) () at
llvm/tools/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h:58
#5  0x00fe40de in
clang::ento::ExprEngine::evalCall(clang::ento::ExplodedNodeSet&,
clang::ento::ExplodedNode*, clang::ento::CallEvent const&) ()
at
llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp:528
#6  0x00fe43ec in
clang::ento::ExprEngine::VisitCallExpr(clang::CallExpr const*,
clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) ()
at
llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp:499
#7  0x00fd4c96 in clang::ento::ExprEngine::Visit(clang::Stmt
const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) ()
at llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:1075
#8  0x00fd6726 in
clang::ento::ExprEngine::ProcessStmt(clang::CFGStmt,
clang::ento::ExplodedNode*) ()
at llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:446
#9  0x00fd6f24 in
clang::ento::ExprEngine::processCFGElement(clang::CFGElement,
clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*)
()
at llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:295
#10 0x00fb746e in
clang::ento::CoreEngine::HandlePostStmt(clang::CFGBlock const*, unsigned
int, clang::ento::ExplodedNode*) ()
at llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:503
#11 0x00fb7607 in
clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*,
clang::ProgramPoint, clang::ento::WorkListUnit const&) ()
at llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:267
#12 0x00fb7708 in
clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*,
unsigned int, llvm::IntrusiveRefCntPtr) ()
#13 0x007d4bd1 in (anonymous
namespace)::AnalysisConsumer::ActionExprEngine ()
#14 0x007d5343 in (anonymous
namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int,
clang::ento::ExprEngine::InliningModes, llvm::DenseSet >*) ()
#15 0x007e021d in (anonymous
namespace)::AnalysisConsumer::HandleTranslationUnit ()
#16 0x0082daa8 in
clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) ()
at llvm/tools/clang/lib/Frontend/MultiplexConsumer.cpp:296
#17 0x008be045 in clang::ParseAST(clang::Sema&, bool, bool) () at
llvm/tools/clang/lib/Parse/ParseAST.cpp:168
#18 0x00812e36 in clang::FrontendAction::Execute() ()
#19 0x007eda8f in
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) ()
#20 0x007ab25c in
clang::tooling::FrontendActionFactory::runInvocation(clang::CompilerInvocation*,
clang::FileManager*, std::shared_ptr,
clang::DiagnosticConsumer*) () at
llvm/tools/clang/lib/Tooling/Tooling.cpp:274
#21 0x007a8861 in
clang::tooling::ToolInvocation::runInvocation(char const*,
clang::driver::Compilation*, clang::CompilerInvocation*,
std::shared_ptr) () at
llvm/tools/clang/lib/Tooling/Tooling.cpp:250
#22 0x007a9e24 in clang::tooling::ToolInvocation::run() () at
llvm/tools/clang/lib/Tooling/Tooling.cpp:235
#23 0x007aa7d2 in
clang::tooling::ClangTool::run(clang::tooling::ToolAction*) () at
llvm/tools/clang/lib/Tooling/Tooling.cpp:369
#24 0x0067a650 in
clang::tidy::runClangTidy(std::unique_ptr >,
clang::tooling::CompilationDatabase const&, llvm::ArrayRef,
std::vector >*, clang::tidy::ProfileData*)
() at llvm/tools

Re: [PATCH] D12002: Initial WebAssembly support in clang

2015-08-31 Thread Eric Christopher via cfe-commits
echristo added a subscriber: echristo.
echristo added a comment.

Some inline comments.

Thanks!

-eric



Comment at: include/clang/Basic/TargetCXXABI.h:166
@@ -148,1 +165,3 @@
 
+  /// \brief Are member functions differently aligned?
+  bool areMemberFunctionsAligned() const {

Can you elaborate on the comment here as to what the alignment here means or 
something? It looks incomplete otherwise.


Comment at: lib/Basic/Targets.cpp:6935-6941
@@ +6934,9 @@
+  if (Feature == "+simd128") {
+SIMDLevel = std::max(SIMDLevel, SIMD128);
+continue;
+  }
+  if (Feature == "-simd128") {
+SIMDLevel = std::min(SIMDLevel, SIMDEnum(SIMD128 - 1));
+continue;
+  }
+

Might make sense to copy the x86 bits here?


Comment at: lib/Basic/Targets.cpp:7633-7658
@@ -7464,1 +7632,28 @@
   }
+  case llvm::Triple::wasm32: {
+// Until specific variations are defined, don't permit any.
+if (Triple.getSubArch() != llvm::Triple::NoSubArch ||
+Triple.getVendor() != llvm::Triple::UnknownVendor ||
+Triple.getOS() != llvm::Triple::UnknownOS ||
+Triple.getEnvironment() != llvm::Triple::UnknownEnvironment ||
+Triple.getObjectFormat() != llvm::Triple::UnknownObjectFormat ||
+(!Triple.getVendorName().empty() &&
+ Triple.getVendorName() != "unknown") ||
+(!Triple.getOSName().empty() && Triple.getOSName() != "unknown") ||
+(Triple.hasEnvironment() && Triple.getEnvironmentName() != "unknown"))
+  return nullptr;
+return new WebAssemblyOSTargetInfo(Triple);
+  }
+  case llvm::Triple::wasm64: {
+// Until specific variations are defined, don't permit any.
+if (Triple.getSubArch() != llvm::Triple::NoSubArch ||
+Triple.getVendor() != llvm::Triple::UnknownVendor ||
+Triple.getOS() != llvm::Triple::UnknownOS ||
+Triple.getEnvironment() != llvm::Triple::UnknownEnvironment ||
+Triple.getObjectFormat() != llvm::Triple::UnknownObjectFormat ||
+(!Triple.getVendorName().empty() &&
+ Triple.getVendorName() != "unknown") ||
+(!Triple.getOSName().empty() && Triple.getOSName() != "unknown") ||
+(Triple.hasEnvironment() && Triple.getEnvironmentName() != "unknown"))
+  return nullptr;
+return new WebAssemblyOSTargetInfo(Triple);

Seems overly complicated? Maybe just a positive test?


Comment at: lib/CodeGen/CodeGenModule.cpp:824
@@ +823,3 @@
+  if (getTarget().getCXXABI().areMemberFunctionsAligned()) {
+// C++ ABI requires 2-byte alignment for member functions.
+if (F->getAlignment() < 2 && isa(D))

Update the comment?


Comment at: lib/Driver/ToolChains.cpp:3853-3873
@@ +3852,23 @@
+
+bool WebAssembly::IsMathErrnoDefault() const { return false; }
+
+bool WebAssembly::IsObjCNonFragileABIDefault() const { return true; }
+
+bool WebAssembly::UseObjCMixedDispatch() const { return true; }
+
+bool WebAssembly::isPICDefault() const { return false; }
+
+bool WebAssembly::isPIEDefault() const { return false; }
+
+bool WebAssembly::isPICDefaultForced() const { return false; }
+
+bool WebAssembly::IsIntegratedAssemblerDefault() const { return true; }
+
+// TODO: Support Objective C stuff.
+bool WebAssembly::SupportsObjCGC() const { return false; }
+
+bool WebAssembly::hasBlocksRuntime() const { return false; }
+
+// TODO: Support profiling.
+bool WebAssembly::SupportsProfiling() const { return false; }
+

No generic defaults here? Might also make sense to have these all inline if 
they're just return true/return false.


Comment at: lib/Driver/Tools.cpp:1564-1569
@@ +1563,8 @@
+
+#ifdef __wasm__
+// Handle "native" by examining the host. "native" isn't meaningful when
+// cross compiling, so only support this when the host is also WebAssembly.
+if (CPU == "native")
+  return llvm::sys::getHostCPUName();
+#endif
+

I really dislike the idea of an ifdef here for this behavior. Can you explain 
some more? :)


Repository:
  rL LLVM

http://reviews.llvm.org/D12002



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


Re: [PATCH] D12444: [Sema] Avoid crash on tag-type mismatch (Fixes PR24610)

2015-08-31 Thread David Majnemer via cfe-commits
majnemer added a comment.

I think it'd be nice if we keep the assert but make 
`setTagNameForLinkagePurposes` early-return if 
`TagFromDeclSpec->isInvalidDecl()` returns true.  How does that sound to you?


http://reviews.llvm.org/D12444



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


Re: [PATCH] D12489: [clang-format] Fixed missing space between Obj-C for/in and a typecast

2015-08-31 Thread Kent Sutherland via cfe-commits
ksuther added a reviewer: djasper.
ksuther added a comment.

This is my first commit and I'm trying to figure out the system, hope I'm doing 
this right.


http://reviews.llvm.org/D12489



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


Re: [PATCH] D12462: [PATCH] [clang-tidy] Add inconsistent declaration parameter name check

2015-08-31 Thread Piotr Dziwinski via cfe-commits
piotrdz marked 7 inline comments as done.


Comment at: 
clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp:23
@@ +22,3 @@
+
+struct CheckResult {
+  CheckResult(bool HasInconsistentParams,

alexfh wrote:
> Maybe use `llvm::Optional`? Or, if you don't need to store 
> invalid locations, just use `SourceLocation` and use `SourceLocation()` as a 
> magic value?
In the end, I used SourceLocation.


Comment at: 
clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp:33
@@ +32,3 @@
+
+struct InconsistentParamChecker {
+  static CheckResult checkForInconsitentDeclarationParameters(const 
FunctionDecl* FunctionDeclaration);

alexfh wrote:
> Why do you need a struct? It's not Java, free functions are totally fine.
That was my sort of "ingenious" workaround for not being able to do this:
```
namespace {
void checkForInconsitentDeclarationParameters(MatchFinder *Finder); // 
declaration
}
void checkForInconsitentDeclarationParameters(MatchFinder *Finder) { /*..*/ } 
// definition
```

But I suppose we're better off without such inventions ;). So I moved it all 
into one anonymous namespace.


Comment at: 
clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp:53
@@ +52,3 @@
+
+  auto CheckResult = 
InconsistentParamChecker::checkForInconsitentDeclarationParameters(FunctionDeclaration);
+  if (CheckResult.HasInconsistentParams) {

alexfh wrote:
> We use `auto` when the type is obvious from the RHS (e.g. line 49 above) or 
> when the specific type is complex and not particularly helpful (e.g. when 
> iterating over std::map<>, or for iterators in general). In almost all other 
> cases the specific type is preferred.
All right, I didn't know about such rule here. In my colobot-lint code I prefer 
the use of auto whenever possible, to isolate my code from possible API 
changes. But here, as part of Clang project itself, I guess it's not necessary.


Comment at: 
clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp:59
@@ +58,3 @@
+
+diag(FunctionDeclaration->getLocation(), "function '%0' has other 
declaration with different parameter name(s)")
+  << QualName;

alexfh wrote:
> The message could be more helpful, if it contained the differing names of the 
> parameters.
> 
> A significant improvement would be to propose a fix when it's more or less 
> clear what the correct name of each parameter should be (e.g. 2 of 3 
> declarations have the same parameter names, and the third one has different 
> names, or we could consider parameter names used in the definition correct). 
> Without a fix, the value of the check will be much lower. In my experience, 
> developers are reluctant to fix readability warnings manually.
All right, I added note messages about parameter names.

As to adding FixIt hints, I also think they're more useful than simple 
diagnostic, but in my opinion, it can be difficult to tell what is the intended 
name in given case. I think there are two cases we can consider:
 - If we see the definition of function in current translation unit, we may 
assume that the most up-to-date parameter names are those of the definition, 
since they are the closest to actual code that uses them in some context. So 
the proposed fix would be to update all other declarations we see to match the 
definition.
 - If we see only declarations in current translation unit, things start 
getting difficult, as we (usually) have no way to tell which declaration is 
considered more important than any other. In such case, I would not propose any 
hints and leave it up to the user to decide what to do.


Comment at: 
clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h:64
@@ +63,3 @@
+private:
+std::set ReportedFunctions;
+};

alexfh wrote:
> If you don't need these to be sorted, you can use `llvm::StringSet<>` which 
> should be more effective.
I went with llvm::DenseSet<>, as suggested below


Comment at: 
test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp:1
@@ +1,2 @@
+// RUN: %python %S/check_clang_tidy.py %s 
readability-inconsistent-declaration-parameter-name %t
+

alexfh wrote:
> Please add tests for special functions (constructor, copy operator), implicit 
> functions, template functions with several instantiations, function 
> declarations in macros.
Thanks for pointing it out. I found there are some problems with formatting 
note messages with templates, but I don't know how to solve them yet :-(


http://reviews.llvm.org/D12462



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


r246479 - Revert r246345 until an assertion is fixed.

2015-08-31 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Mon Aug 31 15:10:35 2015
New Revision: 246479

URL: http://llvm.org/viewvc/llvm-project?rev=246479&view=rev
Log:
Revert r246345 until an assertion is fixed.

Removed:
cfe/trunk/test/Analysis/pr22954.c
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=246479&r1=246478&r2=246479&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Mon 
Aug 31 15:10:35 2015
@@ -1333,9 +1333,7 @@ public:
 /// Tells that a region's contents is not changed.
 TK_PreserveContents = 0x1,
 /// Suppress pointer-escaping of a region.
-TK_SuppressEscape = 0x2,
-// Do not invalidate super region.
-TK_DoNotInvalidateSuperRegion = 0x4
+TK_SuppressEscape = 0x2
 
 // Do not forget to extend StorageTypeForKinds if number of traits exceed 
 // the number of bits StorageTypeForKinds can store.

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp?rev=246479&r1=246478&r2=246479&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Mon Aug 31 
15:10:35 2015
@@ -145,8 +145,7 @@ public:
   static ProgramStateRef InvalidateBuffer(CheckerContext &C,
   ProgramStateRef state,
   const Expr *Ex, SVal V,
-  bool IsSourceBuffer,
-  const Expr *Size);
+  bool IsSourceBuffer);
 
   static bool SummarizeRegion(raw_ostream &os, ASTContext &Ctx,
   const MemRegion *MR);
@@ -194,14 +193,6 @@ public:
 ProgramStateRef state,
 NonLoc left,
 NonLoc right) const;
-
-  // Return true if destination buffer of copy function is in bound.
-  // Expects SVal of Size to be positive and unsigned.
-  // Expects SVal of FirstBuf to be a FieldRegion.
-  static bool IsFirstBufInBound(CheckerContext &C,
-ProgramStateRef state,
-const Expr *FirstBuf,
-const Expr *Size);
 };
 
 } //end anonymous namespace
@@ -823,68 +814,10 @@ const StringLiteral *CStringChecker::get
   return strRegion->getStringLiteral();
 }
 
-bool CStringChecker::IsFirstBufInBound(CheckerContext &C,
-   ProgramStateRef state,
-   const Expr *FirstBuf,
-   const Expr *Size) {
-
-  // Originally copied from CheckBufferAccess and CheckLocation.
-  SValBuilder &svalBuilder = C.getSValBuilder();
-  ASTContext &Ctx = svalBuilder.getContext();
-  const LocationContext *LCtx = C.getLocationContext();
-
-  QualType sizeTy = Size->getType();
-  QualType PtrTy = Ctx.getPointerType(Ctx.CharTy);
-  SVal BufVal = state->getSVal(FirstBuf, LCtx);
-
-  SVal LengthVal = state->getSVal(Size, LCtx);
-  // Cast is safe as the size argument to copy functions are of integral type.
-  NonLoc Length = LengthVal.castAs();
-
-  // Compute the offset of the last element to be accessed: size-1.
-  NonLoc One = svalBuilder.makeIntVal(1, sizeTy).castAs();
-  NonLoc LastOffset =
-  svalBuilder.evalBinOpNN(state, BO_Sub, Length, One, sizeTy)
-  .castAs();
-
-  // Check that the first buffer is sufficiently long.
-  SVal BufStart = svalBuilder.evalCast(BufVal, PtrTy, FirstBuf->getType());
-  // Cast is safe as caller checks BufVal is a MemRegionVal.
-  Loc BufLoc = BufStart.castAs();
-
-  SVal BufEnd =
-  svalBuilder.evalBinOpLN(state, BO_Add, BufLoc, LastOffset, PtrTy);
-
-  // Check for out of bound array element access.
-  const MemRegion *R = BufEnd.getAsRegion();
-  // BufStart is a MemRegionVal so BufEnd should be one too.
-  assert(R && "BufEnd should be a MemRegion");
-
-  // Cast is safe as BufVal's region is a FieldRegion.
-  const ElementRegion *ER = cast(R);
-
-  assert(ER->getValueType() == C.getASTContext().CharTy &&
- "IsFirstBufInBound should only be called with char* ElementRegions");
-
-  // Get the size of the array.
-  const SubRegion *superReg = cast(ER->getSuperRegion());
-  SV

Re: [PATCH] D12462: [PATCH] [clang-tidy] Add inconsistent declaration parameter name check

2015-08-31 Thread Piotr Dziwinski via cfe-commits
piotrdz updated this revision to Diff 33619.
piotrdz marked 3 inline comments as done.
piotrdz added a comment.

Applied fixes for most issues found in review.


http://reviews.llvm.org/D12462

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
  clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
  test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp

Index: test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
===
--- test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
+++ test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
@@ -0,0 +1,56 @@
+// RUN: %python %S/check_clang_tidy.py %s readability-inconsistent-declaration-parameter-name %t
+
+void consistentFunction(int a, int b, int c);
+void consistentFunction(int a, int b, int c);
+void consistentFunction(int a, int b, int /*c*/);
+void consistentFunction(int /*c*/, int /*c*/, int /*c*/);
+
+// CHECK-MESSAGES: :[[@LINE+1]]:6: warning: function 'inconsistentFunction' has other declaration with different parameter names [readability-inconsistent-declaration-parameter-name]
+void inconsistentFunction(int a, int b, int c);
+void inconsistentFunction(int d, int e, int f);
+void inconsistentFunction(int x, int y, int z);
+
+struct SomeStruct {
+// CHECK-MESSAGES: :[[@LINE+1]]:8: warning:  function 'SomeStruct::inconsistentFunction' has other declaration with different parameter name [readability-inconsistent-declaration-parameter-name]
+  void inconsistentFunction(int a);
+};
+
+void SomeStruct::inconsistentFunction(int b)
+{}
+
+
+struct SpecialFunctions {
+// CHECK-MESSAGES: :[[@LINE+1]]:3: warning:  function 'SpecialFunctions::SpecialFunctions' has other declaration with different parameter name [readability-inconsistent-declaration-parameter-name]
+  SpecialFunctions(int a);
+
+// CHECK-MESSAGES: :[[@LINE+1]]:21: warning:  function 'SpecialFunctions::operator=' has other declaration with different parameter name [readability-inconsistent-declaration-parameter-name]
+  SpecialFunctions& operator=(const SpecialFunctions& a);
+};
+
+SpecialFunctions::SpecialFunctions(int b)
+{}
+
+SpecialFunctions& SpecialFunctions::operator=(const SpecialFunctions& b) {
+  return *this;
+}
+
+template
+void templateFunction(T a);
+
+template<>
+// CHECK-MESSAGES: :[[@LINE+1]]:6: warning:  function 'templateFunction' has other declaration with different parameter name [readability-inconsistent-declaration-parameter-name]
+// FIXME: note messages are not very clear here
+void templateFunction(int b)
+{}
+
+template<>
+// CHECK-MESSAGES: :[[@LINE+1]]:6: warning:  function 'templateFunction' has other declaration with different parameter name [readability-inconsistent-declaration-parameter-name]
+void templateFunction(float b)
+{}
+
+#define DECL_FUNCTION(name, arg_name) \
+  void name(int arg_name)
+
+// CHECK-MESSAGES: :[[@LINE+1]]:15: warning:  function 'macroFunction' has other declaration with different parameter name [readability-inconsistent-declaration-parameter-name]
+DECL_FUNCTION(macroFunction, a);
+DECL_FUNCTION(macroFunction, b);
Index: docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
===
--- docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
+++ docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
@@ -0,0 +1,29 @@
+readability-inconsistent-declaration-parameter-name
+===
+
+
+Find function declarations which differ in parameter names.
+
+Example:
+
+.. code:: c++
+
+  // in foo.hpp:
+  void foo(int a, int b, int c);
+
+  // in foo.cpp:
+  void foo(int d, int e, int f); // warning
+
+This check should help to enforce consistency in large projects, where it often happens
+that a definition of function is refactored, changing the parameter names, but its declaration
+in header file is not updated. With this check, we can easily find and correct such inconsistencies,
+keeping declaration and definition always in sync.
+
+Unnamed parameters are allowed and are not taken into account when comparing function declarations, for example:
+
+.. code:: c++
+
+   void foo(int a);
+   void foo(int); // no warning
+
+If there are multiple declarations of same function, only one warning will be generated.
\ No newline at end of file
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -47,6 +47,7 @@
readability-else-after-return
readability-function-size
readability-id

Re: [PATCH] D12462: [PATCH] [clang-tidy] Add inconsistent declaration parameter name check

2015-08-31 Thread Piotr Dziwinski via cfe-commits
piotrdz marked an inline comment as done.
piotrdz added a comment.

Now this issue with templates is a bit difficult for me. I tried everything 
that seems to have made sense, but I still get output like this:

  
/work/clang-trunk/clang-tools-extra/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp:47:6:
 warning: function 'templateFunction' has other declaration with different 
parameter name [readability-inconsistent-declaration-parameter-name]
  void templateFunction(float b)
   ^
  
/work/clang-trunk/clang-tools-extra/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp:47:6:
 note: other declaration seen here
  void templateFunction(float b)
   ^
  
/work/clang-trunk/clang-tools-extra/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp:47:29:
 note: parameter 1 is named 'b' here, but 'a' in other declaration
  void templateFunction(float b)
  ^

But I'd like to get output like this:

  
/work/clang-trunk/clang-tools-extra/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp:47:6:
 warning: function 'templateFunction' has other declaration with 
different parameter name [readability-inconsistent-declaration-parameter-name]
  void templateFunction(float b)
   ^
  
/work/clang-trunk/clang-tools-extra/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp:47:6:
 note: other declaration seen here
  void templateFunction(T a);
   ^
  
/work/clang-trunk/clang-tools-extra/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp:47:29:
 note: parameter 1 is named 'b' here, but 'a' in other declaration
  void templateFunction(float b)
  ^


http://reviews.llvm.org/D12462



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


[PATCH] D12501: [clang-format] Obj-C dictionary literals: Fixed typecast getting put on a separate line from the key

2015-08-31 Thread Kent Sutherland via cfe-commits
ksuther created this revision.
ksuther added a reviewer: djasper.
ksuther added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Fixes this bug: https://llvm.org/bugs/show_bug.cgi?id=22647

The following dictionary was getting formatted oddly:

NSDictionary *query = @{
(__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
(__bridge id)kSecReturnData: (__bridge id)kCFBooleanTrue,
};

It was turning into this:

NSDictionary *passwordQuery = @{
  (__bridge id) kSecClass : (__bridge id)kSecClassGenericPassword, (__bridge id)
  kSecReturnData : (__bridge id)kCFBooleanTrue, (__bridge id)
  kSecReturnAttributes : (__bridge id)kCFBooleanTrue,
};

As far as I can tell, changes to format Proto lines correctly was turning the 
key (e.g. kSecClass) into a TT_SelectorName, which was then force the cast to 
get separated from the key. I added an extra check to see if the current 
context is in a dictionary literal, and if so kept the type as TT_Unknown.

http://reviews.llvm.org/D12501

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7502,6 +7502,12 @@
"  bb : b,\n"
"   : ccc\n"
"}];");
+
+  // Ensure that casts before the key are kept on the same line as the key
+  verifyFormat("NSDictionary *query = @{\n"
+   "  (__bridge id)kSecClass : (__bridge 
id)kSecClassGenericPassword,\n"
+   "  (__bridge id)kSecReturnData : (__bridge id)kCFBooleanTrue,\n"
+   "};");
 }
 
 TEST_F(FormatTest, ObjCArrayLiterals) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -372,7 +372,9 @@
 updateParameterCount(Left, CurrentToken);
 if (CurrentToken->isOneOf(tok::colon, tok::l_brace)) {
   FormatToken *Previous = CurrentToken->getPreviousNonComment();
-  if ((CurrentToken->is(tok::colon) ||
+  if (((CurrentToken->is(tok::colon) &&
+(!Contexts.back().ColonIsDictLiteral ||
+ Style.Language != FormatStyle::LK_Cpp)) ||
Style.Language == FormatStyle::LK_Proto) &&
   Previous->is(tok::identifier))
 Previous->Type = TT_SelectorName;


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7502,6 +7502,12 @@
"  bb : b,\n"
"   : ccc\n"
"}];");
+
+  // Ensure that casts before the key are kept on the same line as the key
+  verifyFormat("NSDictionary *query = @{\n"
+   "  (__bridge id)kSecClass : (__bridge id)kSecClassGenericPassword,\n"
+   "  (__bridge id)kSecReturnData : (__bridge id)kCFBooleanTrue,\n"
+   "};");
 }
 
 TEST_F(FormatTest, ObjCArrayLiterals) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -372,7 +372,9 @@
 updateParameterCount(Left, CurrentToken);
 if (CurrentToken->isOneOf(tok::colon, tok::l_brace)) {
   FormatToken *Previous = CurrentToken->getPreviousNonComment();
-  if ((CurrentToken->is(tok::colon) ||
+  if (((CurrentToken->is(tok::colon) &&
+(!Contexts.back().ColonIsDictLiteral ||
+ Style.Language != FormatStyle::LK_Cpp)) ||
Style.Language == FormatStyle::LK_Proto) &&
   Previous->is(tok::identifier))
 Previous->Type = TT_SelectorName;
___
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-31 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

I reverted the commit until this assertion is fixed.

Steps to reproduce:
Download the following preprocessed file: F804743: clang_crash_7QnDaH.i 

Execute the analyzer on that one: clang -cc1 -analyze -analyzer-checker=core 
-analyzer-checker=unix -fblocks clang_crash_7QnDaH.i


Repository:
  rL LLVM

http://reviews.llvm.org/D11832



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


[PATCH] D12502: [libcxx] Better constain tuples constructors -- Fix PR23256 and PR22806

2015-08-31 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: mclow.lists, eugenis, ldionne.
EricWF added a subscriber: cfe-commits.

This patch fixes the following bugs:
  * PR23256  tuple is_constructible attempts tuple to A conversion:
   * Fix this by disabling the UTypes... overloads using the 
`__disable_tuple_args_ctor<...>` meta-function.
  *  PR22806 Move from destroyed object in tuple_cat of nested tuples
   * Fix this by disabling the tuple-like overloads using the 
`__disable_tuple_like_ctor<...>` meta-function.

The goal of the `__disable_*_ctor` metafunctions is to disable obviously 
incorrect constructor overloads before they evaluate more SFINAE and cause a 
hard compile error. The implementation of these traits uses NO SFINAE that 
could result in a hard compile error. These must be safe to evaluate always.



http://reviews.llvm.org/D12502

Files:
  include/__tuple
  include/tuple
  
test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR22806_constrain_tuple_like_ctor.pass.cpp
  
test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR23256_constrain_UTypes_ctor.pass.cpp

Index: test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR23256_constrain_UTypes_ctor.pass.cpp
===
--- /dev/null
+++ test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR23256_constrain_UTypes_ctor.pass.cpp
@@ -0,0 +1,60 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// template  class tuple;
+
+// template 
+//EXPLICIT(...) tuple(UTypes&&...)
+
+// Check that the UTypes... ctor is properly disabled before evaluating any
+// SFINAE when the tuple-like copy/move ctor should *clearly* be selected
+// instead. This happens 'sizeof...(UTypes) == 1' and the first element of
+// 'UTypes...' is an instance of the tuple itself. See PR23256.
+
+#include 
+#include 
+#include 
+
+
+class UnconstrainedCtor {
+public:
+  UnconstrainedCtor() : value_(0) {}
+
+  template 
+  constexpr UnconstrainedCtor(T value) : value_(static_cast(value)) {
+  static_assert(std::is_same::value, "");
+  }
+
+private:
+  int value_;
+};
+
+int main() {
+typedef UnconstrainedCtor A;
+{
+static_assert(std::is_trivially_copy_constructible>::value, "");
+static_assert(std::is_trivially_move_constructible>::value, "");
+}
+{
+static_assert(std::is_constructible<
+std::tuple,
+std::allocator_arg_t, std::allocator,
+std::tuple const&
+>::value, "");
+static_assert(std::is_constructible<
+std::tuple,
+std::allocator_arg_t, std::allocator,
+std::tuple &&
+>::value, "");
+}
+}
Index: test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR22806_constrain_tuple_like_ctor.pass.cpp
===
--- /dev/null
+++ test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR22806_constrain_tuple_like_ctor.pass.cpp
@@ -0,0 +1,74 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// template  class tuple;
+
+// template 
+//   tuple(TupleLike&&);
+// template 
+//   tuple(std::allocator_arg_t, Alloc const&, TupleLike&&);
+
+// Check that the tuple-like copy/move ctors are properly disabled when the
+// UTypes... constructor should be selected. See PR22806.
+
+#include 
+#include 
+#include 
+
+#include "tracked_value.h"
+
+int main()
+{
+{ // rvalue reference
+TrackedValue v;
+std::tuple t1(v);
+// This selects the wrong constructor and constructs std::tuple&&
+// from a temporary.
+std::tuple&&> t2(std::move(t1));
+// This moves from the reference constructed from the temporary.
+std::tuple>  t3(std::move(t2));
+}
+{ // const lvalue reference
+TrackedValue v;
+std::tuple t1(v);
+std::tuple const &> t2(t1);
+std::tuple>  t3(t2);
+}
+{ // lvalue reference
+TrackedValue v;
+std::tuple t1(v);
+std::tuple &> t2(t1);
+std::tuple>  t3(t2);
+}
+{ // rvalue reference via allocator ctor
+TrackedValue v;
+std::tuple t1(v);
+std::allocator a;
+std::tuple&&> t2(std::allocator_arg, a, std::move(t1));
+std::tuple>  t3(std::move(t2));
+}
+{ // 

Re: [PATCH] D9085: Fix tuple to A conversion in SFINAE for tuple(_Up...) constructor

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

Another possible fix up for review as http://reviews.llvm.org/D12502.


Repository:
  rL LLVM

http://reviews.llvm.org/D9085



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


Re: [PATCH] D8178: [libcxx] Fix PR22806 - Tuple incorrectly selects copy/move constructor when storing nested tuple-like types.

2015-08-31 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a reviewer: EricWF.
EricWF added a comment.
This revision is now accepted and ready to land.

Abandoning for patch http://reviews.llvm.org/D12502.


http://reviews.llvm.org/D8178



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


Re: [PATCH] D8178: [libcxx] Fix PR22806 - Tuple incorrectly selects copy/move constructor when storing nested tuple-like types.

2015-08-31 Thread Eric Fiselier via cfe-commits
EricWF abandoned this revision.
EricWF added a comment.

Actually abandoning. Sorry for the spam.


http://reviews.llvm.org/D8178



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


Re: [PATCH] D12502: [libcxx] Better constain tuples constructors -- Fix PR23256 and PR22806

2015-08-31 Thread Eric Fiselier via cfe-commits
EricWF added reviewers: K-ballo, howard.hinnant.
EricWF added a comment.

Adding K-ballo and Howard Hinnant as reviewers. This patch could use all the 
eyes it could get.


http://reviews.llvm.org/D12502



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


Re: [PATCH][Solaris] Clang/Driver, stop hardcoding GCC paths in crt/ld.so lookup

2015-08-31 Thread Rafael Espíndola via cfe-commits
r246473.

On 31 August 2015 at 13:30, Xan López  wrote:
> Oops, missed this. Here is the updated patch.
>
> And yes please, commit the patch for me.
>
> Cheers,
>
> Xan
>
> On Mon, Aug 31, 2015 at 01:07:35PM -0400, Rafael Espíndola wrote:
>> Do you have a version with the last suggestions? I lgtmed it conditional on
>> it.   Do you need someone to commit it for you?
>> On Aug 23, 2015 7:07 PM, "Rafael Espíndola" 
>> wrote:
>>
>> > SolarisScanLibDirForGCCTriple should start with a lower case. Starting
>> > it with "scan" would probably also be more in line with the code
>> > style.
>> >
>> > LGTM
>> >
>> > On 11 August 2015 at 16:33, Xan López  wrote:
>> > > Hi,
>> > >
>> > > thanks for the review, I was not even aware that this could be
>> > > tested. Adding a test helped to fix me a couple extra issues (plus the
>> > > one you already mentioned). New patch attached.
>> > >
>> > > Xan
>> > >
>> > > On Wed, Aug 05, 2015 at 09:14:30AM -0400, Rafael Espíndola wrote:
>> > >> Please git-clang-format this patch.
>> > >>
>> > >> +  // /usr/gcc/./lib/gcc/../,
>> > >>
>> > >> The code appends a triple after the "/lib/gcc". Is the comment missing
>> > it?
>> > >>
>> > >> The inner loop has no version comparison. Are you depending on the
>> > >> directory iteration order?
>> > >>
>> > >> Can you add a testcase?
>> > >>
>> > >>
>> > >> On 28 July 2015 at 12:35, Xan López  wrote:
>> > >> > Here it is.
>> > >> >
>> > >> > On Tue, Jul 28, 2015 at 01:21:06PM +0200, Xan López wrote:
>> > >> >> On Tue, Jul 28, 2015 at 01:55:23PM +0300, Yaron Keren wrote:
>> > >> >> > +cfe-commits
>> > >> >> >
>> > >> >> > This is a very large Solaris special case in
>> > ScanLibDirForGCCTriple which
>> > >> >> > shares almost no code with the function.
>> > >> >> > How about splitting it out to a helper function or
>> > >> >> > making ScanLibDirForGCCTriple virtual and overriding on Solaris?
>> > >> >>
>> > >> >> Yep, at least a helper function makes sense, you are right. I'll send
>> > >> >> another patch with either of those suggestions later today.
>> > >> >>
>> > >> >>
>> > >> >> Xan
>> > >> >> ___
>> > >> >> llvm-commits mailing list
>> > >> >> llvm-comm...@cs.uiuc.edu
>> > >> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> > >> >
>> > >> > ___
>> > >> > llvm-commits mailing list
>> > >> > llvm-comm...@cs.uiuc.edu
>> > >> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> > >> >
>> >
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12444: [Sema] Avoid crash on tag-type mismatch (Fixes PR24610)

2015-08-31 Thread Vedant Kumar via cfe-commits
vsk updated the summary for this revision.
vsk updated this revision to Diff 33623.
vsk added a comment.

- Keep the assert, return early if the declaration is invalid.


http://reviews.llvm.org/D12444

Files:
  lib/Sema/SemaDecl.cpp
  test/Sema/enum.c

Index: test/Sema/enum.c
===
--- test/Sema/enum.c
+++ test/Sema/enum.c
@@ -119,3 +119,7 @@
 
 typedef enum { NegativeShort = (short)-1 } NegativeShortEnum;
 int NegativeShortTest[NegativeShort == -1 ? 1 : -1];
+
+// PR24610
+enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
+typedef struct Color NewColor; // expected-error {{use of 'Color' with tag 
type that does not match previous declaration}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -3560,6 +3560,9 @@
 
 void Sema::setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
 TypedefNameDecl *NewTD) {
+  if (TagFromDeclSpec->isInvalidDecl())
+return;
+
   // Do nothing if the tag already has a name for linkage purposes.
   if (TagFromDeclSpec->hasNameForLinkage())
 return;


Index: test/Sema/enum.c
===
--- test/Sema/enum.c
+++ test/Sema/enum.c
@@ -119,3 +119,7 @@
 
 typedef enum { NegativeShort = (short)-1 } NegativeShortEnum;
 int NegativeShortTest[NegativeShort == -1 ? 1 : -1];
+
+// PR24610
+enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
+typedef struct Color NewColor; // expected-error {{use of 'Color' with tag type that does not match previous declaration}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -3560,6 +3560,9 @@
 
 void Sema::setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
 TypedefNameDecl *NewTD) {
+  if (TagFromDeclSpec->isInvalidDecl())
+return;
+
   // Do nothing if the tag already has a name for linkage purposes.
   if (TagFromDeclSpec->hasNameForLinkage())
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11948: Add some macros to abstract marking of parameters as "not null", and use them in

2015-08-31 Thread Marshall Clow via cfe-commits
mclow.lists updated this revision to Diff 33624.
mclow.lists added a comment.

Fixed a typo in the patch for `strncmp`, and added a macro 
`_LIBCPP_HAS_NO_NONNULL` to allow people to disable these checks.

Marked them as disabled for non-clang and non-gcc compilers.


http://reviews.llvm.org/D11948

Files:
  include/__config
  include/cstring

Index: include/cstring
===
--- include/cstring
+++ include/cstring
@@ -67,15 +67,34 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::size_t;
-using ::memcpy;
-using ::memmove;
+
+// using ::memcpy;
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_NON_NULL2(1, 2)
+void* memcpy(void* __s1, const void* __s2, size_t __n) 
+{ return ::memcpy(__s1, __s2, __n); }
+
+// using ::memmove;
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_NON_NULL2(1, 2)
+void* memmove(void* __s1, const void* __s2, size_t __n)
+{ return ::memmove(__s1, __s2, __n); }
+
 using ::strcpy;
 using ::strncpy;
 using ::strcat;
 using ::strncat;
-using ::memcmp;
+
+// using ::memcmp;
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_NON_NULL2(1, 2)
+int memcmp(const void* __s1, const void* __s2, size_t __n)
+{ return ::memcmp(__s1, __s2, __n); }
+
 using ::strcmp;
-using ::strncmp;
+
+// using ::strncmp;
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_NON_NULL2(1, 2)
+int strncmp(const char* __s1, const char* __s2, size_t __n)
+{ return ::strncmp(__s1, __s2, __n); }
+
 using ::strcoll;
 using ::strxfrm;
 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -276,6 +276,13 @@
 
 #define _LIBCPP_UNUSED __attribute__((__unused__))
 
+#ifndef _LIBCPP_HAS_NO_NONNULL
+#define	_LIBCPP_NON_NULL			__attribute__((__nonnull__))
+#define	_LIBCPP_NON_NULL1(x)		__attribute__((__nonnull__(x)))
+#define	_LIBCPP_NON_NULL2(x,y)		__attribute__((__nonnull__(x,y)))
+#define	_LIBCPP_NON_NULL3(x,y,z)	__attribute__((__nonnull__(x,y,z)))
+#endif
+
 #if !(__has_feature(cxx_defaulted_functions))
 #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 #endif  // !(__has_feature(cxx_defaulted_functions))
@@ -408,6 +415,13 @@
 
 #define _LIBCPP_UNUSED __attribute__((__unused__))
 
+#ifndef _LIBCPP_HAS_NO_NONNULL
+#define	_LIBCPP_NON_NULL			__attribute__((__nonnull__))
+#define	_LIBCPP_NON_NULL1(x)		__attribute__((__nonnull__(x)))
+#define	_LIBCPP_NON_NULL2(x,y)		__attribute__((__nonnull__(x,y)))
+#define	_LIBCPP_NON_NULL3(x,y,z)	__attribute__((__nonnull__(x,y,z)))
+#endif
+
 #if _GNUC_VER >= 407
 #define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
 #define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
@@ -516,6 +530,7 @@
 #define _LIBCPP_UNUSED
 #define _ALIGNAS(x) __declspec(align(x))
 #define _LIBCPP_HAS_NO_VARIADICS
+#define _LIBCPP_HAS_NO_NONNULL
 
 #define _NOEXCEPT throw ()
 #define _NOEXCEPT_(x)
@@ -552,6 +567,7 @@
 #define _LIBCPP_HAS_IS_BASE_OF
 #define _LIBCPP_HAS_IS_FINAL
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+#define _LIBCPP_HAS_NO_NONNULL
 
 #if defined(_AIX)
 #define __MULTILOCALE_API
@@ -725,6 +741,13 @@
 #  define _LIBCPP_EXPLICIT_MOVE(x) (x)
 #endif
 
+#ifdef _LIBCPP_HAS_NO_NONNULL
+#define	_LIBCPP_NON_NULL
+#define	_LIBCPP_NON_NULL1(x)
+#define	_LIBCPP_NON_NULL2(x,y)
+#define	_LIBCPP_NON_NULL3(x,y,z)
+#endif
+
 #ifndef _LIBCPP_HAS_NO_ASAN
 extern "C" void __sanitizer_annotate_contiguous_container(
   const void *, const void *, const void *, const void *);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11963: Create a __config_site file to capture configuration decisions.

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

In http://reviews.llvm.org/D11963#236376, @jroelofs wrote:

> In http://reviews.llvm.org/D11963#236045, @EricWF wrote:
>
> > So that's not what happens but that's because libc++ builds using the 
> > headers in the source directory. During the build all of the macros in the 
> > __config_site file are manually defined on the command line so that we 
> > don't need to use the generated headers. NOTE: The tests still use the 
> > generated headers though.
>
>
> Oh, I didn't catch that you were setting this up to build from the headers in 
> the source directory.


Yeah, I worry this patch is very unclear. To sum the steps CMake takes:

Configuration time:

1. Configure CMake and detect if the configuration requires any "__config_site" 
defines.
2. Add each "__config_site" definition to the command line manually. These are 
used during the build.
3. Generate a `build/__config_site` file containing each required definition.
4. If any "__config_site" definitions are required setup the tests to use 
`build/include/c++/v1`. Otherwise the tests will use `src/include` as they 
currently do.

Build time:

1. Copy `src/include` to `build/include/c++/v1`.
2. If any "__config_site" defines are needed prepend `build/__config_site` to 
`build/include/c++/v1/__config`.
3. Build libc++ using the headers in `src/include` and the "__config_site" 
definitions added in Configuration step #2. Note that the actual build ignores 
the generated headers.

Install Time:

1. Do build steps including regenerating build headers.
2. Install headers in `build/include/c++/v1`.


http://reviews.llvm.org/D11963



___
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-31 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

FYI I'm focusing on getting http://reviews.llvm.org/D11963 in so that it stops 
blocking this patch.


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-31 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

FYI I'm focusing on getting http://reviews.llvm.org/D11963 in so that it stops 
blocking this patch.


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] D12087: always_inline codegen rewrite

2015-08-31 Thread Reid Kleckner via cfe-commits
rnk added a subscriber: rnk.


Comment at: lib/CodeGen/CodeGenModule.cpp:469-470
@@ +468,4 @@
+  llvm::LLVMContext &Ctx = getModule().getContext();
+  llvm::Function *StubFn =
+  llvm::Function::Create(FT, Fn->getLinkage(), Name, &getModule());
+  assert(StubFn->getName() == Name && "name was uniqued!");

This is a lot of work to do for every always_inline function that got called. 
Can we do this like:
1. Build SmallVector of all non-direct call uses of Fn
2. Return if there are no such uses
3. Build the stub function replacement
4. `for (Use *U : IndirectUses) U->set(StubFn)`


Comment at: test/CodeGen/2008-05-19-AlwaysInline.c:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | not grep sabrina
+// RUN: %clang_cc1 %s -emit-llvm -o - | not grep 'call.*sabrina('
 

FileCheck?


Comment at: test/CodeGenCXX/dllimport.cpp:247-250
@@ -246,1 +246,6 @@
 // MSC2-NOT: @"\01?alwaysInline@@YAXXZ"()
+// MSC2: declare dllimport void @"\01?alwaysInline@@YAXXZ"()
+// MSC2-NOT: @"\01?alwaysInline@@YAXXZ"()
+
+// GNU2-NOT: @_Z12alwaysInlinev()
+// GNU2: define linkonce_odr void @_Z12alwaysInlinev()

This change will go away if you only create the decl when its used indirectly.


http://reviews.llvm.org/D12087



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


Re: [PATCH] D11963: Create a __config_site file to capture configuration decisions.

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

Without the context of this review, this strategy probably won't make any 
sense. So it's probably worth capturing these notes in a comment that describes 
why we're doing it that way.


http://reviews.llvm.org/D11963



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


Re: [PATCH] D12446: [PATCH] Enable clang-tidy misc-static-assert for C11

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

LG


http://reviews.llvm.org/D12446



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


r246492 - Fix CHECK directives that weren't checking.

2015-08-31 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Aug 31 16:48:52 2015
New Revision: 246492

URL: http://llvm.org/viewvc/llvm-project?rev=246492&view=rev
Log:
Fix CHECK directives that weren't checking.

Modified:
cfe/trunk/test/CodeGen/builtin-cpu-supports.c
cfe/trunk/test/CodeGen/builtins-ppc-crypto.c
cfe/trunk/test/CodeGen/builtins-ppc-p7.c
cfe/trunk/test/CodeGen/object-size.c
cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
cfe/trunk/test/CodeGenObjC/arc-loadweakretained-release.m
cfe/trunk/test/Driver/linux-ld.c
cfe/trunk/test/OpenMP/task_codegen.cpp
cfe/trunk/test/OpenMP/threadprivate_codegen.cpp
cfe/trunk/test/Preprocessor/traditional-cpp.c

Modified: cfe/trunk/test/CodeGen/builtin-cpu-supports.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-cpu-supports.c?rev=246492&r1=246491&r2=246492&view=diff
==
--- cfe/trunk/test/CodeGen/builtin-cpu-supports.c (original)
+++ cfe/trunk/test/CodeGen/builtin-cpu-supports.c Mon Aug 31 16:48:52 2015
@@ -10,7 +10,7 @@ int main() {
 
   // CHECK: [[LOAD:%[^ ]+]] = load i32, i32* getelementptr inbounds ({ i32, 
i32, i32, [1 x i32] }, { i32, i32, i32, [1 x i32] }* @__cpu_model, i32 0, i32 
3, i32 0)
   // CHECK: [[AND:%[^ ]+]] = and i32 [[LOAD]], 256
-  // CHECK = icmp ne i32 [[AND]], 0
+  // CHECK: = icmp ne i32 [[AND]], 0
 
   return 0;
 }

Modified: cfe/trunk/test/CodeGen/builtins-ppc-crypto.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-crypto.c?rev=246492&r1=246491&r2=246492&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-crypto.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-crypto.c Mon Aug 31 16:48:52 2015
@@ -34,7 +34,7 @@ vector unsigned char test_vpmsumb(void)
   vector unsigned char a = B_INIT1
   vector unsigned char b = B_INIT2
   return __builtin_altivec_crypto_vpmsumb(a, b);
-// CHECK @llvm.ppc.altivec.crypto.vpmsumb
+// CHECK: @llvm.ppc.altivec.crypto.vpmsumb
 }
 
 // CHECK-LABEL: define <8 x i16> @test_vpmsumh
@@ -43,7 +43,7 @@ vector unsigned short test_vpmsumh(void)
   vector unsigned short a = H_INIT1
   vector unsigned short b = H_INIT2
   return __builtin_altivec_crypto_vpmsumh(a, b);
-// CHECK @llvm.ppc.altivec.crypto.vpmsumh
+// CHECK: @llvm.ppc.altivec.crypto.vpmsumh
 }
 
 // CHECK-LABEL: define <4 x i32> @test_vpmsumw
@@ -52,7 +52,7 @@ vector unsigned int test_vpmsumw(void)
   vector unsigned int a = W_INIT1
   vector unsigned int b = W_INIT2
   return __builtin_altivec_crypto_vpmsumw(a, b);
-// CHECK @llvm.ppc.altivec.crypto.vpmsumw
+// CHECK: @llvm.ppc.altivec.crypto.vpmsumw
 }
 
 // CHECK-LABEL: define <2 x i64> @test_vpmsumd
@@ -61,7 +61,7 @@ vector unsigned long long test_vpmsumd(v
   vector unsigned long long a = D_INIT1
   vector unsigned long long b = D_INIT2
   return __builtin_altivec_crypto_vpmsumd(a, b);
-// CHECK @llvm.ppc.altivec.crypto.vpmsumd
+// CHECK: @llvm.ppc.altivec.crypto.vpmsumd
 }
 
 // CHECK-LABEL: define <2 x i64> @test_vsbox
@@ -172,7 +172,7 @@ vector unsigned char test_vpmsumb_e(void
   vector unsigned char a = B_INIT1
   vector unsigned char b = B_INIT2
   return __builtin_crypto_vpmsumb(a, b);
-// CHECK @llvm.ppc.altivec.crypto.vpmsumb
+// CHECK: @llvm.ppc.altivec.crypto.vpmsumb
 }
 
 // CHECK-LABEL: define <8 x i16> @test_vpmsumh_e
@@ -181,7 +181,7 @@ vector unsigned short test_vpmsumh_e(voi
   vector unsigned short a = H_INIT1
   vector unsigned short b = H_INIT2
   return __builtin_crypto_vpmsumb(a, b);
-// CHECK @llvm.ppc.altivec.crypto.vpmsumh
+// CHECK: @llvm.ppc.altivec.crypto.vpmsumh
 }
 
 // CHECK-LABEL: define <4 x i32> @test_vpmsumw_e
@@ -190,7 +190,7 @@ vector unsigned int test_vpmsumw_e(void)
   vector unsigned int a = W_INIT1
   vector unsigned int b = W_INIT2
   return __builtin_crypto_vpmsumb(a, b);
-// CHECK @llvm.ppc.altivec.crypto.vpmsumw
+// CHECK: @llvm.ppc.altivec.crypto.vpmsumw
 }
 
 // CHECK-LABEL: define <2 x i64> @test_vpmsumd_e
@@ -199,7 +199,7 @@ vector unsigned long long test_vpmsumd_e
   vector unsigned long long a = D_INIT1
   vector unsigned long long b = D_INIT2
   return __builtin_crypto_vpmsumb(a, b);
-// CHECK @llvm.ppc.altivec.crypto.vpmsumd
+// CHECK: @llvm.ppc.altivec.crypto.vpmsumd
 }
 
 // CHECK-LABEL: define <2 x i64> @test_vsbox_e
@@ -227,6 +227,7 @@ vector unsigned short test_vpermxorh_e(v
   vector unsigned short b = H_INIT2
   vector unsigned short c = H_INIT2
   return __builtin_crypto_vpermxor(a, b, c);
+// CHECK: @llvm.ppc.altivec.crypto.vpermxor
 }
 
 // CHECK-LABEL: define <4 x i32> @test_vpermxorw_e

Modified: cfe/trunk/test/CodeGen/builtins-ppc-p7.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-p7.c?rev=246492&r1=246491&r2=246492&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-p7.c (original)
+++ cfe/trunk/test/CodeGen/buil

[clang-tools-extra] r246494 - Help the clang-tidy helper script to understand C files better.

2015-08-31 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Aug 31 16:53:55 2015
New Revision: 246494

URL: http://llvm.org/viewvc/llvm-project?rev=246494&view=rev
Log:
Help the clang-tidy helper script to understand C files better.

Modified:
clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py

Modified: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py?rev=246494&r1=246493&r2=246494&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py (original)
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py Mon Aug 31 
16:53:55 2015
@@ -38,12 +38,16 @@ def main():
 sys.exit('Not enough arguments.')
 
   input_file_name = sys.argv[1]
+  extension = '.cpp'
+  if (input_file_name.endswith('.c')):
+extension = '.c'
+
   check_name = sys.argv[2]
-  temp_file_name = sys.argv[3] + '.cpp'
+  temp_file_name = sys.argv[3] + extension
 
   clang_tidy_extra_args = sys.argv[4:]
   if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--', '--std=c++11']
+clang_tidy_extra_args = ['--', '--std=c++11'] if extension == '.cpp' else 
['--']
 
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()


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


[clang-tools-extra] r246495 - Allow the static assert clang-tidy checker to run over C code.

2015-08-31 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Aug 31 16:54:42 2015
New Revision: 246495

URL: http://llvm.org/viewvc/llvm-project?rev=246495&view=rev
Log:
Allow the static assert clang-tidy checker to run over C code.

Added:
clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.c
Modified:
clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp?rev=246495&r1=246494&r2=246495&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp Mon Aug 31 
16:54:42 2015
@@ -27,10 +27,9 @@ StaticAssertCheck::StaticAssertCheck(Str
 : ClangTidyCheck(Name, Context) {}
 
 void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
-  // FIXME: I don't see why this checker couldn't also be interesting for
-  // _Static_assert in C11, or static_assert if  has been included, 
-  // but it is currently only enabled for C++11. Investigate.
-  if (!getLangOpts().CPlusPlus11)
+  // This checker only makes sense for languages that have static assertion
+  // capabilities: C++11 and C11.
+  if (!(getLangOpts().CPlusPlus11 || getLangOpts().C11))
 return;
 
   auto IsAlwaysFalse = expr(ignoringParenImpCasts(

Added: clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.c
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.c?rev=246495&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.c (added)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.c Mon Aug 31 
16:54:42 2015
@@ -0,0 +1,27 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-static-assert %t -- -std=c11
+// RUN: clang-tidy %s -checks=-*,misc-static-assert -- -std=c99 | count 0
+
+void abort() {}
+#ifdef NDEBUG
+#define assert(x) 1
+#else
+#define assert(x)  
\
+  if (!(x))
\
+  abort()
+#endif
+
+void f(void) {
+  int x = 1;
+  assert(x == 0);
+  // CHECK-FIXES: {{^  }}assert(x == 0);
+
+  #define static_assert(x, msg) _Static_assert(x, msg)
+  assert(11 == 5 + 6);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
+  // CHECK-FIXES: {{^  }}static_assert(11 == 5 + 6, "");
+  #undef static_assert
+
+  assert(10 == 5 + 5);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
+  // CHECK-FIXES: {{^  }}static_assert(10 == 5 + 5, "");
+}


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


Re: [PATCH] D12446: [PATCH] Enable clang-tidy misc-static-assert for C11

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

Thanks! I've commit in r246494 and r246495.


http://reviews.llvm.org/D12446



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


Re: [PATCH] D11582: Fix assertion failure in TransformOpaqueValueExpr

2015-08-31 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Sorry for the delay, LGTM.


http://reviews.llvm.org/D11582



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


Re: [PATCH] D12002: Initial WebAssembly support in clang

2015-08-31 Thread Dan Gohman via cfe-commits
sunfish added a comment.

Thanks for the review!



Comment at: include/clang/Basic/TargetCXXABI.h:166
@@ -148,1 +165,3 @@
 
+  /// \brief Are member functions differently aligned?
+  bool areMemberFunctionsAligned() const {

echristo wrote:
> Can you elaborate on the comment here as to what the alignment here means or 
> something? It looks incomplete otherwise.
Ok, I'll add a longer comment.


Comment at: lib/Basic/Targets.cpp:6935-6941
@@ +6934,9 @@
+  if (Feature == "+simd128") {
+SIMDLevel = std::max(SIMDLevel, SIMD128);
+continue;
+  }
+  if (Feature == "-simd128") {
+SIMDLevel = std::min(SIMDLevel, SIMDEnum(SIMD128 - 1));
+continue;
+  }
+

echristo wrote:
> Might make sense to copy the x86 bits here?
The x86 bits don't handle "-" attributes, so it's not directly applicable.


Comment at: lib/Basic/Targets.cpp:7633-7658
@@ -7464,1 +7632,28 @@
   }
+  case llvm::Triple::wasm32: {
+// Until specific variations are defined, don't permit any.
+if (Triple.getSubArch() != llvm::Triple::NoSubArch ||
+Triple.getVendor() != llvm::Triple::UnknownVendor ||
+Triple.getOS() != llvm::Triple::UnknownOS ||
+Triple.getEnvironment() != llvm::Triple::UnknownEnvironment ||
+Triple.getObjectFormat() != llvm::Triple::UnknownObjectFormat ||
+(!Triple.getVendorName().empty() &&
+ Triple.getVendorName() != "unknown") ||
+(!Triple.getOSName().empty() && Triple.getOSName() != "unknown") ||
+(Triple.hasEnvironment() && Triple.getEnvironmentName() != "unknown"))
+  return nullptr;
+return new WebAssemblyOSTargetInfo(Triple);
+  }
+  case llvm::Triple::wasm64: {
+// Until specific variations are defined, don't permit any.
+if (Triple.getSubArch() != llvm::Triple::NoSubArch ||
+Triple.getVendor() != llvm::Triple::UnknownVendor ||
+Triple.getOS() != llvm::Triple::UnknownOS ||
+Triple.getEnvironment() != llvm::Triple::UnknownEnvironment ||
+Triple.getObjectFormat() != llvm::Triple::UnknownObjectFormat ||
+(!Triple.getVendorName().empty() &&
+ Triple.getVendorName() != "unknown") ||
+(!Triple.getOSName().empty() && Triple.getOSName() != "unknown") ||
+(Triple.hasEnvironment() && Triple.getEnvironmentName() != "unknown"))
+  return nullptr;
+return new WebAssemblyOSTargetInfo(Triple);

echristo wrote:
> Seems overly complicated? Maybe just a positive test?
Good idea. I'll do that.


Comment at: lib/CodeGen/CodeGenModule.cpp:824
@@ +823,3 @@
+  if (getTarget().getCXXABI().areMemberFunctionsAligned()) {
+// C++ ABI requires 2-byte alignment for member functions.
+if (F->getAlignment() < 2 && isa(D))

echristo wrote:
> Update the comment?
Ok, I'll write a bit more here.


Comment at: lib/Driver/ToolChains.cpp:3853-3873
@@ +3852,23 @@
+
+bool WebAssembly::IsMathErrnoDefault() const { return false; }
+
+bool WebAssembly::IsObjCNonFragileABIDefault() const { return true; }
+
+bool WebAssembly::UseObjCMixedDispatch() const { return true; }
+
+bool WebAssembly::isPICDefault() const { return false; }
+
+bool WebAssembly::isPIEDefault() const { return false; }
+
+bool WebAssembly::isPICDefaultForced() const { return false; }
+
+bool WebAssembly::IsIntegratedAssemblerDefault() const { return true; }
+
+// TODO: Support Objective C stuff.
+bool WebAssembly::SupportsObjCGC() const { return false; }
+
+bool WebAssembly::hasBlocksRuntime() const { return false; }
+
+// TODO: Support profiling.
+bool WebAssembly::SupportsProfiling() const { return false; }
+

echristo wrote:
> No generic defaults here? Might also make sense to have these all inline if 
> they're just return true/return false.
All these functions are returning non-default values or are overriding pure 
virtual functions.

And they're outline because they're virtual overrides, so there's little 
optimization advantage to defining them in the header. And it's what most of 
the other toolchain definitions do most of the time.


Comment at: lib/Driver/Tools.cpp:1564-1569
@@ +1563,8 @@
+
+#ifdef __wasm__
+// Handle "native" by examining the host. "native" isn't meaningful when
+// cross compiling, so only support this when the host is also WebAssembly.
+if (CPU == "native")
+  return llvm::sys::getHostCPUName();
+#endif
+

echristo wrote:
> I really dislike the idea of an ifdef here for this behavior. Can you explain 
> some more? :)
As we discussed on IRC, I'll remove this code for now.


Repository:
  rL LLVM

http://reviews.llvm.org/D12002



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


Re: [PATCH] D12301: [PATCH] New checker for UB in handler of a function-try-block

2015-08-31 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Couple of thoughts, but LGTM.



Comment at: lib/Sema/SemaExprMember.cpp:889
@@ +888,3 @@
+S = S->getParent();
+  } while (S != S->getFnParent());
+  return false;

Maybe convert from a do-while into a while loop (or even a for loop)? We might 
not be in a function at all (for instance, we might be in a default member 
initializer), and that would let us bail out earlier in that case.


Comment at: lib/Sema/SemaExprMember.cpp:969-972
@@ +968,6 @@
+  if (S && BaseExpr && isa(BaseExpr->IgnoreImpCasts()) &&
+  IsInFnTryBlockHandler(S)) {
+const auto *FD = getCurFunctionDecl();
+bool IsDestructor = isa(FD);
+if (IsDestructor || isa(FD)) {
+  Diag(MemberLoc, diag::warn_cdtor_function_try_handler_mem_expr)

The `FD` checks are cheaper than the scope check; maybe reorder this to check 
the kind of the function first?


http://reviews.llvm.org/D12301



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


Re: [PATCH] D12002: Initial WebAssembly support in clang

2015-08-31 Thread Dan Gohman via cfe-commits
sunfish updated this revision to Diff 33637.
sunfish added a comment.

Updated to address review comments:

- added comments
- simplified Triple validation code
- removed -mcpu="native" code


Repository:
  rL LLVM

http://reviews.llvm.org/D12002

Files:
  include/clang/Basic/BuiltinsWebAssembly.def
  include/clang/Basic/TargetBuiltins.h
  include/clang/Basic/TargetCXXABI.h
  include/clang/Driver/Options.td
  include/clang/module.modulemap
  lib/AST/ASTContext.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/CodeGen/align-wasm.c
  test/CodeGen/builtins-wasm.c
  test/CodeGen/target-data.c
  test/CodeGen/wasm-arguments.c
  test/CodeGen/wasm-regparm.c
  test/CodeGenCXX/constructor-destructor-return-this.cpp
  test/CodeGenCXX/member-alignment.cpp
  test/CodeGenCXX/member-function-pointers.cpp
  test/CodeGenCXX/static-init-wasm.cpp
  test/CodeGenCXX/wasm-args-returns.cpp
  test/Driver/thread-model.c
  test/Driver/wasm32-unknown-unknown.cpp
  test/Driver/wasm64-unknown-unknown.cpp
  test/Preprocessor/init.c
  test/Preprocessor/wasm-target-features.c

Index: test/Preprocessor/wasm-target-features.c
===
--- test/Preprocessor/wasm-target-features.c
+++ test/Preprocessor/wasm-target-features.c
@@ -0,0 +1,35 @@
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -msimd128 \
+// RUN:   | FileCheck %s -check-prefix=SIMD128
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -msimd128 \
+// RUN:   | FileCheck %s -check-prefix=SIMD128
+//
+// SIMD128:#define __wasm_simd128__ 1{{$}}
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mcpu=mvp \
+// RUN:   | FileCheck %s -check-prefix=MVP
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mcpu=mvp \
+// RUN:   | FileCheck %s -check-prefix=MVP
+//
+// MVP-NOT:#define __wasm_simd128__
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mcpu=bleeding-edge \
+// RUN:   | FileCheck %s -check-prefix=BLEEDING_EDGE
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mcpu=bleeding-edge \
+// RUN:   | FileCheck %s -check-prefix=BLEEDING_EDGE
+//
+// BLEEDING_EDGE:#define __wasm_simd128__ 1{{$}}
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mcpu=bleeding-edge -mno-simd128 \
+// RUN:   | FileCheck %s -check-prefix=BLEEDING_EDGE_NO_SIMD128
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mcpu=bleeding-edge -mno-simd128 \
+// RUN:   | FileCheck %s -check-prefix=BLEEDING_EDGE_NO_SIMD128
+//
+// BLEEDING_EDGE_NO_SIMD128-NOT:#define __wasm_simd128__
Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8419,3 +8419,635 @@
 // XCORE:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
 // XCORE:#define __LITTLE_ENDIAN__ 1
 // XCORE:#define __XS1B__ 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=wasm32-unknown-unknown \
+// RUN:   < /dev/null \
+// RUN:   | FileCheck -check-prefix=WEBASSEMBLY32 %s
+//
+// WEBASSEMBLY32:#define _ILP32 1{{$}}
+// WEBASSEMBLY32-NOT:#define _LP64
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_ACQUIRE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_ACQ_REL 4{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_CONSUME 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_RELAXED 0{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_RELEASE 3{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_SEQ_CST 5{{$}}
+// WEBASSEMBLY32-NEXT:#define __BIGGEST_ALIGNMENT__ 16{{$}}
+// WEBASSEMBLY32-NEXT:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__{{$}}
+// WEBASSEMBLY32-NEXT:#define __CHAR16_TYPE__ unsigned short{{$}}
+// WEBASSEMBLY32-NEXT:#define __CHAR32_TYPE__ unsigned int{{$}}
+// WEBASSEMBLY32-NEXT:#define __CHAR_BIT__ 8{{$}}
+// WEBASSEMBLY32-NOT:#define __CHAR_UNSIGNED__
+// WEBASSEMBLY32-NEXT:#define __CONSTANT_CFSTRINGS__ 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_DECIMAL_DIG__ 17{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_DIG__ 15{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_EPSILON__ 2.2204460492503131e-16{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_HAS_DENORM__ 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_HAS_INFINITY__ 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_HAS_QUIET_NAN__ 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_MANT_DIG__ 53{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_MAX_10_EXP__ 308{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_MAX_EXP__ 1024{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_MAX__ 1.7976931348623157e+308{{$}}
+// W

r246497 - [modules] Rework serialized DeclContext lookup table management. Instead of

2015-08-31 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Aug 31 17:17:11 2015
New Revision: 246497

URL: http://llvm.org/viewvc/llvm-project?rev=246497&view=rev
Log:
[modules] Rework serialized DeclContext lookup table management. Instead of
walking the loaded ModuleFiles looking for lookup tables for the context, store
them all in one place, and merge them together if we find we have too many
(currently, more than 4). If we do merge, include the merged form in our
serialized lookup table, so that downstream readers never need to look at our
imports' tables.

This gives a huge performance improvement to builds with very large numbers of
modules (in some cases, more than a 2x speedup was observed).

Added:
cfe/trunk/lib/Serialization/MultiOnDiskHashTable.h
Modified:
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/include/clang/Serialization/Module.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderInternals.h
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/lib/Serialization/Module.cpp
cfe/trunk/test/Modules/cxx-templates.cpp
cfe/trunk/test/Modules/merge-using-decls.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=246497&r1=246496&r2=246497&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Mon Aug 31 17:17:11 2015
@@ -1530,4 +1530,23 @@ namespace clang {
   }
 } // end namespace clang
 
+namespace llvm {
+  template <> struct DenseMapInfo {
+static clang::serialization::DeclarationNameKey getEmptyKey() {
+  return clang::serialization::DeclarationNameKey(-1, 1);
+}
+static clang::serialization::DeclarationNameKey getTombstoneKey() {
+  return clang::serialization::DeclarationNameKey(-1, 2);
+}
+static unsigned
+getHashValue(const clang::serialization::DeclarationNameKey &Key) {
+  return Key.getHash();
+}
+static bool isEqual(const clang::serialization::DeclarationNameKey &L,
+const clang::serialization::DeclarationNameKey &R) {
+  return L == R;
+}
+  };
+}
+
 #endif

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=246497&r1=246496&r2=246497&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Mon Aug 31 17:17:11 2015
@@ -282,9 +282,8 @@ class ReadMethodPoolVisitor;
 
 namespace reader {
   class ASTIdentifierLookupTrait;
-  /// \brief The on-disk hash table used for the DeclContext's Name lookup 
table.
-  typedef llvm::OnDiskIterableChainedHashTable
-ASTDeclContextNameLookupTable;
+  /// \brief The on-disk hash table(s) used for DeclContext name lookup.
+  struct DeclContextLookupTable;
 }
 
 } // end namespace serialization
@@ -507,6 +506,10 @@ private:
   /// \brief Map from the TU to its lexical contents from each module file.
   std::vector> TULexicalDecls;
 
+  /// \brief Map from a DeclContext to its lookup tables.
+  llvm::DenseMap Lookups;
+
   // Updates for visible decls can occur for other contexts than just the
   // TU, and when we read those update records, the actual context may not
   // be available yet, so have this pending map using the ID as a key. It
@@ -514,7 +517,6 @@ private:
   struct PendingVisibleUpdate {
 ModuleFile *Mod;
 const unsigned char *Data;
-unsigned BucketOffset;
   };
   typedef SmallVector DeclContextVisibleUpdates;
 
@@ -1089,6 +1091,10 @@ public:
 Visit(GetExistingDecl(ID));
   }
 
+  /// \brief Get the loaded lookup tables for \p Primary, if any.
+  const serialization::reader::DeclContextLookupTable *
+  getLoadedLookupTables(DeclContext *Primary) const;
+
 private:
   struct ImportedModule {
 ModuleFile *Mod;
@@ -1870,6 +1876,13 @@ public:
   /// Note: overrides method in ExternalASTSource
   Module *getModule(unsigned ID) override;
 
+  /// \brief Retrieve the module file with a given local ID within the 
specified
+  /// ModuleFile.
+  ModuleFile *getLocalModuleFile(ModuleFile &M, unsigned ID);
+
+  /// \brief Get an ID for the given module file.
+  unsigned getModuleFileID(ModuleFile *M);
+
   /// \brief Return a descriptor for the corresponding module.
   llvm::Optional getSourceDescriptor(unsigned ID) 
override;
   /// \brief Return a descriptor for the module.

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/tr

Re: [PATCH] D12471: Correct documentation for numSelectorArgs matcher

2015-08-31 Thread Dave Lee via cfe-commits
kastiglione added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:2140-2153
@@ -2139,16 +2139,16 @@
 
 /// \brief Matches when the selector has the specified number of arguments
 ///
-///  matcher = objCMessageExpr(numSelectorArgs(1));
+///  matcher = objCMessageExpr(numSelectorArgs(0));
 ///  matches self.bodyView in the code below
 ///
 ///  matcher = objCMessageExpr(numSelectorArgs(2));
 ///  matches the invocation of "loadHTMLString:baseURL:" but not that
 ///  of self.bodyView
 /// \code
 /// [self.bodyView loadHTMLString:html baseURL:NULL];
 /// \endcode
 AST_MATCHER_P(ObjCMessageExpr, numSelectorArgs, unsigned, N) {
   return Node.getSelector().getNumArgs() == N;
 }


klimek wrote:
> It seems like numSelectorArgs is missing unit tests - it might be good to add 
> one, so we're sure the documented version now works and is tested :)
Thanks @klimek. Where are tests for ASTMatchers? I'm new to the codebase, I 
grepped for "matcher" in test/ but there are no relevant files.


http://reviews.llvm.org/D12471



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


Re: [PATCH] fix parentheses location in a CXXConstructExpr

2015-08-31 Thread Olivier Goffart via cfe-commits
On Monday 31. August 2015 08:07:58 Manuel Klimek wrote:
> On Sat, Aug 29, 2015 at 12:23 PM Olivier Goffart via cfe-commits <
> 
> cfe-commits@lists.llvm.org> wrote:
> > Hi,
> > 
> > Please review the attached patch.
> > 
> > In Sema::BuildCXXFunctionalCastExpr, if the class has a destructor, the
> > Op.SrcExpr might be a CXXBindTemporaryExpr which we need to unwrap.
> > 
> > In the testcase, the first new CHECK worked (because A does not have a
> > destructor),  but the second CHECK failed (did not include the last
> > parenthese) because D has a destructor.
> > 
> > I used dyn_cast_or_null just to be safe, becasue i don't know if it is
> > possible for the BindExpr->getSubExpr() to be null.
> 
> Do you know why the added test for A says 'class foo::A' instead of
> 'foo::A' as the other tests do in that file?

I don't know.  It seems it has to do with the fully quallified name vs. normal 
name.

For example, if you dumpt the AST of:

 namespace foo { class A {} *a1 = new foo::A , *a2 = new A; }

You get:

[...]
| |-VarDecl 0x1c9a7a0  col:29 a1 'class A *' cinit
| | `-CXXNewExpr 0x1ce2648  'foo::A *'
| |   `-CXXConstructExpr 0x1ce2618  'foo::A':'class foo::A' 'void 
(void) throw()'
| `-VarDecl 0x1ce26d0  col:48 a2 'class A *' cinit
|   `-CXXNewExpr 0x1ce2768  'class foo::A *'
| `-CXXConstructExpr 0x1ce2738  'class foo::A' 'void (void) 
throw()'


As you can see, when the type of CXXNewExpr is fully quialified, the 'class' 
keyword is omited, but for a2, it prints the 'class' keyword.
The printed type of CXXConstructExpr is even more wierd when it is fully 
qualified.


I guess that's because of ElaboratedTypePolicyRAII in TypePrinter.cpp

But this is irrelevant for this patch and the problem it's trying to solve.
The reason I used 'using namespace foo' in the test was just so the line with 
A and D have the same size.   I just copy pasted the thing without thinking 
about that.

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


r246504 - [modules] Add some missing blockinfo records.

2015-08-31 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Aug 31 17:43:10 2015
New Revision: 246504

URL: http://llvm.org/viewvc/llvm-project?rev=246504&view=rev
Log:
[modules] Add some missing blockinfo records.

Modified:
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=246504&r1=246503&r2=246504&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Mon Aug 31 17:43:10 2015
@@ -344,7 +344,7 @@ namespace clang {
 
   /// \brief This is so that older clang versions, before the introduction
   /// of the control block, can read and reject the newer PCH format.
-  /// *DON"T CHANGE THIS NUMBER*.
+  /// *DON'T CHANGE THIS NUMBER*.
   METADATA_OLD_FORMAT = 4,
 
   /// \brief Record code for the identifier table.

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=246504&r1=246503&r2=246504&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Aug 31 17:43:10 2015
@@ -877,6 +877,7 @@ void ASTWriter::WriteBlockInfoBlock() {
   RECORD(METADATA);
   RECORD(SIGNATURE);
   RECORD(MODULE_NAME);
+  RECORD(MODULE_DIRECTORY);
   RECORD(MODULE_MAP_FILE);
   RECORD(IMPORTS);
   RECORD(LANGUAGE_OPTIONS);
@@ -903,14 +904,15 @@ void ASTWriter::WriteBlockInfoBlock() {
   RECORD(SPECIAL_TYPES);
   RECORD(STATISTICS);
   RECORD(TENTATIVE_DEFINITIONS);
-  RECORD(UNUSED_FILESCOPED_DECLS);
   RECORD(SELECTOR_OFFSETS);
   RECORD(METHOD_POOL);
   RECORD(PP_COUNTER_VALUE);
   RECORD(SOURCE_LOCATION_OFFSETS);
   RECORD(SOURCE_LOCATION_PRELOADS);
   RECORD(EXT_VECTOR_DECLS);
+  RECORD(UNUSED_FILESCOPED_DECLS);
   RECORD(PPD_ENTITIES_OFFSETS);
+  RECORD(VTABLE_USES);
   RECORD(REFERENCED_SELECTOR_POOL);
   RECORD(TU_UPDATE_LEXICAL);
   RECORD(SEMA_DECL_REFS);
@@ -928,7 +930,6 @@ void ASTWriter::WriteBlockInfoBlock() {
   RECORD(OPENCL_EXTENSIONS);
   RECORD(DELEGATING_CTORS);
   RECORD(KNOWN_NAMESPACES);
-  RECORD(UNDEFINED_BUT_USED);
   RECORD(MODULE_OFFSET_MAP);
   RECORD(SOURCE_MANAGER_LINE_TABLE);
   RECORD(OBJC_CATEGORIES_MAP);
@@ -936,8 +937,13 @@ void ASTWriter::WriteBlockInfoBlock() {
   RECORD(IMPORTED_MODULES);
   RECORD(OBJC_CATEGORIES);
   RECORD(MACRO_OFFSET);
+  RECORD(INTERESTING_IDENTIFIERS);
+  RECORD(UNDEFINED_BUT_USED);
   RECORD(LATE_PARSED_TEMPLATE);
   RECORD(OPTIMIZE_PRAGMA_OPTIONS);
+  RECORD(UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES);
+  RECORD(CXX_CTOR_INITIALIZERS_OFFSETS);
+  RECORD(DELETE_EXPRS_TO_ANALYZE);
 
   // SourceManager Block.
   BLOCK(SOURCE_MANAGER_BLOCK);
@@ -954,6 +960,29 @@ void ASTWriter::WriteBlockInfoBlock() {
   RECORD(PP_MODULE_MACRO);
   RECORD(PP_TOKEN);
 
+  // Submodule Block.
+  BLOCK(SUBMODULE_BLOCK);
+  RECORD(SUBMODULE_METADATA);
+  RECORD(SUBMODULE_DEFINITION);
+  RECORD(SUBMODULE_UMBRELLA_HEADER);
+  RECORD(SUBMODULE_HEADER);
+  RECORD(SUBMODULE_TOPHEADER);
+  RECORD(SUBMODULE_UMBRELLA_DIR);
+  RECORD(SUBMODULE_IMPORTS);
+  RECORD(SUBMODULE_EXPORTS);
+  RECORD(SUBMODULE_REQUIRES);
+  RECORD(SUBMODULE_EXCLUDED_HEADER);
+  RECORD(SUBMODULE_LINK_LIBRARY);
+  RECORD(SUBMODULE_CONFIG_MACRO);
+  RECORD(SUBMODULE_CONFLICT);
+  RECORD(SUBMODULE_PRIVATE_HEADER);
+  RECORD(SUBMODULE_TEXTUAL_HEADER);
+  RECORD(SUBMODULE_PRIVATE_TEXTUAL_HEADER);
+
+  // Comments Block.
+  BLOCK(COMMENTS_BLOCK);
+  RECORD(COMMENTS_RAW_COMMENT);
+
   // Decls and Types block.
   BLOCK(DECLTYPES_BLOCK);
   RECORD(TYPE_EXT_QUAL);


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


Re: [PATCH] D12453: [CUDA] Allow function overloads based on host/device attributes.

2015-08-31 Thread Eli Bendersky via cfe-commits
eliben added inline comments.


Comment at: include/clang/Sema/Sema.h:8599
@@ +8598,3 @@
+CFP_Never,  // Invalid caller/callee combination.
+CFP_LastResort, // same as CFP_Never or CFP_Fallback, depending on
+// -fcuda-disable-target-call-checks option

The comment should explain exactly how it depends on the option


Comment at: lib/AST/ItaniumMangle.cpp:504
@@ +503,3 @@
+  if (FD->hasAttr() && FD->hasAttr())
+Out << "Ua6deviceUa4host";
+

Why device before host?


Comment at: lib/Sema/SemaCUDA.cpp:98
@@ +97,3 @@
+  CUDAFunctionTarget CallerTarget =
+ Caller ? IdentifyCUDATarget(Caller) : Sema::CFT_Host,
+ CalleeTarget = IdentifyCUDATarget(Callee);

Why allow Caller to be nullptr but not Callee? Also, != nullptr?


Comment at: lib/Sema/SemaExprCXX.cpp:2277
@@ +2276,3 @@
+Matches.set_size(N);
+  } else
+++I;

Nit: wrap the ++I in braces too, otherwise this looks really weird


http://reviews.llvm.org/D12453



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


[PATCH] D12505: [X86] Set MaxVectorAlign for non-Darwin targets as well.

2015-08-31 Thread Ahmed Bougacha via cfe-commits
ab created this revision.
ab added reviewers: echristo, rnk.
ab added subscribers: alexr, dim, dschuff, tberghammer, cfe-commits.

Follow-up to r246229: this isn't Darwin-specific, so let's enable it for all 
X86 targets.

Quoting r160209, which introduced it:

```
Currently, if no aligned attribute is specified the alignment of a vector is 
inferred from its size.  Thus, very large vectors will be over-aligned with no 
benefit.

```

I tried to cc people for the various OSes we support; if you object or can 
suggest other reviewers, please do!

http://reviews.llvm.org/D12505

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/const-init.c
  test/CodeGen/vector-alignment.c
  test/CodeGen/x86-vector-alignment.c
  test/CodeGen/x86_64-arguments.c

Index: test/CodeGen/x86_64-arguments.c
===
--- test/CodeGen/x86_64-arguments.c
+++ test/CodeGen/x86_64-arguments.c
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | \
 // RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=SSE -check-prefix=NO-AVX512
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-feature +avx | \
-// RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=NO-AVX512
+// RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVXUP -check-prefix=NO-AVX512
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-feature +avx512f | \
-// RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX512
+// RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=AVXUP -check-prefix=AVX512
 #include 
 
 // CHECK-LABEL: define signext i8 @f0()
@@ -197,16 +197,16 @@
 };
 
 struct v8f32wrapper f27a(struct v8f32wrapper X) {
-  // AVX-LABEL: define <8 x float> @f27a(<8 x float> %X.coerce)
+  // AVXUP-LABEL: define <8 x float> @f27a(<8 x float> %X.coerce)
   return X;
 }
 
 struct v8f32wrapper_wrapper {
   v8f32 v[1];
 };
 
 struct v8f32wrapper_wrapper f27b(struct v8f32wrapper_wrapper X) {
-  // AVX-LABEL: define <8 x float> @f27b(<8 x float> %X.coerce)
+  // AVXUP-LABEL: define <8 x float> @f27b(<8 x float> %X.coerce)
   return X;
 }
 
@@ -290,10 +290,10 @@
 typedef unsigned v2i32 __attribute((__vector_size__(8)));
 v2i32 f36(v2i32 arg) { return arg; }
 
-// AVX: declare void @f38(<8 x float>)
-// AVX: declare void @f37(<8 x float>)
-// SSE: declare void @f38(%struct.s256* byval align 32)
-// SSE: declare void @f37(<8 x float>* byval align 32)
+// AVXUP: declare void @f38(<8 x float>)
+// AVXUP: declare void @f37(<8 x float>)
+// SSE: declare void @f38(%struct.s256* byval align 16)
+// SSE: declare void @f37(<8 x float>* byval align 16)
 typedef float __m256 __attribute__ ((__vector_size__ (32)));
 typedef struct {
   __m256 m;
@@ -336,7 +336,8 @@
 
 // CHECK-LABEL: define i32 @f44
 // CHECK: ptrtoint
-// CHECK-NEXT: and {{.*}}, -32
+// SSE-NEXT: and {{.*}}, -16
+// AVXUP-NEXT: and {{.*}}, -32
 // CHECK-NEXT: inttoptr
 typedef int T44 __attribute((vector_size(32)));
 struct s44 { T44 x; int y; };
@@ -349,17 +350,17 @@
 }
 
 // Text that vec3 returns the correct LLVM IR type.
-// AVX-LABEL: define i32 @foo(<3 x i64> %X)
+// AVXUP-LABEL: define i32 @foo(<3 x i64> %X)
 typedef long long3 __attribute((ext_vector_type(3)));
 int foo(long3 X)
 {
   return 0;
 }
 
 // Make sure we don't use a varargs convention for a function without a
 // prototype where AVX types are involved.
-// AVX: @test45
-// AVX: call i32 bitcast (i32 (...)* @f45 to i32 (<8 x float>)*)
+// AVXUP: @test45
+// AVXUP: call i32 bitcast (i32 (...)* @f45 to i32 (<8 x float>)*)
 int f45();
 __m256 x45;
 void test45() { f45(x45); }
@@ -443,23 +444,23 @@
 void test52() {
   test52_helper(0, x52, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0i);
 }
-// AVX: @test52_helper(i32 0, <8 x float> {{%[a-zA-Z0-9]+}}, double 1.00e+00, double 1.00e+00, double 1.00e+00, double 1.00e+00, double 1.00e+00, double 1.00e+00, double {{%[a-zA-Z0-9]+}}, double {{%[a-zA-Z0-9]+}})
+// AVXUP: @test52_helper(i32 0, <8 x float> {{%[a-zA-Z0-9]+}}, double 1.00e+00, double 1.00e+00, double 1.00e+00, double 1.00e+00, double 1.00e+00, double 1.00e+00, double {{%[a-zA-Z0-9]+}}, double {{%[a-zA-Z0-9]+}})
 
 void test53(__m256 *m, __builtin_va_list argList) {
   *m = __builtin_va_arg(argList, __m256);
 }
-// AVX-LABEL: define void @test53
-// AVX-NOT: br i1
-// AVX: ret void
+// AVXUP-LABEL: define void @test53
+// AVXUP-NOT: br i1
+// AVXUP: ret void
 
 void test54_helper(__m256, ...);
 __m256 x54;
 void test54() {
   test54_helper(x54, x54, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0i);
   test54_helper(x54, x54, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0i);
 }
-// AVX: @test54_helper(<8 x float> {{%[a-zA-Z0-9]+}}, <8 x float> {{%[a-zA-Z0-9]+}}, double 1.00e+00, double 1.00e+00, double 1.00e+00, double 1.00e+00, double 1.00e+00, double {{%[a-zA-Z0-9]+}}, double {{%[a-zA-Z0-9]+}})
-// AVX: @test54_helper(<8 x fl

Re: r246468 - Pull the target attribute parsing out of CGCall and onto TargetInfo.

2015-08-31 Thread Hans Wennborg via cfe-commits
This change makes Basic depend on AST.

The immediate problem I'm hitting is clang-format (which uses Basic
but not AST) failing to link on Windows [1], but I suspect this could
cause problems elsewhere too.

Is there some way to avoid this dependency?

 [1]. 
http://build.chromium.org/p/chromium.fyi/builders/ClangToTWin/builds/2903/steps/gclient%20runhooks/logs/stdio

On Mon, Aug 31, 2015 at 11:39 AM, Eric Christopher via cfe-commits
 wrote:
> Author: echristo
> Date: Mon Aug 31 13:39:22 2015
> New Revision: 246468
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246468&view=rev
> Log:
> Pull the target attribute parsing out of CGCall and onto TargetInfo.
>
> Also:
>   - Add a typedef to make working with the result easier.
>   - Update callers to use the new function.
>   - Make initFeatureMap out of line.
>
> Modified:
> cfe/trunk/include/clang/Basic/TargetInfo.h
> cfe/trunk/lib/Basic/TargetInfo.cpp
> cfe/trunk/lib/CodeGen/CGCall.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11361: [OpenMP] Target directive host codegen

2015-08-31 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 33640.
sfantao added a comment.

Address last review comments.


http://reviews.llvm.org/D11361

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/target_codegen.cpp

Index: test/OpenMP/target_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_codegen.cpp
@@ -0,0 +1,753 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[TT:%.+]] = type { i64, i8 }
+// CHECK-DAG: [[S1:%.+]] = type { double }
+
+// We have 8 target regions, but only 7 that actually will generate offloading
+// code, only 6 will have mapped arguments, and only 4 have all-constant map
+// sizes.
+
+// CHECK-DAG: [[SIZET2:@.+]] = private unnamed_addr constant [1 x i{{32|64}}] [i[[SZ:32|64]] 2]
+// CHECK-DAG: [[MAPT2:@.+]] = private unnamed_addr constant [1 x i32] [i32 3]
+// CHECK-DAG: [[SIZET3:@.+]] = private unnamed_addr constant [2 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2]
+// CHECK-DAG: [[MAPT3:@.+]] = private unnamed_addr constant [2 x i32] [i32 3, i32 3]
+// CHECK-DAG: [[MAPT4:@.+]] = private unnamed_addr constant [9 x i32] [i32 3, i32 3, i32 1, i32 3, i32 3, i32 1, i32 1, i32 3, i32 3]
+// CHECK-DAG: [[SIZET5:@.+]] = private unnamed_addr constant [3 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2, i[[SZ]] 40]
+// CHECK-DAG: [[MAPT5:@.+]] = private unnamed_addr constant [3 x i32] [i32 3, i32 3, i32 3]
+// CHECK-DAG: [[SIZET6:@.+]] = private unnamed_addr constant [4 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2, i[[SZ]] 1, i[[SZ]] 40]
+// CHECK-DAG: [[MAPT6:@.+]] = private unnamed_addr constant [4 x i32] [i32 3, i32 3, i32 3, i32 3]
+// CHECK-DAG: [[MAPT7:@.+]] = private unnamed_addr constant [5 x i32] [i32 3, i32 3, i32 1, i32 1, i32 3]
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+
+template
+struct TT{
+  tx X;
+  ty Y;
+};
+
+// CHECK: define {{.*}}[[FOO:@.+]](
+int foo(int n) {
+  int a = 0;
+  short aa = 0;
+  float b[10];
+  float bn[n];
+  double c[5][10];
+  double cn[5][n];
+  TT d;
+
+  // CHECK:   br label %[[TRY:[^,]+]]
+  // CHECK:   [[TRY]]
+  // CHECK:   [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, i32 0, i8** null, i8** null, i[[SZ]]* null, i32* null)
+  // CHECK-NEXT:  [[ERROR:%.+]] = icmp ne i32 [[RET]], 0
+  // CHECK-NEXT:  br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]]
+  // CHECK:   [[FAIL]]
+  // CHECK:   call void [[HVT0:@.+]]()
+  // CHECK-NEXT:  br label %[[END]]
+  // CHECK:   [[END]]
+  #pragma omp target
+  {
+  }
+
+  // CHECK:   call void [[HVT1:@.+]](i32* {{[^,]+}})
+  #pragma omp target if(0)
+  {
+a += 1;
+  }
+
+  // CHECK:   br label %[[TRY:[^,]+]]
+  // CHECK:   [[TRY]]
+  // CHECK-DAG:   [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, i32 1, i8** [[BP:%[^,]+]], i8** [[P:%[^,]+]], i[[SZ]]* getelementptr inbounds ([1 x i[[SZ]]], [1 x i[[SZ]]]* [[SIZET2]], i32 0, i32 0), i32* getelementptr inbounds ([1 x i32], [1 x i32]* [[MAPT2]], i32 0, i32 0))
+  // CHECK-DAG:   [[BP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPR:%[^,]+]], i32 0, i32 0
+  // CHECK-DAG:   [[P]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PR:%[^,]+]], i32 0, i32 0
+  // CHECK-DAG:   [[BPADDR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPR]], i32 0, i32 [[IDX0:[0-9]+]]
+  // CHECK-DAG:   [[PADDR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PR]], i32 0, i32 [[IDX0]]
+  // CHECK-DAG:   store i8* [[BP0:%[^,]+]], i8** [[BPADDR0]]
+  // CHECK-DAG:   store i8* [[P0:%[^,]+]], i8** [[PADDR0]]
+  // CHECK-DAG:   [[BP0]] = bitcast i16* %{{.+}} to i8*
+  // CHECK-DAG:   [[P0]] = bitcast i16* %{{.+}} to i8*
+
+  // CHECK:   [[ERROR:%.+]] = icmp ne i32 [[RET]], 0
+  // CHECK-NEXT:  br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]]
+  // CHECK:   [[FAIL]]
+  // CHECK:   call void [[HVT2:@.+]](i16* {{[^,]+}})
+  // CHECK-NEXT:  br label %[[END]]
+  // CHECK:   [[END]]
+  #pragma omp targe

Re: [PATCH] D11361: [OpenMP] Target directive host codegen

2015-08-31 Thread Samuel Antao via cfe-commits
sfantao added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2991-3005
@@ +2990,17 @@
+
+/// \brief Values for bit flags used to specify the mapping type for
+/// offloading.
+enum OpenMPOffloadMappingFlags {
+  /// \brief Allocate memory on the device and move data from host to device.
+  OMP_MAP_TO = 0x01,
+  /// \brief Allocate memory on the device and move data from device to host.
+  OMP_MAP_FROM = 0x02,
+};
+
+enum OpenMPOffloadingReservedDeviceIDs {
+  /// \brief Device ID if the device was not defined, runtime should get it
+  /// from environment variables in the spec.
+  OMP_DEVICEID_UNDEF = -1,
+};
+
+void CGOpenMPRuntime::emitTargetCall(CodeGenFunction &CGF,

ABataev wrote:
> Move them to CGOpenMPRuntime::emitTargetCall(), they can be made local
Ok, done!


Comment at: test/OpenMP/target_codegen.cpp:8
@@ +7,3 @@
+// expected-no-diagnostics
+// REQUIRES: powerpc-registered-target
+#ifndef HEADER

ABataev wrote:
> Some of your tests has triple i386, they don't need PowerPC target
True, I'm not using any target specific property here. So I guess it is safe to 
remove the requirement. Not using // REQUIRES anymore. Thanks.


http://reviews.llvm.org/D11361



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


  1   2   >