r259351 - clang-format: Fix alignment of trailing multiline columns.

2016-02-01 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Feb  1 05:20:55 2016
New Revision: 259351

URL: http://llvm.org/viewvc/llvm-project?rev=259351&view=rev
Log:
clang-format: Fix alignment of trailing multiline columns.

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

Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=259351&r1=259350&r2=259351&view=diff
==
--- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp Mon Feb  1 05:20:55 2016
@@ -372,16 +372,20 @@ void WhitespaceManager::alignTrailingCom
   unsigned CommentColumn = SourceMgr.getSpellingColumnNumber(
   Changes[i].OriginalWhitespaceRange.getEnd());
   for (unsigned j = i + 1; j != e; ++j) {
-if (Changes[j].Kind != tok::comment) { // Skip over comments.
-  unsigned NextColumn = SourceMgr.getSpellingColumnNumber(
-  Changes[j].OriginalWhitespaceRange.getEnd());
-  // The start of the next token was previously aligned with the
-  // start of this comment.
-  WasAlignedWithStartOfNextLine =
-  CommentColumn == NextColumn ||
-  CommentColumn == NextColumn + Style.IndentWidth;
-  break;
-}
+if (Changes[j].Kind == tok::comment ||
+Changes[j].Kind == tok::unknown)
+  // Skip over comments and unknown tokens. "unknown tokens are used 
for
+  // the continuation of multiline comments.
+  continue;
+
+unsigned NextColumn = SourceMgr.getSpellingColumnNumber(
+Changes[j].OriginalWhitespaceRange.getEnd());
+// The start of the next token was previously aligned with the
+// start of this comment.
+WasAlignedWithStartOfNextLine =
+CommentColumn == NextColumn ||
+CommentColumn == NextColumn + Style.IndentWidth;
+break;
   }
 }
 if (!Style.AlignTrailingComments || FollowsRBraceInColumn0) {

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=259351&r1=259350&r2=259351&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Feb  1 05:20:55 2016
@@ -962,6 +962,14 @@ TEST_F(FormatTest, UnderstandsSingleLine
"// at start\n"
"otherLine();"));
   EXPECT_EQ("lineWith(); // comment\n"
+"/*\n"
+" * at start */\n"
+"otherLine();",
+format("lineWith();   // comment\n"
+   "/*\n"
+   " * at start */\n"
+   "otherLine();"));
+  EXPECT_EQ("lineWith(); // comment\n"
 "// at start\n"
 "otherLine();",
 format("lineWith();   // comment\n"


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


r259353 - clang-format: Fix incorrect pointer detection in lambdas in constructor

2016-02-01 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Feb  1 05:21:07 2016
New Revision: 259353

URL: http://llvm.org/viewvc/llvm-project?rev=259353&view=rev
Log:
clang-format: Fix incorrect pointer detection in lambdas in constructor
initializers.

Before:
  Constructor() : member([](A *a, B * b) {}) {}

After:
  Constructor() : member([](A *a, B *b) {}) {}

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=259353&r1=259352&r2=259353&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Feb  1 05:21:07 2016
@@ -887,8 +887,8 @@ private:
Previous && Previous->isOneOf(tok::star, tok::amp);
Previous = Previous->Previous)
 Previous->Type = TT_PointerOrReference;
-  if (Line.MustBeDeclaration)
-Contexts.back().IsExpression = Contexts.front().InCtorInitializer;
+  if (Line.MustBeDeclaration && !Contexts.front().InCtorInitializer)
+Contexts.back().IsExpression = false;
 } else if (Current.Previous &&
Current.Previous->is(TT_CtorInitializerColon)) {
   Contexts.back().IsExpression = true;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=259353&r1=259352&r2=259353&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Feb  1 05:21:07 2016
@@ -5634,6 +5634,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
   verifyFormat("[](const decltype(*a) &value) {}");
   verifyFormat("decltype(a * b) F();");
   verifyFormat("#define MACRO() [](A *a) { return 1; }");
+  verifyFormat("Constructor() : member([](A *a, B *b) {}) {}");
   verifyIndependentOfContext("typedef void (*f)(int *a);");
   verifyIndependentOfContext("int i{a * b};");
   verifyIndependentOfContext("aaa && aaa->f();");


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


r259350 - clang-format: [JS] Treat "in" as a proper operator.

2016-02-01 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Feb  1 05:20:47 2016
New Revision: 259350

URL: http://llvm.org/viewvc/llvm-project?rev=259350&view=rev
Log:
clang-format: [JS] Treat "in" as a proper operator.

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=259350&r1=259349&r2=259350&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Feb  1 05:20:47 2016
@@ -1035,6 +1035,9 @@ private:
 
 if (Tok.Previous->isOneOf(TT_LeadingJavaAnnotation, 
Keywords.kw_instanceof))
   return false;
+if (Style.Language == FormatStyle::LK_JavaScript &&
+Tok.Previous->is(Keywords.kw_in))
+  return false;
 
 // Skip "const" as it does not have an influence on whether this is a name.
 FormatToken *PreviousNotConst = Tok.Previous;
@@ -1390,6 +1393,9 @@ private:
Style.Language == FormatStyle::LK_JavaScript) &&
   Current->is(Keywords.kw_instanceof))
 return prec::Relational;
+  if (Style.Language == FormatStyle::LK_JavaScript &&
+  Current->is(Keywords.kw_in))
+return prec::Relational;
   if (Current->is(TT_BinaryOperator) || Current->is(tok::comma))
 return Current->getPrecedence();
   if (Current->isOneOf(tok::period, tok::arrow))
@@ -2277,6 +2283,10 @@ bool TokenAnnotator::canBreakBefore(cons
   return true;
 if (Right.NestingLevel == 0 && Right.is(Keywords.kw_is))
   return false;
+if (Left.is(Keywords.kw_in))
+  return Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None;
+if (Right.is(Keywords.kw_in))
+  return Style.BreakBeforeBinaryOperators != FormatStyle::BOS_None;
   }
 
   if (Left.is(tok::at))

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=259350&r1=259349&r2=259350&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Feb  1 05:20:47 2016
@@ -86,6 +86,17 @@ TEST_F(FormatTestJS, UnderstandsJavaScri
 
   verifyFormat("var b = a.map((x) => x + 1);");
   verifyFormat("return ('aaa') in ;");
+  verifyFormat("var x = a() in\n"
+   ".aa.aa;");
+  FormatStyle Style = getGoogleJSStyleWithColumns(80);
+  Style.AlignOperands = true;
+  verifyFormat("var x = a() in\n"
+   ".aa.aa;",
+   Style);
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
+  verifyFormat("var x = a()\n"
+   "in 
.aa.aa;",
+   Style);
 
   // ES6 spread operator.
   verifyFormat("someFunction(...a);");


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


Re: [PATCH] D16219: PR8901: attribute "mode" rejected for enums and dependent types

2016-02-01 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla updated this revision to Diff 46521.
d.zobnin.bugzilla added a comment.

Thanks for the review!

Only updated the text of diagnostics, NFC.


http://reviews.llvm.org/D16219

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  include/clang/Sema/Sema.h
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CodeGen/attr-mode-enums.c
  test/CodeGenCXX/attr-mode-vector-types-tmpl.cpp
  test/Sema/attr-mode-enums.c
  test/Sema/attr-mode.c
  test/SemaCXX/attr-mode-tmpl.cpp

Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -227,6 +227,14 @@
 Attr.getSpellingListIndex());
 }
 
+static void
+instantiateDependentModeAttr(Sema &S,
+ const MultiLevelTemplateArgumentList &TemplateArgs,
+ const ModeAttr &Attr, Decl *New) {
+  S.AddModeAttr(Attr.getRange(), New, Attr.getMode(),
+Attr.getSpellingListIndex(), /*InInstantiation=*/true);
+}
+
 void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
 const Decl *Tmpl, Decl *New,
 LateInstantiatedAttrVec *LateAttrs,
@@ -265,6 +273,11 @@
   continue;
 }
 
+if (const ModeAttr *Mode = dyn_cast(TmplAttr)) {
+  instantiateDependentModeAttr(*this, TemplateArgs, *Mode, New);
+  continue;
+}
+
 // Existing DLL attribute on the instantiation takes precedence.
 if (TmplAttr->getKind() == attr::DLLExport ||
 TmplAttr->getKind() == attr::DLLImport) {
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3297,6 +3297,8 @@
 /// attribute.
 static void parseModeAttrArg(Sema &S, StringRef Str, unsigned &DestWidth,
  bool &IntegerMode, bool &ComplexMode) {
+  IntegerMode = true;
+  ComplexMode = false;
   switch (Str.size()) {
   case 2:
 switch (Str[0]) {
@@ -3363,9 +3365,15 @@
   }
 
   IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
-  StringRef Str = Name->getName();
 
+  S.AddModeAttr(Attr.getRange(), D, Name, Attr.getAttributeSpellingListIndex());
+}
+
+void Sema::AddModeAttr(SourceRange AttrRange, Decl *D, IdentifierInfo *Name,
+   unsigned SpellingListIndex, bool InInstantiation) {
+  StringRef Str = Name->getName();
   normalizeName(Str);
+  SourceLocation AttrLoc = AttrRange.getBegin();
 
   unsigned DestWidth = 0;
   bool IntegerMode = true;
@@ -3381,99 +3389,126 @@
 if (VectorStringLength &&
 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
 VectorSize.isPowerOf2()) {
-  parseModeAttrArg(S, Str.substr(VectorStringLength + 1), DestWidth,
+  parseModeAttrArg(*this, Str.substr(VectorStringLength + 1), DestWidth,
IntegerMode, ComplexMode);
-  S.Diag(Attr.getLoc(), diag::warn_vector_mode_deprecated);
+  // Avoid duplicate warning from template instantiation.
+  if (!InInstantiation)
+Diag(AttrLoc, diag::warn_vector_mode_deprecated);
 } else {
   VectorSize = 0;
 }
   }
 
   if (!VectorSize)
-parseModeAttrArg(S, Str, DestWidth, IntegerMode, ComplexMode);
+parseModeAttrArg(*this, Str, DestWidth, IntegerMode, ComplexMode);
+
+  // FIXME: Sync this with InitializePredefinedMacros; we need to match int8_t
+  // and friends, at least with glibc.
+  // FIXME: Make sure floating-point mappings are accurate
+  // FIXME: Support XF and TF types
+  if (!DestWidth) {
+Diag(AttrLoc, diag::err_machine_mode) << 0 /*Unknown*/ << Name;
+return;
+  }
 
   QualType OldTy;
   if (TypedefNameDecl *TD = dyn_cast(D))
 OldTy = TD->getUnderlyingType();
-  else
+  else if (EnumDecl *ED = dyn_cast(D)) {
+// Something like 'typedef enum { X } __attribute__((mode(XX))) T;'.
+// Try to get type from enum declaration, default to int.
+OldTy = ED->getIntegerType();
+if (OldTy.isNull())
+  OldTy = Context.IntTy;
+  } else
 OldTy = cast(D)->getType();
 
+  if (OldTy->isDependentType()) {
+D->addAttr(::new (Context)
+   ModeAttr(AttrRange, Context, Name, SpellingListIndex));
+return;
+  }
+
   // Base type can also be a vector type (see PR17453).
   // Distinguish between base type and base element type.
   QualType OldElemTy = OldTy;
   if (const VectorType *VT = OldTy->getAs())
 OldElemTy = VT->getElementType();
 
-  if (!OldElemTy->getAs() && !OldElemTy->isComplexType())
-S.Diag(Attr.getLoc(), diag::err_mode_not_primitive);
+  // GCC allows 'mode' attribute on enumeration types (even incomplete), except
+  // for vector modes. So, 'enum X __attribute__((mode(QI)));' forms a complete
+  // type, 'enum { A } 

Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2016-02-01 Thread Nemanja Ivanovic via cfe-commits
nemanjai added a comment.

If the reviewers don't mind, I would like to keep this patch with diagnostics 
for interoperability between the two types for now. This is simply because 
enabling such interoperability requires changes to some of the conversion 
infrastructure (i.e. allowing FPTrunc/FPExt for types of the same width, etc.). 
This is to prevent crashes on code such as:

  __float128 foo(long double d) {
return d;
  }

A test case like that will trip asserts when attempting to generate code. Of 
course, this is easy to fix (3 minor changes in 2 files) but even if we emit 
that IR, the back end will fail when trying to compile it.
What I meant to do with this patch is to just get the Clang support in and emit 
diagnostics for things that the target isn't able to do yet. I will follow this 
up with a patch that will:

1. Remove the diagnostics
2. Allow the conversions
3. Provide libcalls for the necessary operations (similarly to what GCC does)


Repository:
  rL LLVM

http://reviews.llvm.org/D15120



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


[PATCH] D16765: [Clang-Format] Add option for spacing between function parameters

2016-02-01 Thread Kai Wolf via cfe-commits
NewProggie created this revision.
NewProggie added reviewers: poiru, djasper, klimek.
NewProggie added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

This patch adds an option to remove the blank after comma between several 
function parameters. The default value is still to keep the blank.

http://reviews.llvm.org/D16765

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10954,6 +10954,19 @@
   verifyFormat("A>();", Spaces);
 }
 
+TEST_F(FormatTest, SpacesBetweenFunctionParameters) {
+  FormatStyle Spaces = getLLVMStyle();
+  Spaces.SpacesBetweenFunctionParameters = false;
+
+  verifyFormat("void foo(int a);", Spaces);
+  verifyFormat("void foo(int a,double b);", Spaces);
+  verifyFormat("void foo(int a,double b,char c);", Spaces);
+
+  Spaces.SpacesBetweenFunctionParameters = true;
+  verifyFormat("void foo(int a, double b);", Spaces);
+  verifyFormat("void foo(int a, double b, char c);", Spaces);
+}
+
 TEST_F(FormatTest, TripleAngleBrackets) {
   verifyFormat("f<<<1, 1>>>();");
   verifyFormat("f<<<1, 1, 1, s>>>();");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2074,7 +2074,7 @@
   if (Right.is(TT_OverloadedOperatorLParen))
 return Style.SpaceBeforeParens == FormatStyle::SBPO_Always;
   if (Left.is(tok::comma))
-return true;
+return Style.SpacesBetweenFunctionParameters;
   if (Right.is(tok::comma))
 return false;
   if (Right.isOneOf(TT_CtorInitializerColon, TT_ObjCBlockLParen))
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -322,6 +322,8 @@
 IO.mapOptional("SpaceInEmptyParentheses", Style.SpaceInEmptyParentheses);
 IO.mapOptional("SpacesBeforeTrailingComments",
Style.SpacesBeforeTrailingComments);
+IO.mapOptional("SpacesBetweenFunctionParameters",
+   Style.SpacesBetweenFunctionParameters);
 IO.mapOptional("SpacesInAngles", Style.SpacesInAngles);
 IO.mapOptional("SpacesInContainerLiterals",
Style.SpacesInContainerLiterals);
@@ -516,6 +518,7 @@
   LLVMStyle.ObjCSpaceBeforeProtocolList = true;
   LLVMStyle.PointerAlignment = FormatStyle::PAS_Right;
   LLVMStyle.SpacesBeforeTrailingComments = 1;
+  LLVMStyle.SpacesBetweenFunctionParameters = true;
   LLVMStyle.Standard = FormatStyle::LS_Cpp11;
   LLVMStyle.UseTab = FormatStyle::UT_Never;
   LLVMStyle.ReflowComments = true;
@@ -561,6 +564,7 @@
   GoogleStyle.ObjCSpaceBeforeProtocolList = false;
   GoogleStyle.PointerAlignment = FormatStyle::PAS_Left;
   GoogleStyle.SpacesBeforeTrailingComments = 2;
+  GoogleStyle.SpacesBetweenFunctionParameters = true;
   GoogleStyle.Standard = FormatStyle::LS_Auto;
 
   GoogleStyle.PenaltyReturnTypeOnItsOwnLine = 200;
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -539,6 +539,9 @@
   /// commonly have different usage patterns and a number of special cases.
   unsigned SpacesBeforeTrailingComments;
 
+  /// \b If \c true, spaces will be inserted between function parameters.
+  bool SpacesBetweenFunctionParameters;
+
   /// \brief If \c true, spaces will be inserted after '<' and before '>' in
   /// template argument lists
   bool SpacesInAngles;
@@ -657,6 +660,8 @@
SpaceBeforeParens == R.SpaceBeforeParens &&
SpaceInEmptyParentheses == R.SpaceInEmptyParentheses &&
SpacesBeforeTrailingComments == R.SpacesBeforeTrailingComments &&
+   SpacesBetweenFunctionParameters ==
+   R.SpacesBetweenFunctionParameters &&
SpacesInAngles == R.SpacesInAngles &&
SpacesInContainerLiterals == R.SpacesInContainerLiterals &&
SpacesInCStyleCastParentheses == R.SpacesInCStyleCastParentheses &&
Index: docs/ClangFormatStyleOptions.rst
===
--- docs/ClangFormatStyleOptions.rst
+++ docs/ClangFormatStyleOptions.rst
@@ -611,6 +611,9 @@
   This does not affect trailing block comments (``/**/`` - comments) as those
   commonly have different usage patterns and a number of special cases.
 
+**SpacesBetweenFunctionParameters** (``bool``)
+  If ``true``, a space will be inserted between several function parameters.
+
 **SpacesInAngles** (``bool``)
   If ``true``, spaces will be inserted after '<' and before '>' in
   template argument lists
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://

r259345 - [analyzer] Use a wider integer type for an array index.

2016-02-01 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Feb  1 03:29:17 2016
New Revision: 259345

URL: http://llvm.org/viewvc/llvm-project?rev=259345&view=rev
Log:
[analyzer] Use a wider integer type for an array index.

Avoids unexpected overflows while performing pointer arithmetics in 64-bit code.
Moreover, neither PointerDiffType nor 'int' can be used as a common array index
type because arrays may have size (and indexes) more than PTRDIFF_MAX but less
than SIZE_MAX.

Patch by Aleksei Sidorin!

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

Added:
cfe/trunk/test/Analysis/index-type.c
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h?rev=259345&r1=259344&r2=259345&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h Mon 
Feb  1 03:29:17 2016
@@ -65,7 +65,7 @@ public:
   SymMgr(context, BasicVals, alloc),
   MemMgr(context, alloc),
   StateMgr(stateMgr),
-  ArrayIndexTy(context.IntTy),
+  ArrayIndexTy(context.LongLongTy),
   ArrayIndexWidth(context.getTypeSize(ArrayIndexTy)) {}
 
   virtual ~SValBuilder() {}

Added: cfe/trunk/test/Analysis/index-type.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/index-type.c?rev=259345&view=auto
==
--- cfe/trunk/test/Analysis/index-type.c (added)
+++ cfe/trunk/test/Analysis/index-type.c Mon Feb  1 03:29:17 2016
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze 
-analyzer-checker=core,alpha.security.ArrayBoundV2 -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze 
-analyzer-checker=core,alpha.security.ArrayBoundV2 -DM32 -verify %s
+// expected-no-diagnostics
+
+#define UINT_MAX (~0u)
+
+#ifdef M32
+
+#define X86_ARRAY_SIZE (UINT_MAX/2 + 4)
+
+void testIndexTooBig() {
+  char arr[X86_ARRAY_SIZE];
+  char *ptr = arr + UINT_MAX/2;
+  ptr += 2;  // index shouldn't overflow
+  *ptr = 42; // no-warning
+}
+
+#else // 64-bit tests
+
+#define ARRAY_SIZE 0x1
+
+void testIndexOverflow64() {
+  char arr[ARRAY_SIZE];
+  char *ptr = arr + UINT_MAX/2;
+  ptr += 2;  // don't overflow 64-bit index
+  *ptr = 42; // no-warning
+}
+
+#define ULONG_MAX (~0ul)
+#define BIG_INDEX (ULONG_MAX/16)
+
+void testIndexTooBig64() {
+  char arr[ULONG_MAX/8-1];
+  char *ptr = arr + BIG_INDEX;
+  ptr += 2;  // don't overflow 64-bit index
+  *ptr = 42; // no-warning
+}
+
+#endif


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


Re: Adding Python 3 compatibility to Clang Python bindings

2016-02-01 Thread Russell Keith-Magee via cfe-commits
Hi all,

It’s been 10 days since I submitted this patch, without any response; is
there anything else I need to provide/do to get a review and/or commit?

Yours,
Russ Magee %-)

On Thu, Jan 21, 2016 at 12:43 PM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> Hi all,
>
> Following some feedback on cfe-dev, here is an updated version of the
> previous diff, presented as a set of 4 patches. The four patches are:
>
>  1. Python 3 compatibility
>  2. Simple (and hopefully uncontroversial) PEP8 formatting fixes
>  3. A new setup.py
>  4. More controversial PEP8 formatting fixes.
>
> Let me know if there is anything else I can do to smooth the path into
> master.
>
> Yours,
> Russ Magee %-)
>
>
> On Thu, Jan 14, 2016 at 12:45 PM, Russell Keith-Magee <
> russ...@keith-magee.com> wrote:
>
>>
>> For your consideration:
>>
>> Attached is a patch that adds Python 3 compatibility (without losing
>> Python 2 compatibility) to Clang’s Python bindings.
>>
>> The patch also includes PEP8 formatting cleanups, and a setup.py file to
>> make it easier to install the bindings into a working Python development
>> environment.
>>
>> Yours,
>> Russell Keith-Magee %-)
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r259355 - Remove the egregious PCHContainer layering hack that doesn't seem to be necessary anymore.

2016-02-01 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Feb  1 07:22:39 2016
New Revision: 259355

URL: http://llvm.org/viewvc/llvm-project?rev=259355&view=rev
Log:
Remove the egregious PCHContainer layering hack that doesn't seem to be 
necessary anymore.

Modified:
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/lib/Frontend/PCHContainerOperations.cpp

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=259355&r1=259354&r2=259355&view=diff
==
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Mon Feb  1 07:22:39 2016
@@ -19,7 +19,6 @@
 
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemStatCache.h"
-#include "clang/Frontend/PCHContainerOperations.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/ADT/STLExtras.h"
@@ -564,7 +563,3 @@ void FileManager::PrintStats() const {
 
   //llvm::errs() << PagesMapped << BytesOfPagesMapped << FSLookups;
 }
-
-// Virtual destructors for abstract base classes that need live in Basic.
-PCHContainerWriter::~PCHContainerWriter() {}
-PCHContainerReader::~PCHContainerReader() {}

Modified: cfe/trunk/lib/Frontend/PCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHContainerOperations.cpp?rev=259355&r1=259354&r2=259355&view=diff
==
--- cfe/trunk/lib/Frontend/PCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHContainerOperations.cpp Mon Feb  1 07:22:39 2016
@@ -19,6 +19,9 @@
 
 using namespace clang;
 
+PCHContainerWriter::~PCHContainerWriter() {}
+PCHContainerReader::~PCHContainerReader() {}
+
 namespace {
 
 /// \brief A PCHContainerGenerator that writes out the PCH to a flat file.


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


Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute

2016-02-01 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 46526.
yaxunl added a comment.

update the tests.


http://reviews.llvm.org/D16686

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  lib/CodeGen/CGLoopInfo.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaStmtAttr.cpp
  test/CodeGenOpenCL/unroll-hint.cl
  test/Parser/opencl-unroll-hint.cl
  test/SemaOpenCL/unroll-hint.cl

Index: test/SemaOpenCL/unroll-hint.cl
===
--- /dev/null
+++ test/SemaOpenCL/unroll-hint.cl
@@ -0,0 +1,19 @@
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
+
+kernel void C (global int *x) {
+  int I = 3;
+  __attribute__((opencl_unroll_hint(I))) // expected-error {{opencl_unroll_hint attribute requires an integer constant}}
+  while (I--);
+}
+
+kernel void D (global int *x) {
+  int i = 10;
+  __attribute__((opencl_unroll_hint))
+  do {
+  } while(i--);
+}
+
+kernel void E() {
+  __attribute__((opencl_unroll_hint(2,4))) // expected-error {{1 attribute takes no more than 1 argument}}
+  for(int i=0; i<100; i++);
+}
Index: test/Parser/opencl-unroll-hint.cl
===
--- /dev/null
+++ test/Parser/opencl-unroll-hint.cl
@@ -0,0 +1,8 @@
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
+
+kernel void B (global int *x) {
+  __attribute__((opencl_unroll_hint(42)))
+  if (x[0]) // expected-error {{OpenCL only supports opencl_unroll_hint attribute on for, while, and do statements}}
+x[0] = 15;
+}
+
Index: test/CodeGenOpenCL/unroll-hint.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/unroll-hint.cl
@@ -0,0 +1,114 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+/*** for ***/
+void for_count(int* sum)
+{
+// CHECK-LABEL: for_count
+__attribute__((opencl_unroll_hint(8)))
+for( int i = 0; i < 1000; ++i) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_COUNT:.*]]
+}
+
+void for_disable(int* sum)
+{
+// CHECK-LABEL: for_disable
+__attribute__((opencl_unroll_hint(1)))
+for( int i = 0; i < 1000; ++i) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_DISABLE:.*]]
+}
+
+void for_full(int* sum)
+{
+// CHECK-LABEL: for_full
+__attribute__((opencl_unroll_hint))
+for( int i = 0; i < 1000; ++i) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_FULL:.*]]
+}
+
+/*** while ***/
+void while_count(int* sum)
+{
+// CHECK-LABEL: while_count
+int i = 1000;
+__attribute__((opencl_unroll_hint(8)))
+while(i-->0) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_COUNT:.*]]
+}
+
+void while_disable(int* sum)
+{
+// CHECK-LABEL: while_disable
+int i = 1000;
+__attribute__((opencl_unroll_hint(1)))
+while(i-->0) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_DISABLE:.*]]
+}
+
+void while_full(int* sum)
+{
+// CHECK-LABEL: while_full
+int i = 1000;
+__attribute__((opencl_unroll_hint))
+while(i-->0) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_FULL:.*]]
+}
+
+/*** do ***/
+void do_count(int* sum)
+{
+// CHECK-LABEL: do_count
+int i = 1000;
+__attribute__((opencl_unroll_hint(8)))
+do {
+*sum += i;
+} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_COUNT:.*]]
+}
+
+void do_disable(int* sum)
+{
+// CHECK-LABEL: do_disable
+int i = 1000;
+__attribute__((opencl_unroll_hint(1)))
+do {
+*sum += i;
+} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_DISABLE:.*]]
+}
+
+void do_full(int* sum)
+{
+// CHECK-LABEL: do_full
+int i = 1000;
+__attribute__((opencl_unroll_hint))
+do {
+*sum += i;
+} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_FULL:.*]]
+}
+
+
+// CHECK: ![[FOR_COUNT]] =  distinct !{![[FOR_COUNT]],  ![[COUNT:.*]]}
+// CHECK: ![[COUNT]] =  !{!"llvm.loop.unroll.count", i32 8}
+// CHECK: ![[FOR_DISABLE]]   =  distinct !{![[FOR_DISABLE]],  ![[DISABLE:.*]]}
+// CHECK: ![[DISABLE]]   =  !{!"llvm.loop.unroll.disable"}
+// CHECK: ![[FOR_FULL]]  =  distinct !{![[FOR_FULL]],  ![[FULL:.*]]}
+// CHECK: ![[FULL]]  =  !{!"llvm.loop.unroll.full"}
+// CHECK: ![[WHILE_COUNT]]   =  distinct !{![[WHILE_COUNT]],![[COUNT]]}
+// CHECK: ![[WHILE_DISABLE]] =  distinct !{![[WHILE_DISABLE]],  ![[DISABLE]]}
+// CHECK: ![[WHILE_FULL]]=  distinct !{![[WHILE_FULL]], ![[FULL]]}
+// CHECK: ![[DO_COUNT]]  =  distinct !{![[DO_COUNT]],   ![[COUNT]]}
+// CHECK: ![[DO_DISABLE]]=  distinct !{![[DO_DISABLE]], ![[DISABLE]]}
+// CHEC

r259359 - Reapply r259210 with a fix for RegistryTest.cpp.

2016-02-01 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Feb  1 08:11:47 2016
New Revision: 259359

URL: http://llvm.org/viewvc/llvm-project?rev=259359&view=rev
Log:
Reapply r259210 with a fix for RegistryTest.cpp.

Patch by Richard Thomson.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=259359&r1=259358&r2=259359&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Feb  1 08:11:47 2016
@@ -1308,6 +1308,18 @@ c and d.
 
 
 
+MatcherType>functionProtoTypeMatcherFunctionProtoType>...
+Matches 
FunctionProtoType nodes.
+
+Given
+  int (*f)(int);
+  void g();
+functionProtoType()
+  matches "int (*f)(int)" and the type of "g" in C++ mode.
+  In C mode, "g" is not matched because it does not contain a prototype.
+
+
+
 MatcherType>functionTypeMatcherFunctionType>...
 Matches FunctionType 
nodes.
 
@@ -2335,13 +2347,40 @@ compiled in C mode.
 
 
 MatcherFunctionDecl>parameterCountIsunsigned N
-Matches 
FunctionDecls that have a specific parameter count.
+Matches 
FunctionDecls and FunctionProtoTypes that have a
+specific parameter count.
+
+Given
+  void f(int i) {}
+  void g(int i, int j) {}
+  void h(int i, int j);
+  void j(int i);
+  void k(int x, int y, int z, ...);
+functionDecl(parameterCountIs(2))
+  matches void g(int i, int j) {}
+functionProtoType(parameterCountIs(2))
+  matches void h(int i, int j)
+functionProtoType(parameterCountIs(3))
+  matches void k(int x, int y, int z, ...);
+
+
+
+MatcherFunctionProtoType>parameterCountIsunsigned N
+Matches 
FunctionDecls and FunctionProtoTypes that have a
+specific parameter count.
 
 Given
   void f(int i) {}
   void g(int i, int j) {}
+  void h(int i, int j);
+  void j(int i);
+  void k(int x, int y, int z, ...);
 functionDecl(parameterCountIs(2))
-  matches g(int i, int j) {}
+  matches void g(int i, int j) {}
+functionProtoType(parameterCountIs(2))
+  matches void h(int i, int j)
+functionProtoType(parameterCountIs(3))
+  matches void k(int x, int y, int z, ...);
 
 
 
@@ -3995,8 +4034,8 @@ actual casts "explicit" casts.)
 
 
 
-MatcherExpr>hasTypeMatcherDecl> 
InnerMatcher
-Overloaded to match the 
declaration of the expression's or value
+MatcherExpr>hasTypeMatcherDecl> 
InnerMatcher
+Overloaded to match the 
declaration of the expression's or value
 declaration's type.
 
 In case of a value declaration (for example a variable declaration),
@@ -4020,8 +4059,10 @@ matcher.
 
 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")
 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")
+and U (matcher = typedefDecl(hasType(asString("int")))
  class X {};
  void y(X &x) { x; X z; }
+ typedef int U;
 
 
 
@@ -4796,6 +4837,19 @@ Usable as: Any Matcher
 
 
 
+MatcherTypedefDecl>hasTypeMatcherQualType>
 InnerMatcher
+Matches if the expression's 
or declaration's type matches a type
+matcher.
+
+Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")
+and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")
+and U (matcher = typedefDecl(hasType(asString("int")))
+ class X {};
+ void y(X &x) { x; X z; }
+ typedef int U;
+
+
+
 MatcherTypedefType>hasDeclarationMatcherDecl>  
InnerMatcher
 Matches a node if 
the declaration associated with that node
 matches the given matcher.
@@ -4881,8 +4935,8 @@ usingDecl(hasAnyUsingShadowDecl(hasTarge
   matches using X::b but not using X::a 
 
 
-MatcherValueDecl>hasTypeMatcherDecl> 
InnerMatcher
-Overloaded to match t

Re: [PATCH] D8149: Extend hasType narrowing matcher for TypedefDecls, add functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

I haven't quite figured out the proper phab workflow for reverts yet either, 
but I took the updated patch, applied it, and commit in r259359. Thank you for 
the fix!


http://reviews.llvm.org/D8149



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


[PATCH] D16770: [MS] PR26234: Allow typedef redefinition of equally qualified, sized and aligned types in C

2016-02-01 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla created this revision.
d.zobnin.bugzilla added reviewers: rnk, majnemer.
d.zobnin.bugzilla added a subscriber: cfe-commits.

Allow typedef redefinition with different types in C if the types are equally 
qualified, sized and aligned. MSVC allows such redefinition, emits warning 
C4142: "benign redefinition of type" and propagates the type from the first 
typedef declaration in the entire redeclaration chain. 

http://reviews.llvm.org/D16770

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/Sema/SemaDecl.cpp
  test/Sema/ms-benign-typedef-redef.c

Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -6723,6 +6723,43 @@
   return false;
 }
 
+bool ASTContext::areMSCompatibleTypesInC(QualType OldType, QualType NewType) {
+  assert(getLangOpts().MicrosoftExt &&
+ "This routine must be called in Microsoft mode only!");
+  assert(!getLangOpts().CPlusPlus && !getLangOpts().ObjC1 &&
+ !getLangOpts().ObjC2 && "This routine must be called in C mode only!");
+
+  QualType OldCan = getCanonicalType(OldType);
+  QualType NewCan = getCanonicalType(NewType);
+
+  if (OldCan.getCVRQualifiers() != NewCan.getCVRQualifiers())
+return false;
+
+  if (OldCan->isPointerType() && NewCan->isPointerType()) {
+QualType OldPointee = OldType->getPointeeType();
+QualType NewPointee = NewType->getPointeeType();
+// void * and char * are interchangeable.
+if ((OldPointee->isCharType() && NewPointee->isVoidType()) ||
+(OldPointee->isVoidType() && NewPointee->isCharType()))
+  return true;
+return areMSCompatibleTypesInC(OldPointee, NewPointee);
+  }
+
+  // Enum vs float not allowed.
+  if ((OldCan->isRealFloatingType() && NewCan->isEnumeralType()) ||
+  (OldCan->isEnumeralType() && NewCan->isRealFloatingType()))
+return false;
+
+  if (OldCan->isRealType() && NewCan->isRealType()) {
+auto OldTypeInfo = getTypeInfo(OldCan);
+auto NewTypeInfo = getTypeInfo(NewCan);
+return (OldTypeInfo.Width == NewTypeInfo.Width &&
+OldTypeInfo.Align == NewTypeInfo.Align);
+  }
+
+  return false;
+}
+
 //===--===//
 // ObjCQualifiedIdTypesAreCompatible - Compatibility testing for qualified id's.
 //===--===//
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -1842,9 +1842,31 @@
   Filter.done();
 }
 
+static bool areMSCompatibleTypedefs(TypedefNameDecl *OldTypedef,
+TypedefNameDecl *NewTypedef,
+ASTContext &Context) {
+#ifndef NDEBUG
+  const LangOptions &Opts = Context.getLangOpts();
+  assert(Opts.MicrosoftExt &&
+ "This routine must be called in Microsoft mode only!");
+  assert(!Opts.CPlusPlus && !Opts.ObjC1 && !Opts.ObjC2 &&
+ "This routine must be called in C mode only!");
+  assert(OldTypedef && NewTypedef && "Expected valid typedef declarations!");
+#endif
+
+  // If both are locally-scoped, emit an error.
+  if (!OldTypedef->getDeclContext()->isFileContext() &&
+  !NewTypedef->getDeclContext()->isFileContext())
+return false;
+
+  return Context.areMSCompatibleTypesInC(OldTypedef->getUnderlyingType(),
+ NewTypedef->getUnderlyingType());
+}
+
 bool Sema::isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New) {
   QualType OldType;
-  if (TypedefNameDecl *OldTypedef = dyn_cast(Old))
+  TypedefNameDecl *OldTypedef = dyn_cast(Old);
+  if (OldTypedef)
 OldType = OldTypedef->getUnderlyingType();
   else
 OldType = Context.getTypeDeclType(Old);
@@ -1860,18 +1882,35 @@
 New->setInvalidDecl();
 return true;
   }
-  
+
   if (OldType != NewType &&
   !OldType->isDependentType() &&
   !NewType->isDependentType() &&
-  !Context.hasSameType(OldType, NewType)) { 
-int Kind = isa(Old) ? 1 : 0;
-Diag(New->getLocation(), diag::err_redefinition_different_typedef)
-  << Kind << NewType << OldType;
-if (Old->getLocation().isValid())
-  Diag(Old->getLocation(), diag::note_previous_definition);
-New->setInvalidDecl();
-return true;
+  !Context.hasSameType(OldType, NewType)) {
+const LangOptions &Opts = Context.getLangOpts();
+bool AllowedAsMicrosoftExtInC =
+Opts.MicrosoftExt && !Opts.CPlusPlus && !Opts.ObjC1 && !Opts.ObjC2 &&
+OldTypedef && areMSCompatibleTypedefs(OldTypedef, New, Context);
+
+SourceLocation OldLocation = Old->getLocation();
+if (AllowedAsMicrosoftExtInC) {
+  Diag(New->getLocation(), diag::warn_benign_redefinition_different_typedef)
+  << NewType << OldType;
+  if (OldTypedef->isModed())
+New->se

Re: [PATCH] D16764: Move incorrect-roundings to upstream.

2016-02-01 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Nice! See a few comments inline.



Comment at: clang-tidy/misc/IncorrectRoundings.cpp:38
@@ +37,3 @@
+  // Match a floating point expression.
+  auto FloatType = expr(anyOf(hasType(qualType(asString("long double"))),
+  hasType(qualType(asString("double"))),

We should use a more effective way of checking whether the type is a (long)? 
double or float. There'a `builtinType()` matcher that we could extend with a 
narrowing matcher calling `BuiltinType::isFloatingPoint()` (that can be added 
to ASTMatchers.h, I think).


Comment at: clang-tidy/misc/IncorrectRoundings.cpp:50
@@ +49,3 @@
+  auto OneSideHalf = anyOf(
+  allOf(hasLHS(FloatOrCastHalf), hasRHS(FloatType.bind("ExprOnRhs"))),
+  allOf(hasRHS(FloatOrCastHalf), hasLHS(FloatType.bind("ExprOnLhs";

Since these two `.bind()` calls are in alternative branches, they can use the 
same identifier. This would also simplify the code in the callback.


Comment at: clang-tidy/misc/IncorrectRoundings.cpp:71
@@ +70,3 @@
+   "casting (double + 0.5) to integer leads to incorrect rounding; "
+   "consider using lrint (#include ) instead");
+}

I don't think we should recommend `lrint`, since its behavior can be changed by 
[[ http://www.cplusplus.com/reference/cfenv/fesetround | fesetround() ]]. [[ 
http://www.cplusplus.com/reference/cmath/lround/ | lround() ]] and [[ 
http://www.cplusplus.com/reference/cmath/llround/ | llround() ]] are better 
alternatives, IMO. We could also suggest an automated fix for this.


http://reviews.llvm.org/D16764



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


Re: [PATCH] D16539: [FIX] 26194 - LLVM crash in CXXNameMangler::mangleType

2016-02-01 Thread Igor Chesnokov via cfe-commits
ichesnokov removed rL LLVM as the repository for this revision.
ichesnokov updated this revision to Diff 46532.
ichesnokov added a comment.

Added generic variable support and checking address space to Microsoft mangler.
Test case updated.


http://reviews.llvm.org/D16539

Files:
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  test/CodeGenOpenCL/generic_mangling.cl
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -363,7 +363,8 @@
   auto newEnd = std::remove(argv.begin(), argv.end(), nullptr);
   argv.resize(newEnd - argv.begin());
 }
-return ExecuteCC1Tool(argv, argv[1] + 4);
+int Result = ExecuteCC1Tool(argv, argv[1] + 4);
+return Result; // Useful for debugging to set breakpoint here
   }
 
   bool CanonicalPrefixes = true;
Index: test/CodeGenOpenCL/generic_mangling.cl
===
--- test/CodeGenOpenCL/generic_mangling.cl
+++ test/CodeGenOpenCL/generic_mangling.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -ffake-address-space-map -emit-llvm -ffp-contract=off -x cl 
-cl-std=CL2.0 -o - %s | FileCheck %s
+
+// CHECK: define zeroext i1 
@"\01?atomic_compare_exchange_strong@@$$J0YA_NPCU8CLglobalU?$_Atomic@H@__clang@@PAU9CLgenericHH@Z"(i32
 addrspace(1)* %object, i32 addrspace(4)* %expected, i32 %desired)
+bool __attribute__((__overloadable__)) atomic_compare_exchange_strong(
+   volatile  __global atomic_int *object,
+  int  *expected,
+  int  desired)
+{
+  return atomic_compare_exchange_strong_explicit(
+object, expected, desired, 1, 2);
+}
+
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1383,6 +1383,37 @@
 }
   }
 
+  if (Quals.hasAddressSpace()) {
+// Address space extension:
+//
+//::= U 
+//::= U 
+//::= U 
+
+SmallString<64> ASString;
+unsigned AS = Quals.getAddressSpace();
+
+if (Context.getASTContext().addressSpaceMapManglingFor(AS)) {
+  //   ::= "AS" 
+  unsigned TargetAS = Context.getASTContext().getTargetAddressSpace(AS);
+  ASString = "AS" + llvm::utostr_32(TargetAS);
+} else {
+  switch (AS) {
+  default: llvm_unreachable("Not a language specific address space");
+//   ::= "CL" [ "global" | "local" | "constant" ]
+  case LangAS::opencl_global:   ASString = "CLglobal";   break;
+  case LangAS::opencl_local:ASString = "CLlocal";break;
+  case LangAS::opencl_constant: ASString = "CLconstant"; break;
+  case LangAS::opencl_generic:  ASString = "CLgeneric";  break;
+//   ::= "CU" [ "device" | "constant" | "shared" ]
+  case LangAS::cuda_device: ASString = "CUdevice";   break;
+  case LangAS::cuda_constant:   ASString = "CUconstant"; break;
+  case LangAS::cuda_shared: ASString = "CUshared";   break;
+  }
+}
+Out << 'U' << ASString.size() << ASString;
+  }
+
   // FIXME: For now, just drop all extension qualifiers on the floor.
 }
 
Index: lib/AST/ItaniumMangle.cpp
===
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -1796,6 +1796,7 @@
   case LangAS::opencl_global:   ASString = "CLglobal";   break;
   case LangAS::opencl_local:ASString = "CLlocal";break;
   case LangAS::opencl_constant: ASString = "CLconstant"; break;
+  case LangAS::opencl_generic:  ASString = "CLgeneric";  break;
   //   ::= "CU" [ "device" | "constant" | "shared" ]
   case LangAS::cuda_device: ASString = "CUdevice";   break;
   case LangAS::cuda_constant:   ASString = "CUconstant"; break;


Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -363,7 +363,8 @@
   auto newEnd = std::remove(argv.begin(), argv.end(), nullptr);
   argv.resize(newEnd - argv.begin());
 }
-return ExecuteCC1Tool(argv, argv[1] + 4);
+int Result = ExecuteCC1Tool(argv, argv[1] + 4);
+return Result; // Useful for debugging to set breakpoint here
   }
 
   bool CanonicalPrefixes = true;
Index: test/CodeGenOpenCL/generic_mangling.cl
===
--- test/CodeGenOpenCL/generic_mangling.cl
+++ test/CodeGenOpenCL/generic_mangling.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -ffake-address-space-map -emit-llvm -ffp-contract=off -x cl -cl-std=CL2.0 -o - %s | FileCheck %s
+
+// CHECK: define zeroext i1 @"\01?atomic_compare_exchange_strong@@$$J0YA_NPCU8CLglobalU?$_Atomic@H@__clang@@PAU9CLgenericHH@Z"(i32 addrspace(1)* %object, i32 addrspace(4)* %expected, i32 %desired)
+bool __attribute__((__overloadable__)) atomic_compare_exchange_strong(
+	volatile  __global atomic_int *object,

Re: [PATCH] D16748: Cleanup MemRegion.cpp/MemRegion.h

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Aside from one minor nit with `auto` usage, LGTM!



Comment at: C:/LLVM/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1396
@@ -1395,3 +1395,3 @@
   const auto &ReferencedBlockVars = AC->getReferencedBlockVars(BC->getDecl());
-  auto NumBlockVars =
+  const auto NumBlockVars =
   std::distance(ReferencedBlockVars.begin(), ReferencedBlockVars.end());

No need for a const here; the correct change is to not use auto (here and the 
line above), but instead spell out the type explicitly.


http://reviews.llvm.org/D16748



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


Re: [PATCH] D16717: [clang-tidy] Add non-constant references in function parameters check.

2016-02-01 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Thanks! A few comments.



Comment at: clang-tidy/google/NonConstReferences.cpp:54
@@ +53,3 @@
+
+  QualType ReferencedType =
+  *Result.Nodes.getNodeAs("referenced_type");

This could be `auto` to avoid duplicating the type name.


Comment at: clang-tidy/google/NonConstReferences.cpp:81
@@ +80,3 @@
+// operator++, operator-- and operation+assignment operators.
+if (Function->getParamDecl(0) == Parameter) return;
+break;

The `return` should be on the next line (`clang-format -style=llvm` should get 
this right).


Comment at: clang-tidy/google/NonConstReferences.cpp:105
@@ +104,3 @@
+  // Some functions use references to comply with established standards.
+  if (Function->getNameAsString() == "swap")
+return;

We can avoid calling (the more expensive) `getNameAsString` here:

  if (Function->getDeclName().isIdentifier() && Function->getName() == "swap") 
...


Comment at: clang-tidy/google/NonConstReferences.cpp:109
@@ +108,3 @@
+  // iostream parameters are typically passed by non-const reference.
+  if (StringRef(ReferencedType.getAsString()).endswith("stream"))
+return;

I'd better avoid calling getAsString here as well, but I don't see an easy way 
to do this.


Comment at: test/clang-tidy/google-runtime-references.cpp:1
@@ +1,2 @@
+// RUN: clang-tidy -checks=-*,google-runtime-references %s -- -std=c++11 | 
FileCheck -implicit-check-not='{{warning:|error:}}' %s
+

I think, this test can use the %check_clang_tidy script, since it doesn't seem 
to do anything the script doesn't support (you'll need to 
s/CHECK/CHECK-MESSAGES/ to make it work, though).


http://reviews.llvm.org/D16717



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


Re: [PATCH] D16708: Add a new attribute CFNoRelease.

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D16708#340359, @gottesmm wrote:

> I think that my response via email did not hit phabriactor. So sorry for the 
> delay.


No worries!

> Yes there is a forthcoming patch for CodeGen which will place an attribute on 
> the relevant functions. The attribute will be queried in the middle end 
> optimizer. The reason why there has been a bit of a delay is I realized I 
> wanted to talk to a few more people about this attribute internally.

> 

> We may want to expand its use to essentially mean "no-arc", i.e. this is a c 
> function that uses pure c-code.

> 

> There are other possibilities as well so stay tuned.


Okay, I would recommend the future patch include that middle end component as 
well. It gives better context for the attribute side of things.



Comment at: include/clang/Basic/Attr.td:540
@@ +539,3 @@
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];
+}

gottesmm wrote:
> aaron.ballman wrote:
> > Please, no undocumented new attributes. You should modify AttrDocs.td and 
> > include that reference here.
> Ok. I was just following what was done in the surrounding code. I am fine 
> with adding something to AttrDocs.td once we pin down exactly what we want.
> 
Yeah, the surrounding code was grandfathered in. It really should be documented 
as well. ;-)


http://reviews.llvm.org/D16708



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


Re: [PATCH] D16529: [clang-tidy] Add modernize-raw-string-literal check

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:80
@@ +79,3 @@
+return false;
+
+  const size_t NewLinePos = Text.find(R"(\n)");

This is why I would still prefer to block on fixing StringLiteral. This is 
functional, but really kind of nasty -- in the common case (not already a raw 
string literal), this does two linear searches through the entire string 
literal.


Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:88
@@ +87,3 @@
+}
+
+bool containsDelimiter(StringRef Bytes, const std::string &Delimiter) {

I think Alex's point is: why not R"('\"?x01)" (removing the need for lit)?


Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:116
@@ +115,3 @@
+if (containsEscapedCharacters(Result, Literal))
+  replaceWithRawStringLiteral(Result, Literal);
+  }

A configuration option makes sense to me, but I would be fine if it was a 
follow-on patch. I think that someone running this check is likely fine with 
the level of noise it will produce (which should be moderately low).


http://reviews.llvm.org/D16529



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


[clang-tools-extra] r259362 - Add a new check, readability-redundant-control-flow, that check for some forms of redundant control flow statements. Currently checks for return statements at the end of

2016-02-01 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Feb  1 09:31:15 2016
New Revision: 259362

URL: http://llvm.org/viewvc/llvm-project?rev=259362&view=rev
Log:
Add a new check, readability-redundant-control-flow, that check for some forms 
of redundant control flow statements. Currently checks for return statements at 
the end of a function with a void return type and continue statements at the 
end of looping statements.

Patch by Richard Thomson.

Added:
clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-control-flow.rst

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp
Modified:
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

Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=259362&r1=259361&r2=259362&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Mon Feb  1 
09:31:15 2016
@@ -11,6 +11,7 @@ add_clang_library(clangTidyReadabilityMo
   NamedParameterCheck.cpp
   NamespaceCommentCheck.cpp
   ReadabilityTidyModule.cpp
+  RedundantControlFlowCheck.cpp
   RedundantStringCStrCheck.cpp
   RedundantSmartptrGetCheck.cpp
   SimplifyBooleanExprCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp?rev=259362&r1=259361&r2=259362&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
Mon Feb  1 09:31:15 2016
@@ -18,6 +18,7 @@
 #include "ImplicitBoolCastCheck.h"
 #include "InconsistentDeclarationParameterNameCheck.h"
 #include "NamedParameterCheck.h"
+#include "RedundantControlFlowCheck.h"
 #include "RedundantSmartptrGetCheck.h"
 #include "RedundantStringCStrCheck.h"
 #include "SimplifyBooleanExprCheck.h"
@@ -44,6 +45,8 @@ public:
 "readability-implicit-bool-cast");
 CheckFactories.registerCheck(
 "readability-inconsistent-declaration-parameter-name");
+CheckFactories.registerCheck(
+"readability-redundant-control-flow");
 CheckFactories.registerCheck(
 "readability-uniqueptr-delete-release");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp?rev=259362&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp 
(added)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp 
Mon Feb  1 09:31:15 2016
@@ -0,0 +1,99 @@
+//===--- RedundantControlFlowCheck.cpp - 
clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "RedundantControlFlowCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+namespace {
+
+const char *const RedundantReturnDiag = "redundant return statement at the end 
"
+"of a function with a void return 
type";
+const char *const RedundantContinueDiag = "redundant continue statement at the 
"
+  "end of loop statement";
+
+bool isLocationInMacroExpansion(const SourceManager &SM, SourceLocation Loc) {
+  return SM.isMacroBodyExpansion(Loc) || SM.isMacroArgExpansion(Loc);
+}
+
+} // namespace
+
+void RedundantControlFlowCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  functionDecl(isDefinition(), returns(voidType()),
+   has(compoundStmt(hasAnySubstatement(returnStmt(
+
unless(has(expr()).bind("return"))),
+  this);
+  auto CompoundContinue =
+  has(compoundStmt(hasAnySubstatement(continueStmt())).bind("continue"));
+  Finder->addMatche

Re: [PATCH] D16259: Add clang-tidy readability-redundant-control-flow check

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I have commit in r259362. Thank you!


http://reviews.llvm.org/D16259



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


Re: [PATCH] D16259: Add clang-tidy readability-redundant-control-flow check

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

With one small nit to the diagnostic wording for consistency, LGTM! I will go 
ahead and make that change, then commit on your behalf. You may want to talk to 
Chris Lattner about getting commit privileges, if you'd like them.



Comment at: clang-tidy/readability/RedundantControlFlowCheck.cpp:25
@@ +24,3 @@
+"redundant return statement at the end of function returning void";
+const char *const RedundantContinueDiag =
+"redundant continue statement at the end of loop statement";

Our usual diagnostic terminology for this is "void return type" instead of 
"returning void".


Comment at: clang-tidy/readability/RedundantControlFlowCheck.cpp:60
@@ +59,3 @@
+  if (const auto *Return = dyn_cast(*last))
+issueDiagnostic(Result, Block, Return->getSourceRange(),
+RedundantReturnDiag);

It is the LLVM coding style (though I don't personally care for it), and you 
are right -- a clang-tidy check in the LLVM module wouldn't be amiss. :-)


http://reviews.llvm.org/D16259



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


Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.h:21-22
@@ -20,71 +20,4 @@
 /// them to use the appropriate boolean expression directly.
 ///
-/// Examples:
-///
-/// ===  
-/// Initial expression   Result
-/// ---  
-/// `if (b == true)` `if (b)`
-/// `if (b == false)``if (!b)`
-/// `if (b && true)` `if (b)`
-/// `if (b && false)``if (false)`
-/// `if (b || true)` `if (true)`
-/// `if (b || false)``if (b)`
-/// `e ? true : false`   `e`
-/// `e ? false : true`   `!e`
-/// `if (true) t(); else f();`   `t();`
-/// `if (false) t(); else f();`  `f();`
-/// `if (e) return true; else return false;` `return e;`
-/// `if (e) return false; else return true;` `return !e;`
-/// `if (e) b = true; else b = false;`   `b = e;`
-/// `if (e) b = false; else b = true;`   `b = !e;`
-/// `if (e) return true; return false;`  `return e;`
-/// `if (e) return false; return true;`  `return !e;`
-/// ===  
-///
-/// The resulting expression `e` is modified as follows:
-///   1. Unnecessary parentheses around the expression are removed.
-///   2. Negated applications of `!` are eliminated.
-///   3. Negated applications of comparison operators are changed to use the
-///  opposite condition.
-///   4. Implicit conversions of pointer to `bool` are replaced with explicit
-///  comparisons to `nullptr`.
-///   5. Implicit casts to `bool` are replaced with explicit casts to `bool`.
-///   6. Object expressions with `explicit operator bool` conversion operators
-///  are replaced with explicit casts to `bool`.
-///
-/// Examples:
-///   1. The ternary assignment `bool b = (i < 0) ? true : false;` has 
redundant
-///  parentheses and becomes `bool b = i < 0;`.
-///
-///   2. The conditional return `if (!b) return false; return true;` has an
-///  implied double negation and becomes `return b;`.
-///
-///   3. The conditional return `if (i < 0) return false; return true;` becomes
-///  `return i >= 0;`.
-///
-///  The conditional return `if (i != 0) return false; return true;` 
becomes
-///  `return i == 0;`.
-///
-///   4. The conditional return `if (p) return true; return false;` has an
-///  implicit conversion of a pointer to `bool` and becomes
-///  `return p != nullptr;`.
-///
-///  The ternary assignment `bool b = (i & 1) ? true : false;` has an
-///  implicit conversion of `i & 1` to `bool` and becomes
-///  `bool b = static_cast(i & 1);`.
-///
-///   5. The conditional return `if (i & 1) return true; else return false;` 
has
-///  an implicit conversion of an integer quantity `i & 1` to `bool` and
-///  becomes `return static_cast(i & 1);`
-///
-///   6. Given `struct X { explicit operator bool(); };`, and an instance `x` 
of
-///  `struct X`, the conditional return `if (x) return true; return false;`
-///  becomes `return static_cast(x);`
-///
-/// When a conditional boolean return or assignment appears at the end of a
-/// chain of `if`, `else if` statements, the conditional statement is left
-/// unchanged unless the option `ChainedConditionalReturn` or
-/// `ChainedConditionalAssignment`, respectively, is specified as non-zero.
-/// The default value for both options is zero.
-///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/readability-simplify-boolean-expr.html

I think I can agree with that, but I also think it depends a lot on what the 
purpose to the check is. If it's "improve readability regarding parens" + 
options that control when to remove or add, that makes sense to me. Otherwise, 
I think segregating the checks into one that removes (plus options) and one 
that adds (plus options) makes sense -- even if they perhaps use the same 
underlying heuristic engine and are simply surfaced as separate checks.


http://reviews.llvm.org/D16308



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


Re: [PATCH] D16764: Move incorrect-roundings to upstream.

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

Address Alex's comments.


http://reviews.llvm.org/D16764

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/IncorrectRoundings.cpp
  clang-tidy/misc/IncorrectRoundings.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-incorrect-roundings.rst
  test/clang-tidy/misc-incorrect-roundings.cpp

Index: test/clang-tidy/misc-incorrect-roundings.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-incorrect-roundings.cpp
@@ -0,0 +1,86 @@
+// RUN: %check_clang_tidy %s misc-incorrect-roundings %t
+
+void b(int x) {}
+
+void f1() {
+  float f;
+  double d;
+  long double ld;
+  int x;
+
+  x = (d + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5) to integer leads to incorrect rounding; consider using lrint (#include ) instead [misc-incorrect-roundings]
+  x = (d + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (f + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (f + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5 + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5f + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5 + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5f + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5 + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5f + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (int)(d + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(d + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(ld + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(ld + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(f + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(f + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5 + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5f + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5 + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5f + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5 + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5f + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = static_cast(d + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(d + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(ld + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(ld + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(f + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(f + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5 + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5f + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5 + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5f + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5 + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5f + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+
+  // Don't warn if constant is not 0.5.
+  x = (int)(d + 0.6);
+  x = (int)(0.6 + d);
+
+  // Don't warn if binary operator is not directly beneath cast.
+  x = (int)(1 + (0.5 + f));
+}
Index: docs/clang-tidy/checks/misc-incorrect-roundings.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-incorrect-roundings.rst
@@ -0,0 +1,12 @@
+misc-incorrect-roundings
+
+
+Checks the usage of patterns known to produce incorrect rounding.
+Programmers often use
+  (int)(double_expression + 0.5)
+to round the double expression to an integer. The problem with this:
+
+1. It is unnecessarily slow.
+2. It is incorrect. The number 0.49975 (smallest representable float
+   number below 0.5) rounds to 1.0. Even worse behavior for negative
+   numbers where both -0.5f and -1.4f both round to 0.0.
Index: docs/clang-tidy/checks/list.

Re: [PATCH] D16317: [Analyzer] Fix for PR23790: bind real value returned from strcmp when modelling strcmp.

2016-02-01 Thread Антон Ярцев via cfe-commits
ayartsev updated this revision to Diff 46538.
ayartsev added a comment.

Updated the patch, please review.


http://reviews.llvm.org/D16317

Files:
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  test/Analysis/string.c

Index: test/Analysis/string.c
===
--- test/Analysis/string.c
+++ test/Analysis/string.c
@@ -680,6 +680,18 @@
 #define strcmp BUILTIN(strcmp)
 int strcmp(const char * s1, const char * s2);
 
+void strcmp_check_modelling() {
+  char *x = "aa";
+  char *y = "a";
+  clang_analyzer_eval(strcmp(x, y) > 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) <= 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval(strcmp(x, y) > 1); // expected-warning{{UNKNOWN}}
+
+  clang_analyzer_eval(strcmp(y, x) < 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(y, x) >= 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval(strcmp(y, x) < -1); // expected-warning{{UNKNOWN}}
+}
+
 void strcmp_constant0() {
   clang_analyzer_eval(strcmp("123", "123") == 0); // expected-warning{{TRUE}}
 }
@@ -703,13 +715,13 @@
 void strcmp_1() {
   char *x = "234";
   char *y = "123";
-  clang_analyzer_eval(strcmp(x, y) == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) > 0); // expected-warning{{TRUE}}
 }
 
 void strcmp_2() {
   char *x = "123";
   char *y = "234";
-  clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) < 0); // expected-warning{{TRUE}}
 }
 
 void strcmp_null_0() {
@@ -727,25 +739,25 @@
 void strcmp_diff_length_0() {
   char *x = "12345";
   char *y = "234";
-  clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) < 0); // expected-warning{{TRUE}}
 }
 
 void strcmp_diff_length_1() {
   char *x = "123";
   char *y = "23456";
-  clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) < 0); // expected-warning{{TRUE}}
 }
 
 void strcmp_diff_length_2() {
   char *x = "12345";
   char *y = "123";
-  clang_analyzer_eval(strcmp(x, y) == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) > 0); // expected-warning{{TRUE}}
 }
 
 void strcmp_diff_length_3() {
   char *x = "123";
   char *y = "12345";
-  clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) < 0); // expected-warning{{TRUE}}
 }
 
 void strcmp_embedded_null () {
@@ -763,6 +775,18 @@
 #define strncmp BUILTIN(strncmp)
 int strncmp(const char *s1, const char *s2, size_t n);
 
+void strncmp_check_modelling() {
+  char *x = "aa";
+  char *y = "a";
+  clang_analyzer_eval(strncmp(x, y, 2) > 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 2) <= 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval(strncmp(x, y, 2) > 1); // expected-warning{{UNKNOWN}}
+
+  clang_analyzer_eval(strncmp(y, x, 2) < 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(y, x, 2) >= 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval(strncmp(y, x, 2) < -1); // expected-warning{{UNKNOWN}}
+}
+
 void strncmp_constant0() {
   clang_analyzer_eval(strncmp("123", "123", 3) == 0); // expected-warning{{TRUE}}
 }
@@ -786,13 +810,13 @@
 void strncmp_1() {
   char *x = "234";
   char *y = "123";
-  clang_analyzer_eval(strncmp(x, y, 3) == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 3) > 0); // expected-warning{{TRUE}}
 }
 
 void strncmp_2() {
   char *x = "123";
   char *y = "234";
-  clang_analyzer_eval(strncmp(x, y, 3) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 3) < 0); // expected-warning{{TRUE}}
 }
 
 void strncmp_null_0() {
@@ -810,25 +834,25 @@
 void strncmp_diff_length_0() {
   char *x = "12345";
   char *y = "234";
-  clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 5) < 0); // expected-warning{{TRUE}}
 }
 
 void strncmp_diff_length_1() {
   char *x = "123";
   char *y = "23456";
-  clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 5) < 0); // expected-warning{{TRUE}}
 }
 
 void strncmp_diff_length_2() {
   char *x = "12345";
   char *y = "123";
-  clang_analyzer_eval(strncmp(x, y, 5) == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 5) > 0); // expected-warning{{TRUE}}
 }
 
 void strncmp_diff_length_3() {
   char *x = "123";
   char *y = "12345";
-  clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 5) < 0); // expected-warning{{TRUE}}
 }
 
 void strncmp_diff_length_4() {
@@ -840,13 +864,13 @@
 void strncmp_diff_length_5() {
   char *x = "012";
   char *y = "12345";
-  clang_analyzer_eval(strncmp(x, y, 3) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 3) < 0); // expected-warning{{TRUE}}
 }
 
 void strncmp_diff_length_6() {
   char *x = "234";
   char

Re: [PATCH] D16764: Move incorrect-roundings to upstream.

2016-02-01 Thread Haojian Wu via cfe-commits
hokein marked 3 inline comments as done.


Comment at: clang-tidy/misc/IncorrectRoundings.cpp:39
@@ +38,3 @@
+namespace tidy {
+void IncorrectRoundings::registerMatchers(MatchFinder *MatchFinder) {
+  // Match a floating literal with value 0.5.

Done. The `ASTMatchers.h` file is not in clang-tidy repository, so I 
temporarily implement `isFloatingPoint` narrowing matcher here.

Will create a separated patch to clang repository.


Comment at: clang-tidy/misc/IncorrectRoundings.cpp:51
@@ +50,3 @@
+
+  // Match if either the LHS or RHS is a floating literal of 0.5 or a floating
+  // literal of 0.5 and the other is of type double or vice versa.

Just found out there is no need to bind here since `check` function doesn't use 
it. Have removed it.


http://reviews.llvm.org/D16764



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


Re: [libcxx] r196411 - Give all members of exception types default visibility. Lack of this is causing some illegal code relocations rare and hard to reproduce cases.

2016-02-01 Thread Rafael Espíndola via cfe-commits
>> Yes, that is what I mean. It is odd that -frtti changes us from "this
>> is not available anywhere, use linkonce_odr" to "it is available
>> elsewhere, use an external declaration".
>
> Yes, I agree, it's weird (although the transition is in the other
> direction, really, since there's no such flag as -frtti, just -fno-rtti).
> -fexceptions -fno-rtti is a weird combination to begin with though.

I got curious and decided to reduce it. What I got was:

class foo {
  virtual void bar();
};
struct zed : public foo {};
int f() { throw zed(); }

Without -fno-rtti _ZTI3foo is external. With -fno-rtti it is
linkonce_odr. It looks like -fno-rtti disables some key function logic
in both gcc and clang.

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


Re: [PATCH] D16529: [clang-tidy] Add modernize-raw-string-literal check

2016-02-01 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:80
@@ +79,3 @@
+return false;
+
+  const size_t NewLinePos = Text.find(R"(\n)");

aaron.ballman wrote:
> This is why I would still prefer to block on fixing StringLiteral. This is 
> functional, but really kind of nasty -- in the common case (not already a raw 
> string literal), this does two linear searches through the entire string 
> literal.
Richard, you're right, it's `u8R"(...)"`, not `Ru8"(...)"` or something. 
Nevertheless, doing a full scan for `R` (the search for `"` wouldn't result in 
a full scan) in this condition shouldn't be necessary, it could first find a 
`"` and then check if the previous character is `R`. It would be a bit more 
code, but less needless work at runtime.

Alternatively, D16012 might be a better answer, if it ever makes it into Clang.


Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:88
@@ +87,3 @@
+}
+
+bool containsDelimiter(StringRef Bytes, const std::string &Delimiter) {

aaron.ballman wrote:
> I think Alex's point is: why not R"('\"?x01)" (removing the need for lit)?
Exactly, I was only talking about `lit`, not about using the raw string literal.


Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:96
@@ +95,3 @@
+  std::string Delimiter;
+  for (int Counter = 0; containsDelimiter(Bytes, Delimiter); ++Counter) {
+Delimiter = (Counter == 0) ? "lit" : "lit" + std::to_string(Counter);

Please address my comment above that relates to this code. Specifically, I find 
this generic algorithm unnecessarily inefficient and too rigid, i.e. one can't 
configure a custom set of delimiters that don't follow the  
pattern. I suggest using a list of pre-concatenated pairs of strings (like 
`R"lit(` and `)lit"`).


http://reviews.llvm.org/D16529



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


r259366 - [OpenMP] Prevent nesting of target constructs within target code execution regions.

2016-02-01 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Mon Feb  1 10:32:47 2016
New Revision: 259366

URL: http://llvm.org/viewvc/llvm-project?rev=259366&view=rev
Log:
[OpenMP] Prevent nesting of target constructs within target code execution 
regions.

Summary:
This patch enhances Sema to check for the following restriction:

OpenMP 4.5 [2.17 Nesting of Regions]
If a target, target update, target data, target enter data, or
target exit data construct is encountered during execution of a
target region, the behavior is unspecified.

Reviewers: ABataev

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


Modified:
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_private_messages.cpp
cfe/trunk/test/OpenMP/nesting_of_regions.cpp
cfe/trunk/test/OpenMP/target_data_device_messages.cpp
cfe/trunk/test/OpenMP/target_device_messages.cpp
cfe/trunk/test/OpenMP/target_if_messages.cpp
cfe/trunk/test/OpenMP/target_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_default_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_device_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_map_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_num_threads_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_private_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_proc_bind_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_shared_messages.cpp
cfe/trunk/test/OpenMP/target_private_messages.cpp
cfe/trunk/test/OpenMP/teams_reduction_messages.cpp

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.h?rev=259366&r1=259365&r2=259366&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.h (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.h Mon Feb  1 10:32:47 2016
@@ -156,11 +156,20 @@ bool isOpenMPTaskLoopDirective(OpenMPDir
 /// parallel', otherwise - false.
 bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind);
 
-/// \brief Checks if the specified directive is a target-kind directive.
+/// \brief Checks if the specified directive is a target code offload 
directive.
 /// \param DKind Specified directive.
-/// \return true - the directive is a target-like directive like 'omp target',
+/// \return true - the directive is a target code offload directive like
+/// 'omp target', 'omp target parallel', 'omp target xxx'
 /// otherwise - false.
-bool isOpenMPTargetDirective(OpenMPDirectiveKind DKind);
+bool isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind);
+
+/// \brief Checks if the specified directive is a target data offload 
directive.
+/// \param DKind Specified directive.
+/// \return true - the directive is a target data offload directive like
+/// 'omp target data', 'omp target update', 'omp target enter data',
+/// 'omp target exit data'
+/// otherwise - false.
+bool isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind);
 
 /// \brief Checks if the specified directive is a teams-kind directive.
 /// \param DKind Specified directive.

Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=259366&r1=259365&r2=259366&view=diff
==
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Mon Feb  1 10:32:47 2016
@@ -576,8 +576,15 @@ bool clang::isOpenMPParallelDirective(Op
  // TODO add next directives.
 }
 
-bool clang::isOpenMPTargetDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_target; // TODO add next directives.
+bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) {
+  // TODO add next directives.
+  return DKind == OMPD_target || DKind == OMPD_target_parallel;
+}
+
+bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
+  // TODO add target update directive check.
+  return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
+ DKind == OMPD_target_exit_data;
 }
 
 bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=259366&r1=259365&r2=259366&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Feb  1 10:32:47 2016
@@ -809,7 +809,7 @@ bool Sema::IsOpenMPCapturedByRef(ValueDe
   auto DKind = DSAStack->getDirectiveForScope(RSI->TheScope

Re: [PATCH] D16770: [MS] PR26234: Allow typedef redefinition of equally qualified, sized and aligned types in C

2016-02-01 Thread David Majnemer via cfe-commits
majnemer added a comment.

MSVC permits:

  typedef int foo;
  typedef float foo;

This is crazy and most certainly not 'benign'. I think that we should insist 
that the underlying types not just be the same size and alignment but the same 
kind of scalar type. If two types are integral or enumerator types, they should 
have the same signedness.

I believe this would be enough to get things like vortex working without 
harming developer productivity.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4265-4267
@@ -4264,2 +4264,5 @@
   InGroup>;
+def warn_benign_redefinition_different_typedef : ExtWarn<
+  "benign typedef redefinition with different types%diff{ ($ vs $)|}0,1 "
+  "is a Microsoft extension">, InGroup;
 def err_redefinition_different_typedef : Error<

I think giving a warning that 'benign' sends the message that the code is OK 
and that the warning should be disabled.  I think we should say something like 
"typedef redefinition is ignored due to conflicting underlying type".


Comment at: lib/AST/ASTContext.cpp:6727-6728
@@ +6726,4 @@
+bool ASTContext::areMSCompatibleTypesInC(QualType OldType, QualType NewType) {
+  assert(getLangOpts().MicrosoftExt &&
+ "This routine must be called in Microsoft mode only!");
+  assert(!getLangOpts().CPlusPlus && !getLangOpts().ObjC1 &&

Shouldn't this be `MSVCCompat`, not `MicrosoftExt`?


Comment at: lib/Sema/SemaDecl.cpp:1868
@@ -1846,2 +1867,3 @@
   QualType OldType;
-  if (TypedefNameDecl *OldTypedef = dyn_cast(Old))
+  TypedefNameDecl *OldTypedef = dyn_cast(Old);
+  if (OldTypedef)

Please use `auto` here.


http://reviews.llvm.org/D16770



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


Re: [PATCH] D16758: [OpenMP] Prevent nesting of target constructs within target code execution regions.

2016-02-01 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL259366: [OpenMP] Prevent nesting of target constructs within 
target code execution… (authored by arpith).

Changed prior to commit:
  http://reviews.llvm.org/D16758?vs=46496&id=46544#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16758

Files:
  cfe/trunk/include/clang/Basic/OpenMPKinds.h
  cfe/trunk/lib/Basic/OpenMPKinds.cpp
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/test/OpenMP/distribute_private_messages.cpp
  cfe/trunk/test/OpenMP/nesting_of_regions.cpp
  cfe/trunk/test/OpenMP/target_data_device_messages.cpp
  cfe/trunk/test/OpenMP/target_device_messages.cpp
  cfe/trunk/test/OpenMP/target_if_messages.cpp
  cfe/trunk/test/OpenMP/target_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_default_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_device_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_if_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_map_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_num_threads_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_private_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_proc_bind_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_reduction_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_shared_messages.cpp
  cfe/trunk/test/OpenMP/target_private_messages.cpp
  cfe/trunk/test/OpenMP/teams_reduction_messages.cpp

Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -809,7 +809,7 @@
   auto DKind = DSAStack->getDirectiveForScope(RSI->TheScope);
   auto Ty = D->getType();
 
-  if (isOpenMPTargetDirective(DKind)) {
+  if (isOpenMPTargetExecutionDirective(DKind)) {
 // This table summarizes how a given variable should be passed to the device
 // given its type and the clauses where it appears. This table is based on
 // the description in OpenMP 4.5 [2.10.4, target Construct] and
@@ -907,7 +907,7 @@
 DSAStack->hasDirective(
 [](OpenMPDirectiveKind K, const DeclarationNameInfo &DNI,
SourceLocation Loc) -> bool {
-  return isOpenMPTargetDirective(K);
+  return isOpenMPTargetExecutionDirective(K);
 },
 false)) {
   return true;
@@ -944,7 +944,8 @@
 
   auto *VD = dyn_cast(D);
   return VD && !VD->hasLocalStorage() &&
- DSAStack->hasExplicitDirective(isOpenMPTargetDirective, Level);
+ DSAStack->hasExplicitDirective(isOpenMPTargetExecutionDirective,
+Level);
 }
 
 void Sema::DestroyDataSharingAttributesStack() { delete DSAStack; }
@@ -2313,11 +2314,11 @@
   // | target   | flush   | *  |
   // | target   | ordered | *  |
   // | target   | atomic  | *  |
-  // | target   | target  | *  |
-  // | target   | target parallel | *  |
-  // | target   | target enter| *  |
+  // | target   | target  ||
+  // | target   | target parallel ||
+  // | target   | target enter||
   // |  | data||
-  // | target   | target exit | *  |
+  // | target   | target exit ||
   // |  | data||
   // | target   | teams   | *  |
   // | target   | cancellation||
@@ -2347,11 +2348,11 @@
   // | target parallel  | flush   | *  |
   // | target parallel  | ordered | *  |
   // | target parallel  | atomic  | *  |
-  // | target parallel  | target  | *  |
-  // | target parallel  | target parallel | *  |
-  // | target parallel  | target enter| *  |
+  // | target parallel  | target  ||
+  // | target parallel  | target parallel ||
+  // | target parallel  | target enter||
   // |  | data||
-  // | target parallel  | target exit | 

Re: [PATCH] D16259: Add clang-tidy readability-redundant-control-flow check

2016-02-01 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Thank you for adding more test cases! Could you address one more comment in a 
follow-up, please?



Comment at: test/clang-tidy/readability-redundant-control-flow.cpp:193
@@ +192,3 @@
+// CHECK-FIXES-NEXT: {{^return;$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
+

This test doesn't verify whether the second `return` is removed or not. 
Whatever the behavior is, it would be good to make it obvious in the test.


http://reviews.llvm.org/D16259



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


Re: [PATCH] D16692: [OpenCL] Eliminate warning when declaring OpenCL builtin functions

2016-02-01 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM!


http://reviews.llvm.org/D16692



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


Re: [PATCH] D16586: Make clang AAPCS compliant w.r.t volatile bitfield accesses

2016-02-01 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Ping?


http://reviews.llvm.org/D16586



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


Re: [PATCH] D16529: [clang-tidy] Add modernize-raw-string-literal check

2016-02-01 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:88
@@ +87,3 @@
+}
+
+bool containsDelimiter(StringRef Bytes, const std::string &Delimiter) {

alexfh wrote:
> aaron.ballman wrote:
> > I think Alex's point is: why not R"('\"?x01)" (removing the need for lit)?
> Exactly, I was only talking about `lit`, not about using the raw string 
> literal.
It was looking a little busy to my eyes with the raw string " and the quoted " 
close together.  It isn't necessary, but IMO improves readability.


Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:96
@@ +95,3 @@
+  std::string Delimiter;
+  for (int Counter = 0; containsDelimiter(Bytes, Delimiter); ++Counter) {
+Delimiter = (Counter == 0) ? "lit" : "lit" + std::to_string(Counter);

alexfh wrote:
> Please address my comment above that relates to this code. Specifically, I 
> find this generic algorithm unnecessarily inefficient and too rigid, i.e. one 
> can't configure a custom set of delimiters that don't follow the 
>  pattern. I suggest using a list of pre-concatenated pairs of 
> strings (like `R"lit(` and `)lit"`).
Raw strings are new and not many people are using them because the don't have a 
good way to automatically convert disgusting quoted strings to raw strings.  So 
I don't think it is reasonable to draw conclusions by looking in existing code 
bases for raw strings.

We're having the same conversation we've had before.  I'm trying to do a basic 
check and get things working properly and the review comments are tending 
towards a desire for some kind of perfection.

I don't see why we have to make the perfect the enemy of the good.  Nothing you 
are suggesting **must** be present now in order for this check to function 
properly and reasonably.


http://reviews.llvm.org/D16529



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


Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

2016-02-01 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.h:21-22
@@ -20,71 +20,4 @@
 /// them to use the appropriate boolean expression directly.
 ///
-/// Examples:
-///
-/// ===  
-/// Initial expression   Result
-/// ---  
-/// `if (b == true)` `if (b)`
-/// `if (b == false)``if (!b)`
-/// `if (b && true)` `if (b)`
-/// `if (b && false)``if (false)`
-/// `if (b || true)` `if (true)`
-/// `if (b || false)``if (b)`
-/// `e ? true : false`   `e`
-/// `e ? false : true`   `!e`
-/// `if (true) t(); else f();`   `t();`
-/// `if (false) t(); else f();`  `f();`
-/// `if (e) return true; else return false;` `return e;`
-/// `if (e) return false; else return true;` `return !e;`
-/// `if (e) b = true; else b = false;`   `b = e;`
-/// `if (e) b = false; else b = true;`   `b = !e;`
-/// `if (e) return true; return false;`  `return e;`
-/// `if (e) return false; return true;`  `return !e;`
-/// ===  
-///
-/// The resulting expression `e` is modified as follows:
-///   1. Unnecessary parentheses around the expression are removed.
-///   2. Negated applications of `!` are eliminated.
-///   3. Negated applications of comparison operators are changed to use the
-///  opposite condition.
-///   4. Implicit conversions of pointer to `bool` are replaced with explicit
-///  comparisons to `nullptr`.
-///   5. Implicit casts to `bool` are replaced with explicit casts to `bool`.
-///   6. Object expressions with `explicit operator bool` conversion operators
-///  are replaced with explicit casts to `bool`.
-///
-/// Examples:
-///   1. The ternary assignment `bool b = (i < 0) ? true : false;` has 
redundant
-///  parentheses and becomes `bool b = i < 0;`.
-///
-///   2. The conditional return `if (!b) return false; return true;` has an
-///  implied double negation and becomes `return b;`.
-///
-///   3. The conditional return `if (i < 0) return false; return true;` becomes
-///  `return i >= 0;`.
-///
-///  The conditional return `if (i != 0) return false; return true;` 
becomes
-///  `return i == 0;`.
-///
-///   4. The conditional return `if (p) return true; return false;` has an
-///  implicit conversion of a pointer to `bool` and becomes
-///  `return p != nullptr;`.
-///
-///  The ternary assignment `bool b = (i & 1) ? true : false;` has an
-///  implicit conversion of `i & 1` to `bool` and becomes
-///  `bool b = static_cast(i & 1);`.
-///
-///   5. The conditional return `if (i & 1) return true; else return false;` 
has
-///  an implicit conversion of an integer quantity `i & 1` to `bool` and
-///  becomes `return static_cast(i & 1);`
-///
-///   6. Given `struct X { explicit operator bool(); };`, and an instance `x` 
of
-///  `struct X`, the conditional return `if (x) return true; return false;`
-///  becomes `return static_cast(x);`
-///
-/// When a conditional boolean return or assignment appears at the end of a
-/// chain of `if`, `else if` statements, the conditional statement is left
-/// unchanged unless the option `ChainedConditionalReturn` or
-/// `ChainedConditionalAssignment`, respectively, is specified as non-zero.
-/// The default value for both options is zero.
-///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/readability-simplify-boolean-expr.html

aaron.ballman wrote:
> I think I can agree with that, but I also think it depends a lot on what the 
> purpose to the check is. If it's "improve readability regarding parens" + 
> options that control when to remove or add, that makes sense to me. 
> Otherwise, I think segregating the checks into one that removes (plus 
> options) and one that adds (plus options) makes sense -- even if they perhaps 
> use the same underlying heuristic engine and are simply surfaced as separate 
> checks.
This check isn't at all about the readability of parens, so it doesn't make 
sense for this check to be concerned with it IMO.


http://reviews.llvm.org/D16308



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


Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.h:21-22
@@ -20,71 +20,4 @@
 /// them to use the appropriate boolean expression directly.
 ///
-/// Examples:
-///
-/// ===  
-/// Initial expression   Result
-/// ---  
-/// `if (b == true)` `if (b)`
-/// `if (b == false)``if (!b)`
-/// `if (b && true)` `if (b)`
-/// `if (b && false)``if (false)`
-/// `if (b || true)` `if (true)`
-/// `if (b || false)``if (b)`
-/// `e ? true : false`   `e`
-/// `e ? false : true`   `!e`
-/// `if (true) t(); else f();`   `t();`
-/// `if (false) t(); else f();`  `f();`
-/// `if (e) return true; else return false;` `return e;`
-/// `if (e) return false; else return true;` `return !e;`
-/// `if (e) b = true; else b = false;`   `b = e;`
-/// `if (e) b = false; else b = true;`   `b = !e;`
-/// `if (e) return true; return false;`  `return e;`
-/// `if (e) return false; return true;`  `return !e;`
-/// ===  
-///
-/// The resulting expression `e` is modified as follows:
-///   1. Unnecessary parentheses around the expression are removed.
-///   2. Negated applications of `!` are eliminated.
-///   3. Negated applications of comparison operators are changed to use the
-///  opposite condition.
-///   4. Implicit conversions of pointer to `bool` are replaced with explicit
-///  comparisons to `nullptr`.
-///   5. Implicit casts to `bool` are replaced with explicit casts to `bool`.
-///   6. Object expressions with `explicit operator bool` conversion operators
-///  are replaced with explicit casts to `bool`.
-///
-/// Examples:
-///   1. The ternary assignment `bool b = (i < 0) ? true : false;` has 
redundant
-///  parentheses and becomes `bool b = i < 0;`.
-///
-///   2. The conditional return `if (!b) return false; return true;` has an
-///  implied double negation and becomes `return b;`.
-///
-///   3. The conditional return `if (i < 0) return false; return true;` becomes
-///  `return i >= 0;`.
-///
-///  The conditional return `if (i != 0) return false; return true;` 
becomes
-///  `return i == 0;`.
-///
-///   4. The conditional return `if (p) return true; return false;` has an
-///  implicit conversion of a pointer to `bool` and becomes
-///  `return p != nullptr;`.
-///
-///  The ternary assignment `bool b = (i & 1) ? true : false;` has an
-///  implicit conversion of `i & 1` to `bool` and becomes
-///  `bool b = static_cast(i & 1);`.
-///
-///   5. The conditional return `if (i & 1) return true; else return false;` 
has
-///  an implicit conversion of an integer quantity `i & 1` to `bool` and
-///  becomes `return static_cast(i & 1);`
-///
-///   6. Given `struct X { explicit operator bool(); };`, and an instance `x` 
of
-///  `struct X`, the conditional return `if (x) return true; return false;`
-///  becomes `return static_cast(x);`
-///
-/// When a conditional boolean return or assignment appears at the end of a
-/// chain of `if`, `else if` statements, the conditional statement is left
-/// unchanged unless the option `ChainedConditionalReturn` or
-/// `ChainedConditionalAssignment`, respectively, is specified as non-zero.
-/// The default value for both options is zero.
-///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/readability-simplify-boolean-expr.html

LegalizeAdulthood wrote:
> aaron.ballman wrote:
> > I think I can agree with that, but I also think it depends a lot on what 
> > the purpose to the check is. If it's "improve readability regarding parens" 
> > + options that control when to remove or add, that makes sense to me. 
> > Otherwise, I think segregating the checks into one that removes (plus 
> > options) and one that adds (plus options) makes sense -- even if they 
> > perhaps use the same underlying heuristic engine and are simply surfaced as 
> > separate checks.
> This check isn't at all about the readability of parens, so it doesn't make 
> sense for this check to be concerned with it IMO.
Agreed; trying to suss out what the appropriate design for this particular 
check is. I think I've talked myself into "don't touch parens here."


http://reviews.llvm.org/D16308



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


Re: [PATCH] D16770: [MS] PR26234: Allow typedef redefinition of equally qualified, sized and aligned types in C

2016-02-01 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: include/clang/AST/ASTContext.h:1771-1782
@@ -1770,1 +1770,14 @@
 
+  /// Return true is the given types are compatible in C from MSVC's point of
+  /// view.
+  //
+  // Conditions:
+  //   1. Both types are equally-qualified, sized and aligned;
+  //   2. Both types are either integer, floating-point, enumeral or pointers;
+  //   3. If pointers:
+  // 3.1. Levels of pointers are equal;
+  // 3.2. Pointee types are MSVC-compatible OR
+  // 3.3. One type points to void and another points to char.
+  //   4. Enumeral types are NOT compatible with floating-point types.
+  bool areMSCompatibleTypesInC(QualType OldType, QualType NewType);
+

Please update the comments to reflect that this only applies to typedef types.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4265-4267
@@ -4264,2 +4264,5 @@
   InGroup>;
+def warn_benign_redefinition_different_typedef : ExtWarn<
+  "benign typedef redefinition with different types%diff{ ($ vs $)|}0,1 "
+  "is a Microsoft extension">, InGroup;
 def err_redefinition_different_typedef : Error<

majnemer wrote:
> I think giving a warning that 'benign' sends the message that the code is OK 
> and that the warning should be disabled.  I think we should say something 
> like "typedef redefinition is ignored due to conflicting underlying type".
We aren't ignoring it because the underyling types differ, we're ignoring it 
because they are the same size and signedness and we're in MSVC quirks mode. 
Maybe "ignoring conflicting integer typedef redefinition%diff{...} as a 
Microsoft extension; types have the same width and signedness"? Is that too 
much text?


Comment at: lib/AST/ASTContext.cpp:6727-6728
@@ +6726,4 @@
+bool ASTContext::areMSCompatibleTypesInC(QualType OldType, QualType NewType) {
+  assert(getLangOpts().MicrosoftExt &&
+ "This routine must be called in Microsoft mode only!");
+  assert(!getLangOpts().CPlusPlus && !getLangOpts().ObjC1 &&

majnemer wrote:
> Shouldn't this be `MSVCCompat`, not `MicrosoftExt`?
+1


http://reviews.llvm.org/D16770



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


Re: r259260 - [UBSan] Add documentation for runtime issue suppression.

2016-02-01 Thread Hans Wennborg via cfe-commits
On Fri, Jan 29, 2016 at 4:50 PM, Alexey Samsonov  wrote:
>
> On Fri, Jan 29, 2016 at 3:16 PM, Hans Wennborg  wrote:
>>
>> Yes, that seems like a good idea. Go ahead and merge (or let me know
>> if you'd prefer me to do it).
>
>
> I'd appreciate if you could do it. Thanks!

r259371. Thanks.

>> On Fri, Jan 29, 2016 at 3:14 PM, Alexey Samsonov 
>> wrote:
>> > Hans, do you think it makes sense to merge this patch into 3.8?
>> >
>> > On Fri, Jan 29, 2016 at 3:07 PM, Alexey Samsonov via cfe-commits
>> >  wrote:
>> >>
>> >> Author: samsonov
>> >> Date: Fri Jan 29 17:07:14 2016
>> >> New Revision: 259260
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=259260&view=rev
>> >> Log:
>> >> [UBSan] Add documentation for runtime issue suppression.
>> >>
>> >> Modified:
>> >> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>> >>
>> >> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=259260&r1=259259&r2=259260&view=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
>> >> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Fri Jan 29 17:07:14
>> >> 2016
>> >> @@ -168,6 +168,38 @@ UndefinedBehaviorSanitizer supports ``sr
>> >>  :doc:`SanitizerSpecialCaseList`, that can be used to suppress error
>> >> reports
>> >>  in the specified source files or functions.
>> >>
>> >> +Runtime suppressions
>> >> +
>> >> +
>> >> +Sometimes you can suppress UBSan error reports for specific files,
>> >> functions,
>> >> +or libraries without recompiling the code. You need to pass a path to
>> >> +suppression file in a ``UBSAN_OPTIONS`` environment variable.
>> >> +
>> >> +.. code-block:: bash
>> >> +
>> >> +UBSAN_OPTIONS=suppressions=MyUBSan.supp
>> >> +
>> >> +You need to specify a :ref:`check ` you are suppressing
>> >> and
>> >> the
>> >> +bug location. For example:
>> >> +
>> >> +.. code-block:: bash
>> >> +
>> >> +  signed-integer-overflow:file-with-known-overflow.cpp
>> >> +  alignment:function_doing_unaligned_access
>> >> +  vptr:shared_object_with_vptr_failures.so
>> >> +
>> >> +There are several limitations:
>> >> +
>> >> +* Sometimes your binary must have enough debug info and/or symbol
>> >> table,
>> >> so
>> >> +  that the runtime could figure out source file or function name to
>> >> match
>> >> +  against the suppression.
>> >> +* It is only possible to suppress recoverable checks. For the example
>> >> above,
>> >> +  you can additionally pass
>> >> +  ``-fsanitize-recover=signed-integer-overflow,alignment,vptr``,
>> >> although
>> >> +  most of UBSan checks are recoverable by default.
>> >> +* Check groups (like ``undefined``) can't be used in suppressions
>> >> file,
>> >> only
>> >> +  fine-grained checks are supported.
>> >> +
>> >>  Supported Platforms
>> >>  ===
>> >>
>> >>
>> >>
>> >> ___
>> >> cfe-commits mailing list
>> >> cfe-commits@lists.llvm.org
>> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>> >
>> >
>> >
>> >
>> > --
>> > Alexey Samsonov
>> > vonos...@gmail.com
>
>
>
>
> --
> Alexey Samsonov
> vonos...@gmail.com
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16526: Add hasRetValue narrowing matcher for returnStmt

2016-02-01 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

In http://reviews.llvm.org/D16526#334938, @aaron.ballman wrote:

> I'm of two minds on this [...]


I just need a thumbs up/down on this.

Thumbs down, I discard the review.

Thumbs up, you take the patch.

Patch by Richard Thomson.


http://reviews.llvm.org/D16526



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


Re: [PATCH] D16526: Add hasRetValue narrowing matcher for returnStmt

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D16526#340785, @LegalizeAdulthood wrote:

> In http://reviews.llvm.org/D16526#334938, @aaron.ballman wrote:
>
> > I'm of two minds on this [...]
>
>
> I just need a thumbs up/down on this.
>
> Thumbs down, I discard the review.
>
> Thumbs up, you take the patch.
>
> Patch by Richard Thomson.


I think the patch should be discarded. I appreciate the time you put into 
making the patch, however!


http://reviews.llvm.org/D16526



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


Re: [PATCH] D16135: Macro Debug Info support in Clang

2016-02-01 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:2099
@@ -2098,1 +2098,3 @@
 
+llvm::DIMacro *CGDebugInfo::CreateMacro(llvm::DIMacroFile *Parent, bool 
IsUndef,
+SourceLocation LineLoc, StringRef Name,

By using a bool for IsUndef, we'll end up with somewhat ugly call sites like  
  DI->CreateMacro(Parent, /*IsUndef*/ true, ...);
so we might as well just pass in the dwarf constant
  DI->CreateMacro(Parent, llvm::dwarf::DW_MACINFO_undef, ...);
directly.


http://reviews.llvm.org/D16135



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


r259376 - Move LocInfoType from Sema to AST.

2016-02-01 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Feb  1 11:42:01 2016
New Revision: 259376

URL: http://llvm.org/viewvc/llvm-project?rev=259376&view=rev
Log:
Move LocInfoType from Sema to AST.

While transient and only used during parsing, LocInfoTypes are still used
from ASTDumper and are part of the AST.

Added:
cfe/trunk/include/clang/AST/LocInfoType.h
  - copied, changed from r259366, cfe/trunk/include/clang/Sema/LocInfoType.h
Removed:
cfe/trunk/include/clang/Sema/LocInfoType.h
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTConsumer.cpp
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp

Copied: cfe/trunk/include/clang/AST/LocInfoType.h (from r259366, 
cfe/trunk/include/clang/Sema/LocInfoType.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/LocInfoType.h?p2=cfe/trunk/include/clang/AST/LocInfoType.h&p1=cfe/trunk/include/clang/Sema/LocInfoType.h&r1=259366&r2=259376&rev=259376&view=diff
==
--- cfe/trunk/include/clang/Sema/LocInfoType.h (original)
+++ cfe/trunk/include/clang/AST/LocInfoType.h Mon Feb  1 11:42:01 2016
@@ -36,11 +36,10 @@ class LocInfoType : public Type {
   TypeSourceInfo *DeclInfo;
 
   LocInfoType(QualType ty, TypeSourceInfo *TInfo)
-: Type((TypeClass)LocInfo, ty, ty->isDependentType(),
-   ty->isInstantiationDependentType(),
-   ty->isVariablyModifiedType(),
-   ty->containsUnexpandedParameterPack()),
-  DeclInfo(TInfo) {
+  : Type((TypeClass)LocInfo, ty, ty->isDependentType(),
+ ty->isInstantiationDependentType(), ty->isVariablyModifiedType(),
+ ty->containsUnexpandedParameterPack()),
+DeclInfo(TInfo) {
 assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in 
TC?");
   }
   friend class Sema;

Removed: cfe/trunk/include/clang/Sema/LocInfoType.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/LocInfoType.h?rev=259375&view=auto
==
--- cfe/trunk/include/clang/Sema/LocInfoType.h (original)
+++ cfe/trunk/include/clang/Sema/LocInfoType.h (removed)
@@ -1,62 +0,0 @@
-//===--- LocInfoType.h - Parsed Type with Location Information---*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// This file defines the LocInfoType class, which holds a type and its
-// source-location information.
-//
-//===--===//
-#ifndef LLVM_CLANG_SEMA_LOCINFOTYPE_H
-#define LLVM_CLANG_SEMA_LOCINFOTYPE_H
-
-#include "clang/AST/Type.h"
-
-namespace clang {
-
-class TypeSourceInfo;
-
-/// \brief Holds a QualType and a TypeSourceInfo* that came out of a declarator
-/// parsing.
-///
-/// LocInfoType is a "transient" type, only needed for passing to/from Parser
-/// and Sema, when we want to preserve type source info for a parsed type.
-/// It will not participate in the type system semantics in any way.
-class LocInfoType : public Type {
-  enum {
-// The last number that can fit in Type's TC.
-// Avoids conflict with an existing Type class.
-LocInfo = Type::TypeLast + 1
-  };
-
-  TypeSourceInfo *DeclInfo;
-
-  LocInfoType(QualType ty, TypeSourceInfo *TInfo)
-: Type((TypeClass)LocInfo, ty, ty->isDependentType(),
-   ty->isInstantiationDependentType(),
-   ty->isVariablyModifiedType(),
-   ty->containsUnexpandedParameterPack()),
-  DeclInfo(TInfo) {
-assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in 
TC?");
-  }
-  friend class Sema;
-
-public:
-  QualType getType() const { return getCanonicalTypeInternal(); }
-  TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; }
-
-  void getAsStringInternal(std::string &Str,
-   const PrintingPolicy &Policy) const;
-
-  static bool classof(const Type *T) {
-return T->getTypeClass() == (TypeClass)LocInfo;
-  }
-};
-
-} // end namespace clang
-
-#endif // LLVM_CLANG_SEMA_LOCINFOTYPE_H

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=259376&r1=259375&r2=259376&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Feb  1 11:42:01 2016
@@ -20,6 +20,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/ExternalASTSource.h"
+#include "clang/AST/LocInfoType.h"
 #include "clang/AST/MangleNumberingContext.h"
 #include "clang/AST/NSAPI.h"
 #include "clang/AST/PrettyPrinter.h"
@@ -35,7 +36,6 @@
 #include

Re: [PATCH] D15305: [CUDA] Do not allow dynamic initialization of global device side variables.

2016-02-01 Thread Jacques Pienaar via cfe-commits
jpienaar added a comment.

@jlebar: We defer it to your and Richard's approval. Thanks


http://reviews.llvm.org/D15305



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


Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute

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


Comment at: include/clang/Parse/Parser.h:2200
@@ -2199,1 +2199,3 @@
   void ParseOpenCLQualifiers(ParsedAttributes &Attrs);
+  /// \brief Parses opencl_unroll_hint attribute if language is OpenCL 2.0+.
+  /// \return false if error happens.

May be better:
 OpenCL 2.0+ -> OpenCL v2.0 or higher


Comment at: lib/CodeGen/CGLoopInfo.cpp:131
@@ +130,3 @@
+// equivalent LoopHintAttr enums.
+// See OpenCL 2.0 spec section 6.11.5 for details.
+// 0 corresponds to opencl_unroll_hint attribute without

Just to match the other comment style:

OpenCL 2.0 spec section 6.11.5 -> OpenCL v2.0 s6.11.5


Comment at: lib/Sema/SemaStmtAttr.cpp:212
@@ +211,3 @@
+  // factor) or 1 argument (the unroll factor provided by the user).
+  // See OpenCL 2.0 spec section 6.11.5 for details.
+

OpenCL v2.0 s6.11.5


Comment at: lib/Sema/SemaStmtAttr.cpp:221
@@ +220,3 @@
+
+  unsigned unrollingFactor = 0;
+

Variable names are still not compliant to coding style. Could you please change.


Comment at: lib/Sema/SemaStmtAttr.cpp:234
@@ +233,3 @@
+}
+
+int64_t val = ArgVal.getSExtValue();

Could you please change the type to int to match similar code in other places.


Comment at: lib/Sema/SemaStmtAttr.cpp:235
@@ +234,3 @@
+
+int64_t val = ArgVal.getSExtValue();
+

Also could you change variable name here too and in other places to follow the 
coding style.


Comment at: test/CodeGenOpenCL/unroll-hint.cl:9
@@ +8,3 @@
+for( int i = 0; i < 1000; ++i) {
+*sum += i;
+}

I would make all loops with an empty body here too as it doesn't play any role 
in testing. :)


http://reviews.llvm.org/D16686



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


[PATCH] D16779: Fix attribute((mode([word|unwind_word]))) for x32

2016-02-01 Thread H.J Lu via cfe-commits
hjl.tools created this revision.
hjl.tools added reviewers: rnk, rafael.
hjl.tools added a subscriber: cfe-commits.

```
typedef unsigned int gcc_word __attribute__((mode(word)));
```
and

```
typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
```
define the largest unsigned integer types which can be stored in a
general purpose register, which may not be the pointer type.  For x32,
they aren't pointer nor unsigned long.  We should

1. Make getUnwindWordWidth and getRegisterWidth virtual,
2. Override them for x32, similar to hasInt128Type.
3. Use getRegisterWidth for __attribute__((mode(word)));

This fixes PR 24706.


http://reviews.llvm.org/D16779

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/attr-mode.c

Index: test/Sema/attr-mode.c
===
--- test/Sema/attr-mode.c
+++ test/Sema/attr-mode.c
@@ -4,6 +4,8 @@
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_64BIT_PPC64 
-fsyntax-only \
 // RUN:   -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 
-fsyntax-only \
+// RUN:   -verify %s
 
 typedef int i16_1 __attribute((mode(HI)));
 int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
@@ -63,8 +65,17 @@
 void test_long_to_i64(long long* y) { f_i64_arg(y); }
 void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
 #elif TEST_64BIT_X86
+#ifdef __ILP32__
+typedef unsigned int gcc_word __attribute__((mode(word)));
+int foo[sizeof(gcc_word) == 8 ? 1 : -1];
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
+void test_long_to_i64(long long* y) { f_i64_arg(y); }
+void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
+#else
 void test_long_to_i64(long* y) { f_i64_arg(y); }
 void test_long_to_ui64(unsigned long* y) { f_ui64_arg(y); }
+#endif
 typedef  float f128ibm __attribute__ ((mode (TF))); // 
expected-error{{unsupported machine mode 'TF'}}
 #elif TEST_64BIT_PPC64
 typedef  float f128ibm __attribute__ ((mode (TF)));
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3332,7 +3332,7 @@
 // FIXME: glibc uses 'word' to define register_t; this is narrower than a
 // pointer on PIC16 and other embedded platforms.
 if (Str == "word")
-  DestWidth = S.Context.getTargetInfo().getPointerWidth(0);
+  DestWidth = S.Context.getTargetInfo().getRegisterWidth();
 else if (Str == "byte")
   DestWidth = S.Context.getTargetInfo().getCharWidth();
 break;
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4029,6 +4029,8 @@
 
   // for x32 we need it here explicitly
   bool hasInt128Type() const override { return true; }
+  unsigned getUnwindWordWidth() const override { return 64; }
+  unsigned getRegisterWidth() const override { return 64; }
 
   bool validateGlobalRegisterVariable(StringRef RegName,
   unsigned RegSize,
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -413,10 +413,10 @@
   }
 
   // Return the size of unwind_word for this target.
-  unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
+  virtual unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
 
   /// \brief Return the "preferred" register width on this target.
-  unsigned getRegisterWidth() const {
+  virtual unsigned getRegisterWidth() const {
 // Currently we assume the register width on the target matches the pointer
 // width, we can introduce a new variable for this if/when some target 
wants
 // it.


Index: test/Sema/attr-mode.c
===
--- test/Sema/attr-mode.c
+++ test/Sema/attr-mode.c
@@ -4,6 +4,8 @@
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_64BIT_PPC64 -fsyntax-only \
 // RUN:   -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 -fsyntax-only \
+// RUN:   -verify %s
 
 typedef int i16_1 __attribute((mode(HI)));
 int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
@@ -63,8 +65,17 @@
 void test_long_to_i64(long long* y) { f_i64_arg(y); }
 void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
 #elif TEST_64BIT_X86
+#ifdef __ILP32__
+typedef unsigned int gcc_word __attribute__((mode(word)));
+int foo[sizeof(gcc_word) == 8 ? 1 : -1];
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
+void test_long_to_i64(long long* y) { f_i64_arg(y); }
+void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }

Re: [PATCH] D16351: [FIX] Bug 25404 - Crash on typedef in OpenCL 2.0

2016-02-01 Thread Anastasia Stulova via cfe-commits
Anastasia added a subscriber: Anastasia.


Comment at: lib/Sema/SemaDecl.cpp:2038
@@ +2037,3 @@
+  // returns 0. The're many implicit typedefs in OpenCL, e.g. atomic_flag.
+  if (Old->isImplicit() || New->isImplicit()) {
+return;

Braces are not needed.


Comment at: test/SemaOpenCL/implicit-typedef.cl:1
@@ +1,2 @@
+// RUN: %clang_cc1 "-cc1" "-emit-llvm" "-D" "cl_khr_fp64" "-D" 
"cl_khr_int64_base_atomics" "-fno-dwarf-directory-asm" "-fmessage-length" "205" 
"-fdiagnostics-show-option" "-cl-std=CL2.0" "-x" "cl" "%s" 
"-fcolor-diagnostics" -o -
+typedef atomic_int atomic_flag;

"-cc1" is not needed. I have a feeling most of the things are not needed here.

Generally doesn't seem to follow the style. Could you please check other tests 
as an example. Let's say test/SemaOpenCL/extern.cl.


Comment at: test/SemaOpenCL/implicit-typedef.cl:2
@@ +1,2 @@
+// RUN: %clang_cc1 "-cc1" "-emit-llvm" "-D" "cl_khr_fp64" "-D" 
"cl_khr_int64_base_atomics" "-fno-dwarf-directory-asm" "-fmessage-length" "205" 
"-fdiagnostics-show-option" "-cl-std=CL2.0" "-x" "cl" "%s" 
"-fcolor-diagnostics" -o -
+typedef atomic_int atomic_flag;

ichesnokov wrote:
> ichesnokov wrote:
> > Not necessary. Removed.
> -main-file-name is not necessary. Removed.
So now we just silently allow to redefine a builtin OpenCL type. Wondering if 
giving a warning would be a better option? 


Repository:
  rL LLVM

http://reviews.llvm.org/D16351



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


Re: [PATCH] D16779: Fix attribute((mode([word|unwind_word]))) for x32

2016-02-01 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

Should I land this for you?


http://reviews.llvm.org/D16779



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


Re: [PATCH] D16779: Fix attribute((mode([word|unwind_word]))) for x32

2016-02-01 Thread H.J Lu via cfe-commits
hjl.tools added a comment.

Yes, please.  Thanks.


http://reviews.llvm.org/D16779



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


r259382 - docs: Clarify that cfi-unrelated-cast is based on lifetime.

2016-02-01 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon Feb  1 12:55:50 2016
New Revision: 259382

URL: http://llvm.org/viewvc/llvm-project?rev=259382&view=rev
Log:
docs: Clarify that cfi-unrelated-cast is based on lifetime.

Also restore Makefile.sphinx which is needed to build the documentation.

Added:
cfe/trunk/docs/Makefile.sphinx
Modified:
cfe/trunk/docs/ControlFlowIntegrity.rst

Modified: cfe/trunk/docs/ControlFlowIntegrity.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ControlFlowIntegrity.rst?rev=259382&r1=259381&r2=259382&view=diff
==
--- cfe/trunk/docs/ControlFlowIntegrity.rst (original)
+++ cfe/trunk/docs/ControlFlowIntegrity.rst Mon Feb  1 12:55:50 2016
@@ -129,7 +129,8 @@ type ``void*`` or another unrelated type
 The difference between these two types of casts is that the first is defined
 by the C++ standard to produce an undefined value, while the second is not
 in itself undefined behavior (it is well defined to cast the pointer back
-to its original type).
+to its original type) unless the object is uninitialized and the cast is a
+``static_cast`` (see C++14 [basic.life]p5).
 
 If a program as a matter of policy forbids the second type of cast, that
 restriction can normally be enforced. However it may in some cases be necessary

Added: cfe/trunk/docs/Makefile.sphinx
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Makefile.sphinx?rev=259382&view=auto
==
--- cfe/trunk/docs/Makefile.sphinx (added)
+++ cfe/trunk/docs/Makefile.sphinx Mon Feb  1 12:55:50 2016
@@ -0,0 +1,163 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS=
+SPHINXBUILD   = sphinx-build
+PAPER =
+BUILDDIR  = _build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp 
epub latex latexpdf text man changes linkcheck doctest gettext default
+
+default: html
+
+help:
+   @echo "Please use \`make ' where  is one of"
+   @echo "  html   to make standalone HTML files"
+   @echo "  dirhtmlto make HTML files named index.html in directories"
+   @echo "  singlehtml to make a single large HTML file"
+   @echo "  pickle to make pickle files"
+   @echo "  json   to make JSON files"
+   @echo "  htmlhelp   to make HTML files and a HTML help project"
+   @echo "  qthelp to make HTML files and a qthelp project"
+   @echo "  devhelpto make HTML files and a Devhelp project"
+   @echo "  epub   to make an epub"
+   @echo "  latex  to make LaTeX files, you can set PAPER=a4 or 
PAPER=letter"
+   @echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+   @echo "  text   to make text files"
+   @echo "  manto make manual pages"
+   @echo "  texinfoto make Texinfo files"
+   @echo "  info   to make Texinfo files and run them through makeinfo"
+   @echo "  gettextto make PO message catalogs"
+   @echo "  changesto make an overview of all changed/added/deprecated 
items"
+   @echo "  linkcheck  to check all external links for integrity"
+   @echo "  doctestto run all doctests embedded in the documentation 
(if enabled)"
+
+clean:
+   -rm -rf $(BUILDDIR)/*
+
+html:
+   $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+   @echo
+   @# FIXME: Remove this `cp` once HTML->Sphinx transition is completed.
+   @# Kind of a hack, but HTML-formatted docs are on the way out anyway.
+   @echo "Copying legacy HTML-formatted docs into $(BUILDDIR)/html"
+   @cp -a *.html $(BUILDDIR)/html
+   @# FIXME: What we really need is a way to specify redirects, so that
+   @# we can just redirect to a reST'ified version of this document.
+   @# PR14714 is tracking the issue of redirects.
+   @cp -a Block-ABI-Apple.txt $(BUILDDIR)/html
+   @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+   $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+   @echo
+   @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+   $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+   @echo
+   @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+   $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+   @echo
+   @echo "Build finished; now you can process the pickle files."
+
+json:
+   $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+   @ech

r259383 - Fix attribute((mode([word|unwind_word]))) for x32

2016-02-01 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Feb  1 12:58:24 2016
New Revision: 259383

URL: http://llvm.org/viewvc/llvm-project?rev=259383&view=rev
Log:
Fix attribute((mode([word|unwind_word]))) for x32

Patch by H.J. Lu

```
typedef unsigned int gcc_word __attribute__((mode(word)));
```
and

```
typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
```
define the largest unsigned integer types which can be stored in a
general purpose register, which may not be the pointer type.  For x32,
they aren't pointer nor unsigned long.  We should

1. Make getUnwindWordWidth and getRegisterWidth virtual,
2. Override them for x32, similar to hasInt128Type.
3. Use getRegisterWidth for __attribute__((mode(word)));

This fixes PR 24706.

Reviewers: rnk

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

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-mode.c

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=259383&r1=259382&r2=259383&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Mon Feb  1 12:58:24 2016
@@ -413,10 +413,10 @@ public:
   }
 
   // Return the size of unwind_word for this target.
-  unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
+  virtual unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
 
   /// \brief Return the "preferred" register width on this target.
-  unsigned getRegisterWidth() const {
+  virtual unsigned getRegisterWidth() const {
 // Currently we assume the register width on the target matches the pointer
 // width, we can introduce a new variable for this if/when some target 
wants
 // it.

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=259383&r1=259382&r2=259383&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb  1 12:58:24 2016
@@ -4029,6 +4029,8 @@ public:
 
   // for x32 we need it here explicitly
   bool hasInt128Type() const override { return true; }
+  unsigned getUnwindWordWidth() const override { return 64; }
+  unsigned getRegisterWidth() const override { return 64; }
 
   bool validateGlobalRegisterVariable(StringRef RegName,
   unsigned RegSize,

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=259383&r1=259382&r2=259383&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Feb  1 12:58:24 2016
@@ -3332,7 +3332,7 @@ static void parseModeAttrArg(Sema &S, St
 // FIXME: glibc uses 'word' to define register_t; this is narrower than a
 // pointer on PIC16 and other embedded platforms.
 if (Str == "word")
-  DestWidth = S.Context.getTargetInfo().getPointerWidth(0);
+  DestWidth = S.Context.getTargetInfo().getRegisterWidth();
 else if (Str == "byte")
   DestWidth = S.Context.getTargetInfo().getCharWidth();
 break;

Modified: cfe/trunk/test/Sema/attr-mode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-mode.c?rev=259383&r1=259382&r2=259383&view=diff
==
--- cfe/trunk/test/Sema/attr-mode.c (original)
+++ cfe/trunk/test/Sema/attr-mode.c Mon Feb  1 12:58:24 2016
@@ -4,6 +4,8 @@
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_64BIT_PPC64 
-fsyntax-only \
 // RUN:   -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 
-fsyntax-only \
+// RUN:   -verify %s
 
 typedef int i16_1 __attribute((mode(HI)));
 int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
@@ -63,8 +65,17 @@ void test_int_to_ui32(unsigned int* y) {
 void test_long_to_i64(long long* y) { f_i64_arg(y); }
 void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
 #elif TEST_64BIT_X86
+#ifdef __ILP32__
+typedef unsigned int gcc_word __attribute__((mode(word)));
+int foo[sizeof(gcc_word) == 8 ? 1 : -1];
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
+void test_long_to_i64(long long* y) { f_i64_arg(y); }
+void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
+#else
 void test_long_to_i64(long* y) { f_i64_arg(y); }
 void test_long_to_ui64(unsigned long* y) { f_ui64_arg(y); }
+#endif
 typedef  float f128ibm __attribute__ ((mode (TF))); // 
expected-error{{unsupported machine mode 'TF'}}
 #elif TEST_64BIT_PPC64
 typedef  

Re: [PATCH] D16779: Fix attribute((mode([word|unwind_word]))) for x32

2016-02-01 Thread Reid Kleckner via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL259383: Fix attribute((mode([word|unwind_word]))) for x32 
(authored by rnk).

Changed prior to commit:
  http://reviews.llvm.org/D16779?vs=46558&id=46559#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16779

Files:
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/Sema/attr-mode.c

Index: cfe/trunk/include/clang/Basic/TargetInfo.h
===
--- cfe/trunk/include/clang/Basic/TargetInfo.h
+++ cfe/trunk/include/clang/Basic/TargetInfo.h
@@ -413,10 +413,10 @@
   }
 
   // Return the size of unwind_word for this target.
-  unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
+  virtual unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
 
   /// \brief Return the "preferred" register width on this target.
-  unsigned getRegisterWidth() const {
+  virtual unsigned getRegisterWidth() const {
 // Currently we assume the register width on the target matches the pointer
 // width, we can introduce a new variable for this if/when some target 
wants
 // it.
Index: cfe/trunk/test/Sema/attr-mode.c
===
--- cfe/trunk/test/Sema/attr-mode.c
+++ cfe/trunk/test/Sema/attr-mode.c
@@ -4,6 +4,8 @@
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_64BIT_PPC64 
-fsyntax-only \
 // RUN:   -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 
-fsyntax-only \
+// RUN:   -verify %s
 
 typedef int i16_1 __attribute((mode(HI)));
 int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
@@ -63,8 +65,17 @@
 void test_long_to_i64(long long* y) { f_i64_arg(y); }
 void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
 #elif TEST_64BIT_X86
+#ifdef __ILP32__
+typedef unsigned int gcc_word __attribute__((mode(word)));
+int foo[sizeof(gcc_word) == 8 ? 1 : -1];
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
+void test_long_to_i64(long long* y) { f_i64_arg(y); }
+void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
+#else
 void test_long_to_i64(long* y) { f_i64_arg(y); }
 void test_long_to_ui64(unsigned long* y) { f_ui64_arg(y); }
+#endif
 typedef  float f128ibm __attribute__ ((mode (TF))); // 
expected-error{{unsupported machine mode 'TF'}}
 #elif TEST_64BIT_PPC64
 typedef  float f128ibm __attribute__ ((mode (TF)));
Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -3332,7 +3332,7 @@
 // FIXME: glibc uses 'word' to define register_t; this is narrower than a
 // pointer on PIC16 and other embedded platforms.
 if (Str == "word")
-  DestWidth = S.Context.getTargetInfo().getPointerWidth(0);
+  DestWidth = S.Context.getTargetInfo().getRegisterWidth();
 else if (Str == "byte")
   DestWidth = S.Context.getTargetInfo().getCharWidth();
 break;
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4029,6 +4029,8 @@
 
   // for x32 we need it here explicitly
   bool hasInt128Type() const override { return true; }
+  unsigned getUnwindWordWidth() const override { return 64; }
+  unsigned getRegisterWidth() const override { return 64; }
 
   bool validateGlobalRegisterVariable(StringRef RegName,
   unsigned RegSize,


Index: cfe/trunk/include/clang/Basic/TargetInfo.h
===
--- cfe/trunk/include/clang/Basic/TargetInfo.h
+++ cfe/trunk/include/clang/Basic/TargetInfo.h
@@ -413,10 +413,10 @@
   }
 
   // Return the size of unwind_word for this target.
-  unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
+  virtual unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
 
   /// \brief Return the "preferred" register width on this target.
-  unsigned getRegisterWidth() const {
+  virtual unsigned getRegisterWidth() const {
 // Currently we assume the register width on the target matches the pointer
 // width, we can introduce a new variable for this if/when some target wants
 // it.
Index: cfe/trunk/test/Sema/attr-mode.c
===
--- cfe/trunk/test/Sema/attr-mode.c
+++ cfe/trunk/test/Sema/attr-mode.c
@@ -4,6 +4,8 @@
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_64BIT_PPC64 -fsyntax-only \
 // RUN:   -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 -fsyntax-only \
+// RUN:   -verify %s
 
 typedef int i16_1 __attr

[clang-tools-extra] r259393 - Sort checks alphabetically in ReadabilityTidyModule.cpp.

2016-02-01 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Mon Feb  1 13:47:24 2016
New Revision: 259393

URL: http://llvm.org/viewvc/llvm-project?rev=259393&view=rev
Log:
Sort checks alphabetically in ReadabilityTidyModule.cpp.

Modified:
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp?rev=259393&r1=259392&r2=259393&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
Mon Feb  1 13:47:24 2016
@@ -45,18 +45,18 @@ public:
 "readability-implicit-bool-cast");
 CheckFactories.registerCheck(
 "readability-inconsistent-declaration-parameter-name");
-CheckFactories.registerCheck(
-"readability-redundant-control-flow");
-CheckFactories.registerCheck(
-"readability-uniqueptr-delete-release");
 CheckFactories.registerCheck(
 "readability-named-parameter");
+CheckFactories.registerCheck(
+"readability-redundant-control-flow");
 CheckFactories.registerCheck(
 "readability-redundant-smartptr-get");
 CheckFactories.registerCheck(
 "readability-redundant-string-cstr");
 CheckFactories.registerCheck(
 "readability-simplify-boolean-expr");
+CheckFactories.registerCheck(
+"readability-uniqueptr-delete-release");
   }
 };
 


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


RE: [PATCH] D16754: Bug 15785 - OpenCL errors using vector/scalar conditionals and short integer types

2016-02-01 Thread Robinson, Paul via cfe-commits
> Hi Anton,
> 
>   Okey, nevermore.
>   But what to do with a bug which needs simply be closed (NABs)?
>   I believe they also need a review/approval.
> 
> Igor

Bugs do not have such a strict process, compared to patches.
If you don't feel confident in closing the bug directly, you can ask
the person who submitted the bug if they are happy with your answer.
--paulr

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


Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute

2016-02-01 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 46570.
yaxunl marked 7 inline comments as done.
yaxunl added a comment.

Revised as Anastasia suggested.


http://reviews.llvm.org/D16686

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  lib/CodeGen/CGLoopInfo.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaStmtAttr.cpp
  test/CodeGenOpenCL/unroll-hint.cl
  test/Parser/opencl-unroll-hint.cl
  test/SemaOpenCL/unroll-hint.cl

Index: test/SemaOpenCL/unroll-hint.cl
===
--- /dev/null
+++ test/SemaOpenCL/unroll-hint.cl
@@ -0,0 +1,19 @@
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
+
+kernel void C (global int *x) {
+  int I = 3;
+  __attribute__((opencl_unroll_hint(I))) // expected-error {{opencl_unroll_hint attribute requires an integer constant}}
+  while (I--);
+}
+
+kernel void D (global int *x) {
+  int i = 10;
+  __attribute__((opencl_unroll_hint))
+  do {
+  } while(i--);
+}
+
+kernel void E() {
+  __attribute__((opencl_unroll_hint(2,4))) // expected-error {{1 attribute takes no more than 1 argument}}
+  for(int i=0; i<100; i++);
+}
Index: test/Parser/opencl-unroll-hint.cl
===
--- /dev/null
+++ test/Parser/opencl-unroll-hint.cl
@@ -0,0 +1,8 @@
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
+
+kernel void B (global int *x) {
+  __attribute__((opencl_unroll_hint(42)))
+  if (x[0]) // expected-error {{OpenCL only supports opencl_unroll_hint attribute on for, while, and do statements}}
+x[0] = 15;
+}
+
Index: test/CodeGenOpenCL/unroll-hint.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/unroll-hint.cl
@@ -0,0 +1,96 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+/*** for ***/
+void for_count()
+{
+// CHECK-LABEL: for_count
+__attribute__((opencl_unroll_hint(8)))
+for( int i = 0; i < 1000; ++i);
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_COUNT:.*]]
+}
+
+void for_disable()
+{
+// CHECK-LABEL: for_disable
+__attribute__((opencl_unroll_hint(1)))
+for( int i = 0; i < 1000; ++i);
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_DISABLE:.*]]
+}
+
+void for_full()
+{
+// CHECK-LABEL: for_full
+__attribute__((opencl_unroll_hint))
+for( int i = 0; i < 1000; ++i);
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_FULL:.*]]
+}
+
+/*** while ***/
+void while_count()
+{
+// CHECK-LABEL: while_count
+int i = 1000;
+__attribute__((opencl_unroll_hint(8)))
+while(i-->0);
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_COUNT:.*]]
+}
+
+void while_disable()
+{
+// CHECK-LABEL: while_disable
+int i = 1000;
+__attribute__((opencl_unroll_hint(1)))
+while(i-->0);
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_DISABLE:.*]]
+}
+
+void while_full()
+{
+// CHECK-LABEL: while_full
+int i = 1000;
+__attribute__((opencl_unroll_hint))
+while(i-->0);
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_FULL:.*]]
+}
+
+/*** do ***/
+void do_count()
+{
+// CHECK-LABEL: do_count
+int i = 1000;
+__attribute__((opencl_unroll_hint(8)))
+do {} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_COUNT:.*]]
+}
+
+void do_disable()
+{
+// CHECK-LABEL: do_disable
+int i = 1000;
+__attribute__((opencl_unroll_hint(1)))
+do {} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_DISABLE:.*]]
+}
+
+void do_full()
+{
+// CHECK-LABEL: do_full
+int i = 1000;
+__attribute__((opencl_unroll_hint))
+do {} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_FULL:.*]]
+}
+
+
+// CHECK: ![[FOR_COUNT]] =  distinct !{![[FOR_COUNT]],  ![[COUNT:.*]]}
+// CHECK: ![[COUNT]] =  !{!"llvm.loop.unroll.count", i32 8}
+// CHECK: ![[FOR_DISABLE]]   =  distinct !{![[FOR_DISABLE]],  ![[DISABLE:.*]]}
+// CHECK: ![[DISABLE]]   =  !{!"llvm.loop.unroll.disable"}
+// CHECK: ![[FOR_FULL]]  =  distinct !{![[FOR_FULL]],  ![[FULL:.*]]}
+// CHECK: ![[FULL]]  =  !{!"llvm.loop.unroll.full"}
+// CHECK: ![[WHILE_COUNT]]   =  distinct !{![[WHILE_COUNT]],![[COUNT]]}
+// CHECK: ![[WHILE_DISABLE]] =  distinct !{![[WHILE_DISABLE]],  ![[DISABLE]]}
+// CHECK: ![[WHILE_FULL]]=  distinct !{![[WHILE_FULL]], ![[FULL]]}
+// CHECK: ![[DO_COUNT]]  =  distinct !{![[DO_COUNT]],   ![[COUNT]]}
+// CHECK: ![[DO_DISABLE]]=  distinct !{![[DO_DISABLE]], ![[DISABLE]]}
+// CHECK: ![[DO_FULL]]   =  distinct !{![[DO_FULL]],![[FULL]]}
Index: lib/Sema/SemaStmtAttr.cpp
===
--- lib/Sema/SemaStmtAttr.cpp
+++ lib/Sema/SemaStmtAttr.cpp
@@ -203,6 +203,47 @@
   }
 }
 
+sta

RE: [PATCH] D16754: Bug 15785 - OpenCL errors using vector/scalar conditionals and short integer types

2016-02-01 Thread Igor Chesnokov via cfe-commits
Thanks Paul!

-Original Message-
From: Robinson, Paul [mailto:paul_robin...@playstation.sony.com] 
Sent: Monday, February 1, 2016 11:46 PM
To: Igor Chesnokov; Anton Korobeynikov
Cc: cfe-commits (cfe-commits@lists.llvm.org)
Subject: RE: [PATCH] D16754: Bug 15785 - OpenCL errors using vector/scalar 
conditionals and short integer types

> Hi Anton,
> 
>   Okey, nevermore.
>   But what to do with a bug which needs simply be closed (NABs)?
>   I believe they also need a review/approval.
> 
> Igor

Bugs do not have such a strict process, compared to patches.
If you don't feel confident in closing the bug directly, you can ask the person 
who submitted the bug if they are happy with your answer.
--paulr

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


Re: [PATCH] D15305: [CUDA] Do not allow dynamic initialization of global device side variables.

2016-02-01 Thread Artem Belevich via cfe-commits
Richard,

On Fri, Jan 15, 2016 at 5:32 PM, Richard Smith 
wrote:

> On Fri, Jan 15, 2016 at 5:29 PM, Richard Smith 
> wrote:
> > On Fri, Jan 15, 2016 at 4:22 PM, Artem Belevich  wrote:
> >> tra added inline comments.
> >>
> >> 
> >> Comment at: lib/CodeGen/CodeGenModule.cpp:2334
> >> @@ -2339,1 +2333,3 @@
> >> +  D->hasAttr())
> >>  Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy));
> >> +  else if (!InitExpr) {
> >> 
> >> rsmith wrote:
> >>> As this is a global variable, it should presumably still be statically
> zero-initialized.
> >> There is no way to initialize __shared__ variables. They are rough
> equivalent of local variables, only in this case CUDA allocates them per
> kernel invocation from a shared buffer with no guarantees regarding its
> contents.
> >>
> >> They used to be zero-initialized by compiler, but that was
> intentionally changed to undef in r245786 / http://reviews.llvm.org/D12241
> >
> > That doesn't seem right. C++ guarantees zero-initialization for all
> > globals, prior to performing any other initialization.
>
> It looks like the problem being fixed by D12241 was probably caused by
> the __shared__ variables having the wrong linkage.
>

I'll take a look at this separately as it's unrelated to this patch.

I believe current patch addresses your other comments.

--Artem




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


Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-02-01 Thread Richard Smith via cfe-commits
rsmith added a comment.

This is a bug -- we intend to reuse `Stmt` nodes across the template and its 
instantiations, but we should have separate `Decl` nodes in each instantiation 
(otherwise the `Decl`'s parent will be wrong etc).



Comment at: lib/Sema/SemaTemplateInstantiate.cpp:1519-1521
@@ -1518,5 +1518,5 @@
 
   TypeLoc TL = T->getTypeLoc().IgnoreParens();
   if (!TL.getAs())
 return false;
 

This doesn't look quite right: IIRC, there can be attributes here as well as 
parens (in particular, calling convention attributes can appear in this 
position).


Comment at: lib/Sema/SemaTemplateInstantiate.cpp:1530
@@ -1528,2 +1529,3 @@
 if (!P) continue;
+AllParmsNull = false;
 

Just return true here?


http://reviews.llvm.org/D16478



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


Re: [PATCH] D15305: [CUDA] Do not allow dynamic initialization of global device side variables.

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

Some minor things, but feel free to commit after addressing them.

I agree that we should figure out what to do about the zero/undef 
initialization separately.



Comment at: lib/Sema/SemaCUDA.cpp:429-430
@@ +428,4 @@
+  CXXConstructorDecl *CD) {
+  if (!CD->isDefined() && CD->isTemplateInstantiation())
+InstantiateFunctionDefinition(VarLoc, CD->getFirstDecl());
+

The function might still not be defined after this (if the template is not 
defined); you should presumably return `false` here in that case.


Comment at: lib/Sema/SemaCUDA.cpp:442
@@ +441,3 @@
+  // and the function body is an empty compound statement.
+  if (!(CD->isDefined() && CD->getNumParams() == 0 && CD->hasTrivialBody()))
+return false;

Please do remove the `isDefined` check here. Including it makes a reader wonder 
what case it's trying to handle.


Comment at: lib/Sema/SemaCUDA.cpp:455-457
@@ +454,5 @@
+
+  // Its class has no virtual functions and no virtual base classes.
+  if (CD->getParent()->isDynamicClass())
+return false;
+

Maybe reorder this before the `CXXCtorInitializer` check? It's a much cheaper 
test.


Comment at: lib/Sema/SemaDecl.cpp:10191-10198
@@ +10190,10 @@
+  bool AllowedInit = false;
+  if (const CXXConstructExpr *CE = dyn_cast(Init))
+AllowedInit =
+isEmptyCudaConstructor(VD->getLocation(), CE->getConstructor());
+  else if ((VD->hasAttr() ||
+VD->hasAttr()) &&
+   VD->getInit()->isConstantInitializer(
+   Context, VD->getType()->isReferenceType()))
+AllowedInit = true;
+

What should happen if the init is a constant initializer that is a 
`CXXConstructExpr`, but it uses a constructor that is not empty from CUDA's 
perspective? Such as:

  struct X { constexpr X() { int n = 0; } };
  __device__ X x;

I would assume this should be valid, but I think you'll reject it. Maybe change 
`else if (` to `if (!AllowedInit &&`?


Comment at: lib/Sema/SemaDecl.cpp:10196-10198
@@ +10195,5 @@
+VD->hasAttr()) &&
+   VD->getInit()->isConstantInitializer(
+   Context, VD->getType()->isReferenceType()))
+AllowedInit = true;
+

Might be clearer as

  if (__device__ || __constant__)
AllowedInit = isConstantInitializer(...)


http://reviews.llvm.org/D15305



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


Re: [PATCH] D16748: Cleanup MemRegion.cpp/MemRegion.h

2016-02-01 Thread Alexander Riccio via cfe-commits
ariccio marked an inline comment as done.
ariccio added a comment.

As said in comment, I disagree with the no need for `const` here.



Comment at: C:/LLVM/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1396
@@ -1395,3 +1395,3 @@
   const auto &ReferencedBlockVars = AC->getReferencedBlockVars(BC->getDecl());
-  auto NumBlockVars =
+  const auto NumBlockVars =
   std::distance(ReferencedBlockVars.begin(), ReferencedBlockVars.end());

aaron.ballman wrote:
> No need for a const here; the correct change is to not use auto (here and the 
> line above), but instead spell out the type explicitly.
The const is partly to make sure that the `if (NumBlockVars == 0) {` line never 
accidentally becomes `if (NumBlockVars = 0) {` like it did in CPython:

http://bugs.python.org/issue25844


Comment at: C:/LLVM/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1396
@@ -1395,3 +1395,3 @@
   const auto &ReferencedBlockVars = AC->getReferencedBlockVars(BC->getDecl());
-  auto NumBlockVars =
+  const auto NumBlockVars =
   std::distance(ReferencedBlockVars.begin(), ReferencedBlockVars.end());

ariccio wrote:
> aaron.ballman wrote:
> > No need for a const here; the correct change is to not use auto (here and 
> > the line above), but instead spell out the type explicitly.
> The const is partly to make sure that the `if (NumBlockVars == 0) {` line 
> never accidentally becomes `if (NumBlockVars = 0) {` like it did in CPython:
> 
> http://bugs.python.org/issue25844
For archival reasons, I'll copy & paste the relevant diff here (I hate dead 
links):


```
--- a/PC/launcher.c
+++ b/PC/launcher.c
@@ -114,7 +114,7 @@ static wchar_t * get_env(wchar_t * key)
 if (result >= BUFSIZE) {
 /* Large environment variable. Accept some leakage */
 wchar_t *buf2 = (wchar_t*)malloc(sizeof(wchar_t) * (result+1));
-if (buf2 = NULL) {
+if (buf2 == NULL) {
 error(RC_NO_MEMORY, L"Could not allocate environment buffer");
 }
 GetEnvironmentVariableW(key, buf2, result);
```


http://reviews.llvm.org/D16748



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


Re: [PATCH] D16738: Fix invalid casts in .

2016-02-01 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

In http://reviews.llvm.org/D16738#340175, @EricWF wrote:

> > This also could be fixed in a different way by replacing C-style
>
> >  casts with reinterpret_cast<>, which, from my reading of the
>
> >  standard, is allowed in this context.
>
>
> I agree that using `void*` to represent raw memory is the better approach 
> than `reinterpret_cast<>()`.
>  However I'm concerned that changing the signature (and mangling) of `virtual 
> void __clone(...)` could cause ABI problems.
>  I *think* this should be "safe" because the VTable's mangled name doesn't 
> change. but if I'm wrong we must use `reinterpret_cast<>` for calls to 
> `__clone(...)`.
>
> The parts of the patch that don't affect `__clone(...)` LGTM. You can commit 
> them separably if you want.
>
> > That would not help with CFI
>
> >  though, which still flags such casts as invalid (yes, it is stricter that 
> > the standard).
>
>
> I'm sure there are alternative ways to make CFI shut up. Perhaps we could do 
> the `Buffer* -> Base*` conversion inside a blacklisted function (akin to 
> std::launder)?
>  It would also be nice to have "`__attribute__((__no_sanitize__("cfi")))`.


We do have this attribute.


Repository:
  rL LLVM

http://reviews.llvm.org/D16738



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


[PATCH] D16786: [Clang-tidy] Make modernize-redundant-void-arg working with included files

2016-02-01 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko created this revision.
Eugene.Zelenko added reviewers: alexfh, LegalizeAdulthood, aaron.ballman.
Eugene.Zelenko added a subscriber: cfe-commits.
Eugene.Zelenko set the repository for this revision to rL LLVM.

This fix for PR25894. I checked it on my work code base.

Build and regressions were OK on RHEL 6.

Repository:
  rL LLVM

http://reviews.llvm.org/D16786

Files:
  clang-tidy/modernize/RedundantVoidArgCheck.cpp

Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp
===
--- clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -46,42 +46,30 @@
 namespace modernize {
 
 void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(functionDecl(isExpansionInMainFile(), parameterCountIs(0),
-  unless(isImplicit()), unless(isExternC()))
- .bind(FunctionId),
+  Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()),
+  unless(isExternC())).bind(FunctionId),
  this);
-  Finder->addMatcher(typedefDecl(isExpansionInMainFile()).bind(TypedefId),
- this);
+  Finder->addMatcher(typedefDecl().bind(TypedefId), this);
   auto ParenFunctionType = parenType(innerType(functionType()));
   auto PointerToFunctionType = pointee(ParenFunctionType);
   auto FunctionOrMemberPointer =
   anyOf(hasType(pointerType(PointerToFunctionType)),
 hasType(memberPointerType(PointerToFunctionType)));
-  Finder->addMatcher(
-  fieldDecl(isExpansionInMainFile(), 
FunctionOrMemberPointer).bind(FieldId),
-  this);
-  Finder->addMatcher(
-  varDecl(isExpansionInMainFile(), FunctionOrMemberPointer).bind(VarId),
-  this);
+  Finder->addMatcher(fieldDecl(FunctionOrMemberPointer).bind(FieldId), this);
+  Finder->addMatcher(varDecl(FunctionOrMemberPointer).bind(VarId), this);
   auto CastDestinationIsFunction =
   hasDestinationType(pointsTo(ParenFunctionType));
   Finder->addMatcher(
-  cStyleCastExpr(isExpansionInMainFile(), CastDestinationIsFunction)
-  .bind(CStyleCastId),
-  this);
+  cStyleCastExpr(CastDestinationIsFunction).bind(CStyleCastId), this);
   Finder->addMatcher(
-  cxxStaticCastExpr(isExpansionInMainFile(), CastDestinationIsFunction)
-  .bind(NamedCastId),
-  this);
+  cxxStaticCastExpr(CastDestinationIsFunction).bind(NamedCastId), this);
   Finder->addMatcher(
-  cxxReinterpretCastExpr(isExpansionInMainFile(), 
CastDestinationIsFunction)
-  .bind(NamedCastId),
+  cxxReinterpretCastExpr(CastDestinationIsFunction).bind(NamedCastId),
   this);
   Finder->addMatcher(
-  cxxConstCastExpr(isExpansionInMainFile(), CastDestinationIsFunction)
-  .bind(NamedCastId),
+  cxxConstCastExpr(CastDestinationIsFunction).bind(NamedCastId),
   this);
-  Finder->addMatcher(lambdaExpr(isExpansionInMainFile()).bind(LambdaId), this);
+  Finder->addMatcher(lambdaExpr().bind(LambdaId), this);
 }
 
 void RedundantVoidArgCheck::check(const MatchFinder::MatchResult &Result) {


Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp
===
--- clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -46,42 +46,30 @@
 namespace modernize {
 
 void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(functionDecl(isExpansionInMainFile(), parameterCountIs(0),
-  unless(isImplicit()), unless(isExternC()))
- .bind(FunctionId),
+  Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()),
+  unless(isExternC())).bind(FunctionId),
  this);
-  Finder->addMatcher(typedefDecl(isExpansionInMainFile()).bind(TypedefId),
- this);
+  Finder->addMatcher(typedefDecl().bind(TypedefId), this);
   auto ParenFunctionType = parenType(innerType(functionType()));
   auto PointerToFunctionType = pointee(ParenFunctionType);
   auto FunctionOrMemberPointer =
   anyOf(hasType(pointerType(PointerToFunctionType)),
 hasType(memberPointerType(PointerToFunctionType)));
-  Finder->addMatcher(
-  fieldDecl(isExpansionInMainFile(), FunctionOrMemberPointer).bind(FieldId),
-  this);
-  Finder->addMatcher(
-  varDecl(isExpansionInMainFile(), FunctionOrMemberPointer).bind(VarId),
-  this);
+  Finder->addMatcher(fieldDecl(FunctionOrMemberPointer).bind(FieldId), this);
+  Finder->addMatcher(varDecl(FunctionOrMemberPointer).bind(VarId), this);
   auto CastDestinationIsFunction =
   hasDestinationType(pointsTo(ParenFunctionType));
   Finder->addMatcher(
-  cStyleCastExpr(isExpansionInMainFile(), CastDestinationIsFunction)
-  .bind(CStyleCastId),
-  this);
+  cSt

Re: [PATCH] D16748: Cleanup MemRegion.cpp/MemRegion.h

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: C:/LLVM/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1396
@@ -1395,3 +1395,3 @@
   const auto &ReferencedBlockVars = AC->getReferencedBlockVars(BC->getDecl());
-  auto NumBlockVars =
+  const auto NumBlockVars =
   std::distance(ReferencedBlockVars.begin(), ReferencedBlockVars.end());

ariccio wrote:
> ariccio wrote:
> > aaron.ballman wrote:
> > > No need for a const here; the correct change is to not use auto (here and 
> > > the line above), but instead spell out the type explicitly.
> > The const is partly to make sure that the `if (NumBlockVars == 0) {` line 
> > never accidentally becomes `if (NumBlockVars = 0) {` like it did in CPython:
> > 
> > http://bugs.python.org/issue25844
> For archival reasons, I'll copy & paste the relevant diff here (I hate dead 
> links):
> 
> 
> ```
> --- a/PC/launcher.c
> +++ b/PC/launcher.c
> @@ -114,7 +114,7 @@ static wchar_t * get_env(wchar_t * key)
>  if (result >= BUFSIZE) {
>  /* Large environment variable. Accept some leakage */
>  wchar_t *buf2 = (wchar_t*)malloc(sizeof(wchar_t) * (result+1));
> -if (buf2 = NULL) {
> +if (buf2 == NULL) {
>  error(RC_NO_MEMORY, L"Could not allocate environment buffer");
>  }
>  GetEnvironmentVariableW(key, buf2, result);
> ```
While this form of bug can certainly crop up, it's still a bridge-too-far for 
this project, as I understand it our de facto guidelines on this. I am not 
certain that we want to start sprinkling const onto value types (as opposed to 
reference and pointer types) at this point. If we do, it should certainly be 
something handled a bit more consistently and actively than a general clean-up 
related to unnecessary type casting.


http://reviews.llvm.org/D16748



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


Re: [PATCH] D15450: Avoid double deletion in Clang driver.

2016-02-01 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 46575.
sepavloff added a comment.

Added regression test.


http://reviews.llvm.org/D15450

Files:
  lib/CodeGen/CodeGenAction.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/CodeGenActionTest.cpp

Index: unittests/Frontend/CodeGenActionTest.cpp
===
--- /dev/null
+++ unittests/Frontend/CodeGenActionTest.cpp
@@ -0,0 +1,61 @@
+//===- unittests/Frontend/CodeGenActionTest.cpp --- FrontendAction tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Unit tests for CodeGenAction.
+//
+//===--===//
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/CodeGen/CodeGenAction.h"
+#include "clang/CodeGen/BackendUtil.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+using namespace clang::frontend;
+
+namespace {
+
+
+class NullCodeGenAction : public CodeGenAction {
+public:
+  NullCodeGenAction(llvm::LLVMContext *_VMContext = nullptr)
+: CodeGenAction(Backend_EmitLL, _VMContext) {}
+
+  // The action does not call methods of ATContext.
+  void ExecuteAction() override {
+CompilerInstance &CI = getCompilerInstance();
+if (!CI.hasPreprocessor())
+  return;
+if (!CI.hasSema())
+  CI.createSema(getTranslationUnitKind(), nullptr);
+  }
+};
+
+
+TEST(CodeGenTest, TestNullCodeGen) {
+  CompilerInvocation *Invocation = new CompilerInvocation;
+  Invocation->getPreprocessorOpts().addRemappedFile(
+  "test.cc",
+  MemoryBuffer::getMemBuffer("").release());
+  Invocation->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile("test.cc", IK_CXX));
+  Invocation->getFrontendOpts().ProgramAction = EmitLLVM;
+  Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+  CompilerInstance Compiler;
+  Compiler.setInvocation(Invocation);
+  Compiler.createDiagnostics();
+  EXPECT_TRUE(Compiler.hasDiagnostics());
+
+  std::unique_ptr Act(new NullCodeGenAction);
+  bool Success = Compiler.ExecuteAction(*Act);
+  EXPECT_TRUE(Success);
+}
+
+}
Index: unittests/Frontend/CMakeLists.txt
===
--- unittests/Frontend/CMakeLists.txt
+++ unittests/Frontend/CMakeLists.txt
@@ -4,11 +4,13 @@
 
 add_clang_unittest(FrontendTests
   FrontendActionTest.cpp
+  CodeGenActionTest.cpp
   )
 target_link_libraries(FrontendTests
   clangAST
   clangBasic
   clangFrontend
   clangLex
   clangSema
+  clangCodeGen
   )
Index: lib/CodeGen/CodeGenAction.cpp
===
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -53,7 +53,6 @@
 
 std::unique_ptr Gen;
 
-std::unique_ptr TheModule;
 SmallVector>, 4>
 LinkModules;
 
@@ -81,7 +80,10 @@
 this->LinkModules.push_back(
 std::make_pair(I.first, std::unique_ptr(I.second)));
 }
-std::unique_ptr takeModule() { return std::move(TheModule); }
+llvm::Module *getModule() const { return Gen->GetModule(); }
+std::unique_ptr takeModule() {
+  return std::unique_ptr(Gen->ReleaseModule());
+}
 void releaseLinkModules() {
   for (auto &I : LinkModules)
 I.second.release();
@@ -101,8 +103,6 @@
 
   Gen->Initialize(Ctx);
 
-  TheModule.reset(Gen->GetModule());
-
   if (llvm::TimePassesIsEnabled)
 LLVMIRGeneration.stopTimer();
 }
@@ -149,25 +149,12 @@
   }
 
   // Silently ignore if we weren't initialized for some reason.
-  if (!TheModule)
-return;
-
-  // Make sure IR generation is happy with the module. This is released by
-  // the module provider.
-  llvm::Module *M = Gen->ReleaseModule();
-  if (!M) {
-// The module has been released by IR gen on failures, do not double
-// free.
-TheModule.release();
+  if (!getModule())
 return;
-  }
-
-  assert(TheModule.get() == M &&
- "Unexpected module change during IR generation");
 
   // Install an inline asm handler so that diagnostics get printed through
   // our diagnostics hooks.
-  LLVMContext &Ctx = TheModule->getContext();
+  LLVMContext &Ctx = getModule()->getContext();
   LLVMContext::InlineAsmDiagHandlerTy OldHandler =
 Ctx.getInlineAsmDiagnosticHandler();
   void *OldContext = Ctx.getInlineAsmDiagnosticContext();
@@ -182,13 +169,13 @@
   for (auto &I : LinkModules) {
 unsigned LinkFlags = I.first;
 CurLinkModule = I.second.get();
-if (Linker::linkModules(*M, std::move(I.second), LinkFlags))
+if (Linker::linkModules(*getModule(), std::move(I.second), LinkFlags))
   return;

Re: r257710 - [Sema] Suppress diags in overload resolution.

2016-02-01 Thread Richard Smith via cfe-commits
LGTM for 3.8.

On Wed, Jan 13, 2016 at 4:03 PM, Hans Wennborg  wrote:
> Thanks! Richard, what say the code owner?
>
> On Wed, Jan 13, 2016 at 3:59 PM, George Burgess IV
>  wrote:
>> FYI: This patch should to be merged into the clang 3.8.0 branch.
>>
>> Thank you!
>> George
>>
>> On Wed, Jan 13, 2016 at 3:36 PM, George Burgess IV via cfe-commits
>>  wrote:
>>>
>>> Author: gbiv
>>> Date: Wed Jan 13 17:36:34 2016
>>> New Revision: 257710
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=257710&view=rev
>>> Log:
>>> [Sema] Suppress diags in overload resolution.
>>>
>>> We were emitting diagnostics from our shiny new C-only overload
>>> resolution mode. This patch attempts to silence all such diagnostics.
>>>
>>> This fixes PR26085.
>>> Differential Revision: http://reviews.llvm.org/D16159
>>>
>>> Added:
>>> cfe/trunk/test/SemaObjC/ovl-check.m
>>> Modified:
>>> cfe/trunk/include/clang/Sema/Sema.h
>>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>> cfe/trunk/lib/Sema/SemaExprObjC.cpp
>>> cfe/trunk/lib/Sema/SemaOverload.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=257710&r1=257709&r2=257710&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>>> +++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 13 17:36:34 2016
>>> @@ -2229,7 +2229,8 @@ public:
>>>bool CheckPointerConversion(Expr *From, QualType ToType,
>>>CastKind &Kind,
>>>CXXCastPath& BasePath,
>>> -  bool IgnoreBaseAccess);
>>> +  bool IgnoreBaseAccess,
>>> +  bool Diagnose = true);
>>>bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType
>>> ToType,
>>>   bool InOverloadResolution,
>>>   QualType &ConvertedType);
>>> @@ -5388,7 +5389,8 @@ public:
>>>  unsigned AmbigiousBaseConvID,
>>>  SourceLocation Loc, SourceRange
>>> Range,
>>>  DeclarationName Name,
>>> -CXXCastPath *BasePath);
>>> +CXXCastPath *BasePath,
>>> +bool IgnoreAccess = false);
>>>
>>>std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
>>>
>>> @@ -7514,14 +7516,15 @@ public:
>>>  ObjCMethodDecl *&ClassMethod,
>>>  ObjCMethodDecl *&InstanceMethod,
>>>  TypedefNameDecl *&TDNDecl,
>>> -bool CfToNs);
>>> -
>>> +bool CfToNs, bool Diagnose =
>>> true);
>>> +
>>>bool CheckObjCBridgeRelatedConversions(SourceLocation Loc,
>>>   QualType DestType, QualType
>>> SrcType,
>>> - Expr *&SrcExpr);
>>> -
>>> -  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr
>>> *&SrcExpr);
>>> -
>>> + Expr *&SrcExpr, bool Diagnose =
>>> true);
>>> +
>>> +  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr
>>> *&SrcExpr,
>>> +  bool Diagnose = true);
>>> +
>>>bool checkInitMethod(ObjCMethodDecl *method, QualType
>>> receiverTypeIfCall);
>>>
>>>/// \brief Check whether the given new method is a valid override of
>>> the
>>> @@ -8613,6 +8616,7 @@ public:
>>>ARCConversionResult CheckObjCARCConversion(SourceRange castRange,
>>>   QualType castType, Expr
>>> *&op,
>>>   CheckedConversionKind CCK,
>>> + bool Diagnose = true,
>>>   bool DiagnoseCFAudited =
>>> false,
>>>   BinaryOperatorKind Opc =
>>> BO_PtrMemD
>>>   );
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=257710&r1=257709&r2=257710&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Jan 13 17:36:34 2016
>>> @@ -1742,13 +1742,18 @@ void Sema::BuildBasePathArray(const CXXB
>>>  /// otherwise. Loc is the location where this routine should point to
>>>  /// if there is an error, and Range is the source range to highlight
>>>  /// if there is an error.
>>> +///
>>> +/// If eit

r259409 - Code clean up; NFC.

2016-02-01 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Feb  1 15:28:33 2016
New Revision: 259409

URL: http://llvm.org/viewvc/llvm-project?rev=259409&view=rev
Log:
Code clean up; NFC.

Patch by Alexander Riccio.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp?rev=259409&r1=259408&r2=259409&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp Mon Feb  1 15:28:33 
2016
@@ -49,12 +49,12 @@ static void collectCheckers(const Checke
 CheckerOptInfo &opt, CheckerInfoSet &collected) {
   // Use a binary search to find the possible start of the package.
   CheckerRegistry::CheckerInfo packageInfo(nullptr, opt.getName(), "");
-  CheckerRegistry::CheckerInfoList::const_iterator e = checkers.end();
+  auto end = checkers.cend();
   CheckerRegistry::CheckerInfoList::const_iterator i =
-std::lower_bound(checkers.begin(), e, packageInfo, checkerNameLT);
+std::lower_bound(checkers.cbegin(), end, packageInfo, checkerNameLT);
 
   // If we didn't even find a possible package, give up.
-  if (i == e)
+  if (i == end)
 return;
 
   // If what we found doesn't actually start the package, give up.
@@ -73,7 +73,7 @@ static void collectCheckers(const Checke
 size = packageSize->getValue();
 
   // Step through all the checkers in the package.
-  for (e = i+size; i != e; ++i) {
+  for (auto checkEnd = i+size; i != checkEnd; ++i) {
 if (opt.isEnabled())
   collected.insert(&*i);
 else


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


Re: r258396 - Fix crash for typedefs for arrays of runtime bounds in Lambdas/Captured Statements, used in sizeof() expression only.

2016-02-01 Thread Richard Smith via cfe-commits
LGTM for 3.8.

On Thu, Jan 21, 2016 at 1:10 PM, Hans Wennborg  wrote:
> Richard, it was suggested (in
> https://llvm.org/bugs/show_bug.cgi?id=26059#c7) that this gets merged
> to 3.8. I believe this falls under your ownership.
>
> On Thu, Jan 21, 2016 at 4:54 AM, Alexey Bataev via cfe-commits
>  wrote:
>> Author: abataev
>> Date: Thu Jan 21 06:54:48 2016
>> New Revision: 258396
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=258396&view=rev
>> Log:
>> Fix crash for typedefs for arrays of runtime bounds in Lambdas/Captured 
>> Statements, used in sizeof() expression only.
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

2016-02-01 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.h:21-22
@@ -20,71 +20,4 @@
 /// them to use the appropriate boolean expression directly.
 ///
-/// Examples:
-///
-/// ===  
-/// Initial expression   Result
-/// ---  
-/// `if (b == true)` `if (b)`
-/// `if (b == false)``if (!b)`
-/// `if (b && true)` `if (b)`
-/// `if (b && false)``if (false)`
-/// `if (b || true)` `if (true)`
-/// `if (b || false)``if (b)`
-/// `e ? true : false`   `e`
-/// `e ? false : true`   `!e`
-/// `if (true) t(); else f();`   `t();`
-/// `if (false) t(); else f();`  `f();`
-/// `if (e) return true; else return false;` `return e;`
-/// `if (e) return false; else return true;` `return !e;`
-/// `if (e) b = true; else b = false;`   `b = e;`
-/// `if (e) b = false; else b = true;`   `b = !e;`
-/// `if (e) return true; return false;`  `return e;`
-/// `if (e) return false; return true;`  `return !e;`
-/// ===  
-///
-/// The resulting expression `e` is modified as follows:
-///   1. Unnecessary parentheses around the expression are removed.
-///   2. Negated applications of `!` are eliminated.
-///   3. Negated applications of comparison operators are changed to use the
-///  opposite condition.
-///   4. Implicit conversions of pointer to `bool` are replaced with explicit
-///  comparisons to `nullptr`.
-///   5. Implicit casts to `bool` are replaced with explicit casts to `bool`.
-///   6. Object expressions with `explicit operator bool` conversion operators
-///  are replaced with explicit casts to `bool`.
-///
-/// Examples:
-///   1. The ternary assignment `bool b = (i < 0) ? true : false;` has 
redundant
-///  parentheses and becomes `bool b = i < 0;`.
-///
-///   2. The conditional return `if (!b) return false; return true;` has an
-///  implied double negation and becomes `return b;`.
-///
-///   3. The conditional return `if (i < 0) return false; return true;` becomes
-///  `return i >= 0;`.
-///
-///  The conditional return `if (i != 0) return false; return true;` 
becomes
-///  `return i == 0;`.
-///
-///   4. The conditional return `if (p) return true; return false;` has an
-///  implicit conversion of a pointer to `bool` and becomes
-///  `return p != nullptr;`.
-///
-///  The ternary assignment `bool b = (i & 1) ? true : false;` has an
-///  implicit conversion of `i & 1` to `bool` and becomes
-///  `bool b = static_cast(i & 1);`.
-///
-///   5. The conditional return `if (i & 1) return true; else return false;` 
has
-///  an implicit conversion of an integer quantity `i & 1` to `bool` and
-///  becomes `return static_cast(i & 1);`
-///
-///   6. Given `struct X { explicit operator bool(); };`, and an instance `x` 
of
-///  `struct X`, the conditional return `if (x) return true; return false;`
-///  becomes `return static_cast(x);`
-///
-/// When a conditional boolean return or assignment appears at the end of a
-/// chain of `if`, `else if` statements, the conditional statement is left
-/// unchanged unless the option `ChainedConditionalReturn` or
-/// `ChainedConditionalAssignment`, respectively, is specified as non-zero.
-/// The default value for both options is zero.
-///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/readability-simplify-boolean-expr.html

aaron.ballman wrote:
> LegalizeAdulthood wrote:
> > aaron.ballman wrote:
> > > I think I can agree with that, but I also think it depends a lot on what 
> > > the purpose to the check is. If it's "improve readability regarding 
> > > parens" + options that control when to remove or add, that makes sense to 
> > > me. Otherwise, I think segregating the checks into one that removes (plus 
> > > options) and one that adds (plus options) makes sense -- even if they 
> > > perhaps use the same underlying heuristic engine and are simply surfaced 
> > > as separate checks.
> > This check isn't at all about the readability of parens, so it doesn't make 
> > sense for this check to be concerned with it IMO.
> Agreed; trying to suss out what the appropriate design for this particular 
> check is. I think I've talked myself into "don't touch parens here."
Currently in this patch, parens are added when the expression compared to 
`nullptr` or `0` is a binary operator.

I think that is the right thing to do here so we get:

```
bool b = (i & 1) == 0;
```

instead of

```
bool b = i & 1 == 0;
```



http://r

Re: r259271 - Improve -Wconstant-conversion

2016-02-01 Thread Richard Trieu via cfe-commits
C++11 narrowing only happens during certain conversions while this warning
checks all conversions.

We might be able to avoid char array initialization, but it would be a
little tricky.  These warning usually have little information about where
the conversion is coming from, so distinguishing array initialization
versus variable initialization could be hard.

On Sat, Jan 30, 2016 at 6:41 AM, Nico Weber  wrote:

> Shouldn't the new case be in -Wc++11-narrowing instead? This is warning in
> similar places where that warning used to warn.
>
> In practice, char arrays seem to be often used for storing binary blobs in
> header files, and those are usually initialized with numbers 0...255
> instead of -128...127 (why not make the array uint8_t then? Because maybe
> the function you want to pass the data from wants a char* array, and having
> to reinterpret_cast from uint8_t to char is annoying). Maybe this shouldn't
> fire for char arrays?
>
> On Fri, Jan 29, 2016 at 6:51 PM, Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Fri Jan 29 17:51:16 2016
>> New Revision: 259271
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=259271&view=rev
>> Log:
>> Improve -Wconstant-conversion
>>
>> Switch the evaluation from isIntegerConstantExpr to EvaluateAsInt.
>> EvaluateAsInt will evaluate more types of expressions than
>> isIntegerConstantExpr.
>>
>> Move one case from -Wsign-conversion to -Wconstant-conversion.  The case
>> is:
>> 1) Source and target types are signed
>> 2) Source type is wider than the target type
>> 3) The source constant value is positive
>> 4) The conversion will store the value as negative in the target.
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
>> cfe/trunk/test/Sema/constant-conversion.c
>>
>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=259271&r1=259270&r2=259271&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Jan 29 17:51:16 2016
>> @@ -7578,7 +7578,7 @@ void CheckImplicitConversion(Sema &S, Ex
>>  // If the source is a constant, use a default-on diagnostic.
>>  // TODO: this should happen for bitfield stores, too.
>>  llvm::APSInt Value(32);
>> -if (E->isIntegerConstantExpr(Value, S.Context)) {
>> +if (E->EvaluateAsInt(Value, S.Context, Expr::SE_AllowSideEffects)) {
>>if (S.SourceMgr.isInSystemMacro(CC))
>>  return;
>>
>> @@ -7603,6 +7603,42 @@ void CheckImplicitConversion(Sema &S, Ex
>>  return DiagnoseImpCast(S, E, T, CC,
>> diag::warn_impcast_integer_precision);
>>}
>>
>> +  if (TargetRange.Width == SourceRange.Width && !TargetRange.NonNegative
>> &&
>> +  SourceRange.NonNegative && Source->isSignedIntegerType()) {
>> +// Warn when doing a signed to signed conversion, warn if the
>> positive
>> +// source value is exactly the width of the target type, which will
>> +// cause a negative value to be stored.
>> +
>> +llvm::APSInt Value;
>> +if (E->EvaluateAsInt(Value, S.Context, Expr::SE_AllowSideEffects)) {
>> +  if (!S.SourceMgr.isInSystemMacro(CC)) {
>> +
>> +IntegerLiteral *IntLit =
>> +dyn_cast(E->IgnoreParenImpCasts());
>> +
>> +// If initializing from a constant, and the constant starts with
>> '0',
>> +// then it is a binary, octal, or hexadecimal.  Allow these
>> constants
>> +// to fill all the bits, even if there is a sign change.
>> +if (!IntLit ||
>> +
>> *(S.getSourceManager().getCharacterData(IntLit->getLocStart())) !=
>> +'0') {
>> +
>> +  std::string PrettySourceValue = Value.toString(10);
>> +  std::string PrettyTargetValue =
>> +  PrettyPrintInRange(Value, TargetRange);
>> +
>> +  S.DiagRuntimeBehavior(
>> +  E->getExprLoc(), E,
>> +  S.PDiag(diag::warn_impcast_integer_precision_constant)
>> +  << PrettySourceValue << PrettyTargetValue <<
>> E->getType() << T
>> +  << E->getSourceRange() << clang::SourceRange(CC));
>> +  return;
>> +}
>> +  }
>> +}
>> +// Fall through for non-constants to give a sign conversion warning.
>> +  }
>> +
>>if ((TargetRange.NonNegative && !SourceRange.NonNegative) ||
>>(!TargetRange.NonNegative && SourceRange.NonNegative &&
>> SourceRange.Width == TargetRange.Width)) {
>>
>> Modified: cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp?rev=259271&r1=259270&r2=259271&view=diff
>>
>> ==
>> --- cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp (original)
>> +++ cfe/trunk/

Re: r257710 - [Sema] Suppress diags in overload resolution.

2016-02-01 Thread Hans Wennborg via cfe-commits
Thanks! r259412.

On Mon, Feb 1, 2016 at 1:32 PM, Richard Smith  wrote:
> LGTM for 3.8.
>
> On Wed, Jan 13, 2016 at 4:03 PM, Hans Wennborg  wrote:
>> Thanks! Richard, what say the code owner?
>>
>> On Wed, Jan 13, 2016 at 3:59 PM, George Burgess IV
>>  wrote:
>>> FYI: This patch should to be merged into the clang 3.8.0 branch.
>>>
>>> Thank you!
>>> George
>>>
>>> On Wed, Jan 13, 2016 at 3:36 PM, George Burgess IV via cfe-commits
>>>  wrote:

 Author: gbiv
 Date: Wed Jan 13 17:36:34 2016
 New Revision: 257710

 URL: http://llvm.org/viewvc/llvm-project?rev=257710&view=rev
 Log:
 [Sema] Suppress diags in overload resolution.

 We were emitting diagnostics from our shiny new C-only overload
 resolution mode. This patch attempts to silence all such diagnostics.

 This fixes PR26085.
 Differential Revision: http://reviews.llvm.org/D16159

 Added:
 cfe/trunk/test/SemaObjC/ovl-check.m
 Modified:
 cfe/trunk/include/clang/Sema/Sema.h
 cfe/trunk/lib/Sema/SemaDeclCXX.cpp
 cfe/trunk/lib/Sema/SemaExpr.cpp
 cfe/trunk/lib/Sema/SemaExprObjC.cpp
 cfe/trunk/lib/Sema/SemaOverload.cpp

 Modified: cfe/trunk/include/clang/Sema/Sema.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=257710&r1=257709&r2=257710&view=diff

 ==
 --- cfe/trunk/include/clang/Sema/Sema.h (original)
 +++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 13 17:36:34 2016
 @@ -2229,7 +2229,8 @@ public:
bool CheckPointerConversion(Expr *From, QualType ToType,
CastKind &Kind,
CXXCastPath& BasePath,
 -  bool IgnoreBaseAccess);
 +  bool IgnoreBaseAccess,
 +  bool Diagnose = true);
bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType
 ToType,
   bool InOverloadResolution,
   QualType &ConvertedType);
 @@ -5388,7 +5389,8 @@ public:
  unsigned AmbigiousBaseConvID,
  SourceLocation Loc, SourceRange
 Range,
  DeclarationName Name,
 -CXXCastPath *BasePath);
 +CXXCastPath *BasePath,
 +bool IgnoreAccess = false);

std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);

 @@ -7514,14 +7516,15 @@ public:
  ObjCMethodDecl *&ClassMethod,
  ObjCMethodDecl *&InstanceMethod,
  TypedefNameDecl *&TDNDecl,
 -bool CfToNs);
 -
 +bool CfToNs, bool Diagnose =
 true);
 +
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc,
   QualType DestType, QualType
 SrcType,
 - Expr *&SrcExpr);
 -
 -  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr
 *&SrcExpr);
 -
 + Expr *&SrcExpr, bool Diagnose =
 true);
 +
 +  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr
 *&SrcExpr,
 +  bool Diagnose = true);
 +
bool checkInitMethod(ObjCMethodDecl *method, QualType
 receiverTypeIfCall);

/// \brief Check whether the given new method is a valid override of
 the
 @@ -8613,6 +8616,7 @@ public:
ARCConversionResult CheckObjCARCConversion(SourceRange castRange,
   QualType castType, Expr
 *&op,
   CheckedConversionKind CCK,
 + bool Diagnose = true,
   bool DiagnoseCFAudited =
 false,
   BinaryOperatorKind Opc =
 BO_PtrMemD
   );

 Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=257710&r1=257709&r2=257710&view=diff

 ==
 --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
 +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Jan 13 17:36:34 2016
 @@ -1742,13 +1742,18 @@ void Sema::BuildBasePathArray(const CXXB
  /// othe

Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.h:21-22
@@ -20,71 +20,4 @@
 /// them to use the appropriate boolean expression directly.
 ///
-/// Examples:
-///
-/// ===  
-/// Initial expression   Result
-/// ---  
-/// `if (b == true)` `if (b)`
-/// `if (b == false)``if (!b)`
-/// `if (b && true)` `if (b)`
-/// `if (b && false)``if (false)`
-/// `if (b || true)` `if (true)`
-/// `if (b || false)``if (b)`
-/// `e ? true : false`   `e`
-/// `e ? false : true`   `!e`
-/// `if (true) t(); else f();`   `t();`
-/// `if (false) t(); else f();`  `f();`
-/// `if (e) return true; else return false;` `return e;`
-/// `if (e) return false; else return true;` `return !e;`
-/// `if (e) b = true; else b = false;`   `b = e;`
-/// `if (e) b = false; else b = true;`   `b = !e;`
-/// `if (e) return true; return false;`  `return e;`
-/// `if (e) return false; return true;`  `return !e;`
-/// ===  
-///
-/// The resulting expression `e` is modified as follows:
-///   1. Unnecessary parentheses around the expression are removed.
-///   2. Negated applications of `!` are eliminated.
-///   3. Negated applications of comparison operators are changed to use the
-///  opposite condition.
-///   4. Implicit conversions of pointer to `bool` are replaced with explicit
-///  comparisons to `nullptr`.
-///   5. Implicit casts to `bool` are replaced with explicit casts to `bool`.
-///   6. Object expressions with `explicit operator bool` conversion operators
-///  are replaced with explicit casts to `bool`.
-///
-/// Examples:
-///   1. The ternary assignment `bool b = (i < 0) ? true : false;` has 
redundant
-///  parentheses and becomes `bool b = i < 0;`.
-///
-///   2. The conditional return `if (!b) return false; return true;` has an
-///  implied double negation and becomes `return b;`.
-///
-///   3. The conditional return `if (i < 0) return false; return true;` becomes
-///  `return i >= 0;`.
-///
-///  The conditional return `if (i != 0) return false; return true;` 
becomes
-///  `return i == 0;`.
-///
-///   4. The conditional return `if (p) return true; return false;` has an
-///  implicit conversion of a pointer to `bool` and becomes
-///  `return p != nullptr;`.
-///
-///  The ternary assignment `bool b = (i & 1) ? true : false;` has an
-///  implicit conversion of `i & 1` to `bool` and becomes
-///  `bool b = static_cast(i & 1);`.
-///
-///   5. The conditional return `if (i & 1) return true; else return false;` 
has
-///  an implicit conversion of an integer quantity `i & 1` to `bool` and
-///  becomes `return static_cast(i & 1);`
-///
-///   6. Given `struct X { explicit operator bool(); };`, and an instance `x` 
of
-///  `struct X`, the conditional return `if (x) return true; return false;`
-///  becomes `return static_cast(x);`
-///
-/// When a conditional boolean return or assignment appears at the end of a
-/// chain of `if`, `else if` statements, the conditional statement is left
-/// unchanged unless the option `ChainedConditionalReturn` or
-/// `ChainedConditionalAssignment`, respectively, is specified as non-zero.
-/// The default value for both options is zero.
-///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/readability-simplify-boolean-expr.html

LegalizeAdulthood wrote:
> aaron.ballman wrote:
> > LegalizeAdulthood wrote:
> > > aaron.ballman wrote:
> > > > I think I can agree with that, but I also think it depends a lot on 
> > > > what the purpose to the check is. If it's "improve readability 
> > > > regarding parens" + options that control when to remove or add, that 
> > > > makes sense to me. Otherwise, I think segregating the checks into one 
> > > > that removes (plus options) and one that adds (plus options) makes 
> > > > sense -- even if they perhaps use the same underlying heuristic engine 
> > > > and are simply surfaced as separate checks.
> > > This check isn't at all about the readability of parens, so it doesn't 
> > > make sense for this check to be concerned with it IMO.
> > Agreed; trying to suss out what the appropriate design for this particular 
> > check is. I think I've talked myself into "don't touch parens here."
> Currently in this patch, parens are added when the expression compared to 
> `nullptr` or `0` is a binary operator.
> 
> I think that is the right thing to do here so we get:
> 
> ```
> bool b = (i & 1) 

Re: r258396 - Fix crash for typedefs for arrays of runtime bounds in Lambdas/Captured Statements, used in sizeof() expression only.

2016-02-01 Thread Hans Wennborg via cfe-commits
Thanks! r259414.

On Mon, Feb 1, 2016 at 1:36 PM, Richard Smith  wrote:
> LGTM for 3.8.
>
> On Thu, Jan 21, 2016 at 1:10 PM, Hans Wennborg  wrote:
>> Richard, it was suggested (in
>> https://llvm.org/bugs/show_bug.cgi?id=26059#c7) that this gets merged
>> to 3.8. I believe this falls under your ownership.
>>
>> On Thu, Jan 21, 2016 at 4:54 AM, Alexey Bataev via cfe-commits
>>  wrote:
>>> Author: abataev
>>> Date: Thu Jan 21 06:54:48 2016
>>> New Revision: 258396
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=258396&view=rev
>>> Log:
>>> Fix crash for typedefs for arrays of runtime bounds in Lambdas/Captured 
>>> Statements, used in sizeof() expression only.
>>>
>>> Modified:
>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>> cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r258107 - Fix PR#26175. Thanks to Josh Petrie for the report and the patch. Reviewed as http://reviews.llvm.org/D16262

2016-02-01 Thread Hans Wennborg via cfe-commits
Marshall: ping?

On Tue, Jan 26, 2016 at 11:08 AM, Hans Wennborg  wrote:
> On Tue, Jan 19, 2016 at 9:21 AM, Hans Wennborg  wrote:
>> On Tue, Jan 19, 2016 at 12:01 AM, Dimitry Andric  wrote:
>>> On 19 Jan 2016, at 01:50, Marshall Clow via cfe-commits 
>>>  wrote:

 Author: marshall
 Date: Mon Jan 18 18:50:37 2016
 New Revision: 258107

 URL: http://llvm.org/viewvc/llvm-project?rev=258107&view=rev
 Log:
 Fix PR#26175. Thanks to Josh Petrie for the report and the patch. Reviewed 
 as http://reviews.llvm.org/D16262
>>>
>>> This looks like a good candidate for the 3.8 branch, do you agree?
>>
>> Sounds good to me if Marshall agrees.
>
> Ping?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r258782 - Recommit: R258773 [OpenCL] Pipe builtin functions

2016-02-01 Thread Richard Smith via cfe-commits
On Mon, Jan 25, 2016 at 8:03 PM, Xiuli Pan via cfe-commits
 wrote:
> Author: pxl
> Date: Mon Jan 25 22:03:48 2016
> New Revision: 258782
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258782&view=rev
> Log:
> Recommit: R258773 [OpenCL] Pipe builtin functions
> Fix arc patch fuzz error.
> Summary:
> Support for the pipe built-in functions for OpenCL 2.0.
> The pipe builtin functions may have infinite kinds of element types, one 
> approach
> would be to just generate calls that would always use generic types such as 
> void*.
> This patch is based on bader's opencl support patch on SPIR-V branch.
>
> Reviewers: Anastasia, pekka.jaaskelainen
>
> Subscribers: keryell, bader, cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D15914
>
> Added:
> cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl
> cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
> Modified:
> cfe/trunk/include/clang/Basic/Builtins.def
> cfe/trunk/include/clang/Basic/Builtins.h
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Basic/Builtins.cpp
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=258782&r1=258781&r2=258782&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/Builtins.def (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.def Mon Jan 25 22:03:48 2016
> @@ -1252,6 +1252,32 @@ BUILTIN(__builtin___get_unsafe_stack_ptr
>  BUILTIN(__builtin_nontemporal_store, "v.", "t")
>  BUILTIN(__builtin_nontemporal_load, "v.", "t")
>
> +// OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
> +// We need the generic prototype, since the packet type could be anything.
> +LANGBUILTIN(read_pipe, "i.", "tn", OCLC_LANG)
> +LANGBUILTIN(write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC_LANG)
> +LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(commit_write_pipe, "v.", "tn", OCLC_LANG)
> +LANGBUILTIN(commit_read_pipe, "v.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCLC_LANG)
> +LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCLC_LANG)
> +LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCLC_LANG)
> +LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCLC_LANG)
> +LANGBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC_LANG)
> +LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC_LANG)
> +
>  #undef BUILTIN
>  #undef LIBBUILTIN
>  #undef LANGBUILTIN
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=258782&r1=258781&r2=258782&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Jan 25 22:03:48 2016
> @@ -36,6 +36,7 @@ enum LanguageID {
>CXX_LANG = 0x4,  // builtin for cplusplus only.
>OBJC_LANG = 0x8, // builtin for objective-c and objective-c++
>MS_LANG = 0x10,  // builtin requires MS mode.
> +  OCLC_LANG = 0x20,// builtin for OpenCL C only.

Missing space after comma.

>ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all 
> languages.
>ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG,  // builtin requires GNU 
> mode.
>ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG // builtin requires MS mode.
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=258782&r1=258781&r2=258782&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jan 25 22:03:48 
> 2016
> @@ -7680,6 +7680,16 @@ def err_atomic_init_constant : Error<
>  def err_opencl_implicit_vector_conversion : Error<
>"implicit conversions between vector types (%0 and %1) are not permitted">;
>
> +// OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
> +def err_opencl_builtin_pipe_first_arg : Error<
> +  "first argument to %0 must be a pipe type">;
> +def err_opencl_builtin_pipe_arg_num : Error<
> +"invalid number of arguments to function: %0">;

Too much indentation here.

> +def err_opencl_builtin_pipe_invalid_arg : Error<
> +  "invalid argument type to function %0 (expecting %1)">;
> +def err_opencl_builtin_pipe_invalid_access_modifier : Error<
> + 

Re: r258782 - Recommit: R258773 [OpenCL] Pipe builtin functions

2016-02-01 Thread Richard Smith via cfe-commits
On Thu, Jan 28, 2016 at 11:25 AM, Hans Wennborg  wrote:
> I don't think we have a specific code owner for OpenCL in Clang, which
> means Richard is the owner.
>
> Richard, what do you think?

Is there a reason we want to push this new feature into 3.8 rather
than waiting for the next release?

> On Wed, Jan 27, 2016 at 10:08 PM, xiuli pan  wrote:
>> Hi hans,
>>
>> Request to merge it to release 38
>>
>> It adds Pipe BIFs to be used along with Pipe type committed earlier (in 
>> r257254).
>>
>> Thanks
>> Xiuli
>>
>> -Original Message-
>> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
>> Xiuli Pan via cfe-commits
>> Sent: Tuesday, January 26, 2016 12:04 PM
>> To: cfe-commits@lists.llvm.org
>> Subject: r258782 - Recommit: R258773 [OpenCL] Pipe builtin functions
>>
>> Author: pxl
>> Date: Mon Jan 25 22:03:48 2016
>> New Revision: 258782
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=258782&view=rev
>> Log:
>> Recommit: R258773 [OpenCL] Pipe builtin functions
>> Fix arc patch fuzz error.
>> Summary:
>> Support for the pipe built-in functions for OpenCL 2.0.
>> The pipe builtin functions may have infinite kinds of element types, one 
>> approach
>> would be to just generate calls that would always use generic types such as 
>> void*.
>> This patch is based on bader's opencl support patch on SPIR-V branch.
>>
>> Reviewers: Anastasia, pekka.jaaskelainen
>>
>> Subscribers: keryell, bader, cfe-commits
>>
>> Differential Revision: http://reviews.llvm.org/D15914
>>
>> Added:
>> cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl
>> cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
>> Modified:
>> cfe/trunk/include/clang/Basic/Builtins.def
>> cfe/trunk/include/clang/Basic/Builtins.h
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Basic/Builtins.cpp
>> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/Builtins.def
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=258782&r1=258781&r2=258782&view=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/Builtins.def (original)
>> +++ cfe/trunk/include/clang/Basic/Builtins.def Mon Jan 25 22:03:48 2016
>> @@ -1252,6 +1252,32 @@ BUILTIN(__builtin___get_unsafe_stack_ptr
>>  BUILTIN(__builtin_nontemporal_store, "v.", "t")
>>  BUILTIN(__builtin_nontemporal_load, "v.", "t")
>>
>> +// OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
>> +// We need the generic prototype, since the packet type could be anything.
>> +LANGBUILTIN(read_pipe, "i.", "tn", OCLC_LANG)
>> +LANGBUILTIN(write_pipe, "i.", "tn", OCLC_LANG)
>> +
>> +LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC_LANG)
>> +LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC_LANG)
>> +
>> +LANGBUILTIN(commit_write_pipe, "v.", "tn", OCLC_LANG)
>> +LANGBUILTIN(commit_read_pipe, "v.", "tn", OCLC_LANG)
>> +
>> +LANGBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCLC_LANG)
>> +LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCLC_LANG)
>> +
>> +LANGBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCLC_LANG)
>> +LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCLC_LANG)
>> +
>> +LANGBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCLC_LANG)
>> +LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCLC_LANG)
>> +
>> +LANGBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCLC_LANG)
>> +LANGBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCLC_LANG)
>> +
>> +LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC_LANG)
>> +LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC_LANG)
>> +
>>  #undef BUILTIN
>>  #undef LIBBUILTIN
>>  #undef LANGBUILTIN
>>
>> Modified: cfe/trunk/include/clang/Basic/Builtins.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=258782&r1=258781&r2=258782&view=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
>> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Jan 25 22:03:48 2016
>> @@ -36,6 +36,7 @@ enum LanguageID {
>>CXX_LANG = 0x4,  // builtin for cplusplus only.
>>OBJC_LANG = 0x8, // builtin for objective-c and objective-c++
>>MS_LANG = 0x10,  // builtin requires MS mode.
>> +  OCLC_LANG = 0x20,// builtin for OpenCL C only.
>>ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all 
>> languages.
>>ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG,  // builtin requires GNU 
>> mode.
>>ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG // builtin requires MS 
>> mode.
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=258782&r1=258781&r2=258782&view=diff
>> ==
>> --- cfe/

Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-02-01 Thread Nico Weber via cfe-commits
thakis updated this revision to Diff 46577.
thakis added a comment.

just return true


http://reviews.llvm.org/D16478

Files:
  lib/Sema/SemaTemplateInstantiate.cpp

Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1512,7 +1512,7 @@
 }
 
 static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
-  if (T->getType()->isInstantiationDependentType() || 
+  if (T->getType()->isInstantiationDependentType() ||
   T->getType()->isVariablyModifiedType())
 return true;
 
@@ -1522,22 +1522,12 @@
 
   FunctionProtoTypeLoc FP = TL.castAs();
   for (unsigned I = 0, E = FP.getNumParams(); I != E; ++I) {
-ParmVarDecl *P = FP.getParam(I);
-
 // This must be synthesized from a typedef.
-if (!P) continue;
-
-// The parameter's type as written might be dependent even if the
-// decayed type was not dependent.
-if (TypeSourceInfo *TSInfo = P->getTypeSourceInfo())
-  if (TSInfo->getType()->isInstantiationDependentType())
-return true;
+if (!FP.getParam(I)) continue;
 
-// TODO: currently we always rebuild expressions.  When we
-// properly get lazier about this, we should use the same
-// logic to avoid rebuilding prototypes here.
-if (P->hasDefaultArg())
-  return true;
+// If there are any parameters, a new TypeSourceInfo that refers to the
+// instantiated parameters must be built.
+return true;
   }
 
   return false;
@@ -1556,7 +1546,7 @@
   assert(!ActiveTemplateInstantiations.empty() &&
  "Cannot perform an instantiation without some context on the "
  "instantiation stack");
-  
+
   if (!NeedsInstantiationAsFunctionType(T))
 return T;
 


Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1512,7 +1512,7 @@
 }
 
 static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
-  if (T->getType()->isInstantiationDependentType() || 
+  if (T->getType()->isInstantiationDependentType() ||
   T->getType()->isVariablyModifiedType())
 return true;
 
@@ -1522,22 +1522,12 @@
 
   FunctionProtoTypeLoc FP = TL.castAs();
   for (unsigned I = 0, E = FP.getNumParams(); I != E; ++I) {
-ParmVarDecl *P = FP.getParam(I);
-
 // This must be synthesized from a typedef.
-if (!P) continue;
-
-// The parameter's type as written might be dependent even if the
-// decayed type was not dependent.
-if (TypeSourceInfo *TSInfo = P->getTypeSourceInfo())
-  if (TSInfo->getType()->isInstantiationDependentType())
-return true;
+if (!FP.getParam(I)) continue;
 
-// TODO: currently we always rebuild expressions.  When we
-// properly get lazier about this, we should use the same
-// logic to avoid rebuilding prototypes here.
-if (P->hasDefaultArg())
-  return true;
+// If there are any parameters, a new TypeSourceInfo that refers to the
+// instantiated parameters must be built.
+return true;
   }
 
   return false;
@@ -1556,7 +1546,7 @@
   assert(!ActiveTemplateInstantiations.empty() &&
  "Cannot perform an instantiation without some context on the "
  "instantiation stack");
-  
+
   if (!NeedsInstantiationAsFunctionType(T))
 return T;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-02-01 Thread Nico Weber via cfe-commits
thakis marked an inline comment as done.


Comment at: lib/Sema/SemaTemplateInstantiate.cpp:1519-1521
@@ -1518,5 +1518,5 @@
 
   TypeLoc TL = T->getTypeLoc().IgnoreParens();
   if (!TL.getAs())
 return false;
 

Ack.


http://reviews.llvm.org/D16478



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


Re: r258782 - Recommit: R258773 [OpenCL] Pipe builtin functions

2016-02-01 Thread Hans Wennborg via cfe-commits
On Mon, Feb 1, 2016 at 1:53 PM, Richard Smith  wrote:
> On Thu, Jan 28, 2016 at 11:25 AM, Hans Wennborg  wrote:
>> I don't think we have a specific code owner for OpenCL in Clang, which
>> means Richard is the owner.
>>
>> Richard, what do you think?
>
> Is there a reason we want to push this new feature into 3.8 rather
> than waiting for the next release?

Not from my end. Unless it's a low-cost merge (and it doesn't seem to
be, based on your comments), it seems this should just wait for 3.9.


>> On Wed, Jan 27, 2016 at 10:08 PM, xiuli pan  wrote:
>>> Hi hans,
>>>
>>> Request to merge it to release 38
>>>
>>> It adds Pipe BIFs to be used along with Pipe type committed earlier (in 
>>> r257254).
>>>
>>> Thanks
>>> Xiuli
>>>
>>> -Original Message-
>>> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
>>> Xiuli Pan via cfe-commits
>>> Sent: Tuesday, January 26, 2016 12:04 PM
>>> To: cfe-commits@lists.llvm.org
>>> Subject: r258782 - Recommit: R258773 [OpenCL] Pipe builtin functions
>>>
>>> Author: pxl
>>> Date: Mon Jan 25 22:03:48 2016
>>> New Revision: 258782
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=258782&view=rev
>>> Log:
>>> Recommit: R258773 [OpenCL] Pipe builtin functions
>>> Fix arc patch fuzz error.
>>> Summary:
>>> Support for the pipe built-in functions for OpenCL 2.0.
>>> The pipe builtin functions may have infinite kinds of element types, one 
>>> approach
>>> would be to just generate calls that would always use generic types such as 
>>> void*.
>>> This patch is based on bader's opencl support patch on SPIR-V branch.
>>>
>>> Reviewers: Anastasia, pekka.jaaskelainen
>>>
>>> Subscribers: keryell, bader, cfe-commits
>>>
>>> Differential Revision: http://reviews.llvm.org/D15914
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-02-01 Thread Nico Weber via cfe-commits
thakis updated this revision to Diff 46578.
thakis added a comment.

restore accidentally dropped test


http://reviews.llvm.org/D16478

Files:
  lib/Sema/SemaTemplateInstantiate.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -4276,6 +4276,17 @@
   declRefExpr(to(decl(hasAncestor(decl()));
 }
 
+TEST(HasAncestor, NonParmDependentTemplateParmVarDeclRefExpr) {
+  EXPECT_TRUE(matches("struct PartitionAllocator {\n"
+  "  template\n"
+  "  static int quantizedSize(int count) {\n"
+  "return count;\n"
+  "  }\n"
+  "  void f() { quantizedSize(10); }\n"
+  "};",
+  declRefExpr(to(decl(hasAncestor(decl()));
+}
+
 TEST(HasParent, MatchesAllParents) {
   EXPECT_TRUE(matches(
   "template  struct C { static void f() { 42; } };"
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1512,7 +1512,7 @@
 }
 
 static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
-  if (T->getType()->isInstantiationDependentType() || 
+  if (T->getType()->isInstantiationDependentType() ||
   T->getType()->isVariablyModifiedType())
 return true;
 
@@ -1522,22 +1522,12 @@
 
   FunctionProtoTypeLoc FP = TL.castAs();
   for (unsigned I = 0, E = FP.getNumParams(); I != E; ++I) {
-ParmVarDecl *P = FP.getParam(I);
-
 // This must be synthesized from a typedef.
-if (!P) continue;
-
-// The parameter's type as written might be dependent even if the
-// decayed type was not dependent.
-if (TypeSourceInfo *TSInfo = P->getTypeSourceInfo())
-  if (TSInfo->getType()->isInstantiationDependentType())
-return true;
+if (!FP.getParam(I)) continue;
 
-// TODO: currently we always rebuild expressions.  When we
-// properly get lazier about this, we should use the same
-// logic to avoid rebuilding prototypes here.
-if (P->hasDefaultArg())
-  return true;
+// If there are any parameters, a new TypeSourceInfo that refers to the
+// instantiated parameters must be built.
+return true;
   }
 
   return false;
@@ -1556,7 +1546,7 @@
   assert(!ActiveTemplateInstantiations.empty() &&
  "Cannot perform an instantiation without some context on the "
  "instantiation stack");
-  
+
   if (!NeedsInstantiationAsFunctionType(T))
 return T;
 


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -4276,6 +4276,17 @@
   declRefExpr(to(decl(hasAncestor(decl()));
 }
 
+TEST(HasAncestor, NonParmDependentTemplateParmVarDeclRefExpr) {
+  EXPECT_TRUE(matches("struct PartitionAllocator {\n"
+  "  template\n"
+  "  static int quantizedSize(int count) {\n"
+  "return count;\n"
+  "  }\n"
+  "  void f() { quantizedSize(10); }\n"
+  "};",
+  declRefExpr(to(decl(hasAncestor(decl()));
+}
+
 TEST(HasParent, MatchesAllParents) {
   EXPECT_TRUE(matches(
   "template  struct C { static void f() { 42; } };"
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1512,7 +1512,7 @@
 }
 
 static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
-  if (T->getType()->isInstantiationDependentType() || 
+  if (T->getType()->isInstantiationDependentType() ||
   T->getType()->isVariablyModifiedType())
 return true;
 
@@ -1522,22 +1522,12 @@
 
   FunctionProtoTypeLoc FP = TL.castAs();
   for (unsigned I = 0, E = FP.getNumParams(); I != E; ++I) {
-ParmVarDecl *P = FP.getParam(I);
-
 // This must be synthesized from a typedef.
-if (!P) continue;
-
-// The parameter's type as written might be dependent even if the
-// decayed type was not dependent.
-if (TypeSourceInfo *TSInfo = P->getTypeSourceInfo())
-  if (TSInfo->getType()->isInstantiationDependentType())
-return true;
+if (!FP.getParam(I)) continue;
 
-// TODO: currently we always rebuild expressions.  When we
-// properly get lazier about this, we should use the same
-// logic to avoid rebuilding prototypes here.
-if (P->hasDefaultArg())
-  return true;
+// If there are any parameters, a new TypeSourceInfo that refers to the
+// instantiated parameters must be bu

r259418 - Undoing commit r259366 to debug buildbot failure.

2016-02-01 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Mon Feb  1 16:02:05 2016
New Revision: 259418

URL: http://llvm.org/viewvc/llvm-project?rev=259418&view=rev
Log:
Undoing commit r259366 to debug buildbot failure.
> http://reviews.llvm.org/D16758


Modified:
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_private_messages.cpp
cfe/trunk/test/OpenMP/nesting_of_regions.cpp
cfe/trunk/test/OpenMP/target_data_device_messages.cpp
cfe/trunk/test/OpenMP/target_device_messages.cpp
cfe/trunk/test/OpenMP/target_if_messages.cpp
cfe/trunk/test/OpenMP/target_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_default_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_device_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_map_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_num_threads_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_private_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_proc_bind_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_shared_messages.cpp
cfe/trunk/test/OpenMP/target_private_messages.cpp
cfe/trunk/test/OpenMP/teams_reduction_messages.cpp

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.h?rev=259418&r1=259417&r2=259418&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.h (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.h Mon Feb  1 16:02:05 2016
@@ -156,20 +156,11 @@ bool isOpenMPTaskLoopDirective(OpenMPDir
 /// parallel', otherwise - false.
 bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind);
 
-/// \brief Checks if the specified directive is a target code offload 
directive.
+/// \brief Checks if the specified directive is a target-kind directive.
 /// \param DKind Specified directive.
-/// \return true - the directive is a target code offload directive like
-/// 'omp target', 'omp target parallel', 'omp target xxx'
+/// \return true - the directive is a target-like directive like 'omp target',
 /// otherwise - false.
-bool isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind);
-
-/// \brief Checks if the specified directive is a target data offload 
directive.
-/// \param DKind Specified directive.
-/// \return true - the directive is a target data offload directive like
-/// 'omp target data', 'omp target update', 'omp target enter data',
-/// 'omp target exit data'
-/// otherwise - false.
-bool isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind);
+bool isOpenMPTargetDirective(OpenMPDirectiveKind DKind);
 
 /// \brief Checks if the specified directive is a teams-kind directive.
 /// \param DKind Specified directive.

Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=259418&r1=259417&r2=259418&view=diff
==
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Mon Feb  1 16:02:05 2016
@@ -576,15 +576,8 @@ bool clang::isOpenMPParallelDirective(Op
  // TODO add next directives.
 }
 
-bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) {
-  // TODO add next directives.
-  return DKind == OMPD_target || DKind == OMPD_target_parallel;
-}
-
-bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
-  // TODO add target update directive check.
-  return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
- DKind == OMPD_target_exit_data;
+bool clang::isOpenMPTargetDirective(OpenMPDirectiveKind DKind) {
+  return DKind == OMPD_target; // TODO add next directives.
 }
 
 bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=259418&r1=259417&r2=259418&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Feb  1 16:02:05 2016
@@ -809,7 +809,7 @@ bool Sema::IsOpenMPCapturedByRef(ValueDe
   auto DKind = DSAStack->getDirectiveForScope(RSI->TheScope);
   auto Ty = D->getType();
 
-  if (isOpenMPTargetExecutionDirective(DKind)) {
+  if (isOpenMPTargetDirective(DKind)) {
 // This table summarizes how a given variable should be passed to the 
device
 // given its type and the clauses where it appears. This table is based on
 // the description in OpenMP 4.5 [2.10.4, target Construct] and
@@ -90

Re: r257831 - Refactor template type diffing

2016-02-01 Thread Richard Smith via cfe-commits
On Thu, Jan 14, 2016 at 2:57 PM, Richard Trieu via cfe-commits
 wrote:
> Author: rtrieu
> Date: Thu Jan 14 16:56:39 2016
> New Revision: 257831
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257831&view=rev
> Log:
> Refactor template type diffing
>
> 1) Instead of using pairs of From/To* fields, combine fields into a struct
> TemplateArgInfo and have two in each DiffNode.
> 2) Use default initialization in DiffNode so that the constructor shows the
> only field that is initialized differently on construction.
> 3) Use Set and Get functions per each DiffKind to make sure all fields for the
> diff is set.  In one case, the Expr fields were not set.
> 4) Don't print boolean literals for boolean template arguments.  This prevents
> printing 'false aka 0'
>
> Only #3 has a functional change, which is reflected in the test change.
>
> Modified:
> cfe/trunk/lib/AST/ASTDiagnostic.cpp
> cfe/trunk/test/Misc/diag-template-diffing.cpp
>
> Modified: cfe/trunk/lib/AST/ASTDiagnostic.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDiagnostic.cpp?rev=257831&r1=257830&r2=257831&view=diff
> ==
> --- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
> +++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Thu Jan 14 16:56:39 2016
> @@ -491,82 +491,67 @@ class TemplateDiff {
>/// DiffTree - A tree representation the differences between two types.
>class DiffTree {
>public:
> -/// DiffKind - The difference in a DiffNode and which fields are used.
> +/// DiffKind - The difference in a DiffNode.  Fields of
> +/// TemplateArgumentInfo needed by each difference can be found in the
> +/// Set* and Get* functions.
>  enum DiffKind {
>/// Incomplete or invalid node.
>Invalid,
> -  /// Another level of templates, uses TemplateDecl and Qualifiers
> +  /// Another level of templates, requires that

... requires that what?

>Template,
> -  /// Type difference, uses QualType
> +  /// Type difference, all type differences except those falling under
> +  /// the Template difference.
>Type,
> -  /// Expression difference, uses Expr
> +  /// Expression difference, this is only when both arguments are
> +  /// expressions.  If one argument is an expression and the other is
> +  /// Integer or Declaration, then use that diff type instead.
>Expression,
> -  /// Template argument difference, uses TemplateDecl
> +  /// Template argument difference
>TemplateTemplate,
> -  /// Integer difference, uses APSInt and Expr
> +  /// Integer difference
>Integer,
> -  /// Declaration difference, uses ValueDecl
> +  /// Declaration difference, nullptr arguments are included here
>Declaration
>  };
> +
>private:
> +/// TemplateArgumentInfo - All the information needed to pretty print
> +/// a template argument.  See the Set* and Get* functions to see which
> +/// fields are used for each DiffKind.
> +struct TemplateArgumentInfo {
> +  QualType ArgType;
> +  Qualifiers Qual;
> +  llvm::APSInt Val;
> +  bool IsValidInt = false;
> +  Expr *ArgExpr = nullptr;
> +  TemplateDecl *TD = nullptr;
> +  ValueDecl *VD = nullptr;
> +  bool NeedAddressOf = false;
> +  bool IsNullPtr = false;
> +  bool IsDefault = false;
> +};
> +
>  /// DiffNode - The root node stores the original type.  Each child node
>  /// stores template arguments of their parents.  For templated types, the
>  /// template decl is also stored.
>  struct DiffNode {
> -  DiffKind Kind;
> +  DiffKind Kind = Invalid;
>
>/// NextNode - The index of the next sibling node or 0.
> -  unsigned NextNode;
> +  unsigned NextNode = 0;
>
>/// ChildNode - The index of the first child node or 0.
> -  unsigned ChildNode;
> +  unsigned ChildNode = 0;
>
>/// ParentNode - The index of the parent node.
> -  unsigned ParentNode;
> -
> -  /// FromType, ToType - The type arguments.
> -  QualType FromType, ToType;
> -
> -  /// FromExpr, ToExpr - The expression arguments.
> -  Expr *FromExpr, *ToExpr;
> -
> -  /// FromNullPtr, ToNullPtr - If the template argument is a nullptr
> -  bool FromNullPtr, ToNullPtr;
> -
> -  /// FromTD, ToTD - The template decl for template template
> -  /// arguments or the type arguments that are templates.
> -  TemplateDecl *FromTD, *ToTD;
> -
> -  /// FromQual, ToQual - Qualifiers for template types.
> -  Qualifiers FromQual, ToQual;
> -
> -  /// FromInt, ToInt - APSInt's for integral arguments.
> -  llvm::APSInt FromInt, ToInt;
> -
> -  /// IsValidFromInt, IsValidToInt - Whether the APSInt's are valid.
> -  bool IsValidFromInt, IsValidToInt;
> +  unsigned ParentNode = 0;
>
> -  /// FromValueDecl, ToValueDecl - Whether the argument is a decl.
> -  Valu

Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

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

LGTM



Comment at: lib/Sema/SemaTemplateInstantiate.cpp:1525-1530
@@ -1524,18 +1524,8 @@
   for (unsigned I = 0, E = FP.getNumParams(); I != E; ++I) {
-ParmVarDecl *P = FP.getParam(I);
-
 // This must be synthesized from a typedef.
-if (!P) continue;
-
-// The parameter's type as written might be dependent even if the
-// decayed type was not dependent.
-if (TypeSourceInfo *TSInfo = P->getTypeSourceInfo())
-  if (TSInfo->getType()->isInstantiationDependentType())
-return true;
+if (!FP.getParam(I)) continue;
 
-// TODO: currently we always rebuild expressions.  When we
-// properly get lazier about this, we should use the same
-// logic to avoid rebuilding prototypes here.
-if (P->hasDefaultArg())
-  return true;
+// If there are any parameters, a new TypeSourceInfo that refers to the
+// instantiated parameters must be built.
+return true;
   }

Maybe replace the whole loop with

  for (ParmVarDecl *D : FP.getParmArray())
if (D)
  return true;

(or an STL algorithm for same)?


http://reviews.llvm.org/D16478



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


[clang-tools-extra] r259424 - Fix build problem by lower SmallSet to a reasonable value

2016-02-01 Thread Matthias Braun via cfe-commits
Author: matze
Date: Mon Feb  1 16:18:58 2016
New Revision: 259424

URL: http://llvm.org/viewvc/llvm-project?rev=259424&view=rev
Log:
Fix build problem by lower SmallSet to a reasonable value

Modified:
clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp

Modified: clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp?rev=259424&r1=259423&r2=259424&view=diff
==
--- clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp (original)
+++ clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp Mon Feb  1 
16:18:58 2016
@@ -1276,7 +1276,7 @@ private:
   std::vector HeaderStack;
   std::vector InclusionPaths;
   InclusionPathHandle CurrentInclusionPathHandle;
-  llvm::SmallSet HeadersInThisCompile;
+  llvm::SmallSet HeadersInThisCompile;
   std::vector IncludeDirectives;
   MacroExpansionMap MacroExpansions;
   ConditionalExpansionMap ConditionalExpansions;


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


r259428 - Always build a new TypeSourceInfo for function templates with parameters

2016-02-01 Thread Nico Weber via cfe-commits
Author: nico
Date: Mon Feb  1 16:31:51 2016
New Revision: 259428

URL: http://llvm.org/viewvc/llvm-project?rev=259428&view=rev
Log:
Always build a new TypeSourceInfo for function templates with parameters

RecursiveASTVisitor::TraverseFunctionHelper() traverses a function's
ParmVarDecls by going to the function's getTypeSourceInfo if it exists, and
`DEF_TRAVERSE_TYPELOC(FunctionProtoType` then goes to the function's
ParmVarDecls.

For a function template that doesn't have parameters that explicitly depend on
the template parameter, we used to be clever and not build a new
TypeSourceInfo. That meant that when an instantiation of such a template is
visited, its TypeSourceInfo would point to the ParmVarDecls of the template,
not of the instantiation, which then confused clients of RecursiveASTVisitor.

So don't be clever for function templates that have parameters, even if none of
the parameters depend on the type.

Fixes PR26257.
http://reviews.llvm.org/D16478

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=259428&r1=259427&r2=259428&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Mon Feb  1 16:31:51 2016
@@ -1512,7 +1512,7 @@ QualType Sema::SubstType(QualType T,
 }
 
 static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
-  if (T->getType()->isInstantiationDependentType() || 
+  if (T->getType()->isInstantiationDependentType() ||
   T->getType()->isVariablyModifiedType())
 return true;
 
@@ -1521,23 +1521,13 @@ static bool NeedsInstantiationAsFunction
 return false;
 
   FunctionProtoTypeLoc FP = TL.castAs();
-  for (unsigned I = 0, E = FP.getNumParams(); I != E; ++I) {
-ParmVarDecl *P = FP.getParam(I);
-
+  for (ParmVarDecl *P : FP.getParams()) {
 // This must be synthesized from a typedef.
 if (!P) continue;
 
-// The parameter's type as written might be dependent even if the
-// decayed type was not dependent.
-if (TypeSourceInfo *TSInfo = P->getTypeSourceInfo())
-  if (TSInfo->getType()->isInstantiationDependentType())
-return true;
-
-// TODO: currently we always rebuild expressions.  When we
-// properly get lazier about this, we should use the same
-// logic to avoid rebuilding prototypes here.
-if (P->hasDefaultArg())
-  return true;
+// If there are any parameters, a new TypeSourceInfo that refers to the
+// instantiated parameters must be built.
+return true;
   }
 
   return false;
@@ -1556,7 +1546,7 @@ TypeSourceInfo *Sema::SubstFunctionDeclT
   assert(!ActiveTemplateInstantiations.empty() &&
  "Cannot perform an instantiation without some context on the "
  "instantiation stack");
-  
+
   if (!NeedsInstantiationAsFunctionType(T))
 return T;
 

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=259428&r1=259427&r2=259428&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Feb  1 16:31:51 2016
@@ -4276,6 +4276,17 @@ TEST(HasAncestor, AnonymousUnionMemberEx
   declRefExpr(to(decl(hasAncestor(decl()));
 }
 
+TEST(HasAncestor, NonParmDependentTemplateParmVarDeclRefExpr) {
+  EXPECT_TRUE(matches("struct PartitionAllocator {\n"
+  "  template\n"
+  "  static int quantizedSize(int count) {\n"
+  "return count;\n"
+  "  }\n"
+  "  void f() { quantizedSize(10); }\n"
+  "};",
+  declRefExpr(to(decl(hasAncestor(decl()));
+}
+
 TEST(HasParent, MatchesAllParents) {
   EXPECT_TRUE(matches(
   "template  struct C { static void f() { 42; } };"


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


Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-02-01 Thread Nico Weber via cfe-commits
thakis closed this revision.
thakis added a comment.

r259428, thanks! Went with the for-each loop but left the structure as-is -- I 
find the comments helpful and it's not clear where they should go else.


http://reviews.llvm.org/D16478



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


LLVM buildmaster will be restarted tonight

2016-02-01 Thread Galina Kistanova via cfe-commits
Hello everyone,

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

Thanks

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


Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

2016-02-01 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.h:21-22
@@ -20,71 +20,4 @@
 /// them to use the appropriate boolean expression directly.
 ///
-/// Examples:
-///
-/// ===  
-/// Initial expression   Result
-/// ---  
-/// `if (b == true)` `if (b)`
-/// `if (b == false)``if (!b)`
-/// `if (b && true)` `if (b)`
-/// `if (b && false)``if (false)`
-/// `if (b || true)` `if (true)`
-/// `if (b || false)``if (b)`
-/// `e ? true : false`   `e`
-/// `e ? false : true`   `!e`
-/// `if (true) t(); else f();`   `t();`
-/// `if (false) t(); else f();`  `f();`
-/// `if (e) return true; else return false;` `return e;`
-/// `if (e) return false; else return true;` `return !e;`
-/// `if (e) b = true; else b = false;`   `b = e;`
-/// `if (e) b = false; else b = true;`   `b = !e;`
-/// `if (e) return true; return false;`  `return e;`
-/// `if (e) return false; return true;`  `return !e;`
-/// ===  
-///
-/// The resulting expression `e` is modified as follows:
-///   1. Unnecessary parentheses around the expression are removed.
-///   2. Negated applications of `!` are eliminated.
-///   3. Negated applications of comparison operators are changed to use the
-///  opposite condition.
-///   4. Implicit conversions of pointer to `bool` are replaced with explicit
-///  comparisons to `nullptr`.
-///   5. Implicit casts to `bool` are replaced with explicit casts to `bool`.
-///   6. Object expressions with `explicit operator bool` conversion operators
-///  are replaced with explicit casts to `bool`.
-///
-/// Examples:
-///   1. The ternary assignment `bool b = (i < 0) ? true : false;` has 
redundant
-///  parentheses and becomes `bool b = i < 0;`.
-///
-///   2. The conditional return `if (!b) return false; return true;` has an
-///  implied double negation and becomes `return b;`.
-///
-///   3. The conditional return `if (i < 0) return false; return true;` becomes
-///  `return i >= 0;`.
-///
-///  The conditional return `if (i != 0) return false; return true;` 
becomes
-///  `return i == 0;`.
-///
-///   4. The conditional return `if (p) return true; return false;` has an
-///  implicit conversion of a pointer to `bool` and becomes
-///  `return p != nullptr;`.
-///
-///  The ternary assignment `bool b = (i & 1) ? true : false;` has an
-///  implicit conversion of `i & 1` to `bool` and becomes
-///  `bool b = static_cast(i & 1);`.
-///
-///   5. The conditional return `if (i & 1) return true; else return false;` 
has
-///  an implicit conversion of an integer quantity `i & 1` to `bool` and
-///  becomes `return static_cast(i & 1);`
-///
-///   6. Given `struct X { explicit operator bool(); };`, and an instance `x` 
of
-///  `struct X`, the conditional return `if (x) return true; return false;`
-///  becomes `return static_cast(x);`
-///
-/// When a conditional boolean return or assignment appears at the end of a
-/// chain of `if`, `else if` statements, the conditional statement is left
-/// unchanged unless the option `ChainedConditionalReturn` or
-/// `ChainedConditionalAssignment`, respectively, is specified as non-zero.
-/// The default value for both options is zero.
-///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/readability-simplify-boolean-expr.html

aaron.ballman wrote:
> LegalizeAdulthood wrote:
> > aaron.ballman wrote:
> > > LegalizeAdulthood wrote:
> > > > aaron.ballman wrote:
> > > > > I think I can agree with that, but I also think it depends a lot on 
> > > > > what the purpose to the check is. If it's "improve readability 
> > > > > regarding parens" + options that control when to remove or add, that 
> > > > > makes sense to me. Otherwise, I think segregating the checks into one 
> > > > > that removes (plus options) and one that adds (plus options) makes 
> > > > > sense -- even if they perhaps use the same underlying heuristic 
> > > > > engine and are simply surfaced as separate checks.
> > > > This check isn't at all about the readability of parens, so it doesn't 
> > > > make sense for this check to be concerned with it IMO.
> > > Agreed; trying to suss out what the appropriate design for this 
> > > particular check is. I think I've talked myself into "don't touch parens 
> > > here."
> > Currently in this patch, parens are added when the expression compared to 
> > `nullptr` or `0` is a binary operator.
> > 
> > I think that

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-02-01 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 46588.
nwilson added a comment.

- Fix a couple of comments to reflect the Patch.
- Clang-format the changes in this Patch.


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -41,3 +41,20 @@
 void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template  concept bool VCEI{ true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template  concept bool VCPS{ true };
+template  concept bool VCPS{ true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template  concept bool VCES{ true };
+template <> concept bool VCES{ true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template  concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template  concept bool FCES() { return true; }
+template <> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7673,6 +7673,15 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6002,6 +6002,16 @@
 NewVD->setInvalidDecl(true);
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a [...] variable template, declared
+  // in namespace scope. [...] A concept definition refers to [...] a
+  // variable concept and its initializer.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+<< (IsPartialSpecialization ? 2 : 1);
+  }
+
   // C++ Concepts TS [dcl.spec.concept]p6: A variable concept has the
   // following restrictions:
   // - The declared type shall have the type bool.
@@ -7667,6 +7677,10 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  if (FunctionTemplateDecl *FTD = NewFD->getDescribedFunctionTemplate())
+FTD->setConcept(true);
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7733,6 +7747,15 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template [...], declared
+  // in namespace scope. [...] A concept definition refers to either a
+  // function concept and its definition [...].
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7994,9 +8017,9 @@
  TemplateId->NumArgs);
   translateTemplateArguments(TemplateArgsPtr,
  TemplateArgs);
-
+
   HasExplicitTemplateArgs = true;
-
+
  

[PATCH] D16788: Ps4 ABI Round 2. Actual PS4 code.

2016-02-01 Thread Sunil Srivastava via cfe-commits
Sunil_Srivastava created this revision.
Sunil_Srivastava added reviewers: rjmccall, DmitryPolukhin, rsmith, probinson.
Sunil_Srivastava added a subscriber: cfe-commits.

This is the round 2 of the PS4 ABI. In this round:

1) A new value PS4 has been added to TargetCXXABI::Kind. It is being used for 
x86_64-scei-ps4 triple only.
2) RecordLayoutBuilder.cpp has been logically reverted back to pre r257462 
behavior for PS4 abi.
3) The test Sema/bitfield-layout.c has been enhanced by adding the PS4 triple, 
and few test entries that differ between PS4 and other triples, have been put 
under '#ifdef PS4'. Logically, the test has not changed for triples other than 
x86_64-scei-ps4. For x86_64-scei-ps4 triple, the test matches pre r257462 
behavior.

The test passes on all listed triples on x86 Linux and windows hosts.

http://reviews.llvm.org/D16788

Files:
  include/clang/Basic/TargetCXXABI.h
  lib/AST/ASTContext.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  test/Sema/bitfield-layout.c

Index: test/Sema/bitfield-layout.c
===
--- test/Sema/bitfield-layout.c
+++ test/Sema/bitfield-layout.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=arm-linux-gnueabihf
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=aarch64-linux-gnu
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-pc-linux-gnu
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-scei-ps4
 // expected-no-diagnostics
 #include 
 
@@ -96,9 +97,15 @@
   char c;
 };
 
+#if defined(__PS4__)
+CHECK_SIZE(struct, g0, 16);
+CHECK_ALIGN(struct, g0, 16);
+CHECK_OFFSET(struct, g0, c, 2);
+#else
 CHECK_SIZE(struct, g0, 32);
 CHECK_ALIGN(struct, g0, 16);
 CHECK_OFFSET(struct, g0, c, 17);
+#endif
 
 // Bit-field with explicit align smaller than normal.
 struct g1 {
@@ -109,7 +116,11 @@
 
 CHECK_SIZE(struct, g1, 4);
 CHECK_ALIGN(struct, g1, 4);
+#if defined(__PS4__)
+CHECK_OFFSET(struct, g1, c, 2);
+#else
 CHECK_OFFSET(struct, g1, c, 3);
+#endif
 
 // Same as above but without explicit align.
 struct g2 {
@@ -130,9 +141,14 @@
   char c;
 };
 
-CHECK_SIZE(struct, g3, 32);
 CHECK_ALIGN(struct, g3, 16);
+#if defined(__PS4__)
+CHECK_SIZE(struct, g3, 16);
+CHECK_OFFSET(struct, g3, c, 2);
+#else
+CHECK_SIZE(struct, g3, 32);
 CHECK_OFFSET(struct, g3, c, 17);
+#endif
 
 struct __attribute__((packed)) g4 {
   char a;
@@ -142,7 +158,11 @@
 
 CHECK_SIZE(struct, g4, 4);
 CHECK_ALIGN(struct, g4, 2);
+#if defined(__PS4__)
+CHECK_OFFSET(struct, g4, c, 2);
+#else
 CHECK_OFFSET(struct, g4, c, 3);
+#endif
 
 struct g5 {
   char : 1;
@@ -162,28 +182,44 @@
   char : 1;
   __attribute__((aligned(1))) int n : 25;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g7, 4);
+#else
 CHECK_SIZE(struct, g7, 8);
+#endif
 CHECK_ALIGN(struct, g7, 4);
 
 struct __attribute__((packed)) g8 {
   char : 1;
   __attribute__((aligned(1))) int n : 25;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g8, 4);
+#else
 CHECK_SIZE(struct, g8, 5);
+#endif
 CHECK_ALIGN(struct, g8, 1);
 
 struct g9 {
   __attribute__((aligned(1))) char a : 2, b : 2, c : 2, d : 2, e : 2;
   int i;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g9, 8);
+#else
 CHECK_SIZE(struct, g9, 12);
+#endif
 CHECK_ALIGN(struct, g9, 4);
 
 struct __attribute__((packed)) g10 {
   __attribute__((aligned(1))) char a : 2, b : 2, c : 2, d : 2, e : 2;
   int i;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g10, 6);
+#else
 CHECK_SIZE(struct, g10, 9);
+#endif
 CHECK_ALIGN(struct, g10, 1);
 
 struct g11 {
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -480,6 +480,7 @@
 return new WebAssemblyCXXABI(CGM);
 
   case TargetCXXABI::GenericItanium:
+  case TargetCXXABI::PS4:
 if (CGM.getContext().getTargetInfo().getTriple().getArch()
 == llvm::Triple::le32) {
   // For PNaCl, use ARM-style method pointers so that PNaCl code
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -69,6 +69,7 @@
   case TargetCXXABI::WatchOS:
   case TargetCXXABI::GenericMIPS:
   case TargetCXXABI::GenericItanium:
+  case TargetCXXABI::PS4:
   case TargetCXXABI::WebAssembly:
 return CreateItaniumCXXABI(CGM);
   case TargetCXXABI::Microsoft:
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -602,6 +602,9 @@
   PS4OSTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
 this->WCharType = this->UnsignedShort;
 
+// PS4 uses a variant of the C++11 ABI.
+this->TheCXXABI.set(TargetCXXABI::PS4);
+
 // On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits).
 this->MaxTLSAlign = 256;
 this->UserLabe

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-02-01 Thread Nathan Wilson via cfe-commits
nwilson marked 5 inline comments as done.
nwilson added a comment.

Marking some comments Done which were fixed in previous updates.


http://reviews.llvm.org/D13357



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


Re: [PATCH] D16467: [libcxx] re.results.form: Format out-of-range subexpression references as null

2016-02-01 Thread Duncan P. N. Exon Smith via cfe-commits
Ping.

Marshall, does this look okay?

> On 2016-Jan-25, at 10:32, Duncan P. N. Exon Smith via cfe-commits 
>  wrote:
> 
> dexonsmith updated this revision to Diff 45879.
> dexonsmith added a comment.
> 
> Addressed Marshall's review comments: deferring to 
> match_results::operator[]() rather than duplicating the logic.
> 
> 
> http://reviews.llvm.org/D16467
> 
> Files:
>  include/regex
>  test/std/re/re.results/re.results.form/form1.pass.cpp
> 
> Index: test/std/re/re.results/re.results.form/form1.pass.cpp
> ===
> --- test/std/re/re.results/re.results.form/form1.pass.cpp
> +++ test/std/re/re.results/re.results.form/form1.pass.cpp
> @@ -38,6 +38,31 @@
> {
> std::match_results m;
> const char s[] = "abcdefghijk";
> +assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
> +  
> std::regex_constants::nosubs)));
> +
> +char out[100] = {0};
> +const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, 
> m[2]: $2";
> +char* r = m.format(output_iterator(out),
> +fmt, fmt + std::char_traits::length(fmt)).base();
> +assert(r == out + 54);
> +assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, 
> m[1]: , m[2]: ");
> +}
> +{
> +std::match_results m;
> +const char s[] = "abcdefghijk";
> +assert(std::regex_search(s, m, std::regex("cdefghi")));
> +
> +char out[100] = {0};
> +const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, 
> m[2]: $2";
> +char* r = m.format(output_iterator(out),
> +fmt, fmt + std::char_traits::length(fmt)).base();
> +assert(r == out + 54);
> +assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, 
> m[1]: , m[2]: ");
> +}
> +{
> +std::match_results m;
> +const char s[] = "abcdefghijk";
> assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
> 
> char out[100] = {0};
> @@ -61,6 +86,33 @@
> assert(r == out + 34);
> assert(std::string(out) == "match: cdefghi, m[1]: efg, m[2]: e");
> }
> +{
> +std::match_results m;
> +const char s[] = "abcdefghijk";
> +assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
> +  
> std::regex_constants::nosubs)));
> +
> +char out[100] = {0};
> +const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2";
> +char* r = m.format(output_iterator(out),
> +fmt, fmt + std::char_traits::length(fmt),
> +std::regex_constants::format_sed).base();
> +assert(r == out + 30);
> +assert(std::string(out) == "match: cdefghi, m[1]: , m[2]: ");
> +}
> +{
> +std::match_results m;
> +const char s[] = "abcdefghijk";
> +assert(std::regex_search(s, m, std::regex("cdefghi")));
> +
> +char out[100] = {0};
> +const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2";
> +char* r = m.format(output_iterator(out),
> +fmt, fmt + std::char_traits::length(fmt),
> +std::regex_constants::format_sed).base();
> +assert(r == out + 30);
> +assert(std::string(out) == "match: cdefghi, m[1]: , m[2]: ");
> +}
> 
> {
> std::match_results m;
> Index: include/regex
> ===
> --- include/regex
> +++ include/regex
> @@ -5387,8 +5387,8 @@
> if ('0' <= *__fmt_first && *__fmt_first <= '9')
> {
> size_t __i = *__fmt_first - '0';
> -__out = _VSTD::copy(__matches_[__i].first,
> -   __matches_[__i].second, __out);
> +__out = _VSTD::copy((*this)[__i].first,
> +(*this)[__i].second, __out);
> }
> else
> {
> @@ -5439,8 +5439,8 @@
> ++__fmt_first;
> __i = 10 * __i + *__fmt_first - '0';
> }
> -__out = _VSTD::copy(__matches_[__i].first,
> -   __matches_[__i].second, __out);
> +__out = _VSTD::copy((*this)[__i].first,
> +(*this)[__i].second, __out);
> }
> else
> {
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


Re: [PATCH] D16467: [libcxx] re.results.form: Format out-of-range subexpression references as null

2016-02-01 Thread Duncan P. N. Exon Smith via cfe-commits
dexonsmith added a subscriber: dexonsmith.
dexonsmith added a comment.

Ping.

Marshall, does this look okay?


http://reviews.llvm.org/D16467



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


r259445 - Template Type Diffing change

2016-02-01 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon Feb  1 18:36:59 2016
New Revision: 259445

URL: http://llvm.org/viewvc/llvm-project?rev=259445&view=rev
Log:
Template Type Diffing change

When all the arguments of a template are elided, print "A<...>" instead of
"A<[2 * ...]>".  Also remove comment fragment that means nothing.

Modified:
cfe/trunk/lib/AST/ASTDiagnostic.cpp
cfe/trunk/test/Misc/diag-template-diffing-color.cpp
cfe/trunk/test/Misc/diag-template-diffing-cxx98.cpp
cfe/trunk/test/Misc/diag-template-diffing.cpp

Modified: cfe/trunk/lib/AST/ASTDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDiagnostic.cpp?rev=259445&r1=259444&r2=259445&view=diff
==
--- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Mon Feb  1 18:36:59 2016
@@ -497,7 +497,7 @@ class TemplateDiff {
 enum DiffKind {
   /// Incomplete or invalid node.
   Invalid,
-  /// Another level of templates, requires that
+  /// Another level of templates
   Template,
   /// Type difference, all type differences except those falling under
   /// the Template difference.
@@ -1523,12 +1523,14 @@ class TemplateDiff {
 OS << FromTD->getNameAsString() << '<';
 Tree.MoveToChild();
 unsigned NumElideArgs = 0;
+bool AllArgsElided = true;
 do {
   if (ElideType) {
 if (Tree.NodeIsSame()) {
   ++NumElideArgs;
   continue;
 }
+AllArgsElided = false;
 if (NumElideArgs > 0) {
   PrintElideArgs(NumElideArgs, Indent);
   NumElideArgs = 0;
@@ -1539,8 +1541,12 @@ class TemplateDiff {
   if (Tree.HasNextSibling())
 OS << ", ";
 } while (Tree.AdvanceSibling());
-if (NumElideArgs > 0)
-  PrintElideArgs(NumElideArgs, Indent);
+if (NumElideArgs > 0) {
+  if (AllArgsElided)
+OS << "...";
+  else
+PrintElideArgs(NumElideArgs, Indent);
+}
 
 Tree.Parent();
 OS << ">";

Modified: cfe/trunk/test/Misc/diag-template-diffing-color.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-template-diffing-color.cpp?rev=259445&r1=259444&r2=259445&view=diff
==
--- cfe/trunk/test/Misc/diag-template-diffing-color.cpp (original)
+++ cfe/trunk/test/Misc/diag-template-diffing-color.cpp Mon Feb  1 18:36:59 2016
@@ -34,42 +34,38 @@ void set16(vector >) {}
 void test16() {
   set16(vector >());
 }
-// CHECK: {{.*}}candidate function not viable: no known conversion from 
'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' to 
'vector>' for 1st argument
+// CHECK: {{.*}}candidate function not viable: no known conversion from 
'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<...>>' to 
'vector>' for 1st argument
 // TREE: {{.*}}candidate function not viable: no known conversion from 
argument type to parameter type for 1st argument
 // TREE:   vector<
-// TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= [[CYAN]](no 
qualifiers){{ ?}}[[RESET]]]{{ ?}}vector<
-// TREE:   [...]>>
+// TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= [[CYAN]](no 
qualifiers){{ ?}}[[RESET]]]{{ ?}}vector<...>>
 
 void set17(vector >) {}
 void test17() {
   set17(vector >());
 }
-// CHECK: candidate function not viable: no known conversion from 
'vector>' to 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ 
?}}vector<[...]>>' for 1st argument
+// CHECK: candidate function not viable: no known conversion from 
'vector>' to 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ 
?}}vector<...>>' for 1st argument
 // TREE: candidate function not viable: no known conversion from argument type 
to parameter type for 1st argument
 // TREE:   vector<
-// TREE: {{\[}}[[CYAN]](no qualifiers){{ ?}}[[RESET]]{{ ?}}!= 
[[CYAN]]const[[RESET]]] vector<
-// TREE:   [...]>>
+// TREE: {{\[}}[[CYAN]](no qualifiers){{ ?}}[[RESET]]{{ ?}}!= 
[[CYAN]]const[[RESET]]] vector<...>>
 
 void set18(vector >) {}
 void test18() {
   set18(vector >());
 }
-// CHECK: candidate function not viable: no known conversion from 
'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' to 
'vector<[[CYAN]]volatile{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' for 1st argument
+// CHECK: candidate function not viable: no known conversion from 
'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<...>>' to 
'vector<[[CYAN]]volatile{{ ?}}[[RESET]]{{ ?}}vector<...>>' for 1st argument
 // TREE: no matching function for call to 'set18'
 // TREE: candidate function not viable: no known conversion from argument type 
to parameter type for 1st argument
 // TREE:   vector<
-// TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= 
[[CYAN]]volatile[[RESET]]] vector<
-// TREE:   [...]>>
+// TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= 
[[CYAN]]volatile[[R

Re: r257831 - Refactor template type diffing

2016-02-01 Thread Richard Trieu via cfe-commits
On Mon, Feb 1, 2016 at 2:10 PM, Richard Smith  wrote:

> On Thu, Jan 14, 2016 at 2:57 PM, Richard Trieu via cfe-commits
>  wrote:
> > Author: rtrieu
> > Date: Thu Jan 14 16:56:39 2016
> > New Revision: 257831
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=257831&view=rev
> > Log:
> > Refactor template type diffing
> >
> > 1) Instead of using pairs of From/To* fields, combine fields into a
> struct
> > TemplateArgInfo and have two in each DiffNode.
> > 2) Use default initialization in DiffNode so that the constructor shows
> the
> > only field that is initialized differently on construction.
> > 3) Use Set and Get functions per each DiffKind to make sure all fields
> for the
> > diff is set.  In one case, the Expr fields were not set.
> > 4) Don't print boolean literals for boolean template arguments.  This
> prevents
> > printing 'false aka 0'
> >
> > Only #3 has a functional change, which is reflected in the test change.
> >
> > Modified:
> > cfe/trunk/lib/AST/ASTDiagnostic.cpp
> > cfe/trunk/test/Misc/diag-template-diffing.cpp
> >
> > Modified: cfe/trunk/lib/AST/ASTDiagnostic.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDiagnostic.cpp?rev=257831&r1=257830&r2=257831&view=diff
> >
> ==
> > --- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
> > +++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Thu Jan 14 16:56:39 2016
> > @@ -491,82 +491,67 @@ class TemplateDiff {
> >/// DiffTree - A tree representation the differences between two
> types.
> >class DiffTree {
> >public:
> > -/// DiffKind - The difference in a DiffNode and which fields are
> used.
> > +/// DiffKind - The difference in a DiffNode.  Fields of
> > +/// TemplateArgumentInfo needed by each difference can be found in
> the
> > +/// Set* and Get* functions.
> >  enum DiffKind {
> >/// Incomplete or invalid node.
> >Invalid,
> > -  /// Another level of templates, uses TemplateDecl and Qualifiers
> > +  /// Another level of templates, requires that
>
> ... requires that what?
>
Comment fixed in r259445.

>
> >Template,
> > -  /// Type difference, uses QualType
> > +  /// Type difference, all type differences except those falling
> under
> > +  /// the Template difference.
> >Type,
> > -  /// Expression difference, uses Expr
> > +  /// Expression difference, this is only when both arguments are
> > +  /// expressions.  If one argument is an expression and the other
> is
> > +  /// Integer or Declaration, then use that diff type instead.
> >Expression,
> > -  /// Template argument difference, uses TemplateDecl
> > +  /// Template argument difference
> >TemplateTemplate,
> > -  /// Integer difference, uses APSInt and Expr
> > +  /// Integer difference
> >Integer,
> > -  /// Declaration difference, uses ValueDecl
> > +  /// Declaration difference, nullptr arguments are included here
> >Declaration
> >  };
> > +
> >private:
> > +/// TemplateArgumentInfo - All the information needed to pretty
> print
> > +/// a template argument.  See the Set* and Get* functions to see
> which
> > +/// fields are used for each DiffKind.
> > +struct TemplateArgumentInfo {
> > +  QualType ArgType;
> > +  Qualifiers Qual;
> > +  llvm::APSInt Val;
> > +  bool IsValidInt = false;
> > +  Expr *ArgExpr = nullptr;
> > +  TemplateDecl *TD = nullptr;
> > +  ValueDecl *VD = nullptr;
> > +  bool NeedAddressOf = false;
> > +  bool IsNullPtr = false;
> > +  bool IsDefault = false;
> > +};
> > +
> >  /// DiffNode - The root node stores the original type.  Each child
> node
> >  /// stores template arguments of their parents.  For templated
> types, the
> >  /// template decl is also stored.
> >  struct DiffNode {
> > -  DiffKind Kind;
> > +  DiffKind Kind = Invalid;
> >
> >/// NextNode - The index of the next sibling node or 0.
> > -  unsigned NextNode;
> > +  unsigned NextNode = 0;
> >
> >/// ChildNode - The index of the first child node or 0.
> > -  unsigned ChildNode;
> > +  unsigned ChildNode = 0;
> >
> >/// ParentNode - The index of the parent node.
> > -  unsigned ParentNode;
> > -
> > -  /// FromType, ToType - The type arguments.
> > -  QualType FromType, ToType;
> > -
> > -  /// FromExpr, ToExpr - The expression arguments.
> > -  Expr *FromExpr, *ToExpr;
> > -
> > -  /// FromNullPtr, ToNullPtr - If the template argument is a nullptr
> > -  bool FromNullPtr, ToNullPtr;
> > -
> > -  /// FromTD, ToTD - The template decl for template template
> > -  /// arguments or the type arguments that are templates.
> > -  TemplateDecl *FromTD, *ToTD;
> > -
> > -  /// FromQual, ToQual - Qualifiers for template types.
> > -  Qualifiers FromQual, ToQual;
> > -
> >

Re: [PATCH] D16586: Make clang AAPCS compliant w.r.t volatile bitfield accesses

2016-02-01 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.


Comment at: test/CodeGen/aapcs-bitfield.c:312-317
@@ +311,8 @@
+
+  // BE: %[[PTR3:.*]] = bitcast %struct.st5a* %[[PTR2]] to i32*
+  // BE-NEXT: %[[LD:.*]] = load volatile i32, i32* %[[PTR3]], align 4
+  // BE-NEXT: %[[CLR:.*]] = and i32 %[[LD]], -16252929
+  // BE-NEXT: %[[SET:.*]] = or i32 %[[CLR]], 1572864
+  // BE-NEXT: store volatile i32 %[[SET]], i32* %[[PTR3]], align 4
+  m->y.b = 3;
+}

This violates the C and C++ object models by creating a data race on `m->y.a` 
that was not present in the source code. A store to a bit-field cannot write to 
bytes that are not part of the same sequence of bit-field members. If this ABI 
really requires that (and supports multi-threaded systems), it is not a correct 
ABI for C11 nor C++11. (This leaves open the question of which standard we 
should follow...)


http://reviews.llvm.org/D16586



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


Re: [PATCH] D16788: PS4 ABI Round 2. Actual PS4 code.

2016-02-01 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/AST/RecordLayoutBuilder.cpp:1598-1599
@@ -1597,1 +1597,4 @@
 
+// PS4 remains compatible to pre r257462 behavior.
+bool isPS4ABI = (Context.getTargetInfo().getCXXABI().getKind() == 
TargetCXXABI::PS4);
+

Please say what that behavior was here. "The PS4 ABI ignores explicit alignment 
attributes on bitfields." or similar.


http://reviews.llvm.org/D16788



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


[PATCH] D16791: unordered_map: Match emplace_hint logic when _LIBCPP_DEBUG, NFC

2016-02-01 Thread Duncan P. N. Exon Smith via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: EricWF.
dexonsmith added a subscriber: cfe-commits.

When `!defined(_LIBCPP_DEBUG)`, unordered_map::emplace_hint() forwards
to emplace().  Do the same when `defined(_LIBCPP_DEBUG)`.

This has no real functionality change, just unifies the logic as a
prep commit.


http://reviews.llvm.org/D16791

Files:
  include/unordered_map

Index: include/unordered_map
===
--- include/unordered_map
+++ include/unordered_map
@@ -932,7 +932,7 @@
 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
 "unordered_map::emplace_hint(const_iterator, args...) called 
with an iterator not"
 " referring to this unordered_map");
-return 
__table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
+return emplace(_VSTD::forward<_Args>(__args)...).first;
 }
 #else
 iterator emplace_hint(const_iterator, _Args&&... __args)


Index: include/unordered_map
===
--- include/unordered_map
+++ include/unordered_map
@@ -932,7 +932,7 @@
 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
 "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
 " referring to this unordered_map");
-return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
+return emplace(_VSTD::forward<_Args>(__args)...).first;
 }
 #else
 iterator emplace_hint(const_iterator, _Args&&... __args)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16792: unordered_map: Use __hash_table::__emplace_unique(), NFC

2016-02-01 Thread Duncan P. N. Exon Smith via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: EricWF.
dexonsmith added a subscriber: cfe-commits.

Instead of duplicating code in unordered_map::emplace(), use
__hash_table::__emplace_unique().

http://reviews.llvm.org/D16792

Files:
  include/unordered_map

Index: include/unordered_map
===
--- include/unordered_map
+++ include/unordered_map
@@ -922,7 +922,8 @@
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 
 template 
-pair emplace(_Args&&... __args);
+pair emplace(_Args&&... __args)
+{return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
 
 template 
 _LIBCPP_INLINE_VISIBILITY
@@ -1474,18 +1475,6 @@
 return __h;
 }
 
-template 
-template 
-pair::iterator, bool>
-unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
-{
-__node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
-pair __r = __table_.__node_insert_unique(__h.get());
-if (__r.second)
-__h.release();
-return __r;
-}
-
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 


Index: include/unordered_map
===
--- include/unordered_map
+++ include/unordered_map
@@ -922,7 +922,8 @@
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 
 template 
-pair emplace(_Args&&... __args);
+pair emplace(_Args&&... __args)
+{return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
 
 template 
 _LIBCPP_INLINE_VISIBILITY
@@ -1474,18 +1475,6 @@
 return __h;
 }
 
-template 
-template 
-pair::iterator, bool>
-unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
-{
-__node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
-pair __r = __table_.__node_insert_unique(__h.get());
-if (__r.second)
-__h.release();
-return __r;
-}
-
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16264: For FreeBSD, use _p variants of libraries for linking C++ programs

2016-02-01 Thread Saleem Abdulrasool via cfe-commits
compnerd added a comment.

I think it would be better if we could actually create a helper to get the 
profiling library name for a specific library, and use that in both locations.

Do we have a test for the math case at the very least?


http://reviews.llvm.org/D16264



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


Re: [modules] PR24954

2016-02-01 Thread Richard Smith via cfe-commits
On Thu, Jan 28, 2016 at 8:23 AM, Vassil Vassilev  wrote:
> Would this patch be more reasonable? It follows what
> RegisterTemplateSpecialization (introduced in r245779) does. AFAICT this
> adds an update record far less often.

It's still adding redundant update records. We'll write the
appropriate update record as part of serializing the declaration
itself, so we only need to ensure that the declaration is emitted, not
actually emit an update record for it. Perhaps you could store a list
of such declarations on the ASTWriter, and call GetDeclRef on each of
them once we start emitting the AST file (or maybe just push them into
UpdatingVisibleDecls). Please also restrict this to the template
friend corner case.

> --Vassil
>
> On 12/12/15 16:13, Vassil Vassilev wrote:
>
> I couldn't find GetDecl routine in the ASTWriter. Could you elaborate?
>
> Assuming you meant ASTWriter::GetDeclRef(D): It seems that the conditions
> when calling GetDeclRef differ from the conditions of
> AddedCXXTemplateSpecialization. Eg:
>
> ASTWriter::AddedCXXTemplateSpecialization {
>   assert(!WritingAST && "Already writing the AST!");
>   ...
> }
> ASTWriter::GetDeclRef {
>   assert(WritingAST && "Cannot request a declaration ID before AST
> writing");
>   ..
> }
>
> IIUC this particular instantiation happens *after* module B was built, thus
> it needs to be retrospectively added to the serialized namespace. It looks
> like even avoiding somehow the asserts of GetDeclRef it wouldn't help much.
>
> Alternatively I could try to reduce the redundant update records by
> narrowing down to instantiations coming in the context of friends.
>
> --Vassil
>
> On 12/12/15 01:07, Richard Smith wrote:
>
> Instead of adding an update record directly in this case (which will emit
> far more update records than necessary), how about just calling GetDecl(D)
> from AddedCXXTemplateSpecialization to ensure that it gets emitted?
>
> On Fri, Dec 4, 2015 at 7:46 AM, Vassil Vassilev  wrote:
>>
>> Hi,
>>   Could you review my fix please.
>> Many thanks,
>> Vassil
>>
>> On 08/10/15 15:53, Vassil Vassilev wrote:
>>>
>>> Hi Richard,
>>>   I started working on https://llvm.org/bugs/show_bug.cgi?id=24954
>>>
>>>   IIUC r228485 introduces an abstraction to deal with
>>> not-really-anonymous friend decls
>>> (serialization::needsAnonymousDeclarationNumber in ASTCommon.cpp).
>>>
>>>   A comment explicitly says:
>>>   "// This doesn't apply to friend tag decls; Sema makes those available
>>> to name
>>>// lookup in the surrounding context."
>>>
>>>   In the bug reproducer, the friend function (wrt __iom_t10) is forward
>>> declared in the same namespace, where Sema makes the friend available for a
>>> name lookup.
>>>
>>>   It seems that the friend operator<< in __iom_t10 (sorry about the names
>>> they come from libcxx) doesn't get registered in the ASTWriter's DeclIDs but
>>> it gets registered in outer namespace's lookup table. Thus, assert is
>>> triggered when finalizing module A, since it rebuilds the lookups of the
>>> updated contexts.
>>>
>>>   The issue only appears when building module A deserializes/uses module
>>> B.
>>>
>>>   Currently I was assume that something wrong happens in either
>>> needsAnonymousDeclarationNumber or I hit a predicted issue
>>> ASTWriterDecl.cpp:1602
>>> // FIXME: This is not correct; when we reach an imported declaration
>>> we
>>> // won't emit its previous declaration.
>>> (void)Writer.GetDeclRef(D->getPreviousDecl());
>>> (void)Writer.GetDeclRef(MostRecent);
>>>
>>>   The issue seems a fairly complex one and I am a bit stuck.
>>>
>>>   Any hints are very very welcome ;)
>>> Many thanks,
>>> Vassil
>>>
>>>
>>>
>>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >