r285673 - clang-format: Fix incorrect pointer detection.

2016-10-31 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Nov  1 01:23:14 2016
New Revision: 285673

URL: http://llvm.org/viewvc/llvm-project?rev=285673&view=rev
Log:
clang-format: Fix incorrect pointer detection.

Before:
  void f() { f(float{1}, a *a); }

After:
  void f() { f(float{1}, a * a); }

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=285673&r1=285672&r2=285673&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Nov  1 01:23:14 2016
@@ -273,8 +273,9 @@ private:
   !CurrentToken->Next->HasUnescapedNewline &&
   !CurrentToken->Next->isTrailingComment())
 HasMultipleParametersOnALine = true;
-  if (CurrentToken->isOneOf(tok::kw_const, tok::kw_auto) ||
-  CurrentToken->isSimpleTypeSpecifier())
+  if ((CurrentToken->Previous->isOneOf(tok::kw_const, tok::kw_auto) ||
+   CurrentToken->Previous->isSimpleTypeSpecifier()) &&
+  !CurrentToken->is(tok::l_brace))
 Contexts.back().IsExpression = false;
   if (CurrentToken->isOneOf(tok::semi, tok::colon))
 MightBeObjCForRangeLoop = false;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=285673&r1=285672&r2=285673&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Nov  1 01:23:14 2016
@@ -5870,6 +5870,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
   verifyIndependentOfContext("MACRO(auto *a);");
   verifyIndependentOfContext("MACRO(const A *a);");
   verifyIndependentOfContext("MACRO('0' <= c && c <= '9');");
+  verifyFormat("void f() { f(float{1}, a * a); }");
   // FIXME: Is there a way to make this work?
   // verifyIndependentOfContext("MACRO(A *a);");
 


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


r285669 - clang-format: [JS] Fix space when for is used as regular identifier.

2016-10-31 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Nov  1 01:22:54 2016
New Revision: 285669

URL: http://llvm.org/viewvc/llvm-project?rev=285669&view=rev
Log:
clang-format: [JS] Fix space when for is used as regular identifier.

Before:
  x.for () = 1;

After:
  x.for() = 1;

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=285669&r1=285668&r2=285669&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Nov  1 01:22:54 2016
@@ -2159,6 +2159,9 @@ bool TokenAnnotator::spaceRequiredBefore
  Keywords.kw_of, tok::kw_const) &&
 (!Left.Previous || !Left.Previous->is(tok::period)))
   return true;
+if (Left.is(tok::kw_for) && Left.Previous &&
+Left.Previous->is(tok::period) && Right.is(tok::l_paren))
+  return false;
 if (Left.is(Keywords.kw_as) &&
 Right.isOneOf(tok::l_square, tok::l_brace, tok::l_paren))
   return true;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=285669&r1=285668&r2=285669&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Nov  1 01:22:54 2016
@@ -135,6 +135,7 @@ TEST_F(FormatTestJS, ReservedWords) {
   verifyFormat("x.in() = 1;");
   verifyFormat("x.let() = 1;");
   verifyFormat("x.var() = 1;");
+  verifyFormat("x.for() = 1;");
   verifyFormat("x = {\n"
"  a: 12,\n"
"  interface: 1,\n"


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


r285674 - clang-format: Fix bug in function reference qualifier detection.

2016-10-31 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Nov  1 01:23:19 2016
New Revision: 285674

URL: http://llvm.org/viewvc/llvm-project?rev=285674&view=rev
Log:
clang-format: Fix bug in function reference qualifier detection.

Before:
  template 
  void F(T) &&
  = delete;

After:
  template 
  void F(T) && = delete;

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=285674&r1=285673&r2=285674&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Nov  1 01:23:19 2016
@@ -1251,7 +1251,7 @@ private:
 
 const FormatToken *NextToken = Tok.getNextNonComment();
 if (!NextToken ||
-NextToken->isOneOf(tok::arrow, Keywords.kw_final,
+NextToken->isOneOf(tok::arrow, Keywords.kw_final, tok::equal,
Keywords.kw_override) ||
 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
   return TT_PointerOrReference;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=285674&r1=285673&r2=285674&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Nov  1 01:23:19 2016
@@ -5637,6 +5637,9 @@ TEST_F(FormatTest, UnderstandsFunctionRe
   verifyFormat("SomeType MemberFunction(const Deleted &) && final {}");
   verifyFormat("SomeType MemberFunction(const Deleted &) && override {}");
   verifyFormat("SomeType MemberFunction(const Deleted &) const &;");
+  verifyFormat("template \n"
+   "void F(T) && = delete;",
+   getGoogleStyle());
 
   FormatStyle AlignLeft = getLLVMStyle();
   AlignLeft.PointerAlignment = FormatStyle::PAS_Left;
@@ -5789,7 +5792,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
   FormatStyle Left = getLLVMStyle();
   Left.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("x = *a(x) = *a(y);", Left);
-  verifyFormat("for (;; * = b) {\n}", Left);
+  verifyFormat("for (;; *a = b) {\n}", Left);
   verifyFormat("return *this += 1;", Left);
 
   verifyIndependentOfContext("a = *(x + y);");


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


r285670 - clang-format: [JS] Fix formatting of generator functions.

2016-10-31 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Nov  1 01:22:59 2016
New Revision: 285670

URL: http://llvm.org/viewvc/llvm-project?rev=285670&view=rev
Log:
clang-format: [JS] Fix formatting of generator functions.

Before:
  var x = {
a: function*
() {
  //
}
  }

After:
  var x = {
a: function*() {
  //
}
  }

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.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=285670&r1=285669&r2=285670&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Nov  1 01:22:59 2016
@@ -859,7 +859,8 @@ private:
 if (!CurrentToken->isOneOf(TT_LambdaLSquare, TT_ForEachMacro,
TT_FunctionLBrace, TT_ImplicitStringLiteral,
TT_InlineASMBrace, TT_JsFatArrow, 
TT_LambdaArrow,
-   TT_RegexLiteral, TT_TemplateString))
+   TT_OverloadedOperator, TT_RegexLiteral,
+   TT_TemplateString))
   CurrentToken->Type = TT_Unknown;
 CurrentToken->Role.reset();
 CurrentToken->MatchingParen = nullptr;

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=285670&r1=285669&r2=285670&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Nov  1 01:22:59 2016
@@ -1230,9 +1230,11 @@ void UnwrappedLineParser::tryToParseJSFu
   // Consume "function".
   nextToken();
 
-  // Consume * (generator function).
-  if (FormatTok->is(tok::star))
+  // Consume * (generator function). Treat it like C++'s overloaded operators.
+  if (FormatTok->is(tok::star)) {
+FormatTok->Type = TT_OverloadedOperator;
 nextToken();
+  }
 
   // Consume function name.
   if (FormatTok->is(tok::identifier))

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=285670&r1=285669&r2=285670&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Nov  1 01:22:59 2016
@@ -384,6 +384,11 @@ TEST_F(FormatTestJS, GeneratorFunctions)
"yield x;\n"
"  }\n"
"}");
+  verifyFormat("var x = {\n"
+   "  a: function*() {\n"
+   "//\n"
+   "  }\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, AsyncFunctions) {


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


r285671 - clang-format: Fix incorrect binary operator detection.

2016-10-31 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Nov  1 01:23:05 2016
New Revision: 285671

URL: http://llvm.org/viewvc/llvm-project?rev=285671&view=rev
Log:
clang-format: Fix incorrect binary operator detection.

Before:
  int x = f(* + [] {});

After:
  int x = f(*+[] {});

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=285671&r1=285670&r2=285671&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Nov  1 01:23:05 2016
@@ -1310,7 +1310,7 @@ private:
 
   TokenType determinePlusMinusCaretUsage(const FormatToken &Tok) {
 const FormatToken *PrevToken = Tok.getPreviousNonComment();
-if (!PrevToken || PrevToken->is(TT_CastRParen))
+if (!PrevToken || PrevToken->isOneOf(TT_CastRParen, TT_UnaryOperator))
   return TT_UnaryOperator;
 
 // Use heuristics to recognize unary operators.

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=285671&r1=285670&r2=285671&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Nov  1 01:23:05 2016
@@ -10954,6 +10954,7 @@ TEST_F(FormatTest, FormatsLambdas) {
   verifyFormat("int c = [&a, &a, a] { [=, a, b, &c] { return b++; }(); 
}();\n");
   verifyFormat("auto c = {[&a, &a, a] { [=, a, b, &c] { return b++; }(); 
}}\n");
   verifyFormat("auto c = {[&a, &a, a] { [=, a, b, &c] {}(); }}\n");
+  verifyFormat("int x = f(*+[] {});");
   verifyFormat("void f() {\n"
"  other(x.begin(), x.end(), [&](int, int) { return 1; });\n"
"}\n");


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


r285672 - clang-format: [JS] Fix incorrect space when "as" is used as identifier.

2016-10-31 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Nov  1 01:23:10 2016
New Revision: 285672

URL: http://llvm.org/viewvc/llvm-project?rev=285672&view=rev
Log:
clang-format: [JS] Fix incorrect space when "as" is used as identifier.

Before:
  a.as ();

After:
  a.as();

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=285672&r1=285671&r2=285672&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Nov  1 01:23:10 2016
@@ -2160,7 +2160,7 @@ bool TokenAnnotator::spaceRequiredBefore
  Keywords.kw_of, tok::kw_const) &&
 (!Left.Previous || !Left.Previous->is(tok::period)))
   return true;
-if (Left.is(tok::kw_for) && Left.Previous &&
+if (Left.isOneOf(tok::kw_for, Keywords.kw_as) && Left.Previous &&
 Left.Previous->is(tok::period) && Right.is(tok::l_paren))
   return false;
 if (Left.is(Keywords.kw_as) &&

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=285672&r1=285671&r2=285672&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Nov  1 01:23:10 2016
@@ -136,6 +136,7 @@ TEST_F(FormatTestJS, ReservedWords) {
   verifyFormat("x.let() = 1;");
   verifyFormat("x.var() = 1;");
   verifyFormat("x.for() = 1;");
+  verifyFormat("x.as() = 1;");
   verifyFormat("x = {\n"
"  a: 12,\n"
"  interface: 1,\n"


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


r285667 - [AVX-512] Remove masked vector insert builtins and replace with native shufflevectors and selects.

2016-10-31 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Nov  1 00:47:56 2016
New Revision: 285667

URL: http://llvm.org/viewvc/llvm-project?rev=285667&view=rev
Log:
[AVX-512] Remove masked vector insert builtins and replace with native 
shufflevectors and selects.

Unfortunately, the backend currently doesn't fold masks into the instructions 
correctly when they come from these shufflevectors. I'll work on that in a 
future commit.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512dqintrin.h
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vldqintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/avx512dq-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/avx512vldq-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=285667&r1=285666&r2=285667&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Nov  1 00:47:56 2016
@@ -1725,18 +1725,6 @@ TARGET_BUILTIN(__builtin_ia32_pmovqw128_
 TARGET_BUILTIN(__builtin_ia32_pmovqw128mem_mask, "vV8s*V2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pmovqw256_mask, "V8sV4LLiV8sUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pmovqw256mem_mask, "vV8s*V4LLiUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_insertf32x8_mask, 
"V16fV16fV8fIiV16fUs","","avx512dq")
-TARGET_BUILTIN(__builtin_ia32_insertf64x2_512_mask, 
"V8dV8dV2dIiV8dUc","","avx512dq")
-TARGET_BUILTIN(__builtin_ia32_inserti32x8_mask, 
"V16iV16iV8iIiV16iUs","","avx512dq")
-TARGET_BUILTIN(__builtin_ia32_inserti64x2_512_mask, 
"V8LLiV8LLiV2LLiIiV8LLiUc","","avx512dq")
-TARGET_BUILTIN(__builtin_ia32_insertf64x4_mask, 
"V8dV8dV4dIiV8dUc","","avx512f")
-TARGET_BUILTIN(__builtin_ia32_inserti64x4_mask, 
"V8LLiV8LLiV4LLiIiV8LLiUc","","avx512f")
-TARGET_BUILTIN(__builtin_ia32_insertf64x2_256_mask, 
"V4dV4dV2dIiV4dUc","","avx512dq,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_inserti64x2_256_mask, 
"V4LLiV4LLiV2LLiIiV4LLiUc","","avx512dq,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_insertf32x4_256_mask, 
"V8fV8fV4fIiV8fUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_inserti32x4_256_mask, 
"V8iV8iV4iIiV8iUc","","avx512vl")
-TARGET_BUILTIN(__builtin_ia32_insertf32x4_mask, 
"V16fV16fV4fIiV16fUs","","avx512f")
-TARGET_BUILTIN(__builtin_ia32_inserti32x4_mask, 
"V16iV16iV4iIiV16iUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_getmantpd128_mask, "V2dV2diV2dUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_getmantpd256_mask, "V4dV4diV4dUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_getmantps128_mask, "V4fV4fiV4fUc","","avx512vl")

Modified: cfe/trunk/lib/Headers/avx512dqintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512dqintrin.h?rev=285667&r1=285666&r2=285667&view=diff
==
--- cfe/trunk/lib/Headers/avx512dqintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512dqintrin.h Tue Nov  1 00:47:56 2016
@@ -1192,82 +1192,108 @@ _mm512_maskz_broadcast_i64x2 (__mmask8 _
 (__v2di)_mm_setzero_di()); })
 
 #define _mm512_insertf32x8(A, B, imm) __extension__ ({ \
-  (__m512)__builtin_ia32_insertf32x8_mask((__v16sf)(__m512)(A), \
-  (__v8sf)(__m256)(B), (int)(imm), \
-  (__v16sf)_mm512_setzero_ps(), \
-  (__mmask16)-1); })
+  (__m512)__builtin_shufflevector((__v16sf)(__m512)(A), \
+  
(__v16sf)_mm512_castps256_ps512((__m256)(B)),\
+  ((imm) & 0x1) ?  0 : 16, \
+  ((imm) & 0x1) ?  1 : 17, \
+  ((imm) & 0x1) ?  2 : 18, \
+  ((imm) & 0x1) ?  3 : 19, \
+  ((imm) & 0x1) ?  4 : 20, \
+  ((imm) & 0x1) ?  5 : 21, \
+  ((imm) & 0x1) ?  6 : 22, \
+  ((imm) & 0x1) ?  7 : 23, \
+  ((imm) & 0x1) ? 16 :  8, \
+  ((imm) & 0x1) ? 17 :  9, \
+  ((imm) & 0x1) ? 18 : 10, \
+  ((imm) & 0x1) ? 19 : 11, \
+  ((imm) & 0x1) ? 20 : 12, \
+  ((imm) & 0x1) ? 21 : 13, \
+  ((imm) & 0x1) ? 22 : 14, \
+  ((imm) & 0x1) ? 23 : 15); })
 
 #define _mm512_mask_insertf32x8(W, U, A, B, imm) __extension__ ({ \
-  (__m512)__builtin_ia32_insertf32x8_mask((__v16sf)(_

[PATCH] D26166: [Sema] Don't issue analysis-based warnings when a fatal error has occurred

2016-10-31 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 76521.
ahatanak added a comment.

Thanks, that fixed the failing regression tests.


https://reviews.llvm.org/D26166

Files:
  lib/Sema/SemaTemplateInstantiate.cpp
  test/SemaCXX/instantiate-template-fatal-error.cpp


Index: test/SemaCXX/instantiate-template-fatal-error.cpp
===
--- /dev/null
+++ test/SemaCXX/instantiate-template-fatal-error.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+
+#pragma clang diagnostic fatal "-Wall"
+#pragma clang diagnostic fatal "-Wold-style-cast"
+
+template  bool foo0(const long long *a, T* b) {
+  return a == (const long long*)b; // expected-error {{use of old-style cast}}
+}
+
+template
+struct S1 {
+};
+
+template
+struct S2 : S1 {
+  bool m1(const long long *a, T *b) const { return foo0(a, b); }
+};
+
+bool foo1(const long long *a, int *b) {
+  S2 s2;
+  return s2.m1(a, b);
+}
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -209,9 +209,11 @@
 sema::TemplateDeductionInfo *DeductionInfo)
 : SemaRef(SemaRef), SavedInNonInstantiationSFINAEContext(
 SemaRef.InNonInstantiationSFINAEContext) {
-  // Don't allow further instantiation if a fatal error has occcured.  Any
-  // diagnostics we might have raised will not be visible.
-  if (SemaRef.Diags.hasFatalErrorOccurred()) {
+  // Don't allow further instantiation if a fatal error and an uncompilable
+  // error have occcured. Any diagnostics we might have raised will not be
+  // visible.
+  if (SemaRef.Diags.hasFatalErrorOccurred() &&
+  SemaRef.Diags.hasUncompilableErrorOccurred()) {
 Invalid = true;
 return;
   }


Index: test/SemaCXX/instantiate-template-fatal-error.cpp
===
--- /dev/null
+++ test/SemaCXX/instantiate-template-fatal-error.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+
+#pragma clang diagnostic fatal "-Wall"
+#pragma clang diagnostic fatal "-Wold-style-cast"
+
+template  bool foo0(const long long *a, T* b) {
+  return a == (const long long*)b; // expected-error {{use of old-style cast}}
+}
+
+template
+struct S1 {
+};
+
+template
+struct S2 : S1 {
+  bool m1(const long long *a, T *b) const { return foo0(a, b); }
+};
+
+bool foo1(const long long *a, int *b) {
+  S2 s2;
+  return s2.m1(a, b);
+}
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -209,9 +209,11 @@
 sema::TemplateDeductionInfo *DeductionInfo)
 : SemaRef(SemaRef), SavedInNonInstantiationSFINAEContext(
 SemaRef.InNonInstantiationSFINAEContext) {
-  // Don't allow further instantiation if a fatal error has occcured.  Any
-  // diagnostics we might have raised will not be visible.
-  if (SemaRef.Diags.hasFatalErrorOccurred()) {
+  // Don't allow further instantiation if a fatal error and an uncompilable
+  // error have occcured. Any diagnostics we might have raised will not be
+  // visible.
+  if (SemaRef.Diags.hasFatalErrorOccurred() &&
+  SemaRef.Diags.hasUncompilableErrorOccurred()) {
 Invalid = true;
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26065: Improve diagnostics if friend function redefines file-level function.

2016-10-31 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 76520.
sepavloff added a comment.

Do not use getFriendObjectKind(), friend kind sometimes is set too late.


https://reviews.llvm.org/D26065

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp


Index: test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp
===
--- test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp
@@ -4,3 +4,31 @@
 }
 
 inline void f0(); // expected-error {{inline declaration of 'f0' follows 
non-inline definition}}
+
+void func_01() {} // expected-note{{previous definition is here}}
+struct C01 {
+  friend void func_01() {} // expected-error{{redefinition of 'func_01'}}
+};
+
+void func_02() {} // expected-note{{previous definition is here}}
+struct C02 {
+  friend inline void func_02(); // expected-error{{inline declaration of 
'func_02' follows non-inline definition}}
+};
+
+void func_03() {} // expected-note{{previous definition is here}}
+struct C03 {
+  friend inline void func_03() {} // expected-error{{inline declaration of 
'func_03' follows non-inline definition}}
+};
+
+void func_04() {} // expected-note{{previous definition is here}}
+inline void func_04() {} // expected-error{{inline declaration of 'func_04' 
follows non-inline definition}}
+
+void func_06() {} // expected-note{{previous definition is here}}
+template struct C06 {
+  friend inline void func_06() {} // expected-error{{inline declaration of 
'func_06' follows non-inline definition}}
+};
+
+void func_07() {} // expected-note{{previous definition is here}}
+template struct C07 {
+  friend inline void func_07(); // expected-error{{inline declaration of 
'func_07' follows non-inline definition}}
+};
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -639,7 +639,12 @@
 Diag(Old->getLocation(), diag::note_previous_declaration);
 Invalid = true;
   } else if (!Old->getMostRecentDecl()->isInlined() && New->isInlined() &&
- Old->isDefined(Def)) {
+ Old->isDefined(Def) &&
+ // If a friend function is inlined but does not have 'inline'
+ // specifier, it is a definition. Do not report attribute conflict
+ // in this case, redefinition will be diagnosed later.
+ (New->isInlineSpecified() || !New->isOutOfLine() ||
+  !New->getLexicalDeclContext()->isRecord())) {
 // C++11 [dcl.fcn.spec]p4:
 //   If the definition of a function appears in a translation unit before 
its
 //   first declaration as inline, the program is ill-formed.


Index: test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp
===
--- test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp
@@ -4,3 +4,31 @@
 }
 
 inline void f0(); // expected-error {{inline declaration of 'f0' follows non-inline definition}}
+
+void func_01() {} // expected-note{{previous definition is here}}
+struct C01 {
+  friend void func_01() {} // expected-error{{redefinition of 'func_01'}}
+};
+
+void func_02() {} // expected-note{{previous definition is here}}
+struct C02 {
+  friend inline void func_02(); // expected-error{{inline declaration of 'func_02' follows non-inline definition}}
+};
+
+void func_03() {} // expected-note{{previous definition is here}}
+struct C03 {
+  friend inline void func_03() {} // expected-error{{inline declaration of 'func_03' follows non-inline definition}}
+};
+
+void func_04() {} // expected-note{{previous definition is here}}
+inline void func_04() {} // expected-error{{inline declaration of 'func_04' follows non-inline definition}}
+
+void func_06() {} // expected-note{{previous definition is here}}
+template struct C06 {
+  friend inline void func_06() {} // expected-error{{inline declaration of 'func_06' follows non-inline definition}}
+};
+
+void func_07() {} // expected-note{{previous definition is here}}
+template struct C07 {
+  friend inline void func_07(); // expected-error{{inline declaration of 'func_07' follows non-inline definition}}
+};
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -639,7 +639,12 @@
 Diag(Old->getLocation(), diag::note_previous_declaration);
 Invalid = true;
   } else if (!Old->getMostRecentDecl()->isInlined() && New->isInlined() &&
- Old->isDefined(Def)) {
+ Old->isDefined(Def) &&
+ // If a friend function is inlined but does not have 'inline'
+ // specifier, it is a definition. Do not report attribute conflict
+ // in this case, redefinition will be diagnosed later.
+ (New->isInlineSpecified() || !New->isOutOfLine() ||
+  !New->getLexicalDeclCont

Re: r285647 - [index] Fix repeated visitation of the same InitListExpr for indexing.

2016-10-31 Thread Argyrios Kyrtzidis via cfe-commits

> On Oct 31, 2016, at 4:49 PM, Richard Smith  wrote:
> 
> On Mon, Oct 31, 2016 at 3:12 PM, Argyrios Kyrtzidis via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: akirtzidis
> Date: Mon Oct 31 17:12:12 2016
> New Revision: 285647
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=285647&view=rev 
> 
> Log:
> [index] Fix repeated visitation of the same InitListExpr for indexing.
> 
> It was visited multiple times unnecessarily.
> 
> rdar://28985038
> 
> Added:
> cfe/trunk/test/Index/Core/designated-inits.c
> Modified:
> cfe/trunk/lib/Index/IndexBody.cpp
> 
> Modified: cfe/trunk/lib/Index/IndexBody.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=285647&r1=285646&r2=285647&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/Index/IndexBody.cpp (original)
> +++ cfe/trunk/lib/Index/IndexBody.cpp Mon Oct 31 17:12:12 2016
> @@ -300,6 +300,7 @@ public:
>IndexingContext &IndexCtx;
>const NamedDecl *Parent;
>const DeclContext *ParentDC;
> +  bool Visited = false;
> 
>  public:
>SyntacticFormIndexer(IndexingContext &indexCtx,
> 
> Do we need SyntacticFromIndexer to be a RecursiveASTVisitor at all? It looks 
> like you would get the desired effect by simply walking the elements of the 
> syntactic form looking for DesignatedInitExprs (which will always be at the 
> top level of the InitListExpr's element if they exist). Right now, it looks 
> like you still traverse expression E twice in cases like this:
> 
>   int arr[] = { [0] = 0, E };
> 
> ... and you'd still get a quadratic traversal for a case like { [0] = {}, { 
> [0] = {}, { [0] = {}, ... } } }.

This is excellent feedback, see r285666.
Thanks for reviewing!

>  
> @@ -308,6 +309,22 @@ public:
> 
>bool shouldWalkTypesOfTypeLocs() const { return false; }
> 
> +  bool TraverseInitListExpr(InitListExpr *S, DataRecursionQueue *Q = 
> nullptr) {
> +// Don't visit nested InitListExprs, this visitor will be called 
> again
> +// later on for the nested ones.
> +if (Visited)
> +  return true;
> +Visited = true;
> +InitListExpr *SyntaxForm = S->isSemanticForm() ? 
> S->getSyntacticForm() : S;
> +if (SyntaxForm) {
> +  for (Stmt *SubStmt : SyntaxForm->children()) {
> +if (!TraverseStmt(SubStmt, Q))
> +  return false;
> +  }
> +}
> +return true;
> +  }
> +
>bool VisitDesignatedInitExpr(DesignatedInitExpr *E) {
>  for (DesignatedInitExpr::Designator &D : 
> llvm::reverse(E->designators())) {
>if (D.isFieldDesignator())
> 
> Added: cfe/trunk/test/Index/Core/designated-inits.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/designated-inits.c?rev=285647&view=auto
>  
> 
> ==
> --- cfe/trunk/test/Index/Core/designated-inits.c (added)
> +++ cfe/trunk/test/Index/Core/designated-inits.c Mon Oct 31 17:12:12 2016
> @@ -0,0 +1,33 @@
> +// RUN: c-index-test core -print-source-symbols -- %s -target 
> x86_64-apple-macosx10.7 | FileCheck %s
> +
> +struct MyStruct {
> +  int myfield;
> +};
> +
> +enum {
> +  MyValToSet;
> +};
> +
> +// CHECK: [[@LINE+1]]:14 | struct/C | MyStruct |
> +const struct MyStruct _MyStruct[]
> +  [16]
> +  [3]
> +  [3]
> +  [2]
> +  [2] = {
> + [0] = {
> +[0] = {
> +  [0] = {
> +[0][0] = {
> +  [0] = {
> +// CHECK: [[@LINE+2]]:14 | field/C | myfield | {{.*}} | Ref |
> +// CHECK: [[@LINE+1]]:24 | enumerator/C | MyValToSet |
> +.myfield = MyValToSet,
> +// CHECK-NOT: | field/C | myfield |
> +// CHECK-NOT: | enumerator/C | MyValToSet |
> +  },
> +},
> +  },
> +},
> +  },
> +};
> 
> 
> ___
> 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


r285666 - [index] Avoid using a RecursiveASTVisitor for SyntacticFormIndexer and iterate the DesignatedInitExprs of the InitListExpr directly.

2016-10-31 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Mon Oct 31 23:29:39 2016
New Revision: 285666

URL: http://llvm.org/viewvc/llvm-project?rev=285666&view=rev
Log:
[index] Avoid using a RecursiveASTVisitor for SyntacticFormIndexer and iterate 
the DesignatedInitExprs of the InitListExpr directly.

This is more efficient, as per feedback by Richard.

Modified:
cfe/trunk/lib/Index/IndexBody.cpp

Modified: cfe/trunk/lib/Index/IndexBody.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=285666&r1=285665&r2=285666&view=diff
==
--- cfe/trunk/lib/Index/IndexBody.cpp (original)
+++ cfe/trunk/lib/Index/IndexBody.cpp Mon Oct 31 23:29:39 2016
@@ -294,48 +294,6 @@ public:
   // Also visit things that are in the syntactic form but not the semantic one,
   // for example the indices in DesignatedInitExprs.
   bool TraverseInitListExpr(InitListExpr *S, DataRecursionQueue *Q = nullptr) {
-
-class SyntacticFormIndexer :
-  public RecursiveASTVisitor {
-  IndexingContext &IndexCtx;
-  const NamedDecl *Parent;
-  const DeclContext *ParentDC;
-  bool Visited = false;
-
-public:
-  SyntacticFormIndexer(IndexingContext &indexCtx,
-const NamedDecl *Parent, const DeclContext *DC)
-: IndexCtx(indexCtx), Parent(Parent), ParentDC(DC) { }
-
-  bool shouldWalkTypesOfTypeLocs() const { return false; }
-
-  bool TraverseInitListExpr(InitListExpr *S, DataRecursionQueue *Q = 
nullptr) {
-// Don't visit nested InitListExprs, this visitor will be called again
-// later on for the nested ones.
-if (Visited)
-  return true;
-Visited = true;
-InitListExpr *SyntaxForm = S->isSemanticForm() ? S->getSyntacticForm() 
: S;
-if (SyntaxForm) {
-  for (Stmt *SubStmt : SyntaxForm->children()) {
-if (!TraverseStmt(SubStmt, Q))
-  return false;
-  }
-}
-return true;
-  }
-
-  bool VisitDesignatedInitExpr(DesignatedInitExpr *E) {
-for (DesignatedInitExpr::Designator &D : 
llvm::reverse(E->designators())) {
-  if (D.isFieldDesignator())
-return IndexCtx.handleReference(D.getField(), D.getFieldLoc(),
-Parent, ParentDC, SymbolRoleSet(),
-{}, E);
-}
-return true;
-  }
-};
-
 auto visitForm = [&](InitListExpr *Form) {
   for (Stmt *SubStmt : Form->children()) {
 if (!TraverseStmt(SubStmt, Q))
@@ -344,13 +302,26 @@ public:
   return true;
 };
 
+auto visitSyntacticDesignatedInitExpr = [&](DesignatedInitExpr *E) -> bool 
{
+  for (DesignatedInitExpr::Designator &D : 
llvm::reverse(E->designators())) {
+if (D.isFieldDesignator())
+  return IndexCtx.handleReference(D.getField(), D.getFieldLoc(),
+  Parent, ParentDC, SymbolRoleSet(),
+  {}, E);
+  }
+  return true;
+};
+
 InitListExpr *SemaForm = S->isSemanticForm() ? S : S->getSemanticForm();
 InitListExpr *SyntaxForm = S->isSemanticForm() ? S->getSyntacticForm() : S;
 
 if (SemaForm) {
   // Visit things present in syntactic form but not the semantic form.
   if (SyntaxForm) {
-SyntacticFormIndexer(IndexCtx, Parent, 
ParentDC).TraverseStmt(SyntaxForm);
+for (Expr *init : SyntaxForm->inits()) {
+  if (auto *DIE = dyn_cast(init))
+visitSyntacticDesignatedInitExpr(DIE);
+}
   }
   return visitForm(SemaForm);
 }


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


[PATCH] D26166: [Sema] Don't issue analysis-based warnings when a fatal error has occurred

2016-10-31 Thread Richard Smith via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D26166#584285, @ahatanak wrote:

> It seems to me that the root of the problem is that the template 
> instantiation S2 is left in an incomplete state and VarDecl s2 in the 
> AST, which is of type S2, is marked invalid. As I mentioned in my 
> previous comment, I tried to fix this by calling hasUncompilableErrorOccurred 
> instead of hasFatalErrorOccurred in 
> InstantiatingTemplate::InstantiatingTemplate, but that didn't seem correct as 
> a large number of regression tests failed. What is the right way to fix this?


Ah, I see. Try changing that to `hasFatalErrorOccurred() && 
hasUncompilableErrorOccurred()`. (The former indicates we don't need more 
diagnostics, and the latter indicates we don't need a complete AST; if both 
flags are set, then we don't need to instantiate any more templates.)


https://reviews.llvm.org/D26166



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


[PATCH] D26178: [p0012] Implement ABI support for throwing a noexcept function pointer and catching as non-noexcept

2016-10-31 Thread Richard Smith via cfe-commits
rsmith created this revision.
rsmith added a reviewer: EricWF.
rsmith added a subscriber: cfe-commits.
rsmith set the repository for this revision to rL LLVM.

This implements the following proposal from cxx-abi-dev:

  http://sourcerytools.com/pipermail/cxx-abi-dev/2016-October/002988.html

... which is necessary for complete support of http://wg21.link/p0012, 
specifically throwing noexcept function and member function pointers and 
catching them as non-noexcept pointers.


Repository:
  rL LLVM

https://reviews.llvm.org/D26178

Files:
  src/private_typeinfo.cpp
  src/private_typeinfo.h
  test/catch_function_03.pass.cpp
  test/catch_member_function_pointer_02.pass.cpp
  test/libcxxabi/test/config.py

Index: test/libcxxabi/test/config.py
===
--- test/libcxxabi/test/config.py
+++ test/libcxxabi/test/config.py
@@ -37,6 +37,8 @@
 super(Configuration, self).configure_features()
 if not self.get_lit_bool('enable_exceptions', True):
 self.config.available_features.add('libcxxabi-no-exceptions')
+if not self.cxx.addCompileFlagIfSupported(['-Xclang', '-mqualified-function-type-info']):
+self.config.available_features.add("libcxxabi-no-qualified-function-types")
 
 def configure_compile_flags(self):
 self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER']
Index: test/catch_member_function_pointer_02.pass.cpp
===
--- test/catch_member_function_pointer_02.pass.cpp
+++ test/catch_member_function_pointer_02.pass.cpp
@@ -0,0 +1,68 @@
+//===--- catch_member_function_pointer_02.cpp -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Can a noexcept member function pointer be caught by a non-noexcept catch
+// clause?
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: libcxxabi-no-exceptions, libcxxabi-no-qualified-function-types
+
+#include 
+
+struct X {
+  template void f() noexcept(Noexcept) {}
+};
+template using FnType = void (X::*)() noexcept(Noexcept);
+
+template
+void check()
+{
+try
+{
+auto p = &X::f;
+throw p;
+assert(false);
+}
+catch (FnType p)
+{
+assert(ThrowNoexcept || !CatchNoexcept);
+assert(p == &X::f);
+}
+catch (...)
+{
+assert(!ThrowNoexcept && CatchNoexcept);
+}
+}
+
+void check_deep() {
+FnType p = &X::f;
+try
+{
+throw &p;
+}
+catch (FnType *q)
+{
+assert(false);
+}
+catch (FnType *q)
+{
+}
+catch (...)
+{
+assert(false);
+}
+}
+
+int main()
+{
+check();
+check();
+check();
+check();
+check_deep();
+}
Index: test/catch_function_03.pass.cpp
===
--- test/catch_function_03.pass.cpp
+++ test/catch_function_03.pass.cpp
@@ -0,0 +1,65 @@
+//===-- catch_function_03.cpp -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Can a noexcept function pointer be caught by a non-noexcept catch clause?
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: libcxxabi-no-exceptions, libcxxabi-no-qualified-function-types
+
+#include 
+
+template void f() noexcept(Noexcept) {}
+template using FnType = void() noexcept(Noexcept);
+
+template
+void check()
+{
+try
+{
+auto *p = f;
+throw p;
+assert(false);
+}
+catch (FnType *p)
+{
+assert(ThrowNoexcept || !CatchNoexcept);
+assert(p == &f);
+}
+catch (...)
+{
+assert(!ThrowNoexcept && CatchNoexcept);
+}
+}
+
+void check_deep() {
+auto *p = f;
+try
+{
+throw &p;
+}
+catch (FnType **q)
+{
+assert(false);
+}
+catch (FnType **q)
+{
+}
+catch (...)
+{
+assert(false);
+}
+}
+
+int main()
+{
+check();
+check();
+check();
+check();
+check_deep();
+}
Index: src/private_typeinfo.h
===
--- src/private_typeinfo.h
+++ src/private_typeinfo.h
@@ -49,6 +49,25 @@
void *&) const;
 };
 
+class _LIBCXXABI_TYPE_VIS __qualified_function_type_info : public __shim_type_info {
+public:
+  const __function_type_info* __base_type;
+  unsigned int __qualifiers;
+
+  enum __qualifiers_mask {
+__const_mask = 0x01,
+__volatile_mas

r285664 - Implement ABI proposal for throwing noexcept function pointers, per discussion

2016-10-31 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Oct 31 20:34:46 2016
New Revision: 285664

URL: http://llvm.org/viewvc/llvm-project?rev=285664&view=rev
Log:
Implement ABI proposal for throwing noexcept function pointers, per discussion
on cxx-abi-dev (thread starting 2016-10-11). This is currently hidden behind a
cc1-only -m flag, pending discussion of how best to deal with language changes
that require use of new symbols from the ABI library.

Added:
cfe/trunk/test/CodeGenCXX/rtti-qualfn.cpp
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=285664&r1=285663&r2=285664&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Oct 31 20:34:46 2016
@@ -251,6 +251,8 @@ def munwind_tables : Flag<["-"], "munwin
   HelpText<"Generate unwinding tables for all functions">;
 def mconstructor_aliases : Flag<["-"], "mconstructor-aliases">,
   HelpText<"Emit complete constructors and destructors as aliases when 
possible">;
+def mqualified_function_type_info : Flag<["-"], 
"mqualified-function-type-info">,
+  HelpText<"Emit __qualified_function_type_info for qualified function types">;
 def mlink_bitcode_file : Separate<["-"], "mlink-bitcode-file">,
   HelpText<"Link the given bitcode file before performing optimizations.">;
 def mlink_cuda_bitcode : Separate<["-"], "mlink-cuda-bitcode">,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=285664&r1=285663&r2=285664&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Oct 31 20:34:46 2016
@@ -133,6 +133,7 @@ CODEGENOPT(DumpCoverageMapping , 1, 0) /
   /// If -fpcc-struct-return or -freg-struct-return is specified.
 ENUM_CODEGENOPT(StructReturnConvention, StructReturnConventionKind, 2, 
SRCK_Default)
 
+CODEGENOPT(QualifiedFunctionTypeInfo, 1, 0) ///< Use 
__qualified_function_type_info.
 CODEGENOPT(RelaxAll  , 1, 0) ///< Relax all machine code instructions.
 CODEGENOPT(RelaxedAliasing   , 1, 0) ///< Set when -fno-strict-aliasing is 
enabled.
 CODEGENOPT(StructPathTBAA, 1, 0) ///< Whether or not to use struct-path 
TBAA.

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=285664&r1=285663&r2=285664&view=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon Oct 31 20:34:46 2016
@@ -46,6 +46,7 @@ protected:
   bool UseARMMethodPtrABI;
   bool UseARMGuardVarABI;
   bool Use32BitVTableOffsetABI;
+  bool UseQualifiedFunctionTypeInfoABI;
 
   ItaniumMangleContext &getMangleContext() {
 return cast(CodeGen::CGCXXABI::getMangleContext());
@@ -57,7 +58,8 @@ public:
 bool UseARMGuardVarABI = false) :
 CGCXXABI(CGM), UseARMMethodPtrABI(UseARMMethodPtrABI),
 UseARMGuardVarABI(UseARMGuardVarABI),
-Use32BitVTableOffsetABI(false) { }
+Use32BitVTableOffsetABI(false),
+
UseQualifiedFunctionTypeInfoABI(CGM.getCodeGenOpts().QualifiedFunctionTypeInfo) 
{ }
 
   bool classifyReturnType(CGFunctionInfo &FI) const override;
 
@@ -2427,6 +2429,9 @@ class ItaniumRTTIBuilder {
   /// descriptor of the given type.
   llvm::Constant *GetAddrOfExternalRTTIDescriptor(QualType Ty);
 
+  /// Determine whether FnTy should be emitted as a qualified function type.
+  bool EmitAsQualifiedFunctionType(const FunctionType *FnTy);
+
   /// BuildVTablePointer - Build the vtable pointer for the given type.
   void BuildVTablePointer(const Type *Ty);
 
@@ -2439,6 +2444,10 @@ class ItaniumRTTIBuilder {
   /// constraints, according ti the Itanium C++ ABI, 2.9.5p5c.
   void BuildVMIClassTypeInfo(const CXXRecordDecl *RD);
 
+  /// Build an abi::__qualified_function_type_info struct, used for function
+  /// types with various kinds of qualifiers.
+  void BuildQualifiedFunctionTypeInfo(const FunctionType *FnTy);
+
   /// BuildPointerTypeInfo - Build an abi::__pointer_type_info struct, used
   /// for pointer types.
   void BuildPointerTypeInfo(QualType PointeeTy);
@@ -2455,6 +2464,27 @@ public:
   ItaniumRTTIBuilder(const ItaniumCXXABI &ABI)
   : CGM(ABI.CGM), VMContext(CGM.getModule().getContext()), CXXABI(ABI) {}
 
+  // Function type info flags.
+  enum {
+/// Qualifiers for 'this' pointer of member function type.
+   

r285663 - p0012: Teach resolving address of overloaded function with dependent exception

2016-10-31 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Oct 31 20:31:23 2016
New Revision: 285663

URL: http://llvm.org/viewvc/llvm-project?rev=285663&view=rev
Log:
p0012: Teach resolving address of overloaded function with dependent exception
specification to resolve the exception specification as part of the type check,
in C++1z onwards. This is not actually part of P0012 / CWG1330 rules for when
an exception specification is "needed", but is necessary for sanity.

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=285663&r1=285662&r2=285663&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Oct 31 20:31:23 2016
@@ -1599,6 +1599,8 @@ static bool IsStandardConversion(Sema &S
   }
 
   // Check that we've computed the proper type after overload resolution.
+  // FIXME: FixOverloadedFunctionReference has side-effects; we shouldn't
+  // be calling it from within an NDEBUG block.
   assert(S.Context.hasSameType(
 FromType,
 S.FixOverloadedFunctionReference(From, AccessPair, Fn)->getType()));
@@ -10388,6 +10390,21 @@ QualType Sema::ExtractUnqualifiedFunctio
   return Ret;
 }
 
+static bool completeFunctionType(Sema &S, FunctionDecl *FD, SourceLocation Loc,
+ bool Complain = true) {
+  if (S.getLangOpts().CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
+  S.DeduceReturnType(FD, Loc, Complain))
+return true;
+
+  auto *FPT = FD->getType()->castAs();
+  if (S.getLangOpts().CPlusPlus1z &&
+  isUnresolvedExceptionSpec(FPT->getExceptionSpecType()) &&
+  !S.ResolveExceptionSpec(Loc, FPT))
+return true;
+
+  return false;
+}
+
 namespace {
 // A helper class to help with address of function resolution
 // - allows us to avoid passing around all those ugly parameters
@@ -10596,9 +10613,8 @@ private:
 
   // If any candidate has a placeholder return type, trigger its deduction
   // now.
-  if (S.getLangOpts().CPlusPlus14 &&
-  FunDecl->getReturnType()->isUndeducedType() &&
-  S.DeduceReturnType(FunDecl, SourceExpr->getLocStart(), Complain)) {
+  if (completeFunctionType(S, FunDecl, SourceExpr->getLocStart(),
+   Complain)) {
 HasComplained |= Complain;
 return false;
   }
@@ -10823,6 +10839,8 @@ Sema::ResolveAddressOfOverloadedFunction
   else if (NumMatches == 1) {
 Fn = Resolver.getMatchingFunctionDecl();
 assert(Fn);
+if (auto *FPT = Fn->getType()->getAs())
+  ResolveExceptionSpec(AddressOfExpr->getExprLoc(), FPT);
 FoundResult = *Resolver.getMatchingFunctionAccessPair();
 if (Complain) {
   if (Resolver.IsStaticMemberFunctionFromBoundPointer())
@@ -10982,9 +11000,8 @@ Sema::ResolveSingleFunctionTemplateSpeci
 if (FoundResult) *FoundResult = I.getPair();
   }
 
-  if (Matched && getLangOpts().CPlusPlus14 &&
-  Matched->getReturnType()->isUndeducedType() &&
-  DeduceReturnType(Matched, ovl->getExprLoc(), Complain))
+  if (Matched &&
+  completeFunctionType(*this, Matched, ovl->getExprLoc(), Complain))
 return nullptr;
 
   return Matched;

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=285663&r1=285662&r2=285663&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Mon Oct 31 20:31:23 2016
@@ -3687,6 +3687,15 @@ Sema::DeduceTemplateArguments(FunctionTe
   DeduceReturnType(Specialization, Info.getLocation(), false))
 return TDK_MiscellaneousDeductionFailure;
 
+  // If the function has a dependent exception specification, resolve it now,
+  // so we can check that the exception specification matches.
+  auto *SpecializationFPT =
+  Specialization->getType()->castAs();
+  if (getLangOpts().CPlusPlus1z &&
+  isUnresolvedExceptionSpec(SpecializationFPT->getExceptionSpecType()) &&
+  !ResolveExceptionSpec(Info.getLocation(), SpecializationFPT))
+return TDK_MiscellaneousDeductionFailure;
+
   // If the requested function type does not match the actual type of the
   // specialization with respect to arguments of compatible pointer to function
   // types, template argument deduction fails.

Modified: cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp?rev=285663&r1=285662&r2=285663&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-n

[PATCH] D26166: [Sema] Don't issue analysis-based warnings when a fatal error has occurred

2016-10-31 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 76513.
ahatanak added a comment.

I think the non-uncompilable error you mentioned is the one on line 7 of the 
test case and the uncompilable error is the one on line 15. Is that correct? 
The modified test case has only one error (on line 7, which is promoted from a 
warning) and it compiles without any errors if the #pragmas are removed.

It seems to me that the root of the problem is that the template instantiation 
S2 is left in an incomplete state and VarDecl s2 in the AST, which is of 
type S2, is marked invalid. As I mentioned in my previous comment, I tried 
to fix this by calling hasUncompilableErrorOccurred instead of 
hasFatalErrorOccurred in InstantiatingTemplate::InstantiatingTemplate, but that 
didn't seem correct as a large number of regression tests failed. What is the 
right way to fix this?

`-FunctionDecl 0x7f889602fa90  line:19:6 foo1 '_Bool 
(const long long *, int *)'

| -ParmVarDecl 0x7f889602f918  col:28 used a 'const long long 
*' |
| -ParmVarDecl 0x7f889602f9c0  col:36 used b 'int *'
 |

  `-CompoundStmt 0x7f889602fde0 
`-DeclStmt 0x7f889602fd78 
  `-VarDecl 0x7f889602fd18  col:11 invalid s2 
'S2':'struct S2'


https://reviews.llvm.org/D26166

Files:
  lib/Sema/AnalysisBasedWarnings.cpp
  test/SemaCXX/instantiate-template-fatal-error.cpp


Index: test/SemaCXX/instantiate-template-fatal-error.cpp
===
--- /dev/null
+++ test/SemaCXX/instantiate-template-fatal-error.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+
+#pragma clang diagnostic fatal "-Wall"
+#pragma clang diagnostic fatal "-Wold-style-cast"
+
+template  bool foo0(const long long *a, T* b) {
+  return a == (const long long*)b; // expected-error {{use of old-style cast}}
+}
+
+template
+struct S1 {
+};
+
+template
+struct S2 : S1 {
+  bool m1(const long long *a, T *b) const { return foo0(a, b); }
+};
+
+bool foo1(const long long *a, int *b) {
+  S2 s2;
+  return s2.m1(a, b);
+}
Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -1914,7 +1914,7 @@
   if (cast(D)->isDependentContext())
 return;
 
-  if (Diags.hasUncompilableErrorOccurred()) {
+  if (Diags.hasUncompilableErrorOccurred() || Diags.hasFatalErrorOccurred()) {
 // Flush out any possibly unreachable diagnostics.
 flushDiagnostics(S, fscope);
 return;


Index: test/SemaCXX/instantiate-template-fatal-error.cpp
===
--- /dev/null
+++ test/SemaCXX/instantiate-template-fatal-error.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+
+#pragma clang diagnostic fatal "-Wall"
+#pragma clang diagnostic fatal "-Wold-style-cast"
+
+template  bool foo0(const long long *a, T* b) {
+  return a == (const long long*)b; // expected-error {{use of old-style cast}}
+}
+
+template
+struct S1 {
+};
+
+template
+struct S2 : S1 {
+  bool m1(const long long *a, T *b) const { return foo0(a, b); }
+};
+
+bool foo1(const long long *a, int *b) {
+  S2 s2;
+  return s2.m1(a, b);
+}
Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -1914,7 +1914,7 @@
   if (cast(D)->isDependentContext())
 return;
 
-  if (Diags.hasUncompilableErrorOccurred()) {
+  if (Diags.hasUncompilableErrorOccurred() || Diags.hasFatalErrorOccurred()) {
 // Flush out any possibly unreachable diagnostics.
 flushDiagnostics(S, fscope);
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285660 - Bitcode: Simplify BitstreamWriter::EnterBlockInfoBlock() interface.

2016-10-31 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon Oct 31 20:18:57 2016
New Revision: 285660

URL: http://llvm.org/viewvc/llvm-project?rev=285660&view=rev
Log:
Bitcode: Simplify BitstreamWriter::EnterBlockInfoBlock() interface.

No block info block should need to define local abbreviations, so we can
always use a code width of 2.

Also change all block info block writers to use EnterBlockInfoBlock.

Differential Revision: https://reviews.llvm.org/D26168

Modified:
cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp

Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=285660&r1=285659&r2=285660&view=diff
==
--- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Mon Oct 31 20:18:57 
2016
@@ -436,7 +436,7 @@ static void AddRangeLocationAbbrev(llvm:
 }
 
 void SDiagsWriter::EmitBlockInfoBlock() {
-  State->Stream.EnterBlockInfoBlock(3);
+  State->Stream.EnterBlockInfoBlock();
 
   using namespace llvm;
   llvm::BitstreamWriter &Stream = State->Stream;

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=285660&r1=285659&r2=285660&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Oct 31 20:18:57 2016
@@ -991,7 +991,7 @@ static void AddStmtsExprs(llvm::Bitstrea
 
 void ASTWriter::WriteBlockInfoBlock() {
   RecordData Record;
-  Stream.EnterSubblock(llvm::bitc::BLOCKINFO_BLOCK_ID, 3);
+  Stream.EnterBlockInfoBlock();
 
 #define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
 #define RECORD(X) EmitRecordID(X, #X, Stream, Record)

Modified: cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp?rev=285660&r1=285659&r2=285660&view=diff
==
--- cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp (original)
+++ cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp Mon Oct 31 20:18:57 2016
@@ -460,7 +460,7 @@ static void emitRecordID(unsigned ID, co
 void
 GlobalModuleIndexBuilder::emitBlockInfoBlock(llvm::BitstreamWriter &Stream) {
   SmallVector Record;
-  Stream.EnterSubblock(llvm::bitc::BLOCKINFO_BLOCK_ID, 3);
+  Stream.EnterBlockInfoBlock();
 
 #define BLOCK(X) emitBlockID(X ## _ID, #X, Stream, Record)
 #define RECORD(X) emitRecordID(X, #X, Stream, Record)


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


Re: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.

2016-10-31 Thread Samuel F Antao via cfe-commits
Hi Galina,
 
Thanks for letting me know. Can you tell me which compiler (kind and version) is used in the buildbot slave? Looks like that compiler is not doing what it should, so I need to be able to test a workaround.
 
We have  
 
virtual void ConstructJob(Compilation &C, const JobAction &JA,                            const InputInfo &Output,                            const InputInfoList &Inputs,                            const llvm::opt::ArgList &TCArgs,                            const char *LinkingOutput) const = 0;
 
which is the signature of ConstructJob that should be overwritten, so we are not hiding anything. And in Action.cpp we have an unreachable statement, so no need for return. So, the code seems to be okay, but we can probably massage the code a little to silence the compiler you are using.
 
Thanks!
Samuel
 
- Original message -From: Galina Kistanova To: Samuel F Antao/Watson/IBM@IBMUSCc: cfe-commits Subject: Re: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.Date: Tue, Nov 1, 2016 12:59 AM 
Hi Samuel,Looks like this revision introduced warning to one of our builders:http://lab.llvm.org:8011/builders/clang-3stage-ubuntu/builds/67/steps/build-stage3-clang/logs/warnings%20%28830%29Please have a look at this?ThanksGalina
 
On Thu, Oct 27, 2016 at 11:14 AM, Samuel Antao via cfe-commits  wrote:

Author: sfantaoDate: Thu Oct 27 13:14:55 2016New Revision: 285326URL: http://llvm.org/viewvc/llvm-project?rev=285326&view=revLog:[Driver][OpenMP] Add support to create jobs for unbundling actions.Summary:This patch adds the support to create jobs for the `OffloadBundlingAction` which will invoke the `clang-offload-bundler` tool to unbundle input files.Unlike other actions, unbundling actions have multiple outputs. Therefore, this patch adds the required changes to have a variant of `Tool::ConstructJob` with multiple outputs.The way the naming of the results is implemented is also slightly modified so that the same action can use a different offloading prefix for each use by the different offloading actions.With this patch, it is possible to compile a functional OpenMP binary with offloading support, even with separate compilation.Reviewers: echristo, tra, jlebar, ABataev, hfinkelSubscribers: mkuron, whchung, mehdi_amini, cfe-commits, Hahnfeld, andreybokhanko, arpith-jacob, carlo.bertolli, caomhinDifferential Revision: https://reviews.llvm.org/D21857Modified:    cfe/trunk/include/clang/Driver/Action.h    cfe/trunk/include/clang/Driver/Driver.h    cfe/trunk/include/clang/Driver/Tool.h    cfe/trunk/lib/Driver/Action.cpp    cfe/trunk/lib/Driver/Driver.cpp    cfe/trunk/lib/Driver/Tool.cpp    cfe/trunk/lib/Driver/Tools.cpp    cfe/trunk/lib/Driver/Tools.h    cfe/trunk/test/Driver/cuda-bindings.cu    cfe/trunk/test/Driver/openmp-offload.c    cfe/trunk/test/Driver/opt-record.cModified: cfe/trunk/include/clang/Driver/Action.hURL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=285326&r1=285325&r2=285326&view=diff==--- cfe/trunk/include/clang/Driver/Action.h (original)+++ cfe/trunk/include/clang/Driver/Action.h Thu Oct 27 13:14:55 2016@@ -157,9 +157,12 @@ public:   /// Return a string containing the offload kind of the action.   std::string getOffloadingKindPrefix() const;   /// Return a string that can be used as prefix in order to generate unique-  /// files for each offloading kind.-  std::string-  getOffloadingFileNamePrefix(llvm::StringRef NormalizedTriple) const;+  /// files for each offloading kind. By default, no prefix is used for+  /// non-device kinds, except if \a CreatePrefixForHost is set.+  static std::string+  GetOffloadingFileNamePrefix(OffloadKind Kind,+                              llvm::StringRef NormalizedTriple,+                              bool CreatePrefixForHost = false);   /// Return a string containing a offload kind name.   static StringRef GetOffloadKindName(OffloadKind Kind);Modified: cfe/trunk/include/clang/Driver/Driver.hURL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=285326&r1=285325&r2=285326&view=diff==--- cfe/trunk/include/clang/Driver/Driver.h (original)+++ cfe/trunk/include/clang/Driver/Driver.h Thu Oct 27 13:14:55 2016@@ -12,6 +12,7 @@ #include "clang/Basic/Diagnostic.h" #include "clang/Basic/LLVM.h"+#include "clang/Driver/Action.h" #include "clang/Driver/Phases.h" #include "clang/Driver/Types.h" #include "clang/Driver/Util.h"@@ -42,7 +43,6 @@ class FileSystem; namespace driver {-  class Action;   class Command;   class Compilation;   class InputInfo;@@ -417,14 +417,14 @@ public:   /// BuildJobsForAction - Construct the jobs to perform for the action \p A and   /// return an InputInfo for the result of running \p A.  Will only construct-  /// jobs for a given (Action, ToolChain, BoundArch) 

[PATCH] D26136: Protect exceptional path under libcpp-no-exceptions

2016-10-31 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

This all looks ok to me - all mechanical changes.
I wonder if there's a better way to refactor these - there's all that 
duplicated code.

Does this look any better to you?
Replace:

  try
  {
  s.replace(pos1, n1, str, pos2);
  LIBCPP_ASSERT(s.__invariants());
  assert(pos1 <= old_size && pos2 <= str.size());
  assert(s == expected);
  typename S::size_type xlen = std::min(n1, old_size - pos1);
  typename S::size_type rlen = std::min(S::npos, str.size() - pos2);
  assert(s.size() == old_size - xlen + rlen);
  }
  catch (std::out_of_range&)
  {
  assert(pos1 > old_size || pos2 > str.size());
  assert(s == s0);
  }

with:

  if(pos1 <= old_size && pos2 <= str.size())
  {
  s.replace(pos1, n1, str, pos2);
  LIBCPP_ASSERT(s.__invariants());
  assert(s == expected);
  typename S::size_type xlen = std::min(n1, old_size - pos1);
  typename S::size_type rlen = std::min(S::npos, str.size() - pos2);
  assert(s.size() == old_size - xlen + rlen);
  }
  #ifndef TEST_HAS_NO_EXCEPTIONS
  else
  {
  try { s.replace(pos1, n1, str, pos2); }
  catch (std::out_of_range&)
  {
  assert(pos1 > old_size || pos2 > str.size());
  assert(s == s0);
  }
  }
  #endif




Comment at: test/std/strings/basic.string/string.access/at.pass.cpp:42
+if (pos < cs.size())
+{
+assert(s.at(pos) == s[pos]);

I think you should just test `s.size()` here, not both `s` and `cs`.  (the 
original code got it wrong, too)
The assert at L45 can be removed.



https://reviews.llvm.org/D26136



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


Re: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.

2016-10-31 Thread Galina Kistanova via cfe-commits
Hi Samuel,

Looks like this revision introduced warning to one of our builders:
http://lab.llvm.org:8011/builders/clang-3stage-ubuntu/builds/67/steps/build-stage3-clang/logs/warnings%20%28830%29

Please have a look at this?

Thanks

Galina

On Thu, Oct 27, 2016 at 11:14 AM, Samuel Antao via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sfantao
> Date: Thu Oct 27 13:14:55 2016
> New Revision: 285326
>
> URL: http://llvm.org/viewvc/llvm-project?rev=285326&view=rev
> Log:
> [Driver][OpenMP] Add support to create jobs for unbundling actions.
>
> Summary:
> This patch adds the support to create jobs for the `OffloadBundlingAction`
> which will invoke the `clang-offload-bundler` tool to unbundle input files.
>
> Unlike other actions, unbundling actions have multiple outputs. Therefore,
> this patch adds the required changes to have a variant of
> `Tool::ConstructJob` with multiple outputs.
>
> The way the naming of the results is implemented is also slightly modified
> so that the same action can use a different offloading prefix for each use
> by the different offloading actions.
>
> With this patch, it is possible to compile a functional OpenMP binary with
> offloading support, even with separate compilation.
>
> Reviewers: echristo, tra, jlebar, ABataev, hfinkel
>
> Subscribers: mkuron, whchung, mehdi_amini, cfe-commits, Hahnfeld,
> andreybokhanko, arpith-jacob, carlo.bertolli, caomhin
>
> Differential Revision: https://reviews.llvm.org/D21857
>
> Modified:
> cfe/trunk/include/clang/Driver/Action.h
> cfe/trunk/include/clang/Driver/Driver.h
> cfe/trunk/include/clang/Driver/Tool.h
> cfe/trunk/lib/Driver/Action.cpp
> cfe/trunk/lib/Driver/Driver.cpp
> cfe/trunk/lib/Driver/Tool.cpp
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Driver/Tools.h
> cfe/trunk/test/Driver/cuda-bindings.cu
> cfe/trunk/test/Driver/openmp-offload.c
> cfe/trunk/test/Driver/opt-record.c
>
> Modified: cfe/trunk/include/clang/Driver/Action.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Driver/Action.h?rev=285326&r1=285325&r2=285326&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Driver/Action.h (original)
> +++ cfe/trunk/include/clang/Driver/Action.h Thu Oct 27 13:14:55 2016
> @@ -157,9 +157,12 @@ public:
>/// Return a string containing the offload kind of the action.
>std::string getOffloadingKindPrefix() const;
>/// Return a string that can be used as prefix in order to generate
> unique
> -  /// files for each offloading kind.
> -  std::string
> -  getOffloadingFileNamePrefix(llvm::StringRef NormalizedTriple) const;
> +  /// files for each offloading kind. By default, no prefix is used for
> +  /// non-device kinds, except if \a CreatePrefixForHost is set.
> +  static std::string
> +  GetOffloadingFileNamePrefix(OffloadKind Kind,
> +  llvm::StringRef NormalizedTriple,
> +  bool CreatePrefixForHost = false);
>/// Return a string containing a offload kind name.
>static StringRef GetOffloadKindName(OffloadKind Kind);
>
>
> Modified: cfe/trunk/include/clang/Driver/Driver.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Driver/Driver.h?rev=285326&r1=285325&r2=285326&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Driver/Driver.h (original)
> +++ cfe/trunk/include/clang/Driver/Driver.h Thu Oct 27 13:14:55 2016
> @@ -12,6 +12,7 @@
>
>  #include "clang/Basic/Diagnostic.h"
>  #include "clang/Basic/LLVM.h"
> +#include "clang/Driver/Action.h"
>  #include "clang/Driver/Phases.h"
>  #include "clang/Driver/Types.h"
>  #include "clang/Driver/Util.h"
> @@ -42,7 +43,6 @@ class FileSystem;
>
>  namespace driver {
>
> -  class Action;
>class Command;
>class Compilation;
>class InputInfo;
> @@ -417,14 +417,14 @@ public:
>
>/// BuildJobsForAction - Construct the jobs to perform for the action
> \p A and
>/// return an InputInfo for the result of running \p A.  Will only
> construct
> -  /// jobs for a given (Action, ToolChain, BoundArch) tuple once.
> +  /// jobs for a given (Action, ToolChain, BoundArch, DeviceKind) tuple
> once.
>InputInfo
>BuildJobsForAction(Compilation &C, const Action *A, const ToolChain *TC,
>   StringRef BoundArch, bool AtTopLevel, bool
> MultipleArchs,
>   const char *LinkingOutput,
>   std::map,
> InputInfo>
>   &CachedResults,
> - bool BuildForOffloadDevice) const;
> + Action::OffloadKind TargetDeviceOffloadKind) const;
>
>/// Returns the default name for linked images (e.g., "a.out").
>const char *getDefaultImageName() const;
> @@ -495,7 +495,7 @@ private:
>bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
>std::map, 

[PATCH] D26166: [Sema] Don't issue analysis-based warnings when a fatal error has occurred

2016-10-31 Thread Richard Smith via cfe-commits
rsmith added a comment.

It looks like the bug is that if we hit an uncompilable error after hitting a 
non-uncompilable fatal error (promoted from a warning), we fail to notice that 
we've hit an uncompileable error. Our AST should be complete if 
`hasUncompilableErrorOccurred()` is not set, and it looks like we're violating 
that invariant here.


https://reviews.llvm.org/D26166



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


[PATCH] D26176: [Clang-tidy] Fix copy-paste error in misc-redundant-expression detected by PVS-Studio

2016-10-31 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko created this revision.
Eugene.Zelenko added reviewers: alexfh, aaron.ballman, hokein, etienneb.
Eugene.Zelenko added subscribers: cfe-commits, Prazek.
Eugene.Zelenko set the repository for this revision to rL LLVM.

Unfortunately, misc-redundant-expression didn't detect problem in own code.

I also fixed some  Include What You Use and modernize-use-bool-literals 
warnings.

See http://www.viva64.com/en/b/0446/ for full article about problems found in 
LLVM code by PVS-Studio.


Repository:
  rL LLVM

https://reviews.llvm.org/D26176

Files:
  
llvm-svn.src/tools/clang/tools/extra/clang-tidy/misc/RedundantExpressionCheck.cpp


Index: 
llvm-svn.src/tools/clang/tools/extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- 
llvm-svn.src/tools/clang/tools/extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ 
llvm-svn.src/tools/clang/tools/extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -12,7 +12,20 @@
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/FoldingSet.h"
+#include "llvm/Support/Casting.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 using namespace clang::ast_matchers;
 using namespace clang::tidy::matchers;
@@ -171,7 +184,7 @@
   }
 
   // Handle cases where the constants are different.
-  if ((OpcodeLHS == BO_EQ || OpcodeLHS == BO_LE || OpcodeLHS == BO_LE) &&
+  if ((OpcodeLHS == BO_EQ || OpcodeLHS == BO_LT || OpcodeLHS == BO_LE) &&
   (OpcodeRHS == BO_EQ || OpcodeRHS == BO_GT || OpcodeRHS == BO_GE))
 return true;
 
@@ -401,7 +414,7 @@
 // Operand received with implicit comparator (cast).
 Opcode = BO_NE;
 OperandExpr = Cast;
-Value = APSInt(32, 0);
+Value = APSInt(32, false);
   } else {
 return false;
   }


Index: llvm-svn.src/tools/clang/tools/extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- llvm-svn.src/tools/clang/tools/extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ llvm-svn.src/tools/clang/tools/extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -12,7 +12,20 @@
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/FoldingSet.h"
+#include "llvm/Support/Casting.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 using namespace clang::ast_matchers;
 using namespace clang::tidy::matchers;
@@ -171,7 +184,7 @@
   }
 
   // Handle cases where the constants are different.
-  if ((OpcodeLHS == BO_EQ || OpcodeLHS == BO_LE || OpcodeLHS == BO_LE) &&
+  if ((OpcodeLHS == BO_EQ || OpcodeLHS == BO_LT || OpcodeLHS == BO_LE) &&
   (OpcodeRHS == BO_EQ || OpcodeRHS == BO_GT || OpcodeRHS == BO_GE))
 return true;
 
@@ -401,7 +414,7 @@
 // Operand received with implicit comparator (cast).
 Opcode = BO_NE;
 OperandExpr = Cast;
-Value = APSInt(32, 0);
+Value = APSInt(32, false);
   } else {
 return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-31 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285657: [ReachableCode] Skip over ExprWithCleanups in 
isConfigurationValue (authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D24010?vs=75644&id=76508#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24010

Files:
  cfe/trunk/include/clang/AST/Stmt.h
  cfe/trunk/lib/Analysis/ReachableCode.cpp
  cfe/trunk/test/SemaCXX/PR29152.cpp


Index: cfe/trunk/include/clang/AST/Stmt.h
===
--- cfe/trunk/include/clang/AST/Stmt.h
+++ cfe/trunk/include/clang/AST/Stmt.h
@@ -387,6 +387,9 @@
   /// Skip past any implicit AST nodes which might surround this
   /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
   Stmt *IgnoreImplicit();
+  const Stmt *IgnoreImplicit() const {
+return const_cast(this)->IgnoreImplicit();
+  }
 
   /// \brief Skip no-op (attributed, compound) container stmts and skip 
captured
   /// stmt at the top, if \a IgnoreCaptured is true.
Index: cfe/trunk/test/SemaCXX/PR29152.cpp
===
--- cfe/trunk/test/SemaCXX/PR29152.cpp
+++ cfe/trunk/test/SemaCXX/PR29152.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
+
+static const bool False = false;
+
+struct A {
+  ~A();
+  operator bool();
+};
+void Bar();
+
+void Foo() {
+  if (False && A()) {
+Bar(); // expected-no-diagnostics
+  }
+}
Index: cfe/trunk/lib/Analysis/ReachableCode.cpp
===
--- cfe/trunk/lib/Analysis/ReachableCode.cpp
+++ cfe/trunk/lib/Analysis/ReachableCode.cpp
@@ -164,6 +164,8 @@
   if (!S)
 return false;
 
+  S = S->IgnoreImplicit();
+
   if (const Expr *Ex = dyn_cast(S))
 S = Ex->IgnoreCasts();
 


Index: cfe/trunk/include/clang/AST/Stmt.h
===
--- cfe/trunk/include/clang/AST/Stmt.h
+++ cfe/trunk/include/clang/AST/Stmt.h
@@ -387,6 +387,9 @@
   /// Skip past any implicit AST nodes which might surround this
   /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
   Stmt *IgnoreImplicit();
+  const Stmt *IgnoreImplicit() const {
+return const_cast(this)->IgnoreImplicit();
+  }
 
   /// \brief Skip no-op (attributed, compound) container stmts and skip captured
   /// stmt at the top, if \a IgnoreCaptured is true.
Index: cfe/trunk/test/SemaCXX/PR29152.cpp
===
--- cfe/trunk/test/SemaCXX/PR29152.cpp
+++ cfe/trunk/test/SemaCXX/PR29152.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
+
+static const bool False = false;
+
+struct A {
+  ~A();
+  operator bool();
+};
+void Bar();
+
+void Foo() {
+  if (False && A()) {
+Bar(); // expected-no-diagnostics
+  }
+}
Index: cfe/trunk/lib/Analysis/ReachableCode.cpp
===
--- cfe/trunk/lib/Analysis/ReachableCode.cpp
+++ cfe/trunk/lib/Analysis/ReachableCode.cpp
@@ -164,6 +164,8 @@
   if (!S)
 return false;
 
+  S = S->IgnoreImplicit();
+
   if (const Expr *Ex = dyn_cast(S))
 S = Ex->IgnoreCasts();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285657 - [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-31 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Oct 31 19:19:04 2016
New Revision: 285657

URL: http://llvm.org/viewvc/llvm-project?rev=285657&view=rev
Log:
[ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

Summary: Fixes pr29152.

Reviewers: rsmith, pirama, krememek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D24010

Added:
cfe/trunk/test/SemaCXX/PR29152.cpp
Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/Analysis/ReachableCode.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=285657&r1=285656&r2=285657&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Mon Oct 31 19:19:04 2016
@@ -387,6 +387,9 @@ public:
   /// Skip past any implicit AST nodes which might surround this
   /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
   Stmt *IgnoreImplicit();
+  const Stmt *IgnoreImplicit() const {
+return const_cast(this)->IgnoreImplicit();
+  }
 
   /// \brief Skip no-op (attributed, compound) container stmts and skip 
captured
   /// stmt at the top, if \a IgnoreCaptured is true.

Modified: cfe/trunk/lib/Analysis/ReachableCode.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ReachableCode.cpp?rev=285657&r1=285656&r2=285657&view=diff
==
--- cfe/trunk/lib/Analysis/ReachableCode.cpp (original)
+++ cfe/trunk/lib/Analysis/ReachableCode.cpp Mon Oct 31 19:19:04 2016
@@ -164,6 +164,8 @@ static bool isConfigurationValue(const S
   if (!S)
 return false;
 
+  S = S->IgnoreImplicit();
+
   if (const Expr *Ex = dyn_cast(S))
 S = Ex->IgnoreCasts();
 

Added: cfe/trunk/test/SemaCXX/PR29152.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/PR29152.cpp?rev=285657&view=auto
==
--- cfe/trunk/test/SemaCXX/PR29152.cpp (added)
+++ cfe/trunk/test/SemaCXX/PR29152.cpp Mon Oct 31 19:19:04 2016
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
+
+static const bool False = false;
+
+struct A {
+  ~A();
+  operator bool();
+};
+void Bar();
+
+void Foo() {
+  if (False && A()) {
+Bar(); // expected-no-diagnostics
+  }
+}


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


[PATCH] D26175: [Driver] Fall back to plain '-plugin LLVMgold.so' if no lib at std path

2016-10-31 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: rafael, beanz, chandlerc.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: mehdi_amini, srhines, danalbert, tberghammer.

Add a fallback to using plain '-plugin LLVMgold.so' when the plugin does
not exist at the standard path. This e.g. happens on Gentoo when clang
is compiled for a different ABI than binutils.

Since full path is used to reference LLVMgold.so, it is safe to use
the same path to check whether the plugin exists. If it does not, this
lets gold perform library search instead of passing known-wrong path.
As a result, the plugin is either found somewhere in search path, or
gold fails the same.

This is an alternate solution to the problem originally addressed by
https://reviews.llvm.org/D23754. Unlike the original proposal, it does not 
introduce additional
options that could confuse users and does not affect anything in common
installations.


https://reviews.llvm.org/D26175

Files:
  lib/Driver/Tools.cpp
  test/Driver/gold-lto.c
  test/Driver/lto.c
  test/Driver/thinlto.c

Index: test/Driver/thinlto.c
===
--- test/Driver/thinlto.c
+++ test/Driver/thinlto.c
@@ -19,19 +19,19 @@
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto -flto=thin 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-ACTION < %t %s
 //
-// CHECK-LINK-THIN-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-THIN-ACTION: "-plugin" "{{.*}}LLVMgold.so"
 // CHECK-LINK-THIN-ACTION: "-plugin-opt=thinlto"
 
 // Check that subsequent -flto=full takes precedence
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto=full 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s
 //
-// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}LLVMgold.so"
 // CHECK-LINK-FULL-ACTION-NOT: "-plugin-opt=thinlto"
 
 // Check that subsequent -fno-lto takes precedence
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -fno-lto 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s
 //
-// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}LLVMgold.so"
 // CHECK-LINK-NOLTO-ACTION-NOT: "-plugin-opt=thinlto"
Index: test/Driver/lto.c
===
--- test/Driver/lto.c
+++ test/Driver/lto.c
@@ -36,19 +36,19 @@
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-LTO-ACTION < %t %s
 //
-// CHECK-LINK-LTO-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-LTO-ACTION: "-plugin" "{{.*}}LLVMgold.so"
 
 // -flto=full should cause link using gold plugin
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s
 //
-// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}LLVMgold.so"
 
 // Check that subsequent -fno-lto takes precedence
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s
 //
-// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}LLVMgold.so"
 
 // -flto passes along an explicit debugger tuning argument.
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto -glldb 2> %t
Index: test/Driver/gold-lto.c
===
--- test/Driver/gold-lto.c
+++ test/Driver/gold-lto.c
@@ -3,26 +3,26 @@
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -Wl,-plugin-opt=foo -O3 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-64-BASIC
-// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-BASIC: "-plugin" "{{.*}}LLVMgold.so"
 // CHECK-X86-64-BASIC: "-plugin-opt=O3"
 // CHECK-X86-64-BASIC: "-plugin-opt=foo"
 //
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -march=corei7 -Wl,-plugin-opt=foo -Ofast \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-64-COREI7
-// CHECK-X86-64-COREI7: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-COREI7: "-plugin" "{{.*}}LLVMgold.so"
 // CHECK-X86-64-COREI7: "-plugin-opt=mcpu=corei7"
 // CHECK-X86-64-COREI7: "-plugin-opt=O3"
 // CHECK-X86-64-COREI7: "-plugin-opt=foo"
 //
 // RUN: %clang -target arm-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 \
 // RUN: | FileCheck %s --check-prefix=CHECK-ARM-V7A
-// CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-ARM-V7A: "-plugin" "{{.*}}LLVMgold.so"
 // CHECK-ARM-V7A: "-plugin-opt=mcpu=cortex-a8"
 // CHECK-ARM-V7A: "-plugin-opt=O0"
 // CHECK-ARM-V7A: "-plugin-opt=foo"
 //
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDRO

Re: r285647 - [index] Fix repeated visitation of the same InitListExpr for indexing.

2016-10-31 Thread Richard Smith via cfe-commits
On Mon, Oct 31, 2016 at 3:12 PM, Argyrios Kyrtzidis via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: akirtzidis
> Date: Mon Oct 31 17:12:12 2016
> New Revision: 285647
>
> URL: http://llvm.org/viewvc/llvm-project?rev=285647&view=rev
> Log:
> [index] Fix repeated visitation of the same InitListExpr for indexing.
>
> It was visited multiple times unnecessarily.
>
> rdar://28985038
>
> Added:
> cfe/trunk/test/Index/Core/designated-inits.c
> Modified:
> cfe/trunk/lib/Index/IndexBody.cpp
>
> Modified: cfe/trunk/lib/Index/IndexBody.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/
> IndexBody.cpp?rev=285647&r1=285646&r2=285647&view=diff
> 
> ==
> --- cfe/trunk/lib/Index/IndexBody.cpp (original)
> +++ cfe/trunk/lib/Index/IndexBody.cpp Mon Oct 31 17:12:12 2016
> @@ -300,6 +300,7 @@ public:
>IndexingContext &IndexCtx;
>const NamedDecl *Parent;
>const DeclContext *ParentDC;
> +  bool Visited = false;
>
>  public:
>SyntacticFormIndexer(IndexingContext &indexCtx,
>

Do we need SyntacticFromIndexer to be a RecursiveASTVisitor at all? It
looks like you would get the desired effect by simply walking the elements
of the syntactic form looking for DesignatedInitExprs (which will always be
at the top level of the InitListExpr's element if they exist). Right now,
it looks like you still traverse expression E twice in cases like this:

  int arr[] = { [0] = 0, E };

... and you'd still get a quadratic traversal for a case like { [0] = {}, {
[0] = {}, { [0] = {}, ... } } }.


> @@ -308,6 +309,22 @@ public:
>
>bool shouldWalkTypesOfTypeLocs() const { return false; }
>
> +  bool TraverseInitListExpr(InitListExpr *S, DataRecursionQueue *Q =
> nullptr) {
> +// Don't visit nested InitListExprs, this visitor will be called
> again
> +// later on for the nested ones.
> +if (Visited)
> +  return true;
> +Visited = true;
> +InitListExpr *SyntaxForm = S->isSemanticForm() ?
> S->getSyntacticForm() : S;
> +if (SyntaxForm) {
> +  for (Stmt *SubStmt : SyntaxForm->children()) {
> +if (!TraverseStmt(SubStmt, Q))
> +  return false;
> +  }
> +}
> +return true;
> +  }
> +
>bool VisitDesignatedInitExpr(DesignatedInitExpr *E) {
>  for (DesignatedInitExpr::Designator &D :
> llvm::reverse(E->designators())) {
>if (D.isFieldDesignator())
>
> Added: cfe/trunk/test/Index/Core/designated-inits.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/
> Core/designated-inits.c?rev=285647&view=auto
> 
> ==
> --- cfe/trunk/test/Index/Core/designated-inits.c (added)
> +++ cfe/trunk/test/Index/Core/designated-inits.c Mon Oct 31 17:12:12 2016
> @@ -0,0 +1,33 @@
> +// RUN: c-index-test core -print-source-symbols -- %s -target
> x86_64-apple-macosx10.7 | FileCheck %s
> +
> +struct MyStruct {
> +  int myfield;
> +};
> +
> +enum {
> +  MyValToSet;
> +};
> +
> +// CHECK: [[@LINE+1]]:14 | struct/C | MyStruct |
> +const struct MyStruct _MyStruct[]
> +  [16]
> +  [3]
> +  [3]
> +  [2]
> +  [2] = {
> + [0] = {
> +[0] = {
> +  [0] = {
> +[0][0] = {
> +  [0] = {
> +// CHECK: [[@LINE+2]]:14 | field/C | myfield | {{.*}} | Ref |
> +// CHECK: [[@LINE+1]]:24 | enumerator/C | MyValToSet |
> +.myfield = MyValToSet,
> +// CHECK-NOT: | field/C | myfield |
> +// CHECK-NOT: | enumerator/C | MyValToSet |
> +  },
> +},
> +  },
> +},
> +  },
> +};
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26143: [modules] Mark deleted functions as implicitly inline to allow merging

2016-10-31 Thread Eric Fiselier via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285655: [modules] Mark deleted functions as implicitly 
inline to allow  merging (authored by EricWF).

Changed prior to commit:
  https://reviews.llvm.org/D26143?vs=76501&id=76502#toc

https://reviews.llvm.org/D26143

Files:
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h


Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -13875,6 +13875,9 @@
   if (Fn->isMain())
 Diag(DelLoc, diag::err_deleted_main);
 
+  // C++11 [dcl.fct.def.delete]p4:
+  //  A deleted function is implicitly inline.
+  Fn->setImplicitlyInline();
   Fn->setDeletedAsWritten();
 }
 
Index: cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h
===
--- cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h
+++ cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h
@@ -24,5 +24,6 @@
 struct Aggregate {
   int member;
 };
+bool operator==(Aggregate, Aggregate) = delete;
 
 #endif


Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -13875,6 +13875,9 @@
   if (Fn->isMain())
 Diag(DelLoc, diag::err_deleted_main);
 
+  // C++11 [dcl.fct.def.delete]p4:
+  //  A deleted function is implicitly inline.
+  Fn->setImplicitlyInline();
   Fn->setDeletedAsWritten();
 }
 
Index: cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h
===
--- cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h
+++ cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h
@@ -24,5 +24,6 @@
 struct Aggregate {
   int member;
 };
+bool operator==(Aggregate, Aggregate) = delete;
 
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285655 - [modules] Mark deleted functions as implicitly inline to allow merging

2016-10-31 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Oct 31 18:07:15 2016
New Revision: 285655

URL: http://llvm.org/viewvc/llvm-project?rev=285655&view=rev
Log:
[modules] Mark deleted functions as implicitly inline to allow  merging

Summary: When merging definitions with ModulesLocalVisibility enabled it's 
important to make deleted definitions implicitly inline, otherwise they'll be 
diagnosed as a redefinition.

Reviewers: silvas, manmanren, rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D26143

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=285655&r1=285654&r2=285655&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Oct 31 18:07:15 2016
@@ -13875,6 +13875,9 @@ void Sema::SetDeclDeleted(Decl *Dcl, Sou
   if (Fn->isMain())
 Diag(DelLoc, diag::err_deleted_main);
 
+  // C++11 [dcl.fct.def.delete]p4:
+  //  A deleted function is implicitly inline.
+  Fn->setImplicitlyInline();
   Fn->setDeletedAsWritten();
 }
 

Modified: cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h?rev=285655&r1=285654&r2=285655&view=diff
==
--- cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h (original)
+++ cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h Mon Oct 31 18:07:15 
2016
@@ -24,5 +24,6 @@ inline A ff(int i) {
 struct Aggregate {
   int member;
 };
+bool operator==(Aggregate, Aggregate) = delete;
 
 #endif


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


[PATCH] D26143: [modules] Mark deleted functions as implicitly inline to allow merging

2016-10-31 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 76501.

https://reviews.llvm.org/D26143

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/Modules/Inputs/merge-decl-context/a.h


Index: test/Modules/Inputs/merge-decl-context/a.h
===
--- test/Modules/Inputs/merge-decl-context/a.h
+++ test/Modules/Inputs/merge-decl-context/a.h
@@ -24,5 +24,6 @@
 struct Aggregate {
   int member;
 };
+bool operator==(Aggregate, Aggregate) = delete;
 
 #endif
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -13870,6 +13870,9 @@
   if (Fn->isMain())
 Diag(DelLoc, diag::err_deleted_main);
 
+  // C++11 [dcl.fct.def.delete]p4:
+  //  A deleted function is implicitly inline.
+  Fn->setImplicitlyInline();
   Fn->setDeletedAsWritten();
 }
 


Index: test/Modules/Inputs/merge-decl-context/a.h
===
--- test/Modules/Inputs/merge-decl-context/a.h
+++ test/Modules/Inputs/merge-decl-context/a.h
@@ -24,5 +24,6 @@
 struct Aggregate {
   int member;
 };
+bool operator==(Aggregate, Aggregate) = delete;
 
 #endif
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -13870,6 +13870,9 @@
   if (Fn->isMain())
 Diag(DelLoc, diag::err_deleted_main);
 
+  // C++11 [dcl.fct.def.delete]p4:
+  //  A deleted function is implicitly inline.
+  Fn->setImplicitlyInline();
   Fn->setDeletedAsWritten();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25925: [clang-tidy] Update cert-err58-cpp to match its new generalised form.

2016-10-31 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285653: [clang-tidy] Update cert-err58-cpp to match its new 
generalised form. (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D25925?vs=76318&id=76494#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25925

Files:
  clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp
  clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err58-cpp.rst
  clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp

Index: clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp
@@ -22,27 +22,37 @@
   if (!getLangOpts().CPlusPlus)
 return;
 
-  // Match any static or thread_local variable declaration that is initialized
-  // with a constructor that can throw.
+  // Match any static or thread_local variable declaration that has an
+  // initializer that can throw.
   Finder->addMatcher(
   varDecl(anyOf(hasThreadStorageDuration(), hasStaticStorageDuration()),
   unless(hasAncestor(functionDecl())),
-  hasInitializer(ignoringImplicit(cxxConstructExpr(hasDeclaration(
-  cxxConstructorDecl(unless(isNoThrow())).bind("ctor"))
+  anyOf(hasDescendant(cxxConstructExpr(hasDeclaration(
+cxxConstructorDecl(unless(isNoThrow())).bind("func",
+hasDescendant(cxxNewExpr(hasDeclaration(
+functionDecl(unless(isNoThrow())).bind("func",
+hasDescendant(callExpr(hasDeclaration(
+functionDecl(unless(isNoThrow())).bind("func"))
   .bind("var"),
   this);
 }
 
 void StaticObjectExceptionCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *VD = Result.Nodes.getNodeAs("var");
-  const auto *Ctor = Result.Nodes.getNodeAs("ctor");
+  const auto *Func = Result.Nodes.getNodeAs("func");
 
   diag(VD->getLocation(),
-   "construction of %0 with %select{static|thread_local}1 storage "
+   "initialization of %0 with %select{static|thread_local}1 storage "
"duration may throw an exception that cannot be caught")
   << VD << (VD->getStorageDuration() == SD_Static ? 0 : 1);
-  diag(Ctor->getLocation(), "possibly throwing constructor declared here",
-   DiagnosticIDs::Note);
+
+  SourceLocation FuncLocation = Func->getLocation();
+  if(FuncLocation.isValid()) {
+diag(FuncLocation,
+ "possibly throwing %select{constructor|function}0 declared here",
+ DiagnosticIDs::Note)
+<< (isa(Func) ? 0 : 1);
+  }
 }
 
 } // namespace cert
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err58-cpp.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err58-cpp.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err58-cpp.rst
@@ -4,8 +4,8 @@
 ==
 
 This check flags all ``static`` or ``thread_local`` variable declarations where
-the constructor for the object may throw an exception.
+the initializer for the object may throw an exception.
 
 This check corresponds to the CERT C++ Coding Standard rule
-`ERR58-CPP. Constructors of objects with static or thread storage duration must not throw exceptions
-`_.
+`ERR58-CPP. Handle all exceptions thrown before main() begins executing
+`_.
Index: clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp
@@ -16,39 +16,94 @@
   explicit V(const char *) {} // Can throw
 };
 
-struct Cleanup
-{
+struct Cleanup {
   ~Cleanup() {}
 };
 
 struct W {
   W(Cleanup c = {}) noexcept(false);
 };
 
+struct X {
+  X(S = {}) noexcept;
+};
+
+struct Y {
+  S s;
+};
+
+struct Z {
+  T t;
+};
+
+int f();
+int g() noexcept(false);
+int h() noexcept(true);
+
+struct UserConv_Bad {
+  operator int() noexcept(false);
+};
+
+struct UserConv_Good {
+  operator int() noexcept;
+};
+
+UserConv_Bad some_bad_func() noexcept;
+UserConv_Good some_good_func() noexcept;
 
 S s;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 's' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initializa

[clang-tools-extra] r285653 - [clang-tidy] Update cert-err58-cpp to match its new generalised form.

2016-10-31 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Mon Oct 31 17:47:04 2016
New Revision: 285653

URL: http://llvm.org/viewvc/llvm-project?rev=285653&view=rev
Log:
[clang-tidy] Update cert-err58-cpp to match its new generalised form.

Summary:
Aaron modified cert-err58-cpp to include all exceptions thrown before main()
Update the check to match.

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D25925

Modified:
clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err58-cpp.rst
clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp

Modified: clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp?rev=285653&r1=285652&r2=285653&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp Mon 
Oct 31 17:47:04 2016
@@ -22,27 +22,37 @@ void StaticObjectExceptionCheck::registe
   if (!getLangOpts().CPlusPlus)
 return;
 
-  // Match any static or thread_local variable declaration that is initialized
-  // with a constructor that can throw.
+  // Match any static or thread_local variable declaration that has an
+  // initializer that can throw.
   Finder->addMatcher(
   varDecl(anyOf(hasThreadStorageDuration(), hasStaticStorageDuration()),
   unless(hasAncestor(functionDecl())),
-  hasInitializer(ignoringImplicit(cxxConstructExpr(hasDeclaration(
-  cxxConstructorDecl(unless(isNoThrow())).bind("ctor"))
+  anyOf(hasDescendant(cxxConstructExpr(hasDeclaration(
+
cxxConstructorDecl(unless(isNoThrow())).bind("func",
+hasDescendant(cxxNewExpr(hasDeclaration(
+functionDecl(unless(isNoThrow())).bind("func",
+hasDescendant(callExpr(hasDeclaration(
+functionDecl(unless(isNoThrow())).bind("func"))
   .bind("var"),
   this);
 }
 
 void StaticObjectExceptionCheck::check(const MatchFinder::MatchResult &Result) 
{
   const auto *VD = Result.Nodes.getNodeAs("var");
-  const auto *Ctor = Result.Nodes.getNodeAs("ctor");
+  const auto *Func = Result.Nodes.getNodeAs("func");
 
   diag(VD->getLocation(),
-   "construction of %0 with %select{static|thread_local}1 storage "
+   "initialization of %0 with %select{static|thread_local}1 storage "
"duration may throw an exception that cannot be caught")
   << VD << (VD->getStorageDuration() == SD_Static ? 0 : 1);
-  diag(Ctor->getLocation(), "possibly throwing constructor declared here",
-   DiagnosticIDs::Note);
+
+  SourceLocation FuncLocation = Func->getLocation();
+  if(FuncLocation.isValid()) {
+diag(FuncLocation,
+ "possibly throwing %select{constructor|function}0 declared here",
+ DiagnosticIDs::Note)
+<< (isa(Func) ? 0 : 1);
+  }
 }
 
 } // namespace cert

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err58-cpp.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err58-cpp.rst?rev=285653&r1=285652&r2=285653&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err58-cpp.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err58-cpp.rst Mon Oct 
31 17:47:04 2016
@@ -4,8 +4,8 @@ cert-err58-cpp
 ==
 
 This check flags all ``static`` or ``thread_local`` variable declarations where
-the constructor for the object may throw an exception.
+the initializer for the object may throw an exception.
 
 This check corresponds to the CERT C++ Coding Standard rule
-`ERR58-CPP. Constructors of objects with static or thread storage duration 
must not throw exceptions
-`_.
+`ERR58-CPP. Handle all exceptions thrown before main() begins executing
+`_.

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp?rev=285653&r1=285652&r2=285653&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp 
Mon Oct 31 

[PATCH] D26138: [clang-tidy] Add modernize-use-equals-delete check

2016-10-31 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 76493.
malcolm.parsons added a comment.

Fix comment.
Rename variable.
Use global.


https://reviews.llvm.org/D26138

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseEqualsDeleteCheck.cpp
  clang-tidy/modernize/UseEqualsDeleteCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-equals-delete.rst
  test/clang-tidy/modernize-use-equals-delete.cpp

Index: test/clang-tidy/modernize-use-equals-delete.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-equals-delete.cpp
@@ -0,0 +1,122 @@
+// RUN: %check_clang_tidy %s modernize-use-equals-delete %t
+
+struct PositivePrivate {
+private:
+  PositivePrivate();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prevent a default special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivate() = delete;
+  PositivePrivate(const PositivePrivate &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prevent a default special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivate(const PositivePrivate &) = delete;
+  PositivePrivate &operator=(const PositivePrivate &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use '= delete' to prevent a default special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivate &operator=(const PositivePrivate &) = delete;
+  PositivePrivate(PositivePrivate &&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prevent a default special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivate(PositivePrivate &&) = delete;
+  PositivePrivate &operator=(PositivePrivate &&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use '= delete' to prevent a default special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivate &operator=(PositivePrivate &&) = delete;
+  ~PositivePrivate();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prevent a default special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: ~PositivePrivate() = delete;
+};
+
+struct NegativePublic {
+  NegativePublic(const NegativePublic &);
+};
+
+struct NegativeProtected {
+protected:
+  NegativeProtected(const NegativeProtected &);
+};
+
+struct PositiveInlineMember {
+  int foo() { return 0; }
+
+private:
+  PositiveInlineMember(const PositiveInlineMember &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prevent a default special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositiveInlineMember(const PositiveInlineMember &) = delete;
+};
+
+struct PositiveOutOfLineMember {
+  int foo();
+
+private:
+  PositiveOutOfLineMember(const PositiveOutOfLineMember &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prevent a default special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositiveOutOfLineMember(const PositiveOutOfLineMember &) = delete;
+};
+
+int PositiveOutOfLineMember::foo() { return 0; }
+
+struct PositiveAbstractMember {
+  virtual int foo() = 0;
+
+private:
+  PositiveAbstractMember(const PositiveAbstractMember &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prevent a default special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositiveAbstractMember(const PositiveAbstractMember &) = delete;
+};
+
+struct NegativeMemberNotImpl {
+  int foo();
+
+private:
+  NegativeMemberNotImpl(const NegativeMemberNotImpl &);
+};
+
+struct NegativeStaticMemberNotImpl {
+  static int foo();
+
+private:
+  NegativeStaticMemberNotImpl(const NegativeStaticMemberNotImpl &);
+};
+
+struct NegativeInline {
+private:
+  NegativeInline(const NegativeInline &) {}
+};
+
+struct NegativeOutOfLine {
+private:
+  NegativeOutOfLine(const NegativeOutOfLine &);
+};
+
+NegativeOutOfLine::NegativeOutOfLine(const NegativeOutOfLine &) {}
+
+struct NegativeConstructNotImpl {
+  NegativeConstructNotImpl();
+
+private:
+  NegativeConstructNotImpl(const NegativeConstructNotImpl &);
+};
+
+struct PositiveDefaultedConstruct {
+  PositiveDefaultedConstruct() = default;
+
+private:
+  PositiveDefaultedConstruct(const PositiveDefaultedConstruct &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prevent a default special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositiveDefaultedConstruct(const PositiveDefaultedConstruct &) = delete;
+};
+
+struct PositiveDeletedConstruct {
+  PositiveDeletedConstruct() = delete;
+
+private:
+  PositiveDeletedConstruct(const PositiveDeletedConstruct &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prevent a default special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositiveDeletedConstruct(const PositiveDeletedConstruct &) = delete;
+};
+
+struct N

[PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-31 Thread Stephen Hines via cfe-commits
srhines added a comment.

Ping. Other developers (Firefox) are now starting to hit this issue.


https://reviews.llvm.org/D24010



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


[PATCH] D26164: [cfi] Fix missing !type annotation.

2016-10-31 Thread Evgeniy Stepanov via cfe-commits
eugenis closed this revision.
eugenis added a comment.

thanks!
r285650


Repository:
  rL LLVM

https://reviews.llvm.org/D26164



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


[PATCH] D25624: Added 'inline' attribute to basic_string's destructor

2016-10-31 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D25624#583883, @sebpop wrote:

> In https://reviews.llvm.org/D25624#583163, @mehdi_amini wrote:
>
> > I'd like to understand why only the destructor?
>
>
> We have committed a patch to inline the constructor of std::string.
>  Do you think we should inline some other functions?


I'd say all of them (unless there's a reason to not do) :)
So: default to the inline keyword, with possibility of opt-out on a case by 
case.

The only impact of the inline attribute, as I understand, is to make sure some 
IR is emitted. There won't be any codegen, and the compile-time impact should 
be reasonnable.


https://reviews.llvm.org/D25624



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


[PATCH] D25624: Added 'inline' attribute to basic_string's destructor

2016-10-31 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D25624#584095, @hiraditya wrote:

> In https://reviews.llvm.org/D25624#583167, @mehdi_amini wrote:
>
> > I talked with Eric on IRC, he mentioned some benchmarks were ran. I'd like 
> > to understand what was the baseline?
> >  Here we add *both* the inline keyword and the always_inline attribute. I'd 
> > like to know if there is a benchmarks that shows that always_inline is 
> > beneficial on top of the inline keyword. 
> >  If we need to add always_inline anywhere: this is likely an inliner 
> > heuristic failure and we should at minima track it as an example to improve 
> > it.
>
>
> I remmber that the constructor of std::string wouldn't inline without 
> always_inline attribute https://reviews.llvm.org/D22782


I don't see where is it mentioned in the revision you are linking, can you 
elaborate what I should look at?


https://reviews.llvm.org/D25624



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


[PATCH] D26138: [clang-tidy] Add modernize-use-equals-delete check

2016-10-31 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/UseEqualsDeleteCheck.cpp:29
+cxxMethodDecl(
+anyOf(isCopyAssignmentOperator(), isMoveAssignmentOperator())),
+cxxDestructorDecl()));

aaron.ballman wrote:
> How about a conversion operator, like `operator bool()`? You'll sometimes see 
> that one declared privately for similar reasons.
I haven't seen that. Do you have an example?



Comment at: clang-tidy/modernize/UseEqualsDeleteCheck.cpp:52
+  diag(SpecialFunction->getLocation(),
+   "use '= delete' to prevent a default special member function")
+  << FixItHint::CreateInsertion(EndLoc, " = delete");

aaron.ballman wrote:
> This diagnostic isn't very clear to me -- what does it mean to "prevent" a 
> default special member function?
> 
> The fixit for this is also somewhat unsatisfying as this takes a private, 
> not-defined function and turns it into a private, deleted function. That's a 
> very small win, because it only impacts code which could access the special 
> member function in the first place (some compilers give a diagnostic about 
> the special member function being inaccessible even if it's explicitly marked 
> as deleted; clang is not one such compiler). Do we have a way to rewrite the 
> access specifier for the special member function as well (kind of like how we 
> have a way to handle includes we're adding)? I am guessing not yet, but if we 
> do, that would be fantastic to use here.
> 
> Note, I don't think this should hold up your patch or the fixit. A small win 
> is still a win. :-)
Do you have a better wording for the diagnostic?

I don't see any utility functions to make a method public.


https://reviews.llvm.org/D26138



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


[PATCH] D25624: Added 'inline' attribute to basic_string's destructor

2016-10-31 Thread Aditya Kumar via cfe-commits
hiraditya added a comment.

In https://reviews.llvm.org/D25624#583167, @mehdi_amini wrote:

> I talked with Eric on IRC, he mentioned some benchmarks were ran. I'd like to 
> understand what was the baseline?
>  Here we add *both* the inline keyword and the always_inline attribute. I'd 
> like to know if there is a benchmarks that shows that always_inline is 
> beneficial on top of the inline keyword. 
>  If we need to add always_inline anywhere: this is likely an inliner 
> heuristic failure and we should at minima track it as an example to improve 
> it.


I remmber that the constructor of std::string wouldn't inline without 
always_inline attribute https://reviews.llvm.org/D22782


https://reviews.llvm.org/D25624



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


r285650 - [cfi] Fix missing !type annotation.

2016-10-31 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Mon Oct 31 17:28:10 2016
New Revision: 285650

URL: http://llvm.org/viewvc/llvm-project?rev=285650&view=rev
Log:
[cfi] Fix missing !type annotation.

CFI (only in the cross-dso mode) fails to set !type annotations when
a function is used before it is defined.

Added:
cfe/trunk/test/CodeGen/cfi-icall-cross-dso2.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=285650&r1=285649&r2=285650&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Oct 31 17:28:10 2016
@@ -929,6 +929,11 @@ void CodeGenModule::SetLLVMFunctionAttri
 if (F->getAlignment() < 2 && isa(D))
   F->setAlignment(2);
   }
+
+  // In the cross-dso CFI mode, we want !type attributes on definitions only.
+  if (CodeGenOpts.SanitizeCfiCrossDso)
+if (auto *FD = dyn_cast(D))
+  CreateFunctionTypeMetadata(FD, F);
 }
 
 void CodeGenModule::SetCommonAttributes(const Decl *D,
@@ -1011,10 +1016,6 @@ void CodeGenModule::CreateFunctionTypeMe
 
   // Additionally, if building with cross-DSO support...
   if (CodeGenOpts.SanitizeCfiCrossDso) {
-// Don't emit entries for function declarations. In cross-DSO mode these 
are
-// handled with better precision at run time.
-if (!FD->hasBody())
-  return;
 // Skip available_externally functions. They won't be codegen'ed in the
 // current module anyway.
 if (getContext().GetGVALinkageForFunction(FD) == GVA_AvailableExternally)
@@ -1087,7 +1088,10 @@ void CodeGenModule::SetFunctionAttribute
 if (MD->isVirtual())
   F->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 
-  CreateFunctionTypeMetadata(FD, F);
+  // Don't emit entries for function declarations in the cross-DSO mode. This
+  // is handled with better precision by the receiving DSO.
+  if (!CodeGenOpts.SanitizeCfiCrossDso)
+CreateFunctionTypeMetadata(FD, F);
 }
 
 void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV) {

Added: cfe/trunk/test/CodeGen/cfi-icall-cross-dso2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfi-icall-cross-dso2.c?rev=285650&view=auto
==
--- cfe/trunk/test/CodeGen/cfi-icall-cross-dso2.c (added)
+++ cfe/trunk/test/CodeGen/cfi-icall-cross-dso2.c Mon Oct 31 17:28:10 2016
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 -fblocks \
+// RUN:   -fsanitize=cfi-icall -fsanitize-cfi-cross-dso \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @f() {{.*}} !type !{{.*}} !type !{{.*}}
+void f(void);
+void (*pf)(void) = f;
+void f(void) { }
+
+// Check that we do not crash on non-FunctionDecl definitions.
+void (^g)(void) = ^{};


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


r285647 - [index] Fix repeated visitation of the same InitListExpr for indexing.

2016-10-31 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Mon Oct 31 17:12:12 2016
New Revision: 285647

URL: http://llvm.org/viewvc/llvm-project?rev=285647&view=rev
Log:
[index] Fix repeated visitation of the same InitListExpr for indexing.

It was visited multiple times unnecessarily.

rdar://28985038

Added:
cfe/trunk/test/Index/Core/designated-inits.c
Modified:
cfe/trunk/lib/Index/IndexBody.cpp

Modified: cfe/trunk/lib/Index/IndexBody.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=285647&r1=285646&r2=285647&view=diff
==
--- cfe/trunk/lib/Index/IndexBody.cpp (original)
+++ cfe/trunk/lib/Index/IndexBody.cpp Mon Oct 31 17:12:12 2016
@@ -300,6 +300,7 @@ public:
   IndexingContext &IndexCtx;
   const NamedDecl *Parent;
   const DeclContext *ParentDC;
+  bool Visited = false;
 
 public:
   SyntacticFormIndexer(IndexingContext &indexCtx,
@@ -308,6 +309,22 @@ public:
 
   bool shouldWalkTypesOfTypeLocs() const { return false; }
 
+  bool TraverseInitListExpr(InitListExpr *S, DataRecursionQueue *Q = 
nullptr) {
+// Don't visit nested InitListExprs, this visitor will be called again
+// later on for the nested ones.
+if (Visited)
+  return true;
+Visited = true;
+InitListExpr *SyntaxForm = S->isSemanticForm() ? S->getSyntacticForm() 
: S;
+if (SyntaxForm) {
+  for (Stmt *SubStmt : SyntaxForm->children()) {
+if (!TraverseStmt(SubStmt, Q))
+  return false;
+  }
+}
+return true;
+  }
+
   bool VisitDesignatedInitExpr(DesignatedInitExpr *E) {
 for (DesignatedInitExpr::Designator &D : 
llvm::reverse(E->designators())) {
   if (D.isFieldDesignator())

Added: cfe/trunk/test/Index/Core/designated-inits.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/designated-inits.c?rev=285647&view=auto
==
--- cfe/trunk/test/Index/Core/designated-inits.c (added)
+++ cfe/trunk/test/Index/Core/designated-inits.c Mon Oct 31 17:12:12 2016
@@ -0,0 +1,33 @@
+// RUN: c-index-test core -print-source-symbols -- %s -target 
x86_64-apple-macosx10.7 | FileCheck %s
+
+struct MyStruct {
+  int myfield;
+};
+
+enum {
+  MyValToSet;
+};
+
+// CHECK: [[@LINE+1]]:14 | struct/C | MyStruct |
+const struct MyStruct _MyStruct[]
+  [16]
+  [3]
+  [3]
+  [2]
+  [2] = {
+ [0] = {
+[0] = {
+  [0] = {
+[0][0] = {
+  [0] = {
+// CHECK: [[@LINE+2]]:14 | field/C | myfield | {{.*}} | Ref |
+// CHECK: [[@LINE+1]]:24 | enumerator/C | MyValToSet |
+.myfield = MyValToSet,
+// CHECK-NOT: | field/C | myfield |
+// CHECK-NOT: | enumerator/C | MyValToSet |
+  },
+},
+  },
+},
+  },
+};


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


[clang-tools-extra] r285645 - [Release notes] Highlight reset() as language/library artifact.

2016-10-31 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Mon Oct 31 17:05:45 2016
New Revision: 285645

URL: http://llvm.org/viewvc/llvm-project?rev=285645&view=rev
Log:
[Release notes] Highlight reset() as language/library artifact.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=285645&r1=285644&r2=285645&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Mon Oct 31 17:05:45 2016
@@ -85,7 +85,7 @@ Improvements to clang-tidy
   `_
   and `modernize-make-shared
   `_
-  now handle calls to the smart pointer's reset method.
+  now handle calls to the smart pointer's ``reset()`` method.
 
 - The `modernize-use-auto
   `_ 
check


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


[PATCH] D26032: [ASTMatcher] Add CXXNewExpr support to hasDeclaration

2016-10-31 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285644: [ASTMatcher] Add CXXNewExpr support to 
hasDeclaration (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D26032?vs=76316&id=76490#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26032

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
  cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -3767,11 +3767,13 @@
 - for CallExpr, the declaration of the callee
 - for MemberExpr, the declaration of the referenced member
 - for CXXConstructExpr, the declaration of the constructor
+- for CXXNewExpr, the declaration of the operator new
 
 Also usable as Matcher for any T supporting the getDecl() member
 function. e.g. various subtypes of clang::Type and various expressions.
 
 Usable as: MatcherCallExpr>, MatcherCXXConstructExpr>,
+  MatcherCXXNewExpr>,
   MatcherDeclRefExpr>, MatcherEnumType>, MatcherInjectedClassNameType>,
   MatcherLabelStmt>, MatcherAddrLabelExpr>, MatcherMemberExpr>,
   MatcherQualType>, MatcherRecordType>, MatcherTagType>,
@@ -3997,11 +3999,13 @@
 - for CallExpr, the declaration of the callee
 - for MemberExpr, the declaration of the referenced member
 - for CXXConstructExpr, the declaration of the constructor
+- for CXXNewExpr, the declaration of the operator new
 
 Also usable as Matcher for any T supporting the getDecl() member
 function. e.g. various subtypes of clang::Type and various expressions.
 
 Usable as: MatcherCallExpr>, MatcherCXXConstructExpr>,
+  MatcherCXXNewExpr>,
   MatcherDeclRefExpr>, MatcherEnumType>, MatcherInjectedClassNameType>,
   MatcherLabelStmt>, MatcherAddrLabelExpr>, MatcherMemberExpr>,
   MatcherQualType>, MatcherRecordType>, MatcherTagType>,
@@ -4170,6 +4174,30 @@
 
 
 
+MatcherCXXNewExpr>hasDeclarationMatcherDecl>  InnerMatcher
+Matches a node if the declaration associated with that node
+matches the given matcher.
+
+The associated declaration is:
+- for type nodes, the declaration of the underlying type
+- for CallExpr, the declaration of the callee
+- for MemberExpr, the declaration of the referenced member
+- for CXXConstructExpr, the declaration of the constructor
+- for CXXNewExpr, the declaration of the operator new
+
+Also usable as Matcher for any T supporting the getDecl() member
+function. e.g. various subtypes of clang::Type and various expressions.
+
+Usable as: MatcherCallExpr>, MatcherCXXConstructExpr>,
+  MatcherCXXNewExpr>,
+  MatcherDeclRefExpr>, MatcherEnumType>, MatcherInjectedClassNameType>,
+  Matcher

r285644 - [ASTMatcher] Add CXXNewExpr support to hasDeclaration

2016-10-31 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Mon Oct 31 17:04:07 2016
New Revision: 285644

URL: http://llvm.org/viewvc/llvm-project?rev=285644&view=rev
Log:
[ASTMatcher] Add CXXNewExpr support to hasDeclaration

Reviewers: sbenza, lukasza, aaron.ballman, klimek

Subscribers: lukasza, sbenza, cfe-commits

Differential Revision: https://reviews.llvm.org/D26032

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=285644&r1=285643&r2=285644&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Oct 31 17:04:07 2016
@@ -3767,11 +3767,13 @@ The associated declaration is:
 - for CallExpr, the declaration of the callee
 - for MemberExpr, the declaration of the referenced member
 - for CXXConstructExpr, the declaration of the constructor
+- for CXXNewExpr, the declaration of the operator new
 
 Also usable as Matcher for any T supporting the getDecl() member
 function. e.g. various subtypes of clang::Type and various expressions.
 
 Usable as: MatcherCallExpr>,
 MatcherCXXConstructExpr>,
+  MatcherCXXNewExpr>,
   MatcherDeclRefExpr>,
 MatcherEnumType>,
 MatcherInjectedClassNameType>,
   MatcherLabelStmt>,
 MatcherAddrLabelExpr>,
 MatcherMemberExpr>,
   MatcherQualType>,
 MatcherRecordType>,
 MatcherTagType>,
@@ -3997,11 +3999,13 @@ The associated declaration is:
 - for CallExpr, the declaration of the callee
 - for MemberExpr, the declaration of the referenced member
 - for CXXConstructExpr, the declaration of the constructor
+- for CXXNewExpr, the declaration of the operator new
 
 Also usable as Matcher for any T supporting the getDecl() member
 function. e.g. various subtypes of clang::Type and various expressions.
 
 Usable as: MatcherCallExpr>,
 MatcherCXXConstructExpr>,
+  MatcherCXXNewExpr>,
   MatcherDeclRefExpr>,
 MatcherEnumType>,
 MatcherInjectedClassNameType>,
   MatcherLabelStmt>,
 MatcherAddrLabelExpr>,
 MatcherMemberExpr>,
   MatcherQualType>,
 MatcherRecordType>,
 MatcherTagType>,
@@ -4170,6 +4174,30 @@ Example matches A() in the last line
 
 
 
+MatcherCXXNewExpr>hasDeclarationMatcherDecl>  
InnerMatcher
+Matches a node if 
the declaration associated with that node
+matches the given matcher.
+
+The associated declaration is:
+- for type nodes, the declaration of the underlying type
+- for CallExpr, the declaration of the callee
+- for MemberExpr, the declaration of the referenced member
+- for CXXConstructExpr, the declaration of the constructor
+- for CXXNewExpr, the declaration of the operator new
+
+Also usable as Matcher for any T supporting the getDecl() member
+function. e.g. various subtypes of clang::Type and various expressions.
+
+Usable as: MatcherCallExpr>,
 MatcherCXXConstructExpr>,
+  MatcherCXXNewExpr>,
+  Ma

[PATCH] D26164: [cfi] Fix missing !type annotation.

2016-10-31 Thread Peter Collingbourne via cfe-commits
pcc accepted this revision.
pcc added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D26164



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


[PATCH] D26164: [cfi] Fix missing !type annotation.

2016-10-31 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 76489.

Repository:
  rL LLVM

https://reviews.llvm.org/D26164

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGen/cfi-icall-cross-dso2.c


Index: test/CodeGen/cfi-icall-cross-dso2.c
===
--- /dev/null
+++ test/CodeGen/cfi-icall-cross-dso2.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 -fblocks \
+// RUN:   -fsanitize=cfi-icall -fsanitize-cfi-cross-dso \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @f() {{.*}} !type !{{.*}} !type !{{.*}}
+void f(void);
+void (*pf)(void) = f;
+void f(void) { }
+
+// Check that we do not crash on non-FunctionDecl definitions.
+void (^g)(void) = ^{};
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -928,6 +928,11 @@
 if (F->getAlignment() < 2 && isa(D))
   F->setAlignment(2);
   }
+
+  // In the cross-dso CFI mode, we want !type attributes on definitions only.
+  if (CodeGenOpts.SanitizeCfiCrossDso)
+if (auto *FD = dyn_cast(D))
+  CreateFunctionTypeMetadata(FD, F);
 }
 
 void CodeGenModule::SetCommonAttributes(const Decl *D,
@@ -1010,10 +1015,6 @@
 
   // Additionally, if building with cross-DSO support...
   if (CodeGenOpts.SanitizeCfiCrossDso) {
-// Don't emit entries for function declarations. In cross-DSO mode these 
are
-// handled with better precision at run time.
-if (!FD->hasBody())
-  return;
 // Skip available_externally functions. They won't be codegen'ed in the
 // current module anyway.
 if (getContext().GetGVALinkageForFunction(FD) == GVA_AvailableExternally)
@@ -1086,7 +1087,10 @@
 if (MD->isVirtual())
   F->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 
-  CreateFunctionTypeMetadata(FD, F);
+  // Don't emit entries for function declarations in the cross-DSO mode. This
+  // is handled with better precision by the receiving DSO.
+  if (!CodeGenOpts.SanitizeCfiCrossDso)
+CreateFunctionTypeMetadata(FD, F);
 }
 
 void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV) {


Index: test/CodeGen/cfi-icall-cross-dso2.c
===
--- /dev/null
+++ test/CodeGen/cfi-icall-cross-dso2.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 -fblocks \
+// RUN:   -fsanitize=cfi-icall -fsanitize-cfi-cross-dso \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @f() {{.*}} !type !{{.*}} !type !{{.*}}
+void f(void);
+void (*pf)(void) = f;
+void f(void) { }
+
+// Check that we do not crash on non-FunctionDecl definitions.
+void (^g)(void) = ^{};
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -928,6 +928,11 @@
 if (F->getAlignment() < 2 && isa(D))
   F->setAlignment(2);
   }
+
+  // In the cross-dso CFI mode, we want !type attributes on definitions only.
+  if (CodeGenOpts.SanitizeCfiCrossDso)
+if (auto *FD = dyn_cast(D))
+  CreateFunctionTypeMetadata(FD, F);
 }
 
 void CodeGenModule::SetCommonAttributes(const Decl *D,
@@ -1010,10 +1015,6 @@
 
   // Additionally, if building with cross-DSO support...
   if (CodeGenOpts.SanitizeCfiCrossDso) {
-// Don't emit entries for function declarations. In cross-DSO mode these are
-// handled with better precision at run time.
-if (!FD->hasBody())
-  return;
 // Skip available_externally functions. They won't be codegen'ed in the
 // current module anyway.
 if (getContext().GetGVALinkageForFunction(FD) == GVA_AvailableExternally)
@@ -1086,7 +1087,10 @@
 if (MD->isVirtual())
   F->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 
-  CreateFunctionTypeMetadata(FD, F);
+  // Don't emit entries for function declarations in the cross-DSO mode. This
+  // is handled with better precision by the receiving DSO.
+  if (!CodeGenOpts.SanitizeCfiCrossDso)
+CreateFunctionTypeMetadata(FD, F);
 }
 
 void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285643 - A compound literal within a global lambda or block is still within

2016-10-31 Thread John McCall via cfe-commits
Author: rjmccall
Date: Mon Oct 31 16:56:26 2016
New Revision: 285643

URL: http://llvm.org/viewvc/llvm-project?rev=285643&view=rev
Log:
A compound literal within a global lambda or block is still within
the body of a function for the purposes of computing its storage
duration and deciding whether its initializer must be constant.

There are a number of problems in our current treatment of compound
literals.  C specifies that a compound literal yields an l-value
referring to an object with either static or automatic storage
duration, depending on where it was written; in the latter case,
the literal object has a lifetime tied to the enclosing scope (much
like an ObjC block), not the enclosing full-expression.  To get these
semantics fully correct in our current design, we would need to
collect compound literals on the ExprWithCleanups, just like we do
with ObjC blocks; we would probably also want to identify literals
like we do with materialized temporaries.  But it gets stranger;
GCC adds compound literals to C++ as an extension, but makes them
r-values, which are generally assumed to have temporary storage
duration.  Ignoring destructor ordering, the difference only matters
if the object's address escapes the full-expression, which for an
r-value can only happen with reference binding (which extends
temporaries) or array-to-pointer decay (which does not).  GCC then
attempts to lock down on array-to-pointer decay in ad hoc ways.
Arguably a far superior language solution for C++ (and perhaps even
array r-values in C, which can occur in other ways) would be to
propagate lifetime extension through array-to-pointer decay, so
that initializing a pointer object to a decayed r-value array
extends the lifetime of the complete object containing the array.
But this would be a major change in semantics which arguably ought
to be blessed by the committee(s).

Anyway, I'm not fixing any of that in this patch; I did try, but
it got out of hand.

Fixes rdar://28949016.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGenCXX/compound-literals.cpp
cfe/trunk/test/Sema/compound-literal.c
cfe/trunk/test/SemaCXX/compound-literal.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=285643&r1=285642&r2=285643&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Oct 31 16:56:26 2016
@@ -5572,7 +5572,7 @@ Sema::BuildCompoundLiteralExpr(SourceLoc
 return ExprError();
   LiteralExpr = Result.get();
 
-  bool isFileScope = getCurFunctionOrMethodDecl() == nullptr;
+  bool isFileScope = !CurContext->isFunctionOrMethod();
   if (isFileScope &&
   !LiteralExpr->isTypeDependent() &&
   !LiteralExpr->isValueDependent() &&

Modified: cfe/trunk/test/CodeGenCXX/compound-literals.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/compound-literals.cpp?rev=285643&r1=285642&r2=285643&view=diff
==
--- cfe/trunk/test/CodeGenCXX/compound-literals.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/compound-literals.cpp Mon Oct 31 16:56:26 2016
@@ -55,3 +55,11 @@ union PR21912Ty {
 union PR21912Ty *PR21912_2 = (union PR21912Ty[]){{.d = 2.0}, {.l = 3}};
 // CHECK-LABEL: define {{.*}}__cxx_global_var_init.3()
 // CHECK: store %union.PR21912Ty* getelementptr inbounds ([2 x 
%union.PR21912Ty], [2 x %union.PR21912Ty]* bitcast (<{ { double }, 
%union.PR21912Ty }>* @.compoundliteral.4 to [2 x %union.PR21912Ty]*), i32 0, 
i32 0), %union.PR21912Ty** @PR21912_2
+
+// This compound literal should have local scope.
+int computed_with_lambda = [] {
+  int *array = (int[]) { 1, 3, 5, 7 };
+  return array[0];
+}();
+// CHECK-LABEL: define internal i32 @{{.*}}clEv
+// CHECK: alloca [4 x i32]

Modified: cfe/trunk/test/Sema/compound-literal.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/compound-literal.c?rev=285643&r1=285642&r2=285643&view=diff
==
--- cfe/trunk/test/Sema/compound-literal.c (original)
+++ cfe/trunk/test/Sema/compound-literal.c Mon Oct 31 16:56:26 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -pedantic %s
 // REQUIRES: LP64
 
 struct foo { int a, b; };
@@ -36,3 +36,9 @@ void IncompleteFunc(unsigned x) {
 
 // PR6080
 int array[(sizeof(int[3]) == sizeof( (int[]) {0,1,2} )) ? 1 : -1];
+
+// rdar://28949016 - Constant restriction should not apply to compound 
literals in blocks
+int (^block)(int) = ^(int i) {
+  int *array = (int[]) {i, i + 2, i + 4};
+  return array[i];
+};

Modified: cfe/trunk/test/SemaCXX/compound-literal.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/compound-literal.cpp?rev=285643&r1=285642&r2=285643&view=diff
==

[PATCH] D26061: [analyzer] Refactor and simplify SimpleConstraintManager

2016-10-31 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Thanks for the patch!

Would it be possible to split this up into several patches? I think it is 
important to separate the interface layering changes from the formatting 
changes, renaming changes, and minor optimization changes. This will make the 
patches easier to review.

Also: is this motivated by a different implementation of range constraints? Is 
this something you plan on upstreaming?

In https://reviews.llvm.org/D26061#581778, @ddcc wrote:

> To summarize, here is a list of changes:
>
> - General
>   - Fixed some issues with formatting (`clang-format`)
>   - Fixed inconsistent capitalization following camel case style guidelines
> - `ConstraintManager.h`
>   - Renamed `assumeWithinInclusiveRange*()` to `assumeInclusiveRange*()`, 
> since the range is not necessarily contained within unless `Assumption` is 
> true, to match `assume()`
> - `RangedConstraintManager.h` (inherits `SimpleConstraintManager`)
>   - Moved `assumeSym*` and `canReasonAbout()` from `SimpleConstraintManager` 
> to here
>   - Renamed 
> `assumeSymbolWithinInclusiveRange`/`assumeSymbolOutOfInclusiveRange` to 
> `assumeSymWithinInclusiveRange`/`assumeSymOutsideInclusiveRange` to match the 
> above, and moved to here
>   - This is now inherited by `RangeConstraintManager`, and essentially 
> provides the current interface in `SimpleConstraintManager`


What do you view as the distinction between RangeConstraintMananger and 
RangedConstraintManager? In other words, if I'm a developer adding new 
functionality how would you suggest I decide which to add it to? It would be 
good to document this in the code! Also: the closeness in the names of these 
classes could be potentially confusing. Are there other, more distinctive, 
names that still communicate the difference you intend?

> 
> 
> - `SimpleConstraintManager.h` (inherits `ConstraintManager`)
>   - Implemented a new interface that internally converts the `DefinedSVal` in 
> `assume(...)` from `ConstraintManager.h` to `NonLoc` to `SymbolRef`. 
> Subclasses only need to override `ProgramStateRef assumeSym(ProgramStateRef 
> State, SymbolRef Sym, bool Assumption)`
>   - For inclusive ranges, implemented a new interface that internally 
> converts from `NonLoc` to `SymbolRef`. Subclasses only need to override 
> `ProgramStateRef assumeSymInclusiveRange(ProgramStateRef State, SymbolRef 
> Sym, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange)`
>   - Implemented a new interface that internally handles expressions that fail 
> `canReasonAbout()` by adding them directly to the constraint manager state. 
> Subclasses only need to expose `ProgramStateRef assumeSymRel(ProgramStateRef 
> State, SymbolRef Sym, BinaryOperator::Opcode op, const llvm::APSInt &Int)`
> - `RangeConstraintManager.cpp`
>   - Minor optimization to avoid updating the state if nothing is pruned in 
> `removeDeadBindings()`


https://reviews.llvm.org/D26061



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


[PATCH] D25225: Add an option to save the backend-produced YAML optimization record to a file

2016-10-31 Thread Taewook Oh via cfe-commits
twoh added a comment.

In https://reviews.llvm.org/D25225#584012, @hfinkel wrote:

> In https://reviews.llvm.org/D25225#584010, @twoh wrote:
>
> > Is there a particular reason why "opt_record_file" is defined in 
> > CC1Options.td, not Options.td? If -opt-record-file= is provided 
> > by the command line, line 829-831 in CompilerInvocation.cpp won't handle it 
> > because opt_record_file is not a CodeGenArg.
>
>
> It is not intended to be used directly. The user should use 
> -fsave-optimization-record (along with -foptimization-record-file= if they 
> don't like the default name selected). We definitely need to write end-user 
> docs for this; it is on my TODO list.


Got it. Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D25225



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


[PATCH] D26166: [Sema] Don't issue analysis-based warnings when a fatal error has occurred

2016-10-31 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rsmith, majnemer.
ahatanak added a subscriber: cfe-commits.

This patch makes AnalysisBasedWarnings::IssueWarnings return without issuing 
warnings based on CFG analysis when a fatal error has occurred. This is needed 
to avoid a crash that occurs when compiling the test case 
(instantiate-template-fatal-error.cpp).

My first patch made changes in InstantiatingTemplate::InstantiatingTemplate to 
call hasUncompilableErrorOccurred instead of hasFatalErrorOccurred at 
SemaTemplateInstantiate.cpp:214. That fixed the crash for the test case but 
introduced a large number of regression test failures, so I fixed 
AnalysisBasedWarnings::IssueWarnings instead.


https://reviews.llvm.org/D26166

Files:
  lib/Sema/AnalysisBasedWarnings.cpp
  test/SemaCXX/instantiate-template-fatal-error.cpp


Index: test/SemaCXX/instantiate-template-fatal-error.cpp
===
--- /dev/null
+++ test/SemaCXX/instantiate-template-fatal-error.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+
+#pragma clang diagnostic fatal "-Wall"
+#pragma clang diagnostic fatal "-Wold-style-cast"
+
+template  bool operator==(const long long *a, T* b) {
+  return a == (const long long*)b; // expected-error {{use of old-style cast}}
+}
+
+template
+struct S1 {
+};
+
+template
+struct S2 : S1 {
+  bool m1(const long long *a, T *b) const { return a == b; }
+};
+
+bool foo1(const long long *a, int *b) {
+  S2 s2;
+  return s2.m1(a, b);
+}
Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -1914,7 +1914,7 @@
   if (cast(D)->isDependentContext())
 return;
 
-  if (Diags.hasUncompilableErrorOccurred()) {
+  if (Diags.hasUncompilableErrorOccurred() || Diags.hasFatalErrorOccurred()) {
 // Flush out any possibly unreachable diagnostics.
 flushDiagnostics(S, fscope);
 return;


Index: test/SemaCXX/instantiate-template-fatal-error.cpp
===
--- /dev/null
+++ test/SemaCXX/instantiate-template-fatal-error.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+
+#pragma clang diagnostic fatal "-Wall"
+#pragma clang diagnostic fatal "-Wold-style-cast"
+
+template  bool operator==(const long long *a, T* b) {
+  return a == (const long long*)b; // expected-error {{use of old-style cast}}
+}
+
+template
+struct S1 {
+};
+
+template
+struct S2 : S1 {
+  bool m1(const long long *a, T *b) const { return a == b; }
+};
+
+bool foo1(const long long *a, int *b) {
+  S2 s2;
+  return s2.m1(a, b);
+}
Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -1914,7 +1914,7 @@
   if (cast(D)->isDependentContext())
 return;
 
-  if (Diags.hasUncompilableErrorOccurred()) {
+  if (Diags.hasUncompilableErrorOccurred() || Diags.hasFatalErrorOccurred()) {
 // Flush out any possibly unreachable diagnostics.
 flushDiagnostics(S, fscope);
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26164: [cfi] Fix missing !type annotation.

2016-10-31 Thread Peter Collingbourne via cfe-commits
pcc added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:934
+  if (CodeGenOpts.SanitizeCfiCrossDso)
+CreateFunctionTypeMetadata(dyn_cast(D), F);
 }

It looks like we can get here with declarations that are not of type 
`FunctionDecl` (mostly via `SetInternalFunctionAttributes` -- see 
http://llvm-cs.pcc.me.uk/tools/clang/lib/CodeGen/CodeGenModule.cpp/rSetInternalFunctionAttributes).
 I suppose that either means you would need to tolerate null pointers in 
`CreateFunctionTypeMetadata` or add an `isa` check here.

Please also add a test for one of those cases.


Repository:
  rL LLVM

https://reviews.llvm.org/D26164



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


[PATCH] D25225: Add an option to save the backend-produced YAML optimization record to a file

2016-10-31 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D25225#584010, @twoh wrote:

> Is there a particular reason why "opt_record_file" is defined in 
> CC1Options.td, not Options.td? If -opt-record-file= is provided by 
> the command line, line 829-831 in CompilerInvocation.cpp won't handle it 
> because opt_record_file is not a CodeGenArg.


It is not intended to be used directly. The user should use 
-fsave-optimization-record (along with -foptimization-record-file= if they 
don't like the default name selected). We definitely need to write end-user 
docs for this; it is on my TODO list.


Repository:
  rL LLVM

https://reviews.llvm.org/D25225



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


[PATCH] D25225: Add an option to save the backend-produced YAML optimization record to a file

2016-10-31 Thread Taewook Oh via cfe-commits
twoh added a comment.

Is there a particular reason why "opt_record_file" is defined in CC1Options.td, 
not Options.td? If -opt-record-file= is provided by the command line, 
line 829-831 in CompilerInvocation.cpp won't handle it because opt_record_file 
is not a CodeGenArg.


Repository:
  rL LLVM

https://reviews.llvm.org/D25225



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


Re: [libcxx] r285382 - Add __libcpp_version file and __libcpp_library_version function.

2016-10-31 Thread Richard Smith via cfe-commits
On Mon, Oct 31, 2016 at 2:01 PM, Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Mon, Oct 31, 2016 at 01:25:19PM -0700, Richard Smith wrote:
> > We could alternatively control the language features based only on the
> > selected language mode, and only use version detection to power a warning
> > for the (currently fairly common, but becoming less so) case where the
> > selected runtime library isn't new enough to implement the requested
> > features. That would cause a bunch of scenarios to break when upgrading
> to
> > clang 4.0, but at least the fix would be pretty clear.
>
> Let's split this slightly. Ultimately, we need to have codegen flags to
> control individual features that require support from the ABI
> implementation or even just from the STL implementation. I can think of
> three different ways to provide the default values:
> (1) Language mode selection
> (2) Driver logic based on the target
> (3) Source controls like #pragma

The third option would serve mostly the same purpose as feature
> detection based on some magic __version file, but it also would allow
> non-libc++ implementations or -nostdinc use cases to get the same
> behavior.


We need to make this decision in source files without #includes, and the
decision may affect entities we implicitly declare at the start of the
program, so I'm not entirely convinced that it's feasible to base the
default on the contents of the source code we actually process.

[With the previous strategy, for non-libc++, non-libstdc++ implementations,
you would be able to use the -f flags to explicitly specify what your
standard library supports (and it's probably reasonable to assume that it
fully supports the language specified by -std, by default); for -nostdinc,
you could use -stdlib=libc++-4.0 to explicitly specify the version.]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25727: [analyzer] Handle case of undefined values in performTrivialCopy

2016-10-31 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285640: [analyzer] Allow undefined values in 
performTrivialCopy. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D25727?vs=74994&id=76482#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25727

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  cfe/trunk/test/Analysis/uninit-vals.cpp


Index: cfe/trunk/test/Analysis/uninit-vals.cpp
===
--- cfe/trunk/test/Analysis/uninit-vals.cpp
+++ cfe/trunk/test/Analysis/uninit-vals.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin -verify 
-DCHECK_FOR_CRASH %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
+
+#ifdef CHECK_FOR_CRASH
+// expected-no-diagnostics
+#endif
+
+namespace PerformTrivialCopyForUndefs {
+struct A {
+  int x;
+};
+
+struct B {
+  A a;
+};
+
+struct C {
+  B b;
+};
+
+void foo() {
+  C c1;
+  C *c2;
+#ifdef CHECK_FOR_CRASH
+  // If the value of variable is not defined and checkers that check undefined
+  // values are not enabled, performTrivialCopy should be able to handle the
+  // case with undefined values, too.
+  c1.b.a = c2->b.a;
+#else
+  c1.b.a = c2->b.a; // expected-warning{{Function call argument is an 
uninitialized value}}
+#endif
+}
+}
+
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -65,7 +65,7 @@
   if (Optional L = V.getAs())
 V = Pred->getState()->getSVal(*L);
   else
-assert(V.isUnknown());
+assert(V.isUnknownOrUndef());
 
   const Expr *CallExpr = Call.getOriginExpr();
   evalBind(Dst, CallExpr, Pred, ThisVal, V, true);


Index: cfe/trunk/test/Analysis/uninit-vals.cpp
===
--- cfe/trunk/test/Analysis/uninit-vals.cpp
+++ cfe/trunk/test/Analysis/uninit-vals.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin -verify -DCHECK_FOR_CRASH %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
+
+#ifdef CHECK_FOR_CRASH
+// expected-no-diagnostics
+#endif
+
+namespace PerformTrivialCopyForUndefs {
+struct A {
+  int x;
+};
+
+struct B {
+  A a;
+};
+
+struct C {
+  B b;
+};
+
+void foo() {
+  C c1;
+  C *c2;
+#ifdef CHECK_FOR_CRASH
+  // If the value of variable is not defined and checkers that check undefined
+  // values are not enabled, performTrivialCopy should be able to handle the
+  // case with undefined values, too.
+  c1.b.a = c2->b.a;
+#else
+  c1.b.a = c2->b.a; // expected-warning{{Function call argument is an uninitialized value}}
+#endif
+}
+}
+
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -65,7 +65,7 @@
   if (Optional L = V.getAs())
 V = Pred->getState()->getSVal(*L);
   else
-assert(V.isUnknown());
+assert(V.isUnknownOrUndef());
 
   const Expr *CallExpr = Call.getOriginExpr();
   evalBind(Dst, CallExpr, Pred, ThisVal, V, true);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285640 - [analyzer] Allow undefined values in performTrivialCopy.

2016-10-31 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Oct 31 16:11:20 2016
New Revision: 285640

URL: http://llvm.org/viewvc/llvm-project?rev=285640&view=rev
Log:
[analyzer] Allow undefined values in performTrivialCopy.

Reading from a garbage pointer should be modeled as garbage,
and performTrivialCopy should be able to deal with any SVal input.

Patch by Ilya Palachev!

Differential Revision: https://reviews.llvm.org/D25727

Added:
cfe/trunk/test/Analysis/uninit-vals.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp?rev=285640&r1=285639&r2=285640&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp Mon Oct 31 16:11:20 2016
@@ -65,7 +65,7 @@ void ExprEngine::performTrivialCopy(Node
   if (Optional L = V.getAs())
 V = Pred->getState()->getSVal(*L);
   else
-assert(V.isUnknown());
+assert(V.isUnknownOrUndef());
 
   const Expr *CallExpr = Call.getOriginExpr();
   evalBind(Dst, CallExpr, Pred, ThisVal, V, true);

Added: cfe/trunk/test/Analysis/uninit-vals.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/uninit-vals.cpp?rev=285640&view=auto
==
--- cfe/trunk/test/Analysis/uninit-vals.cpp (added)
+++ cfe/trunk/test/Analysis/uninit-vals.cpp Mon Oct 31 16:11:20 2016
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin -verify 
-DCHECK_FOR_CRASH %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
+
+#ifdef CHECK_FOR_CRASH
+// expected-no-diagnostics
+#endif
+
+namespace PerformTrivialCopyForUndefs {
+struct A {
+  int x;
+};
+
+struct B {
+  A a;
+};
+
+struct C {
+  B b;
+};
+
+void foo() {
+  C c1;
+  C *c2;
+#ifdef CHECK_FOR_CRASH
+  // If the value of variable is not defined and checkers that check undefined
+  // values are not enabled, performTrivialCopy should be able to handle the
+  // case with undefined values, too.
+  c1.b.a = c2->b.a;
+#else
+  c1.b.a = c2->b.a; // expected-warning{{Function call argument is an 
uninitialized value}}
+#endif
+}
+}
+


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


[PATCH] D26164: [cfi] Fix missing !type annotation.

2016-10-31 Thread Evgeniy Stepanov via cfe-commits
eugenis created this revision.
eugenis added a reviewer: pcc.
eugenis added a subscriber: cfe-commits.
eugenis set the repository for this revision to rL LLVM.

CFI (only in the cross-dso mode) fails to set !type annotations when
a function is used before it is defined.


Repository:
  rL LLVM

https://reviews.llvm.org/D26164

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGen/cfi-icall-cross-dso2.c


Index: test/CodeGen/cfi-icall-cross-dso2.c
===
--- /dev/null
+++ test/CodeGen/cfi-icall-cross-dso2.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 \
+// RUN:   -fsanitize=cfi-icall -fsanitize-cfi-cross-dso \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @f() {{.*}} !type !{{.*}} !type !{{.*}}
+void f(void);
+void (*pf)(void) = f;
+void f(void) { }
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -928,6 +928,10 @@
 if (F->getAlignment() < 2 && isa(D))
   F->setAlignment(2);
   }
+
+  // In the cross-dso CFI mode, we want !type attributes on definitions only.
+  if (CodeGenOpts.SanitizeCfiCrossDso)
+CreateFunctionTypeMetadata(dyn_cast(D), F);
 }
 
 void CodeGenModule::SetCommonAttributes(const Decl *D,
@@ -1010,10 +1014,6 @@
 
   // Additionally, if building with cross-DSO support...
   if (CodeGenOpts.SanitizeCfiCrossDso) {
-// Don't emit entries for function declarations. In cross-DSO mode these 
are
-// handled with better precision at run time.
-if (!FD->hasBody())
-  return;
 // Skip available_externally functions. They won't be codegen'ed in the
 // current module anyway.
 if (getContext().GetGVALinkageForFunction(FD) == GVA_AvailableExternally)
@@ -1086,7 +1086,10 @@
 if (MD->isVirtual())
   F->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 
-  CreateFunctionTypeMetadata(FD, F);
+  // Don't emit entries for function declarations in the cross-DSO mode. This
+  // is handled with better precision by the receiving DSO.
+  if (!CodeGenOpts.SanitizeCfiCrossDso)
+CreateFunctionTypeMetadata(FD, F);
 }
 
 void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV) {


Index: test/CodeGen/cfi-icall-cross-dso2.c
===
--- /dev/null
+++ test/CodeGen/cfi-icall-cross-dso2.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 \
+// RUN:   -fsanitize=cfi-icall -fsanitize-cfi-cross-dso \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @f() {{.*}} !type !{{.*}} !type !{{.*}}
+void f(void);
+void (*pf)(void) = f;
+void f(void) { }
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -928,6 +928,10 @@
 if (F->getAlignment() < 2 && isa(D))
   F->setAlignment(2);
   }
+
+  // In the cross-dso CFI mode, we want !type attributes on definitions only.
+  if (CodeGenOpts.SanitizeCfiCrossDso)
+CreateFunctionTypeMetadata(dyn_cast(D), F);
 }
 
 void CodeGenModule::SetCommonAttributes(const Decl *D,
@@ -1010,10 +1014,6 @@
 
   // Additionally, if building with cross-DSO support...
   if (CodeGenOpts.SanitizeCfiCrossDso) {
-// Don't emit entries for function declarations. In cross-DSO mode these are
-// handled with better precision at run time.
-if (!FD->hasBody())
-  return;
 // Skip available_externally functions. They won't be codegen'ed in the
 // current module anyway.
 if (getContext().GetGVALinkageForFunction(FD) == GVA_AvailableExternally)
@@ -1086,7 +1086,10 @@
 if (MD->isVirtual())
   F->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 
-  CreateFunctionTypeMetadata(FD, F);
+  // Don't emit entries for function declarations in the cross-DSO mode. This
+  // is handled with better precision by the receiving DSO.
+  if (!CodeGenOpts.SanitizeCfiCrossDso)
+CreateFunctionTypeMetadata(FD, F);
 }
 
 void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26163: [clang-format] Fix PR30527: Regression when clang-format insert spaces in [] when in template

2016-10-31 Thread Branko Kokanovic via cfe-commits
branko created this revision.
branko added a reviewer: djasper.
branko added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Actual regression was introduced in r272668. This revision fixes JS script, but 
also regress Cpp case. It manifests with spaces added when template is followed 
with array. Bug 30527 mentions case of array as a nested template type 
(foo[]>). Fix is to detect such case and to prevent treating it as 
array initialization, but as a subscript case. However, before r272668, this 
case was treated simple because we were detecting it as a StartsObjCMethodExpr. 
Same was true for other similar case - array of templates (foo[]). This 
patch tries to address two problems: 1) fixing regression 2) making sure both 
cases (array as a nested type, array of templates) which were entering 
StartsObjCMethodExpr branch are handled now appropriately.


https://reviews.llvm.org/D26163

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11501,6 +11501,26 @@
   verifyFormat("include \"a.td\"\ninclude \"b.td\"", Style);
 }
 
+TEST_F(FormatTest, ArrayOfTemplates) {
+  EXPECT_EQ("auto a = new unique_ptr[10];",
+format("auto a = new unique_ptr [ 10];"));
+
+  FormatStyle Spaces = getLLVMStyle();
+  Spaces.SpacesInSquareBrackets = true;
+  EXPECT_EQ("auto a = new unique_ptr[ 10 ];",
+format("auto a = new unique_ptr [10];", Spaces));
+}
+
+TEST_F(FormatTest, ArrayAsTemplateType) {
+  EXPECT_EQ("auto a = unique_ptr[10]>;",
+format("auto a = unique_ptr < Foo < Bar>[ 10]> ;"));
+
+  FormatStyle Spaces = getLLVMStyle();
+  Spaces.SpacesInSquareBrackets = true;
+  EXPECT_EQ("auto a = unique_ptr[ 10 ]>;",
+format("auto a = unique_ptr < Foo < Bar>[10]> ;", Spaces));
+}
+
 // Since this test case uses UNIX-style file path. We disable it for MS
 // compiler.
 #if !defined(_MSC_VER) && !defined(__MINGW32__)
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -305,7 +305,17 @@
 FormatToken *Left = CurrentToken->Previous;
 Left->ParentBracket = Contexts.back().ContextKind;
 FormatToken *Parent = Left->getPreviousNonComment();
-bool StartsObjCMethodExpr =
+
+// Cases where '>' is followed by '['.
+// In C++, this can happen either in array of templates (foo[10])
+// or when array is a nested template type (unique_ptr[]>).
+bool CppArrayTemplates =
+Style.Language == FormatStyle::LK_Cpp && Parent &&
+Parent->is(TT_TemplateCloser) &&
+(Contexts.back().CanBeExpression || Contexts.back().IsExpression ||
+ Contexts.back().InTemplateArgument);
+
+bool StartsObjCMethodExpr = !CppArrayTemplates &&
 Style.Language == FormatStyle::LK_Cpp &&
 Contexts.back().CanBeExpression && Left->isNot(TT_LambdaLSquare) &&
 CurrentToken->isNot(tok::l_brace) &&
@@ -326,7 +336,7 @@
  Parent->isOneOf(tok::l_brace, tok::comma)) {
 Left->Type = TT_JsComputedPropertyName;
   } else if (Style.Language == FormatStyle::LK_Proto ||
- (Parent &&
+ (!CppArrayTemplates && Parent &&
   Parent->isOneOf(TT_BinaryOperator, TT_TemplateCloser, 
tok::at,
   tok::comma, tok::l_paren, tok::l_square,
   tok::question, tok::colon, tok::kw_return,


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11501,6 +11501,26 @@
   verifyFormat("include \"a.td\"\ninclude \"b.td\"", Style);
 }
 
+TEST_F(FormatTest, ArrayOfTemplates) {
+  EXPECT_EQ("auto a = new unique_ptr[10];",
+format("auto a = new unique_ptr [ 10];"));
+
+  FormatStyle Spaces = getLLVMStyle();
+  Spaces.SpacesInSquareBrackets = true;
+  EXPECT_EQ("auto a = new unique_ptr[ 10 ];",
+format("auto a = new unique_ptr [10];", Spaces));
+}
+
+TEST_F(FormatTest, ArrayAsTemplateType) {
+  EXPECT_EQ("auto a = unique_ptr[10]>;",
+format("auto a = unique_ptr < Foo < Bar>[ 10]> ;"));
+
+  FormatStyle Spaces = getLLVMStyle();
+  Spaces.SpacesInSquareBrackets = true;
+  EXPECT_EQ("auto a = unique_ptr[ 10 ]>;",
+format("auto a = unique_ptr < Foo < Bar>[10]> ;", Spaces));
+}
+
 // Since this test case uses UNIX-style file path. We disable it for MS
 // compiler.
 #if !defined(_MSC_VER) && !defined(__MINGW32__)
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -305,7 +305,17 @@
 FormatToken *Left = CurrentToken

[PATCH] D26138: [clang-tidy] Add modernize-use-equals-delete check

2016-10-31 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/UseEqualsDeleteCheck.cpp:29
+cxxMethodDecl(
+anyOf(isCopyAssignmentOperator(), isMoveAssignmentOperator())),
+cxxDestructorDecl()));

How about a conversion operator, like `operator bool()`? You'll sometimes see 
that one declared privately for similar reasons.



Comment at: clang-tidy/modernize/UseEqualsDeleteCheck.cpp:37
+   // Ensure that all methods except private special member
+   // functions are defined
+   hasParent(cxxRecordDecl(hasMethod(unless(

Missing a full stop at the end of the comment.



Comment at: clang-tidy/modernize/UseEqualsDeleteCheck.cpp:46
+void UseEqualsDeleteCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *SpecialFunction =
+  Result.Nodes.getNodeAs("SpecialFunction");

Should rename this to not hide the global `SpecialFunction` object, and use the 
global `SpecialFunction` object in place of the string literal here. 
Alternatively, leave this name alone and remove the global variable and just 
use the string literal; either is fine.



Comment at: clang-tidy/modernize/UseEqualsDeleteCheck.cpp:52
+  diag(SpecialFunction->getLocation(),
+   "use '= delete' to prevent a default special member function")
+  << FixItHint::CreateInsertion(EndLoc, " = delete");

This diagnostic isn't very clear to me -- what does it mean to "prevent" a 
default special member function?

The fixit for this is also somewhat unsatisfying as this takes a private, 
not-defined function and turns it into a private, deleted function. That's a 
very small win, because it only impacts code which could access the special 
member function in the first place (some compilers give a diagnostic about the 
special member function being inaccessible even if it's explicitly marked as 
deleted; clang is not one such compiler). Do we have a way to rewrite the 
access specifier for the special member function as well (kind of like how we 
have a way to handle includes we're adding)? I am guessing not yet, but if we 
do, that would be fantastic to use here.

Note, I don't think this should hold up your patch or the fixit. A small win is 
still a win. :-)



Comment at: test/clang-tidy/modernize-use-equals-delete.cpp:93
+private:
+  NegativeConstructNotImpl(const NegativeConstructNotImpl &);
+};

Phab will not let me delete the unsubmitted comment I had about this, so I am 
leaving a junk comment instead. Your move, Phabricator.


https://reviews.llvm.org/D26138



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


[PATCH] D26159: [analyzer] MacOSXAPIChecker: Improve warning messages for __block vars in dispatch_once().

2016-10-31 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285637: [analyzer] MacOSXAPIChecker: Improve warnings for 
__block vars in dispatch_once. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D26159?vs=76453&id=76478#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26159

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  cfe/trunk/test/Analysis/dispatch-once.m


Index: cfe/trunk/test/Analysis/dispatch-once.m
===
--- cfe/trunk/test/Analysis/dispatch-once.m
+++ cfe/trunk/test/Analysis/dispatch-once.m
@@ -90,3 +90,20 @@
 void test_ivar_array_from_external_obj(Object *o) {
   dispatch_once(&o->once_array[1], ^{}); // expected-warning{{Call to 
'dispatch_once' uses memory within the instance variable 'once_array' for the 
predicate value.}}
 }
+
+void test_block_var_from_block() {
+  __block dispatch_once_t once;
+  ^{
+dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' 
uses the block variable 'once' for the predicate value.}}
+  };
+}
+
+void use_block_var(dispatch_once_t *once);
+
+void test_block_var_from_outside_block() {
+  __block dispatch_once_t once;
+  ^{
+use_block_var(&once);
+  };
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses 
the block variable 'once' for the predicate value.}}
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
@@ -94,10 +94,15 @@
   bool SuggestStatic = false;
   os << "Call to '" << FName << "' uses";
   if (const VarRegion *VR = dyn_cast(RB)) {
-// We filtered out globals earlier, so it must be a local variable.
+// We filtered out globals earlier, so it must be a local variable
+// or a block variable which is under UnknownSpaceRegion.
 if (VR != R)
   os << " memory within";
-os << " the local variable '" << VR->getDecl()->getName() << '\'';
+if (VR->getDecl()->hasAttr())
+  os << " the block variable '";
+else
+  os << " the local variable '";
+os << VR->getDecl()->getName() << '\'';
 SuggestStatic = true;
   } else if (const ObjCIvarRegion *IVR = getParentIvarRegion(R)) {
 if (IVR != R)
@@ -108,6 +113,9 @@
   } else if (isa(RS)) {
 // Presence of an IVar superregion has priority over this branch, because
 // ObjC objects are on the heap even if the core doesn't realize this.
+// Presence of a block variable base region has priority over this branch,
+// because block variables are known to be either on stack or on heap
+// (might actually move between the two, hence UnknownSpace).
 return;
   } else {
 os << " stack allocated memory";


Index: cfe/trunk/test/Analysis/dispatch-once.m
===
--- cfe/trunk/test/Analysis/dispatch-once.m
+++ cfe/trunk/test/Analysis/dispatch-once.m
@@ -90,3 +90,20 @@
 void test_ivar_array_from_external_obj(Object *o) {
   dispatch_once(&o->once_array[1], ^{}); // expected-warning{{Call to 'dispatch_once' uses memory within the instance variable 'once_array' for the predicate value.}}
 }
+
+void test_block_var_from_block() {
+  __block dispatch_once_t once;
+  ^{
+dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the block variable 'once' for the predicate value.}}
+  };
+}
+
+void use_block_var(dispatch_once_t *once);
+
+void test_block_var_from_outside_block() {
+  __block dispatch_once_t once;
+  ^{
+use_block_var(&once);
+  };
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the block variable 'once' for the predicate value.}}
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
@@ -94,10 +94,15 @@
   bool SuggestStatic = false;
   os << "Call to '" << FName << "' uses";
   if (const VarRegion *VR = dyn_cast(RB)) {
-// We filtered out globals earlier, so it must be a local variable.
+// We filtered out globals earlier, so it must be a local variable
+// or a block variable which is under UnknownSpaceRegion.
 if (VR != R)
   os << " memory within";
-os << " the local variable '" << VR->getDecl()->getName() << '\'';
+if (VR->getDecl()->hasAttr())
+  os << " the block variable '";
+else
+  os << " the local variable '";
+os << VR->getDecl()->getName() << '\'';
 SuggestStatic = true;
   } else if (const ObjCIvarRegion *IVR = getParentIvarRegion(R)) {
 if (IVR != R)
@@ -108,6 +113,9 @@
   } else if (isa(RS)) {
 // Presence of an IVar superregion has priority o

r285637 - [analyzer] MacOSXAPIChecker: Improve warnings for __block vars in dispatch_once.

2016-10-31 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Oct 31 16:04:54 2016
New Revision: 285637

URL: http://llvm.org/viewvc/llvm-project?rev=285637&view=rev
Log:
[analyzer] MacOSXAPIChecker: Improve warnings for __block vars in dispatch_once.

The checker already warns for __block-storage variables being used as a
dispatch_once() predicate, however it refers to them as local which is not quite
accurate, so we fix that.

Differential Revision: https://reviews.llvm.org/D26159

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
cfe/trunk/test/Analysis/dispatch-once.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp?rev=285637&r1=285636&r2=285637&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp Mon Oct 31 
16:04:54 2016
@@ -94,10 +94,15 @@ void MacOSXAPIChecker::CheckDispatchOnce
   bool SuggestStatic = false;
   os << "Call to '" << FName << "' uses";
   if (const VarRegion *VR = dyn_cast(RB)) {
-// We filtered out globals earlier, so it must be a local variable.
+// We filtered out globals earlier, so it must be a local variable
+// or a block variable which is under UnknownSpaceRegion.
 if (VR != R)
   os << " memory within";
-os << " the local variable '" << VR->getDecl()->getName() << '\'';
+if (VR->getDecl()->hasAttr())
+  os << " the block variable '";
+else
+  os << " the local variable '";
+os << VR->getDecl()->getName() << '\'';
 SuggestStatic = true;
   } else if (const ObjCIvarRegion *IVR = getParentIvarRegion(R)) {
 if (IVR != R)
@@ -108,6 +113,9 @@ void MacOSXAPIChecker::CheckDispatchOnce
   } else if (isa(RS)) {
 // Presence of an IVar superregion has priority over this branch, because
 // ObjC objects are on the heap even if the core doesn't realize this.
+// Presence of a block variable base region has priority over this branch,
+// because block variables are known to be either on stack or on heap
+// (might actually move between the two, hence UnknownSpace).
 return;
   } else {
 os << " stack allocated memory";

Modified: cfe/trunk/test/Analysis/dispatch-once.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dispatch-once.m?rev=285637&r1=285636&r2=285637&view=diff
==
--- cfe/trunk/test/Analysis/dispatch-once.m (original)
+++ cfe/trunk/test/Analysis/dispatch-once.m Mon Oct 31 16:04:54 2016
@@ -90,3 +90,20 @@ void test_ivar_struct_from_external_obj(
 void test_ivar_array_from_external_obj(Object *o) {
   dispatch_once(&o->once_array[1], ^{}); // expected-warning{{Call to 
'dispatch_once' uses memory within the instance variable 'once_array' for the 
predicate value.}}
 }
+
+void test_block_var_from_block() {
+  __block dispatch_once_t once;
+  ^{
+dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' 
uses the block variable 'once' for the predicate value.}}
+  };
+}
+
+void use_block_var(dispatch_once_t *once);
+
+void test_block_var_from_outside_block() {
+  __block dispatch_once_t once;
+  ^{
+use_block_var(&once);
+  };
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses 
the block variable 'once' for the predicate value.}}
+}


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


[libunwind] r285636 - fix _dyld_find_unwind_sections() for pre-10.7. Patch by Jeremy Sequoia

2016-10-31 Thread Nick Kledzik via cfe-commits
Author: kledzik
Date: Mon Oct 31 16:04:17 2016
New Revision: 285636

URL: http://llvm.org/viewvc/llvm-project?rev=285636&view=rev
Log:
fix _dyld_find_unwind_sections() for pre-10.7.  Patch by Jeremy Sequoia

Modified:
libunwind/trunk/src/AddressSpace.hpp

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=285636&r1=285635&r2=285636&view=diff
==
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Mon Oct 31 16:04:17 2016
@@ -321,28 +321,34 @@ LocalAddressSpace::getEncodedP(pint_t &a
 // In 10.7.0 or later, libSystem.dylib implements this function.
 extern "C" bool _dyld_find_unwind_sections(void *, dyld_unwind_sections *);
   #else
-// In 10.6.x and earlier, we need to implement this functionality.
+// In 10.6.x and earlier, we need to implement this functionality. Note
+// that this requires a newer version of libmacho (from cctools) than is
+// present in libSystem on 10.6.x (for getsectiondata).
 static inline bool _dyld_find_unwind_sections(void* addr, 
 dyld_unwind_sections* 
info) {
   // Find mach-o image containing address.
   Dl_info dlinfo;
   if (!dladdr(addr, &dlinfo))
 return false;
-  const mach_header *mh = (const mach_header *)dlinfo.dli_saddr;
-  
-  // Find DWARF unwind section in that image.
-  unsigned long size;
-  const uint8_t *p = getsectiondata(mh, "__TEXT", "__eh_frame", &size);
-  if (!p)
-return false;
-  
-  // Fill in return struct.
-  info->mh = mh;
-  info->dwarf_section = p;
-  info->dwarf_section_length = size;
-  info->compact_unwind_section = 0;
-  info->compact_unwind_section_length = 0;
- 
+#if __LP64__
+  const struct mach_header_64 *mh = (const struct mach_header_64 
*)dlinfo.dli_fbase;
+#else
+  const struct mach_header *mh = (const struct mach_header 
*)dlinfo.dli_fbase;
+#endif
+
+  // Initialize the return struct
+  info->mh = (const struct mach_header *)mh;
+  info->dwarf_section = getsectiondata(mh, "__TEXT", "__eh_frame", 
&info->dwarf_section_length);
+  info->compact_unwind_section = getsectiondata(mh, "__TEXT", 
"__unwind_info", &info->compact_unwind_section_length);
+
+  if (!info->dwarf_section) {
+info->dwarf_section_length = 0;
+  }
+
+  if (!info->compact_unwind_section) {
+info->compact_unwind_section_length = 0;
+  }
+
   return true;
 }
   #endif


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


[PATCH] D26138: [clang-tidy] Add modernize-use-equals-delete check

2016-10-31 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

It'll be good idea to rename //modernize-use-default// in similar fashion, 
since both checks are closely relate and in both cases keywords are ambiguous.


https://reviews.llvm.org/D26138



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


[PATCH] D26032: [ASTMatcher] Add CXXNewExpr support to hasDeclaration

2016-10-31 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.

Yep, makes sense. Open issues are all about types :)


https://reviews.llvm.org/D26032



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


Re: [libcxx] r285382 - Add __libcpp_version file and __libcpp_library_version function.

2016-10-31 Thread Joerg Sonnenberger via cfe-commits
On Mon, Oct 31, 2016 at 01:25:19PM -0700, Richard Smith wrote:
> We could alternatively control the language features based only on the
> selected language mode, and only use version detection to power a warning
> for the (currently fairly common, but becoming less so) case where the
> selected runtime library isn't new enough to implement the requested
> features. That would cause a bunch of scenarios to break when upgrading to
> clang 4.0, but at least the fix would be pretty clear.

Let's split this slightly. Ultimately, we need to have codegen flags to
control individual features that require support from the ABI
implementation or even just from the STL implementation. I can think of
three different ways to provide the default values:
(1) Language mode selection
(2) Driver logic based on the target
(3) Source controls like #pragma

The third option would serve mostly the same purpose as feature
detection based on some magic __version file, but it also would allow
non-libc++ implementations or -nostdinc use cases to get the same
behavior.

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


[PATCH] D26032: [ASTMatcher] Add CXXNewExpr support to hasDeclaration

2016-10-31 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.

Assuming @klimek agrees with the design, this LGTM. If you don't hear from 
Manuel by next Wed, I think you're okay to commit (we can always roll it back 
post-commit if needed).


https://reviews.llvm.org/D26032



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


[PATCH] D26159: [analyzer] MacOSXAPIChecker: Improve warning messages for __block vars in dispatch_once().

2016-10-31 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

> FIXME: The analyzer sets stack memory space for __block variables when they 
> are referenced outside the block (eg. test_block_var_from_outside_block() 
> line 108). Will try to fix in a separate patch; i'm not relying on the memory 
> space in this patch.

That's actually correct, never mind.


https://reviews.llvm.org/D26159



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


r285631 - Add comment explaining this mysterious macro name.

2016-10-31 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Oct 31 15:25:52 2016
New Revision: 285631

URL: http://llvm.org/viewvc/llvm-project?rev=285631&view=rev
Log:
Add comment explaining this mysterious macro name.

Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=285631&r1=285630&r2=285631&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Oct 31 15:25:52 2016
@@ -992,6 +992,9 @@ static void InitializePredefinedMacros(c
   }
 
   if (TI.hasInt128Type() && LangOpts.CPlusPlus && LangOpts.GNUMode) {
+// For each extended integer type, g++ defines a macro mapping the
+// index of the type (0 in this case) in some list of extended types
+// to the type.
 Builder.defineMacro("__GLIBCXX_TYPE_INT_N_0", "__int128");
 Builder.defineMacro("__GLIBCXX_BITSIZE_INT_N_0", "128");
   }


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


[PATCH] D26159: [analyzer] MacOSXAPIChecker: Improve warning messages for __block vars in dispatch_once().

2016-10-31 Thread Devin Coughlin via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

LGTM.

We should probably be warning any time the address of a block variable is taken 
since the address is not stable -- but that's a job for a different checker or 
possibly even Sema.


https://reviews.llvm.org/D26159



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


Re: [libcxx] r285382 - Add __libcpp_version file and __libcpp_library_version function.

2016-10-31 Thread Richard Smith via cfe-commits
On Mon, Oct 31, 2016 at 11:21 AM, Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Mon, Oct 31, 2016 at 10:45:05AM -0700, Richard Smith via cfe-commits
> wrote:
> > On Sun, Oct 30, 2016 at 12:32 PM, Joerg Sonnenberger 
> wrote:
> >
> > > On Sun, Oct 30, 2016 at 12:54:28PM -0600, Eric Fiselier wrote:
> > > > Richard requested this change. Take a look at
> > > > https://reviews.llvm.org/D26044 for more rational.
> > >
> > > I don't see much rational and in fact, I disagree with some of the
> > > mentioned items. E.g. presence of libc++ won't tell you if you can use
> > > sized deallocation as that's a ABI library issue.
> >
> >
> > The real situation is a lot more subtle than that. Every one of
> libc++abi,
> > libcxxrt, libc++, libsupc++, and libstdc++ provides definitions of global
> > operator new and operator delete. It's obviously not part of the Itanium
> > C++ ABI, so it's not the responsibility of a pure "ABI library" to
> provide
> > it, but the boundary between the ABI library and the standard library has
> > never been formally defined.
>
> That doesn't actually invalidate anything I said.


No, but that was just introduction to the part of my reply that you
snipped, which does: libc++, not the ABI library, provides the definition
of the symbols of interest in this case, so it's the libc++ version that we
care about.

But the make the
> argument even more explicit: any detection based on magic files in the
> include directories are breaking important properties. A preprocessed
> file is now no longer independent of the build system.


Yes, this requires distributed build systems like distcc (that preprocess
locally before distributing) to have the complete toolchain, including the
runtime libraries and standard library headers, present on each build
worker, not just the compiler. And if we're using any part of GCC in a
compilation, that complete toolchain includes the selected GCC
installation. But that is not actually a new requirement; the detected GCC
installation already affects, for instance, the default setting for
-fuse-init-array.

We could alternatively control the language features based only on the
selected language mode, and only use version detection to power a warning
for the (currently fairly common, but becoming less so) case where the
selected runtime library isn't new enough to implement the requested
features. That would cause a bunch of scenarios to break when upgrading to
clang 4.0, but at least the fix would be pretty clear.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24933: Enable configuration files in clang

2016-10-31 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Added some people who might have opinions on the command line interface. Sorry, 
I don't have a lot of time for this right now.


https://reviews.llvm.org/D24933



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


[PATCH] D25624: Added 'inline' attribute to basic_string's destructor

2016-10-31 Thread Sebastian Pop via cfe-commits
sebpop added a comment.

In https://reviews.llvm.org/D25624#583163, @mehdi_amini wrote:

> I'd like to understand why only the destructor?


We have committed a patch to inline the constructor of std::string.
Do you think we should inline some other functions?

In https://reviews.llvm.org/D25624#583167, @mehdi_amini wrote:

> I talked with Eric on IRC, he mentioned some benchmarks were ran. I'd like to 
> understand what was the baseline?


We ran a proprietary benchmark compiled with clang + libc++ and compared 
against clang + libstdc++.
With this patch, libc++ is on par with libstdc++.

> Here we add *both* the inline keyword and the always_inline attribute. I'd 
> like to know if there is a benchmarks that shows that always_inline is 
> beneficial on top of the inline keyword. 
>  If we need to add always_inline anywhere: this is likely an inliner 
> heuristic failure and we should at minima track it as an example to improve 
> it.

This is a good observation: I am not sure we ran the benchmark without the 
always_inline attribute.
We will try again wihout that attribute and report whether it matters 
performance wise.
Thanks Mehdi for catching this!


https://reviews.llvm.org/D25624



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


[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2016-10-31 Thread Kuba Brecka via cfe-commits
kubabrecka added a comment.

Just a question:  TSan intercepts on the dylib functions, namely 
`__release_shared`, to track the atomic accesses.  Can you make sure this 
doesn't break?  There's a few testcases for this in compiler-rt.


https://reviews.llvm.org/D24991



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


[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2016-10-31 Thread Sebastian Pop via cfe-commits
sebpop added a comment.

Ping: Eric, Marshall, could you please approve or comment on this patch?
Thanks!


https://reviews.llvm.org/D24991



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


Re: r285625 - DebugInfo: support for DW_TAG_atomic_type

2016-10-31 Thread Adrian Prantl via cfe-commits

> On Oct 31, 2016, at 12:09 PM, Victor Leschuk via cfe-commits 
>  wrote:
> 
> Author: vleschuk
> Date: Mon Oct 31 14:09:47 2016
> New Revision: 285625
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=285625&view=rev
> Log:
> DebugInfo: support for DW_TAG_atomic_type
> 
> Mark C11 _Atomic variables with DW_TAG_atomic_type tag.
> 
> Differential Revision: https://reviews.llvm.org/D26145
> 
> Added:
>cfe/trunk/test/CodeGen/debug-info-atomic.c
> Modified:
>cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=285625&r1=285624&r2=285625&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Oct 31 14:09:47 2016
> @@ -2287,9 +2287,8 @@ llvm::DIType *CGDebugInfo::CreateType(co
> }
> 
> llvm::DIType *CGDebugInfo::CreateType(const AtomicType *Ty, llvm::DIFile *U) {
> -  // Ignore the atomic wrapping
> -  // FIXME: What is the correct representation?
> -  return getOrCreateType(Ty->getValueType(), U);
> +  auto *FromTy = getOrCreateType(Ty->getValueType(), U);
> +  return DBuilder.createQualifiedType(llvm::dwarf::DW_TAG_atomic_type, 
> FromTy);
> }
> 
> llvm::DIType* CGDebugInfo::CreateType(const PipeType *Ty,
> 
> Added: cfe/trunk/test/CodeGen/debug-info-atomic.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-atomic.c?rev=285625&view=auto
> ==
> --- cfe/trunk/test/CodeGen/debug-info-atomic.c (added)
> +++ cfe/trunk/test/CodeGen/debug-info-atomic.c Mon Oct 31 14:09:47 2016
> @@ -0,0 +1,7 @@
> +// RUN: %clang -g -c -std=c11 -S -emit-llvm -o - %s | FileCheck %s
> +
> +// CHECK: !DIGlobalVariable(name: "i"{{.*}}type: !5, isLocal: false, 
> isDefinition: true)
> +// CHECK: !5 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !6)
> +// CHECK: !6 = !DIDerivedType(tag: DW_TAG_atomic_type, baseType: !7)
> +// CHECK: !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)

Please use FileCheck variables like ![[TYPE:[0-9]+]] instead of hardcoding the 
numbers. This is bound to break soon otherwise.

-- adrian

> +_Atomic const int i;
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2016-10-31 Thread Kevin Hu via cfe-commits
hxy9243 accepted this revision.
hxy9243 added a comment.
This revision is now accepted and ready to land.

Looks good to me.
Notice that the performance gain can only be observed when compiled with the 
updated C++ header files.


https://reviews.llvm.org/D24991



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


[PATCH] D24888: [clang-tidy] Use [[clang::suppress]] with cppcoreguidelines-pro-type-reinterpret-cast

2016-10-31 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/cppcoreguidelines/Suppression.h:59
+ anyOf(hasAncestor(attributedStmt(hasSuppressAttr(Rules))),
+   hasAncestor(decl(hasAttrs(), hasSuppressAttr(Rules)
+  .matches(Node, Finder, Builder);

mgehre wrote:
> aaron.ballman wrote:
> > mgehre wrote:
> > > aaron.ballman wrote:
> > > > Why is the check for `hasAttrs` required?
> > > > 
> > > > Also, this use of `hasAncestor()` makes this expensive to use, and that 
> > > > expense may be hidden from the caller. Is there a way to structure this 
> > > > so that we don't need to walk the entire ancestor tree?
> > > hasAttr() is needed here, because inside of hasSuppressAttr(), we call 
> > > getAttrs() which would assert if hasAttr() is false.
> > > I cannot push hasAttr() into hasSuppressAttr(), because hasSuppressAttr() 
> > > is a template getting either Decl or AttributedStmt,
> > > and AttributedStmt does not have an hasAttr() method.
> > I believe that `getSpecificAttr` should be resilient to no attributes being 
> > present (since it also has to handle the case there are no attributes of 
> > the specific type, so no attributes at all is simply a degenerate case), 
> > and so the check for `hasAttrs()` should be redundant.
> Decl::getAttrs() will assert if called on a Decl where hasAttrs() is false, 
> see
> http://clang.llvm.org/doxygen/DeclBase_8cpp_source.html#l00741
Ugh, that is a problem, but not one you should have to handle as part of this 
patch. I'll put it on my list of things to look into, thank you for being 
patient with me! :-)


https://reviews.llvm.org/D24888



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


[PATCH] D26145: DebugInfo: support for DW_TAG_atomic_type

2016-10-31 Thread Victor Leschuk via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285625: DebugInfo: support for DW_TAG_atomic_type (authored 
by vleschuk).

Changed prior to commit:
  https://reviews.llvm.org/D26145?vs=76441&id=76458#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26145

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/test/CodeGen/debug-info-atomic.c


Index: cfe/trunk/test/CodeGen/debug-info-atomic.c
===
--- cfe/trunk/test/CodeGen/debug-info-atomic.c
+++ cfe/trunk/test/CodeGen/debug-info-atomic.c
@@ -0,0 +1,7 @@
+// RUN: %clang -g -c -std=c11 -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: !DIGlobalVariable(name: "i"{{.*}}type: !5, isLocal: false, 
isDefinition: true)
+// CHECK: !5 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !6)
+// CHECK: !6 = !DIDerivedType(tag: DW_TAG_atomic_type, baseType: !7)
+// CHECK: !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+_Atomic const int i;
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -2287,9 +2287,8 @@
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const AtomicType *Ty, llvm::DIFile *U) {
-  // Ignore the atomic wrapping
-  // FIXME: What is the correct representation?
-  return getOrCreateType(Ty->getValueType(), U);
+  auto *FromTy = getOrCreateType(Ty->getValueType(), U);
+  return DBuilder.createQualifiedType(llvm::dwarf::DW_TAG_atomic_type, FromTy);
 }
 
 llvm::DIType* CGDebugInfo::CreateType(const PipeType *Ty,


Index: cfe/trunk/test/CodeGen/debug-info-atomic.c
===
--- cfe/trunk/test/CodeGen/debug-info-atomic.c
+++ cfe/trunk/test/CodeGen/debug-info-atomic.c
@@ -0,0 +1,7 @@
+// RUN: %clang -g -c -std=c11 -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: !DIGlobalVariable(name: "i"{{.*}}type: !5, isLocal: false, isDefinition: true)
+// CHECK: !5 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !6)
+// CHECK: !6 = !DIDerivedType(tag: DW_TAG_atomic_type, baseType: !7)
+// CHECK: !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+_Atomic const int i;
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -2287,9 +2287,8 @@
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const AtomicType *Ty, llvm::DIFile *U) {
-  // Ignore the atomic wrapping
-  // FIXME: What is the correct representation?
-  return getOrCreateType(Ty->getValueType(), U);
+  auto *FromTy = getOrCreateType(Ty->getValueType(), U);
+  return DBuilder.createQualifiedType(llvm::dwarf::DW_TAG_atomic_type, FromTy);
 }
 
 llvm::DIType* CGDebugInfo::CreateType(const PipeType *Ty,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285625 - DebugInfo: support for DW_TAG_atomic_type

2016-10-31 Thread Victor Leschuk via cfe-commits
Author: vleschuk
Date: Mon Oct 31 14:09:47 2016
New Revision: 285625

URL: http://llvm.org/viewvc/llvm-project?rev=285625&view=rev
Log:
DebugInfo: support for DW_TAG_atomic_type

Mark C11 _Atomic variables with DW_TAG_atomic_type tag.

Differential Revision: https://reviews.llvm.org/D26145

Added:
cfe/trunk/test/CodeGen/debug-info-atomic.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=285625&r1=285624&r2=285625&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Oct 31 14:09:47 2016
@@ -2287,9 +2287,8 @@ llvm::DIType *CGDebugInfo::CreateType(co
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const AtomicType *Ty, llvm::DIFile *U) {
-  // Ignore the atomic wrapping
-  // FIXME: What is the correct representation?
-  return getOrCreateType(Ty->getValueType(), U);
+  auto *FromTy = getOrCreateType(Ty->getValueType(), U);
+  return DBuilder.createQualifiedType(llvm::dwarf::DW_TAG_atomic_type, FromTy);
 }
 
 llvm::DIType* CGDebugInfo::CreateType(const PipeType *Ty,

Added: cfe/trunk/test/CodeGen/debug-info-atomic.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-atomic.c?rev=285625&view=auto
==
--- cfe/trunk/test/CodeGen/debug-info-atomic.c (added)
+++ cfe/trunk/test/CodeGen/debug-info-atomic.c Mon Oct 31 14:09:47 2016
@@ -0,0 +1,7 @@
+// RUN: %clang -g -c -std=c11 -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: !DIGlobalVariable(name: "i"{{.*}}type: !5, isLocal: false, 
isDefinition: true)
+// CHECK: !5 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !6)
+// CHECK: !6 = !DIDerivedType(tag: DW_TAG_atomic_type, baseType: !7)
+// CHECK: !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+_Atomic const int i;


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


[PATCH] D25857: [tsan][clang] Introduce a function attribute to disable TSan checking at run time

2016-10-31 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Thanks for the review! I'll submit the updated patches soon.


https://reviews.llvm.org/D25857



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


r285623 - NFC - Reorder test case names in a PPC test case

2016-10-31 Thread Nemanja Ivanovic via cfe-commits
Author: nemanjai
Date: Mon Oct 31 14:02:54 2016
New Revision: 285623

URL: http://llvm.org/viewvc/llvm-project?rev=285623&view=rev
Log:
NFC - Reorder test case names in a PPC test case

A few recent commits have messed up the order of some tests
in a PPC test case. This just reorders them in a sensible way.

Modified:
cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c

Modified: cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c?rev=285623&r1=285622&r2=285623&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c Mon Oct 31 14:02:54 2016
@@ -700,6 +700,34 @@ vector unsigned short test54(void) {
 // CHECK-NEXT: ret <8 x i16>
   return vec_popcnt (vusa);
 }
+vector double test55(void) {
+// CHECK-BE: @llvm.ppc.vsx.xviexpdp(<2 x i64> %{{.+}}, <2 x i64>
+// CHECK-BE-NEXT: ret <2 x double>
+// CHECK: @llvm.ppc.vsx.xviexpdp(<2 x i64> %{{.+}}, <2 x i64>
+// CHECK-NEXT: ret <2 x double>
+  return vec_insert_exp (vda,vulb);
+}
+vector double test56(void) {
+// CHECK-BE: @llvm.ppc.vsx.xviexpdp(<2 x i64> %{{.+}}, <2 x i64>
+// CHECK-BE-NEXT: ret <2 x double>
+// CHECK: @llvm.ppc.vsx.xviexpdp(<2 x i64> %{{.+}}, <2 x i64>
+// CHECK-NEXT: ret <2 x double>
+  return vec_insert_exp (vula, vulb);
+}
+vector float test57(void) {
+// CHECK-BE: @llvm.ppc.vsx.xviexpsp(<4 x i32> %{{.+}}, <4 x i32>
+// CHECK-BE-NEXT: ret <4 x float>
+// CHECK: @llvm.ppc.vsx.xviexpsp(<4 x i32> %{{.+}}, <4 x i32>
+// CHECK-NEXT: ret <4 x float>
+  return vec_insert_exp (vfa,vuib);
+}
+vector float test58(void) {
+// CHECK-BE: @llvm.ppc.vsx.xviexpsp(<4 x i32> %{{.+}}, <4 x i32>
+// CHECK-BE-NEXT: ret <4 x float>
+// CHECK: @llvm.ppc.vsx.xviexpsp(<4 x i32> %{{.+}}, <4 x i32>
+// CHECK-NEXT: ret <4 x float>
+  return vec_insert_exp (vuia,vuib);
+}
 signed int test59(void) {
 // CHECK-BE: @llvm.ppc.altivec.vclzlsbb(<16 x i8>
 // CHECK-BE-NEXT: ret i32
@@ -775,31 +803,3 @@ vector unsigned __int128 test68(void) {
 // CHECK-NEXT: ret <1 x i128>
   return vec_parity_lsbb (vsi128a);
 }
-vector double test55(void) {
-// CHECK-BE: @llvm.ppc.vsx.xviexpdp(<2 x i64> %{{.+}}, <2 x i64>
-// CHECK-BE-NEXT: ret <2 x double>
-// CHECK: @llvm.ppc.vsx.xviexpdp(<2 x i64> %{{.+}}, <2 x i64>
-// CHECK-NEXT: ret <2 x double>
-  return vec_insert_exp (vda,vulb);
-}
-vector double test56(void) {
-// CHECK-BE: @llvm.ppc.vsx.xviexpdp(<2 x i64> %{{.+}}, <2 x i64>
-// CHECK-BE-NEXT: ret <2 x double>
-// CHECK: @llvm.ppc.vsx.xviexpdp(<2 x i64> %{{.+}}, <2 x i64>
-// CHECK-NEXT: ret <2 x double>
-  return vec_insert_exp (vula, vulb);
-}
-vector float test57(void) {
-// CHECK-BE: @llvm.ppc.vsx.xviexpsp(<4 x i32> %{{.+}}, <4 x i32>
-// CHECK-BE-NEXT: ret <4 x float>
-// CHECK: @llvm.ppc.vsx.xviexpsp(<4 x i32> %{{.+}}, <4 x i32>
-// CHECK-NEXT: ret <4 x float>
-  return vec_insert_exp (vfa,vuib);
-}
-vector float test58(void) {
-// CHECK-BE: @llvm.ppc.vsx.xviexpsp(<4 x i32> %{{.+}}, <4 x i32>
-// CHECK-BE-NEXT: ret <4 x float>
-// CHECK: @llvm.ppc.vsx.xviexpsp(<4 x i32> %{{.+}}, <4 x i32>
-// CHECK-NEXT: ret <4 x float>
-  return vec_insert_exp (vuia,vuib);
-}


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


Re: [PATCH] D25316: [clang-tidy] Enhance modernize-use-auto to casts

2016-10-31 Thread Aaron Ballman via cfe-commits
On Mon, Oct 31, 2016 at 2:55 PM, Malcolm Parsons
 wrote:
> malcolm.parsons added inline comments.
>
>
> 
> Comment at: clang-tidy/modernize/UseAutoCheck.cpp:404
> +[](const Expr *Expr) { return Expr->getType(); },
> +"use auto when initializing with new to avoid "
> +"duplicating the type name");
> 
> aaron.ballman wrote:
>> malcolm.parsons wrote:
>> > aaron.ballman wrote:
>> > > Quote use of `auto` and `new` in the diagnostic since they're syntax 
>> > > rather than english.
>> > A lot of clang-tidy diagnostics don't quote syntax/functions/types:
>> >
>> > ```
>> > "do not use reinterpret_cast"
>> > "pass by value and use std::move"
>> > "use nullptr"
>> > "the shrink_to_fit method should be used "
>> > "use std::move to transfer ownership"
>> > "auto_ptr is deprecated, use unique_ptr instead"
>> > "use auto when declaring iterators"
>> > "use range-based for loop instead"
>> > "use emplace_back instead of push_back"
>> > "prefer a lambda to std::bind"
>> > ...
>> > ```
>> clang-tidy hasn't always done a good job of following the conventions that 
>> clang uses for its diagnostics, but the reason I pointed this wording out 
>> specifically is because things like "new" are a valid word to use in an 
>> English sentence too, which makes the diagnostic text harder to understand 
>> without the quotes.
> The diagnostic with 'new' isn't new.

Correct, but you are adding a new instance of it, which is a good time
to fix things up.

> Let's cleanup the diagnostics in another patch.

I'm fine with that.

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


[PATCH] D25316: [clang-tidy] Enhance modernize-use-auto to casts

2016-10-31 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/UseAutoCheck.cpp:404
+[](const Expr *Expr) { return Expr->getType(); },
+"use auto when initializing with new to avoid "
+"duplicating the type name");

aaron.ballman wrote:
> malcolm.parsons wrote:
> > aaron.ballman wrote:
> > > Quote use of `auto` and `new` in the diagnostic since they're syntax 
> > > rather than english.
> > A lot of clang-tidy diagnostics don't quote syntax/functions/types:
> > 
> > ```
> > "do not use reinterpret_cast"
> > "pass by value and use std::move"
> > "use nullptr"
> > "the shrink_to_fit method should be used "
> > "use std::move to transfer ownership"
> > "auto_ptr is deprecated, use unique_ptr instead"
> > "use auto when declaring iterators"
> > "use range-based for loop instead"
> > "use emplace_back instead of push_back"
> > "prefer a lambda to std::bind"
> > ...
> > ```
> clang-tidy hasn't always done a good job of following the conventions that 
> clang uses for its diagnostics, but the reason I pointed this wording out 
> specifically is because things like "new" are a valid word to use in an 
> English sentence too, which makes the diagnostic text harder to understand 
> without the quotes.
The diagnostic with 'new' isn't new.

Let's cleanup the diagnostics in another patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D25316



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


[PATCH] D26159: [analyzer] MacOSXAPIChecker: Improve warning messages for __block vars in dispatch_once().

2016-10-31 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added reviewers: zaks.anna, dcoughlin.
NoQ added a subscriber: cfe-commits.

The checker already warns for `__block`-storage variables being used as a 
`dispatch_once()` predicate, however it refers to them as local which is not 
quite accurate, so we fix that.

Also add tests to make sure it works.

FIXME: The analyzer sets stack memory space for `__block` variables when they 
are referenced outside the block (eg. `test_block_var_from_outside_block()` 
line 108). Will try to fix in a separate patch; i'm not relying on the memory 
space in this patch.


https://reviews.llvm.org/D26159

Files:
  lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  test/Analysis/dispatch-once.m


Index: test/Analysis/dispatch-once.m
===
--- test/Analysis/dispatch-once.m
+++ test/Analysis/dispatch-once.m
@@ -90,3 +90,20 @@
 void test_ivar_array_from_external_obj(Object *o) {
   dispatch_once(&o->once_array[1], ^{}); // expected-warning{{Call to 
'dispatch_once' uses memory within the instance variable 'once_array' for the 
predicate value.}}
 }
+
+void test_block_var_from_block() {
+  __block dispatch_once_t once;
+  ^{
+dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' 
uses the block variable 'once' for the predicate value.}}
+  };
+}
+
+void use_block_var(dispatch_once_t *once);
+
+void test_block_var_from_outside_block() {
+  __block dispatch_once_t once;
+  ^{
+use_block_var(&once);
+  };
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses 
the block variable 'once' for the predicate value.}}
+}
Index: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
@@ -94,10 +94,15 @@
   bool SuggestStatic = false;
   os << "Call to '" << FName << "' uses";
   if (const VarRegion *VR = dyn_cast(RB)) {
-// We filtered out globals earlier, so it must be a local variable.
+// We filtered out globals earlier, so it must be a local variable
+// or a block variable which is under UnknownSpaceRegion.
 if (VR != R)
   os << " memory within";
-os << " the local variable '" << VR->getDecl()->getName() << '\'';
+if (VR->getDecl()->hasAttr())
+  os << " the block variable '";
+else
+  os << " the local variable '";
+os << VR->getDecl()->getName() << '\'';
 SuggestStatic = true;
   } else if (const ObjCIvarRegion *IVR = getParentIvarRegion(R)) {
 if (IVR != R)
@@ -108,6 +113,9 @@
   } else if (isa(RS)) {
 // Presence of an IVar superregion has priority over this branch, because
 // ObjC objects are on the heap even if the core doesn't realize this.
+// Presence of a block variable base region has priority over this branch,
+// because block variables are known to be either on stack or on heap
+// (might actually move between the two, hence UnknownSpace).
 return;
   } else {
 os << " stack allocated memory";


Index: test/Analysis/dispatch-once.m
===
--- test/Analysis/dispatch-once.m
+++ test/Analysis/dispatch-once.m
@@ -90,3 +90,20 @@
 void test_ivar_array_from_external_obj(Object *o) {
   dispatch_once(&o->once_array[1], ^{}); // expected-warning{{Call to 'dispatch_once' uses memory within the instance variable 'once_array' for the predicate value.}}
 }
+
+void test_block_var_from_block() {
+  __block dispatch_once_t once;
+  ^{
+dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the block variable 'once' for the predicate value.}}
+  };
+}
+
+void use_block_var(dispatch_once_t *once);
+
+void test_block_var_from_outside_block() {
+  __block dispatch_once_t once;
+  ^{
+use_block_var(&once);
+  };
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the block variable 'once' for the predicate value.}}
+}
Index: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
@@ -94,10 +94,15 @@
   bool SuggestStatic = false;
   os << "Call to '" << FName << "' uses";
   if (const VarRegion *VR = dyn_cast(RB)) {
-// We filtered out globals earlier, so it must be a local variable.
+// We filtered out globals earlier, so it must be a local variable
+// or a block variable which is under UnknownSpaceRegion.
 if (VR != R)
   os << " memory within";
-os << " the local variable '" << VR->getDecl()->getName() << '\'';
+if (VR->getDecl()->hasAttr())
+  os << " the block variable '";
+else
+  os << " the local variable '";
+os << VR->getDecl()->getName() << '\'';
 SuggestStatic = true;
   } else if (const ObjCIvarRegion *IVR = getPare

r285617 - Fixing problem with CodeGen/avx512-kconstraints-att_inline_asm.c

2016-10-31 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Oct 31 13:40:17 2016
New Revision: 285617

URL: http://llvm.org/viewvc/llvm-project?rev=285617&view=rev
Log:
Fixing problem with CodeGen/avx512-kconstraints-att_inline_asm.c  


Modified:
cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c

Modified: cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c?rev=285617&r1=285616&r2=285617&view=diff
==
--- cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c (original)
+++ cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c Mon Oct 31 
13:40:17 2016
@@ -1,58 +1,58 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-cpu skylake-avx512 
-O0  -emit-llvm -S -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-cpu 
skylake-avx512 -emit-llvm -o - -Wall -Werror |opt -instnamer -S |FileCheck %s
 // This test checks validity of att\gcc style inline assmebly for avx512 k and 
Yk constraints.
 // Also checks mask register allows flexible type (size <= 64 bit)
 
 void mask_Yk_i8(char msk){ 
-//CHECK: vpaddb %xmm1, %xmm0, %xmm1 {%k1}
+//CHECK: vpaddb\09 %xmm1, %xmm0, %xmm1 {$0}\09
  asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
://output
: "Yk" (msk));   //inputs
 }
 
 void mask_Yk_i16(short msk){
-//CHECK: vpaddb %xmm1, %xmm0, %xmm1 {%k1}
+//CHECK: vpaddb\09 %xmm1, %xmm0, %xmm1 {$0}\09
  asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
://output
:  "Yk" (msk));  //inputs
 }
 
 void mask_Yk_i32(int msk){
-//CHECK: vpaddb %xmm1, %xmm0, %xmm1 {%k1}
+//CHECK: vpaddb\09 %xmm1, %xmm0, %xmm1 {$0}\09
 asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
://output
:  "Yk" (msk));   //inputs
 }
 
 void mask_Yk_i64(long long msk){
-//CHECK: vpaddb %xmm1, %xmm0, %xmm1 {%k1}
+//CHECK: vpaddb\09 %xmm1, %xmm0, %xmm1 {$0}\09
  asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
://output
:  "Yk" (msk));   //inputs
 }
 
 void k_wise_op_i8(char msk_dst,char msk_src1,char msk_src2){
-//CHECK: kandw %k1, %k0, %k0
+//CHECK: kandw\09$2, $1, $0
  asm ("kandw\t%2, %1, %0"
: "=k" (msk_dst)
: "k" (msk_src1), "k" (msk_src2));
 }
 
 void k_wise_op_i16(short msk_dst, short msk_src1, short msk_src2){
-//CHECK: kandw %k1, %k0, %k0
+//CHECK: kandw\09$2, $1, $0
   asm ("kandw\t%2, %1, %0"
: "=k" (msk_dst)
: "k" (msk_src1), "k" (msk_src2));
 }
 
 void k_wise_op_i32(int msk_dst, int msk_src1, int msk_src2){
-//CHECK: kandw %k1, %k0, %k0
+//CHECK: kandw\09$2, $1, $0
   asm ("kandw\t%2, %1, %0"
: "=k" (msk_dst)
: "k" (msk_src1), "k" (msk_src2));
 }
 
 void k_wise_op_i64(long long msk_dst, long long msk_src1, long long msk_src2){
-//CHECK: kandw %k1, %k0, %k0
+//CHECK: kandw\09$2, $1, $0
   asm ("kandw\t%2, %1, %0"
: "=k" (msk_dst)
: "k" (msk_src1), "k" (msk_src2));


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


Re: r285604 - [x86][inline-asm][AVX512][clang][PART-1] Introducing "k" and "Yk" constraints for extended inline assembly, enabling use of AVX512 masked vectorized instructions.

2016-10-31 Thread Renato Golin via cfe-commits
On 31 October 2016 at 17:23, Michael Zuckerman via cfe-commits
 wrote:
> Author: mzuckerm
> Date: Mon Oct 31 12:23:52 2016
> New Revision: 285604
>
> URL: http://llvm.org/viewvc/llvm-project?rev=285604&view=rev
> Log:
> [x86][inline-asm][AVX512][clang][PART-1] Introducing "k" and "Yk" constraints 
> for extended inline assembly, enabling use of AVX512 masked vectorized 
> instructions.

Hi Michael,

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-39vma/builds/90
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/311
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/271

'No available targets are compatible with this triple.'

I'm not sure why this one fails and the other similar ones don't.

This is breaking all bots that don't build x86.

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


[PATCH] D25316: [clang-tidy] Enhance modernize-use-auto to casts

2016-10-31 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/UseAutoCheck.cpp:404
+[](const Expr *Expr) { return Expr->getType(); },
+"use auto when initializing with new to avoid "
+"duplicating the type name");

malcolm.parsons wrote:
> aaron.ballman wrote:
> > Quote use of `auto` and `new` in the diagnostic since they're syntax rather 
> > than english.
> A lot of clang-tidy diagnostics don't quote syntax/functions/types:
> 
> ```
> "do not use reinterpret_cast"
> "pass by value and use std::move"
> "use nullptr"
> "the shrink_to_fit method should be used "
> "use std::move to transfer ownership"
> "auto_ptr is deprecated, use unique_ptr instead"
> "use auto when declaring iterators"
> "use range-based for loop instead"
> "use emplace_back instead of push_back"
> "prefer a lambda to std::bind"
> ...
> ```
clang-tidy hasn't always done a good job of following the conventions that 
clang uses for its diagnostics, but the reason I pointed this wording out 
specifically is because things like "new" are a valid word to use in an English 
sentence too, which makes the diagnostic text harder to understand without the 
quotes.


Repository:
  rL LLVM

https://reviews.llvm.org/D25316



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


[PATCH] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-10-31 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

LGTM. Thanks.


Repository:
  rL LLVM

https://reviews.llvm.org/D26157



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


r285612 - Add a warning flag for warn_alloca_align_alignof

2016-10-31 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Oct 31 13:23:02 2016
New Revision: 285612

URL: http://llvm.org/viewvc/llvm-project?rev=285612&view=rev
Log:
Add a warning flag for warn_alloca_align_alignof

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=285612&r1=285611&r2=285612&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct 31 13:23:02 
2016
@@ -2441,7 +2441,8 @@ def error_cannot_find_suitable_accessor
   "cannot find suitable %select{getter|setter}0 for property %1">;
 
 def warn_alloca_align_alignof : Warning<
-  "second argument to __builtin_alloca_with_align is supposed to be in bits">;
+  "second argument to __builtin_alloca_with_align is supposed to be in bits">,
+  InGroup>;
 
 def err_alignment_too_small : Error<
   "requested alignment must be %0 or greater">;


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


r285610 - When diagnosing that a defaulted function is ill-formed because it would be

2016-10-31 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Oct 31 13:18:29 2016
New Revision: 285610

URL: http://llvm.org/viewvc/llvm-project?rev=285610&view=rev
Log:
When diagnosing that a defaulted function is ill-formed because it would be
implicitly deleted and overrides a non-deleted function, explain why the
function is deleted. For PR30844.

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/class.derived/class.abstract/p16.cpp
cfe/trunk/test/CXX/special/class.dtor/p5-0x.cpp
cfe/trunk/test/CXX/special/class.dtor/p9.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=285610&r1=285609&r2=285610&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Oct 31 13:18:29 2016
@@ -13850,7 +13850,7 @@ void Sema::SetDeclDeleted(Decl *Dcl, Sou
 
   // See if we're deleting a function which is already known to override a
   // non-deleted virtual function.
-  if (const CXXMethodDecl *MD = dyn_cast(Fn)) {
+  if (CXXMethodDecl *MD = dyn_cast(Fn)) {
 bool IssuedDiagnostic = false;
 for (CXXMethodDecl::method_iterator I = MD->begin_overridden_methods(),
 E = MD->end_overridden_methods();
@@ -13863,6 +13863,11 @@ void Sema::SetDeclDeleted(Decl *Dcl, Sou
 Diag((*I)->getLocation(), diag::note_overridden_virtual_function);
   }
 }
+// If this function was implicitly deleted because it was defaulted,
+// explain why it was deleted.
+if (IssuedDiagnostic && MD->isDefaulted())
+  ShouldDeleteSpecialMember(MD, getSpecialMember(MD), nullptr,
+/*Diagnose*/true);
   }
 
   // C++11 [basic.start.main]p3:

Modified: cfe/trunk/test/CXX/class.derived/class.abstract/p16.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.derived/class.abstract/p16.cpp?rev=285610&r1=285609&r2=285610&view=diff
==
--- cfe/trunk/test/CXX/class.derived/class.abstract/p16.cpp (original)
+++ cfe/trunk/test/CXX/class.derived/class.abstract/p16.cpp Mon Oct 31 13:18:29 
2016
@@ -31,12 +31,20 @@ private:
   D &operator=(D&&) = default;
   virtual ~D(); // expected-note 2{{here}}
 };
-struct E : D {}; // expected-error {{deleted function '~E' cannot override a 
non-deleted function}} \
- // expected-error {{deleted function 'operator=' cannot 
override a non-deleted function}}
+struct E : D {};
+// expected-error@-1 {{deleted function '~E' cannot override a non-deleted 
function}}
+// expected-note@-2 {{destructor of 'E' is implicitly deleted because base 
class 'D' has an inaccessible destructor}}
+// expected-error@-3 {{deleted function 'operator=' cannot override a 
non-deleted function}}
+// expected-note@-4 {{copy assignment operator of 'E' is implicitly deleted 
because base class 'D' has an inaccessible copy assignment operator}}
 struct F : D {};
-struct G : D {}; // expected-error {{deleted function '~G' cannot override a 
non-deleted function}}
- // expected-error@-1 {{deleted function 'operator=' cannot 
override a non-deleted function}}
+struct G : D {};
+// expected-error@-1 {{deleted function '~G' cannot override a non-deleted 
function}}
+// expected-note@-2 {{move assignment operator of 'G' is implicitly deleted 
because base class 'D' has an inaccessible move assignment operator}}
+// expected-error@-3 {{deleted function 'operator=' cannot override a 
non-deleted function}}
+// expected-note@-4 {{destructor of 'G' is implicitly deleted because base 
class 'D' has an inaccessible destructor}}
 struct H : D {
-  H &operator=(H&&) = default; // expected-error {{deleted function 
'operator=' cannot override a non-deleted function}}
+  H &operator=(H&&) = default;
+  // expected-error@-1 {{deleted function 'operator=' cannot override a 
non-deleted function}}
+  // expected-note@-3 {{move assignment operator of 'H' is implicitly deleted 
because base class 'D' has an inaccessible move assignment operator}}
   ~H();
 };

Modified: cfe/trunk/test/CXX/special/class.dtor/p5-0x.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/special/class.dtor/p5-0x.cpp?rev=285610&r1=285609&r2=285610&view=diff
==
--- cfe/trunk/test/CXX/special/class.dtor/p5-0x.cpp (original)
+++ cfe/trunk/test/CXX/special/class.dtor/p5-0x.cpp Mon Oct 31 13:18:29 2016
@@ -90,7 +90,7 @@ class D1 {
 public:
   virtual ~D1() = default; // expected-note {{here}}
 } d1; // ok
-struct D2 : D1 { // expected-note {{virtual destructor requires an 
unambiguous, accessible 'operator delete'}} \
+struct D2 : D1 { // expected-note 2{{virtual destructor requires an 
unambiguous, accessible 'operator delete'}} \
  // expected-error {{deleted function '~D2' cannot 

[PATCH] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-10-31 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

It looks good generally. My only concern here if anyone could use this MD 
expecting target AS values which correspond to those put in the IR itself. On 
the other hand clGetKernelArgInfo is supposed to be used for obtaining the 
information about the original source which I agree we are not preserving any 
longer.


Repository:
  rL LLVM

https://reviews.llvm.org/D26157



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


Re: [libcxx] r285382 - Add __libcpp_version file and __libcpp_library_version function.

2016-10-31 Thread Joerg Sonnenberger via cfe-commits
On Mon, Oct 31, 2016 at 10:45:05AM -0700, Richard Smith via cfe-commits wrote:
> On Sun, Oct 30, 2016 at 12:32 PM, Joerg Sonnenberger  wrote:
> 
> > On Sun, Oct 30, 2016 at 12:54:28PM -0600, Eric Fiselier wrote:
> > > Richard requested this change. Take a look at
> > > https://reviews.llvm.org/D26044 for more rational.
> >
> > I don't see much rational and in fact, I disagree with some of the
> > mentioned items. E.g. presence of libc++ won't tell you if you can use
> > sized deallocation as that's a ABI library issue.
> 
> 
> The real situation is a lot more subtle than that. Every one of libc++abi,
> libcxxrt, libc++, libsupc++, and libstdc++ provides definitions of global
> operator new and operator delete. It's obviously not part of the Itanium
> C++ ABI, so it's not the responsibility of a pure "ABI library" to provide
> it, but the boundary between the ABI library and the standard library has
> never been formally defined.

That doesn't actually invalidate anything I said. But the make the
argument even more explicit: any detection based on magic files in the
include directories are breaking important properties. A preprocessed
file is now no longer independent of the build system.

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


Re: r285544 - Add support for __builtin_alloca_with_align

2016-10-31 Thread David Majnemer via cfe-commits
Added in r285609.

On Mon, Oct 31, 2016 at 9:21 AM, Hal Finkel  wrote:

> Hi David,
>
> On Reid's patch for this (D25581), Richard said, "This takes the alignment
> in bits? That's so ridiculously dumb that I would feel bad about accepting
> this patch unless it comes with a warning for people writing the
> obvious-but-wrong __builtin_alloca_with_align(sizeof(T), alignof(T))". We
> should add the warning.
>
> Thanks again,
> Hal
>
> - Original Message -
> > From: "David Majnemer via cfe-commits" 
> > To: cfe-commits@lists.llvm.org
> > Sent: Monday, October 31, 2016 12:37:49 AM
> > Subject: r285544 - Add support for __builtin_alloca_with_align
> >
> > Author: majnemer
> > Date: Mon Oct 31 00:37:48 2016
> > New Revision: 285544
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=285544&view=rev
> > Log:
> > Add support for __builtin_alloca_with_align
> >
> > __builtin_alloca always uses __BIGGEST_ALIGNMENT__ for the alignment
> > of
> > the allocation.  __builtin_alloca_with_align allows the programmer to
> > specify the alignment of the allocation.
> >
> > This fixes PR30658.
> >
> > Added:
> > cfe/trunk/test/Sema/builtin-alloca-with-align.c
> > Modified:
> > cfe/trunk/include/clang/Basic/Builtins.def
> > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> > cfe/trunk/include/clang/Sema/Sema.h
> > cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> > cfe/trunk/lib/Sema/SemaChecking.cpp
> > cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
> > cfe/trunk/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
> > cfe/trunk/test/CodeGen/builtins-ms.c
> >
> > Modified: cfe/trunk/include/clang/Basic/Builtins.def
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/Builtins.def?rev=285544&r1=285543&r2=285544&view=diff
> > 
> ==
> > --- cfe/trunk/include/clang/Basic/Builtins.def (original)
> > +++ cfe/trunk/include/clang/Basic/Builtins.def Mon Oct 31 00:37:48
> > 2016
> > @@ -512,6 +512,7 @@ BUILTIN(__builtin_unreachable, "v", "nr"
> >  BUILTIN(__builtin_shufflevector, "v."   , "nc")
> >  BUILTIN(__builtin_convertvector, "v."   , "nct")
> >  BUILTIN(__builtin_alloca, "v*z"   , "Fn")
> > +BUILTIN(__builtin_alloca_with_align, "v*zIz", "Fn")
> >  BUILTIN(__builtin_call_with_static_chain, "v.", "nt")
> >
> >  // "Overloaded" Atomic operator builtins.  These are overloaded to
> >  support data
> >
> > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=285544&r1=285543&r2=285544&view=diff
> > 
> ==
> > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct 31
> > 00:37:48 2016
> > @@ -2440,6 +2440,10 @@ def err_no_accessor_for_property : Error
> >  def error_cannot_find_suitable_accessor : Error<
> >"cannot find suitable %select{getter|setter}0 for property %1">;
> >
> > +def err_alignment_too_small : Error<
> > +  "requested alignment must be %0 or greater">;
> > +def err_alignment_too_big : Error<
> > +  "requested alignment must be %0 or smaller">;
> >  def err_alignment_not_power_of_two : Error<
> >"requested alignment is not a power of 2">;
> >  def err_alignment_dependent_typedef_name : Error<
> >
> > Modified: cfe/trunk/include/clang/Sema/Sema.h
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Sema/Sema.h?rev=285544&r1=285543&r2=285544&view=diff
> > 
> ==
> > --- cfe/trunk/include/clang/Sema/Sema.h (original)
> > +++ cfe/trunk/include/clang/Sema/Sema.h Mon Oct 31 00:37:48 2016
> > @@ -9719,6 +9719,7 @@ public:
> >
> >  private:
> >bool SemaBuiltinPrefetch(CallExpr *TheCall);
> > +  bool SemaBuiltinAllocaWithAlign(CallExpr *TheCall);
> >bool SemaBuiltinAssume(CallExpr *TheCall);
> >bool SemaBuiltinAssumeAligned(CallExpr *TheCall);
> >bool SemaBuiltinLongjmp(CallExpr *TheCall);
> >
> > Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGBuiltin.cpp?rev=285544&r1=285543&r2=285544&view=diff
> > 
> ==
> > --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 31 00:37:48 2016
> > @@ -1147,6 +1147,19 @@ RValue CodeGenFunction::EmitBuiltinExpr(
> >  AI->setAlignment(SuitableAlignmentInBytes);
> >  return RValue::get(AI);
> >}
> > +
> > +  case Builtin::BI__builtin_alloca_with_align: {
> > +Value *Size = EmitScalarExpr(E->getArg(0));
> > +Value *AlignmentValue = EmitScalarExpr(E->getArg(1));
> > +auto *AlignmentCI = cast(AlignmentValue);
> > +unsigned Alignment =

r285609 - [Sema] Warn when alignof is used with __builtin_alloca_with_align

2016-10-31 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Oct 31 13:07:57 2016
New Revision: 285609

URL: http://llvm.org/viewvc/llvm-project?rev=285609&view=rev
Log:
[Sema] Warn when alignof is used with __builtin_alloca_with_align

The second argument to __builtin_alloca_with_align is supposed to be in
bits, not bytes.  Using alignof there would be indicative of a bug.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/builtin-alloca-with-align.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=285609&r1=285608&r2=285609&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct 31 13:07:57 
2016
@@ -2440,6 +2440,9 @@ def err_no_accessor_for_property : Error
 def error_cannot_find_suitable_accessor : Error<
   "cannot find suitable %select{getter|setter}0 for property %1">;
 
+def warn_alloca_align_alignof : Warning<
+  "second argument to __builtin_alloca_with_align is supposed to be in bits">;
+
 def err_alignment_too_small : Error<
   "requested alignment must be %0 or greater">;
 def err_alignment_too_big : Error<

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=285609&r1=285608&r2=285609&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 31 13:07:57 2016
@@ -3907,7 +3907,7 @@ bool Sema::SemaBuiltinAssume(CallExpr *T
   return false;
 }
 
-/// Handle __builtin_assume_aligned. This is declared
+/// Handle __builtin_alloca_with_align. This is declared
 /// as (size_t, size_t) where the second size_t must be a power of 2 greater
 /// than 8.
 bool Sema::SemaBuiltinAllocaWithAlign(CallExpr *TheCall) {
@@ -3916,6 +3916,12 @@ bool Sema::SemaBuiltinAllocaWithAlign(Ca
 
   // We can't check the value of a dependent argument.
   if (!Arg->isTypeDependent() && !Arg->isValueDependent()) {
+if (const auto *UE =
+dyn_cast(Arg->IgnoreParenImpCasts()))
+  if (UE->getKind() == UETT_AlignOf)
+Diag(TheCall->getLocStart(), diag::warn_alloca_align_alignof)
+  << Arg->getSourceRange();
+
 llvm::APSInt Result = Arg->EvaluateKnownConstInt(Context);
 
 if (!Result.isPowerOf2())

Modified: cfe/trunk/test/Sema/builtin-alloca-with-align.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtin-alloca-with-align.c?rev=285609&r1=285608&r2=285609&view=diff
==
--- cfe/trunk/test/Sema/builtin-alloca-with-align.c (original)
+++ cfe/trunk/test/Sema/builtin-alloca-with-align.c Mon Oct 31 13:07:57 2016
@@ -27,3 +27,7 @@ void test6(int a, int j) {
 void test7(int a) {
   __builtin_alloca_with_align(a, 2); // expected-error {{requested alignment 
must be 8 or greater}}
 }
+
+void test8() {
+  __builtin_alloca_with_align(sizeof(__INT64_TYPE__), 
__alignof__(__INT64_TYPE__)); // expected-warning {{second argument to 
__builtin_alloca_with_align is supposed to be in bits}}
+}


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


[PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h

2016-10-31 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.



Comment at: test/CodeGenOpenCL/convergent.cl:54
+// CHECK: tail call spir_func void @f()
+// CHECK-NOT: call spir_func void @non_convfun()
+// CHECK-NOT: call spir_func void @g()

Anastasia wrote:
> Did you mean to check @convfun() here?
Yes. Will fix it when committing.


https://reviews.llvm.org/D25343



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


[PATCH] D26145: DebugInfo: support for DW_TAG_atomic_type

2016-10-31 Thread Adrian Prantl via cfe-commits
aprantl added a comment.

One more inline comment.




Comment at: test/CodeGen/debug-info-atomic.c:4
+// CHECK: !DIGlobalVariable(name: "i"{{.*}}type: !5, isLocal: false, 
isDefinition: true)
+// CHECK: !5 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !6)
+// CHECK: !6 = !DIDerivedType(tag: DW_TAG_atomic_type, baseType: !7)

Please use FileCheck variables ![[TYPE:[0-9]+]] instead of hardcoding the 
numbers. This is bound to break soon otherwise.


https://reviews.llvm.org/D26145



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


[PATCH] D26143: [modules] Mark deleted functions as implicitly inline to allow merging

2016-10-31 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Sema/SemaDeclCXX.cpp:13875-13876
+  //  A deleted function is implicitly inline.
+  // NOTE: Modules cannot correctly merge deleted functions unless they are
+  // inline.
+  Fn->setImplicitlyInline();

This comment is effectively saying "Modules relies on the AST being correct". I 
don't think we need it.


https://reviews.llvm.org/D26143



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


Re: [libcxx] r285382 - Add __libcpp_version file and __libcpp_library_version function.

2016-10-31 Thread Richard Smith via cfe-commits
On Sun, Oct 30, 2016 at 12:32 PM, Joerg Sonnenberger  wrote:

> On Sun, Oct 30, 2016 at 12:54:28PM -0600, Eric Fiselier wrote:
> > Richard requested this change. Take a look at
> > https://reviews.llvm.org/D26044 for more rational.
>
> I don't see much rational and in fact, I disagree with some of the
> mentioned items. E.g. presence of libc++ won't tell you if you can use
> sized deallocation as that's a ABI library issue.


The real situation is a lot more subtle than that. Every one of libc++abi,
libcxxrt, libc++, libsupc++, and libstdc++ provides definitions of global
operator new and operator delete. It's obviously not part of the Itanium
C++ ABI, so it's not the responsibility of a pure "ABI library" to provide
it, but the boundary between the ABI library and the standard library has
never been formally defined.

In any case, the point is that libc++ does provide the relevant symbols,
except when using libstdc++ as its ABI library (in which case it leaves
them to libstdc++ to define). libc++abi does not define sized delete nor
aligned new/delete.

(And for what it's worth, we will also need to detect the version of the
ABI library to correctly enable/disable support for other features.)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25316: [clang-tidy] Enhance modernize-use-auto to casts

2016-10-31 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D25316#583651, @aaron.ballman wrote:

> Does this check properly work in the presence of macros? Those are sometimes 
> more common in casting operations, so a few explicit tests would be good 
> (those tests could be follow-on work if it turns out that this check doesn't 
> play nicely with macros).


Tests added in r285601.


Repository:
  rL LLVM

https://reviews.llvm.org/D25316



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


[PATCH] D25909: [analyzer] MacOSXApiChecker: Disallow dispatch_once predicates on heap and in ivars.

2016-10-31 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285605: [analyzer] MacOSXAPIChecker: Disallow 
dispatch_once_t in ivars and heap. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D25909?vs=75998&id=76446#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25909

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  cfe/trunk/test/Analysis/dispatch-once.m

Index: cfe/trunk/test/Analysis/dispatch-once.m
===
--- cfe/trunk/test/Analysis/dispatch-once.m
+++ cfe/trunk/test/Analysis/dispatch-once.m
@@ -0,0 +1,92 @@
+// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=core,osx.API,unix.Malloc -verify %s
+// RUN: %clang_cc1 -w -fblocks -fobjc-arc -analyze -analyzer-checker=core,osx.API,unix.Malloc -verify %s
+
+#include "Inputs/system-header-simulator-objc.h"
+
+typedef unsigned long size_t;
+void *calloc(size_t nmemb, size_t size);
+
+typedef void (^dispatch_block_t)(void);
+typedef long dispatch_once_t;
+void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);
+
+void test_stack() {
+  dispatch_once_t once;
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the local variable 'once' for the predicate value.  Using such transient memory for the predicate is potentially dangerous.  Perhaps you intended to declare the variable as 'static'?}}
+}
+
+void test_static_local() {
+  static dispatch_once_t once;
+  dispatch_once(&once, ^{}); // no-warning
+}
+
+void test_heap_var() {
+  dispatch_once_t *once = calloc(1, sizeof(dispatch_once_t));
+  // Use regexps to check that we're NOT suggesting to make this static.
+  dispatch_once(once, ^{}); // expected-warning-re^Call to 'dispatch_once' uses heap-allocated memory for the predicate value.  Using such transient memory for the predicate is potentially dangerous$
+}
+
+void test_external_pointer(dispatch_once_t *once) {
+  // External pointer does not necessarily point to the heap.
+  dispatch_once(once, ^{}); // no-warning
+}
+
+typedef struct {
+  dispatch_once_t once;
+} Struct;
+
+void test_local_struct() {
+  Struct s;
+  dispatch_once(&s.once, ^{}); // expected-warning{{Call to 'dispatch_once' uses memory within the local variable 's' for the predicate value.}}
+}
+
+void test_heap_struct() {
+  Struct *s = calloc(1, sizeof(Struct));
+  dispatch_once(&s->once, ^{}); // expected-warning{{Call to 'dispatch_once' uses heap-allocated memory for the predicate value.}}
+}
+
+@interface Object : NSObject {
+@public
+  dispatch_once_t once;
+  Struct s;
+  dispatch_once_t once_array[2];
+}
+- (void)test_ivar_from_inside;
+- (void)test_ivar_struct_from_inside;
+@end
+
+@implementation Object
+- (void)test_ivar_from_inside {
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 'once' for the predicate value.}}
+}
+- (void)test_ivar_struct_from_inside {
+  dispatch_once(&s.once, ^{}); // expected-warning{{Call to 'dispatch_once' uses memory within the instance variable 's' for the predicate value.}}
+}
+- (void)test_ivar_array_from_inside {
+  dispatch_once(&once_array[1], ^{}); // expected-warning{{Call to 'dispatch_once' uses memory within the instance variable 'once_array' for the predicate value.}}
+}
+@end
+
+void test_ivar_from_alloc_init() {
+  Object *o = [[Object alloc] init];
+  dispatch_once(&o->once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 'once' for the predicate value.}}
+}
+void test_ivar_struct_from_alloc_init() {
+  Object *o = [[Object alloc] init];
+  dispatch_once(&o->s.once, ^{}); // expected-warning{{Call to 'dispatch_once' uses memory within the instance variable 's' for the predicate value.}}
+}
+void test_ivar_array_from_alloc_init() {
+  Object *o = [[Object alloc] init];
+  dispatch_once(&o->once_array[1], ^{}); // expected-warning{{Call to 'dispatch_once' uses memory within the instance variable 'once_array' for the predicate value.}}
+}
+
+void test_ivar_from_external_obj(Object *o) {
+  // ObjC object pointer always points to the heap.
+  dispatch_once(&o->once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 'once' for the predicate value.}}
+}
+void test_ivar_struct_from_external_obj(Object *o) {
+  dispatch_once(&o->s.once, ^{}); // expected-warning{{Call to 'dispatch_once' uses memory within the instance variable 's' for the predicate value.}}
+}
+void test_ivar_array_from_external_obj(Object *o) {
+  dispatch_once(&o->once_array[1], ^{}); // expected-warning{{Call to 'dispatch_once' uses memory within the instance variable 'once_array' for the predicate value.}}
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe

r285605 - [analyzer] MacOSXAPIChecker: Disallow dispatch_once_t in ivars and heap.

2016-10-31 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Oct 31 12:27:26 2016
New Revision: 285605

URL: http://llvm.org/viewvc/llvm-project?rev=285605&view=rev
Log:
[analyzer] MacOSXAPIChecker: Disallow dispatch_once_t in ivars and heap.

Unlike global/static variables, calloc etc. functions that allocate ObjC
objects behave differently in terms of memory barriers, and hacks that make
dispatch_once as fast as it possibly could be start failing.

Differential Revision: https://reviews.llvm.org/D25909

Added:
cfe/trunk/test/Analysis/dispatch-once.m
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp?rev=285605&r1=285604&r2=285605&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp Mon Oct 31 
12:27:26 2016
@@ -33,6 +33,8 @@ namespace {
 class MacOSXAPIChecker : public Checker< check::PreStmt > {
   mutable std::unique_ptr BT_dispatchOnce;
 
+  static const ObjCIvarRegion *getParentIvarRegion(const MemRegion *R);
+
 public:
   void checkPreStmt(const CallExpr *CE, CheckerContext &C) const;
 
@@ -49,27 +51,34 @@ public:
 // dispatch_once and dispatch_once_f
 
//===--===//
 
+const ObjCIvarRegion *
+MacOSXAPIChecker::getParentIvarRegion(const MemRegion *R) {
+  const SubRegion *SR = dyn_cast(R);
+  while (SR) {
+if (const ObjCIvarRegion *IR = dyn_cast(SR))
+  return IR;
+SR = dyn_cast(SR->getSuperRegion());
+  }
+  return nullptr;
+}
+
 void MacOSXAPIChecker::CheckDispatchOnce(CheckerContext &C, const CallExpr *CE,
  StringRef FName) const {
   if (CE->getNumArgs() < 1)
 return;
 
-  // Check if the first argument is stack allocated.  If so, issue a warning
-  // because that's likely to be bad news.
-  ProgramStateRef state = C.getState();
-  const MemRegion *R =
-state->getSVal(CE->getArg(0), C.getLocationContext()).getAsRegion();
-  if (!R || !isa(R->getMemorySpace()))
+  // Check if the first argument is improperly allocated.  If so, issue a
+  // warning because that's likely to be bad news.
+  const MemRegion *R = C.getSVal(CE->getArg(0)).getAsRegion();
+  if (!R)
 return;
 
-  ExplodedNode *N = C.generateErrorNode(state);
-  if (!N)
+  // Global variables are fine.
+  const MemRegion *RB = R->getBaseRegion();
+  const MemSpaceRegion *RS = RB->getMemorySpace();
+  if (isa(RS))
 return;
 
-  if (!BT_dispatchOnce)
-BT_dispatchOnce.reset(new BugType(this, "Improper use of 'dispatch_once'",
-  "API Misuse (Apple)"));
-
   // Handle _dispatch_once.  In some versions of the OS X SDK we have the case
   // that dispatch_once is a macro that wraps a call to _dispatch_once.
   // _dispatch_once is then a function which then calls the real dispatch_once.
@@ -82,16 +91,40 @@ void MacOSXAPIChecker::CheckDispatchOnce
 
   SmallString<256> S;
   llvm::raw_svector_ostream os(S);
+  bool SuggestStatic = false;
   os << "Call to '" << FName << "' uses";
-  if (const VarRegion *VR = dyn_cast(R))
+  if (const VarRegion *VR = dyn_cast(RB)) {
+// We filtered out globals earlier, so it must be a local variable.
+if (VR != R)
+  os << " memory within";
 os << " the local variable '" << VR->getDecl()->getName() << '\'';
-  else
+SuggestStatic = true;
+  } else if (const ObjCIvarRegion *IVR = getParentIvarRegion(R)) {
+if (IVR != R)
+  os << " memory within";
+os << " the instance variable '" << IVR->getDecl()->getName() << '\'';
+  } else if (isa(RS)) {
+os << " heap-allocated memory";
+  } else if (isa(RS)) {
+// Presence of an IVar superregion has priority over this branch, because
+// ObjC objects are on the heap even if the core doesn't realize this.
+return;
+  } else {
 os << " stack allocated memory";
+  }
   os << " for the predicate value.  Using such transient memory for "
 "the predicate is potentially dangerous.";
-  if (isa(R) && isa(R->getMemorySpace()))
+  if (SuggestStatic)
 os << "  Perhaps you intended to declare the variable as 'static'?";
 
+  ExplodedNode *N = C.generateErrorNode();
+  if (!N)
+return;
+
+  if (!BT_dispatchOnce)
+BT_dispatchOnce.reset(new BugType(this, "Improper use of 'dispatch_once'",
+  "API Misuse (Apple)"));
+
   auto report = llvm::make_unique(*BT_dispatchOnce, os.str(), N);
   report->addRange(CE->getArg(0)->getSourceRange());
   C.emitReport(std::move(report));

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSVa

  1   2   >