r295710 - Fix lookup through injected-class-names in implicit deduction guides in the

2017-02-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Feb 21 02:42:39 2017
New Revision: 295710

URL: http://llvm.org/viewvc/llvm-project?rev=295710&view=rev
Log:
Fix lookup through injected-class-names in implicit deduction guides in the
case where the class template has a parameter pack.

Checking of the template arguments expects an "as-written" template argument
list, which in particular does not have any parameter packs. So flatten the
packs into separate arguments before passing them in.

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=295710&r1=295709&r2=295710&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Feb 21 02:42:39 2017
@@ -4957,11 +4957,17 @@ NamedDecl *Sema::FindInstantiatedDecl(So
 auto *Guide = dyn_cast(FD);
 if (Guide && Guide->isImplicit()) {
   TemplateDecl *TD = Guide->getDeducedTemplate();
+  // Convert the arguments to an "as-written" list.
   TemplateArgumentListInfo Args(Loc, Loc);
-  for (auto Arg : TemplateArgs.getInnermost().take_front(
-  TD->getTemplateParameters()->size()))
-Args.addArgument(
-getTrivialTemplateArgumentLoc(Arg, QualType(), Loc));
+  for (TemplateArgument Arg : TemplateArgs.getInnermost().take_front(
+TD->getTemplateParameters()->size())) {
+ArrayRef Unpacked(Arg);
+if (Arg.getKind() == TemplateArgument::Pack)
+  Unpacked = Arg.pack_elements();
+for (TemplateArgument UnpackedArg : Unpacked)
+  Args.addArgument(
+  getTrivialTemplateArgumentLoc(UnpackedArg, QualType(), Loc));
+  }
   QualType T = CheckTemplateIdType(TemplateName(TD), Loc, Args);
   if (T.isNull())
 return nullptr;

Modified: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp?rev=295710&r1=295709&r2=295710&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp 
(original)
+++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Tue Feb 
21 02:42:39 2017
@@ -194,9 +194,22 @@ namespace transform_params {
   A a(qn, qn); // expected-error {{no matching constructor for initialization 
of 'transform_params::A'}}
   static_assert(a.v == 12);
 
-  // FIXME: This should be accepted.
-  template struct B { // expected-note {{candidate}}
-template B(const T (&...p)[V]); // expected-note {{substitution 
failure}}
+  template struct B {
+template B(const T (&...p)[V]) {
+  constexpr int Vs[] = {V...};
+  static_assert(Vs[0] == 3 && Vs[1] == 4 && Vs[2] == 4);
+}
+static constexpr int (*p)(T...) = (int(*)(int, char, char))nullptr;
   };
-  B b({1, 2, 3}, {"foo", "bar"}, {'x', 'y', 'z', 'w'}); // expected-error {{no 
viable constructor or deduction guide}}
+  B b({1, 2, 3}, "foo", {'x', 'y', 'z', 'w'}); // ok
+
+  template struct C { // expected-note {{candidate}}
+template typename X>
+  C(X); // expected-note {{substitution failure [with T = <>, V = 
<0, 1, 2>]}}
+  };
+  template struct Y {};
+  // FIXME: This incorrectly deduces T = <>, rather than deducing
+  // T =  from the types of the elements of V.
+  // (This failure is not related to class template argument deduction.)
+  C c(Y<0, 1, 2>{}); // expected-error {{no viable constructor or deduction 
guide}}
 }


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


[PATCH] D30166: Honor __unaligned in codegen for declarations and expressions

2017-02-21 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 updated this revision to Diff 89172.
rogfer01 marked 2 inline comments as done.
rogfer01 added a comment.

Updated patch. Use TargetInfo::getCharWidth and remove unnecessary else.


https://reviews.llvm.org/D30166

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  test/CodeGen/unaligned-decl.c
  test/CodeGen/unaligned-expr.c
  test/CodeGen/unaligned-field.c
  test/CodeGenCXX/unaligned.cpp

Index: test/CodeGenCXX/unaligned.cpp
===
--- /dev/null
+++ test/CodeGenCXX/unaligned.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -triple x86_64-unknown-linux-gnu -fms-extensions -emit-llvm < %s | FileCheck %s
+
+int foo() {
+  // CHECK: ret i32 1
+  return alignof(__unaligned int);
+}
Index: test/CodeGen/unaligned-field.c
===
--- /dev/null
+++ test/CodeGen/unaligned-field.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fms-extensions -emit-llvm < %s | FileCheck %s
+// Test that __unaligned does not impact the layout of the fields.
+
+struct A
+{
+char a;
+__unaligned int b;
+} a;
+// CHECK: %struct.A = type { i8, i32 }
+
+struct A2
+{
+int b;
+char a;
+__unaligned int c;
+} a2;
+// CHECK: %struct.A2 = type { i32, i8, i32 }
Index: test/CodeGen/unaligned-expr.c
===
--- /dev/null
+++ test/CodeGen/unaligned-expr.c
@@ -0,0 +1,217 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fms-extensions -emit-llvm < %s | FileCheck %s
+
+// -
+// Scalar integer
+// -
+__unaligned int x;
+void test1(void) {
+  // CHECK: {{%.*}} = load i32, i32* @x, align 1
+  // CHECK: store i32 {{%.*}}, i32* @x, align 1
+  x++;
+}
+
+void test2(void) {
+  // CHECK: %y = alloca i32, align 1
+  // CHECK: {{%.*}} = load i32, i32* %y, align 1
+  // CHECK: store i32 {{%.*}}, i32* %y, align 1
+  __unaligned int y;
+  y++;
+}
+
+void test2_1(void) {
+  // CHECK: %y = alloca i32, align 1
+  // CHECK: store i32 1, i32* %y, align 1
+  __unaligned int y = 1;
+}
+
+// -
+// Global pointer
+// -
+int *__unaligned p1;
+void test3(void) {
+
+  // CHECK: {{%.*}} = load i32*, i32** @p1, align 1
+  // CHECK: {{%.*}} = load i32, i32* {{%.*}}, align 4
+  // CHECK: store i32 {{%.*}}, i32* {{%.*}}, align 4
+  (*p1)++;
+}
+
+int __unaligned *p2;
+void test4(void) {
+  // CHECK: {{%.*}} = load i32*, i32** @p2, align 8
+  // CHECK: {{%.*}} = load i32, i32* {{%.*}}, align 1
+  // CHECK: store i32 {{%.*}}, i32* {{%.*}}, align 1
+  (*p2)++;
+}
+
+int __unaligned *__unaligned p3;
+void test5(void) {
+  // CHECK: {{%.*}} = load i32*, i32** @p3, align 1
+  // CHECK: {{%.*}} = load i32, i32* {{%.*}}, align 1
+  // CHECK: store i32 {{%.*}}, i32* {{%.*}}, align 1
+  (*p3)++;
+}
+
+// -
+// Local pointer
+// -
+void test6(void) {
+  // CHECK: %lp1 = alloca i32*, align 1
+  // CHECK: {{%.*}} = load i32*, i32** %lp1, align 1
+  // CHECK: {{%.*}} = load i32, i32* {{%.*}}, align 4
+  // CHECK: store i32 {{%.*}}, i32* {{%.*}}, align 4
+  int *__unaligned lp1;
+  (*lp1)++;
+}
+
+void test7(void) {
+  // CHECK: %lp2 = alloca i32*, align 8
+  // CHECK: {{%.*}} = load i32*, i32** %lp2, align 8
+  // CHECK: {{%.*}} = load i32, i32* {{%.*}}, align 1
+  // CHECK: store i32 {{%.*}}, i32* {{%.*}}, align 1
+  int __unaligned *lp2;
+  (*lp2)++;
+}
+
+void test8(void) {
+  // CHECK: %lp3 = alloca i32*, align 1
+  // CHECK: {{%.*}} = load i32*, i32** %lp3, align 1
+  // CHECK: {{%.*}} = load i32, i32* {{%.*}}, align 1
+  // CHECK: store i32 {{%.*}}, i32* {{%.*}}, align 1
+  int __unaligned *__unaligned lp3;
+  (*lp3)++;
+}
+
+// -
+// Global array
+// -
+__unaligned int a[10];
+void test9(void) {
+  // CHECK: {{%.*}} = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @a, i64 0, i64 3), align 1
+  // CHECK: store i32 {{%.*}}, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @a, i64 0, i64 3), align 1
+  (a[3])++;
+}
+
+// -
+// Local array
+// -
+void test10(void) {
+  // CHECK: %la = alloca [10 x i32], align 1
+  // CHECK: {{%.*}} = getelementptr inbounds [10 x i32], [10 x i32]* %la, i64 0, i64 3
+  // CHECK: {{%.*}} = load i32, i32* {{%.*}}, align 1
+  // CHECK: store i32 {{%.*}}, i32* {{%.*}}, align 1
+  __unaligned int la[10];
+  (la[3])++;
+}
+
+// 
+// Typedefs
+// 
+
+typedef __unaligned int UnalignedInt;
+void test13() {
+  // CHECK: %i = alloca i32, align 1
+  // CHECK: {{%.*}} = load i32, i32* %i, align 1
+  // CHECK: store i32 {{%.*}}, i32* %i, align 1
+  UnalignedInt i;
+  i++;
+}
+
+typedef int Aligned;
+typedef __unaligned Aligned UnalignedInt2;
+void test14() {
+  // CHECK: %i = alloca i32, align 1
+  // CHECK: {{%.*}} = load i32, i32* %i, align 1
+  // CHECK: store i32 {{%.*}}, i32* %i, align 1
+  UnalignedInt2 i;
+  i++;
+}
+
+typede

[PATCH] D30191: [clang-tidy] Reword the "code outside header guard" warning.

2017-02-21 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer created this revision.
Herald added a subscriber: JDevlieghere.

The check doesn't really know if the code it is warning about came before
or after the header guard, so phrase it more neutral instead of complaining
about code before the header guard. The location for the warning is still
not optimal, but I don't think fixing that is worth the effort, the
preprocessor doesn't give us a better location.


https://reviews.llvm.org/D30191

Files:
  clang-tidy/utils/HeaderGuard.cpp
  unittests/clang-tidy/LLVMModuleTest.cpp

Index: unittests/clang-tidy/LLVMModuleTest.cpp
===
--- unittests/clang-tidy/LLVMModuleTest.cpp
+++ unittests/clang-tidy/LLVMModuleTest.cpp
@@ -12,11 +12,16 @@
 // FIXME: It seems this might be incompatible to dos path. Investigating.
 #if !defined(_WIN32)
 static std::string runHeaderGuardCheck(StringRef Code, const Twine &Filename,
-   unsigned ExpectedWarnings) {
+   Optional ExpectedWarning) {
   std::vector Errors;
   std::string Result = test::runCheckOnCode(
   Code, &Errors, Filename, std::string("-xc++-header"));
-  return Errors.size() == ExpectedWarnings ? Result : "invalid error count";
+  if (Errors.size() != (size_t)ExpectedWarning.hasValue())
+return "invalid error count";
+  if (ExpectedWarning && *ExpectedWarning != Errors.back().Message.Message)
+return "expected: '" + ExpectedWarning->str() + "', saw: '" +
+   Errors.back().Message.Message + "'";
+  return Result;
 }
 
 namespace {
@@ -27,68 +32,89 @@
 };
 } // namespace
 
-static std::string runHeaderGuardCheckWithEndif(StringRef Code,
-const Twine &Filename,
-unsigned ExpectedWarnings) {
+static std::string
+runHeaderGuardCheckWithEndif(StringRef Code, const Twine &Filename,
+ Optional ExpectedWarning) {
   std::vector Errors;
   std::string Result = test::runCheckOnCode(
   Code, &Errors, Filename, std::string("-xc++-header"));
-  return Errors.size() == ExpectedWarnings ? Result : "invalid error count";
+  if (Errors.size() != (size_t)ExpectedWarning.hasValue())
+return "invalid error count";
+  if (ExpectedWarning && *ExpectedWarning != Errors.back().Message.Message)
+return "expected: '" + ExpectedWarning->str() + "', saw: '" +
+   Errors.back().Message.Message + "'";
+  return Result;
 }
 
 TEST(LLVMHeaderGuardCheckTest, FixHeaderGuards) {
   EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n"
 "#define LLVM_ADT_FOO_H\n"
 "#endif\n",
-runHeaderGuardCheck("#ifndef FOO\n"
-"#define FOO\n"
-"#endif\n",
-"include/llvm/ADT/foo.h",
-/*ExpectedWarnings=*/1));
+runHeaderGuardCheck(
+"#ifndef FOO\n"
+"#define FOO\n"
+"#endif\n",
+"include/llvm/ADT/foo.h",
+StringRef("header guard does not follow preferred style")));
 
   // Allow trailing underscores.
   EXPECT_EQ("#ifndef LLVM_ADT_FOO_H_\n"
 "#define LLVM_ADT_FOO_H_\n"
 "#endif\n",
 runHeaderGuardCheck("#ifndef LLVM_ADT_FOO_H_\n"
 "#define LLVM_ADT_FOO_H_\n"
 "#endif\n",
-"include/llvm/ADT/foo.h",
-/*ExpectedWarnings=*/0));
+"include/llvm/ADT/foo.h", None));
 
   EXPECT_EQ("#ifndef LLVM_CLANG_C_BAR_H\n"
 "#define LLVM_CLANG_C_BAR_H\n"
 "\n"
 "\n"
 "#endif\n",
 runHeaderGuardCheck("", "./include/clang-c/bar.h",
-/*ExpectedWarnings=*/1));
+StringRef("header is missing header guard")));
 
   EXPECT_EQ("#ifndef LLVM_CLANG_LIB_CODEGEN_C_H\n"
 "#define LLVM_CLANG_LIB_CODEGEN_C_H\n"
 "\n"
 "\n"
 "#endif\n",
 runHeaderGuardCheck("", "tools/clang/lib/CodeGen/c.h",
-/*ExpectedWarnings=*/1));
+StringRef("header is missing header guard")));
 
   EXPECT_EQ("#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_X_H\n"
 "#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_X_H\n"
 "\n"
 "\n"
 "#endif\n",
 runHeaderGuardCheck("", "tools/clang/tools/extra/clang-tidy/x.h",
-/*ExpectedWarnings=*/1));
-
-  EXPECT_EQ("int foo;\n"
-"#ifndef LLVM_CLANG_BAR_H\n"
-"#define LLVM_CLANG_BAR_H\n"
-"#endif\n",
-runHeaderGuardCheck("int foo;\n"
-"#ifndef LLVM_CLANG_BAR_H\n"
-  

r295714 - [clang-format] Remove unused member variables from BreakableToken

2017-02-21 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Tue Feb 21 04:54:50 2017
New Revision: 295714

URL: http://llvm.org/viewvc/llvm-project?rev=295714&view=rev
Log:
[clang-format] Remove unused member variables from BreakableToken

Modified:
cfe/trunk/lib/Format/BreakableToken.cpp
cfe/trunk/lib/Format/BreakableToken.h

Modified: cfe/trunk/lib/Format/BreakableToken.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=295714&r1=295713&r2=295714&view=diff
==
--- cfe/trunk/lib/Format/BreakableToken.cpp (original)
+++ cfe/trunk/lib/Format/BreakableToken.cpp Tue Feb 21 04:54:50 2017
@@ -223,13 +223,11 @@ void BreakableStringLiteral::insertBreak
 
 BreakableComment::BreakableComment(const FormatToken &Token,
unsigned StartColumn,
-   unsigned OriginalStartColumn,
-   bool FirstInLine, bool InPPDirective,
+   bool InPPDirective,
encoding::Encoding Encoding,
const FormatStyle &Style)
 : BreakableToken(Token, InPPDirective, Encoding, Style),
-  StartColumn(StartColumn), OriginalStartColumn(OriginalStartColumn),
-  FirstInLine(FirstInLine) {}
+  StartColumn(StartColumn) {}
 
 unsigned BreakableComment::getLineCount() const { return Lines.size(); }
 
@@ -325,8 +323,7 @@ BreakableBlockComment::BreakableBlockCom
 const FormatToken &Token, unsigned StartColumn,
 unsigned OriginalStartColumn, bool FirstInLine, bool InPPDirective,
 encoding::Encoding Encoding, const FormatStyle &Style)
-: BreakableComment(Token, StartColumn, OriginalStartColumn, FirstInLine,
-   InPPDirective, Encoding, Style) {
+: BreakableComment(Token, StartColumn, InPPDirective, Encoding, Style) {
   assert(Tok.is(TT_BlockComment) &&
  "block comment section must start with a block comment");
 
@@ -664,8 +661,7 @@ BreakableLineCommentSection::BreakableLi
 const FormatToken &Token, unsigned StartColumn,
 unsigned OriginalStartColumn, bool FirstInLine, bool InPPDirective,
 encoding::Encoding Encoding, const FormatStyle &Style)
-: BreakableComment(Token, StartColumn, OriginalStartColumn, FirstInLine,
-   InPPDirective, Encoding, Style) {
+: BreakableComment(Token, StartColumn, InPPDirective, Encoding, Style) {
   assert(Tok.is(TT_LineComment) &&
  "line comment section must start with a line comment");
   FormatToken *LineTok = nullptr;

Modified: cfe/trunk/lib/Format/BreakableToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.h?rev=295714&r1=295713&r2=295714&view=diff
==
--- cfe/trunk/lib/Format/BreakableToken.h (original)
+++ cfe/trunk/lib/Format/BreakableToken.h Tue Feb 21 04:54:50 2017
@@ -210,12 +210,9 @@ class BreakableComment : public Breakabl
 protected:
   /// \brief Creates a breakable token for a comment.
   ///
-  /// \p StartColumn specifies the column in which the comment will start
-  /// after formatting, while \p OriginalStartColumn specifies in which
-  /// column the comment started before formatting.
-  /// If the comment starts a line after formatting, set \p FirstInLine to 
true.
+  /// \p StartColumn specifies the column in which the comment will start after
+  /// formatting.
   BreakableComment(const FormatToken &Token, unsigned StartColumn,
-   unsigned OriginalStartColumn, bool FirstInLine,
bool InPPDirective, encoding::Encoding Encoding,
const FormatStyle &Style);
 
@@ -275,13 +272,6 @@ protected:
   // The intended start column of the first line of text from this section.
   unsigned StartColumn;
 
-  // The original start column of the first line of text from this section.
-  unsigned OriginalStartColumn;
-
-  // Whether the first token of this section is the first token in its 
unwrapped
-  // line.
-  bool FirstInLine;
-
   // The prefix to use in front a line that has been reflown up.
   // For example, when reflowing the second line after the first here:
   // // comment 1


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


[PATCH] D30192: [Sema] Detecting more array index out of bounds

2017-02-21 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki created this revision.

Diagnose array index out of bounds when there is overloaded C++ operators also.


Repository:
  rL LLVM

https://reviews.llvm.org/D30192

Files:
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/array-bounds.cpp


Index: test/SemaCXX/array-bounds.cpp
===
--- test/SemaCXX/array-bounds.cpp
+++ test/SemaCXX/array-bounds.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -std=c++11 %s
 
 int foo() {
   int x[2]; // expected-note 4 {{array 'x' declared here}}
@@ -253,3 +253,19 @@
int a[128]; // expected-note {{array 'a' declared here}}
a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is 
past the end of the array}}
 }
+
+struct P {
+  int a;
+  int b;
+};
+
+void test_struct_array_index() {
+  struct P p[10]; // expected-note {{array 'p' declared here}}
+  p[11] = {0, 1}; // expected-warning {{array index 11 is past the end of the 
array (which contains 10 elements)}}
+}
+
+int operator+(const struct P &s1, const struct P &s2);
+int test_operator_overload_struct_array_index() {
+  struct P x[10] = {0}; // expected-note {{array 'x' declared here}}
+  return x[1] + x[11]; // expected-warning {{array index 11 is past the end of 
the array (which contains 10 elements)}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -10609,6 +10609,12 @@
   CheckArrayAccess(rhs);
 return;
   }
+  case Stmt::CXXOperatorCallExprClass: {
+const CXXOperatorCallExpr *OCE = cast(expr);
+for (auto Arg : OCE->arguments())
+  CheckArrayAccess(Arg);
+return;
+  }
   default:
 return;
 }


Index: test/SemaCXX/array-bounds.cpp
===
--- test/SemaCXX/array-bounds.cpp
+++ test/SemaCXX/array-bounds.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -std=c++11 %s
 
 int foo() {
   int x[2]; // expected-note 4 {{array 'x' declared here}}
@@ -253,3 +253,19 @@
 	int a[128]; // expected-note {{array 'a' declared here}}
 	a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is past the end of the array}}
 }
+
+struct P {
+  int a;
+  int b;
+};
+
+void test_struct_array_index() {
+  struct P p[10]; // expected-note {{array 'p' declared here}}
+  p[11] = {0, 1}; // expected-warning {{array index 11 is past the end of the array (which contains 10 elements)}}
+}
+
+int operator+(const struct P &s1, const struct P &s2);
+int test_operator_overload_struct_array_index() {
+  struct P x[10] = {0}; // expected-note {{array 'x' declared here}}
+  return x[1] + x[11]; // expected-warning {{array index 11 is past the end of the array (which contains 10 elements)}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -10609,6 +10609,12 @@
   CheckArrayAccess(rhs);
 return;
   }
+  case Stmt::CXXOperatorCallExprClass: {
+const CXXOperatorCallExpr *OCE = cast(expr);
+for (auto Arg : OCE->arguments())
+  CheckArrayAccess(Arg);
+return;
+  }
   default:
 return;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30191: [clang-tidy] Reword the "code outside header guard" warning.

2017-02-21 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thank you for the fix!


https://reviews.llvm.org/D30191



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


[PATCH] D30191: [clang-tidy] Reword the "code outside header guard" warning.

2017-02-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295715: [clang-tidy] Reword the "code outside header guard" 
warning. (authored by d0k).

Changed prior to commit:
  https://reviews.llvm.org/D30191?vs=89182&id=89184#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30191

Files:
  clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp
  clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp

Index: clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp
===
--- clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp
+++ clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp
@@ -223,19 +223,19 @@
 
   std::string CPPVar = Check->getHeaderGuard(FileName);
   std::string CPPVarUnder = CPPVar + '_'; // Allow a trailing underscore.
-  // If there is a header guard macro but it's not in the topmost position
-  // emit a plain warning without fix-its. This often happens when the guard
-  // macro is preceeded by includes.
+  // If there's a macro with a name that follows the header guard convention
+  // but was not recognized by the preprocessor as a header guard there must
+  // be code outside of the guarded area. Emit a plain warning without
+  // fix-its.
   // FIXME: Can we move it into the right spot?
   bool SeenMacro = false;
   for (const auto &MacroEntry : Macros) {
 StringRef Name = MacroEntry.first.getIdentifierInfo()->getName();
 SourceLocation DefineLoc = MacroEntry.first.getLocation();
 if ((Name == CPPVar || Name == CPPVarUnder) &&
 SM.isWrittenInSameFile(StartLoc, DefineLoc)) {
-  Check->diag(
-  DefineLoc,
-  "Header guard after code/includes. Consider moving it up.");
+  Check->diag(DefineLoc, "code/includes outside of area guarded by "
+ "header guard; consider moving it");
   SeenMacro = true;
   break;
 }
Index: clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp
===
--- clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp
+++ clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp
@@ -12,11 +12,16 @@
 // FIXME: It seems this might be incompatible to dos path. Investigating.
 #if !defined(_WIN32)
 static std::string runHeaderGuardCheck(StringRef Code, const Twine &Filename,
-   unsigned ExpectedWarnings) {
+   Optional ExpectedWarning) {
   std::vector Errors;
   std::string Result = test::runCheckOnCode(
   Code, &Errors, Filename, std::string("-xc++-header"));
-  return Errors.size() == ExpectedWarnings ? Result : "invalid error count";
+  if (Errors.size() != (size_t)ExpectedWarning.hasValue())
+return "invalid error count";
+  if (ExpectedWarning && *ExpectedWarning != Errors.back().Message.Message)
+return "expected: '" + ExpectedWarning->str() + "', saw: '" +
+   Errors.back().Message.Message + "'";
+  return Result;
 }
 
 namespace {
@@ -27,68 +32,89 @@
 };
 } // namespace
 
-static std::string runHeaderGuardCheckWithEndif(StringRef Code,
-const Twine &Filename,
-unsigned ExpectedWarnings) {
+static std::string
+runHeaderGuardCheckWithEndif(StringRef Code, const Twine &Filename,
+ Optional ExpectedWarning) {
   std::vector Errors;
   std::string Result = test::runCheckOnCode(
   Code, &Errors, Filename, std::string("-xc++-header"));
-  return Errors.size() == ExpectedWarnings ? Result : "invalid error count";
+  if (Errors.size() != (size_t)ExpectedWarning.hasValue())
+return "invalid error count";
+  if (ExpectedWarning && *ExpectedWarning != Errors.back().Message.Message)
+return "expected: '" + ExpectedWarning->str() + "', saw: '" +
+   Errors.back().Message.Message + "'";
+  return Result;
 }
 
 TEST(LLVMHeaderGuardCheckTest, FixHeaderGuards) {
   EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n"
 "#define LLVM_ADT_FOO_H\n"
 "#endif\n",
-runHeaderGuardCheck("#ifndef FOO\n"
-"#define FOO\n"
-"#endif\n",
-"include/llvm/ADT/foo.h",
-/*ExpectedWarnings=*/1));
+runHeaderGuardCheck(
+"#ifndef FOO\n"
+"#define FOO\n"
+"#endif\n",
+"include/llvm/ADT/foo.h",
+StringRef("header guard does not follow preferred style")));
 
   // Allow trailing underscores.
   EXPECT_EQ("#ifndef LLVM_ADT_FOO_H_\n"
 "#define LLVM_ADT_FOO_H_\n"
 "#endif\n",
 runHeaderGuardCheck("#ifndef LLVM_ADT_FOO_H_\n"
 

[clang-tools-extra] r295715 - [clang-tidy] Reword the "code outside header guard" warning.

2017-02-21 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Feb 21 05:25:45 2017
New Revision: 295715

URL: http://llvm.org/viewvc/llvm-project?rev=295715&view=rev
Log:
[clang-tidy] Reword the "code outside header guard" warning.

The check doesn't really know if the code it is warning about came before
or after the header guard, so phrase it more neutral instead of complaining
about code before the header guard. The location for the warning is still
not optimal, but I don't think fixing that is worth the effort, the
preprocessor doesn't give us a better location.

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

Modified:
clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp
clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp

Modified: clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp?rev=295715&r1=295714&r2=295715&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp Tue Feb 21 
05:25:45 2017
@@ -223,9 +223,10 @@ public:
 
   std::string CPPVar = Check->getHeaderGuard(FileName);
   std::string CPPVarUnder = CPPVar + '_'; // Allow a trailing underscore.
-  // If there is a header guard macro but it's not in the topmost position
-  // emit a plain warning without fix-its. This often happens when the 
guard
-  // macro is preceeded by includes.
+  // If there's a macro with a name that follows the header guard 
convention
+  // but was not recognized by the preprocessor as a header guard there 
must
+  // be code outside of the guarded area. Emit a plain warning without
+  // fix-its.
   // FIXME: Can we move it into the right spot?
   bool SeenMacro = false;
   for (const auto &MacroEntry : Macros) {
@@ -233,9 +234,8 @@ public:
 SourceLocation DefineLoc = MacroEntry.first.getLocation();
 if ((Name == CPPVar || Name == CPPVarUnder) &&
 SM.isWrittenInSameFile(StartLoc, DefineLoc)) {
-  Check->diag(
-  DefineLoc,
-  "Header guard after code/includes. Consider moving it up.");
+  Check->diag(DefineLoc, "code/includes outside of area guarded by "
+ "header guard; consider moving it");
   SeenMacro = true;
   break;
 }

Modified: clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp?rev=295715&r1=295714&r2=295715&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp Tue Feb 21 
05:25:45 2017
@@ -12,11 +12,16 @@ namespace test {
 // FIXME: It seems this might be incompatible to dos path. Investigating.
 #if !defined(_WIN32)
 static std::string runHeaderGuardCheck(StringRef Code, const Twine &Filename,
-   unsigned ExpectedWarnings) {
+   Optional ExpectedWarning) {
   std::vector Errors;
   std::string Result = test::runCheckOnCode(
   Code, &Errors, Filename, std::string("-xc++-header"));
-  return Errors.size() == ExpectedWarnings ? Result : "invalid error count";
+  if (Errors.size() != (size_t)ExpectedWarning.hasValue())
+return "invalid error count";
+  if (ExpectedWarning && *ExpectedWarning != Errors.back().Message.Message)
+return "expected: '" + ExpectedWarning->str() + "', saw: '" +
+   Errors.back().Message.Message + "'";
+  return Result;
 }
 
 namespace {
@@ -27,24 +32,30 @@ struct WithEndifComment : public LLVMHea
 };
 } // namespace
 
-static std::string runHeaderGuardCheckWithEndif(StringRef Code,
-const Twine &Filename,
-unsigned ExpectedWarnings) {
+static std::string
+runHeaderGuardCheckWithEndif(StringRef Code, const Twine &Filename,
+ Optional ExpectedWarning) {
   std::vector Errors;
   std::string Result = test::runCheckOnCode(
   Code, &Errors, Filename, std::string("-xc++-header"));
-  return Errors.size() == ExpectedWarnings ? Result : "invalid error count";
+  if (Errors.size() != (size_t)ExpectedWarning.hasValue())
+return "invalid error count";
+  if (ExpectedWarning && *ExpectedWarning != Errors.back().Message.Message)
+return "expected: '" + ExpectedWarning->str() + "', saw: '" +
+   Errors.back().Message.Message + "'";
+  return Result;
 }
 
 TEST(LLVMHeaderGuardCheckTest, FixHeaderGuards) {
   EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n"
 "#define LLVM_ADT_FOO_H\n"
 "#endif\n",
-runHeaderGuardCheck(

[PATCH] D28297: [StaticAnalyzer] Fix crash in CastToStructChecker

2017-02-21 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki reopened this revision.
danielmarjamaki added a comment.
This revision is now accepted and ready to land.

I reverted the change because there were buildbot failures.


Repository:
  rL LLVM

https://reviews.llvm.org/D28297



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


[PATCH] D30157: [analyzer] Improve valist check

2017-02-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 89185.
xazax.hun added a comment.

- Address some review comments.
- Add some additional tests.
- Fixed some false positives (checking for symbolic values for va_copy and more 
robust detection of which valist model is used by the platform)
- I have run the checker on https://github.com/rathena/rathena, there were no 
false positives or crashes using the current state. It is a 170KLOC C project.


https://reviews.llvm.org/D30157

Files:
  lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  test/Analysis/valist-uninitialized-no-undef.c
  test/Analysis/valist-uninitialized.c
  test/Analysis/valist-unterminated.c

Index: test/Analysis/valist-unterminated.c
===
--- test/Analysis/valist-unterminated.c
+++ test/Analysis/valist-unterminated.c
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -triple hexagon-unknown-linux -analyze -analyzer-checker=core,alpha.valist.Unterminated,alpha.valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,alpha.valist.Unterminated,alpha.valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
 
 #include "Inputs/system-header-simulator-for-valist.h"
@@ -28,9 +29,8 @@
 }
 
 void f5(va_list fst, ...) {
-  va_start(fst, fst);
-  //FIXME: this should cause a warning
-} // no-warning
+  va_start(fst, fst); // expected-note{{Initialized va_list}}
+} // expected-warning{{Initialized va_list}} expected-note{{Initialized va_list}}
 
 void f6(va_list *fst, ...) {
   va_start(*fst, fst); // expected-note{{Initialized va_list}}
Index: test/Analysis/valist-uninitialized.c
===
--- test/Analysis/valist-uninitialized.c
+++ test/Analysis/valist-uninitialized.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,alpha.valist.Uninitialized,alpha.valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -triple hexagon-unknown-linux -analyze -analyzer-checker=core,alpha.valist.Uninitialized,alpha.valist.CopyToSelf -analyzer-disable-checker=core.CallAndMessage -analyzer-output=text -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,alpha.valist.Uninitialized,alpha.valist.CopyToSelf -analyzer-disable-checker=core.CallAndMessage -analyzer-output=text -analyzer-store=region -verify %s
 
 #include "Inputs/system-header-simulator-for-valist.h"
 
@@ -38,13 +39,6 @@
   va_end(fst);
 } // no-warning
 
-//FIXME: this should not cause a warning
-void f6(va_list *fst, ...) {
-  va_start(*fst, fst);
-  (void)va_arg(*fst, int); //expected-warning{{va_arg() is called on an uninitialized va_list}} expected-note{{va_arg() is called on an uninitialized va_list}}
-  va_end(*fst);
-}
-
 void f7(int *fst, ...) {
   va_list x;
   va_list *y = &x;
@@ -141,38 +135,31 @@
   (void)va_arg(arg, int);
 } //no-warning
 
-// This is the same function as the previous one, but it is called in call_uses_arg2(),
-// and the warning is generated during the analysis of call_uses_arg2().
-void inlined_uses_arg(va_list arg) {
-  (void)va_arg(arg, int); //expected-warning{{va_arg() is called on an uninitialized va_list}} expected-note{{va_arg() is called on an uninitialized va_list}}
-}
-
-void call_inlined_uses_arg(int fst, ...) {
-  va_list va;
-  inlined_uses_arg(va); // expected-note{{Calling 'inlined_uses_arg'}}
-}
-
 void call_vprintf_ok(int isstring, ...) {
   va_list va;
   va_start(va, isstring);
   vprintf(isstring ? "%s" : "%d", va);
   va_end(va);
 } //no-warning
 
-void call_vprintf_bad(int isstring, ...) {
+void call_some_other_func(int n, ...) {
   va_list va;
-  vprintf(isstring ? "%s" : "%d", va); //expected-warning{{Function 'vprintf' is called with an uninitialized va_list argument}} expected-note{{Function 'vprintf' is called with an uninitialized va_list argument}} expected-note{{Assuming 'isstring' is 0}} expected-note{{'?' condition is false}}
-}
+  some_library_function(n, va);
+} //no-warning
 
-void call_vsprintf_bad(char *buffer, ...) {
-  va_list va;
-  va_start(va, buffer); // expected-note{{Initialized va_list}}
-  va_end(va); // expected-note{{Ended va_list}}
-  vsprintf(buffer, "%s %d %d %lf %03d", va); //expected-warning{{Function 'vsprintf' is called with an uninitialized va_list argument}} expected-note{{Function 'vsprintf' is called with an uninitialized va_list argument}}
+void inlined_uses_arg_good(va_list arg) {
+  (void)va_arg(arg, int);
 }
 
-void call_some_other_func(int n, ...) {
+void call_inlined_uses_arg_good(int fst, ...) {
   va_list va;
-  some_library_function(n, va);
-} //no-warning
+  va_start(va, fst);
+  inlined_uses_arg_good(va);
+  va_end(va);
+}
 
+void va_copy_test(va_list arg) {
+  va_list dst;
+  va_copy(dst, arg);
+  va_end(dst);
+}
Index: test/Analysis/valist-uninitialized-no-u

[PATCH] D30157: [analyzer] Improve valist check

2017-02-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked 3 inline comments as done.
xazax.hun added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/ValistChecker.cpp:178
+VaListModelledAsArray = Cast->getCastKind() == CK_ArrayToPointerDecay;
+  const MemRegion *Reg = SV.getAsRegion();
+  if (const auto *DeclReg = Reg->getAs()) {

NoQ wrote:
> I suspect that UnknownVal should also be handled before that, otherwise we'd 
> have null dereference on the next line.
Indeed. 



Comment at: test/Analysis/valist-uninitialized-no-undef.c:5
+
+// This is the same function as the previous one, but it is called in 
call_inlined_uses_arg(),
+// and the warning is generated during the analysis of call_inlined_uses_arg().

NoQ wrote:
> Hmm, where's the previous one?
Tha calling function is after this one. 



Comment at: test/Analysis/valist-uninitialized-no-undef.c:19
+  // FIXME: There should be no warning for this.
+  (void)va_arg(*fst, int); // expected-warning{{va_arg() is called on an 
uninitialized va_list}} expected-note{{va_arg() is called on an uninitialized 
va_list}}
+  va_end(*fst);

NoQ wrote:
> As the patch tries to handle symbolic va_list regions, i wonder what's so 
> particularly hard about this false positive (apart from its being obviously 
> rare, by the way did you actually see such code?).
What is strange, this case does work with the hexagon AST variant. 


https://reviews.llvm.org/D30157



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


[PATCH] D30157: [analyzer] Improve valist check

2017-02-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 89187.
xazax.hun marked 3 inline comments as done.
xazax.hun added a comment.

- Fixed a comment.


https://reviews.llvm.org/D30157

Files:
  lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  test/Analysis/valist-uninitialized-no-undef.c
  test/Analysis/valist-uninitialized.c
  test/Analysis/valist-unterminated.c

Index: test/Analysis/valist-unterminated.c
===
--- test/Analysis/valist-unterminated.c
+++ test/Analysis/valist-unterminated.c
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -triple hexagon-unknown-linux -analyze -analyzer-checker=core,alpha.valist.Unterminated,alpha.valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,alpha.valist.Unterminated,alpha.valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
 
 #include "Inputs/system-header-simulator-for-valist.h"
@@ -28,9 +29,8 @@
 }
 
 void f5(va_list fst, ...) {
-  va_start(fst, fst);
-  //FIXME: this should cause a warning
-} // no-warning
+  va_start(fst, fst); // expected-note{{Initialized va_list}}
+} // expected-warning{{Initialized va_list}} expected-note{{Initialized va_list}}
 
 void f6(va_list *fst, ...) {
   va_start(*fst, fst); // expected-note{{Initialized va_list}}
Index: test/Analysis/valist-uninitialized.c
===
--- test/Analysis/valist-uninitialized.c
+++ test/Analysis/valist-uninitialized.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,alpha.valist.Uninitialized,alpha.valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -triple hexagon-unknown-linux -analyze -analyzer-checker=core,alpha.valist.Uninitialized,alpha.valist.CopyToSelf -analyzer-disable-checker=core.CallAndMessage -analyzer-output=text -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,alpha.valist.Uninitialized,alpha.valist.CopyToSelf -analyzer-disable-checker=core.CallAndMessage -analyzer-output=text -analyzer-store=region -verify %s
 
 #include "Inputs/system-header-simulator-for-valist.h"
 
@@ -38,13 +39,6 @@
   va_end(fst);
 } // no-warning
 
-//FIXME: this should not cause a warning
-void f6(va_list *fst, ...) {
-  va_start(*fst, fst);
-  (void)va_arg(*fst, int); //expected-warning{{va_arg() is called on an uninitialized va_list}} expected-note{{va_arg() is called on an uninitialized va_list}}
-  va_end(*fst);
-}
-
 void f7(int *fst, ...) {
   va_list x;
   va_list *y = &x;
@@ -141,38 +135,31 @@
   (void)va_arg(arg, int);
 } //no-warning
 
-// This is the same function as the previous one, but it is called in call_uses_arg2(),
-// and the warning is generated during the analysis of call_uses_arg2().
-void inlined_uses_arg(va_list arg) {
-  (void)va_arg(arg, int); //expected-warning{{va_arg() is called on an uninitialized va_list}} expected-note{{va_arg() is called on an uninitialized va_list}}
-}
-
-void call_inlined_uses_arg(int fst, ...) {
-  va_list va;
-  inlined_uses_arg(va); // expected-note{{Calling 'inlined_uses_arg'}}
-}
-
 void call_vprintf_ok(int isstring, ...) {
   va_list va;
   va_start(va, isstring);
   vprintf(isstring ? "%s" : "%d", va);
   va_end(va);
 } //no-warning
 
-void call_vprintf_bad(int isstring, ...) {
+void call_some_other_func(int n, ...) {
   va_list va;
-  vprintf(isstring ? "%s" : "%d", va); //expected-warning{{Function 'vprintf' is called with an uninitialized va_list argument}} expected-note{{Function 'vprintf' is called with an uninitialized va_list argument}} expected-note{{Assuming 'isstring' is 0}} expected-note{{'?' condition is false}}
-}
+  some_library_function(n, va);
+} //no-warning
 
-void call_vsprintf_bad(char *buffer, ...) {
-  va_list va;
-  va_start(va, buffer); // expected-note{{Initialized va_list}}
-  va_end(va); // expected-note{{Ended va_list}}
-  vsprintf(buffer, "%s %d %d %lf %03d", va); //expected-warning{{Function 'vsprintf' is called with an uninitialized va_list argument}} expected-note{{Function 'vsprintf' is called with an uninitialized va_list argument}}
+void inlined_uses_arg_good(va_list arg) {
+  (void)va_arg(arg, int);
 }
 
-void call_some_other_func(int n, ...) {
+void call_inlined_uses_arg_good(int fst, ...) {
   va_list va;
-  some_library_function(n, va);
-} //no-warning
+  va_start(va, fst);
+  inlined_uses_arg_good(va);
+  va_end(va);
+}
 
+void va_copy_test(va_list arg) {
+  va_list dst;
+  va_copy(dst, arg);
+  va_end(dst);
+}
Index: test/Analysis/valist-uninitialized-no-undef.c
===
--- /dev/null
+++ test/Analysis/valist-uninitialized-no-undef.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,alpha.valist.Uninitialized,alpha.valist.CopyToSelf -analyzer-outp

Re: [PATCH] Improved plugin/tool support by expanding an existing attribute

2017-02-21 Thread Marcwell Helpdesk via cfe-commits
Friendly ping.

> On 14 feb 2017, at 12:05, Marcwell Helpdesk wrote:
> 
> The intention of the patch is to extend the functionality of annotations 
> while utilizing existing infrastructure in the AST and IR as much as 
> possible. Annotations are indeed a general purpose solution, sufficient for 
> many use cases, and a complement, not mutual exclusive to pluggable 
> attributes. And don’t forget the realm of AST tools. The compiler should not 
> perform any content checking of annotations but leave that to tool 
> implementations if it is used for other purposes than merely tags. For a more 
> complete support of annotations the AST and IR needs further work but this 
> patch is a step on the way.
> 
> Having pluggable attributes would be cool but it would face even greater 
> problems than you describe. Unless pluggable attributes involves writing 
> pluggable AST and IR modules the AST and IR must both support some form of 
> generic containers that could handle any type of attribute with any number of 
> parameters. In either case, it would most likely involve substantial 
> architectural changes to many parts.
> 
> I have revised the patch by adding a second, optional parameter that makes it 
> possible to group annotations, reducing the risk for collisions and since it 
> is optional it won’t break any existing code. A non-zero group string is 
> prepended to the value string when forwarded to IR. The C++11 attribute has 
> been moved to the clang namespace as requested and unit tests and 
> documentation are updated to reflect the changes.
> 
> Cheers,
> Chris
> 
> Modified
>   include/clang/Basic/Attr.td
>   include/clang/Basic/AttrDocs.td
>   lib/CodeGen/CodeGenFunction.cpp
>   lib/CodeGen/CodeGenModule.cpp
>   lib/CodeGen/CodeGenModule.h
>   lib/Sema/SemaDeclAttr.cpp
>   lib/Sema/SemaStmtAttr.cpp
>   test/Parser/access-spec-attrs.cpp
>   test/Sema/annotate.c
> 
> Added
>   test/CodeGenCXX/annotations-field.cpp
>   test/CodeGenCXX/annotations-global.cpp
>   test/CodeGenCXX/annotations-loc.cpp
>   test/CodeGenCXX/annotations-var.cpp
>   test/SemaCXX/attr-annotate.cpp
> 
> 
> 
>> On 9 feb 2017, at 15:07, Aaron Ballman  wrote:
>> 
>> On Sat, Feb 4, 2017 at 8:26 AM, Marcwell Helpdesk via cfe-commits
>>  wrote:
>>> Many plugins/tools could benefit from having a generic way for 
>>> communicating control directives directly from the source code to itself 
>>> (via the AST) when acting, for example, as source code transformers, 
>>> generators, collectors and the like. Attributes are a suitable way of doing 
>>> this but most available attributes have predefined functionality and 
>>> modifying the compiler for every plugin/tool is obviously not an option. 
>>> There is however one undocumented but existing attribute that could be used 
>>> for a generic solution if it was slightly modified and expanded - the 
>>> annotate attribute.
>>> 
>>> The current functionality of the annotate attribute encompass annotating 
>>> declarations with arbitrary strings using the GNU spelling. The attached 
>>> patch expands on this functionality by adding annotation of statements, 
>>> C++11 spelling and documentation. With the patch applied most of the code 
>>> could be annotated for the use by any Clang plugin or tool. For a more 
>>> detailed description of the updated attribute, see patch for "AttrDocs.td".
>> 
>> I definitely agree with the premise for this work -- having a generic
>> way for Clang to pass attributed information down to LLVM IR is
>> desirable. However, I'm not convinced that the annotate attribute is
>> the correct approach over something like pluggable attributes. My
>> primary concerns stem from the fact that the annotate attribute has no
>> safe guards for feature collisions (you have to pick a unique string,
>> or else you collide with someone else's string, but there's nothing
>> that forces you to do this), has no mechanisms for accepting arguments
>> in a consistent fashion, and provides no way to check the semantics of
>> the attribute. It's basically a minimum viable option for lowering
>> attributed information down to LLVM IR, which is fine for things that
>> aren't in the user's face, but isn't a good general-purpose solution.
>> 
>> I do not have a problem with adding a C++11 spelling to the annotate
>> attribute for the cases we already support, and I definitely think we
>> should document the attribute. But I don't think it makes sense to add
>> it as a statement attribute (and the current patch also leaves out
>> type attributes).
>> 
>> Some quick thoughts on the patch:
>> 
>>> Index: include/clang/Basic/Attr.td
>>> ===
>>> --- include/clang/Basic/Attr.td (revision 293612)
>>> +++ include/clang/Basic/Attr.td (working copy)
>>> @@ -462,9 +462,10 @@
>>> }
>>> 
>>> def Annotate : InheritableParamAttr {
>>> -  let Spellings = [GNU<"annotate">];
>>> +  let Spellings = [GNU<"annotate">,
>>> +   CXX11<"", 

[PATCH] D30157: [analyzer] Improve valist check

2017-02-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: test/Analysis/valist-uninitialized-no-undef.c:19
+  // FIXME: There should be no warning for this.
+  (void)va_arg(*fst, int); // expected-warning{{va_arg() is called on an 
uninitialized va_list}} expected-note{{va_arg() is called on an uninitialized 
va_list}}
+  va_end(*fst);

xazax.hun wrote:
> NoQ wrote:
> > As the patch tries to handle symbolic va_list regions, i wonder what's so 
> > particularly hard about this false positive (apart from its being obviously 
> > rare, by the way did you actually see such code?).
> What is strange, this case does work with the hexagon AST variant. 
Also, I did not see such code inproduction yet 


https://reviews.llvm.org/D30157



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


[PATCH] D29819: Introduce an 'external_source_symbol' attribute that describes the origin and the nature of a declaration

2017-02-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:1007
+
+defined_in=\ *string-literal*
+  The name of the source container in which the declaration was defined. The

arphaman wrote:
> aaron.ballman wrote:
> > Would this hold something like a file name? If so, I worry about conflicts 
> > between the comma separator and a file name -- you might want to pick a 
> > separator that can't be used in a file name (like | or :).
> It could potentially include a filename, yes.
> I don't quite follow your concerns though.. If a comma is in a string literal 
> then it's wrapped in quotes. Wouldn't that be enough to distinguish the comma 
> separator token from the comma in a filename?
You're correct, I had a brain fart. :-)



Comment at: include/clang/Basic/AttrDocs.td:1005
+language=\ *identifier*
+  The source language in which this declaration was defined.
+

This being an identifier makes me wonder about languages that aren't a single 
token. For instance, how do you specify Objective-C or Objective-C++? What 
about C++? Visual Basic .NET?

Perhaps this should also be a string literal.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2713
+  "|classes and enumerations"
+  "|named declarations}1">,
   InGroup;

I'm not too keen on this entry, because I'm not certain how many users really 
know what a "named declaration" is ("don't all declarations have names?" is a 
valid question for this to raise). However, I don't know of a better term to 
use, so it may be fine.



Comment at: include/clang/Parse/Parser.h:146
+  /// Identifiers used by the 'external_source_symbol' attribute.
+  IdentifierInfo *Ident_language, *Ident_defined_in,
+  *Ident_generated_declaration;

Can we handle identifiers that have spaces in the name? I'm thinking about the 
case where `Ident_defined_in` is something like `"My Long File Name With Spaces 
On Windows.cpp"`

We should have something like that as a test to make sure it's handled 
properly. Same with odd values for `Ident_language`, like 'c++' or 
'Objective-C', etc.



Comment at: lib/Parse/ParseDecl.cpp:1090
+  BalancedDelimiterTracker T(*this, tok::l_paren);
+  if (T.consumeOpen()) {
+Diag(Tok, diag::err_expected) << tok::l_paren;

`expectAndConsume()` instead of manually diagnosing?



Comment at: lib/Parse/ParseDecl.cpp:1160
+  }
+  if (!DefinedInExpr.isUnset()) {
+Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause)

As an interesting case: if the attribute has two `defined_in` arguments and the 
first one is invalid, they will not get a diagnostic about the second one being 
a duplicate. e.g., `__attribute__((external_source_symbol(defined_in = 
"1234"udl, defined_in = "1234")))`




Comment at: lib/Parse/ParseDeclCXX.cpp:3818-3819
+  if (ScopeName && (ScopeName->getName() == "gnu" ||
+(ScopeName->getName() == "clang" &&
+ AttrName->isStr("external_source_symbol"
 // GNU-scoped attributes have some special cases to handle GNU-specific

I don't really like hard-coding a list of attributes like this. I think you 
should handle clang-namespaced attributes with a separate helper function.



Comment at: lib/Sema/SemaDeclAttr.cpp:2414
+   const AttributeList &Attr) {
+  if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+return;

arphaman wrote:
> aaron.ballman wrote:
> > You should also diagnose if there's more than 3 arguments, no?
> I think an assert would be more appropriate since I only use up to 3 
> arguments when creating the attribute, so I wouldn't be able to test the 
> diagnostic.
An assert is fine by me, but please add a string literal after the assert to 
explain why it fails.



Comment at: lib/Sema/SemaDeclAttr.cpp:2420
+S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+<< Attr.getName() << /*Named declarations=*/45;
+return;

This is incorrect -- you need to update the enumeration at the end of 
AttributeList.h and use an enumerator rather than a magic literal value.



Comment at: test/Parser/attr-external-source-symbol.m:26
+void f6()
+__attribute__((external_source_symbol(defined_in=20))); // expected-error 
{{expected string literal for source container name in 'external_source_symbol' 
attribute}}

aaron.ballman wrote:
> I think you can currently get away with writing 
> `external_source_symbol(generated_declaration, generated_declaration, 
> generated_declaration, defined_in="module"))` and other odd combinations.
> 
> There should be additional parser tests for totally crazy parsing scenarios. 
> You may want to consider running a fuzzer to generate

[PATCH] D30035: Add const to function parameters

2017-02-21 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Absent I good motivation (i.e, a documented, significant performance change), I 
don't think we want this - not because it's not a reasonable change (it is!), 
but because it's an ABI break.

It's unfortunate the `__atoms` were not passed as const in the first place.
An alternate change would be to add a new local variable in these routines:

  const CharT *__cAtoms = __atoms;

and then use `__cAtoms` instead of `__atoms` in the routines.

But we should determine if this is a win, code-gen wise.


https://reviews.llvm.org/D30035



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


Re: [PATCH] Improved plugin/tool support by expanding an existing attribute

2017-02-21 Thread Aaron Ballman via cfe-commits
On Tue, Feb 14, 2017 at 6:05 AM, Marcwell Helpdesk  wrote:
> The intention of the patch is to extend the functionality of annotations
> while utilizing existing infrastructure in the AST and IR as much as
> possible. Annotations are indeed a general purpose solution, sufficient for
> many use cases, and a complement, not mutual exclusive to pluggable
> attributes. And don’t forget the realm of AST tools. The compiler should not
> perform any content checking of annotations but leave that to tool
> implementations if it is used for other purposes than merely tags. For a
> more complete support of annotations the AST and IR needs further work but
> this patch is a step on the way.
>
> Having pluggable attributes would be cool but it would face even greater
> problems than you describe. Unless pluggable attributes involves writing
> pluggable AST and IR modules the AST and IR must both support some form of
> generic containers that could handle any type of attribute with any number
> of parameters. In either case, it would most likely involve substantial
> architectural changes to many parts.

Pluggable attributes do not require these component up front (though
they could be explored for later iterations), but you are correct in
that they involve more work than simply piggy-backing off the annotate
attribute. However, that extra work comes with benefits that expanding
the annotate attribute will never realize with the end results being
roughly the same (the attribute metadata still gets passed down to the
LLVM IR and represented in a manner that AST tools can handle).

> I have revised the patch by adding a second, optional parameter that makes
> it possible to group annotations, reducing the risk for collisions and since
> it is optional it won’t break any existing code. A non-zero group string is
> prepended to the value string when forwarded to IR. The C++11 attribute has
> been moved to the clang namespace as requested and unit tests and
> documentation are updated to reflect the changes.

Can you please split this patch? The C++11 attribute name, associated
tests, and documentation of what the attribute does currently are not
controversial and those changes can go in pretty quickly if separated
from the greater discussion about how to allow generic, custom
attributes to be exposed.

~Aaron

>
> Cheers,
> Chris
>
> Modified
>   include/clang/Basic/Attr.td
>   include/clang/Basic/AttrDocs.td
>   lib/CodeGen/CodeGenFunction.cpp
>   lib/CodeGen/CodeGenModule.cpp
>   lib/CodeGen/CodeGenModule.h
>   lib/Sema/SemaDeclAttr.cpp
>   lib/Sema/SemaStmtAttr.cpp
>   test/Parser/access-spec-attrs.cpp
>   test/Sema/annotate.c
>
> Added
>   test/CodeGenCXX/annotations-field.cpp
>   test/CodeGenCXX/annotations-global.cpp
>   test/CodeGenCXX/annotations-loc.cpp
>   test/CodeGenCXX/annotations-var.cpp
>   test/SemaCXX/attr-annotate.cpp
>
>
>
> On 9 feb 2017, at 15:07, Aaron Ballman  wrote:
>
> On Sat, Feb 4, 2017 at 8:26 AM, Marcwell Helpdesk via cfe-commits
>  wrote:
>
> Many plugins/tools could benefit from having a generic way for communicating
> control directives directly from the source code to itself (via the AST)
> when acting, for example, as source code transformers, generators,
> collectors and the like. Attributes are a suitable way of doing this but
> most available attributes have predefined functionality and modifying the
> compiler for every plugin/tool is obviously not an option. There is however
> one undocumented but existing attribute that could be used for a generic
> solution if it was slightly modified and expanded - the annotate attribute.
>
> The current functionality of the annotate attribute encompass annotating
> declarations with arbitrary strings using the GNU spelling. The attached
> patch expands on this functionality by adding annotation of statements,
> C++11 spelling and documentation. With the patch applied most of the code
> could be annotated for the use by any Clang plugin or tool. For a more
> detailed description of the updated attribute, see patch for "AttrDocs.td".
>
>
> I definitely agree with the premise for this work -- having a generic
> way for Clang to pass attributed information down to LLVM IR is
> desirable. However, I'm not convinced that the annotate attribute is
> the correct approach over something like pluggable attributes. My
> primary concerns stem from the fact that the annotate attribute has no
> safe guards for feature collisions (you have to pick a unique string,
> or else you collide with someone else's string, but there's nothing
> that forces you to do this), has no mechanisms for accepting arguments
> in a consistent fashion, and provides no way to check the semantics of
> the attribute. It's basically a minimum viable option for lowering
> attributed information down to LLVM IR, which is fine for things that
> aren't in the user's face, but isn't a good general-purpose solution.
>
> I do not have a problem with adding a C++11 spelling to the annotate
> attr

[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/Attr.td:308-311
+  // - An attribute requires delayed parsing (LateParsed is on)
+  // - An attribute has no GNU/CXX11 spelling
+  // - An attribute has no subject list
+  // - An attribute derives from a StmtAttr or a TypeAttr

arphaman wrote:
> aaron.ballman wrote:
> > arphaman wrote:
> > > aaron.ballman wrote:
> > > > I have strong reservations about this -- users are going to have no 
> > > > idea what attributes are and are not supported because they're not 
> > > > going to know whether the attribute has a subject list or requires 
> > > > delayed parsing. We have a considerable number of attributes for which 
> > > > the Subjects line is currently commented out simply because no one has 
> > > > bothered to fix that. This means those attributes can't be used with 
> > > > this pragma until someone fixes that, but when it happens, they 
> > > > magically can be used, which is a good thing. But the converse is more 
> > > > problematic -- if there's an existing Subjects line that gets removed 
> > > > because a subject is added that is difficult to express in TableGen it 
> > > > may break user code.
> > > > 
> > > > We can fix the discoverability issues somewhat by updating the 
> > > > documentation emitter to spit out some wording that says when an 
> > > > attribute is/is not supported by this feature, but that only works for 
> > > > attributes which have documentation and so it's not a particularly 
> > > > reliable workaround.
> > > > I have strong reservations about this -- users are going to have no 
> > > > idea what attributes are and are not supported because they're not 
> > > > going to know whether the attribute has a subject list or requires 
> > > > delayed parsing. We have a considerable number of attributes for which 
> > > > the Subjects line is currently commented out simply because no one has 
> > > > bothered to fix that. This means those attributes can't be used with 
> > > > this pragma until someone fixes that, but when it happens, they 
> > > > magically can be used, which is a good thing. But the converse is more 
> > > > problematic -- if there's an existing Subjects line that gets removed 
> > > > because a subject is added that is difficult to express in TableGen it 
> > > > may break user code.
> > > 
> > > That's a good point. I think we can address this problem by creating a 
> > > test that verifies the list of attributes that support the pragma. This 
> > > would allow us to ensure that no attributes loose the ability to use the 
> > > pragma.
> > > 
> > > > We can fix the discoverability issues somewhat by updating the 
> > > > documentation emitter to spit out some wording that says when an 
> > > > attribute is/is not supported by this feature, but that only works for 
> > > > attributes which have documentation and so it's not a particularly 
> > > > reliable workaround.
> > > 
> > > We can enforce the rule that the attributes can only be used with 
> > > '#pragma clang attribute' when they're documented. This way we can ensure 
> > > that all attributes that can be used with the pragma are explicitly 
> > > documented.
> > > That's a good point. I think we can address this problem by creating a 
> > > test that verifies the list of attributes that support the pragma. This 
> > > would allow us to ensure that no attributes loose the ability to use the 
> > > pragma.
> > 
> > That would be good.
> > 
> > > We can enforce the rule that the attributes can only be used with 
> > > '#pragma clang attribute' when they're documented. This way we can ensure 
> > > that all attributes that can be used with the pragma are explicitly 
> > > documented.
> > 
> > This addresses the concern about discoverability, but it worsens the 
> > concerns about fragility. The biggest problem is: the user has very little 
> > hope of understanding what attributes will apply to what declarations with 
> > which version of the compiler they're using. With this sort of thing, the 
> > act of us adding documentation can impact the behavior of a user's program 
> > from one release to the next.
> > 
> > While I can imagine this pragma reducing some amount of code clutter, it is 
> > far too "magical" for me to feel comfortable with it (at least in the 
> > proposed form). I cannot read the user's source code and understand what 
> > attributes are going to be applied to which declarations, and that's not a 
> > good story for usability of the feature.
> What about the following idea:
> 
> The user has to include a **strict** set of declarations that receive the 
> attribute explicitly, e.g.:
> 
> ```
> #pragma clang attribute push([[noreturn]], apply_to={ function })
> ``` 
> 
> The compiler then would verify that the set of declarations (in this case 
> just `function`) is **strictly** identical to the built-in compiler-defined 
> set of declarations that can receive the attribute (i.e. t

[PATCH] D21815: [clang-tidy] Add 'included from' details to warning message.

2017-02-21 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Ping ;)
Do you have time to finish this?


https://reviews.llvm.org/D21815



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


[PATCH] D30170: Function definition may have uninstantiated body

2017-02-21 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 89206.
sepavloff added a comment.

Implement `isDefined` through `isThisDeclarationADefinition`.


https://reviews.llvm.org/D30170

Files:
  include/clang/AST/Decl.h
  lib/AST/Decl.cpp
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/cxx0x-cursory-default-delete.cpp
  test/SemaCXX/friend2.cpp

Index: test/SemaCXX/friend2.cpp
===
--- test/SemaCXX/friend2.cpp
+++ test/SemaCXX/friend2.cpp
@@ -101,6 +101,34 @@
   friend void func_12(int x = 0);  // expected-error{{friend declaration specifying a default argument must be the only declaration}}
 };
 
+// Friend function with uninstantiated body is still a definition.
+
+template struct C20 {
+  friend void func_20() {} // expected-note{{previous definition is here}}
+};
+C20 c20i;
+void func_20() {} // expected-error{{redefinition of 'func_20'}}
+
+template struct C21a {
+  friend void func_21() {} // expected-note{{previous definition is here}}
+};
+template struct C21b {
+  friend void func_21() {} // expected-error{{redefinition of 'func_21'}}
+};
+C21a c21ai;
+C21b c21bi; // expected-note{{in instantiation of template class 'C21b' requested here}}
+
+template struct C22a {
+  friend void func_22() {} // expected-note{{previous definition is here}}
+};
+template struct C22b {
+  friend void func_22();
+};
+C22a c22ai;
+C22b c22bi;
+void func_22() {} // expected-error{{redefinition of 'func_22'}}
+
+
 
 namespace pr22307 {
 
Index: test/SemaCXX/cxx0x-cursory-default-delete.cpp
===
--- test/SemaCXX/cxx0x-cursory-default-delete.cpp
+++ test/SemaCXX/cxx0x-cursory-default-delete.cpp
@@ -136,13 +136,13 @@
 };
 
 struct DefaultDelete {
-  DefaultDelete() = default; // expected-note {{previous declaration is here}}
+  DefaultDelete() = default; // expected-note {{previous definition is here}}
   DefaultDelete() = delete; // expected-error {{constructor cannot be redeclared}}
 
-  ~DefaultDelete() = default; // expected-note {{previous declaration is here}}
+  ~DefaultDelete() = default; // expected-note {{previous definition is here}}
   ~DefaultDelete() = delete; // expected-error {{destructor cannot be redeclared}}
 
-  DefaultDelete &operator=(const DefaultDelete &) = default; // expected-note {{previous declaration is here}}
+  DefaultDelete &operator=(const DefaultDelete &) = default; // expected-note {{previous definition is here}}
   DefaultDelete &operator=(const DefaultDelete &) = delete; // expected-error {{class member cannot be redeclared}}
 };
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11692,8 +11692,12 @@
SkipBodyInfo *SkipBody) {
   const FunctionDecl *Definition = EffectiveDefinition;
   if (!Definition)
-if (!FD->isDefined(Definition))
+if (!FD->isOdrDefined(Definition))
   return;
+  assert(Definition);
+
+  if (FD == Definition)
+return;
 
   if (canRedefineFunction(Definition, getLangOpts()))
 return;
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -2528,8 +2528,18 @@
 
 bool FunctionDecl::isDefined(const FunctionDecl *&Definition) const {
   for (auto I : redecls()) {
-if (I->IsDeleted || I->IsDefaulted || I->Body || I->IsLateTemplateParsed ||
-I->hasDefiningAttr()) {
+if (I->isThisDeclarationADefinition()) {
+  Definition = I->IsDeleted ? I->getCanonicalDecl() : I;
+  return true;
+}
+  }
+
+  return false;
+}
+
+bool FunctionDecl::isOdrDefined(const FunctionDecl *&Definition) const {
+  for (auto I : redecls()) {
+if (I->isThisDeclarationAnOdrDefinition()) {
   Definition = I->IsDeleted ? I->getCanonicalDecl() : I;
   return true;
 }
Index: include/clang/AST/Decl.h
===
--- include/clang/AST/Decl.h
+++ include/clang/AST/Decl.h
@@ -1781,32 +1781,104 @@
 
   SourceRange getSourceRange() const override LLVM_READONLY;
 
-  /// \brief Returns true if the function has a body (definition). The
-  /// function body might be in any of the (re-)declarations of this
-  /// function. The variant that accepts a FunctionDecl pointer will
-  /// set that function declaration to the actual declaration
-  /// containing the body (if there is one).
+  /// \name Definition and body checks
+  ///
+  /// A function declaration may be:
+  /// - a non defining declaration,
+  /// - a definition. A function may be defined because:
+  ///   - it has a body, or will have it in the case of late parsing.
+  ///   - it has an uninstantiated body. The body does not exist because the
+  /// function is not used yet, but the declaration is considered a
+  /// definition from viewpoint of ODR checks.
+  ///   - it does not have a user specified body, but it

[PATCH] D28771: [Analyzer] Various fixes for the IteratorPastEnd checker

2017-02-21 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 89211.
baloghadamsoftware added a comment.

checkBind replaces checking of DeclStmt, CXXConstructExpr and assignment 
operators. Incremention by 0 is not a bug anymore regardless the position of 
the iterator.


https://reviews.llvm.org/D28771

Files:
  lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/diagnostics/explicit-suppression.cpp
  test/Analysis/iterator-past-end.cpp

Index: test/Analysis/iterator-past-end.cpp
===
--- test/Analysis/iterator-past-end.cpp
+++ test/Analysis/iterator-past-end.cpp
@@ -203,3 +203,50 @@
 start = ++item; // no-warning
   }
 }
+
+void good_overwrite(std::vector &vec) {
+  auto i = vec.end();
+  i = vec.begin();
+  *i; // no-warning
+}
+
+void good_overwrite_find(std::vector &vec, int e) {
+  auto i = std::find(vec.begin(), vec.end(), e);
+  if(i == vec.end()) {
+i = vec.begin();
+  }
+  *i; // no-warning
+}
+
+void bad_overwrite(std::vector &vec) {
+  auto i = vec.begin();
+  i = vec.end();
+  *i; // expected-warning{{Iterator accessed past its end}}
+}
+
+void bad_overwrite_find(std::vector &vec, int e) {
+  auto i = std::find(vec.begin(), vec.end(), e);
+  if(i != vec.end()) {
+i = vec.begin();
+  }
+  *i; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_advance(std::vector &vec) {
+  auto i = vec.end();
+  std::advance(i, -1);
+  *i; // no-warning
+}
+
+void good_prev(std::vector &vec) {
+  auto i = std::prev(vec.end());
+  *i; // no-warning
+}
+
+void front(const std::vector &vec) {
+  vec.front();
+}
+
+void back(const std::vector &vec) {
+  vec.back();
+}
Index: test/Analysis/diagnostics/explicit-suppression.cpp
===
--- test/Analysis/diagnostics/explicit-suppression.cpp
+++ test/Analysis/diagnostics/explicit-suppression.cpp
@@ -18,6 +18,6 @@
 void testCopyNull(C *I, C *E) {
   std::copy(I, E, (C *)0);
 #ifndef SUPPRESSED
-  // expected-warning@../Inputs/system-header-simulator-cxx.h:191 {{Called C++ object pointer is null}}
+  // expected-warning@../Inputs/system-header-simulator-cxx.h:303 {{Called C++ object pointer is null}}
 #endif
 }
Index: test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- test/Analysis/Inputs/system-header-simulator-cxx.h
+++ test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -8,18 +8,60 @@
 typedef unsigned char uint8_t;
 
 typedef __typeof__(sizeof(int)) size_t;
+typedef __typeof__((char*)0-(char*)0) ptrdiff_t;
 void *memmove(void *s1, const void *s2, size_t n);
 
-template  struct __iterator {
-  typedef __iterator iterator;
-  typedef __iterator const_iterator;
+namespace std {
+  struct input_iterator_tag { };
+  struct output_iterator_tag { };
+  struct forward_iterator_tag : public input_iterator_tag { };
+  struct bidirectional_iterator_tag : public forward_iterator_tag { };
+  struct random_access_iterator_tag : public bidirectional_iterator_tag { };
 
-  __iterator(const Ptr p) : ptr(p) {}
+  template  struct iterator_traits {
+typedef typename Iterator::difference_type difference_type;
+typedef typename Iterator::value_type value_type;
+typedef typename Iterator::pointer pointer;
+typedef typename Iterator::reference reference;
+typedef typename Iterator::iterator_category iterator_category;
+  };
+}
+
+template  struct __vector_iterator {
+  typedef __vector_iterator iterator;
+  typedef __vector_iterator const_iterator;
+
+  typedef ptrdiff_t difference_type;
+  typedef T value_type;
+  typedef Ptr pointer;
+  typedef Ref reference;
+  typedef std::random_access_iterator_tag iterator_category;
+
+  __vector_iterator(const Ptr p) : ptr(p) {}
+  __vector_iterator operator++() { ++ ptr; return *this; }
+  __vector_iterator operator++(int) {
+auto tmp = *this;
+++ ptr;
+return tmp;
+  }
+  __vector_iterator operator--() { -- ptr; return *this; }
+  __vector_iterator operator--(int) {
+auto tmp = *this; -- ptr;
+return tmp;
+  }
+  __vector_iterator operator+(difference_type n) {
+return ptr + n;
+  }
+  __vector_iterator operator-(difference_type n) {
+return ptr - n;
+  }
+  __vector_iterator operator+=(difference_type n) {
+return ptr += n;
+  }
+  __vector_iterator operator-=(difference_type n) {
+return ptr -= n;
+  }
 
-  __iterator operator++() { return *this; }
-  __iterator operator++(int) { return *this; }
-  __iterator operator--() { return *this; }
-  __iterator operator--(int) { return *this; }
   Ref operator*() const { return *ptr; }
   Ptr operator->() const { return *ptr; }
 
@@ -33,7 +75,45 @@
   Ptr ptr;
 };
 
+template  struct __list_iterator {
+  typedef __vector_iterator iterator;
+  typedef __vector_iterator const_iterator;
+
+  typedef ptrdiff_t difference_type;
+  typedef T value_type;
+  typedef Ptr poin

[PATCH] D28771: [Analyzer] Various fixes for the IteratorPastEnd checker

2017-02-21 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:530
+  auto value = RVal;
+  if (auto loc = value.getAs()) {
+value = State->getRawSVal(*loc);

NoQ wrote:
> baloghadamsoftware wrote:
> > NoQ wrote:
> > > baloghadamsoftware wrote:
> > > > NoQ wrote:
> > > > > Is there a test case for this hack?
> > > > > 
> > > > > I'd also consider inspecting the AST (probably before passing the 
> > > > > values to `handleRandomIncrOrDecr()`) and making the decision based 
> > > > > on that. Because even though this pattern ("if a value is a loc and 
> > > > > we expect a nonloc, do an extra dereference") is present in many 
> > > > > places in the analyzer, in most of these places it doesn't work 
> > > > > correctly (what if we try to discriminate between `int*` and 
> > > > > `int*&`?).
> > > > I just want to get the sign of the integer value (if it is available). 
> > > > It turned out that I cannot do comparison between loc and nonloc. 
> > > > (Strange, because I can do anything else). After I created this hack, 
> > > > the Analyzer did not crash anymore on the llvm/clang code.
> > > > 
> > > > I do not fully understand what I should fix here and how? In this 
> > > > particular place we expect some integer, thus no int* or int*&.
> > > Loc value, essentially, *is* a pointer or reference value. If you're 
> > > getting a Loc, then your expectations of an integer are not met in the 
> > > actual code. In this case you *want* to know why they are not met, 
> > > otherwise you may avoid the crash, but do incorrect things and run into 
> > > false positives. So i'd rather have this investigated carefully.
> > > 
> > > You say that you are crashing otherwise - and then it should be trivial 
> > > for you to attach a debugger and `dump()` the expression for which you 
> > > expect to take the integer value, and see why it suddenly has a pointer 
> > > type in a particular case. From that you'd easily see what to do.
> > > 
> > > Also, crashes are often easy to auto-reduce using tools like `creduce`. 
> > > Unlike false positives, which may turn into true positives during 
> > > reduction.
> > > 
> > > If you still don't see the reason why your workaround is necessary and 
> > > what exactly it does, could you attach a preprocessed file and an 
> > > analyzer runline for the crash, so that we could have a look together?
> > Just to be clear: I know why it crashes without the hack: I simply cannot 
> > compare loc and nonloc. Since concrete 0 is nonloc I need another nonloc. I 
> > suppose this happens if an integer reference is passed to the operator +, 
> > +=, - or -=. So I thought that dereferencing it by getting the raw SVal is 
> > the correct thing to do.
> Yep, in this case the correct thing to do would be to check AST types rather 
> than SVal types. Eg.,
> ```
> if (Arg->getType()->isReferenceType())
>  value = State->getRawSVal(*loc);
> ```
> 
> (you might need to do it in the caller function, which still has access to 
> the expressions)
> 
> It is better this way because expectations are explicitly stated, and the 
> assertion would still catch the situation when expectations are not met.
> 
> Also, please still add a test case to cover this branch :)
I tried it and failed in std::vector::back(). It seems that the problem is not 
the reference, but loc::ConcreteInt. I added a test case, but in our mocked 
vector the integer 1 in *(end()-1) is nonloc::ConcreteInt, but in the real one 
it is loc::ConcreteInt. I do not see why is there a difference, neither do I 
know how could something be a location and a concrete integer at once. What is 
loc::ConcreteInt and what to do with it?


https://reviews.llvm.org/D28771



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


[PATCH] D29032: [mips] Define macros related to -mabicalls in the preprocessor

2017-02-21 Thread Simon Dardis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295728: [mips] Define macros related to -mabicalls in the 
preprocessor (authored by sdardis).

Changed prior to commit:
  https://reviews.llvm.org/D29032?vs=85392&id=89219#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29032

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Preprocessor/init.c

Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -3040,6 +3040,7 @@
 // MIPS32BE:#define __llvm__ 1
 // MIPS32BE:#define __mips 32
 // MIPS32BE:#define __mips__ 1
+// MIPS32BE:#define __mips_abicalls 1
 // MIPS32BE:#define __mips_fpr 32
 // MIPS32BE:#define __mips_hard_float 1
 // MIPS32BE:#define __mips_o32 1
@@ -3246,6 +3247,7 @@
 // MIPS32EL:#define __llvm__ 1
 // MIPS32EL:#define __mips 32
 // MIPS32EL:#define __mips__ 1
+// MIPS32EL:#define __mips_abicalls 1
 // MIPS32EL:#define __mips_fpr 32
 // MIPS32EL:#define __mips_hard_float 1
 // MIPS32EL:#define __mips_o32 1
@@ -3555,6 +3557,7 @@
 // MIPSN32BE: #define __mips64 1
 // MIPSN32BE: #define __mips64__ 1
 // MIPSN32BE: #define __mips__ 1
+// MIPSN32BE: #define __mips_abicalls 1
 // MIPSN32BE: #define __mips_fpr 64
 // MIPSN32BE: #define __mips_hard_float 1
 // MIPSN32BE: #define __mips_isa_rev 2
@@ -3861,6 +3864,7 @@
 // MIPSN32EL: #define __mips64 1
 // MIPSN32EL: #define __mips64__ 1
 // MIPSN32EL: #define __mips__ 1
+// MIPSN32EL: #define __mips_abicalls 1
 // MIPSN32EL: #define __mips_fpr 64
 // MIPSN32EL: #define __mips_hard_float 1
 // MIPSN32EL: #define __mips_isa_rev 2
@@ -4073,6 +4077,7 @@
 // MIPS64BE:#define __mips64 1
 // MIPS64BE:#define __mips64__ 1
 // MIPS64BE:#define __mips__ 1
+// MIPS64BE:#define __mips_abicalls 1
 // MIPS64BE:#define __mips_fpr 64
 // MIPS64BE:#define __mips_hard_float 1
 // MIPS64BE:#define __mips_n64 1
@@ -4282,6 +4287,7 @@
 // MIPS64EL:#define __mips64 1
 // MIPS64EL:#define __mips64__ 1
 // MIPS64EL:#define __mips__ 1
+// MIPS64EL:#define __mips_abicalls 1
 // MIPS64EL:#define __mips_fpr 64
 // MIPS64EL:#define __mips_hard_float 1
 // MIPS64EL:#define __mips_n64 1
@@ -4513,6 +4519,45 @@
 // MIPS-XXR6:#define __mips_fpr 64
 // MIPS-XXR6:#define __mips_nan2008 1
 //
+// RUN: %clang_cc1 -target-cpu mips32 \
+// RUN:   -E -dM -triple=mips-unknown-netbsd -mrelocation-model pic < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix MIPS-ABICALLS-NETBSD %s
+// MIPS-ABICALLS-NETBSD-NOT: #define __ABICALLS__ 1
+// MIPS-ABICALLS-NETBSD: #define __mips_abicalls 1
+//
+// RUN: %clang_cc1 -target-cpu mips64 \
+// RUN:   -E -dM -triple=mips64-unknown-netbsd -mrelocation-model pic < \
+// RUN:   /dev/null | FileCheck -match-full-lines \
+// RUN:   -check-prefix MIPS-ABICALLS-NETBSD64 %s
+// MIPS-ABICALLS-NETBSD64-NOT: #define __ABICALLS__ 1
+// MIPS-ABICALLS-NETBSD64: #define __mips_abicalls 1
+//
+// RUN: %clang_cc1 -target-cpu mips32 \
+// RUN:   -E -dM -triple=mips-unknown-freebsd -mrelocation-model pic < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix MIPS-ABICALLS-FREEBSD %s
+// MIPS-ABICALLS-FREEBSD: #define __ABICALLS__ 1
+// MIPS-ABICALLS-FREEBSD: #define __mips_abicalls 1
+//
+// RUN: %clang_cc1 -target-cpu mips64 \
+// RUN:   -E -dM -triple=mips64-unknown-freebsd -mrelocation-model pic < \
+// RUN:   /dev/null | FileCheck -match-full-lines \
+// RUN:   -check-prefix MIPS-ABICALLS-FREEBSD64 %s
+// MIPS-ABICALLS-FREEBSD64: #define __ABICALLS__ 1
+// MIPS-ABICALLS-FREEBSD64: #define __mips_abicalls 1
+//
+// RUN: %clang_cc1 -target-cpu mips32 \
+// RUN:   -E -dM -triple=mips-unknown-openbsd -mrelocation-model pic < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix MIPS-ABICALLS-OPENBSD %s
+// MIPS-ABICALLS-OPENBSD: #define __ABICALLS__ 1
+// MIPS-ABICALLS-OPENBSD: #define __mips_abicalls 1
+//
+// RUN: %clang_cc1 -target-cpu mips64 \
+// RUN:   -E -dM -triple=mips64-unknown-openbsd -mrelocation-model pic < \
+// RUN:   /dev/null | FileCheck -match-full-lines \
+// RUN:   -check-prefix MIPS-ABICALLS-OPENBSD64 %s
+// MIPS-ABICALLS-OPENBSD64: #define __ABICALLS__ 1
+// MIPS-ABICALLS-OPENBSD64: #define __mips_abicalls 1
+//
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=msp430-none-none < /dev/null | FileCheck -match-full-lines -check-prefix MSP430 %s
 // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=msp430-none-none < /dev/null | FileCheck -match-full-lines -check-prefix MSP430 -check-prefix MSP430-CXX %s
 //
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -7464,6 +7464,8 @@
   bool IsMicromips;
   bool IsNan2008;
   bool IsSingleFloat;
+  bool IsNoABICalls;
+  bool CanUseBSDABICalls;
   enum MipsFloatABI {
 HardFloat, SoftFloat
   } FloatABI;
@@ -7479,16 +7481,20 @@
 public:
   MipsTarge

r295728 - [mips] Define macros related to -mabicalls in the preprocessor

2017-02-21 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Tue Feb 21 10:01:00 2017
New Revision: 295728

URL: http://llvm.org/viewvc/llvm-project?rev=295728&view=rev
Log:
[mips] Define macros related to -mabicalls in the preprocessor

Summary:
Historically, NetBSD, FreeBSD and OpenBSD have defined the macro ABICALLS in
the preprocessor when -mabicalls is in effect.

Mainline GCC later defined __mips_abicalls when -mabicalls is in effect.

This patch teaches the preprocessor to define these macros when appropriate.

NetBSD does not require the ABICALLS macro.

This resolves PR/31694.

Thanks to Sean Bruno for highlighting this issue!

Reviewers: slthakur, seanbruno

Reviewed By: seanbruno

Subscribers: joerg, brad, emaste, seanbruno, cfe-commits

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


Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=295728&r1=295727&r2=295728&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Feb 21 10:01:00 2017
@@ -7464,6 +7464,8 @@ class MipsTargetInfo : public TargetInfo
   bool IsMicromips;
   bool IsNan2008;
   bool IsSingleFloat;
+  bool IsNoABICalls;
+  bool CanUseBSDABICalls;
   enum MipsFloatABI {
 HardFloat, SoftFloat
   } FloatABI;
@@ -7479,8 +7481,9 @@ protected:
 public:
   MipsTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), IsMips16(false), IsMicromips(false),
-IsNan2008(false), IsSingleFloat(false), FloatABI(HardFloat),
-DspRev(NoDSP), HasMSA(false), HasFP64(false) {
+IsNan2008(false), IsSingleFloat(false), IsNoABICalls(false),
+CanUseBSDABICalls(false), FloatABI(HardFloat), DspRev(NoDSP),
+HasMSA(false), HasFP64(false) {
 TheCXXABI.set(TargetCXXABI::GenericMIPS);
 
 setABI((getTriple().getArch() == llvm::Triple::mips ||
@@ -7489,6 +7492,9 @@ public:
: "n64");
 
 CPU = ABI == "o32" ? "mips32r2" : "mips64r2";
+
+CanUseBSDABICalls = Triple.getOS() == llvm::Triple::FreeBSD ||
+Triple.getOS() == llvm::Triple::OpenBSD;
   }
 
   bool isNaN2008Default() const {
@@ -7669,6 +7675,12 @@ public:
 } else
   llvm_unreachable("Invalid ABI.");
 
+if (!IsNoABICalls) {
+  Builder.defineMacro("__mips_abicalls");
+  if (CanUseBSDABICalls)
+Builder.defineMacro("__ABICALLS__");
+}
+
 Builder.defineMacro("__REGISTER_PREFIX__", "");
 
 switch (FloatABI) {
@@ -7883,6 +7895,8 @@ public:
 IsNan2008 = true;
   else if (Feature == "-nan2008")
 IsNan2008 = false;
+  else if (Feature == "+noabicalls")
+IsNoABICalls = true;
 }
 
 setDataLayout();

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=295728&r1=295727&r2=295728&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Tue Feb 21 10:01:00 2017
@@ -3040,6 +3040,7 @@
 // MIPS32BE:#define __llvm__ 1
 // MIPS32BE:#define __mips 32
 // MIPS32BE:#define __mips__ 1
+// MIPS32BE:#define __mips_abicalls 1
 // MIPS32BE:#define __mips_fpr 32
 // MIPS32BE:#define __mips_hard_float 1
 // MIPS32BE:#define __mips_o32 1
@@ -3246,6 +3247,7 @@
 // MIPS32EL:#define __llvm__ 1
 // MIPS32EL:#define __mips 32
 // MIPS32EL:#define __mips__ 1
+// MIPS32EL:#define __mips_abicalls 1
 // MIPS32EL:#define __mips_fpr 32
 // MIPS32EL:#define __mips_hard_float 1
 // MIPS32EL:#define __mips_o32 1
@@ -3555,6 +3557,7 @@
 // MIPSN32BE: #define __mips64 1
 // MIPSN32BE: #define __mips64__ 1
 // MIPSN32BE: #define __mips__ 1
+// MIPSN32BE: #define __mips_abicalls 1
 // MIPSN32BE: #define __mips_fpr 64
 // MIPSN32BE: #define __mips_hard_float 1
 // MIPSN32BE: #define __mips_isa_rev 2
@@ -3861,6 +3864,7 @@
 // MIPSN32EL: #define __mips64 1
 // MIPSN32EL: #define __mips64__ 1
 // MIPSN32EL: #define __mips__ 1
+// MIPSN32EL: #define __mips_abicalls 1
 // MIPSN32EL: #define __mips_fpr 64
 // MIPSN32EL: #define __mips_hard_float 1
 // MIPSN32EL: #define __mips_isa_rev 2
@@ -4073,6 +4077,7 @@
 // MIPS64BE:#define __mips64 1
 // MIPS64BE:#define __mips64__ 1
 // MIPS64BE:#define __mips__ 1
+// MIPS64BE:#define __mips_abicalls 1
 // MIPS64BE:#define __mips_fpr 64
 // MIPS64BE:#define __mips_hard_float 1
 // MIPS64BE:#define __mips_n64 1
@@ -4282,6 +4287,7 @@
 // MIPS64EL:#define __mips64 1
 // MIPS64EL:#define __mips64__ 1
 // MIPS64EL:#define __mips__ 1
+// MIPS64EL:#define __mips_abicalls 1
 // MIPS64EL:#define __mips_fpr 64
 // MIPS64EL:#define __mips_hard_float 1
 // MIPS64EL:#define __mips_n64 1
@@ -4513,6 +4519,45 @@
 // MIPS-XXR6:#define __mips_fpr 64
 // MIPS-XXR6:#define __mips_nan2008 1
 //
+// RUN: %clang_cc

[PATCH] D30135: [OpenMP] Generate better diagnostics for cancel and cancellation point

2017-02-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D30135



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


[PATCH] D27689: Module: hash the pcm content and use it as SIGNATURE for implicit modules.

2017-02-21 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Ping.


https://reviews.llvm.org/D27689



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


[PATCH] D30174: [Sema][ObjC] Warn about 'performSelector' calls with selectors that return record types

2017-02-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D30174#681890, @ahatanak wrote:

> In https://reviews.llvm.org/D30174#681843, @arphaman wrote:
>
> > Yes, we do. Primarily for the following reason: even if some target may 
> > return a struct in a register, another target isn't guaranteed to do the 
> > same thing. It's better to always warn about this rather than accept some 
> > small structs. Furthermore, the official documentation states that "For 
> > methods that return anything other than an object, use NSInvocation." [1], 
> > so methods that return records are completely prohibited by the docs.
>
>
> OK, I think you are right. It doesn't seem like a good idea to warn when 
> compiling for one target and not warn when compiling for another target.
>
> If the official documentation says the method should return an object, why 
> not prohibit all methods that don't return a pointer to an object (methods 
> like returnsInt in the test case)? Doing so will also take care of methods 
> that don't return struct but still return via sret (for example, I think some 
> targets return vectors via sret).


I think it would catch too many "false positives" if we prohibit all primitive 
types. This might make the warning less effective as well, since users might 
get annoyed and completely disable the warning if they think that it's too 
strict. Maybe we can have a stricter version of the warning that's not on by 
default? I agree that we can warn on vectors as well though.

> Also, the documentation says that methods passed to 
> performSelectorInBackground and performSelectorOnMainThread should not have a 
> significant return value. Does it mean that the methods can have any return 
> type but the return value will be ignored (I noticed that those two methods 
> return "void" unlike performSelector which returns "id")?

No, they still use objc_msgSend, so the memory corruption problem still applies 
to them as they can write to the object thinking that it's the pointer to the 
return value. The fact that `performSelectorInBackground` and 
`performSelectorOnMainThread` don't return anything doesn't really make a 
difference.


Repository:
  rL LLVM

https://reviews.llvm.org/D30174



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


[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.

2017-02-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.

Add usage count to find-all-symbols.

FindAllSymbols now finds (most!) main-file usages of the discovered symbols.
The per-TU map output has NumUses=0 or 1 (only one use per file is counted).
The reducer aggregates these to find the number of files that use a symbol.

The NumOccurrences is now set to 1 in the mapper rather than being inferred by
the reducer, for consistency.

The idea here is to use NumUses for ranking: intuitively number of files that
use a symbol is more meaningful than number of files that include the header.


https://reviews.llvm.org/D30210

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/SymbolIndexManager.cpp
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/find-all-symbols/SymbolReporter.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  test/include-fixer/Inputs/fake_yaml_db.yaml
  test/include-fixer/Inputs/merge/a.yaml
  test/include-fixer/Inputs/merge/b.yaml
  test/include-fixer/merge.test
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -40,25 +40,33 @@
 Symbols.push_back(Symbol);
   }
 
+  void reportUse(llvm::StringRef FileName, const SymbolInfo &Symbol) override {
+Used.push_back(Symbol);
+  }
+
   bool hasSymbol(const SymbolInfo &Symbol) const {
-for (const auto &S : Symbols) {
-  if (S == Symbol)
-return true;
-}
-return false;
+return std::find(Symbols.begin(), Symbols.end(), Symbol) != Symbols.end();
+  }
+
+  bool hasUse(const SymbolInfo &Symbol) const {
+return std::find(Used.begin(), Used.end(), Symbol) != Used.end();
   }
 
 private:
   std::vector Symbols;
+  std::vector Used;
 };
 
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
 return Reporter.hasSymbol(Symbol);
   }
+  bool hasUse(const SymbolInfo &Symbol) {
+return Reporter.hasUse(Symbol);
+  }
 
-  bool runFindAllSymbols(StringRef Code) {
+  bool runFindAllSymbols(StringRef HeaderCode, StringRef MainCode) {
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
@@ -98,7 +106,7 @@
 std::make_shared());
 
 InMemoryFileSystem->addFile(HeaderName, 0,
-llvm::MemoryBuffer::getMemBuffer(Code));
+llvm::MemoryBuffer::getMemBuffer(HeaderCode));
 
 std::string Content = "#include\"" + std::string(HeaderName) +
   "\"\n"
@@ -118,6 +126,7 @@
 SymbolInfo DirtySymbol("ExtraInternal", SymbolInfo::SymbolKind::Class,
CleanHeader, 2, {});
 #endif // _MSC_VER && __MINGW32__
+Content += "\n" + MainCode.str();
 InMemoryFileSystem->addFile(FileName, 0,
 llvm::MemoryBuffer::getMemBuffer(Content));
 Invocation.run();
@@ -135,49 +144,64 @@
 };
 
 TEST_F(FindAllSymbolsTest, VariableSymbols) {
-  static const char Code[] = R"(
+  static const char Header[] = R"(
   extern int xargc;
   namespace na {
   static bool  = false;
   namespace nb { const long long *; }
   })";
-  runFindAllSymbols(Code);
+  static const char Main[] = R"(
+  auto y = &na::nb::;
+  int main() { if (na::) return xargc; }
+  )";
+  runFindAllSymbols(Header, Main);
 
   SymbolInfo Symbol =
   SymbolInfo("xargc", SymbolInfo::SymbolKind::Variable, HeaderName, 2, {});
   EXPECT_TRUE(hasSymbol(Symbol));
+  EXPECT_TRUE(hasUse(Symbol));
 
   Symbol = SymbolInfo("", SymbolInfo::SymbolKind::Variable, HeaderName, 4,
   {{SymbolInfo::ContextType::Namespace, "na"}});
   EXPECT_TRUE(hasSymbol(Symbol));
+  EXPECT_TRUE(hasUse(Symbol));
 
   Symbol = SymbolInfo("", SymbolInfo::SymbolKind::Variable, HeaderName, 5,
   {{SymbolInfo::ContextType::Namespace, "nb"},
{SymbolInfo::ContextType::Namespace, "na"}});
   EXPECT_TRUE(hasSymbol(Symbol));
+  EXPECT_TRUE(hasUse(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, ExternCSymbols) {
-  static const char Code[] = R"(
+  static const char Header[] = R"(
   extern "C" {
   int C_Func() { return 0; }
   struct C_struct {
 int Member;
   };
   })";
-  runFindAllSymbols(Code);
+  static const char Main[] = R"(
+  C_struct q() {
+int(*ptr)() = C_Func;
+return {0};
+  }
+  )";
+  runFindAllSymbols(Header, Main);
 
   SymbolInfo Symbol =
   SymbolInfo("C_Func", SymbolInfo::SymbolKind::Function, HeaderName, 3, {});
   EXPECT_TRUE(hasSymbol(Symbol));
+  EXPECT_TRUE(ha

[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.

2017-02-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 89236.
sammccall added a comment.

Remove obsolete comment.


https://reviews.llvm.org/D30210

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/SymbolIndexManager.cpp
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/find-all-symbols/SymbolReporter.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  test/include-fixer/Inputs/fake_yaml_db.yaml
  test/include-fixer/Inputs/merge/a.yaml
  test/include-fixer/Inputs/merge/b.yaml
  test/include-fixer/merge.test
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -40,25 +40,33 @@
 Symbols.push_back(Symbol);
   }
 
+  void reportUse(llvm::StringRef FileName, const SymbolInfo &Symbol) override {
+Used.push_back(Symbol);
+  }
+
   bool hasSymbol(const SymbolInfo &Symbol) const {
-for (const auto &S : Symbols) {
-  if (S == Symbol)
-return true;
-}
-return false;
+return std::find(Symbols.begin(), Symbols.end(), Symbol) != Symbols.end();
+  }
+
+  bool hasUse(const SymbolInfo &Symbol) const {
+return std::find(Used.begin(), Used.end(), Symbol) != Used.end();
   }
 
 private:
   std::vector Symbols;
+  std::vector Used;
 };
 
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
 return Reporter.hasSymbol(Symbol);
   }
+  bool hasUse(const SymbolInfo &Symbol) {
+return Reporter.hasUse(Symbol);
+  }
 
-  bool runFindAllSymbols(StringRef Code) {
+  bool runFindAllSymbols(StringRef HeaderCode, StringRef MainCode) {
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
@@ -98,7 +106,7 @@
 std::make_shared());
 
 InMemoryFileSystem->addFile(HeaderName, 0,
-llvm::MemoryBuffer::getMemBuffer(Code));
+llvm::MemoryBuffer::getMemBuffer(HeaderCode));
 
 std::string Content = "#include\"" + std::string(HeaderName) +
   "\"\n"
@@ -118,6 +126,7 @@
 SymbolInfo DirtySymbol("ExtraInternal", SymbolInfo::SymbolKind::Class,
CleanHeader, 2, {});
 #endif // _MSC_VER && __MINGW32__
+Content += "\n" + MainCode.str();
 InMemoryFileSystem->addFile(FileName, 0,
 llvm::MemoryBuffer::getMemBuffer(Content));
 Invocation.run();
@@ -135,49 +144,64 @@
 };
 
 TEST_F(FindAllSymbolsTest, VariableSymbols) {
-  static const char Code[] = R"(
+  static const char Header[] = R"(
   extern int xargc;
   namespace na {
   static bool  = false;
   namespace nb { const long long *; }
   })";
-  runFindAllSymbols(Code);
+  static const char Main[] = R"(
+  auto y = &na::nb::;
+  int main() { if (na::) return xargc; }
+  )";
+  runFindAllSymbols(Header, Main);
 
   SymbolInfo Symbol =
   SymbolInfo("xargc", SymbolInfo::SymbolKind::Variable, HeaderName, 2, {});
   EXPECT_TRUE(hasSymbol(Symbol));
+  EXPECT_TRUE(hasUse(Symbol));
 
   Symbol = SymbolInfo("", SymbolInfo::SymbolKind::Variable, HeaderName, 4,
   {{SymbolInfo::ContextType::Namespace, "na"}});
   EXPECT_TRUE(hasSymbol(Symbol));
+  EXPECT_TRUE(hasUse(Symbol));
 
   Symbol = SymbolInfo("", SymbolInfo::SymbolKind::Variable, HeaderName, 5,
   {{SymbolInfo::ContextType::Namespace, "nb"},
{SymbolInfo::ContextType::Namespace, "na"}});
   EXPECT_TRUE(hasSymbol(Symbol));
+  EXPECT_TRUE(hasUse(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, ExternCSymbols) {
-  static const char Code[] = R"(
+  static const char Header[] = R"(
   extern "C" {
   int C_Func() { return 0; }
   struct C_struct {
 int Member;
   };
   })";
-  runFindAllSymbols(Code);
+  static const char Main[] = R"(
+  C_struct q() {
+int(*ptr)() = C_Func;
+return {0};
+  }
+  )";
+  runFindAllSymbols(Header, Main);
 
   SymbolInfo Symbol =
   SymbolInfo("C_Func", SymbolInfo::SymbolKind::Function, HeaderName, 3, {});
   EXPECT_TRUE(hasSymbol(Symbol));
+  EXPECT_TRUE(hasUse(Symbol));
 
   Symbol =
   SymbolInfo("C_struct", SymbolInfo::SymbolKind::Class, HeaderName, 4, {});
   EXPECT_TRUE(hasSymbol(Symbol));
+  EXPECT_TRUE(hasUse(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, CXXRecordSymbols) {
-  static const char Code[] = R"(
+  static const char Header[] = R"(
   struct Glob {};
   struct A; // Not a defintion, ignored.
   class NOP; // Not a defintion, ignored
@@ -190,26 +214,33 @@
   };
   };  //
   )

[PATCH] D30214: [Driver] Search for libc++ headers in ResourceDir

2017-02-21 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.

https://reviews.llvm.org/D30214

Files:
  lib/Driver/ToolChains.cpp


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4642,6 +4642,7 @@
 std::string Linux::findLibCxxIncludePath() const {
   const std::string LibCXXIncludePathCandidates[] = {
   DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
+  DetectLibcxxIncludePath(getDriver().ResourceDir + "/include/c++"),
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4642,6 +4642,7 @@
 std::string Linux::findLibCxxIncludePath() const {
   const std::string LibCXXIncludePathCandidates[] = {
   DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
+  DetectLibcxxIncludePath(getDriver().ResourceDir + "/include/c++"),
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r295473 - [OpenMP] Remove barriers at cancel and cancellation point

2017-02-21 Thread Hans Wennborg via cfe-commits
I'm Ok with it if Alexey approves.

On Fri, Feb 17, 2017 at 10:52 AM, Hahnfeld, Jonas
 wrote:
> Hi Hans, Alexey,
>
> can we merge this commit and r295474 for the 4.0 release or is it already
> too late for that? I will totally understand that and can apply these
> commits locally prior to installing.
> However, I think that these changes are quite focussed and bear minimal
> possibility of introducing regressions.
>
> Thanks,
> Jonas
>
> Am Freitag, den 17.02.2017, 18:32 + schrieb Jonas Hahnfeld via
> cfe-commits:
>
> Author: hahnfeld
> Date: Fri Feb 17 12:32:51 2017
> New Revision: 295473
>
> URL: http://llvm.org/viewvc/llvm-project?rev=295473&view=rev
> Log:
> [OpenMP] Remove barriers at cancel and cancellation point
>
> This resolves a deadlock with the cancel directive when there is no explicit
> cancellation point. In that case, the implicit barrier acts as cancellation
> point. After removing the barrier after cancel, the now unmatched barrier
> for
> the explicit cancellation point has to go as well.
>
> This has probably worked before rL255992: With the calls for the explicit
> barrier, it was sure that all threads passed a barrier before exiting.
>
> Reported by Simon Convent and Joachim Protze!
>
> Differential Revision: https://reviews.llvm.org/D30088
>
> Modified:
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/test/OpenMP/cancel_codegen.cpp
> cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r295610 - Link static PIE programs against rcrt0.o on OpenBSD

2017-02-21 Thread Hans Wennborg via cfe-commits
Merged to 4.0 in r295752 as requested in PR32013.

On Sun, Feb 19, 2017 at 11:33 AM, Brad Smith via cfe-commits
 wrote:
> Author: brad
> Date: Sun Feb 19 13:33:26 2017
> New Revision: 295610
>
> URL: http://llvm.org/viewvc/llvm-project?rev=295610&view=rev
> Log:
> Link static PIE programs against rcrt0.o on OpenBSD
>
> Patch by Stefan Kempf.
>
> Modified:
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/test/Driver/openbsd.c
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=295610&r1=295609&r2=295610&view=diff
> ==
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Sun Feb 19 13:33:26 2017
> @@ -9035,6 +9035,10 @@ void openbsd::Linker::ConstructJob(Compi
>if (Args.hasArg(options::OPT_pg))
>  CmdArgs.push_back(
>  Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
> +  else if (Args.hasArg(options::OPT_static) &&
> +   !Args.hasArg(options::OPT_nopie))
> +CmdArgs.push_back(
> +Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
>else
>  CmdArgs.push_back(
>  Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));
>
> Modified: cfe/trunk/test/Driver/openbsd.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=295610&r1=295609&r2=295610&view=diff
> ==
> --- cfe/trunk/test/Driver/openbsd.c (original)
> +++ cfe/trunk/test/Driver/openbsd.c Sun Feb 19 13:33:26 2017
> @@ -67,3 +67,26 @@
>  // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
>  // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
>  // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
> +
> +// Check linking against correct startup code when (not) using PIE
> +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \
> +// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
> +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -fno-pie %s 
> -### 2>&1 \
> +// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
> +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static %s 
> -### 2>&1 \
> +// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
> +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static 
> -fno-pie %s -### 2>&1 \
> +// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
> +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -nopie %s -### 
> 2>&1 \
> +// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
> +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -fno-pie 
> -nopie %s -### 2>&1 \
> +// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
> +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static -nopie 
> %s -### 2>&1 \
> +// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
> +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -fno-pie 
> -static -nopie %s -### 2>&1 \
> +// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
> +// CHECK-PIE: "{{.*}}crt0.o"
> +// CHECK-PIE-NOT: "-nopie"
> +// CHECK-STATIC-PIE: "{{.*}}rcrt0.o"
> +// CHECK-STATIC-PIE-NOT: "-nopie"
> +// CHECK-NOPIE: "-nopie" "{{.*}}crt0.o"
>
>
> ___
> 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] D30000: Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

2017-02-21 Thread Taewook Oh via Phabricator via cfe-commits
twoh added a comment.

@eric_niebler Do you want any more experiments with this patch? I think Windows 
machines not printing warnings/fixits for absolute path is a separate issue 
with this.


https://reviews.llvm.org/D3



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


[PATCH] D30220: Only enable AddDiscriminator pass when -fdebug-info-for-profiling is true

2017-02-21 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh created this revision.

AddDiscriminator pass is only useful for sample pgo. This patch restricts 
AddDiscriminator to -fdebug-info-for-profiling so that it does not introduce 
unecessary debug size increases for non-sample-pgo builds.


https://reviews.llvm.org/D30220

Files:
  lib/CodeGen/BackendUtil.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenObjC/arc-linetable-autorelease.m


Index: test/CodeGenObjC/arc-linetable-autorelease.m
===
--- test/CodeGenObjC/arc-linetable-autorelease.m
+++ test/CodeGenObjC/arc-linetable-autorelease.m
@@ -30,11 +30,10 @@
   // CHECK: define {{.*}}_createBezierPathWithWidth
   // CHECK: load {{.*}} %path, align {{.*}}, !dbg ![[RET:[0-9]+]]
   // CHECK: call void @objc_storeStrong{{.*}} !dbg ![[ARC:[0-9]+]]
-  // CHECK: call {{.*}} @objc_autoreleaseReturnValue{{.*}} !dbg 
![[ARC1:[0-9]+]]
+  // CHECK: call {{.*}} @objc_autoreleaseReturnValue{{.*}} !dbg ![[ARC]]
   // CHECK: ret {{.*}} !dbg ![[ARC]]
   // CHECK: ![[RET]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
   return path;
-  // CHECK: ![[ARC]] = !DILocation(line: [[@LINE+2]], scope: !{{.*}})
-  // CHECK: ![[ARC1]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
+  // CHECK: ![[ARC]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
 }
 @end
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -545,8 +545,9 @@
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
   Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
   Opts.SampleProfileFile = Args.getLastArgValue(OPT_fprofile_sample_use_EQ);
-  Opts.DebugInfoForProfiling = Args.hasFlag(
-  OPT_fdebug_info_for_profiling, OPT_fno_debug_info_for_profiling, false);
+  Opts.DebugInfoForProfiling = Args.hasFlag(OPT_fdebug_info_for_profiling,
+OPT_fno_debug_info_for_profiling,
+!Opts.SampleProfileFile.empty());
 
   setPGOInstrumentor(Opts, Args, Diags);
   Opts.InstrProfileOutput =
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -339,8 +339,9 @@
   if (TM)
 TM->adjustPassManager(PMBuilder);
 
-  PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
- addAddDiscriminatorsPass);
+  if (CodeGenOpts.DebugInfoForProfiling)
+PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
+   addAddDiscriminatorsPass);
 
   // In ObjC ARC mode, add the main ARC optimization passes.
   if (LangOpts.ObjCAutoRefCount) {


Index: test/CodeGenObjC/arc-linetable-autorelease.m
===
--- test/CodeGenObjC/arc-linetable-autorelease.m
+++ test/CodeGenObjC/arc-linetable-autorelease.m
@@ -30,11 +30,10 @@
   // CHECK: define {{.*}}_createBezierPathWithWidth
   // CHECK: load {{.*}} %path, align {{.*}}, !dbg ![[RET:[0-9]+]]
   // CHECK: call void @objc_storeStrong{{.*}} !dbg ![[ARC:[0-9]+]]
-  // CHECK: call {{.*}} @objc_autoreleaseReturnValue{{.*}} !dbg ![[ARC1:[0-9]+]]
+  // CHECK: call {{.*}} @objc_autoreleaseReturnValue{{.*}} !dbg ![[ARC]]
   // CHECK: ret {{.*}} !dbg ![[ARC]]
   // CHECK: ![[RET]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
   return path;
-  // CHECK: ![[ARC]] = !DILocation(line: [[@LINE+2]], scope: !{{.*}})
-  // CHECK: ![[ARC1]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
+  // CHECK: ![[ARC]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
 }
 @end
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -545,8 +545,9 @@
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
   Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
   Opts.SampleProfileFile = Args.getLastArgValue(OPT_fprofile_sample_use_EQ);
-  Opts.DebugInfoForProfiling = Args.hasFlag(
-  OPT_fdebug_info_for_profiling, OPT_fno_debug_info_for_profiling, false);
+  Opts.DebugInfoForProfiling = Args.hasFlag(OPT_fdebug_info_for_profiling,
+OPT_fno_debug_info_for_profiling,
+!Opts.SampleProfileFile.empty());
 
   setPGOInstrumentor(Opts, Args, Diags);
   Opts.InstrProfileOutput =
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -339,8 +339,9 @@
   if (TM)
 TM->adjustPassManager(PMBuilder);
 
-  PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
- addAddDiscriminatorsPass);
+  if (CodeGenOpts.DebugInfoForProfiling)
+PMBuilder.addExtension(Pa

[PATCH] D30220: Only enable AddDiscriminator pass when -fdebug-info-for-profiling is true

2017-02-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Did you want to enable all DebugInfoForProfiling features when there's a sample 
profile specified? (not sure if all of the features are needed when stitching 
things back up, or if some of them are only needed for emission/tracking 
purposes)


https://reviews.llvm.org/D30220



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


[PATCH] D30220: Only enable AddDiscriminator pass when -fdebug-info-for-profiling is true

2017-02-21 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh updated this revision to Diff 89258.
danielcdh added a comment.

update


https://reviews.llvm.org/D30220

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGenObjC/arc-linetable-autorelease.m


Index: test/CodeGenObjC/arc-linetable-autorelease.m
===
--- test/CodeGenObjC/arc-linetable-autorelease.m
+++ test/CodeGenObjC/arc-linetable-autorelease.m
@@ -30,11 +30,10 @@
   // CHECK: define {{.*}}_createBezierPathWithWidth
   // CHECK: load {{.*}} %path, align {{.*}}, !dbg ![[RET:[0-9]+]]
   // CHECK: call void @objc_storeStrong{{.*}} !dbg ![[ARC:[0-9]+]]
-  // CHECK: call {{.*}} @objc_autoreleaseReturnValue{{.*}} !dbg 
![[ARC1:[0-9]+]]
+  // CHECK: call {{.*}} @objc_autoreleaseReturnValue{{.*}} !dbg ![[ARC]]
   // CHECK: ret {{.*}} !dbg ![[ARC]]
   // CHECK: ![[RET]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
   return path;
-  // CHECK: ![[ARC]] = !DILocation(line: [[@LINE+2]], scope: !{{.*}})
-  // CHECK: ![[ARC1]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
+  // CHECK: ![[ARC]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
 }
 @end
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -339,8 +339,10 @@
   if (TM)
 TM->adjustPassManager(PMBuilder);
 
-  PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
- addAddDiscriminatorsPass);
+  if (CodeGenOpts.DebugInfoForProfiling ||
+  !CodeGenOpts.SampleProfileFile.empty())
+PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
+   addAddDiscriminatorsPass);
 
   // In ObjC ARC mode, add the main ARC optimization passes.
   if (LangOpts.ObjCAutoRefCount) {


Index: test/CodeGenObjC/arc-linetable-autorelease.m
===
--- test/CodeGenObjC/arc-linetable-autorelease.m
+++ test/CodeGenObjC/arc-linetable-autorelease.m
@@ -30,11 +30,10 @@
   // CHECK: define {{.*}}_createBezierPathWithWidth
   // CHECK: load {{.*}} %path, align {{.*}}, !dbg ![[RET:[0-9]+]]
   // CHECK: call void @objc_storeStrong{{.*}} !dbg ![[ARC:[0-9]+]]
-  // CHECK: call {{.*}} @objc_autoreleaseReturnValue{{.*}} !dbg ![[ARC1:[0-9]+]]
+  // CHECK: call {{.*}} @objc_autoreleaseReturnValue{{.*}} !dbg ![[ARC]]
   // CHECK: ret {{.*}} !dbg ![[ARC]]
   // CHECK: ![[RET]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
   return path;
-  // CHECK: ![[ARC]] = !DILocation(line: [[@LINE+2]], scope: !{{.*}})
-  // CHECK: ![[ARC1]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
+  // CHECK: ![[ARC]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
 }
 @end
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -339,8 +339,10 @@
   if (TM)
 TM->adjustPassManager(PMBuilder);
 
-  PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
- addAddDiscriminatorsPass);
+  if (CodeGenOpts.DebugInfoForProfiling ||
+  !CodeGenOpts.SampleProfileFile.empty())
+PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
+   addAddDiscriminatorsPass);
 
   // In ObjC ARC mode, add the main ARC optimization passes.
   if (LangOpts.ObjCAutoRefCount) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30220: Only enable AddDiscriminator pass when -fdebug-info-for-profiling is true

2017-02-21 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh added a comment.

You are right, only discriminator is needed, the encoding and emission part 
should be orthogonal. Patch updated.


https://reviews.llvm.org/D30220



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


Re: r295592 - clang/CMakeLists.txt: Rework r294954 -- use file(TO_CMAKE_PATH).

2017-02-21 Thread Hans Wennborg via cfe-commits
Merged in r295760.

On Mon, Feb 20, 2017 at 3:12 PM, NAKAMURA Takumi via cfe-commits
 wrote:
> Hans, could you pull this (and r294954) into release_40, please?
>
> This is a regression from previous releases that clang standalone build
> cannot be configured on msbuild.
>
>
> On Sun, Feb 19, 2017 at 12:29 PM NAKAMURA Takumi via cfe-commits
>  wrote:
>>
>> Author: chapuni
>> Date: Sat Feb 18 21:17:31 2017
>> New Revision: 295592
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=295592&view=rev
>> Log:
>> clang/CMakeLists.txt: Rework r294954 -- use file(TO_CMAKE_PATH).
>>
>> Modified:
>> cfe/trunk/CMakeLists.txt
>>
>> Modified: cfe/trunk/CMakeLists.txt
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=295592&r1=295591&r2=295592&view=diff
>>
>> ==
>> --- cfe/trunk/CMakeLists.txt (original)
>> +++ cfe/trunk/CMakeLists.txt Sat Feb 18 21:17:31 2017
>> @@ -59,7 +59,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
>>
>># Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes.
>># CMake assumes slashes as PATH.
>> -  get_filename_component(LLVM_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH}
>> ABSOLUTE)
>> +  file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} LLVM_CMAKE_PATH)
>>
>>find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
>>  NO_DEFAULT_PATH)
>>
>>
>> ___
>> 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
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r295763 - Fix copy and paste mistake in header comment, NFC.

2017-02-21 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Feb 21 14:31:01 2017
New Revision: 295763

URL: http://llvm.org/viewvc/llvm-project?rev=295763&view=rev
Log:
Fix copy and paste mistake in header comment, NFC.

Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=295763&r1=295762&r2=295763&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Tue Feb 21 14:31:01 2017
@@ -1,4 +1,4 @@
-//=== CGBuiltin.cpp - Emit LLVM Code for builtins 
-===//
+//=== CGObjC.cpp - Emit LLVM Code for Objective-C 
-===//
 //
 // The LLVM Compiler Infrastructure
 //


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


r295764 - Only enable AddDiscriminator pass when -fdebug-info-for-profiling is true

2017-02-21 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Tue Feb 21 14:36:21 2017
New Revision: 295764

URL: http://llvm.org/viewvc/llvm-project?rev=295764&view=rev
Log:
Only enable AddDiscriminator pass when -fdebug-info-for-profiling is true

Summary: AddDiscriminator pass is only useful for sample pgo. This patch 
restricts AddDiscriminator to -fdebug-info-for-profiling so that it does not 
introduce unecessary debug size increases for non-sample-pgo builds.

Reviewers: dblaikie, aprantl

Reviewed By: dblaikie

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGenObjC/arc-linetable-autorelease.m

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=295764&r1=295763&r2=295764&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Feb 21 14:36:21 2017
@@ -339,8 +339,10 @@ void EmitAssemblyHelper::CreatePasses(le
   if (TM)
 TM->adjustPassManager(PMBuilder);
 
-  PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
- addAddDiscriminatorsPass);
+  if (CodeGenOpts.DebugInfoForProfiling ||
+  !CodeGenOpts.SampleProfileFile.empty())
+PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
+   addAddDiscriminatorsPass);
 
   // In ObjC ARC mode, add the main ARC optimization passes.
   if (LangOpts.ObjCAutoRefCount) {

Modified: cfe/trunk/test/CodeGenObjC/arc-linetable-autorelease.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-linetable-autorelease.m?rev=295764&r1=295763&r2=295764&view=diff
==
--- cfe/trunk/test/CodeGenObjC/arc-linetable-autorelease.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-linetable-autorelease.m Tue Feb 21 14:36:21 
2017
@@ -30,11 +30,10 @@ NSRect NSMakeRect(CGFloat x, CGFloat y,
   // CHECK: define {{.*}}_createBezierPathWithWidth
   // CHECK: load {{.*}} %path, align {{.*}}, !dbg ![[RET:[0-9]+]]
   // CHECK: call void @objc_storeStrong{{.*}} !dbg ![[ARC:[0-9]+]]
-  // CHECK: call {{.*}} @objc_autoreleaseReturnValue{{.*}} !dbg 
![[ARC1:[0-9]+]]
+  // CHECK: call {{.*}} @objc_autoreleaseReturnValue{{.*}} !dbg ![[ARC]]
   // CHECK: ret {{.*}} !dbg ![[ARC]]
   // CHECK: ![[RET]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
   return path;
-  // CHECK: ![[ARC]] = !DILocation(line: [[@LINE+2]], scope: !{{.*}})
-  // CHECK: ![[ARC1]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
+  // CHECK: ![[ARC]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
 }
 @end


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


[PATCH] D30000: Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

2017-02-21 Thread Eric Niebler via Phabricator via cfe-commits
eric_niebler accepted this revision.
eric_niebler added a comment.
This revision is now accepted and ready to land.

Nope looks good.


https://reviews.llvm.org/D3



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


[PATCH] D27689: Module: hash the pcm content and use it as SIGNATURE for implicit modules.

2017-02-21 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Serialization/ASTBitCodes.h:258
+  /// A block containing unhashed contents. It currently holds Diagnostic
+  /// Options and Signature.
+  UNHASHED_CONTROL_BLOCK_ID,

This comment is out of date. Maybe just point to the 
`UnhashedControlBlockRecordTypes` for the definitive list of records within 
this block?



Comment at: clang/lib/Serialization/ASTReader.cpp:2240-2241
 
+  // Lambda to read the unhashed control block the first time it's called.
+  bool HasReadUnhashedControlBlock = false;
+  auto readUnhashedControlBlockOnce = [&]() {

I guess the reason to do this is because reading that block depends on certain 
things in this block having been already read, and reading other things in this 
block depends on that block having been read? A comment explaining that would 
be useful.



Comment at: clang/lib/Serialization/ASTReader.cpp:4014-4015
+case UNHASHED_CONTROL_BLOCK_ID:
+  // This block is handled using look-ahead during ReadControlBlock.  We
+  // shouldn't get here!
+  return Failure;

We shouldn't return `Failure` without producing an error message.


https://reviews.llvm.org/D27689



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


r295778 - [XRay] Merge xray clang flag tests, and add powerpc64le.

2017-02-21 Thread Tim Shen via cfe-commits
Author: timshen
Date: Tue Feb 21 16:30:00 2017
New Revision: 295778

URL: http://llvm.org/viewvc/llvm-project?rev=295778&view=rev
Log:
[XRay] Merge xray clang flag tests, and add powerpc64le.

Summary: I'm not sure why they were in different files, but it's kind of harder 
to maintain. I create this patch partially for initiate a discussion.

Reviewers: dberris

Subscribers: nemanjai, cfe-commits

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

Removed:
cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
cfe/trunk/test/CodeGen/xray-attributes-supported-mips.cpp
Modified:
cfe/trunk/test/CodeGen/xray-attributes-supported.cpp

Removed: cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp?rev=295777&view=auto
==
--- cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp (original)
+++ cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp (removed)
@@ -1,13 +0,0 @@
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
-
-// Make sure that the LLVM attribute for XRay-annotated functions do show up.
-[[clang::xray_always_instrument]] void foo() {
-// CHECK: define void @_Z3foov() #0
-};
-
-[[clang::xray_never_instrument]] void bar() {
-// CHECK: define void @_Z3barv() #1
-};
-
-// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
-// CHECK: #1 = {{.*}}"function-instrument"="xray-never"

Removed: cfe/trunk/test/CodeGen/xray-attributes-supported-mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-attributes-supported-mips.cpp?rev=295777&view=auto
==
--- cfe/trunk/test/CodeGen/xray-attributes-supported-mips.cpp (original)
+++ cfe/trunk/test/CodeGen/xray-attributes-supported-mips.cpp (removed)
@@ -1,16 +0,0 @@
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips-unknown-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mipsel-unknown-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64-unknown-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64el-unknown-linux-gnu | FileCheck %s
-
-// Make sure that the LLVM attribute for XRay-annotated functions do show up.
-[[clang::xray_always_instrument]] void foo() {
-// CHECK: define void @_Z3foov() #0
-};
-
-[[clang::xray_never_instrument]] void bar() {
-// CHECK: define void @_Z3barv() #1
-};
-
-// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
-// CHECK: #1 = {{.*}}"function-instrument"="xray-never"

Modified: cfe/trunk/test/CodeGen/xray-attributes-supported.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-attributes-supported.cpp?rev=295778&r1=295777&r2=295778&view=diff
==
--- cfe/trunk/test/CodeGen/xray-attributes-supported.cpp (original)
+++ cfe/trunk/test/CodeGen/xray-attributes-supported.cpp Tue Feb 21 16:30:00 
2017
@@ -1,4 +1,10 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mipsel-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64el-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
 [[clang::xray_always_instrument]] void foo() {


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


[PATCH] D30118: [XRay] Merge xray clang flag tests, and add powerpc64le.

2017-02-21 Thread Tim Shen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295778: [XRay] Merge xray clang flag tests, and add 
powerpc64le. (authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D30118?vs=88953&id=89284#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30118

Files:
  cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
  cfe/trunk/test/CodeGen/xray-attributes-supported-mips.cpp
  cfe/trunk/test/CodeGen/xray-attributes-supported.cpp


Index: cfe/trunk/test/CodeGen/xray-attributes-supported.cpp
===
--- cfe/trunk/test/CodeGen/xray-attributes-supported.cpp
+++ cfe/trunk/test/CodeGen/xray-attributes-supported.cpp
@@ -1,4 +1,10 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mipsel-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64el-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
 [[clang::xray_always_instrument]] void foo() {
Index: cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
===
--- cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
+++ cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
@@ -1,13 +0,0 @@
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
-
-// Make sure that the LLVM attribute for XRay-annotated functions do show up.
-[[clang::xray_always_instrument]] void foo() {
-// CHECK: define void @_Z3foov() #0
-};
-
-[[clang::xray_never_instrument]] void bar() {
-// CHECK: define void @_Z3barv() #1
-};
-
-// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
-// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
Index: cfe/trunk/test/CodeGen/xray-attributes-supported-mips.cpp
===
--- cfe/trunk/test/CodeGen/xray-attributes-supported-mips.cpp
+++ cfe/trunk/test/CodeGen/xray-attributes-supported-mips.cpp
@@ -1,16 +0,0 @@
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips-unknown-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mipsel-unknown-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64-unknown-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64el-unknown-linux-gnu | FileCheck %s
-
-// Make sure that the LLVM attribute for XRay-annotated functions do show up.
-[[clang::xray_always_instrument]] void foo() {
-// CHECK: define void @_Z3foov() #0
-};
-
-[[clang::xray_never_instrument]] void bar() {
-// CHECK: define void @_Z3barv() #1
-};
-
-// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
-// CHECK: #1 = {{.*}}"function-instrument"="xray-never"


Index: cfe/trunk/test/CodeGen/xray-attributes-supported.cpp
===
--- cfe/trunk/test/CodeGen/xray-attributes-supported.cpp
+++ cfe/trunk/test/CodeGen/xray-attributes-supported.cpp
@@ -1,4 +1,10 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple arm-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mipsel-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64el-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
 [[clang::xray_always_instrument]] void foo() {
Index: cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp

r295779 - Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

2017-02-21 Thread Taewook Oh via cfe-commits
Author: twoh
Date: Tue Feb 21 16:30:55 2017
New Revision: 295779

URL: http://llvm.org/viewvc/llvm-project?rev=295779&view=rev
Log:
Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

Summary: This is a patch for PR31836. As the bug replaces the path separators 
in the included file name with the characters following them, the test script 
makes sure that there's no "Ccase-insensitive-include-pr31836.h" in the warning 
message.

Reviewers: rsmith, eric_niebler

Reviewed By: eric_niebler

Subscribers: karies, cfe-commits

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

Added:
cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh
Modified:
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=295779&r1=295778&r2=295779&view=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Feb 21 16:30:55 2017
@@ -1976,8 +1976,12 @@ void Preprocessor::HandleIncludeDirectiv
   SmallString<128> Path;
   Path.reserve(Name.size()+2);
   Path.push_back(isAngled ? '<' : '"');
+  bool isLeadingSeparator = llvm::sys::path::is_absolute(Name);
   for (auto Component : Components) {
-Path.append(Component);
+if (isLeadingSeparator)
+  isLeadingSeparator = false;
+else
+  Path.append(Component);
 // Append the separator the user used, or the close quote
 Path.push_back(
   Path.size() <= Filename.size() ? Filename[Path.size()-1] :

Added: cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh?rev=295779&view=auto
==
--- cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh (added)
+++ cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh Tue Feb 21 
16:30:55 2017
@@ -0,0 +1,9 @@
+// REQUIRES: case-insensitive-filesystem
+// UNSUPPORTED: system-windows
+
+// RUN: mkdir -p %T
+// RUN: touch %T/case-insensitive-include-pr31836.h
+// RUN: echo "#include \"%T/Case-Insensitive-Include-Pr31836.h\"" | %clang_cc1 
-E - 2>&1 | FileCheck %s
+
+// CHECK: warning: non-portable path to file
+// CHECK-SAME: /case-insensitive-include-pr31836.h


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


[PATCH] D30000: Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

2017-02-21 Thread Taewook Oh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295779: Fix for pr31836 - pp_nonportable_path on absolute 
paths: broken delimiters (authored by twoh).

Changed prior to commit:
  https://reviews.llvm.org/D3?vs=88584&id=89285#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D3

Files:
  cfe/trunk/lib/Lex/PPDirectives.cpp
  cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh


Index: cfe/trunk/lib/Lex/PPDirectives.cpp
===
--- cfe/trunk/lib/Lex/PPDirectives.cpp
+++ cfe/trunk/lib/Lex/PPDirectives.cpp
@@ -1976,8 +1976,12 @@
   SmallString<128> Path;
   Path.reserve(Name.size()+2);
   Path.push_back(isAngled ? '<' : '"');
+  bool isLeadingSeparator = llvm::sys::path::is_absolute(Name);
   for (auto Component : Components) {
-Path.append(Component);
+if (isLeadingSeparator)
+  isLeadingSeparator = false;
+else
+  Path.append(Component);
 // Append the separator the user used, or the close quote
 Path.push_back(
   Path.size() <= Filename.size() ? Filename[Path.size()-1] :
Index: cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh
===
--- cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh
+++ cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh
@@ -0,0 +1,9 @@
+// REQUIRES: case-insensitive-filesystem
+// UNSUPPORTED: system-windows
+
+// RUN: mkdir -p %T
+// RUN: touch %T/case-insensitive-include-pr31836.h
+// RUN: echo "#include \"%T/Case-Insensitive-Include-Pr31836.h\"" | %clang_cc1 
-E - 2>&1 | FileCheck %s
+
+// CHECK: warning: non-portable path to file
+// CHECK-SAME: /case-insensitive-include-pr31836.h


Index: cfe/trunk/lib/Lex/PPDirectives.cpp
===
--- cfe/trunk/lib/Lex/PPDirectives.cpp
+++ cfe/trunk/lib/Lex/PPDirectives.cpp
@@ -1976,8 +1976,12 @@
   SmallString<128> Path;
   Path.reserve(Name.size()+2);
   Path.push_back(isAngled ? '<' : '"');
+  bool isLeadingSeparator = llvm::sys::path::is_absolute(Name);
   for (auto Component : Components) {
-Path.append(Component);
+if (isLeadingSeparator)
+  isLeadingSeparator = false;
+else
+  Path.append(Component);
 // Append the separator the user used, or the close quote
 Path.push_back(
   Path.size() <= Filename.size() ? Filename[Path.size()-1] :
Index: cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh
===
--- cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh
+++ cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh
@@ -0,0 +1,9 @@
+// REQUIRES: case-insensitive-filesystem
+// UNSUPPORTED: system-windows
+
+// RUN: mkdir -p %T
+// RUN: touch %T/case-insensitive-include-pr31836.h
+// RUN: echo "#include \"%T/Case-Insensitive-Include-Pr31836.h\"" | %clang_cc1 -E - 2>&1 | FileCheck %s
+
+// CHECK: warning: non-portable path to file
+// CHECK-SAME: /case-insensitive-include-pr31836.h
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r295781 - Declare lgamma library builtins as never being const

2017-02-21 Thread Jacob Gravelle via cfe-commits
Author: jgravelle
Date: Tue Feb 21 16:37:27 2017
New Revision: 295781

URL: http://llvm.org/viewvc/llvm-project?rev=295781&view=rev
Log:
Declare lgamma library builtins as never being const

Summary:
POSIX requires lgamma writes to an external global variable, signgam.
This prevents annotating lgamma with readnone, which is incorrect on
targets that write to signgam.

Reviewers: efriedma, rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/test/CodeGen/libcall-declarations.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=295781&r1=295780&r2=295781&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Tue Feb 21 16:37:27 2017
@@ -1087,9 +1087,11 @@ LIBBUILTIN(ilogb, "id", "fne", "math.h",
 LIBBUILTIN(ilogbf, "if", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(ilogbl, "iLd", "fne", "math.h", ALL_LANGUAGES)
 
-LIBBUILTIN(lgamma, "dd", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(lgammaf, "ff", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(lgammal, "LdLd", "fne", "math.h", ALL_LANGUAGES)
+// POSIX math.h declares a global, signgam, that lgamma writes to, so these
+// shouldn't have "e" or "c" attributes
+LIBBUILTIN(lgamma, "dd", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(lgammaf, "ff", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(lgammal, "LdLd", "fn", "math.h", ALL_LANGUAGES)
 
 LIBBUILTIN(llrint, "LLid", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(llrintf, "LLif", "fne", "math.h", ALL_LANGUAGES)

Modified: cfe/trunk/test/CodeGen/libcall-declarations.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/libcall-declarations.c?rev=295781&r1=295780&r2=295781&view=diff
==
--- cfe/trunk/test/CodeGen/libcall-declarations.c (original)
+++ cfe/trunk/test/CodeGen/libcall-declarations.c Tue Feb 21 16:37:27 2017
@@ -402,9 +402,9 @@ void *use[] = {
 // CHECK-NOERRNO: declare i32 @ilogb(double) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbf(float) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbl(x86_fp80) [[NUW]]
-// CHECK-NOERRNO: declare double @lgamma(double) [[NUW]]
-// CHECK-NOERRNO: declare float @lgammaf(float) [[NUW]]
-// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NUW]]
+// CHECK-NOERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-NOERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-NOERRNO: declare i64 @llrint(double) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintf(float) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintl(x86_fp80) [[NUW]]
@@ -554,6 +554,9 @@ void *use[] = {
 // CHECK-ERRNO: declare double @fmin(double, double) [[NUW]]
 // CHECK-ERRNO: declare float @fminf(float, float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @fminl(x86_fp80, x86_fp80) [[NUW]]
+// CHECK-ERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-ERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-ERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-ERRNO: declare double @nearbyint(double) [[NUW]]
 // CHECK-ERRNO: declare float @nearbyintf(float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @nearbyintl(x86_fp80) [[NUW]]
@@ -612,5 +615,11 @@ void *use[] = {
 // CHECK-ERRNO: declare <2 x float> @ctanhf(<2 x float>) [[NUW]]
 
 // CHECK-NOERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }
+// CHECK-NOERRNO: attributes [[NONCONST]] = {
+// CHECK-NOERRNO-NOT: readnone
+// CHECK-NOERRNO-SAME: nounwind{{.*}} }
 
+// CHECK-ERRNO: attributes [[NONCONST]] = {
+// CHECK-ERRNO-NOT: readnone
+// CHECK-ERRNO-SAME: nounwind{{.*}} }
 // CHECK-ERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }


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


[PATCH] D29778: Declare lgamma library builtins as never being const

2017-02-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295781: Declare lgamma library builtins as never being const 
(authored by jgravelle).

Changed prior to commit:
  https://reviews.llvm.org/D29778?vs=88629&id=89287#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29778

Files:
  cfe/trunk/include/clang/Basic/Builtins.def
  cfe/trunk/test/CodeGen/libcall-declarations.c


Index: cfe/trunk/test/CodeGen/libcall-declarations.c
===
--- cfe/trunk/test/CodeGen/libcall-declarations.c
+++ cfe/trunk/test/CodeGen/libcall-declarations.c
@@ -402,9 +402,9 @@
 // CHECK-NOERRNO: declare i32 @ilogb(double) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbf(float) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbl(x86_fp80) [[NUW]]
-// CHECK-NOERRNO: declare double @lgamma(double) [[NUW]]
-// CHECK-NOERRNO: declare float @lgammaf(float) [[NUW]]
-// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NUW]]
+// CHECK-NOERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-NOERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-NOERRNO: declare i64 @llrint(double) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintf(float) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintl(x86_fp80) [[NUW]]
@@ -554,6 +554,9 @@
 // CHECK-ERRNO: declare double @fmin(double, double) [[NUW]]
 // CHECK-ERRNO: declare float @fminf(float, float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @fminl(x86_fp80, x86_fp80) [[NUW]]
+// CHECK-ERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-ERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-ERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-ERRNO: declare double @nearbyint(double) [[NUW]]
 // CHECK-ERRNO: declare float @nearbyintf(float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @nearbyintl(x86_fp80) [[NUW]]
@@ -612,5 +615,11 @@
 // CHECK-ERRNO: declare <2 x float> @ctanhf(<2 x float>) [[NUW]]
 
 // CHECK-NOERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }
+// CHECK-NOERRNO: attributes [[NONCONST]] = {
+// CHECK-NOERRNO-NOT: readnone
+// CHECK-NOERRNO-SAME: nounwind{{.*}} }
 
+// CHECK-ERRNO: attributes [[NONCONST]] = {
+// CHECK-ERRNO-NOT: readnone
+// CHECK-ERRNO-SAME: nounwind{{.*}} }
 // CHECK-ERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }
Index: cfe/trunk/include/clang/Basic/Builtins.def
===
--- cfe/trunk/include/clang/Basic/Builtins.def
+++ cfe/trunk/include/clang/Basic/Builtins.def
@@ -1087,9 +1087,11 @@
 LIBBUILTIN(ilogbf, "if", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(ilogbl, "iLd", "fne", "math.h", ALL_LANGUAGES)
 
-LIBBUILTIN(lgamma, "dd", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(lgammaf, "ff", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(lgammal, "LdLd", "fne", "math.h", ALL_LANGUAGES)
+// POSIX math.h declares a global, signgam, that lgamma writes to, so these
+// shouldn't have "e" or "c" attributes
+LIBBUILTIN(lgamma, "dd", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(lgammaf, "ff", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(lgammal, "LdLd", "fn", "math.h", ALL_LANGUAGES)
 
 LIBBUILTIN(llrint, "LLid", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(llrintf, "LLif", "fne", "math.h", ALL_LANGUAGES)


Index: cfe/trunk/test/CodeGen/libcall-declarations.c
===
--- cfe/trunk/test/CodeGen/libcall-declarations.c
+++ cfe/trunk/test/CodeGen/libcall-declarations.c
@@ -402,9 +402,9 @@
 // CHECK-NOERRNO: declare i32 @ilogb(double) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbf(float) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbl(x86_fp80) [[NUW]]
-// CHECK-NOERRNO: declare double @lgamma(double) [[NUW]]
-// CHECK-NOERRNO: declare float @lgammaf(float) [[NUW]]
-// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NUW]]
+// CHECK-NOERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-NOERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-NOERRNO: declare i64 @llrint(double) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintf(float) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintl(x86_fp80) [[NUW]]
@@ -554,6 +554,9 @@
 // CHECK-ERRNO: declare double @fmin(double, double) [[NUW]]
 // CHECK-ERRNO: declare float @fminf(float, float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @fminl(x86_fp80, x86_fp80) [[NUW]]
+// CHECK-ERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-ERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-ERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-ERRNO: declare double @nearbyint(double) [[NUW]]
 // CHECK-ERRNO: declare float @nearbyintf(float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @nearbyintl(x86_fp80) [[NUW]]
@@ -612,5 +615,11 @@
 // CHECK-ERRNO: declare <2 x float> @ctanhf(<2 x float>) [[NUW]]
 

[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-02-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I'm not really qualified to review the implementation details, but this seems 
good as far as I can tell. A few comments, mostly style related.




Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:39
 private string style = "file";
+private bool formatOnSaveEnabled = false;
+private string formatOnSaveFileExtensions =

Perhaps just `formatOnSave`, similar to `sortIncludes` above?



Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:46
+{
+// Use MemberwiseClone to copy value types
+var clone = (OptionPageGrid)MemberwiseClone();

Ultra nit: end the sentence with a period.



Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:88
 
-[Category("LLVM/Clang")]
+[Category("Format Options")]
 [DisplayName("Style")]

What do you think about using "clang-format" for the category name?



Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:178
+
+[Category("Format On Save")]
+[DisplayName("Enable")]

Does this mean the "FormatOnSave" is not nested under the same category as the 
other clang-format options?



Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:276
+
+if (Vsix.IsDocumentDirty(document))
+{

Perhaps return early if `!Vsix.IsDocumentDirty(document)` instead?


https://reviews.llvm.org/D29221



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


r295786 - Hook up OpenBSD AArch64 support

2017-02-21 Thread Brad Smith via cfe-commits
Author: brad
Date: Tue Feb 21 17:13:09 2017
New Revision: 295786

URL: http://llvm.org/viewvc/llvm-project?rev=295786&view=rev
Log:
Hook up OpenBSD AArch64 support

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Frontend/gnu-mcount.c
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=295786&r1=295785&r2=295786&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Feb 21 17:13:09 2017
@@ -5944,7 +5944,8 @@ class AArch64TargetInfo : public TargetI
 public:
   AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : TargetInfo(Triple), ABI("aapcs") {
-if (getTriple().getOS() == llvm::Triple::NetBSD) {
+if (getTriple().getOS() == llvm::Triple::NetBSD ||
+getTriple().getOS() == llvm::Triple::OpenBSD) {
   WCharType = SignedInt;
 
   // NetBSD apparently prefers consistency across ARM targets to 
consistency
@@ -8962,6 +8963,8 @@ static TargetInfo *AllocateTarget(const
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
+case llvm::Triple::OpenBSD:
+  return new OpenBSDTargetInfo(Triple, Opts);
 default:
   return new AArch64leTargetInfo(Triple, Opts);
 }

Modified: cfe/trunk/test/Frontend/gnu-mcount.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/gnu-mcount.c?rev=295786&r1=295785&r2=295786&view=diff
==
--- cfe/trunk/test/Frontend/gnu-mcount.c (original)
+++ cfe/trunk/test/Frontend/gnu-mcount.c Tue Feb 21 17:13:09 2017
@@ -61,7 +61,7 @@ int f() {
 // CHECK-ARM-EABI-NETBSD-NOT: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
 // CHECK-ARM-EABI-OPENBSD: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="__mcount"{{.*}} }
 // CHECK-ARM-EABI-OPENBSD-NOT: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-EABI-OPENBSD: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="mcount"{{.*}} }
+// CHECK-ARM64-EABI-OPENBSD: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="__mcount"{{.*}} }
 // CHECK-ARM64-EABI-OPENBSD-NOT: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
 // CHECK-ARM-EABI-MEABI-GNU-NOT: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="mcount"{{.*}} }
 // CHECK-ARM-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=295786&r1=295785&r2=295786&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Tue Feb 21 17:13:09 2017
@@ -831,6 +831,198 @@
 // AARCH64-NETBSD:#define __WINT_WIDTH__ 32
 // AARCH64-NETBSD:#define __aarch64__ 1
 //
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-openbsd < /dev/null | 
FileCheck -match-full-lines -check-prefix AARCH64-OPENBSD %s
+//
+// AARCH64-OPENBSD:#define _LP64 1
+// AARCH64-OPENBSD-NOT:#define __AARCH64EB__ 1
+// AARCH64-OPENBSD:#define __AARCH64EL__ 1
+// AARCH64-OPENBSD-NOT:#define __AARCH_BIG_ENDIAN 1
+// AARCH64-OPENBSD:#define __ARM_64BIT_STATE 1
+// AARCH64-OPENBSD:#define __ARM_ARCH 8
+// AARCH64-OPENBSD:#define __ARM_ARCH_ISA_A64 1
+// AARCH64-OPENBSD-NOT:#define __ARM_BIG_ENDIAN 1
+// AARCH64-OPENBSD:#define __BIGGEST_ALIGNMENT__ 16
+// AARCH64-OPENBSD:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// AARCH64-OPENBSD:#define __CHAR16_TYPE__ unsigned short
+// AARCH64-OPENBSD:#define __CHAR32_TYPE__ unsigned int
+// AARCH64-OPENBSD:#define __CHAR_BIT__ 8
+// AARCH64-OPENBSD:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// AARCH64-OPENBSD:#define __DBL_DIG__ 15
+// AARCH64-OPENBSD:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// AARCH64-OPENBSD:#define __DBL_HAS_DENORM__ 1
+// AARCH64-OPENBSD:#define __DBL_HAS_INFINITY__ 1
+// AARCH64-OPENBSD:#define __DBL_HAS_QUIET_NAN__ 1
+// AARCH64-OPENBSD:#define __DBL_MANT_DIG__ 53
+// AARCH64-OPENBSD:#define __DBL_MAX_10_EXP__ 308
+// AARCH64-OPENBSD:#define __DBL_MAX_EXP__ 1024
+// AARCH64-OPENBSD:#define __DBL_MAX__ 1.7976931348623157e+308
+// AARCH64-OPENBSD:#define __DBL_MIN_10_EXP__ (-307)
+// AARCH64-OPENBSD:#define __DBL_MIN_EXP__ (-1021)
+// AARCH64-OPENBSD:#define __DBL_MIN__ 2.2250738585072014e-308
+// AARCH64-OPENBSD:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
+// AARCH64-OPENBSD:#define __ELF__ 1
+// AARCH64-OPENBSD:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// AARCH64-OPENBSD:#define __FLT_DIG__ 6
+// AARCH64-OPENBSD:#define __FLT_EPSILON__ 1.19209290e-7F
+// AARCH64-OPENBSD:#define 

LLVM buildmaster will be updated and restarted tonight

2017-02-21 Thread Galina Kistanova via cfe-commits
Hello everyone,

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

Thanks

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


[PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

2017-02-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

This seems to be stuck. Bruno, Richard, do you think there's a chance this can 
be fixed for 4.0?


https://reviews.llvm.org/D29753



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


r295790 - Fix deduction of type of pack-expanded non-type template parameter.

2017-02-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Feb 21 17:49:18 2017
New Revision: 295790

URL: http://llvm.org/viewvc/llvm-project?rev=295790&view=rev
Log:
Fix deduction of type of pack-expanded non-type template parameter.

We need to look through the PackExpansionType in the parameter type when
deducing, and we need to consider the possibility of deducing arguments for
packs that are not lexically mentioned in the pattern (but are nonetheless
deducible) when figuring out which packs are covered by a pack deduction scope.

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
cfe/trunk/test/SemaTemplate/deduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=295790&r1=295789&r2=295790&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Tue Feb 21 17:49:18 2017
@@ -112,6 +112,15 @@ DeduceTemplateArguments(Sema &S, Templat
 SmallVectorImpl &Deduced,
 bool NumberOfArgumentsMustMatch);
 
+static void MarkUsedTemplateParameters(ASTContext &Ctx,
+   const TemplateArgument &TemplateArg,
+   bool OnlyDeduced, unsigned Depth,
+   llvm::SmallBitVector &Used);
+
+static void MarkUsedTemplateParameters(ASTContext &Ctx, QualType T,
+   bool OnlyDeduced, unsigned Level,
+   llvm::SmallBitVector &Deduced);
+
 /// \brief If the given expression is of a form that permits the deduction
 /// of a non-type template parameter, return the declaration of that
 /// non-type template parameter.
@@ -334,12 +343,24 @@ static Sema::TemplateDeductionResult Ded
   if (!S.getLangOpts().CPlusPlus1z)
 return Sema::TDK_Success;
 
+  if (NTTP->isExpandedParameterPack())
+// FIXME: We may still need to deduce parts of the type here! But we
+// don't have any way to find which slice of the type to use, and the
+// type stored on the NTTP itself is nonsense. Perhaps the type of an
+// expanded NTTP should be a pack expansion type?
+return Sema::TDK_Success;
+
+  // Get the type of the parameter for deduction.
+  QualType ParamType = NTTP->getType();
+  if (auto *Expansion = dyn_cast(ParamType))
+ParamType = Expansion->getPattern();
+
   // FIXME: It's not clear how deduction of a parameter of reference
   // type from an argument (of non-reference type) should be performed.
   // For now, we just remove reference types from both sides and let
   // the final check for matching types sort out the mess.
   return DeduceTemplateArgumentsByTypeMatch(
-  S, TemplateParams, NTTP->getType().getNonReferenceType(),
+  S, TemplateParams, ParamType.getNonReferenceType(),
   ValueType.getNonReferenceType(), Info, Deduced, TDF_SkipNonDependent,
   /*PartialOrdering=*/false,
   /*ArrayBound=*/NewDeduced.wasDeducedFromArrayBound());
@@ -617,29 +638,68 @@ public:
  SmallVectorImpl &Deduced,
  TemplateDeductionInfo &Info, TemplateArgument Pattern)
   : S(S), TemplateParams(TemplateParams), Deduced(Deduced), Info(Info) {
+// Dig out the partially-substituted pack, if there is one.
+const TemplateArgument *PartialPackArgs = nullptr;
+unsigned NumPartialPackArgs = 0;
+std::pair PartialPackDepthIndex(-1u, -1u);
+if (auto *Scope = S.CurrentInstantiationScope)
+  if (auto *Partial = Scope->getPartiallySubstitutedPack(
+  &PartialPackArgs, &NumPartialPackArgs))
+PartialPackDepthIndex = getDepthAndIndex(Partial);
+
 // Compute the set of template parameter indices that correspond to
 // parameter packs expanded by the pack expansion.
 {
   llvm::SmallBitVector SawIndices(TemplateParams->size());
+
+  auto AddPack = [&](unsigned Index) {
+if (SawIndices[Index])
+  return;
+SawIndices[Index] = true;
+
+// Save the deduced template argument for the parameter pack expanded
+// by this pack expansion, then clear out the deduction.
+DeducedPack Pack(Index);
+Pack.Saved = Deduced[Index];
+Deduced[Index] = TemplateArgument();
+
+Packs.push_back(Pack);
+  };
+
+  // First look for unexpanded packs in the pattern.
   SmallVector Unexpanded;
   S.collectUnexpandedParameterPacks(Pattern, Unexpanded);
   for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
 unsigned Depth, Index;
 std::tie(Depth, Index) = getDepthAndIndex(Unexpanded[I]);
-if (Depth == Info.getDeducedDepth() && !SawIndices[Index]) {
-  SawIndices[Index] = true;
-
-  // Save the deduced template argu

r295791 - [c++1z] Mark constexpr lambdas as done on status page and start advertising

2017-02-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Feb 21 17:58:29 2017
New Revision: 295791

URL: http://llvm.org/viewvc/llvm-project?rev=295791&view=rev
Log:
[c++1z] Mark constexpr lambdas as done on status page and start advertising
them via feature test macro __cpp_constexpr.

Thanks to Faisal for implementing this feature!

Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Lexer/cxx-features.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=295791&r1=295790&r2=295791&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Feb 21 17:58:29 2017
@@ -475,6 +475,7 @@ static void InitializeCPlusPlusFeatureTe
 Builder.defineMacro("__cpp_user_defined_literals", "200809");
 Builder.defineMacro("__cpp_lambdas", "200907");
 Builder.defineMacro("__cpp_constexpr",
+LangOpts.CPlusPlus1z ? "201603" : 
 LangOpts.CPlusPlus14 ? "201304" : "200704");
 Builder.defineMacro("__cpp_range_based_for",
 LangOpts.CPlusPlus1z ? "201603" : "200907");

Modified: cfe/trunk/test/Lexer/cxx-features.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx-features.cpp?rev=295791&r1=295790&r2=295791&view=diff
==
--- cfe/trunk/test/Lexer/cxx-features.cpp (original)
+++ cfe/trunk/test/Lexer/cxx-features.cpp Tue Feb 21 17:58:29 2017
@@ -50,7 +50,7 @@
 #error "wrong value for __cpp_capture_star_this"
 #endif
 
-// FIXME: bump __cpp_constexpr to 201603 for constexpr lambda support
+// constexpr checked below
 
 #if check(if_constexpr, 0, 0, 0, 201606) // FIXME: provisional name
 #error "wrong value for __cpp_if_constexpr"
@@ -167,7 +167,7 @@
 #error "wrong value for __cpp_lambdas"
 #endif
 
-#if check(constexpr, 0, 200704, 201304, 201304)
+#if check(constexpr, 0, 200704, 201304, 201603)
 #error "wrong value for __cpp_constexpr"
 #endif
 

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=295791&r1=295790&r2=295791&view=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Tue Feb 21 17:58:29 2017
@@ -648,7 +648,7 @@ as the draft C++1z standard evolves.
 
   constexpr lambda expressions
   http://wg21.link/p0170r1";>P0170R1
-  No
+  SVN
 
 
   Differing begin and end types in range-based 
for


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


Re: r295279 - [cxx1z-constexpr-lambda] Implement captures - thus completing implementation of constexpr lambdas.

2017-02-21 Thread Richard Smith via cfe-commits
Timeout -- committed r295791 on your behalf.

On 16 February 2017 at 05:04, Faisal Vali  wrote:

> Of course Richard - I'll be happy to bump that value for C++1z
> hopefully later today.
> Thanks!
> Faisal Vali
>
>
>
> On Wed, Feb 15, 2017 at 10:30 PM, Richard Smith 
> wrote:
> > On 15 February 2017 at 20:12, Faisal Vali via cfe-commits
> >  wrote:
> >>
> >> Author: faisalv
> >> Date: Wed Feb 15 22:12:21 2017
> >> New Revision: 295279
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=295279&view=rev
> >> Log:
> >> [cxx1z-constexpr-lambda] Implement captures - thus completing
> >> implementation of constexpr lambdas.
> >>
> >> Enable evaluation of captures within constexpr lambdas by using a
> strategy
> >> similar to that used in CodeGen:
> >>   - when starting evaluation of a lambda's call operator, create a map
> >> from VarDecl's to a closure's FieldDecls
> >>   - every time a VarDecl (or '*this) that represents a capture is
> >> encountered while evaluating the expression via the expression evaluator
> >> (specifically the LValueEvaluator) in ExprConstant.cpp - it is replaced
> by
> >> the corresponding FieldDecl LValue (an Lvalue-to-Rvalue conversion on
> this
> >> LValue representation then determines the right rvalue when needed).
> >>
> >> Thanks to Richard Smith and Hubert Tong for their review and feedback!
> >
> >
> > Awesome, thanks Faisal!
> >
> > Want to bump our value for __cpp_constexpr to 201603 in C++1z mode to
> > advertise support for this?
> >
> >>
> >> https://reviews.llvm.org/D29748
> >>
> >>
> >> Modified:
> >> cfe/trunk/lib/AST/ExprConstant.cpp
> >> cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
> >>
> >> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ExprConstant.cpp?rev=295279&r1=295278&r2=295279&view=diff
> >>
> >> 
> ==
> >> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> >> +++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Feb 15 22:12:21 2017
> >> @@ -425,6 +425,17 @@ namespace {
> >>  /// Index - The call index of this call.
> >>  unsigned Index;
> >>
> >> +// FIXME: Adding this to every 'CallStackFrame' may have a
> nontrivial
> >> impact
> >> +// on the overall stack usage of deeply-recursing constexpr
> >> evaluataions.
> >> +// (We should cache this map rather than recomputing it
> repeatedly.)
> >> +// But let's try this and see how it goes; we can look into caching
> >> the map
> >> +// as a later change.
> >> +
> >> +/// LambdaCaptureFields - Mapping from captured variables/this to
> >> +/// corresponding data members in the closure class.
> >> +llvm::DenseMap LambdaCaptureFields;
> >> +FieldDecl *LambdaThisCaptureField;
> >> +
> >>  CallStackFrame(EvalInfo &Info, SourceLocation CallLoc,
> >> const FunctionDecl *Callee, const LValue *This,
> >> APValue *Arguments);
> >> @@ -2279,6 +2290,10 @@ static bool HandleLValueComplexElement(E
> >>return true;
> >>  }
> >>
> >> +static bool handleLValueToRValueConversion(EvalInfo &Info, const Expr
> >> *Conv,
> >> +   QualType Type, const LValue
> >> &LVal,
> >> +   APValue &RVal);
> >> +
> >>  /// Try to evaluate the initializer for a variable declaration.
> >>  ///
> >>  /// \param Info   Information about the ongoing evaluation.
> >> @@ -2290,6 +2305,7 @@ static bool HandleLValueComplexElement(E
> >>  static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
> >>  const VarDecl *VD, CallStackFrame
> *Frame,
> >>  APValue *&Result) {
> >> +
> >>// If this is a parameter to an active constexpr function call,
> perform
> >>// argument substitution.
> >>if (const ParmVarDecl *PVD = dyn_cast(VD)) {
> >> @@ -4180,6 +4196,10 @@ static bool HandleFunctionCall(SourceLoc
> >>return false;
> >>  This->moveInto(Result);
> >>  return true;
> >> +  } else if (MD && isLambdaCallOperator(MD)) {
> >> +// We're in a lambda; determine the lambda capture field maps.
> >> +MD->getParent()->getCaptureFields(Frame.LambdaCaptureFields,
> >> +  Frame.LambdaThisCaptureField);
> >>}
> >>
> >>StmtResult Ret = {Result, ResultSlot};
> >> @@ -5041,6 +5061,33 @@ bool LValueExprEvaluator::VisitDeclRefEx
> >>
> >>
> >>  bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl
> *VD)
> >> {
> >> +
> >> +  // If we are within a lambda's call operator, check whether the 'VD'
> >> referred
> >> +  // to within 'E' actually represents a lambda-capture that maps to a
> >> +  // data-member/field within the closure object, and if so, evaluate
> to
> >> the
> >> +  // field or what the field refers to.
> >> +  if (Info.CurrentCall && isLambdaCallOperator(Info.
> CurrentCall->Callee))

[PATCH] D29819: Introduce an 'external_source_symbol' attribute that describes the origin and the nature of a declaration

2017-02-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 89298.
arphaman marked 8 inline comments as done.
arphaman added a comment.

I've addressed Aaron's comments and made the language a string literal.


Repository:
  rL LLVM

https://reviews.llvm.org/D29819

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/AttributeList.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Misc/ast-dump-attr.cpp
  test/Parser/attr-external-source-symbol-cxx11.cpp
  test/Parser/attr-external-source-symbol.m
  test/Sema/attr-external-source-symbol.c

Index: test/Sema/attr-external-source-symbol.c
===
--- /dev/null
+++ test/Sema/attr-external-source-symbol.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+
+void threeClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
+
+void twoClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module")));
+
+void fourClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
+
+void oneClause() __attribute__((external_source_symbol(generated_declaration)));
+
+void noArguments()
+__attribute__((external_source_symbol)); // expected-error {{'external_source_symbol' attribute takes at least 1 argument}}
+
+void namedDeclsOnly() {
+  int (^block)(void) = ^ (void)
+__attribute__((external_source_symbol(language="Swift"))) { // expected-warning {{'external_source_symbol' attribute only applies to named declarations}}
+  return 1;
+  };
+}
Index: test/Parser/attr-external-source-symbol.m
===
--- /dev/null
+++ test/Parser/attr-external-source-symbol.m
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void function() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
+
+__attribute__((external_source_symbol(language="Swift", defined_in="module")))
+@interface I
+
+- (void)method __attribute__((external_source_symbol(defined_in= "module")));
+
+@end
+
+enum E {
+  CaseA __attribute__((external_source_symbol(generated_declaration))),
+  CaseB __attribute__((external_source_symbol(generated_declaration, language="Swift")))
+} __attribute__((external_source_symbol(language = "Swift")));
+
+void f2()
+__attribute__((external_source_symbol())); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
+void f3()
+__attribute__((external_source_symbol(invalid))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
+void f4()
+__attribute__((external_source_symbol(language))); // expected-error {{expected '=' after language}}
+void f5()
+__attribute__((external_source_symbol(language=))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
+void f6()
+__attribute__((external_source_symbol(defined_in=20))); // expected-error {{expected string literal for source container name in 'external_source_symbol' attribute}}
+
+void f7()
+__attribute__((external_source_symbol(generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
+void f8()
+__attribute__((external_source_symbol(language="Swift", language="Swift"))); // expected-error {{duplicate 'language' clause in an 'external_source_symbol' attribute}}
+void f9()
+__attribute__((external_source_symbol(defined_in="module", language="Swift", defined_in="foo"))); // expected-error {{duplicate 'defined_in' clause in an 'external_source_symbol' attribute}}
+
+void f10()
+__attribute__((external_source_symbol(generated_declaration, language="Swift", defined_in="foo", generated_declaration, generated_declaration, language="Swift"))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
+
+void f11()
+__attribute__((external_source_symbol(language="Objective-C++", defined_in="Some file with spaces")));
+
+void f12()
+__attribute__((external_source_symbol(language="C Sharp", defined_in="file:Hello world with spaces. cs")));
+
+void f13()
+__attribute__((external_source_symbol(language=Swift))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
+
+void f14()
+__attribute__((external_source_symbol(=))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
+
+void f15()
+__attribute__((external_s

[PATCH] D29819: Introduce an 'external_source_symbol' attribute that describes the origin and the nature of a declaration

2017-02-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:1005
+language=\ *identifier*
+  The source language in which this declaration was defined.
+

aaron.ballman wrote:
> This being an identifier makes me wonder about languages that aren't a single 
> token. For instance, how do you specify Objective-C or Objective-C++? What 
> about C++? Visual Basic .NET?
> 
> Perhaps this should also be a string literal.
Good point, I've changed it to a string literal.


Repository:
  rL LLVM

https://reviews.llvm.org/D29819



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


r295794 - Fix assertion failure when generating debug information for a variable

2017-02-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Feb 21 18:13:14 2017
New Revision: 295794

URL: http://llvm.org/viewvc/llvm-project?rev=295794&view=rev
Log:
Fix assertion failure when generating debug information for a variable
declaration declared using class template argument deduction.

Patch by Eric Fiselier (who is busy and asked me to commit this on his behalf)!

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

Added:
cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp
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=295794&r1=295793&r2=295794&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb 21 18:13:14 2017
@@ -2475,8 +2475,9 @@ static QualType UnwrapTypeForDebugInfo(Q
 case Type::SubstTemplateTypeParm:
   T = cast(T)->getReplacementType();
   break;
-case Type::Auto: {
-  QualType DT = cast(T)->getDeducedType();
+case Type::Auto:
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = cast(T)->getDeducedType();
   assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
   T = DT;
   break;

Added: cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp?rev=295794&view=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp Tue Feb 
21 18:13:14 2017
@@ -0,0 +1,17 @@
+// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - 
-std=c++1z | FileCheck %s
+
+// Verify that we don't crash when emitting debug information for objects
+// created from a deduced template specialization.
+
+template 
+struct S {
+  S(T) {}
+};
+
+// CHECK: !DIGlobalVariable(name: "s1"
+// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]]
+// CHECK: !DIGlobalVariable(name: "s2"
+// CHECK-SAME: type: [[TYPE_NUM]]
+// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "S",
+S s1(42);
+S s2(42);


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


[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.

2017-02-21 Thread Richard Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295794: Fix assertion failure when generating debug 
information for a variable (authored by rsmith).

Changed prior to commit:
  https://reviews.llvm.org/D30082?vs=88943&id=89300#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30082

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp


Index: cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - 
-std=c++1z | FileCheck %s
+
+// Verify that we don't crash when emitting debug information for objects
+// created from a deduced template specialization.
+
+template 
+struct S {
+  S(T) {}
+};
+
+// CHECK: !DIGlobalVariable(name: "s1"
+// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]]
+// CHECK: !DIGlobalVariable(name: "s2"
+// CHECK-SAME: type: [[TYPE_NUM]]
+// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "S",
+S s1(42);
+S s2(42);
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -2475,8 +2475,9 @@
 case Type::SubstTemplateTypeParm:
   T = cast(T)->getReplacementType();
   break;
-case Type::Auto: {
-  QualType DT = cast(T)->getDeducedType();
+case Type::Auto:
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = cast(T)->getDeducedType();
   assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
   T = DT;
   break;


Index: cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-template-deduction-guide.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s
+
+// Verify that we don't crash when emitting debug information for objects
+// created from a deduced template specialization.
+
+template 
+struct S {
+  S(T) {}
+};
+
+// CHECK: !DIGlobalVariable(name: "s1"
+// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]]
+// CHECK: !DIGlobalVariable(name: "s2"
+// CHECK-SAME: type: [[TYPE_NUM]]
+// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S",
+S s1(42);
+S s2(42);
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -2475,8 +2475,9 @@
 case Type::SubstTemplateTypeParm:
   T = cast(T)->getReplacementType();
   break;
-case Type::Auto: {
-  QualType DT = cast(T)->getDeducedType();
+case Type::Auto:
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = cast(T)->getDeducedType();
   assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
   T = DT;
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r295800 - Add more ODR checking.

2017-02-21 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Feb 21 19:11:25 2017
New Revision: 295800

URL: http://llvm.org/viewvc/llvm-project?rev=295800&view=rev
Log:
Add more ODR checking.

Add the basics for the ODRHash class, which will only process Decl's from
a whitelist, which currently only has AccessSpecDecl.  Different access
specifiers in merged classes can now be detected.

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

Added:
cfe/trunk/include/clang/AST/ODRHash.h
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/CMakeLists.txt
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Added: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=295800&view=auto
==
--- cfe/trunk/include/clang/AST/ODRHash.h (added)
+++ cfe/trunk/include/clang/AST/ODRHash.h Tue Feb 21 19:11:25 2017
@@ -0,0 +1,84 @@
+//===-- ODRHash.h - Hashing to diagnose ODR failures *- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// This file contains the declaration of the ODRHash class, which calculates
+/// a hash based on AST nodes, which is stable across different runs.
+///
+//===--===//
+
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TemplateBase.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang {
+
+class Decl;
+class IdentifierInfo;
+class NestedNameSpecifer;
+class Stmt;
+class TemplateParameterList;
+
+// ODRHash is used to calculate a hash based on AST node contents that
+// does not rely on pointer addresses.  This allows the hash to not vary
+// between runs and is usable to detect ODR problems in modules.  To use,
+// construct an ODRHash object, then call Add* methods over the nodes that
+// need to be hashed.  Then call CalculateHash to get the hash value.
+// Typically, only one Add* call is needed.  clear can be called to reuse the
+// object.
+class ODRHash {
+  // Use DenseMaps to convert between Decl and Type pointers and an index 
value.
+  llvm::DenseMap DeclMap;
+  llvm::DenseMap TypeMap;
+
+  // Save space by processing bools at the end.
+  llvm::SmallVector Bools;
+
+  llvm::FoldingSetNodeID ID;
+
+public:
+  ODRHash() {}
+
+  // Use this for ODR checking classes between modules.  This method compares
+  // more information than the AddDecl class.
+  void AddCXXRecordDecl(const CXXRecordDecl *Record);
+
+  // Process SubDecls of the main Decl.  This method calls the DeclVisitor
+  // while AddDecl does not.
+  void AddSubDecl(const Decl *D);
+
+  // Reset the object for reuse.
+  void clear();
+
+  // Add booleans to ID and uses it to calculate the hash.
+  unsigned CalculateHash();
+
+  // Add AST nodes that need to be processed.
+  void AddDecl(const Decl *D);
+  void AddType(const Type *T);
+  void AddQualType(QualType T);
+  void AddStmt(const Stmt *S);
+  void AddIdentifierInfo(const IdentifierInfo *II);
+  void AddNestedNameSpecifier(const NestedNameSpecifier *NNS);
+  void AddTemplateName(TemplateName Name);
+  void AddDeclarationName(DeclarationName Name);
+  void AddTemplateArgument(TemplateArgument TA);
+  void AddTemplateParameterList(const TemplateParameterList *TPL);
+
+  // Save booleans until the end to lower the size of data to process.
+  void AddBoolean(bool value);
+
+  static bool isWhitelistedDecl(const Decl* D, const CXXRecordDecl *Record);
+};
+
+}  // end namespace clang

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=295800&r1=295799&r2=295800&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Tue Feb 21 
19:11:25 2017
@@ -117,6 +117,15 @@ def note_module_odr_violation_different_
 def err_module_odr_violation_different_instantiations : Error<
   "instantiation of %q0 is different in different modules">;
 
+def err_module_odr_violation_mismatch_decl : Error<
+  "%q0 has different definitions in different modules; first difference is "
+  "%select{definition in module '%2'|defined here}1 found "
+  "%select{end of class|public access specifier|private access specifier|"
+  "protected access specifier}3">;
+def note_module_odr_viola

Buildbot numbers for the week of 02/05/2017 - 02/11/2017

2017-02-21 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 02/05/2017 - 02/11/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername | was_red
+-
 lld-x86_64-win7| 46:33:59
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan | 39:43:26
 sanitizer-x86_64-linux | 35:32:15
 sanitizer-ppc64le-linux| 32:43:54
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 29:14:54
 clang-x86-windows-msvc2015 | 25:56:55
 sanitizer-x86_64-linux-bootstrap   | 25:45:40
 clang-cmake-aarch64-quick  | 21:46:28
 clang-s390x-linux  | 16:33:32
 clang-cmake-thumbv7-a15-full-sh| 16:28:14
 llvm-mips-linux| 15:52:35
 sanitizer-x86_64-linux-fast| 10:58:24
 sanitizer-x86_64-linux-fuzzer  | 10:43:53
 lldb-x86_64-ubuntu-14.04-android   | 09:38:04
 clang-cmake-mips   | 09:23:42
 libcxx-libcxxabi-libunwind-x86_64-linux-debian | 08:58:08
 clang-cmake-armv7-a15-selfhost | 07:06:04
 lldb-x86_64-darwin-13.4| 06:48:29
 clang-ppc64le-linux-multistage | 06:33:54
 clang-cmake-aarch64-full   | 06:26:59
 perf-x86_64-penryn-O3-polly| 06:20:04
 clang-cmake-aarch64-lld| 06:17:55
 clang-ppc64be-linux-multistage | 06:01:18
 clang-lld-x86_64-2stage| 05:44:44
 clang-ppc64le-linux-lnt| 05:27:25
 clang-ppc64le-linux| 05:10:33
 clang-x86_64-linux-selfhost-modules| 04:50:04
 clang-ppc64be-linux-lnt| 04:50:02
 clang-cuda-build   | 04:49:19
 clang-cmake-mipsel | 04:45:50
 clang-x86_64-debian-fast   | 04:40:33
 clang-hexagon-elf  | 04:28:15
 clang-ppc64be-linux| 04:18:02
 clang-cmake-armv7-a15-full | 04:17:34
 clang-cmake-aarch64-39vma  | 04:15:56
 clang-cmake-aarch64-42vma  | 04:13:41
 clang-cmake-armv7-a15  | 04:11:52
 llvm-hexagon-elf   | 04:08:13
 clang-x64-ninja-win7   | 03:57:04
 clang-cmake-thumbv7-a15| 03:53:12
 clang-cmake-armv7-a15-selfhost-neon| 03:35:19
 clang-with-thin-lto-ubuntu | 03:26:46
 clang-with-lto-ubuntu  | 03:17:06
 lldb-x86_64-ubuntu-14.04-buildserver   | 02:42:39
 sanitizer-x86_64-linux-autoconf| 02:41:06
 polly-amd64-linux  | 02:40:22
 clang-atom-d525-fedora-rel | 02:28:32
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11   | 02:28:08
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan  | 02:16:43
 clang-x86_64-linux-selfhost-modules-2  | 02:16:14
 perf-x86_64-penryn-O3-polly-unprofitable   | 02:14:43
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan  | 02:11:03
 lld-x86_64-darwin13| 02:09:15
 lldb-windows7-android  | 01:59:06
 lldb-amd64-ninja-netbsd7   | 01:58:38
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14 | 01:50:30
 polly-arm-linux| 01:48:59
 sanitizer-ppc64be-linux| 01:43:47
 clang-native-arm-lnt   | 01:39:14
 libcxx-libcxxabi-libunwind-x8

Buildbot numbers for the week of 02/12/2017 - 02/18/2017

2017-02-21 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 02/12/2017 -
02/18/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername | was_red
+-
 lldb-x86_64-ubuntu-14.04-android   | 63:39:17
 clang-x64-ninja-win7   | 59:12:13
 lldb-x86_64-darwin-13.4| 49:09:06
 lldb-windows7-android  | 24:51:31
 sanitizer-ppc64le-linux| 22:55:53
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 17:56:35
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions  | 17:39:22
 lldb-x86_64-ubuntu-14.04-cmake | 17:10:44
 libcxx-libcxxabi-libunwind-aarch64-linux   | 16:13:50
 clang-x86-windows-msvc2015 | 15:28:02
 perf-x86_64-penryn-O3  | 14:24:10
 sanitizer-x86_64-linux-bootstrap   | 12:39:53
 clang-cmake-mipsel | 12:39:34
 sanitizer-x86_64-linux-fast| 12:00:54
 clang-cmake-armv7-a15-full | 11:30:23
 sanitizer-x86_64-linux | 11:28:54
 clang-cmake-thumbv7-a15-full-sh| 11:27:43
 clang-cmake-armv7-a15  | 11:14:19
 clang-with-lto-ubuntu  | 11:11:05
 clang-cuda-build   | 10:58:26
 clang-cmake-thumbv7-a15| 10:51:21
 perf-x86_64-penryn-O3-polly-unprofitable   | 10:29:50
 perf-x86_64-penryn-O3-polly-parallel-fast  | 10:29:36
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only  | 10:21:45
 clang-with-thin-lto-ubuntu | 10:16:24
 clang-cmake-armv7-a15-selfhost-neon| 10:08:44
 perf-x86_64-penryn-O3-polly| 09:50:26
 sanitizer-ppc64be-linux| 09:48:48
 perf-x86_64-penryn-O3-polly-fast   | 09:05:48
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 08:54:57
 clang-ppc64le-linux-multistage | 06:49:12
 clang-x86_64-debian-fast   | 06:33:05
 clang-cmake-armv7-a15-selfhost | 06:25:29
 clang-lld-x86_64-2stage| 06:12:05
 clang-cmake-mips   | 05:54:04
 clang-ppc64le-linux| 05:42:01
 clang-cmake-aarch64-full   | 05:34:30
 clang-ppc64be-linux-multistage | 05:19:27
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan  | 05:15:12
 clang-x86_64-linux-selfhost-modules-2  | 04:11:31
 lldb-x86_64-ubuntu-14.04-buildserver   | 04:07:45
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan  | 03:47:39
 lldb-amd64-ninja-netbsd7   | 03:44:56
 clang-x86_64-linux-selfhost-modules| 03:42:39
 llvm-mips-linux| 03:12:36
 polly-amd64-linux  | 02:56:44
 clang-ppc64le-linux-lnt| 02:55:18
 lldb-amd64-ninja-freebsd11 | 02:54:47
 polly-arm-linux| 02:49:00
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 02:45:53
 clang-ppc64be-linux| 02:39:11
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan  | 02:32:26
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan | 02:23:26
 clang-atom-d525-fedora-rel | 02:22:54
 clang-cmake-aarch64-42vma  | 02:21:28
 clang-cmake-aarch64-lld| 02:17:45
 clang-cmake-aarch64-39vma  | 01:56:36
 clang-ppc64be-linux-lnt| 01:49:50
 libcxx-libcxxabi-libunwind-x86_64-linux-debian | 01:48:30
 clang-s390x-linux   

[PATCH] D27827: [ObjC] CodeGen support for @available on macOS

2017-02-21 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 89305.
erik.pilkington added a comment.

This new patch addresses all of Alex's comments:

- Remove `ObjC` from function names
- Rename `_IsOSVersionAtLeast` -> `__isOSVersionAtLeast`
- Improve testcase


https://reviews.llvm.org/D27827

Files:
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  test/CodeGenObjC/availability-check.m

Index: test/CodeGenObjC/availability-check.m
===
--- test/CodeGenObjC/availability-check.m
+++ test/CodeGenObjC/availability-check.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - %s | FileCheck %s
+
+void use_at_available() {
+  // CHECK: call i32 @__isOSVersionAtLeast(i32 10, i32 12, i32 0)
+  // CHECK-NEXT: icmp ne
+  if (__builtin_available(macos 10.12, *))
+;
+
+  // CHECK: call i32 @__isOSVersionAtLeast(i32 10, i32 12, i32 42)
+  // CHECK-NEXT: icmp ne
+  if (__builtin_available(ios 10, macos 10.12.42, *))
+;
+
+  // CHECK-NOT: call i32 @__isOSVersionAtLeast
+  // CHECK: br i1 true
+  if (__builtin_available(ios 10, *))
+;
+
+  // This check should be folded: our deployment target is 10.11.
+  // CHECK-NOT: call i32 @__isOSVersionAtLeast
+  // CHECK: br i1 true
+  if (__builtin_available(macos 10.11, *))
+;
+}
+
+// CHECK: declare i32 @__isOSVersionAtLeast(i32, i32, i32)
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -546,6 +546,10 @@
 return *ObjCData;
   }
 
+  // Version checking function, used to implement ObjC's @available:
+  // i32 @__isOSVersionAtLeast(i32, i32, i32)
+  llvm::Constant *IsOSVersionAtLeastFn = nullptr;
+
   InstrProfStats &getPGOStats() { return PGOStats; }
   llvm::IndexedInstrProfReader *getPGOReader() const { return PGOReader.get(); }
 
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3168,6 +3168,8 @@
 public:
   llvm::Value *EmitMSVCBuiltinExpr(MSVCIntrin BuiltinID, const CallExpr *E);
 
+  llvm::Value *EmitBuiltinAvailable(ArrayRef Args);
+
   llvm::Value *EmitObjCProtocolExpr(const ObjCProtocolExpr *E);
   llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E);
   llvm::Value *EmitObjCBoxedExpr(const ObjCBoxedExpr *E);
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -3399,5 +3399,21 @@
   return Val;
 }
 
+llvm::Value *
+CodeGenFunction::EmitBuiltinAvailable(ArrayRef Args) {
+  assert(Args.size() == 3 && "Expected 3 argument here!");
+
+  if (!CGM.IsOSVersionAtLeastFn) {
+llvm::FunctionType *FTy =
+llvm::FunctionType::get(Int32Ty, {Int32Ty, Int32Ty, Int32Ty}, false);
+CGM.IsOSVersionAtLeastFn =
+CGM.CreateRuntimeFunction(FTy, "__isOSVersionAtLeast");
+  }
+
+  llvm::Value *CallRes =
+  EmitNounwindRuntimeCall(CGM.IsOSVersionAtLeastFn, Args);
+
+  return Builder.CreateICmpNE(CallRes, llvm::Constant::getNullValue(Int32Ty));
+}
 
 CGObjCRuntime::~CGObjCRuntime() {}
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -300,6 +300,24 @@
 return V;
   }
 
+  Value *VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
+VersionTuple Version = E->getVersion();
+
+// If we're checking for a platform older than our minimum deployment
+// target, we can fold the check away.
+if (Version <= CGF.CGM.getTarget().getPlatformMinVersion())
+  return llvm::ConstantInt::get(Builder.getInt1Ty(), 1);
+
+Optional Min = Version.getMinor(), SMin = Version.getSubminor();
+llvm::Value *Args[] = {
+llvm::ConstantInt::get(CGF.CGM.Int32Ty, Version.getMajor()),
+llvm::ConstantInt::get(CGF.CGM.Int32Ty, Min ? *Min : 0),
+llvm::ConstantInt::get(CGF.CGM.Int32Ty, SMin ? *SMin : 0),
+};
+
+return CGF.EmitBuiltinAvailable(Args);
+  }
+
   Value *VisitArraySubscriptExpr(ArraySubscriptExpr *E);
   Value *VisitShuffleVectorExpr(ShuffleVectorExpr *E);
   Value *VisitConvertVectorExpr(ConvertVectorExpr *E);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30238: [Driver] Enable SafeStack for Fuchsia targets

2017-02-21 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr created this revision.

The runtime support is provided directly by the Fuchsia system C library.


Repository:
  rL LLVM

https://reviews.llvm.org/D30238

Files:
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h


Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -1095,6 +1095,8 @@
 return llvm::DebuggerKind::GDB;
   }
 
+  SanitizerMask getSupportedSanitizers() const override;
+
   RuntimeLibType
   GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
   CXXStdlibType
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4860,6 +4860,12 @@
   CmdArgs.push_back("-lunwind");
 }
 
+SanitizerMask Fuchsia::getSupportedSanitizers() const {
+  SanitizerMask Res = ToolChain::getSupportedSanitizers();
+  Res |= SanitizerKind::SafeStack;
+  return Res;
+}
+
 /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
 
 DragonFly::DragonFly(const Driver &D, const llvm::Triple &Triple,


Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -1095,6 +1095,8 @@
 return llvm::DebuggerKind::GDB;
   }
 
+  SanitizerMask getSupportedSanitizers() const override;
+
   RuntimeLibType
   GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
   CXXStdlibType
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4860,6 +4860,12 @@
   CmdArgs.push_back("-lunwind");
 }
 
+SanitizerMask Fuchsia::getSupportedSanitizers() const {
+  SanitizerMask Res = ToolChain::getSupportedSanitizers();
+  Res |= SanitizerKind::SafeStack;
+  return Res;
+}
+
 /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
 
 DragonFly::DragonFly(const Driver &D, const llvm::Triple &Triple,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30238: [Driver] Enable SafeStack for Fuchsia targets

2017-02-21 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr added a comment.

This assumes https://reviews.llvm.org/D30237


Repository:
  rL LLVM

https://reviews.llvm.org/D30238



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


r295805 - Call the correct @llvm.objectsize.

2017-02-21 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Tue Feb 21 20:35:51 2017
New Revision: 295805

URL: http://llvm.org/viewvc/llvm-project?rev=295805&view=rev
Log:
Call the correct @llvm.objectsize.

The following code would crash clang:

void foo(unsigned *const __attribute__((pass_object_size(0;
void bar(unsigned *i) { foo(i); }

This is because we were always selecting the version of
`@llvm.objectsize` that takes an i8* in CodeGen. Passing an i32* as an
i8* makes LLVM very unhappy.

(Yes, I'm surprised that this remained uncaught for so long, too. :) )

As an added bonus, we'll now also use the appropriate address space when
emitting @llvm.objectsize calls.

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/pass-object-size.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=295805&r1=295804&r2=295805&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Feb 21 20:35:51 2017
@@ -460,13 +460,14 @@ CodeGenFunction::emitBuiltinObjectSize(c
   if (Type == 3 || E->HasSideEffects(getContext()))
 return getDefaultBuiltinObjectSizeResult(Type, ResType);
 
-  // LLVM only supports 0 and 2, make sure that we pass along that
-  // as a boolean.
+  Value *Ptr = EmitScalarExpr(E);
+  assert(Ptr->getType()->isPointerTy() &&
+ "Non-pointer passed to __builtin_object_size?");
+
+  // LLVM only supports 0 and 2, make sure that we pass along that as a 
boolean.
   auto *CI = ConstantInt::get(Builder.getInt1Ty(), (Type & 2) >> 1);
-  // FIXME: Get right address space.
-  llvm::Type *Tys[] = {ResType, Builder.getInt8PtrTy(0)};
-  Value *F = CGM.getIntrinsic(Intrinsic::objectsize, Tys);
-  return Builder.CreateCall(F, {EmitScalarExpr(E), CI});
+  Value *F = CGM.getIntrinsic(Intrinsic::objectsize, {ResType, 
Ptr->getType()});
+  return Builder.CreateCall(F, {Ptr, CI});
 }
 
 // Many of MSVC builtins are on both x64 and ARM; to avoid repeating code, we

Modified: cfe/trunk/test/CodeGen/pass-object-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pass-object-size.c?rev=295805&r1=295804&r2=295805&view=diff
==
--- cfe/trunk/test/CodeGen/pass-object-size.c (original)
+++ cfe/trunk/test/CodeGen/pass-object-size.c Tue Feb 21 20:35:51 2017
@@ -369,3 +369,29 @@ void test14(char *c) {
   // CHECK: call void (i8*, i64, ...) @my_sprintf
   my_sprintf(c, 1, 2, 3);
 }
+
+void pass_size_unsigned(unsigned *const PS(0));
+
+// Bug: we weren't lowering to the proper @llvm.objectsize for pointers that
+// don't turn into i8*s, which caused crashes.
+// CHECK-LABEL: define void @test15
+void test15(unsigned *I) {
+  // CHECK: @llvm.objectsize.i64.p0i32
+  // CHECK: call void @pass_size_unsigned
+  pass_size_unsigned(I);
+}
+
+void pass_size_as1(__attribute__((address_space(1))) void *const PS(0));
+
+void pass_size_unsigned_as1(
+__attribute__((address_space(1))) unsigned *const PS(0));
+
+// CHECK-LABEL: define void @test16
+void test16(__attribute__((address_space(1))) unsigned *I) {
+  // CHECK: call i64 @llvm.objectsize.i64.p1i8
+  // CHECK: call void @pass_size_as1
+  pass_size_as1(I);
+  // CHECK: call i64 @llvm.objectsize.i64.p1i32
+  // CHECK: call void @pass_size_unsigned_as1
+  pass_size_unsigned_as1(I);
+}


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


[PATCH] D30238: [Driver] Enable SafeStack for Fuchsia targets

2017-02-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

Could you also please update test/Driver/fuchsia.c and add a case for 
`-fsanitize=safe-stack`?


Repository:
  rL LLVM

https://reviews.llvm.org/D30238



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


[PATCH] D30239: enable -flto=thin, -flto-jobs=, and -fthinlto-index= in clang-cl

2017-02-21 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added subscribers: cfe-commits, pcc.
pcc added a comment.

Can you please add a ThinLTO test to lld before adding driver support?


https://reviews.llvm.org/D30239



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


[PATCH] D30239: enable -flto=thin, -flto-jobs=, and -fthinlto-index= in clang-cl

2017-02-21 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D30239#683116, @pcc wrote:

> Can you please add a ThinLTO test to lld before adding driver support?


Is clang-cl using lld as default? How is the switch done? Ideally we should 
have a nice error message from the driver if -flto is used without lld.


https://reviews.llvm.org/D30239



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


[PATCH] D30241: AMDGPU: Add fmed3 half builtin

2017-02-21 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
Herald added subscribers: tpr, dstuttard, tony-tye, yaxunl, nhaehnle, wdng, 
kzhuravl.

https://reviews.llvm.org/D30241

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
  test/SemaOpenCL/builtins-amdgcn-error-f16.cl
  test/SemaOpenCL/builtins-amdgcn-error-gfx9.cl


Index: test/SemaOpenCL/builtins-amdgcn-error-gfx9.cl
===
--- /dev/null
+++ test/SemaOpenCL/builtins-amdgcn-error-gfx9.cl
@@ -0,0 +1,9 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu fiji -verify -S -o - %s
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+void test_gfx9_fmed3h(global half *out, half a, half b, half c)
+{
+  *out = __builtin_amdgcn_fmed3h(a, b, c); // expected-error 
{{'__builtin_amdgcn_fmed3h' needs target feature gfx9-insts}}
+}
Index: test/SemaOpenCL/builtins-amdgcn-error-f16.cl
===
--- test/SemaOpenCL/builtins-amdgcn-error-f16.cl
+++ test/SemaOpenCL/builtins-amdgcn-error-f16.cl
@@ -1,9 +1,10 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 -triple amdgcn-- -target-cpu tahiti -verify -S -o - %s
+// RUN: %clang_cc1 -triple amdgcn-- -verify -S -o - %s
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
-void test_f16(global half *out, half a, half b, half c)
+__attribute__((target("arch=tahiti")))
+void test_f16_tahiti(global half *out, half a, half b, half c)
 {
   *out = __builtin_amdgcn_div_fixuph(a, b, c); // expected-error 
{{'__builtin_amdgcn_div_fixuph' needs target feature 16-bit-insts}}
   *out = __builtin_amdgcn_rcph(a); // expected-error {{'__builtin_amdgcn_rcph' 
needs target feature 16-bit-insts}}
@@ -15,4 +16,5 @@
   *out = __builtin_amdgcn_frexp_exph(a); // expected-error 
{{'__builtin_amdgcn_frexp_exph' needs target feature 16-bit-insts}}
   *out = __builtin_amdgcn_fracth(a); // expected-error 
{{'__builtin_amdgcn_fracth' needs target feature 16-bit-insts}}
   *out = __builtin_amdgcn_classh(a, b); // expected-error 
{{'__builtin_amdgcn_classh' needs target feature 16-bit-insts}}
+  *out = __builtin_amdgcn_fmed3h(a, b, c); // expected-error 
{{'__builtin_amdgcn_fmed3h' needs target feature gfx9-insts}}
 }
Index: test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
@@ -0,0 +1,11 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx900 -S 
-emit-llvm -o - %s | FileCheck %s
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+// CHECK-LABEL: @test_fmed3_f16
+// CHECK: call half @llvm.amdgcn.fmed3.f16(half %a, half %b, half %c)
+void test_fmed3_f16(global half* out, half a, half b, half c)
+{
+  *out = __builtin_amdgcn_fmed3h(a, b, c);
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -8445,6 +8445,7 @@
   case AMDGPU::BI__builtin_amdgcn_classh:
 return emitFPIntBuiltin(*this, E, Intrinsic::amdgcn_class);
   case AMDGPU::BI__builtin_amdgcn_fmed3f:
+  case AMDGPU::BI__builtin_amdgcn_fmed3h:
 return emitTernaryBuiltin(*this, E, Intrinsic::amdgcn_fmed3);
   case AMDGPU::BI__builtin_amdgcn_read_exec: {
 CallInst *CI = cast(
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2355,6 +2355,9 @@
 case GK_GFX7:
   break;
 
+case GK_GFX9:
+  Features["gfx9-insts"] = true;
+  LLVM_FALLTHROUGH;
 case GK_GFX8:
   Features["s-memrealtime"] = true;
   Features["16-bit-insts"] = true;
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -100,6 +100,12 @@
 TARGET_BUILTIN(__builtin_amdgcn_s_memrealtime, "LUi", "n", "s-memrealtime")
 
 
//===--===//
+// GFX9+ only builtins.
+//===--===//
+
+TARGET_BUILTIN(__builtin_amdgcn_fmed3h, "", "nc", "gfx9-insts")
+
+//===--===//
 // Special builtins.
 
//===--===//
 BUILTIN(__builtin_amdgcn_read_exec, "LUi", "nc")


Index: test/SemaOpenCL/builtins-amdgcn-error-gfx9.cl
===
--- /dev/null
+++ test/SemaOpenCL/builtins-amdgcn-error-gfx9.cl
@@ -0,0 +1,9 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu fiji -verify -S -o - %s
+
+#pragma OPENCL EXTE

[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-02-21 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added inline comments.



Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:39
 private string style = "file";
+private bool formatOnSaveEnabled = false;
+private string formatOnSaveFileExtensions =

hans wrote:
> Perhaps just `formatOnSave`, similar to `sortIncludes` above?
Will do.



Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:46
+{
+// Use MemberwiseClone to copy value types
+var clone = (OptionPageGrid)MemberwiseClone();

hans wrote:
> Ultra nit: end the sentence with a period.
Will do.



Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:88
 
-[Category("LLVM/Clang")]
+[Category("Format Options")]
 [DisplayName("Style")]

hans wrote:
> What do you think about using "clang-format" for the category name?
So if you take a look at the screenshot I posted with the original diff, you'll 
see how these categories show up:
https://reviews.llvm.org/file/data/cuztal767fqmcy2k7kkv/PHID-FILE-xcoqfwj3o2tpwbabbak5/pasted_file

"LLVM/Clang" is the main option menu name, and was always there. I figure the 
idea is that if we write other extensions, they'd all fall under this heading. 
Personally I'd like for it to be "clang-format" or "Clang Format".

As part of my change, I grouped the options that were there before under 
"Format Options", which is what they are (arguments to clang-format), and my 
new options under "Format On Save".



Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:178
+
+[Category("Format On Save")]
+[DisplayName("Enable")]

hans wrote:
> Does this mean the "FormatOnSave" is not nested under the same category as 
> the other clang-format options?
See my answer to the comment on line 88.


https://reviews.llvm.org/D29221



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


[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-02-21 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added inline comments.



Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:276
+
+if (Vsix.IsDocumentDirty(document))
+{

hans wrote:
> Perhaps return early if `!Vsix.IsDocumentDirty(document)` instead?
Yes, will do.


https://reviews.llvm.org/D29221



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


r295808 - [OpenMP] Generate better diagnostics for cancel and cancellation point

2017-02-21 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Wed Feb 22 00:49:10 2017
New Revision: 295808

URL: http://llvm.org/viewvc/llvm-project?rev=295808&view=rev
Log:
[OpenMP] Generate better diagnostics for cancel and cancellation point

checkNestingOfRegions uses CancelRegion to determine whether cancel and
cancellation point are valid in the given nesting. This leads to unuseful
diagnostics if CancelRegion is invalid. The given test case has produced:
  region cannot be closely nested inside 'parallel' region

As a solution, introduce checkCancelRegion and call it first to get the
expected error:
  one of 'for', 'parallel', 'sections' or 'taskgroup' is expected

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

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/cancel_messages.cpp
cfe/trunk/test/OpenMP/cancellation_point_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=295808&r1=295807&r2=295808&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Feb 22 00:49:10 2017
@@ -1956,7 +1956,23 @@ StmtResult Sema::ActOnOpenMPRegionEnd(St
   return SR;
 }
 
-static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
+static bool checkCancelRegion(Sema &SemaRef, OpenMPDirectiveKind CurrentRegion,
+  OpenMPDirectiveKind CancelRegion,
+  SourceLocation StartLoc) {
+  // CancelRegion is only needed for cancel and cancellation_point.
+  if (CurrentRegion != OMPD_cancel && CurrentRegion != OMPD_cancellation_point)
+return false;
+
+  if (CancelRegion == OMPD_parallel || CancelRegion == OMPD_for ||
+  CancelRegion == OMPD_sections || CancelRegion == OMPD_taskgroup)
+return false;
+
+  SemaRef.Diag(StartLoc, diag::err_omp_wrong_cancel_region)
+  << getOpenMPDirectiveName(CancelRegion);
+  return true;
+}
+
+static bool checkNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
   OpenMPDirectiveKind CurrentRegion,
   const DeclarationNameInfo &CurrentName,
   OpenMPDirectiveKind CancelRegion,
@@ -2256,7 +2272,9 @@ StmtResult Sema::ActOnOpenMPExecutableDi
 OpenMPDirectiveKind CancelRegion, ArrayRef Clauses,
 Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc) {
   StmtResult Res = StmtError();
-  if (CheckNestingOfRegions(*this, DSAStack, Kind, DirName, CancelRegion,
+  // First check CancelRegion which is then used in checkNestingOfRegions.
+  if (checkCancelRegion(*this, Kind, CancelRegion, StartLoc) ||
+  checkNestingOfRegions(*this, DSAStack, Kind, DirName, CancelRegion,
 StartLoc))
 return StmtError();
 
@@ -5860,12 +5878,6 @@ StmtResult
 Sema::ActOnOpenMPCancellationPointDirective(SourceLocation StartLoc,
 SourceLocation EndLoc,
 OpenMPDirectiveKind CancelRegion) {
-  if (CancelRegion != OMPD_parallel && CancelRegion != OMPD_for &&
-  CancelRegion != OMPD_sections && CancelRegion != OMPD_taskgroup) {
-Diag(StartLoc, diag::err_omp_wrong_cancel_region)
-<< getOpenMPDirectiveName(CancelRegion);
-return StmtError();
-  }
   if (DSAStack->isParentNowaitRegion()) {
 Diag(StartLoc, diag::err_omp_parent_cancel_region_nowait) << 0;
 return StmtError();
@@ -5882,12 +5894,6 @@ StmtResult Sema::ActOnOpenMPCancelDirect
 SourceLocation StartLoc,
 SourceLocation EndLoc,
 OpenMPDirectiveKind CancelRegion) {
-  if (CancelRegion != OMPD_parallel && CancelRegion != OMPD_for &&
-  CancelRegion != OMPD_sections && CancelRegion != OMPD_taskgroup) {
-Diag(StartLoc, diag::err_omp_wrong_cancel_region)
-<< getOpenMPDirectiveName(CancelRegion);
-return StmtError();
-  }
   if (DSAStack->isParentNowaitRegion()) {
 Diag(StartLoc, diag::err_omp_parent_cancel_region_nowait) << 1;
 return StmtError();

Modified: cfe/trunk/test/OpenMP/cancel_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/cancel_messages.cpp?rev=295808&r1=295807&r2=295808&view=diff
==
--- cfe/trunk/test/OpenMP/cancel_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/cancel_messages.cpp Wed Feb 22 00:49:10 2017
@@ -4,8 +4,16 @@ int main(int argc, char **argv) {
 #pragma omp cancellation   // expected-error {{expected an OpenMP 
directive}}
 #pragma omp cancel // expected-error {{one of 'for', 'parallel', 'sections' or 
'taskgroup' is expected}}
   ;
+#pragma omp parallel
+  {
+#pragma omp cancel // expected-error {{one of 'for', 'parallel', 'sections' or 
'taskgroup'

[PATCH] D30135: [OpenMP] Generate better diagnostics for cancel and cancellation point

2017-02-21 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295808: [OpenMP] Generate better diagnostics for cancel and 
cancellation point (authored by Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D30135?vs=89106&id=89326#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30135

Files:
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/test/OpenMP/cancel_messages.cpp
  cfe/trunk/test/OpenMP/cancellation_point_messages.cpp

Index: cfe/trunk/test/OpenMP/cancel_messages.cpp
===
--- cfe/trunk/test/OpenMP/cancel_messages.cpp
+++ cfe/trunk/test/OpenMP/cancel_messages.cpp
@@ -4,8 +4,16 @@
 #pragma omp cancellation   // expected-error {{expected an OpenMP directive}}
 #pragma omp cancel // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
   ;
+#pragma omp parallel
+  {
+#pragma omp cancel // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
+  }
 #pragma omp cancel parallel untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp cancel'}}
 #pragma omp cancel unknown // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
+#pragma omp parallel
+  {
+#pragma omp cancel unknown // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
+  }
 #pragma omp cancel sections(   // expected-warning {{extra tokens at the end of '#pragma omp cancel' are ignored}}
 #pragma omp cancel for, )  // expected-warning {{extra tokens at the end of '#pragma omp cancel' are ignored}}
 #pragma omp cancel taskgroup() // expected-warning {{extra tokens at the end of '#pragma omp cancel' are ignored}}
Index: cfe/trunk/test/OpenMP/cancellation_point_messages.cpp
===
--- cfe/trunk/test/OpenMP/cancellation_point_messages.cpp
+++ cfe/trunk/test/OpenMP/cancellation_point_messages.cpp
@@ -4,8 +4,16 @@
 #pragma omp cancellation   // expected-error {{expected an OpenMP directive}}
 #pragma omp cancellation point // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
   ;
+#pragma omp parallel
+  {
+#pragma omp cancellation point // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
+  }
 #pragma omp cancellation point parallel untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp cancellation point'}}
 #pragma omp cancellation point unknown // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
+#pragma omp parallel
+  {
+#pragma omp cancellation point unknown // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
+  }
 #pragma omp cancellation point sections(   // expected-warning {{extra tokens at the end of '#pragma omp cancellation point' are ignored}}
 #pragma omp cancellation point for, )  // expected-warning {{extra tokens at the end of '#pragma omp cancellation point' are ignored}}
 #pragma omp cancellation point taskgroup() // expected-warning {{extra tokens at the end of '#pragma omp cancellation point' are ignored}}
Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -1956,7 +1956,23 @@
   return SR;
 }
 
-static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
+static bool checkCancelRegion(Sema &SemaRef, OpenMPDirectiveKind CurrentRegion,
+  OpenMPDirectiveKind CancelRegion,
+  SourceLocation StartLoc) {
+  // CancelRegion is only needed for cancel and cancellation_point.
+  if (CurrentRegion != OMPD_cancel && CurrentRegion != OMPD_cancellation_point)
+return false;
+
+  if (CancelRegion == OMPD_parallel || CancelRegion == OMPD_for ||
+  CancelRegion == OMPD_sections || CancelRegion == OMPD_taskgroup)
+return false;
+
+  SemaRef.Diag(StartLoc, diag::err_omp_wrong_cancel_region)
+  << getOpenMPDirectiveName(CancelRegion);
+  return true;
+}
+
+static bool checkNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
   OpenMPDirectiveKind CurrentRegion,
   const DeclarationNameInfo &CurrentName,
   OpenMPDirectiveKind CancelRegion,
@@ -2256,7 +2272,9 @@
 OpenMPDirectiveKind CancelRegion, ArrayRef Clauses,
 Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc) {
   StmtResult Res = StmtError();
-  if (CheckNestingOfRegions(*this, DSAStack, Kind, DirName, CancelRegion,
+  // First check CancelRegion which is then used in checkNestingOfRegions.
+  if (checkCancelRegion(*this, Kind, CancelRegion, StartLoc) ||
+  checkNestingOfRegions(*this, DSAStack, Kind, DirNam

[PATCH] D30174: [Sema][ObjC] Warn about 'performSelector' calls with selectors that return record types

2017-02-21 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

I'm not sure how common it is to pass a function that doesn't return an object 
or void, I think it's OK to allow returning primitive types if you think being 
too strict would catch too many false positives.




Comment at: lib/AST/DeclObjC.cpp:987
   unsigned noParams = param_size();
   if (noParams < 1 || noParams > 3)
 family = OMF_None;

It seems like this code would set "family" to OMF_None for some of the 
performSelector functions. For example:

https://developer.apple.com/reference/objectivec/nsobject/1411637-performselectoronmainthread?language=objc
https://developer.apple.com/reference/objectivec/nsobject/1417922-performselector?language=objc

Do those functions belong to the performSelector family of methods?



Comment at: lib/Sema/SemaExprObjC.cpp:2280
+ImpliedMethod =
+OPT->getInterfaceDecl()->lookupInstanceMethod(SE->getSelector());
+  } else {

Do you need to check if OPT->getInterfaceDecl() returns null here? What happens 
if OPT is id?



Comment at: lib/Sema/SemaExprObjC.cpp:2499
   checkCocoaAPI(*this, Result);
+if (Method)
+  checkFoundationAPI(*this, SelLoc, Method, makeArrayRef(Args, NumArgs),

I'm not sure why checkFoundationAPI has to be called inside the else statement. 
Was there a reason you didn't or couldn't move it outside?


Repository:
  rL LLVM

https://reviews.llvm.org/D30174



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