Re: [PATCH] D12834: add gcc abi_tag support

2016-01-15 Thread Stefan Bühler via cfe-commits
stbuehler updated this revision to Diff 44972.
stbuehler marked an inline comment as done.
stbuehler added a comment.

- disable dervied abi tags in some recursions to fix infinite recursions
- don't emit abi tags for NestedNameSpecifier::Identifier


Repository:
  rL LLVM

http://reviews.llvm.org/D12834

Files:
  docs/ItaniumMangleAbiTags.rst
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/AST/ItaniumMangle.cpp
  lib/Sema/SemaDeclAttr.cpp

Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4446,6 +4446,58 @@
   Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleAbiTagAttr(Sema &S, Decl *D,
+ const AttributeList &Attr) {
+  if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+return;
+
+  SmallVector Tags;
+
+  for (unsigned I = 0, E = Attr.getNumArgs(); I != E; ++I) {
+StringRef Tag;
+
+if (!S.checkStringLiteralArgumentAttr(Attr, I, Tag))
+  return;
+
+Tags.push_back(Tag);
+  }
+  // store tags sorted and without duplicates
+  std::sort(Tags.begin(), Tags.end());
+  Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
+
+  if (const auto *NS = dyn_cast(D)) {
+if (!NS->isInline()) {
+  S.Diag(Attr.getLoc(), diag::err_attr_abi_tag_only_on_inline_namespace);
+  return;
+}
+  }
+
+  const auto *CD = D->getCanonicalDecl();
+  if (CD != D) {
+// redeclarations must not add new abi tags, or abi tags in the first place
+const auto *OldAbiTagAttr = D->getAttr();
+if (nullptr == OldAbiTagAttr) {
+  S.Diag(Attr.getLoc(), diag::err_abi_tag_on_redeclaration);
+  S.Diag(CD->getLocation(), diag::note_previous_definition);
+  return;
+}
+for (const auto& NewTag: Tags) {
+  if (std::find(OldAbiTagAttr->tags_begin(),
+OldAbiTagAttr->tags_end(),
+NewTag) == OldAbiTagAttr->tags_end()) {
+S.Diag(Attr.getLoc(), diag::err_new_abi_tag_on_redeclaration) << NewTag;
+S.Diag(OldAbiTagAttr->getLocation(), diag::note_previous_definition);
+return;
+  }
+}
+return;
+  }
+
+  D->addAttr(::new (S.Context) AbiTagAttr(Attr.getRange(), S.Context,
+  Tags.data(), Tags.size(),
+  Attr.getAttributeSpellingListIndex()));
+}
+
 static void handleARMInterruptAttr(Sema &S, Decl *D,
const AttributeList &Attr) {
   // Check the attribute arguments.
@@ -5360,6 +5412,9 @@
   case AttributeList::AT_Thread:
 handleDeclspecThreadAttr(S, D, Attr);
 break;
+  case AttributeList::AT_AbiTag:
+handleAbiTagAttr(S, D, Attr);
+break;
 
   // Thread safety attributes:
   case AttributeList::AT_AssertExclusiveLock:
Index: lib/AST/ItaniumMangle.cpp
===
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -212,6 +212,8 @@
 class CXXNameMangler {
   ItaniumMangleContextImpl &Context;
   raw_ostream &Out;
+  bool NullOut = false;
+  bool DisableDerivedAbiTags = false;
 
   /// The "structor" is the top-level declaration being mangled, if
   /// that's not a template specialization; otherwise it's the pattern
@@ -261,6 +263,167 @@
 
   } FunctionTypeDepth;
 
+  // abi_tag is a gcc attribute, taking one or more strings called "tags".
+  //
+  // the goal is to annotage against which version of a library an object was
+  // build and to be able to provide backwards compatibility ("dual abi").
+  //
+  // for this the emitted mangled names have to be different, while you don't
+  // want the user to have to use different names in the source.
+  //
+  // the abi_tag can be present on Struct, Var and Function  declarations as
+  // "explicit" tag, and on inline Namespace as "implicit" tag. Explicit tags
+  // are always emitted after the unqualified name, and (implicit) tags on
+  // namespace are not.
+  //
+  // For functions and variables there is a set of "implicitly available"
+  // tags. These tags are: all tags from the namespace/structs the name is
+  // embedded in, all tags from any template arguments of the name, and, for
+  // functions, alls tags used anywhere in the  (i.e.
+  // parameters and sometimes the return type).
+  //
+  // For functions this is basically the list of all tags from the signature
+  // without the unqualified name and usually without the return type of the
+  // function. In `operator Type()` Type is NOT part of that list, as it is
+  // part of the unqualified name!
+  //
+  // Now all tags from the function return type/variable type which are not
+  // "implicitly available" must be added to the explicit list of tags, and
+  // are emitted after the unqualified name.
+  //
+  // Example:
+  // namespace std {
+  //   inline namesp

[PATCH] D16215: ASTMatchers: enable hasBody() matcher for FunctionDecls

2016-01-15 Thread Aleksei Sidorin via cfe-commits
a.sidorin created this revision.
a.sidorin added reviewers: klimek, aaron.ballman.
a.sidorin added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

This patch enables matching for FunctionDecls that have bodies.

http://reviews.llvm.org/D16215

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersTest.cpp
  unittests/ASTMatchers/Dynamic/ParserTest.cpp

Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -263,7 +263,7 @@
 "1:1: Matcher does not support binding.",
 ParseWithError("isArrow().bind(\"foo\")"));
   EXPECT_EQ("Input value has unresolved overloaded type: "
-"Matcher",
+"Matcher",
 ParseMatcherWithError("hasBody(stmt())"));
 }
 
Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2869,6 +2869,10 @@
   doStmt(hasBody(compoundStmt();
   EXPECT_TRUE(matches("void f() { int p[2]; for (auto x : p) {} }",
   cxxForRangeStmt(hasBody(compoundStmt();
+  EXPECT_TRUE(matches("void f() {}", functionDecl(hasBody(compoundStmt();
+  EXPECT_TRUE(notMatches("void f();", functionDecl(hasBody(compoundStmt();
+  EXPECT_TRUE(matches("void f(); void f() {}",
+ functionDecl(hasBody(compoundStmt();
 }
 
 TEST(HasAnySubstatement, MatchesForTopLevelCompoundStatement) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3128,7 +3128,8 @@
 AST_POLYMORPHIC_MATCHER_P(hasBody,
   AST_POLYMORPHIC_SUPPORTED_TYPES(DoStmt, ForStmt,
   WhileStmt,
-  CXXForRangeStmt),
+  CXXForRangeStmt,
+  FunctionDecl),
   internal::Matcher, InnerMatcher) {
   const Stmt *const Statement = Node.getBody();
   return (Statement != nullptr &&


Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -263,7 +263,7 @@
 "1:1: Matcher does not support binding.",
 ParseWithError("isArrow().bind(\"foo\")"));
   EXPECT_EQ("Input value has unresolved overloaded type: "
-"Matcher",
+"Matcher",
 ParseMatcherWithError("hasBody(stmt())"));
 }
 
Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2869,6 +2869,10 @@
   doStmt(hasBody(compoundStmt();
   EXPECT_TRUE(matches("void f() { int p[2]; for (auto x : p) {} }",
   cxxForRangeStmt(hasBody(compoundStmt();
+  EXPECT_TRUE(matches("void f() {}", functionDecl(hasBody(compoundStmt();
+  EXPECT_TRUE(notMatches("void f();", functionDecl(hasBody(compoundStmt();
+  EXPECT_TRUE(matches("void f(); void f() {}",
+ functionDecl(hasBody(compoundStmt();
 }
 
 TEST(HasAnySubstatement, MatchesForTopLevelCompoundStatement) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3128,7 +3128,8 @@
 AST_POLYMORPHIC_MATCHER_P(hasBody,
   AST_POLYMORPHIC_SUPPORTED_TYPES(DoStmt, ForStmt,
   WhileStmt,
-  CXXForRangeStmt),
+  CXXForRangeStmt,
+  FunctionDecl),
   internal::Matcher, InnerMatcher) {
   const Stmt *const Statement = Node.getBody();
   return (Statement != nullptr &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13289: [libc++] Provide additional templates for valarray transcendentals that satisfy the standard synopsis

2016-01-15 Thread Petr Pavlu via cfe-commits
petpav01 added a comment.

Ping. I would still like to address this problem. Could I please get a review 
on the last version of the patch?

Thanks,
Petr


http://reviews.llvm.org/D13289



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


[PATCH] D16216: Fix infinite loop when ::new or ::delete are found in member initializer list

2016-01-15 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla created this revision.
d.zobnin.bugzilla added reviewers: kcc, rsmith.
d.zobnin.bugzilla added a subscriber: cfe-commits.

Fix for a case found by fuzzing PR23057 (comment #33 
https://llvm.org/bugs/show_bug.cgi?id=23057#c33). Diagnose and consume 
unexpected ::new and ::delete tokens to prevent infinite loop in parsing a 
member initializer list.

http://reviews.llvm.org/D16216

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  lib/Parse/ParseDeclCXX.cpp
  test/Parser/cxx-invalid-function-decl.cpp

Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -3237,6 +3237,20 @@
   CXXScopeSpec SS;
   ParseOptionalCXXScopeSpecifier(SS, ParsedType(), /*EnteringContext=*/false);
   ParsedType TemplateTypeTy;
+  // If ::new or ::delete was met, ParseOptionalCXXScopeSpecifier just left
+  // them untouched. Diagnose it now to prevent infinite loop on parsing such
+  // code: "f() : ::new".
+  if (Tok.is(tok::coloncolon)) {
+tok::TokenKind NextKind = NextToken().getKind();
+if (NextKind == tok::kw_new || NextKind == tok::kw_delete) {
+  SourceRange Range(Tok.getLocation(), NextToken().getEndLoc());
+  Diag(Tok.getLocation(), diag::err_unexpected_in_member_initlist)
+  << (NextKind == tok::kw_delete) << Range;
+  ConsumeToken(); // the '::' token.
+  ConsumeToken(); // 'new' or 'delete'.
+  return true;
+}
+  }
   if (Tok.is(tok::annot_template_id)) {
 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
 if (TemplateId->Kind == TNK_Type_template ||
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -161,6 +161,8 @@
 def err_at_defs_cxx : Error<"@defs is not supported in Objective-C++">;
 def err_at_in_class : Error<"unexpected '@' in member specification">;
 def err_unexpected_semi : Error<"unexpected ';' before %0">;
+def err_unexpected_in_member_initlist : Error<
+  "unexpected %select{'::new'|'::delete'}0 in member initializer list">;
 
 def err_expected_fn_body : Error<
   "expected function body after function declarator">;
Index: test/Parser/cxx-invalid-function-decl.cpp
===
--- test/Parser/cxx-invalid-function-decl.cpp
+++ test/Parser/cxx-invalid-function-decl.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f() : X() ::new{}; // expected-error{{missing ',' between base or member 
initializers}}
+// expected-error@-1{{unexpected '::new' in member 
initializer list}}
+// expected-error@-2{{only constructors take base 
initializers}}
+
+template 
+struct Base1 {
+  T x1;
+  Base1(T a1) : x1(a1) {}
+};
+
+template 
+struct Base2 {
+  T x2;
+  Base2(T a2) : x2(a2) {}
+};
+
+struct S : public Base1, public Base2 {
+  int x;
+  S() : ::Base1(0) ::new, ::Base2(1.0) ::delete x(2) {} // 
expected-error3{{missing ',' between base or member initializers}}
+// 
expected-error@-1{{unexpected '::new' in member initializer list}}
+// 
expected-error@-2{{unexpected '::delete' in member initializer list}}
+};


Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -3237,6 +3237,20 @@
   CXXScopeSpec SS;
   ParseOptionalCXXScopeSpecifier(SS, ParsedType(), /*EnteringContext=*/false);
   ParsedType TemplateTypeTy;
+  // If ::new or ::delete was met, ParseOptionalCXXScopeSpecifier just left
+  // them untouched. Diagnose it now to prevent infinite loop on parsing such
+  // code: "f() : ::new".
+  if (Tok.is(tok::coloncolon)) {
+tok::TokenKind NextKind = NextToken().getKind();
+if (NextKind == tok::kw_new || NextKind == tok::kw_delete) {
+  SourceRange Range(Tok.getLocation(), NextToken().getEndLoc());
+  Diag(Tok.getLocation(), diag::err_unexpected_in_member_initlist)
+  << (NextKind == tok::kw_delete) << Range;
+  ConsumeToken(); // the '::' token.
+  ConsumeToken(); // 'new' or 'delete'.
+  return true;
+}
+  }
   if (Tok.is(tok::annot_template_id)) {
 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
 if (TemplateId->Kind == TNK_Type_template ||
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -161,6 +161,8 @@
 def err_at_defs_cxx : Error<"@defs is not supported in Objective-C++">;
 def err_at_in_class : Error<"unexpected '@' in member specification">;
 def err_un

Re: [PATCH] D12834: add gcc abi_tag support

2016-01-15 Thread Stefan Bühler via cfe-commits
stbuehler updated this revision to Diff 44973.
stbuehler added a comment.

integrate patch by Stephan Bergmann :

- Fix handling of abi_tag attribute on namespaces to match GCC behavior:
  - Forbid the attribute on unnamed namespaces.  (GCC merely produces a warning 
instead of an error for unnamed or non-inline namespaces, though.)
  - When no tags are given for a (named, inline) namespace, use the namespace's 
name as tag.


Repository:
  rL LLVM

http://reviews.llvm.org/D12834

Files:
  docs/ItaniumMangleAbiTags.rst
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/AST/ItaniumMangle.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCXX/attr-abi-tag-syntax.cpp
  test/SemaCXX/attr-abi-tag.cpp

Index: test/SemaCXX/attr-abi-tag.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-abi-tag.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -triple x86_64-unknown-linux -emit-llvm < %s | FileCheck %s
+
+// CHECK: @_Z5Func1B6Names1v()
+inline namespace Names1 __attribute__((__abi_tag__)) {
+class C1 {};
+}
+C1 Func1() { return C1(); }
+
+// CHECK: @_Z5Func2B4Tag1B4Tag2v()
+inline namespace Names2 __attribute__((__abi_tag__("Tag1", "Tag2"))) {
+class C2 {};
+}
+C2 Func2() { return C2(); }
Index: test/SemaCXX/attr-abi-tag-syntax.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-abi-tag-syntax.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+namespace N1 {
+
+namespace __attribute__((__abi_tag__)) {} // \
+  // expected-error {{abi_tag attribute only allowed on inline namespaces}}
+
+namespace N __attribute__((__abi_tag__)) {} // \
+  // expected-error {{abi_tag attribute only allowed on inline namespaces}}
+
+}
+
+namespace N2 {
+
+inline namespace __attribute__((__abi_tag__)) {} // \
+  // expected-error {{abi_tag attribute only allowed on named namespaces}}
+
+inline namespace N __attribute__((__abi_tag__)) {}
+
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4446,6 +4446,66 @@
   Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleAbiTagAttr(Sema &S, Decl *D,
+ const AttributeList &Attr) {
+  const auto *NS = dyn_cast(D);
+
+  if (!checkAttributeAtLeastNumArgs(S, Attr, NS ? 0 : 1))
+return;
+
+  SmallVector Tags;
+
+  for (unsigned I = 0, E = Attr.getNumArgs(); I != E; ++I) {
+StringRef Tag;
+
+if (!S.checkStringLiteralArgumentAttr(Attr, I, Tag))
+  return;
+
+Tags.push_back(Tag);
+  }
+
+  if (NS && !NS->isInline()) {
+S.Diag(Attr.getLoc(), diag::err_attr_abi_tag_only_on_inline_namespace);
+return;
+  }
+  if (NS && NS->isAnonymousNamespace()) {
+S.Diag(Attr.getLoc(), diag::err_attr_abi_tag_only_on_named_namespace);
+return;
+  }
+  if (NS && Attr.getNumArgs() == 0) {
+  Tags.push_back(NS->getName());
+  }
+
+  // store tags sorted and without duplicates
+  std::sort(Tags.begin(), Tags.end());
+  Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
+
+  const auto *CD = D->getCanonicalDecl();
+  if (CD != D) {
+// redeclarations must not add new abi tags, or abi tags in the first place
+const auto *OldAbiTagAttr = D->getAttr();
+if (nullptr == OldAbiTagAttr) {
+  S.Diag(Attr.getLoc(), diag::err_abi_tag_on_redeclaration);
+  S.Diag(CD->getLocation(), diag::note_previous_definition);
+  return;
+}
+for (const auto& NewTag: Tags) {
+  if (std::find(OldAbiTagAttr->tags_begin(),
+OldAbiTagAttr->tags_end(),
+NewTag) == OldAbiTagAttr->tags_end()) {
+S.Diag(Attr.getLoc(), diag::err_new_abi_tag_on_redeclaration) << NewTag;
+S.Diag(OldAbiTagAttr->getLocation(), diag::note_previous_definition);
+return;
+  }
+}
+return;
+  }
+
+  D->addAttr(::new (S.Context) AbiTagAttr(Attr.getRange(), S.Context,
+  Tags.data(), Tags.size(),
+  Attr.getAttributeSpellingListIndex()));
+}
+
 static void handleARMInterruptAttr(Sema &S, Decl *D,
const AttributeList &Attr) {
   // Check the attribute arguments.
@@ -5360,6 +5420,9 @@
   case AttributeList::AT_Thread:
 handleDeclspecThreadAttr(S, D, Attr);
 break;
+  case AttributeList::AT_AbiTag:
+handleAbiTagAttr(S, D, Attr);
+break;
 
   // Thread safety attributes:
   case AttributeList::AT_AssertExclusiveLock:
Index: lib/AST/ItaniumMangle.cpp
===
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -212,6 +212,8 @@
 class CXXNameMangler {
   ItaniumMangleContextImpl &Context;
   raw_ostream &Out;
+  bool NullOut = false;
+ 

Re: [PATCH] D16215: ASTMatchers: enable hasBody() matcher for FunctionDecls

2016-01-15 Thread Aleksei Sidorin via cfe-commits
a.sidorin updated this revision to Diff 44975.
a.sidorin added a comment.

Update comments and documentation.


http://reviews.llvm.org/D16215

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersTest.cpp
  unittests/ASTMatchers/Dynamic/ParserTest.cpp

Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -263,7 +263,7 @@
 "1:1: Matcher does not support binding.",
 ParseWithError("isArrow().bind(\"foo\")"));
   EXPECT_EQ("Input value has unresolved overloaded type: "
-"Matcher",
+"Matcher",
 ParseMatcherWithError("hasBody(stmt())"));
 }
 
Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2858,7 +2858,7 @@
   compoundStmt()));
 }
 
-TEST(HasBody, FindsBodyOfForWhileDoLoops) {
+TEST(HasBody, FindsBodyOfForWhileDoLoopsAndFunctions) {
   EXPECT_TRUE(matches("void f() { for(;;) {} }",
   forStmt(hasBody(compoundStmt();
   EXPECT_TRUE(notMatches("void f() { for(;;); }",
@@ -2869,6 +2869,10 @@
   doStmt(hasBody(compoundStmt();
   EXPECT_TRUE(matches("void f() { int p[2]; for (auto x : p) {} }",
   cxxForRangeStmt(hasBody(compoundStmt();
+  EXPECT_TRUE(matches("void f() {}", functionDecl(hasBody(compoundStmt();
+  EXPECT_TRUE(notMatches("void f();", functionDecl(hasBody(compoundStmt();
+  EXPECT_TRUE(matches("void f(); void f() {}",
+ functionDecl(hasBody(compoundStmt();
 }
 
 TEST(HasAnySubstatement, MatchesForTopLevelCompoundStatement) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3114,8 +3114,8 @@
   return false;
 }
 
-/// \brief Matches a 'for', 'while', or 'do while' statement that has
-/// a given body.
+/// \brief Matches a 'for', 'while', 'do while' statement or a function
+/// declaration that has a given body.
 ///
 /// Given
 /// \code
@@ -3128,7 +3128,8 @@
 AST_POLYMORPHIC_MATCHER_P(hasBody,
   AST_POLYMORPHIC_SUPPORTED_TYPES(DoStmt, ForStmt,
   WhileStmt,
-  CXXForRangeStmt),
+  CXXForRangeStmt,
+  FunctionDecl),
   internal::Matcher, InnerMatcher) {
   const Stmt *const Statement = Node.getBody();
   return (Statement != nullptr &&
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3400,8 +3400,8 @@
 
 
 MatcherCXXForRangeStmt>hasBodyMatcherStmt> InnerMatcher
-Matches a 'for', 'while', or 'do while' statement that has
-a given body.
+Matches a 'for', 'while', 'do while' statement or a function
+declaration that has a given body.
 
 Given
   for (;;) {}
@@ -3825,8 +3825,8 @@
 
 
 MatcherDoStmt>hasBodyMatcherStmt> InnerMatcher
-Matches a 'for', 'while', or 'do while' statement that has
-a given body.
+Matches a 'for', 'while', 'do while' statement or a function
+declaration that has a given body.
 
 Given
   for (;;) {}
@@ -4006,8 +4006,8 @@
 
 
 MatcherForStmt>hasBodyMatcherStmt> InnerMatcher
-Matches a 'for', 'while', or 'do while' statement that has
-a given body.
+Matches a 'for', 'while', 'do while' statement or a function
+declaration that has a given body.
 
 Given
   for (;;) {}
@@ -4061,6 +4061,19 @@
 
 
 
+MatcherFunctionDecl>hasBodyMatcherStmt> InnerMatcher
+Matches a 'for', 'while', 'do while' statement or a function
+declaration that has a given body.
+
+Given
+  for (;;) {}
+hasBody(compoundStmt())
+  matches 'for (;;) {}'
+with compoundStmt()
+  matching '{}'
+
+
+
 MatcherFunctionDecl>hasParameterunsigned N, MatcherParmVarDecl> InnerMatcher
 Matches the n'th parameter of a function d

Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too

2016-01-15 Thread Stefan Kemnitz via cfe-commits
realincubus added a comment.

ok after i checked out a recent version of clang and applied the patch 
http://reviews.llvm.org/D15729 i can verify, that one does not have to add the 
symbols to the libclang.exports file.

i believe the plugin mechanism was changed between the first version of my 
plugin and how it works right now.
i will now try to find out why the test doesn't work like it should or write 
another one.


http://reviews.llvm.org/D15729



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


RE: r257827 - [CMake] Set SVN_REVISION if CLANG_APPEND_VC_REV=On

2016-01-15 Thread Daniel Sanders via cfe-commits
Hi Chris,

This doesn't seem to work when building clang separately from llvm. LLVMLinux 
fails to build clang with:
CMake Error at CMakeLists.txt:104 (include):
  include could not find load file:

VersionFromVCS

CMake Error at CMakeLists.txt:222 (add_version_info_from_vcs):
  Unknown CMake command "add_version_info_from_vcs".
See 
http://buildbot.llvm.linuxfoundation.org/builders/13_malta/builds/383/steps/shell_3/logs/stdio
 for the full log.

I've added a patch to llvmlinux to work around the problem for now 
http://git.linuxfoundation.org/?p=llvmlinux.git;a=blob;f=toolchain/clang/patches/clang/workaround-versionfromvcsbug.patch;h=848a096df37b1255575650680a266234f5d4936e;hb=e0c4c72c5a008006dc230db748ea69e0d1518daf.
Should we make that change to clang or fix it another way?

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Chris Bieneman via cfe-commits
> Sent: 14 January 2016 22:45
> To: cfe-commits@lists.llvm.org
> Subject: r257827 - [CMake] Set SVN_REVISION if
> CLANG_APPEND_VC_REV=On
> 
> Author: cbieneman
> Date: Thu Jan 14 16:45:12 2016
> New Revision: 257827
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=257827&view=rev
> Log:
> [CMake] Set SVN_REVISION if CLANG_APPEND_VC_REV=On
> 
> This matches autoconf's ability to put clang revisions in the clang --version
> spew.
> 
> Modified:
> cfe/trunk/CMakeLists.txt
> 
> Modified: cfe/trunk/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/CMakeLists.txt?rev=257827&r1=257826&r2=257827&view
> =diff
> ==
> 
> --- cfe/trunk/CMakeLists.txt (original)
> +++ cfe/trunk/CMakeLists.txt Thu Jan 14 16:45:12 2016
> @@ -101,6 +101,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
>include(AddLLVM)
>include(TableGen)
>include(HandleLLVMOptions)
> +  include(VersionFromVCS)
> 
>set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
> 
> @@ -213,6 +214,18 @@ if(CLANG_REPOSITORY_STRING)
>add_definitions(-
> DCLANG_REPOSITORY_STRING="${CLANG_REPOSITORY_STRING}")
>  endif()
> 
> +option(CLANG_APPEND_VC_REV
> +  "Append the version control system revision id to clang version spew"
> OFF)
> +
> +if(NOT SVN_REVISION)
> +  # This macro will set SVN_REVISION in the parent scope
> +  add_version_info_from_vcs(VERSION_VAR)
> +endif()
> +
> +if(SVN_REVISION)
> +  add_definitions(-DSVN_REVISION="${SVN_REVISION}")
> +endif()
> +
>  set(CLANG_VENDOR_UTI "org.llvm.clang" CACHE STRING
>"Vendor-specific uti.")
> 
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15373: Fix for bug 25786 - Assertion "Chunk.Kind == DeclaratorChunk::Function" failed with regparm attribute.

2016-01-15 Thread Alexander Makarov via cfe-commits
a.makarov added a comment.

Thanks for review! I've understood your idea, I'm working on updating the patch.


http://reviews.llvm.org/D15373



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


Re: [PATCH] D12834: add gcc abi_tag support

2016-01-15 Thread Evangelos Foutras via cfe-commits
foutrelis added a comment.

The latest patch still applies (relatively cleanly) to Clang 3.7.x which is 
nice. The infinite recursion segfaults appear to be gone, thanks!

There are a few test failures which I assume will be need to be addressed later 
on: F1315853: clang-diff-44973-test-failures.log 



Repository:
  rL LLVM

http://reviews.llvm.org/D12834



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


Re: [PATCH] D15506: [ASTMatchers] Allow hasName() to look through inline namespaces

2016-01-15 Thread Alexander Kornienko via cfe-commits
alexfh added a subscriber: alexfh.
alexfh added a comment.

Manuel, can you take a look at this?


http://reviews.llvm.org/D15506



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


Re: [PATCH] D16215: ASTMatchers: enable hasBody() matcher for FunctionDecls

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

The examples and test code you use seem to imply that the isDefinition() 
matcher may be all you need; is isDefinition() insufficient for some reason? If 
so, can you expand the test cases to cover that particular usage? Also, 
FunctionDecl::getBody() does more work than FunctionDecl::hasBody() -- it would 
be better to implement the AST matcher in terms of FunctionDecl::hasBody() 
instead.


http://reviews.llvm.org/D16215



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


Re: [PATCH] D15506: [ASTMatchers] Allow hasName() to look through inline namespaces

2016-01-15 Thread Manuel Klimek via cfe-commits
klimek added a reviewer: bkramer.
klimek added a comment.

Adding Benjamin for an additional pair of eyes.
Generally looks good.



Comment at: lib/ASTMatchers/ASTMatchersInternal.cpp:351
@@ +350,3 @@
+
+  // First, match the name.
+  if (!MatchNodeName(Pattern, Node))

Perhaps comment that Pattern will be changed to the prefix, so it's clear 
afterwards.
(I wonder whether returning a tuple might be slightly easier to understand here)


http://reviews.llvm.org/D15506



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


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

2016-01-15 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla created this revision.
d.zobnin.bugzilla added a reviewer: aaron.ballman.
d.zobnin.bugzilla added a subscriber: cfe-commits.

Allow "mode" attribute for enum types, except for vector modes, for 
compatibility with GCC. Support "mode" attribute with dependent types.

http://reviews.llvm.org/D16219

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

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

Re: [libcxxabi] r256323 - Add new tests for throwing incomplete pointer types

2016-01-15 Thread Nico Weber via cfe-commits
This test fails on OS X for me:


Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: libc++abi :: incomplete_type.sh.cpp (29529 of 29545)
 TEST 'libc++abi :: incomplete_type.sh.cpp' FAILED

Script:
--
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-v -DLIBCXXABI_NO_TIMER -funwind-tables -std=c++1z -nostdinc++
-I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include
-I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
-isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
-c
/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/test/incomplete_type.sh.cpp
-o
/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-v -DLIBCXXABI_NO_TIMER -funwind-tables -std=c++1z -nostdinc++
-I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include
-I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
-isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
-c
/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/test/incomplete_type.sh.cpp
-o
/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.two.o
-DTU_ONE
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-v -nodefaultlibs
-L/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/lib
-Wl,-rpath,/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/lib
-lc++ -lc++abi -lSystem -o
/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.exe
/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.two.o
/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.exe
--
Exit Code: 134

Command Output (stderr):
--
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
 
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
-cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage
-Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name incomplete_type.sh.cpp
-mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim
-masm-verbose -munwind-tables -target-cpu core2 -target-linker-version
253.6 -v -dwarf-column-info -coverage-file
/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
-nostdinc++ -resource-dir
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0
-isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
-D LIBCXXABI_NO_TIMER -I
/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include -I
/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
-stdlib=libc++ -std=c++1z -fdeprecated-macro -fdebug-compilation-dir
/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test
-ferror-limit 19 -fmessage-length 0 -stack-protector 1 -mstackrealign
-fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature
-fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option
-o
/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
-x c++
/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/test/incomplete_type.sh.cpp
clang -cc1 version 7.0.0 based upon LLVM 3.7.0svn default target
x86_64-apple-darwin15.0.0
ignoring nonexistent directory
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/local/include"
ignoring nonexistent directory
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include
 /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0/include
 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include
 
/Applications/Xcode.app/Contents/Developer/

Re: [libcxxabi] r256323 - Add new tests for throwing incomplete pointer types

2016-01-15 Thread Nico Weber via cfe-commits
I reverted this and 322 for now in 257896.

On Fri, Jan 15, 2016 at 10:36 AM, Nico Weber  wrote:

> This test fails on OS X for me:
>
>
> Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
> FAIL: libc++abi :: incomplete_type.sh.cpp (29529 of 29545)
>  TEST 'libc++abi :: incomplete_type.sh.cpp' FAILED
> 
> Script:
> --
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
> -v -DLIBCXXABI_NO_TIMER -funwind-tables -std=c++1z -nostdinc++
> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include
> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
> -isysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
> -c
> /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/test/incomplete_type.sh.cpp
> -o
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
> -v -DLIBCXXABI_NO_TIMER -funwind-tables -std=c++1z -nostdinc++
> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include
> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
> -isysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
> -c
> /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/test/incomplete_type.sh.cpp
> -o
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.two.o
> -DTU_ONE
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
> -v -nodefaultlibs
> -L/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/lib
> -Wl,-rpath,/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/lib
> -lc++ -lc++abi -lSystem -o
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.exe
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.two.o
>
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.exe
> --
> Exit Code: 134
>
> Command Output (stderr):
> --
> Apple LLVM version 7.0.0 (clang-700.1.76)
> Target: x86_64-apple-darwin15.0.0
> Thread model: posix
>  
> "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
> -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage
> -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free
> -disable-llvm-verifier -main-file-name incomplete_type.sh.cpp
> -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim
> -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version
> 253.6 -v -dwarf-column-info -coverage-file
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
> -nostdinc++ -resource-dir
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0
> -isysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
> -D LIBCXXABI_NO_TIMER -I
> /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include -I
> /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
> -stdlib=libc++ -std=c++1z -fdeprecated-macro -fdebug-compilation-dir
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test
> -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -mstackrealign
> -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature
> -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option
> -o
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
> -x c++
> /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/test/incomplete_type.sh.cpp
> clang -cc1 version 7.0.0 based upon LLVM 3.7.0svn default target
> x86_64-apple-darwin15.0.0
> ignoring nonexistent directory
> "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/local/include"
> ignoring nonexistent directory
> "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/Library/Frameworks"
> #include "..." search starts here:
> #include <...> search starts here:
>  /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include
>  /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
>
>  
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang

[libcxxabi] r257896 - Revert r256322 (and follow-up 256323), the test it added does not pass on OS X.

2016-01-15 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Jan 15 09:44:14 2016
New Revision: 257896

URL: http://llvm.org/viewvc/llvm-project?rev=257896&view=rev
Log:
Revert r256322 (and follow-up 256323), the test it added does not pass on OS X.

Removed:
libcxxabi/trunk/test/incomplete_type.sh.cpp
Modified:
libcxxabi/trunk/src/private_typeinfo.cpp

Modified: libcxxabi/trunk/src/private_typeinfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/private_typeinfo.cpp?rev=257896&r1=257895&r2=257896&view=diff
==
--- libcxxabi/trunk/src/private_typeinfo.cpp (original)
+++ libcxxabi/trunk/src/private_typeinfo.cpp Fri Jan 15 09:44:14 2016
@@ -34,12 +34,9 @@
 // 
 // _LIBCXX_DYNAMIC_FALLBACK is currently off by default.
 
-
-#include 
-
-
 #ifdef _LIBCXX_DYNAMIC_FALLBACK
 #include "abort_message.h"
+#include 
 #include 
 #endif
 
@@ -60,19 +57,31 @@ namespace __cxxabiv1
 
 #pragma GCC visibility push(hidden)
 
+#ifdef _LIBCXX_DYNAMIC_FALLBACK
+
 inline
 bool
 is_equal(const std::type_info* x, const std::type_info* y, bool use_strcmp)
 {
-#ifndef _WIN32
 if (!use_strcmp)
 return x == y;
 return strcmp(x->name(), y->name()) == 0;
+}
+
+#else  // !_LIBCXX_DYNAMIC_FALLBACK
+
+inline
+bool
+is_equal(const std::type_info* x, const std::type_info* y, bool)
+{
+#ifndef _WIN32
+return x == y;
 #else
 return (x == y) || (strcmp(x->name(), y->name()) == 0);
-#endif
+#endif
 }
 
+#endif  // _LIBCXX_DYNAMIC_FALLBACK
 
 // __shim_type_info
 
@@ -342,17 +351,8 @@ bool
 __pbase_type_info::can_catch(const __shim_type_info* thrown_type,
  void*&) const
 {
-if (is_equal(thrown_type, &typeid(std::nullptr_t), false)) return true;
-bool use_strcmp = this->__flags & (__incomplete_class_mask |
-   __incomplete_mask);
-if (!use_strcmp) {
-const __pbase_type_info* thrown_pbase = dynamic_cast(
-thrown_type);
-if (!thrown_pbase) return false;
-use_strcmp = thrown_pbase->__flags & (__incomplete_class_mask |
-  __incomplete_mask);
-}
-return is_equal(this, thrown_type, use_strcmp);
+return is_equal(this, thrown_type, false) ||
+   is_equal(thrown_type, &typeid(std::nullptr_t), false);
 }
 
 #ifdef __clang__

Removed: libcxxabi/trunk/test/incomplete_type.sh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/incomplete_type.sh.cpp?rev=257895&view=auto
==
--- libcxxabi/trunk/test/incomplete_type.sh.cpp (original)
+++ libcxxabi/trunk/test/incomplete_type.sh.cpp (removed)
@@ -1,162 +0,0 @@
-//===- incomplete_type.cpp 
--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-// http://mentorembedded.github.io/cxx-abi/abi.html#rtti-layout
-
-// Two abi::__pbase_type_info objects can always be compared for equality
-// (i.e. of the types represented) or ordering by comparison of their name
-// NTBS addresses. In addition, unless either or both have either of the
-// incomplete flags set, equality can be tested by comparing the type_info
-// addresses.
-
-// RUN: %cxx %flags %compile_flags -c %s -o %t.one.o
-// RUN: %cxx %flags %compile_flags -c %s -o %t.two.o -DTU_ONE
-// RUN: %cxx %flags %link_flags -o %t.exe %t.one.o %t.two.o
-// RUN: %t.exe
-
-#include 
-#include 
-#include 
-
-struct NeverDefined;
-void ThrowNeverDefinedMP();
-
-struct IncompleteAtThrow;
-void ThrowIncompleteMP();
-void ThrowIncompletePP();
-void ThrowIncompletePMP();
-std::type_info const& ReturnTypeInfoIncompleteMP();
-std::type_info const& ReturnTypeInfoIncompletePP();
-
-struct CompleteAtThrow;
-void ThrowCompleteMP();
-void ThrowCompletePP();
-void ThrowCompletePMP();
-std::type_info const& ReturnTypeInfoCompleteMP();
-std::type_info const& ReturnTypeInfoCompletePP();
-
-void ThrowNullptr();
-
-#ifndef TU_ONE
-
-void ThrowNeverDefinedMP() { throw (int NeverDefined::*)nullptr; }
-
-void ThrowIncompleteMP() { throw (int IncompleteAtThrow::*)nullptr; }
-void ThrowIncompletePP() { throw (IncompleteAtThrow**)nullptr; }
-void ThrowIncompletePMP() { throw (int IncompleteAtThrow::**)nullptr; }
-
-std::type_info const& ReturnTypeInfoIncompleteMP() { return typeid(int 
IncompleteAtThrow::*); }
-std::type_info const& ReturnTypeInfoIncompletePP() { return 
typeid(IncompleteAtThrow**); }
-
-struct CompleteAtThrow {};
-void ThrowCompleteMP() { throw (int CompleteAtThrow::*)nullptr; }
-void ThrowCompletePP() { throw (CompleteAtThrow**)nullptr; }
-void ThrowCompletePMP() { throw (int CompleteAtThrow::**)nullptr; }
-
-std::type_info const& ReturnTypeInfoCom

Re: [PATCH] D15448: [analyzer] SVal Visitor.

2016-01-15 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

Managed to reproduce the build error with `-fmodules` on my machine.
Committed the updated patch as r257893, the buildbot seems happy.
I hope this review is actually closed now :)


http://reviews.llvm.org/D15448



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


[clang-tools-extra] r257900 - [clang-tidy] Fix a copy-paste error.

2016-01-15 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Jan 15 10:16:47 2016
New Revision: 257900

URL: http://llvm.org/viewvc/llvm-project?rev=257900&view=rev
Log:
[clang-tidy] Fix a copy-paste error.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=257900&r1=257899&r2=257900&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Fri Jan 
15 10:16:47 2016
@@ -226,7 +226,7 @@ ClangTidyOptions ClangTidyContext::getOp
   // Merge options on top of getDefaults() as a safeguard against options with
   // unset values.
   return ClangTidyOptions::getDefaults().mergeWith(
-  OptionsProvider->getOptions(CurrentFile));
+  OptionsProvider->getOptions(File));
 }
 
 void ClangTidyContext::setCheckProfileData(ProfileData *P) { Profile = P; }


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


Re: [PATCH] D15173: [Preprocessor] Fix assertion in AnnotatePreviousCachedTokens

2016-01-15 Thread Bruno Cardoso Lopes via cfe-commits
Ping :-)

On Mon, Jan 11, 2016 at 8:49 AM, Bruno Cardoso Lopes
 wrote:
> bruno added a comment.
>
> Ping!
>
>
> http://reviews.llvm.org/D15173
>
>
>



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r257893 - [analyzer] Provide .def-files and visitors for SVal/SymExpr/MemRegion, v2.

2016-01-15 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Jan 15 09:22:05 2016
New Revision: 257893

URL: http://llvm.org/viewvc/llvm-project?rev=257893&view=rev
Log:
[analyzer] Provide .def-files and visitors for SVal/SymExpr/MemRegion, v2.

Provide separate visitor templates for the three hierarchies, and also
the `FullSValVisitor' class, which is a union of all three visitors.

Additionally, add a particular example visitor, `SValExplainer', in order to
test the visitor templates. This visitor is capable of explaining the SVal,
SymExpr, or MemRegion in a natural language.

Compared to the reverted r257605, this fixes the test that used to fail
on some triples, and fixes build failure under -fmodules.

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

Added:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Symbols.def
cfe/trunk/test/Analysis/explain-svals.cpp
Modified:
cfe/trunk/docs/analyzer/DebugChecks.rst
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
cfe/trunk/include/clang/module.modulemap
cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp

Modified: cfe/trunk/docs/analyzer/DebugChecks.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/DebugChecks.rst?rev=257893&r1=257892&r2=257893&view=diff
==
--- cfe/trunk/docs/analyzer/DebugChecks.rst (original)
+++ cfe/trunk/docs/analyzer/DebugChecks.rst Fri Jan 15 09:22:05 2016
@@ -162,6 +162,41 @@ ExprInspection checks
 } while(0);  // expected-warning{{SYMBOL DEAD}}
 
 
+- void clang_analyzer_explain(a single argument of any type);
+
+  This function explains the value of its argument in a human-readable manner
+  in the warning message. You can make as many overrides of its prototype
+  in the test code as necessary to explain various integral, pointer,
+  or even record-type values.
+
+  Example usage::
+
+void clang_analyzer_explain(int);
+void clang_analyzer_explain(void *);
+
+void foo(int param, void *ptr) {
+  clang_analyzer_explain(param); // expected-warning{{argument 'param'}}
+  if (!ptr)
+clang_analyzer_explain(ptr); // expected-warning{{memory address '0'}}
+}
+
+- size_t clang_analyzer_getExtent(void *);
+
+  This function returns the value that represents the extent of a memory region
+  pointed to by the argument. This value is often difficult to obtain 
otherwise,
+  because no valid code that produces this value. However, it may be useful
+  for testing purposes, to see how well does the analyzer model region extents.
+
+  Example usage::
+
+void foo() {
+  int x, *y;
+  size_t xs = clang_analyzer_getExtent(&x);
+  clang_analyzer_explain(xs); // expected-warning{{'4'}}
+  size_t ys = clang_analyzer_getExtent(&y);
+  clang_analyzer_explain(ys); // expected-warning{{'8'}}
+}
+
 Statistics
 ==
 

Added: cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h?rev=257893&view=auto
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h (added)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h Fri Jan 15 
09:22:05 2016
@@ -0,0 +1,233 @@
+//== SValExplainer.h - Symbolic value explainer -*- C++ 
-*--==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines SValExplainer, a class for pretty-printing a
+//  human-readable description of a symbolic value. For example,
+//  "reg_$0" is turned into "initial value of variable 'x'".
+//
+//===--===//
+
+#ifndef LLVM_CLANG_STATICANALYZER_CHECKERS_SVALEXPLAINER_H
+#define LLVM_CLANG_STATICANALYZER_CHECKERS_SVALEXPLAINER_H
+
+#include "clang/AST/DeclCXX.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
+
+namespace clang {
+
+namespace ento {
+
+class SValExplainer : public FullSValVisitor {
+private:
+  ASTContext &ACtx;
+
+  std::string printStmt(const Stmt *S) {
+std::string Str;
+llvm::raw_string_ostream OS(Str);
+S->printPretty(OS, nullptr, PrintingPolicy(ACtx.getLangOpts()));
+return OS.str();
+

Re: r257868 - PR26111: segmentation fault with __attribute__((mode(QI))) on function declaration, by Denis Zobnin

2016-01-15 Thread Hans Wennborg via cfe-commits
Should this be merged to 3.8?

On Thu, Jan 14, 2016 at 8:36 PM, Alexey Bataev via cfe-commits
 wrote:
> Author: abataev
> Date: Thu Jan 14 22:36:32 2016
> New Revision: 257868
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257868&view=rev
> Log:
> PR26111: segmentation fault with __attribute__((mode(QI))) on function 
> declaration, by Denis Zobnin
> Allow "mode" attribute to be applied to VarDecl, not ValueDecl (which 
> includes FunctionDecl and EnumConstantDecl), emit an error if this attribute 
> is used with function declarations and enum constants.
> Differential Revision: http://reviews.llvm.org/D16112
>
> Modified:
> cfe/trunk/include/clang/AST/Decl.h
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/test/Sema/attr-mode.c
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r257868 - PR26111: segmentation fault with __attribute__((mode(QI))) on function declaration, by Denis Zobnin

2016-01-15 Thread Aaron Ballman via cfe-commits
On Fri, Jan 15, 2016 at 11:52 AM, Hans Wennborg via cfe-commits
 wrote:
> Should this be merged to 3.8?

I can't speak to whether it severe enough to warrant it, but I think
that it is sufficiently safe to merge.

~Aaron

>
> On Thu, Jan 14, 2016 at 8:36 PM, Alexey Bataev via cfe-commits
>  wrote:
>> Author: abataev
>> Date: Thu Jan 14 22:36:32 2016
>> New Revision: 257868
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=257868&view=rev
>> Log:
>> PR26111: segmentation fault with __attribute__((mode(QI))) on function 
>> declaration, by Denis Zobnin
>> Allow "mode" attribute to be applied to VarDecl, not ValueDecl (which 
>> includes FunctionDecl and EnumConstantDecl), emit an error if this attribute 
>> is used with function declarations and enum constants.
>> Differential Revision: http://reviews.llvm.org/D16112
>>
>> Modified:
>> cfe/trunk/include/clang/AST/Decl.h
>> cfe/trunk/include/clang/Basic/Attr.td
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> cfe/trunk/test/Sema/attr-mode.c
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r257827 - [CMake] Set SVN_REVISION if CLANG_APPEND_VC_REV=On

2016-01-15 Thread Chris Bieneman via cfe-commits
Thanks for the heads up. It looks like that module is was excluded from the 
LLVM install. I’ve changed that in LLVM r257909. That change should resolve 
your build issue. Please let me know if you continue having problems.

Thanks,
-Chris

> On Jan 15, 2016, at 5:18 AM, Daniel Sanders  wrote:
> 
> Hi Chris,
> 
> This doesn't seem to work when building clang separately from llvm. LLVMLinux 
> fails to build clang with:
>   CMake Error at CMakeLists.txt:104 (include):
> include could not find load file:
>   
>   VersionFromVCS
> 
>   CMake Error at CMakeLists.txt:222 (add_version_info_from_vcs):
> Unknown CMake command "add_version_info_from_vcs".
> See 
> http://buildbot.llvm.linuxfoundation.org/builders/13_malta/builds/383/steps/shell_3/logs/stdio
>  for the full log.
> 
> I've added a patch to llvmlinux to work around the problem for now 
> http://git.linuxfoundation.org/?p=llvmlinux.git;a=blob;f=toolchain/clang/patches/clang/workaround-versionfromvcsbug.patch;h=848a096df37b1255575650680a266234f5d4936e;hb=e0c4c72c5a008006dc230db748ea69e0d1518daf.
> Should we make that change to clang or fix it another way?
> 
>> -Original Message-
>> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
>> Of Chris Bieneman via cfe-commits
>> Sent: 14 January 2016 22:45
>> To: cfe-commits@lists.llvm.org
>> Subject: r257827 - [CMake] Set SVN_REVISION if
>> CLANG_APPEND_VC_REV=On
>> 
>> Author: cbieneman
>> Date: Thu Jan 14 16:45:12 2016
>> New Revision: 257827
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=257827&view=rev
>> Log:
>> [CMake] Set SVN_REVISION if CLANG_APPEND_VC_REV=On
>> 
>> This matches autoconf's ability to put clang revisions in the clang --version
>> spew.
>> 
>> Modified:
>>cfe/trunk/CMakeLists.txt
>> 
>> Modified: cfe/trunk/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-
>> project/cfe/trunk/CMakeLists.txt?rev=257827&r1=257826&r2=257827&view
>> =diff
>> ==
>> 
>> --- cfe/trunk/CMakeLists.txt (original)
>> +++ cfe/trunk/CMakeLists.txt Thu Jan 14 16:45:12 2016
>> @@ -101,6 +101,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
>>   include(AddLLVM)
>>   include(TableGen)
>>   include(HandleLLVMOptions)
>> +  include(VersionFromVCS)
>> 
>>   set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
>> 
>> @@ -213,6 +214,18 @@ if(CLANG_REPOSITORY_STRING)
>>   add_definitions(-
>> DCLANG_REPOSITORY_STRING="${CLANG_REPOSITORY_STRING}")
>> endif()
>> 
>> +option(CLANG_APPEND_VC_REV
>> +  "Append the version control system revision id to clang version spew"
>> OFF)
>> +
>> +if(NOT SVN_REVISION)
>> +  # This macro will set SVN_REVISION in the parent scope
>> +  add_version_info_from_vcs(VERSION_VAR)
>> +endif()
>> +
>> +if(SVN_REVISION)
>> +  add_definitions(-DSVN_REVISION="${SVN_REVISION}")
>> +endif()
>> +
>> set(CLANG_VENDOR_UTI "org.llvm.clang" CACHE STRING
>>   "Vendor-specific uti.")
>> 
>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


Re: [PATCH] D16113: [clang-tdiy] Add header file extension configuration support.

2016-01-15 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 45006.
hokein marked an inline comment as done.
hokein added a comment.

Add extension-less header file doc.


http://reviews.llvm.org/D16113

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h
  clang-tidy/google/GlobalNamesInHeadersCheck.cpp
  clang-tidy/google/GlobalNamesInHeadersCheck.h
  clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
  clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
  clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tidy/utils/CMakeLists.txt
  clang-tidy/utils/HeaderFileExtensionsUtils.cpp
  clang-tidy/utils/HeaderFileExtensionsUtils.h

Index: clang-tidy/utils/HeaderFileExtensionsUtils.h
===
--- /dev/null
+++ clang-tidy/utils/HeaderFileExtensionsUtils.h
@@ -0,0 +1,54 @@
+//===--- HeaderFileExtensionsUtils.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
+
+#include 
+
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/Support/Path.h"
+
+namespace clang {
+namespace tidy {
+namespace header_file_extensions_utils {
+
+typedef llvm::SmallSet HeaderFileExtensionsSet;
+
+/// \brief Checks whether expansion location of Loc is in header file.
+bool isExpansionLocInHeaderFile(
+SourceLocation Loc,
+const SourceManager &SM,
+const HeaderFileExtensionsSet &HeaderFileExtensions);
+
+/// \brief Checks whether presumed location of Loc is in header file.
+bool isPresumedLocInHeaderFile(
+SourceLocation Loc,
+SourceManager &SM,
+const HeaderFileExtensionsSet &HeaderFileExtensions);
+
+/// \brief Checks whether spelling location of Loc is in header file.
+bool isSpellingLocInHeaderFile(
+SourceLocation Loc,
+SourceManager &SM,
+const HeaderFileExtensionsSet &HeaderFileExtensions);
+
+/// \brief Parses header file extensions from a comma-separated list.
+bool parseHeaderFileExtensions(llvm::StringRef AllHeaderFileExtensions,
+   HeaderFileExtensionsSet &HeaderFileExtensions);
+
+
+} // namespace header_file_extensions_utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
Index: clang-tidy/utils/HeaderFileExtensionsUtils.cpp
===
--- /dev/null
+++ clang-tidy/utils/HeaderFileExtensionsUtils.cpp
@@ -0,0 +1,67 @@
+//===--- HeaderFileExtensionsUtils.cpp - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "HeaderFileExtensionsUtils.h"
+#include "clang/Basic/CharInfo.h"
+
+namespace clang {
+namespace tidy {
+namespace header_file_extensions_utils {
+
+bool isExpansionLocInHeaderFile(
+SourceLocation Loc,
+const SourceManager &SM,
+const HeaderFileExtensionsSet &HeaderFileExtensions) {
+  SourceLocation ExpansionLoc = SM.getExpansionLoc(Loc);
+  StringRef FileExtension = llvm::sys::path::extension(
+  SM.getFilename(ExpansionLoc));
+  return HeaderFileExtensions.count(FileExtension.substr(1)) > 0;
+}
+
+bool isPresumedLocInHeaderFile(
+SourceLocation Loc,
+SourceManager &SM,
+const HeaderFileExtensionsSet &HeaderFileExtensions) {
+  PresumedLoc PresumedLocation = SM.getPresumedLoc(Loc);
+  StringRef FileExtension = llvm::sys::path::extension(
+  PresumedLocation.getFilename());
+  return HeaderFileExtensions.count(FileExtension.substr(1)) > 0;
+}
+
+bool isSpellingLocInHeaderFile(
+SourceLocation Loc,
+SourceManager &SM,
+const HeaderFileExtensionsSet &HeaderFileExtensions) {
+  SourceLocation SpellingLoc = SM.getSpellingLoc(Loc);
+  StringRef FileExtension = llvm::sys::path::extension(
+  SM.getFilename(SpellingLoc));
+
+  return HeaderFileExtensions.count(FileExtension.substr(1)) > 0;
+}
+
+bool parseHeaderFileExtensions(llvm::StringRef AllHeaderFileExtensions,
+   HeaderFileExtensionsSet &HeaderFileExtensions) {
+  SmallVector Suffixes;
+  AllHeaderFileExtensions.split(Suffixes, ',');
+  HeaderFileExtensions.clear();
+  for (llvm::StringRef Suffix : Suffixes) {
+llvm::StringRef Extension = Suffix.trim();
+for (llvm::StringRef::const_iterator it = Extension.begin();
+

Re: [PATCH] D16113: [clang-tdiy] Add header file extension configuration support.

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


Comment at: clang-tidy/utils/HeaderFileExtensionsUtils.cpp:48
@@ +47,3 @@
+
+bool parseHeaderFileExtensions(llvm::StringRef AllHeaderFileExtensions,
+   HeaderFileExtensionsSet &HeaderFileExtensions) {

One thing we may want to reconsider for this function is using comma as a 
delimiter. We have another in-flight review which has to use semi-colons for a 
checker option list because commas are part of the syntax for a type 
description (think Foo). It would be really nice to have one utility for 
parsing lists of information from checker options, and for that to use the same 
delimiter everywhere so that users aren't confused by using commas in some 
places and semi-colons in others.


http://reviews.llvm.org/D16113



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


Re: [PATCH] D16113: [clang-tdiy] Add header file extension configuration support.

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


Comment at: clang-tidy/ClangTidyOptions.cpp:269
@@ +268,3 @@
+  SmallVector Suffixes;
+  HeaderFileExtensions.split(Suffixes, ',');
+  for (const auto& Suffix : Suffixes) {

aaron.ballman wrote:
> alexfh wrote:
> > It's rather inefficient to split the string each time the function is 
> > called. If even we needed this function, we would better pass an 
> > `ArrayRef`. But even better, we can use `llvm::StringSet` and 
> > get rid of this function at all (we might need a helper function to parse a 
> > comma-separated list of extensions to a StringSet though).
> This code seems like it will fail if there are spaces in the extension list, 
> like `.h, .hxx` instead of `.h,.hxx`. I think the list, as given by the end 
> user, should be processed into a vector of sorts so that things can be 
> normalized (entries without a period can be diagnosed, spaces removed, etc).
Now it's tolerant of whitespace around the commas.


http://reviews.llvm.org/D16113



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


Re: [PATCH] D15897: [libc++] Silence warning about padding inserted at the tail of struct _Rep_base

2016-01-15 Thread Akira Hatanaka via cfe-commits
ahatanak added reviewers: mclow.lists, EricWF, joerg, howard.hinnant.
ahatanak added a comment.

Adding reviewers


http://reviews.llvm.org/D15897



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


Re: [PATCH] D8940: Clang changes for indirect call target profiling

2016-01-15 Thread Betul Buyukkurt via cfe-commits
betulb added a comment.

ping?


http://reviews.llvm.org/D8940



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


Re: r255890 - [ms-inline-asm] Add support for composite structs in MS inline asm

2016-01-15 Thread David Blaikie via cfe-commits
On Thu, Dec 17, 2015 at 4:51 AM, Marina Yatsina via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: myatsina
> Date: Thu Dec 17 06:51:51 2015
> New Revision: 255890
>
> URL: http://llvm.org/viewvc/llvm-project?rev=255890&view=rev
> Log:
> [ms-inline-asm] Add support for composite structs in MS inline asm
>
> Add MS inline asm support for structs that contain fields that are also
> structs.
>
> Differential Revision: http://reviews.llvm.org/D15578
>
>
> Modified:
> cfe/trunk/lib/Sema/SemaStmtAsm.cpp
> cfe/trunk/test/CodeGen/ms-inline-asm.c
>
> Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=255890&r1=255889&r2=255890&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Thu Dec 17 06:51:51 2015
> @@ -617,45 +617,57 @@ ExprResult Sema::LookupInlineAsmIdentifi
>  bool Sema::LookupInlineAsmField(StringRef Base, StringRef Member,
>  unsigned &Offset, SourceLocation AsmLoc) {
>Offset = 0;
> +  SmallVector Members;
> +  Member.split(Members, ".");
> +
>LookupResult BaseResult(*this, &Context.Idents.get(Base),
> SourceLocation(),
>LookupOrdinaryName);
>
>if (!LookupName(BaseResult, getCurScope()))
>  return true;
>
> -  if (!BaseResult.isSingleResult())
> -return true;
> +  LookupResult CurrBaseResult(BaseResult);
>
> -  const RecordType *RT = nullptr;
> -  NamedDecl *FoundDecl = BaseResult.getFoundDecl();
> -  if (VarDecl *VD = dyn_cast(FoundDecl))
> -RT = VD->getType()->getAs();
> -  else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) {
> -MarkAnyDeclReferenced(TD->getLocation(), TD, /*OdrUse=*/false);
> -RT = TD->getUnderlyingType()->getAs();
> -  } else if (TypeDecl *TD = dyn_cast(FoundDecl))
> -RT = TD->getTypeForDecl()->getAs();
> -  if (!RT)
> -return true;
> -
> -  if (RequireCompleteType(AsmLoc, QualType(RT, 0), 0))
> -return true;
> +  for (StringRef NextMember : Members) {
>
> -  LookupResult FieldResult(*this, &Context.Idents.get(Member),
> SourceLocation(),
> -   LookupMemberName);
> -
> -  if (!LookupQualifiedName(FieldResult, RT->getDecl()))
> -return true;
> -
> -  // FIXME: Handle IndirectFieldDecl?
> -  FieldDecl *FD = dyn_cast(FieldResult.getFoundDecl());
> -  if (!FD)
> -return true;
> +if (!CurrBaseResult.isSingleResult())
> +  return true;
>
> -  const ASTRecordLayout &RL = Context.getASTRecordLayout(RT->getDecl());
> -  unsigned i = FD->getFieldIndex();
> -  CharUnits Result = Context.toCharUnitsFromBits(RL.getFieldOffset(i));
> -  Offset = (unsigned)Result.getQuantity();
> +const RecordType *RT = nullptr;
> +NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl();
> +if (VarDecl *VD = dyn_cast(FoundDecl))
> +  RT = VD->getType()->getAs();
> +else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) {
> +  MarkAnyDeclReferenced(TD->getLocation(), TD, /*OdrUse=*/false);
> +  RT = TD->getUnderlyingType()->getAs();
> +} else if (TypeDecl *TD = dyn_cast(FoundDecl))
> +  RT = TD->getTypeForDecl()->getAs();
> +else if (FieldDecl *TD = dyn_cast(FoundDecl))
> +  RT = TD->getType()->getAs();
> +if (!RT)
> +  return true;
> +
> +if (RequireCompleteType(AsmLoc, QualType(RT, 0), 0))
> +  return true;
> +
> +LookupResult FieldResult(*this, &Context.Idents.get(NextMember),
> + SourceLocation(), LookupMemberName);
> +
> +if (!LookupQualifiedName(FieldResult, RT->getDecl()))
> +  return true;
> +
> +// FIXME: Handle IndirectFieldDecl?
> +FieldDecl *FD = dyn_cast(FieldResult.getFoundDecl());
> +if (!FD)
> +  return true;
> +
> +CurrBaseResult = FieldResult;
>

LookupResults shouldn't be/aren't really copyable (it's deprecated in C++11
to copy them, because they have a non-trivial dtor, which is reasonable -
the default copy ctor would produce bad behavior if the interesting members
(explicitly destroyed in the user-defined dtor) were present/non-null when
the copy took place).

Perhaps you could generalize/do something like the change I made in
http://llvm.org/viewvc/llvm-project?rev=248761&view=rev ?

At some point it'd be nice to enable -Wdeprecated for the Clang-on-clang
build directly, but there's a few wrinkles I need to sort out (when I find
the time/motivation) before that happens.


> +
> +const ASTRecordLayout &RL = Context.getASTRecordLayout(RT->getDecl());
> +unsigned i = FD->getFieldIndex();
> +CharUnits Result = Context.toCharUnitsFromBits(RL.getFieldOffset(i));
> +Offset += (unsigned)Result.getQuantity();
> +  }
>
>return false;
>  }
>
> Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=255890&r1=255889&r2=2558

r257917 - Add OpenMP dist_schedule clause to distribute directive and related regression tests.

2016-01-15 Thread Carlo Bertolli via cfe-commits
Author: cbertol
Date: Fri Jan 15 12:50:31 2016
New Revision: 257917

URL: http://llvm.org/viewvc/llvm-project?rev=257917&view=rev
Log:
Add OpenMP dist_schedule clause to distribute directive and related regression 
tests.

Added:
cfe/trunk/test/OpenMP/distribute_dist_schedule_ast_print.cpp
cfe/trunk/test/OpenMP/distribute_dist_schedule_messages.cpp
Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=257917&r1=257916&r2=257917&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Fri Jan 15 12:50:31 2016
@@ -3193,6 +3193,135 @@ public:
   child_range children() { return child_range(&Hint, &Hint + 1); }
 };
 
+/// \brief This represents 'dist_schedule' clause in the '#pragma omp ...'
+/// directive.
+///
+/// \code
+/// #pragma omp distribute dist_schedule(static, 3)
+/// \endcode
+/// In this example directive '#pragma omp distribute' has 'dist_schedule'
+/// clause with arguments 'static' and '3'.
+///
+class OMPDistScheduleClause : public OMPClause {
+  friend class OMPClauseReader;
+  /// \brief Location of '('.
+  SourceLocation LParenLoc;
+  /// \brief A kind of the 'schedule' clause.
+  OpenMPDistScheduleClauseKind Kind;
+  /// \brief Start location of the schedule kind in source code.
+  SourceLocation KindLoc;
+  /// \brief Location of ',' (if any).
+  SourceLocation CommaLoc;
+  /// \brief Chunk size and a reference to pseudo variable for combined
+  /// directives.
+  enum { CHUNK_SIZE, HELPER_CHUNK_SIZE, NUM_EXPRS };
+  Stmt *ChunkSizes[NUM_EXPRS];
+
+  /// \brief Set schedule kind.
+  ///
+  /// \param K Schedule kind.
+  ///
+  void setDistScheduleKind(OpenMPDistScheduleClauseKind K) { Kind = K; }
+  /// \brief Sets the location of '('.
+  ///
+  /// \param Loc Location of '('.
+  ///
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+  /// \brief Set schedule kind start location.
+  ///
+  /// \param KLoc Schedule kind location.
+  ///
+  void setDistScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
+  /// \brief Set location of ','.
+  ///
+  /// \param Loc Location of ','.
+  ///
+  void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
+  /// \brief Set chunk size.
+  ///
+  /// \param E Chunk size.
+  ///
+  void setChunkSize(Expr *E) { ChunkSizes[CHUNK_SIZE] = E; }
+  /// \brief Set helper chunk size.
+  ///
+  /// \param E Helper chunk size.
+  ///
+  void setHelperChunkSize(Expr *E) { ChunkSizes[HELPER_CHUNK_SIZE] = E; }
+
+public:
+  /// \brief Build 'dist_schedule' clause with schedule kind \a Kind and chunk
+  /// size expression \a ChunkSize.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param LParenLoc Location of '('.
+  /// \param KLoc Starting location of the argument.
+  /// \param CommaLoc Location of ','.
+  /// \param EndLoc Ending location of the clause.
+  /// \param Kind DistSchedule kind.
+  /// \param ChunkSize Chunk size.
+  /// \param HelperChunkSize Helper chunk size for combined directives.
+  ///
+  OMPDistScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc,
+SourceLocation KLoc, SourceLocation CommaLoc,
+SourceLocation EndLoc,
+OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize,
+Expr *HelperChunkSize)
+  : OMPClause(OMPC_dist_schedule, StartLoc, EndLoc), LParenLoc(LParenLoc),
+Kind(Kind), KindLoc(KLoc), CommaLoc(CommaLoc) {
+ChunkSizes[CHUNK_SIZE] = ChunkSize;
+ChunkSizes[HELPER_CHUNK_SIZE] = HelperChunkSize;
+  }
+
+  /// \brief Build an empty clause.
+  ///
+  explicit OMPDistScheduleClause()
+  : OMPClause(OMPC_dist_schedule, SourceLocation(), SourceLocation()),
+Kind(OMPC_DIST_SCHEDULE_unknown) {
+ChunkSizes[CHUNK_SIZE] = nullptr;
+ChunkSizes[HELPER_CHUNK_SIZE] = nullptr;
+  }
+
+  /// \brief Get kind of the clause.
+  ///
+  OpenMPDistScheduleClauseKind getDistScheduleKind() const { return Kind; }
+  /// \brief Get location of '('.
+  ///
+  SourceLocation getLParenLoc() { return LParenLoc; }
+  /// \brief Get kind location.
+  ///
+  SourceLocation getDistScheduleKindLoc() { retu

Re: [PATCH] D15220: [OPENMP] dist_schedule clause for distribute directive

2016-01-15 Thread Carlo Bertolli via cfe-commits
carlo.bertolli added a comment.

Committed revision 257917.


Repository:
  rL LLVM

http://reviews.llvm.org/D15220



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


Re: [PATCH] D16102: Bug 25496 - clang++ -pg links with -lc++ instead of -lc++_p

2016-01-15 Thread David Sanderson via cfe-commits
dws added a comment.

Ping?


http://reviews.llvm.org/D16102



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


Re: [PATCH] D15220: [OPENMP] dist_schedule clause for distribute directive

2016-01-15 Thread Carlo Bertolli via cfe-commits
carlo.bertolli closed this revision.
carlo.bertolli added a comment.

Please notify of any issues.


Repository:
  rL LLVM

http://reviews.llvm.org/D15220



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


Re: [PATCH] D16216: Fix infinite loop when ::new or ::delete are found in member initializer list

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

This isn't quite the right way to fix this issue.



Comment at: lib/Parse/ParseDeclCXX.cpp:3206-3209
@@ -3205,6 +3205,6 @@
 // we're just missing a comma.
 else if (Tok.isOneOf(tok::identifier, tok::coloncolon)) {
   SourceLocation Loc = PP.getLocForEndOfToken(PrevTokLocation);
   Diag(Loc, diag::err_ctor_init_missing_comma)
 << FixItHint::CreateInsertion(Loc, ", ");
 } else {

This is the right place to fix the bug. We should not enter this codepath if 
the previous initializer was not valid, and should instead fall into the `else` 
below to skip the rest of the initializers. (Delete the `else {` so that 
`MemInit` is still in scope here, and don't enter this block if 
`MemInit.isInvalid()`. Please also suppress the `err_expected_either` 
diagnostic below in that case.)


http://reviews.llvm.org/D16216



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


Re: [PATCH] D16179: [clang-tidy] Handle decayed types and other improvements in VirtualNearMiss check.

2016-01-15 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 45022.
xazax.hun added a comment.

- Address a review comment.
- Fix an assertion failure for methods that has non-identifier name e.g.: 
destructors.
- Ignore qualifiers.


http://reviews.llvm.org/D16179

Files:
  clang-tidy/misc/VirtualNearMissCheck.cpp
  test/clang-tidy/misc-virtual-near-miss.cpp

Index: test/clang-tidy/misc-virtual-near-miss.cpp
===
--- test/clang-tidy/misc-virtual-near-miss.cpp
+++ test/clang-tidy/misc-virtual-near-miss.cpp
@@ -3,6 +3,7 @@
 struct Base {
   virtual void func();
   virtual void gunk();
+  virtual ~Base();
 };
 
 struct Derived : Base {
@@ -36,6 +37,7 @@
   static void method();
   virtual int method(int argc, const char **argv);
   virtual int method(int argc) const;
+  virtual int decay(const char *str);
 };
 
 class Child : private Father, private Mother {
@@ -47,7 +49,8 @@
 
   int methoe(int x, char **strs); // Should not warn: parameter types don't match.
 
-  int methoe(int x); // Should not warn: method is not const.
+  int methoe(int x);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::methoe' has {{.*}} 'Mother::method'
 
   void methof(int x, const char **strs); // Should not warn: return types don't match.
 
@@ -60,6 +63,10 @@
   virtual Derived &&generat();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::generat' has {{.*}} 'Father::generate'
 
+  int decaz(const char str[]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::decaz' has {{.*}} 'Mother::decay'
+
 private:
-  void funk(); // Should not warn: access qualifers don't match.
+  void funk();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::funk' has {{.*}} 'Father::func'
 };
Index: clang-tidy/misc/VirtualNearMissCheck.cpp
===
--- clang-tidy/misc/VirtualNearMissCheck.cpp
+++ clang-tidy/misc/VirtualNearMissCheck.cpp
@@ -52,22 +52,13 @@
   const CXXRecordDecl *BRD, *DRD;
 
   // Both types must be pointers or references to classes.
-  if (const auto *DerivedPT = DerivedReturnTy->getAs()) {
-if (const auto *BasePT = BaseReturnTy->getAs()) {
-  DTy = DerivedPT->getPointeeType();
-  BTy = BasePT->getPointeeType();
-}
-  } else if (const auto *DerivedRT = DerivedReturnTy->getAs()) {
-if (const auto *BaseRT = BaseReturnTy->getAs()) {
-  DTy = DerivedRT->getPointeeType();
-  BTy = BaseRT->getPointeeType();
-}
-  }
-
-  // The return types aren't either both pointers or references to a class type.
-  if (DTy.isNull())
+  if ((!BaseReturnTy->isPointerType() || !DerivedReturnTy->isPointerType()) &&
+  (!BaseReturnTy->isReferenceType() || !DerivedReturnTy->isReferenceType()))
 return false;
 
+  DTy = DerivedReturnTy->getPointeeType();
+  BTy = BaseReturnTy->getPointeeType();
+
   DRD = DTy->getAsCXXRecordDecl();
   BRD = BTy->getAsCXXRecordDecl();
   if (DRD == nullptr || BRD == nullptr)
@@ -116,6 +107,13 @@
   return true;
 }
 
+/// \returns decayed type for arrays and functions.
+static QualType getDecayedType(QualType Type) {
+  if (const auto *Decayed = Type->getAs())
+return Decayed->getDecayedType();
+  return Type;
+}
+
 /// \returns true if the param types are the same.
 static bool checkParamTypes(const CXXMethodDecl *BaseMD,
 const CXXMethodDecl *DerivedMD) {
@@ -125,8 +123,8 @@
 return false;
 
   for (unsigned I = 0; I < NumParamA; I++) {
-if (BaseMD->getParamDecl(I)->getType() !=
-DerivedMD->getParamDecl(I)->getType())
+if (getDecayedType(BaseMD->getParamDecl(I)->getType()) !=
+getDecayedType(DerivedMD->getParamDecl(I)->getType()))
   return false;
   }
   return true;
@@ -137,15 +135,9 @@
 static bool checkOverrideWithoutName(const ASTContext *Context,
  const CXXMethodDecl *BaseMD,
  const CXXMethodDecl *DerivedMD) {
-  if (BaseMD->getTypeQualifiers() != DerivedMD->getTypeQualifiers())
-return false;
-
   if (BaseMD->isStatic() != DerivedMD->isStatic())
 return false;
 
-  if (BaseMD->getAccess() != DerivedMD->getAccess())
-return false;
-
   if (BaseMD->getType() == DerivedMD->getType())
 return true;
 
@@ -226,7 +218,7 @@
 
 void VirtualNearMissCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *DerivedMD = Result.Nodes.getNodeAs("method");
-  assert(DerivedMD != nullptr);
+  assert(DerivedMD);
 
   if (DerivedMD->isStatic())
 return;
@@ -245,7 +237,8 @@
   continue;
 
 unsigned EditDistance =
-BaseMD->getName().edit_distance(DerivedMD->getName());
+StringRef(BaseMD->getNameAsString())
+.edit_distance(DerivedMD->getNameAsString());
 if (EditDistance > 0 && EditDistance <= EditDistanceThreshold) {
   if (checkOverrideWithoutName(Context, BaseMD, DerivedMD)) {
 // A "virtual near miss" i

Re: [PATCH] D16179: [clang-tidy] Handle decayed types and other improvements in VirtualNearMiss check.

2016-01-15 Thread Gábor Horváth via cfe-commits
xazax.hun marked an inline comment as done.
xazax.hun added a comment.

In http://reviews.llvm.org/D16179#326746, @alexfh wrote:

> > ... What about a configuration option to also report near misses when only 
> > a qualifier is missing?
>
>
> Might be a useful thing. We should first check if it makes sense to always 
> ignore a qualifier.


In this iteration of the patch I made the checker ignore the qualifiers. I did 
not get any results from running it on clang and llvm.



Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:126-127
@@ -127,4 +125,4 @@
   for (unsigned I = 0; I < NumParamA; I++) {
-if (BaseMD->getParamDecl(I)->getType() !=
-DerivedMD->getParamDecl(I)->getType())
+if (getDecayedType(BaseMD->getParamDecl(I)->getType()) !=
+getDecayedType(DerivedMD->getParamDecl(I)->getType()))
   return false;

This might not be representative, but I did not get any results on the LLVM 
codebase.


http://reviews.llvm.org/D16179



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


Re: [PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2016-01-15 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

> I see, so essentially you want to use a different approach for determining 
> sanitizer availability (on OS X for now): if the library is present, then we 
> support 

>  sanitizer, otherwise we don't: i.e. the binary distribution is the source of 
> truth, not the list of sanitizers hardcoded into Clang driver source code. 
> I'm fine with 

>  that, and see why it would make sense.


Correct.

> It's just that error message looks misleading: the problem is not TSan is 
> unsupported for target, it's just unavailable in this distribution for one 
> reason or 

>  another.


The main advantage of the error message Kuba has right now is that it is user 
friendly. A sanitizer IS unsupported for the given target in the given 
distribution if the library is missing. Saying something along the lines of 
"runtime components for '-fsanitize=thread' not available" is vague. For 
example, does it mean that the user needs to install the runtime components in 
some other way?


http://reviews.llvm.org/D15225



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


r257934 - [CMake] Support generation of linker order files using dtrace

2016-01-15 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Jan 15 15:21:12 2016
New Revision: 257934

URL: http://llvm.org/viewvc/llvm-project?rev=257934&view=rev
Log:
[CMake] Support generation of linker order files using dtrace

Summary:
This patch extends the lit-based perf-training tooling supplied for PGO data 
generation to also generate linker order files using dtrace.

This patch should work on any system that has dtrace. If CMake can find the 
dtrace tool it will generate a target 'generate-order-file' which will run the 
per-training tests wrapped by dtrace to capture function entries. There are 
several algorithms implemented for sorting the order files which can be 
experimented with for best performance. The dtrace wrapper also supports bot 
oneshot and pid probes.

The perf-helper.py changes to support order file construction are ported from 
internal changes by ddunbar; he gets all the credit for the hard work here, I 
just copy and pasted.

Note: I've tested these patches on FreeBSD and OS X 10.10.

Reviewers: ddunbar, bogner, silvas

Subscribers: llvm-commits, emaste

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

Added:
cfe/trunk/utils/perf-training/order-files.lit.cfg
cfe/trunk/utils/perf-training/order-files.lit.site.cfg.in
Modified:
cfe/trunk/utils/perf-training/CMakeLists.txt
cfe/trunk/utils/perf-training/perf-helper.py

Modified: cfe/trunk/utils/perf-training/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/CMakeLists.txt?rev=257934&r1=257933&r2=257934&view=diff
==
--- cfe/trunk/utils/perf-training/CMakeLists.txt (original)
+++ cfe/trunk/utils/perf-training/CMakeLists.txt Fri Jan 15 15:21:12 2016
@@ -1,24 +1,24 @@
-if(LLVM_BUILD_INSTRUMENTED)
-  if (CMAKE_CFG_INTDIR STREQUAL ".")
-set(LLVM_BUILD_MODE ".")
-  else ()
-set(LLVM_BUILD_MODE "%(build_mode)s")
-  endif ()
+if (CMAKE_CFG_INTDIR STREQUAL ".")
+  set(LLVM_BUILD_MODE ".")
+else ()
+  set(LLVM_BUILD_MODE "%(build_mode)s")
+endif ()
 
-  string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
 
+if(LLVM_BUILD_INSTRUMENTED)
   configure_lit_site_cfg(
 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+${CMAKE_CURRENT_BINARY_DIR}/pgo-data/lit.site.cfg
 )
 
   add_lit_testsuite(generate-profraw "Generating clang PGO data"
-${CMAKE_CURRENT_BINARY_DIR}
+${CMAKE_CURRENT_BINARY_DIR}/pgo-data/
 DEPENDS clang clear-profraw
 )
 
   add_custom_target(clear-profraw
-COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR}
+COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR} profraw
 COMMENT "Clearing old profraw data")
 
   if(NOT LLVM_PROFDATA)
@@ -34,3 +34,26 @@ if(LLVM_BUILD_INSTRUMENTED)
 COMMENT "Merging profdata"
 DEPENDS generate-profraw)
 endif()
+
+find_program(DTRACE dtrace)
+if(DTRACE)
+  configure_lit_site_cfg(
+${CMAKE_CURRENT_SOURCE_DIR}/order-files.lit.site.cfg.in
+${CMAKE_CURRENT_BINARY_DIR}/order-files/lit.site.cfg
+)
+
+  add_lit_testsuite(generate-dtrace-logs "Generating clang dtrace data"
+${CMAKE_CURRENT_BINARY_DIR}/order-files/
+DEPENDS clang clear-dtrace-logs
+)
+
+  add_custom_target(clear-dtrace-logs
+COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR} dtrace
+COMMENT "Clearing old dtrace data")
+
+
+  add_custom_target(generate-order-file
+COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
gen-order-file --binary $ --output 
${CMAKE_CURRENT_BINARY_DIR}/clang.order ${CMAKE_CURRENT_BINARY_DIR}
+COMMENT "Generating order file"
+DEPENDS generate-dtrace-logs)
+endif()

Added: cfe/trunk/utils/perf-training/order-files.lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/order-files.lit.cfg?rev=257934&view=auto
==
--- cfe/trunk/utils/perf-training/order-files.lit.cfg (added)
+++ cfe/trunk/utils/perf-training/order-files.lit.cfg Fri Jan 15 15:21:12 2016
@@ -0,0 +1,39 @@
+# -*- Python -*-
+
+from lit import Test
+import lit.formats
+import lit.util
+import os
+
+def getSysrootFlagsOnDarwin(config, lit_config):
+# On Darwin, support relocatable SDKs by providing Clang with a
+# default system root path.
+if 'darwin' in config.target_triple:
+try:
+out = lit.util.capture(['xcrun', '--show-sdk-path']).strip()
+res = 0
+except OSError:
+res = -1
+if res == 0 and out:
+sdk_path = out
+lit_config.note('using SDKROOT: %r' % sdk_path)
+return '-isysroot %s' 

Re: [PATCH] D15363: [UBSan] Implement runtime suppressions (PR25066).

2016-01-15 Thread Nico Weber via cfe-commits
thakis added a comment.

This test is failing again when it runs as part of llvm's tests when I
build a clang package for chromium. It passes when I run it in my regular
llvm build directory (where I ran it to test my "fix") -- this explains why
the fix didn't work when I tried it in the chrome case on 12/22. I'm not
sure what's different in the two cases. The path length to the test is
longer, I suppose :-/


Repository:
  rL LLVM

http://reviews.llvm.org/D15363



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


r257936 - [CMake] [Order-files] Use print_function as an attempt at being forward compatible.

2016-01-15 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Jan 15 15:30:06 2016
New Revision: 257936

URL: http://llvm.org/viewvc/llvm-project?rev=257936&view=rev
Log:
[CMake] [Order-files] Use print_function as an attempt at being forward 
compatible.

Based on feedback from bogner.

Modified:
cfe/trunk/utils/perf-training/perf-helper.py

Modified: cfe/trunk/utils/perf-training/perf-helper.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/perf-helper.py?rev=257936&r1=257935&r2=257936&view=diff
==
--- cfe/trunk/utils/perf-training/perf-helper.py (original)
+++ cfe/trunk/utils/perf-training/perf-helper.py Fri Jan 15 15:30:06 2016
@@ -7,6 +7,8 @@
 #
 
#======#
 
+from __future__ import print_function
+
 import sys
 import os
 import subprocess
@@ -24,8 +26,8 @@ def findFilesWithExtension(path, extensi
 
 def clean(args):
   if len(args) != 2:
-print 'Usage: %s clean  ' % __file__
-print '\tRemoves all files with extension from .'
+print('Usage: %s clean  \n' % __file__ +
+  '\tRemoves all files with extension from .')
 return 1
   for filename in findFilesWithExtension(args[0], args[1]):
 os.remove(filename)
@@ -33,8 +35,8 @@ def clean(args):
 
 def merge(args):
   if len(args) != 3:
-print 'Usage: %s clean   \n' % __file__
-print '\tMerges all profraw files from path into output.'
+print('Usage: %s clean   \n' % __file__ +
+  '\tMerges all profraw files from path into output.')
 return 1
   cmd = [args[0], 'merge', '-o', args[1]]
   cmd.extend(findFilesWithExtension(args[2], "profraw"))
@@ -74,8 +76,9 @@ def dtrace(args):
 
   dtrace_args = []
   if not os.geteuid() == 0:
-print 'Script must be run as root, or you must add the following to your 
sudoers:'
-print '%%admin ALL=(ALL) NOPASSWD: /usr/sbin/dtrace'
+print(
+  'Script must be run as root, or you must add the following to your 
sudoers:'
+  + '%%admin ALL=(ALL) NOPASSWD: /usr/sbin/dtrace')
 dtrace_args.append("sudo")
 
   dtrace_args.extend((
@@ -91,7 +94,7 @@ def dtrace(args):
   start_time = time.time()
   subprocess.check_call(dtrace_args, stdout=f, stderr=subprocess.PIPE)
   elapsed = time.time() - start_time
-  print "... data collection took %.4fs" % elapsed
+  print("... data collection took %.4fs" % elapsed)
 
   return 0
 
@@ -127,8 +130,8 @@ def parse_dtrace_symbol_file(path, all_s
   if ln.startswith("dtrace-TS: "):
 _,data = ln.split(': ', 1)
 if not data.isdigit():
-  print >>sys.stderr, (
-"warning: unrecognized timestamp line %r, ignoring" % ln)
+  print("warning: unrecognized timestamp line %r, ignoring" % ln,
+file=sys.stderr)
   continue
 current_timestamp = int(data)
 continue
@@ -167,14 +170,13 @@ def parse_dtrace_symbol_file(path, all_s
 
 # If we found too many possible symbols, ignore this as a prefix.
 if len(possible_symbols) > 100:
-  print >>sys.stderr, (
-"warning: ignoring symbol %r " % symbol +
-"(no match and too many possible suffixes)") 
+  print( "warning: ignoring symbol %r " % symbol +
+"(no match and too many possible suffixes)", file=sys.stderr) 
   continue
 
 # Report that we resolved a missing symbol.
 if opts.show_missing_symbols and symbol not in missing_symbols:
-  print >>sys.stderr, ( "warning: resolved missing symbol %r" % symbol)
+  print("warning: resolved missing symbol %r" % symbol, 
file=sys.stderr)
   missing_symbols.add(symbol)
 
 # Otherwise, treat all the possible matches as having occurred. This
@@ -287,7 +289,7 @@ def genOrderFile(args):
  all_symbols = [ln.split(' ',1)[0]
 for ln in lines
 if ln.strip()]
- print "found %d symbols in binary" % len(all_symbols)
+ print("found %d symbols in binary" % len(all_symbols))
  all_symbols.sort()
   else:
  all_symbols = []
@@ -299,7 +301,7 @@ def genOrderFile(args):
 input_files.extend(findFilesWithExtension(dirname, "dtrace"))
 
   # Load all of the input files.
-  print "loading from %d data files" % len(input_files)
+  print("loading from %d data files" % len(input_files))
   missing_symbols = set()
   timestamped_symbol_lists = [
   list(parse_dtrace_symbol_file(path, all_symbols, all_symbols_set,
@@ -320,9 +322,9 @@ def genOrderFile(args):
   # file.
   num_ordered_symbols = len(result)
   if all_symbols:
-print >>sys.stderr, "note: order file contains %d/%d symbols (%.2f%%)" % (
+print("note: order file contains %d/%d symbols (%.2f%%)" % (
   num_ordered_symbols, len(all_symbols),
-  100.*num_ordered_symbols/len(all_symbols))
+  100.*num_ordered_symbols/len(all_symbols)), file=sys.stderr)
 
   if opts.output_unordered_symbols_path:
 ordered_

Re: [PATCH] D15363: [UBSan] Implement runtime suppressions (PR25066).

2016-01-15 Thread Nico Weber via cfe-commits
thakis added a comment.

In http://reviews.llvm.org/D15363#321941, @samsonov wrote:

> Interesting. Do we run test/asan/TestCases/suppressions-interceptor.cc on
>  Windows? Seems so: I don't see an XFAIL there, and it also uses
>  suppressions, but with single quote, followed by double quote:
>
> %env_asan_opts=suppressions='"%t.supp"'
>
> Why does it work there?


I figured this part out: We build a 64-bit clang, and since there's no 64-bit 
asan runtime `check-asan` isn't part of `check-all` in that case. Later, we 
build a 32-bit asan runtime in a separate build dir, but we apparently don't 
run tests for that build (this looks like an oversight). That's why the asan 
test doesn't fail -- it doesn't run.


Repository:
  rL LLVM

http://reviews.llvm.org/D15363



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


r257938 - [analyzer] Check for return of nil in ObjC methods with nonnull return type.

2016-01-15 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri Jan 15 15:35:40 2016
New Revision: 257938

URL: http://llvm.org/viewvc/llvm-project?rev=257938&view=rev
Log:
[analyzer] Check for return of nil in ObjC methods with nonnull return type.

Update NullabilityChecker so that it checks return statements in ObjC methods.
Previously it was returning early because methods do not have a function type.

Also update detection of violated parameter _Nonnull preconditions to handle
ObjC methods.

rdar://problem/24200560

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/test/Analysis/nullability_nullonly.mm

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp?rev=257938&r1=257937&r2=257938&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp Fri Jan 15 
15:35:40 2016
@@ -366,24 +366,20 @@ static bool checkPreconditionViolation(P
   if (!D)
 return false;
 
-  if (const auto *BlockD = dyn_cast(D)) {
-if (checkParamsForPreconditionViolation(BlockD->parameters(), State,
-LocCtxt)) {
-  if (!N->isSink())
-C.addTransition(State->set(true), N);
-  return true;
-}
+  ArrayRef Params;
+  if (const auto *BD = dyn_cast(D))
+Params = BD->parameters();
+  else if (const auto *FD = dyn_cast(D))
+Params = FD->parameters();
+  else if (const auto *MD = dyn_cast(D))
+Params = MD->parameters();
+  else
 return false;
-  }
 
-  if (const auto *FuncDecl = dyn_cast(D)) {
-if (checkParamsForPreconditionViolation(FuncDecl->parameters(), State,
-LocCtxt)) {
-  if (!N->isSink())
-C.addTransition(State->set(true), N);
-  return true;
-}
-return false;
+  if (checkParamsForPreconditionViolation(Params, State, LocCtxt)) {
+if (!N->isSink())
+  C.addTransition(State->set(true), N);
+return true;
   }
   return false;
 }
@@ -484,16 +480,20 @@ void NullabilityChecker::checkPreStmt(co
   if (!RetSVal)
 return;
 
+  QualType RequiredRetType;
   AnalysisDeclContext *DeclCtxt =
   C.getLocationContext()->getAnalysisDeclContext();
-  const FunctionType *FuncType = DeclCtxt->getDecl()->getFunctionType();
-  if (!FuncType)
+  const Decl *D = DeclCtxt->getDecl();
+  if (auto *MD = dyn_cast(D))
+RequiredRetType = MD->getReturnType();
+  else if (auto *FD = dyn_cast(D))
+RequiredRetType = FD->getReturnType();
+  else
 return;
 
   NullConstraint Nullness = getNullConstraint(*RetSVal, State);
 
-  Nullability RequiredNullability =
-  getNullabilityAnnotation(FuncType->getReturnType());
+  Nullability RequiredNullability = getNullabilityAnnotation(RequiredRetType);
 
   // If the returned value is null but the type of the expression
   // generating it is nonnull then we will suppress the diagnostic.

Modified: cfe/trunk/test/Analysis/nullability_nullonly.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullability_nullonly.mm?rev=257938&r1=257937&r2=257938&view=diff
==
--- cfe/trunk/test/Analysis/nullability_nullonly.mm (original)
+++ cfe/trunk/test/Analysis/nullability_nullonly.mm Fri Jan 15 15:35:40 2016
@@ -1,5 +1,21 @@
 // RUN: %clang_cc1 -analyze 
-analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull
 -verify %s
 
+#define nil 0
+#define BOOL int
+
+@protocol NSObject
++ (id)alloc;
+- (id)init;
+@end
+
+@protocol NSCopying
+@end
+
+__attribute__((objc_root_class))
+@interface
+NSObject
+@end
+
 int getRandom();
 
 typedef struct Dummy { int val; } Dummy;
@@ -85,3 +101,27 @@ Dummy *_Nonnull testDefensiveInlineCheck
 takesNonnull(p);
   return p;
 }
+
+
+@interface SomeClass : NSObject
+@end
+
+@implementation SomeClass (MethodReturn)
+- (SomeClass * _Nonnull)testReturnsNilInNonnull {
+  SomeClass *local = nil;
+  return local; // expected-warning {{Null is returned from a function that is 
expected to return a non-null value}}
+}
+
+- (SomeClass * _Nonnull)testReturnsCastSuppressedNilInNonnull {
+  SomeClass *local = nil;
+  return (SomeClass * _Nonnull)local; // no-warning
+}
+
+- (SomeClass * 
_Nonnull)testReturnsNilInNonnullWhenPreconditionViolated:(SomeClass * _Nonnull) 
p {
+  SomeClass *local = nil;
+  if (!p) // Pre-condition violated here.
+return local; // no-warning
+  else
+return p; // no-warning
+}
+@end


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


Re: [PATCH] D15384: Don't ask for the size of dependent integral types in template diffing

2016-01-15 Thread Richard Trieu via cfe-commits
rtrieu added a comment.

I've fixed this issue as part of the template type diffing refactoring.  
r257870 was the last of the refactoring, and includes your test case in it.


http://reviews.llvm.org/D15384



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


Re: [PATCH] D16102: Bug 25496 - clang++ -pg links with -lc++ instead of -lc++_p

2016-01-15 Thread Dimitry Andric via cfe-commits
dim added a subscriber: dim.
dim added a comment.

In http://reviews.llvm.org/D16102#324395, @davide wrote:

> I'm fine with this solution but Saleem pointed out there are some changes 
> that need to be made before getting this in.


@compnerd, what were these changes to be made?


http://reviews.llvm.org/D16102



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


r257939 - Make -Wdelete-non-virtual-dtor warn on explicit `a->~A()` dtor calls too.

2016-01-15 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Jan 15 15:45:31 2016
New Revision: 257939

URL: http://llvm.org/viewvc/llvm-project?rev=257939&view=rev
Log:
Make -Wdelete-non-virtual-dtor warn on explicit `a->~A()` dtor calls too.

-Wdelete-non-virtual-dtor warns if A is a type with virtual functions but
without virtual dtor has its constructor called via `delete a`. This makes the
warning also fire if the dtor is called via `a->~A()`. This would've found a
security bug in Chromium at compile time. Fixes PR26137.

To fix the warning, add a virtual destructor, make the class final, or remove
its other virtual methods.  If you want to silence the warning, there's also
a fixit that shows how:

test.cc:12:3: warning: destructor called on 'B' ... [-Wdelete-non-virtual-dtor]
  b->~B();
  ^
test.cc:12:6: note: qualify call to silence this warning
  b->~B();
 ^
 B::

http://reviews.llvm.org/D16206

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/destructor.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=257939&r1=257938&r2=257939&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 15 15:45:31 
2016
@@ -5807,12 +5807,14 @@ def warn_non_virtual_dtor : Warning<
   "%0 has virtual functions but non-virtual destructor">,
   InGroup, DefaultIgnore;
 def warn_delete_non_virtual_dtor : Warning<
-  "delete called on non-final %0 that has virtual functions "
-  "but non-virtual destructor">,
+  "%select{delete|destructor}0 called on non-final %1 that has "
+  "virtual functions but non-virtual destructor">,
   InGroup, DefaultIgnore;
+def note_delete_non_virtual : Note<
+  "qualify call to silence this warning">;
 def warn_delete_abstract_non_virtual_dtor : Warning<
-  "delete called on %0 that is abstract but has non-virtual destructor">,
-  InGroup;
+  "%select{delete|destructor}0 called on %1 that is abstract but has "
+  "non-virtual destructor">, InGroup;
 def warn_overloaded_virtual : Warning<
   "%q0 hides overloaded virtual %select{function|functions}1">,
   InGroup, DefaultIgnore;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=257939&r1=257938&r2=257939&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Jan 15 15:45:31 2016
@@ -4698,6 +4698,10 @@ public:
   ExprResult ActOnCXXDelete(SourceLocation StartLoc,
 bool UseGlobal, bool ArrayForm,
 Expr *Operand);
+  void CheckVirtualDtorCall(CXXDestructorDecl *dtor, SourceLocation Loc,
+bool IsDelete, bool CallCanBeVirtual,
+bool WarnOnNonAbstractTypes,
+SourceLocation DtorLoc);
 
   DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D);
   ExprResult CheckConditionVariable(VarDecl *ConditionVar,

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=257939&r1=257938&r2=257939&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Jan 15 15:45:31 2016
@@ -2765,30 +2765,10 @@ Sema::ActOnCXXDelete(SourceLocation Star
 return ExprError();
 }
 
-  // C++ [expr.delete]p3:
-  //   In the first alternative (delete object), if the static type of the
-  //   object to be deleted is different from its dynamic type, the static
-  //   type shall be a base class of the dynamic type of the object to be
-  //   deleted and the static type shall have a virtual destructor or the
-  //   behavior is undefined.
-  //
-  // Note: a final class cannot be derived from, no issue there
-  if (PointeeRD->isPolymorphic() && !PointeeRD->hasAttr()) {
-CXXDestructorDecl *dtor = PointeeRD->getDestructor();
-if (dtor && !dtor->isVirtual()) {
-  if (PointeeRD->isAbstract()) {
-// If the class is abstract, we warn by default, because we're
-// sure the code has undefined behavior.
-Diag(StartLoc, diag::warn_delete_abstract_non_virtual_dtor)
-<< PointeeElem;
-  } else if (!ArrayForm) {
-// Otherwise, if this is not an array delete, it's a bit suspect,
-// but not necessarily wrong.
-Diag(StartLoc, diag::warn_delete_non_virtual_dtor) << PointeeElem;

Re: [PATCH] D16206: Make -Wdelete-non-virtual-dtor warn on explicit `a->~A()` dtor calls too.

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

r257939, thanks!


http://reviews.llvm.org/D16206



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


Re: [PATCH] D15384: Don't ask for the size of dependent integral types in template diffing

2016-01-15 Thread Reid Kleckner via cfe-commits
rnk abandoned this revision.
rnk added a comment.

Thanks!


http://reviews.llvm.org/D15384



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


r257947 - Avoid self-assignment of SmallString, trigger UB behavior down the road.

2016-01-15 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Fri Jan 15 16:29:34 2016
New Revision: 257947

URL: http://llvm.org/viewvc/llvm-project?rev=257947&view=rev
Log:
Avoid self-assignment of SmallString, trigger UB behavior down the road.

Modified:
cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/tools/driver/driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=257947&r1=257946&r2=257947&view=diff
==
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Fri Jan 15 16:29:34 2016
@@ -290,9 +290,9 @@ static void SetInstallDir(SmallVectorImp
   if (CanonicalPrefixes)
 llvm::sys::fs::make_absolute(InstalledPath);
 
-  InstalledPath = llvm::sys::path::parent_path(InstalledPath);
-  if (llvm::sys::fs::exists(InstalledPath.c_str()))
-TheDriver.setInstalledDir(InstalledPath);
+  StringRef InstalledPathParent(llvm::sys::path::parent_path(InstalledPath));
+  if (llvm::sys::fs::exists(InstalledPathParent))
+TheDriver.setInstalledDir(InstalledPathParent);
 }
 
 static int ExecuteCC1Tool(ArrayRef argv, StringRef Tool) {


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


r257948 - [CMake] Fix bots broken by including order file generation in check-all

2016-01-15 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Jan 15 16:44:18 2016
New Revision: 257948

URL: http://llvm.org/viewvc/llvm-project?rev=257948&view=rev
Log:
[CMake] Fix bots broken by including order file generation in check-all

Modified:
cfe/trunk/utils/perf-training/CMakeLists.txt

Modified: cfe/trunk/utils/perf-training/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/CMakeLists.txt?rev=257948&r1=257947&r2=257948&view=diff
==
--- cfe/trunk/utils/perf-training/CMakeLists.txt (original)
+++ cfe/trunk/utils/perf-training/CMakeLists.txt Fri Jan 15 16:44:18 2016
@@ -1,3 +1,7 @@
+
+# All test suites added here should be excuded from check-all
+set(EXCLUDE_FROM_ALL On)
+
 if (CMAKE_CFG_INTDIR STREQUAL ".")
   set(LLVM_BUILD_MODE ".")
 else ()


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


Re: r257947 - Avoid self-assignment of SmallString, trigger UB behavior down the road.

2016-01-15 Thread David Blaikie via cfe-commits
On Fri, Jan 15, 2016 at 2:29 PM, Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: joerg
> Date: Fri Jan 15 16:29:34 2016
> New Revision: 257947
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257947&view=rev
> Log:
> Avoid self-assignment of SmallString, trigger UB behavior down the road.
>

Shouldn't we be fixing that in SmallString? (self /move/ assignment
arguably can be UB, but self copy assign probably shouldn't be)


>
> Modified:
> cfe/trunk/tools/driver/driver.cpp
>
> Modified: cfe/trunk/tools/driver/driver.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=257947&r1=257946&r2=257947&view=diff
>
> ==
> --- cfe/trunk/tools/driver/driver.cpp (original)
> +++ cfe/trunk/tools/driver/driver.cpp Fri Jan 15 16:29:34 2016
> @@ -290,9 +290,9 @@ static void SetInstallDir(SmallVectorImp
>if (CanonicalPrefixes)
>  llvm::sys::fs::make_absolute(InstalledPath);
>
> -  InstalledPath = llvm::sys::path::parent_path(InstalledPath);
> -  if (llvm::sys::fs::exists(InstalledPath.c_str()))
> -TheDriver.setInstalledDir(InstalledPath);
> +  StringRef
> InstalledPathParent(llvm::sys::path::parent_path(InstalledPath));
> +  if (llvm::sys::fs::exists(InstalledPathParent))
> +TheDriver.setInstalledDir(InstalledPathParent);
>  }
>
>  static int ExecuteCC1Tool(ArrayRef argv, StringRef Tool) {
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r257947 - Avoid self-assignment of SmallString, trigger UB behavior down the road.

2016-01-15 Thread Benjamin Kramer via cfe-commits
On Fri, Jan 15, 2016 at 11:52 PM, David Blaikie via cfe-commits
 wrote:
>
>
> On Fri, Jan 15, 2016 at 2:29 PM, Joerg Sonnenberger via cfe-commits
>  wrote:
>>
>> Author: joerg
>> Date: Fri Jan 15 16:29:34 2016
>> New Revision: 257947
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=257947&view=rev
>> Log:
>> Avoid self-assignment of SmallString, trigger UB behavior down the road.
>
>
> Shouldn't we be fixing that in SmallString? (self /move/ assignment arguably
> can be UB, but self copy assign probably shouldn't be)

It's a partial self-copy via StringRef. I don't think guarding against
that very special case is worth it.

>>
>>
>> Modified:
>> cfe/trunk/tools/driver/driver.cpp
>>
>> Modified: cfe/trunk/tools/driver/driver.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=257947&r1=257946&r2=257947&view=diff
>>
>> ==
>> --- cfe/trunk/tools/driver/driver.cpp (original)
>> +++ cfe/trunk/tools/driver/driver.cpp Fri Jan 15 16:29:34 2016
>> @@ -290,9 +290,9 @@ static void SetInstallDir(SmallVectorImp
>>if (CanonicalPrefixes)
>>  llvm::sys::fs::make_absolute(InstalledPath);
>>
>> -  InstalledPath = llvm::sys::path::parent_path(InstalledPath);
>> -  if (llvm::sys::fs::exists(InstalledPath.c_str()))
>> -TheDriver.setInstalledDir(InstalledPath);
>> +  StringRef
>> InstalledPathParent(llvm::sys::path::parent_path(InstalledPath));
>> +  if (llvm::sys::fs::exists(InstalledPathParent))
>> +TheDriver.setInstalledDir(InstalledPathParent);
>>  }
>>
>>  static int ExecuteCC1Tool(ArrayRef argv, StringRef Tool) {
>>
>>
>> ___
>> 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


Re: r257947 - Avoid self-assignment of SmallString, trigger UB behavior down the road.

2016-01-15 Thread Joerg Sonnenberger via cfe-commits
On Fri, Jan 15, 2016 at 02:52:08PM -0800, David Blaikie via cfe-commits wrote:
> On Fri, Jan 15, 2016 at 2:29 PM, Joerg Sonnenberger via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> 
> > Author: joerg
> > Date: Fri Jan 15 16:29:34 2016
> > New Revision: 257947
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=257947&view=rev
> > Log:
> > Avoid self-assignment of SmallString, trigger UB behavior down the road.
> >
> 
> Shouldn't we be fixing that in SmallString? (self /move/ assignment
> arguably can be UB, but self copy assign probably shouldn't be)

parent_path can effectively onoly return the prefix of the argument, to
the overlap between src and dst is restricted to a prefix as well. I
don't think that's normally the case for a copy assignment from a
reference to the current string. If anything, I'd prefer to have an
assert checking for non-overlap.

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


Re: r257947 - Avoid self-assignment of SmallString, trigger UB behavior down the road.

2016-01-15 Thread David Blaikie via cfe-commits
On Fri, Jan 15, 2016 at 2:56 PM, Benjamin Kramer 
wrote:

> On Fri, Jan 15, 2016 at 11:52 PM, David Blaikie via cfe-commits
>  wrote:
> >
> >
> > On Fri, Jan 15, 2016 at 2:29 PM, Joerg Sonnenberger via cfe-commits
> >  wrote:
> >>
> >> Author: joerg
> >> Date: Fri Jan 15 16:29:34 2016
> >> New Revision: 257947
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=257947&view=rev
> >> Log:
> >> Avoid self-assignment of SmallString, trigger UB behavior down the road.
> >
> >
> > Shouldn't we be fixing that in SmallString? (self /move/ assignment
> arguably
> > can be UB, but self copy assign probably shouldn't be)
>
> It's a partial self-copy via StringRef. I don't think guarding against
> that very special case is worth it.
>

Seems pretty subtle/likely to cause pain in the future, perhaps.

I assume std::string is resilient to this?


>
> >>
> >>
> >> Modified:
> >> cfe/trunk/tools/driver/driver.cpp
> >>
> >> Modified: cfe/trunk/tools/driver/driver.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=257947&r1=257946&r2=257947&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/tools/driver/driver.cpp (original)
> >> +++ cfe/trunk/tools/driver/driver.cpp Fri Jan 15 16:29:34 2016
> >> @@ -290,9 +290,9 @@ static void SetInstallDir(SmallVectorImp
> >>if (CanonicalPrefixes)
> >>  llvm::sys::fs::make_absolute(InstalledPath);
> >>
> >> -  InstalledPath = llvm::sys::path::parent_path(InstalledPath);
> >> -  if (llvm::sys::fs::exists(InstalledPath.c_str()))
> >> -TheDriver.setInstalledDir(InstalledPath);
> >> +  StringRef
> >> InstalledPathParent(llvm::sys::path::parent_path(InstalledPath));
> >> +  if (llvm::sys::fs::exists(InstalledPathParent))
> >> +TheDriver.setInstalledDir(InstalledPathParent);
> >>  }
> >>
> >>  static int ExecuteCC1Tool(ArrayRef argv, StringRef Tool)
> {
> >>
> >>
> >> ___
> >> 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


Re: [PATCH] D15363: [UBSan] Implement runtime suppressions (PR25066).

2016-01-15 Thread Nico Weber via cfe-commits
thakis added a comment.

I figured out the difference. If I set up my environment by running 
`setenv.cmd` in the windows sdk, the test fails. If I set it up by running 
`vcvarsall.bat`, the test succeeds. Not clear yet why. But with the setenv.cmd 
setup, the asan suppression test fails too.


Repository:
  rL LLVM

http://reviews.llvm.org/D15363



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


Re: r257934 - [CMake] Support generation of linker order files using dtrace

2016-01-15 Thread Renato Golin via cfe-commits
On 15 January 2016 at 21:21, Chris Bieneman via cfe-commits
 wrote:
> Author: cbieneman
> Date: Fri Jan 15 15:21:12 2016
> New Revision: 257934
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257934&view=rev
> Log:
> [CMake] Support generation of linker order files using dtrace
>
> Summary:
> This patch extends the lit-based perf-training tooling supplied for PGO data 
> generation to also generate linker order files using dtrace.

Hi Chris,

This doesn't look good:

Script must be run as root, or you must add the following to your
sudoers:%%admin ALL=(ALL) NOPASSWD: /usr/sbin/dtrace

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/5234/steps/ninja%20check%201/logs/FAIL%3A%20Clang%20Perf%20Training%3A%3Ahello_world.cpp

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


Re: [PATCH] D15363: [UBSan] Implement runtime suppressions (PR25066).

2016-01-15 Thread Nico Weber via cfe-commits
thakis added a comment.

I re-disabled the test in 257952.


Repository:
  rL LLVM

http://reviews.llvm.org/D15363



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


Re: r257934 - [CMake] Support generation of linker order files using dtrace

2016-01-15 Thread Chris Bieneman via cfe-commits
That should be fixed with r257948.

-Chris

> On Jan 15, 2016, at 3:19 PM, Renato Golin  wrote:
> 
> On 15 January 2016 at 21:21, Chris Bieneman via cfe-commits
>  wrote:
>> Author: cbieneman
>> Date: Fri Jan 15 15:21:12 2016
>> New Revision: 257934
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=257934&view=rev
>> Log:
>> [CMake] Support generation of linker order files using dtrace
>> 
>> Summary:
>> This patch extends the lit-based perf-training tooling supplied for PGO data 
>> generation to also generate linker order files using dtrace.
> 
> Hi Chris,
> 
> This doesn't look good:
> 
> Script must be run as root, or you must add the following to your
> sudoers:%%admin ALL=(ALL) NOPASSWD: /usr/sbin/dtrace
> 
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/5234/steps/ninja%20check%201/logs/FAIL%3A%20Clang%20Perf%20Training%3A%3Ahello_world.cpp
> 
> cheers,
> --renato

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


Re: [PATCH] D15363: [UBSan] Implement runtime suppressions (PR25066).

2016-01-15 Thread Hans Wennborg via cfe-commits
hans added a subscriber: hans.
hans added a comment.

I tried to printf debug with this patch:

  Index: lib/sanitizer_common/sanitizer_suppressions.cc
  ===
  --- lib/sanitizer_common/sanitizer_suppressions.cc  (revision 257931)
  +++ lib/sanitizer_common/sanitizer_suppressions.cc  (working copy)
  @@ -82,6 +82,7 @@
   return false;
 for (uptr i = 0; i < suppressions_.size(); i++) {
   Suppression &cur = suppressions_[i];
  +Printf("matching cur.templ='%s' against str='%s'\n", cur.templ, str);
   if (0 == internal_strcmp(cur.type, type) && TemplateMatch(cur.templ, 
str))
  {
 *s = &cur;
 return true;
  @@ -134,6 +135,8 @@
 s.templ[end2 - line] = 0;
 suppressions_.push_back(s);
 has_suppression_type_[type] = true;
  +  Printf("suppression type: %s\n", suppression_types_[type]);
  +  Printf("template: %s\n", s.templ);
   }
   if (end[0] == 0)
 break;
  Index: lib/sanitizer_common/sanitizer_flag_parser.cc
  ===
  --- lib/sanitizer_common/sanitizer_flag_parser.cc   (revision 257931)
  +++ lib/sanitizer_common/sanitizer_flag_parser.cc   (working copy)
  @@ -97,6 +97,8 @@
   value = ll_strndup(buf_ + value_start, pos_ - value_start);
 }
  
  +  Printf("parsed flag: '%s' = '%s'\n", name, value);
  +
 bool res = run_handler(name, value);
 if (!res) fatal_error("Flag parsing failed.");
   }

Maybe it's failing to symbolize the do_overflow function name? It looks like 
it's never trying to match it against the suppressions, instead it's trying to 
match the null string twice for some reason:

  Command 7 Stderr:
  parsed flag: 'halt_on_error' = '1'
  parsed flag: 'suppressions' = 
'D:\src\chromium\src\third_party\llvm-bootstrap\pr
  
ojects\compiler-rt\test\ubsan\Standalone-x86_64\TestCases\Integer\Output\suppres
  sions.cpp.tmp.func-supp'
  suppression type: unsigned-integer-overflow
  template: do_overflow
  matching cur.templ='do_overflow' against 
str='D:\src\chromium\src\third_party\ll
  vm\projects\compiler-rt\test\ubsan\TestCases\Integer\suppressions.cpp'
  matching cur.templ='do_overflow' against 
str='D:\src\chromium\src\third_party\ll
  
vm-bootstrap\projects\compiler-rt\test\ubsan\Standalone-x86_64\TestCases\Integer
  \Output\suppressions.cpp.tmp'
  matching cur.templ='do_overflow' against str=''
  matching cur.templ='do_overflow' against str=''
  
D:\src\chromium\src\third_party\llvm\projects\compiler-rt\test\ubsan\TestCases\I
  nteger\suppressions.cpp:25:44: runtime error: unsigned integer overflow: 
100
  0 + 900 cannot be represented in type 'unsigned 
long
   long'


Repository:
  rL LLVM

http://reviews.llvm.org/D15363



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


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

2016-01-15 Thread Artem Belevich via cfe-commits
tra added a reviewer: jlebar.
tra updated this revision to Diff 45044.
tra added a comment.

Moved initializer checks from CodeGen to Sema.
Added test cases for initializers of non-class variables.


http://reviews.llvm.org/D15305

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGenCUDA/device-var-init.cu

Index: test/CodeGenCUDA/device-var-init.cu
===
--- /dev/null
+++ test/CodeGenCUDA/device-var-init.cu
@@ -0,0 +1,387 @@
+// REQUIRES: nvptx-registered-target
+
+// Make sure we don't allow dynamic initialization for device
+// variables, but accept empty constructors allowed by CUDA.
+
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \
+// RUN: -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \
+// RUN: -emit-llvm -DERROR_CASE -verify -o /dev/null %s
+
+#ifdef __clang__
+#include "Inputs/cuda.h"
+#endif
+
+// Base classes with different initializer variants.
+
+// trivial constructor -- allowed
+struct T {
+  int t;
+};
+
+// empty constructor
+struct EC {
+  int ec;
+  __device__ EC() {} // -- allowed
+  __device__ EC(int) {}  // -- not allowed
+};
+
+// empty templated constructor -- allowed with no arguments
+struct ETC {
+  template  __device__ ETC(T...) {}
+};
+
+// undefined constructor -- not allowed
+struct UC {
+  int uc;
+  __device__ UC();
+};
+
+// empty constructor w/ initializer list -- not allowed
+struct ECI {
+  int eci;
+  __device__ ECI() : eci(1) {}
+};
+
+// non-empty constructor -- not allowed
+struct NEC {
+  int nec;
+  __device__ NEC() { nec = 1; }
+};
+
+// no-constructor,  virtual method -- not allowed
+struct NCV {
+  int ncv;
+  __device__ virtual void vm() {}
+};
+
+// dynamic in-class field initializer -- not allowed
+__device__ int f();
+struct NCF {
+  int ncf = f();
+};
+
+// static in-class field initializer.
+struct NCFS {
+  int ncfs = 3;
+};
+
+// undefined templated constructor -- not allowed
+struct UTC {
+  template  __device__ UTC(T...);
+};
+
+// non-empty templated constructor -- not allowed
+struct NETC {
+  int netc;
+  template  __device__ NETC(T...) { netc = 1; }
+};
+
+__device__ int d_v;
+// CHECK: @d_v = addrspace(1) externally_initialized global i32 0,
+__shared__ int s_v;
+// CHECK: @s_v = addrspace(3) global i32 undef,
+__constant__ int c_v;
+// CHECK: addrspace(4) externally_initialized global i32 0,
+
+__device__ int d_v_i = 1;
+// CHECK: @d_v_i = addrspace(1) externally_initialized global i32 1,
+#ifdef ERROR_CASE
+__shared__ int s_v_i = 1;
+// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
+#endif
+__constant__ int c_v_i = 1;
+// CHECK: @c_v_i = addrspace(4) externally_initialized global i32 1,
+
+#ifdef ERROR_CASE
+__device__ int d_v_f = f();
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}}
+__shared__ int s_v_f = f();
+// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
+__constant__ int c_v_f = f();
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}}
+#endif
+
+__device__ T d_t;
+// CHECK: @d_t = addrspace(1) externally_initialized global %struct.T zeroinitializer
+__shared__ T s_t;
+// CHECK: @s_t = addrspace(3) global %struct.T undef,
+__constant__ T c_t;
+// CHECK: @c_t = addrspace(4) externally_initialized global %struct.T zeroinitializer,
+
+__device__ T d_t_i = {2};
+// CHECKL @d_t_i = addrspace(1) externally_initialized global %struct.T { i32 2 },
+#ifdef ERROR_CASE
+__shared__ T s_t_i = {2};
+// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
+#endif
+__constant__ T c_t_i = {2};
+// CHECK: @c_t_i = addrspace(4) externally_initialized global %struct.T { i32 2 },
+
+__device__ EC d_ec;
+// CHECK: @d_ec = addrspace(1) externally_initialized global %struct.EC zeroinitializer,
+__shared__ EC s_ec;
+// CHECK: @s_ec = addrspace(3) global %struct.EC undef,
+__constant__ EC c_ec;
+// CHECK: @c_ec = addrspace(4) externally_initialized global %struct.EC zeroinitializer,
+
+#if ERROR_CASE
+__device__ EC d_ec_i(3);
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}}
+__shared__ EC s_ec_i(3);
+// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
+__constant__ EC c_ec_i(3);
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}}
+
+__device__ EC d_ec_i2 = {3};
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}}
+__shared__ EC s_ec_i2 = {3};
+// expected-error@-1 {{initialization is 

Re: [PATCH] D16179: [clang-tidy] Handle decayed types and other improvements in VirtualNearMiss check.

2016-01-15 Thread Cong Liu via cfe-commits
congliu added a comment.

> - Ignore qualifiers.


I don't think we should ignore qualifiers. Please see my inline comment for 
line 52 of the test file.



Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:240
@@ -247,2 +239,3 @@
 unsigned EditDistance =
-BaseMD->getName().edit_distance(DerivedMD->getName());
+StringRef(BaseMD->getNameAsString())
+.edit_distance(DerivedMD->getNameAsString());

NamedDecl::getName() directly returns a StringRef. Why using 
"getNameAsString()"? 


Comment at: test/clang-tidy/misc-virtual-near-miss.cpp:52
@@ -49,2 +51,3 @@
 
-  int methoe(int x); // Should not warn: method is not const.
+  int methoe(int x);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::methoe' has 
{{.*}} 'Mother::method'

If a function in derived class has a same name but different cv-qualifiers as a 
function in base class, they are not regarded as overriding. For example, 

```
class Mother{ 
  virtual int method(int argc) const;
};
class Child : Mother{
  int method(int x);
};
```
In this case, Child::method does not overrides Mother::method, but hides it. So 
I think we should not warn for "methoe", because even if the programmer changes 
"methoe" to "method", it's not an overriding. 


http://reviews.llvm.org/D16179



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


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

2016-01-15 Thread Artem Belevich via cfe-commits
tra marked an inline comment as done.
tra added a comment.

In http://reviews.llvm.org/D15305#327226, @rsmith wrote:

> I think you missed this from my previous review:
>
> > This should be checked and diagnosed in Sema, not in CodeGen.
>


Done.


http://reviews.llvm.org/D15305



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


r257957 - OpaquePtr: Use nullptr construction for TemplateTy OpaquePtr typedef

2016-01-15 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Jan 15 17:43:28 2016
New Revision: 257957

URL: http://llvm.org/viewvc/llvm-project?rev=257957&view=rev
Log:
OpaquePtr: Use nullptr construction for TemplateTy OpaquePtr typedef

Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=257957&r1=257956&r2=257957&view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri Jan 15 17:43:28 2016
@@ -1006,8 +1006,8 @@ TypeResult Parser::ParseBaseTypeSpecifie
 if (!Template) {
   TemplateArgList TemplateArgs;
   SourceLocation LAngleLoc, RAngleLoc;
-  ParseTemplateIdAfterTemplateName(TemplateTy(), IdLoc, SS,
-  true, LAngleLoc, TemplateArgs, RAngleLoc);
+  ParseTemplateIdAfterTemplateName(nullptr, IdLoc, SS, true, LAngleLoc,
+   TemplateArgs, RAngleLoc);
   return true;
 }
 
@@ -1381,9 +1381,8 @@ void Parser::ParseClassSpecifier(tok::To
   // a class (or template thereof).
   TemplateArgList TemplateArgs;
   SourceLocation LAngleLoc, RAngleLoc;
-  if (ParseTemplateIdAfterTemplateName(TemplateTy(), NameLoc, SS,
-   true, LAngleLoc,
-   TemplateArgs, RAngleLoc)) {
+  if (ParseTemplateIdAfterTemplateName(
+  nullptr, NameLoc, SS, true, LAngleLoc, TemplateArgs, RAngleLoc)) 
{
 // We couldn't parse the template argument list at all, so don't
 // try to give any location information for the list.
 LAngleLoc = RAngleLoc = SourceLocation();


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


r257956 - OpaquePtr: Use nullptr construction for DeclGroupPtrTy OpaquePtr typedef

2016-01-15 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Jan 15 17:43:25 2016
New Revision: 257956

URL: http://llvm.org/viewvc/llvm-project?rev=257956&view=rev
Log:
OpaquePtr: Use nullptr construction for DeclGroupPtrTy OpaquePtr typedef

Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=257956&r1=257955&r2=257956&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Jan 15 17:43:25 2016
@@ -1522,7 +1522,7 @@ Parser::ParseSimpleDeclaration(unsigned
   // may get this far before the problem becomes obvious.
   if (DS.hasTagDefinition() &&
   DiagnoseMissingSemiAfterTagDefinition(DS, AS_none, DSContext))
-return DeclGroupPtrTy();
+return nullptr;
 
   // C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
   // declaration-specifiers init-declarator-list[opt] ';'
@@ -1701,7 +1701,7 @@ Parser::DeclGroupPtrTy Parser::ParseDecl
   // Bail out if the first declarator didn't seem well-formed.
   if (!D.hasName() && !D.mayOmitIdentifier()) {
 SkipMalformedDecl();
-return DeclGroupPtrTy();
+return nullptr;
   }
 
   // Save late-parsed attributes for now; they need to be parsed in the
@@ -1766,19 +1766,19 @@ Parser::DeclGroupPtrTy Parser::ParseDecl
   } else {
 Diag(Tok, diag::err_expected_fn_body);
 SkipUntil(tok::semi);
-return DeclGroupPtrTy();
+return nullptr;
   }
 } else {
   if (Tok.is(tok::l_brace)) {
 Diag(Tok, diag::err_function_definition_not_allowed);
 SkipMalformedDecl();
-return DeclGroupPtrTy();
+return nullptr;
   }
 }
   }
 
   if (ParseAsmAttributesAfterDeclarator(D))
-return DeclGroupPtrTy();
+return nullptr;
 
   // C++0x [stmt.iter]p1: Check if we have a for-range-declarator. If so, we
   // must parse and analyze the for-range-initializer before the declaration is

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=257956&r1=257955&r2=257956&view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri Jan 15 17:43:25 2016
@@ -65,7 +65,7 @@ Parser::DeclGroupPtrTy Parser::ParseName
   if (Tok.is(tok::code_completion)) {
 Actions.CodeCompleteNamespaceDecl(getCurScope());
 cutOffParsing();
-return DeclGroupPtrTy();
+return nullptr;
   }
 
   SourceLocation IdentLoc;
@@ -109,7 +109,7 @@ Parser::DeclGroupPtrTy Parser::ParseName
   Diag(Tok, diag::err_expected) << tok::identifier;
   // Skip to end of the definition and eat the ';'.
   SkipUntil(tok::semi);
-  return DeclGroupPtrTy();
+  return nullptr;
 }
 if (attrLoc.isValid())
   Diag(attrLoc, diag::err_unexpected_namespace_attributes_alias);
@@ -126,7 +126,7 @@ Parser::DeclGroupPtrTy Parser::ParseName
   Diag(Tok, diag::err_expected) << tok::l_brace;
 else
   Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
-return DeclGroupPtrTy();
+return nullptr;
   }
 
   if (getCurScope()->isClassScope() || getCurScope()->isTemplateParamScope() 
|| 
@@ -134,7 +134,7 @@ Parser::DeclGroupPtrTy Parser::ParseName
   getCurScope()->getFnParent()) {
 Diag(T.getOpenLocation(), diag::err_namespace_nonnamespace_scope);
 SkipUntil(tok::r_brace);
-return DeclGroupPtrTy();
+return nullptr;
   }
 
   if (ExtraIdent.empty()) {
@@ -2253,7 +2253,7 @@ Parser::ParseCXXClassMemberDeclaration(A
 
 ConsumeToken();
 SkipUntil(tok::r_brace, StopAtSemi);
-return DeclGroupPtrTy();
+return nullptr;
   }
 
   // Turn on colon protection early, while parsing declspec, although there is
@@ -2287,7 +2287,7 @@ Parser::ParseCXXClassMemberDeclaration(A
 
   if (SS.isInvalid()) {
 SkipUntil(tok::semi);
-return DeclGroupPtrTy();
+return nullptr;
   }
 
   // Try to parse an unqualified-id.
@@ -2296,14 +2296,14 @@ Parser::ParseCXXClassMemberDeclaration(A
   if (ParseUnqualifiedId(SS, false, true, true, ParsedType(),
  TemplateKWLoc, Name)) {
 SkipUntil(tok::semi);
-return DeclGroupPtrTy();
+return nullptr;
   }
 
   // TODO: recover from mistakenly-qualified operator declarations.
   if (ExpectAndConsume(tok::semi, diag::err_expected_after,
"access declaration")) {
 SkipUntil(tok::semi);
-return DeclGroupPtrTy();
+return nullptr;
   }
 

r257955 - OpaquePtr: Provide conversion-from-nullptr_t to make default construction simpler to read/write

2016-01-15 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Jan 15 17:43:21 2016
New Revision: 257955

URL: http://llvm.org/viewvc/llvm-project?rev=257955&view=rev
Log:
OpaquePtr: Provide conversion-from-nullptr_t to make default construction 
simpler to read/write

Modified:
cfe/trunk/include/clang/Sema/Ownership.h

Modified: cfe/trunk/include/clang/Sema/Ownership.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Ownership.h?rev=257955&r1=257954&r2=257955&view=diff
==
--- cfe/trunk/include/clang/Sema/Ownership.h (original)
+++ cfe/trunk/include/clang/Sema/Ownership.h Fri Jan 15 17:43:21 2016
@@ -43,13 +43,13 @@ namespace clang {
   /// compatible with "Type" pointers for example.
   template 
   class OpaquePtr {
-void *Ptr;
+void *Ptr = nullptr;
 explicit OpaquePtr(void *Ptr) : Ptr(Ptr) {}
 
 typedef llvm::PointerLikeTypeTraits Traits;
 
   public:
-OpaquePtr() : Ptr(nullptr) {}
+OpaquePtr(std::nullptr_t = nullptr) {}
 
 static OpaquePtr make(PtrTy P) { OpaquePtr OP; OP.set(P); return OP; }
 


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


r257958 - OpaquePtr: Use nullptr construction for ParsedType OpaquePtr typedef

2016-01-15 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Jan 15 17:43:34 2016
New Revision: 257958

URL: http://llvm.org/viewvc/llvm-project?rev=257958&view=rev
Log:
OpaquePtr: Use nullptr construction for ParsedType OpaquePtr typedef

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseInit.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Parse/ParseStmtAsm.cpp
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=257958&r1=257957&r2=257958&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Jan 15 17:43:34 2016
@@ -1485,9 +1485,8 @@ public:
 
   ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc,
  Scope *S, CXXScopeSpec *SS = nullptr,
- bool isClassName = false,
- bool HasTrailingDot = false,
- ParsedType ObjectType = ParsedType(),
+ bool isClassName = false, bool HasTrailingDot = false,
+ ParsedType ObjectType = nullptr,
  bool IsCtorOrDtorName = false,
  bool WantNontrivialTypeSourceInfo = false,
  IdentifierInfo **CorrectedII = nullptr);

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=257958&r1=257957&r2=257958&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Jan 15 17:43:34 2016
@@ -2835,12 +2835,11 @@ void Parser::ParseDeclarationSpecifiers(
   << Next.getIdentifierInfo() << 1 /* type */;
   }
 
-  ParsedType TypeRep = Actions.getTypeName(*Next.getIdentifierInfo(),
-   Next.getLocation(),
-   getCurScope(), &SS,
-   false, false, ParsedType(),
-   /*IsCtorOrDtorName=*/false,
-   /*NonTrivialSourceInfo=*/true);
+  ParsedType TypeRep =
+  Actions.getTypeName(*Next.getIdentifierInfo(), Next.getLocation(),
+  getCurScope(), &SS, false, false, nullptr,
+  /*IsCtorOrDtorName=*/false,
+  /*NonTrivialSourceInfo=*/true);
 
   // If the referenced identifier is not a type, then this declspec is
   // erroneous: We already checked about that it has no type specifier, and
@@ -3788,7 +3787,7 @@ void Parser::ParseEnumSpecifier(SourceLo
 ColonProtectionRAIIObject X(*this, AllowFixedUnderlyingType);
 
 CXXScopeSpec Spec;
-if (ParseOptionalCXXScopeSpecifier(Spec, ParsedType(),
+if (ParseOptionalCXXScopeSpecifier(Spec, nullptr,
/*EnteringContext=*/true))
   return;
 
@@ -4588,7 +4587,7 @@ bool Parser::isConstructorDeclarator(boo
 
   // Parse the C++ scope specifier.
   CXXScopeSpec SS;
-  if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(),
+  if (ParseOptionalCXXScopeSpecifier(SS, nullptr,
  /*EnteringContext=*/true)) {
 TPA.Revert();
 return false;
@@ -4932,7 +4931,7 @@ void Parser::ParseDeclaratorInternal(Dec
 bool EnteringContext = D.getContext() == Declarator::FileContext ||
D.getContext() == Declarator::MemberContext;
 CXXScopeSpec SS;
-ParseOptionalCXXScopeSpecifier(SS, ParsedType(), EnteringContext);
+ParseOptionalCXXScopeSpecifier(SS, nullptr, EnteringContext);
 
 if (SS.isNotEmpty()) {
   if (Tok.isNot(tok::star)) {
@@ -5147,7 +5146,7 @@ void Parser::ParseDirectDeclarator(Decla
 if (D.getCXXScopeSpec().isEmpty()) {
   bool EnteringContext = D.getContext() == Declarator::FileContext ||
  D.getContext() == Declarator::MemberContext;
-  ParseOptionalCXXScopeSpecifier(D.getCXXScopeSpec(), ParsedType(),
+  ParseOptionalCXXScopeSpecifier(D.getCXXScopeSpec(), nullptr,
  EnteringContext);
 }
 
@@ -5208,11 +5207,8 @@ void Parser::ParseDirectDeclarator(Decla
   bool HadScope = D.getCXXScopeSpec().isValid();
   if (ParseUnqualifiedId(D.getCXXScopeSpec(),

Re: r255281 - Do not generate DW_TAG_imported_module for anonymous namespaces (even nested) for all the platforms except PS4.

2016-01-15 Thread David Blaikie via cfe-commits
On Mon, Dec 21, 2015 at 2:35 AM, Romanova, Katya <
katya_roman...@playstation.sony.com> wrote:

> Hi David,
>
>
>
> Thank you so much for the review.
>
> I copied and pasted the diff file. Let me know if it’s OK to commit.
>
>
>
>
>
> >> Could/should this ^ just be: Opts.DebugExplicitImport =
> Triple.isPS4CPU(); ?
>
> Done.
>
>
>
> >> Extra semicolon here ^
>
> Done.
>

Thanks! Feel free to commit those changes. (you're welcome to commit
changes like that without review, btw)


>
>
> >> And is there any reason not to just use nullptr here and elsewhere?
> Anything with the substring "PtrTy" in the name seems like it should be
> pointer-like and be convertible from nullptr_t, no? (what is
> DeclGroupPtrTy?)
>
> No, it's not convertible from nullptr_t.
>
>
>
> /home/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:68:12: error: could not
> cnvert ‘nullptr’ from ‘std::nullptr_t’ to ‘clang::Parser::DeclGroupPtrTy
> {aka clang::OpaquePtr}’
>
>  return nullptr;
>

Ah - well, I fixed that and updated every instance of the old code to use
nullptr instead.


>
>
>
>
>
>
> Index: lib/Frontend/CompilerInvocation.cpp
>
> ===
>
> --- lib/Frontend/CompilerInvocation.cpp (revision 256140)
>
> +++ lib/Frontend/CompilerInvocation.cpp (working copy)
>
> @@ -1,4 +1,4 @@
>
> -//===--- CompilerInvocation.cpp
> ---===//
>
> +//===---
>
> //
>
> // The LLVM Compiler Infrastructure
>
> //
>
> @@ -417,8 +417,7 @@
>
>Opts.EmitCodeView = Args.hasArg(OPT_gcodeview);
>
>Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
>
>Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
>
> -  if (Triple.isPS4CPU())
>
> -Opts.DebugExplicitImport = true;
>
> +  Opts.DebugExplicitImport = Triple.isPS4CPU();
>
>
>
>for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
>
>  Opts.DebugPrefixMap.insert(StringRef(Arg).split('='));
>
> Index: lib/Parse/ParseDeclCXX.cpp
>
> ===
>
> --- lib/Parse/ParseDeclCXX.cpp  (revision 256140)
>
> +++ lib/Parse/ParseDeclCXX.cpp  (working copy)
>
> @@ -65,7 +65,7 @@
>
>if (Tok.is(tok::code_completion)) {
>
>  Actions.CodeCompleteNamespaceDecl(getCurScope());
>
>  cutOffParsing();
>
> -return DeclGroupPtrTy();;
>
> +return DeclGroupPtrTy();
>
>}
>
>
>
>SourceLocation IdentLoc;
>
>
>
>
>
> Thank you!
>
> Katya.
>
>
>
>
>
>
>
> *From:* David Blaikie [mailto:dblai...@gmail.com]
> *Sent:* Sunday, December 13, 2015 3:46 PM
> *To:* Romanova, Katya
> *Cc:* cfe-commits
> *Subject:* Re: r255281 - Do not generate DW_TAG_imported_module for
> anonymous namespaces (even nested) for all the platforms except PS4.
>
>
>
>
>
>
>
> On Thu, Dec 10, 2015 at 10:52 AM, Ekaterina Romanova via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: kromanova
> Date: Thu Dec 10 12:52:50 2015
> New Revision: 255281
>
> URL: http://llvm.org/viewvc/llvm-project?rev=255281&view=rev
> Log:
> Do not generate DW_TAG_imported_module for anonymous namespaces (even
> nested) for all the platforms except PS4.
> For PS4, generate explicit import for anonymous namespaces and mark it by
> DW_AT_artificial attribute.
>
> Differential Revision: http://reviews.llvm.org/D12624
>
>
> Added:
> cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp
> Modified:
> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>
> Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=255281&r1=255280&r2=255281&view=diff
>
> ==
> --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Dec 10
> 12:52:50 2015
> @@ -166,6 +166,10 @@ CODEGENOPT(DebugColumnInfo, 1, 0) ///< W
>  CODEGENOPT(DebugTypeExtRefs, 1, 0) ///< Whether or not debug info should
> contain
> ///< external references to a PCH or
> module.
>
> +CODEGENOPT(DebugExplicitImport, 1, 0)  ///< Whether or not debug info
> should
> +   ///< contain explicit imports for
> +   ///< anonymous namespaces
> +
>  CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize
> use-lists.
>
>  /// The user specified number of registers to be used for integral
> arguments,
>
> Modified: cfe/trunk/include/clang/Parse/Parser.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/

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

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


Comment at: lib/CodeGen/CGDeclCXX.cpp:312
@@ +311,3 @@
+  // the checks have been done in Sema by now. Whatever initializers
+  // areallowed are empty and we just need to ignore them here.
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&

areallowed -> are allowed


Comment at: lib/CodeGen/CodeGenModule.cpp:2334
@@ -2339,1 +2333,3 @@
+  D->hasAttr())
 Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy));
+  else if (!InitExpr) {

As this is a global variable, it should presumably still be statically 
zero-initialized.


http://reviews.llvm.org/D15305



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


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

2016-01-15 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: lib/CodeGen/CodeGenModule.cpp:2334
@@ -2339,1 +2333,3 @@
+  D->hasAttr())
 Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy));
+  else if (!InitExpr) {

rsmith wrote:
> As this is a global variable, it should presumably still be statically 
> zero-initialized.
There is no way to initialize __shared__ variables. They are rough equivalent 
of local variables, only in this case CUDA allocates them per kernel invocation 
from a shared buffer with no guarantees regarding its contents.

They used to be zero-initialized by compiler, but that was intentionally 
changed to undef in r245786 / http://reviews.llvm.org/D12241


http://reviews.llvm.org/D15305



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


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

2016-01-15 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 45051.
tra marked an inline comment as done.
tra added a comment.

Typo fix.


http://reviews.llvm.org/D15305

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGenCUDA/device-var-init.cu

Index: test/CodeGenCUDA/device-var-init.cu
===
--- /dev/null
+++ test/CodeGenCUDA/device-var-init.cu
@@ -0,0 +1,387 @@
+// REQUIRES: nvptx-registered-target
+
+// Make sure we don't allow dynamic initialization for device
+// variables, but accept empty constructors allowed by CUDA.
+
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \
+// RUN: -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \
+// RUN: -emit-llvm -DERROR_CASE -verify -o /dev/null %s
+
+#ifdef __clang__
+#include "Inputs/cuda.h"
+#endif
+
+// Base classes with different initializer variants.
+
+// trivial constructor -- allowed
+struct T {
+  int t;
+};
+
+// empty constructor
+struct EC {
+  int ec;
+  __device__ EC() {} // -- allowed
+  __device__ EC(int) {}  // -- not allowed
+};
+
+// empty templated constructor -- allowed with no arguments
+struct ETC {
+  template  __device__ ETC(T...) {}
+};
+
+// undefined constructor -- not allowed
+struct UC {
+  int uc;
+  __device__ UC();
+};
+
+// empty constructor w/ initializer list -- not allowed
+struct ECI {
+  int eci;
+  __device__ ECI() : eci(1) {}
+};
+
+// non-empty constructor -- not allowed
+struct NEC {
+  int nec;
+  __device__ NEC() { nec = 1; }
+};
+
+// no-constructor,  virtual method -- not allowed
+struct NCV {
+  int ncv;
+  __device__ virtual void vm() {}
+};
+
+// dynamic in-class field initializer -- not allowed
+__device__ int f();
+struct NCF {
+  int ncf = f();
+};
+
+// static in-class field initializer.
+struct NCFS {
+  int ncfs = 3;
+};
+
+// undefined templated constructor -- not allowed
+struct UTC {
+  template  __device__ UTC(T...);
+};
+
+// non-empty templated constructor -- not allowed
+struct NETC {
+  int netc;
+  template  __device__ NETC(T...) { netc = 1; }
+};
+
+__device__ int d_v;
+// CHECK: @d_v = addrspace(1) externally_initialized global i32 0,
+__shared__ int s_v;
+// CHECK: @s_v = addrspace(3) global i32 undef,
+__constant__ int c_v;
+// CHECK: addrspace(4) externally_initialized global i32 0,
+
+__device__ int d_v_i = 1;
+// CHECK: @d_v_i = addrspace(1) externally_initialized global i32 1,
+#ifdef ERROR_CASE
+__shared__ int s_v_i = 1;
+// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
+#endif
+__constant__ int c_v_i = 1;
+// CHECK: @c_v_i = addrspace(4) externally_initialized global i32 1,
+
+#ifdef ERROR_CASE
+__device__ int d_v_f = f();
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}}
+__shared__ int s_v_f = f();
+// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
+__constant__ int c_v_f = f();
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}}
+#endif
+
+__device__ T d_t;
+// CHECK: @d_t = addrspace(1) externally_initialized global %struct.T zeroinitializer
+__shared__ T s_t;
+// CHECK: @s_t = addrspace(3) global %struct.T undef,
+__constant__ T c_t;
+// CHECK: @c_t = addrspace(4) externally_initialized global %struct.T zeroinitializer,
+
+__device__ T d_t_i = {2};
+// CHECKL @d_t_i = addrspace(1) externally_initialized global %struct.T { i32 2 },
+#ifdef ERROR_CASE
+__shared__ T s_t_i = {2};
+// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
+#endif
+__constant__ T c_t_i = {2};
+// CHECK: @c_t_i = addrspace(4) externally_initialized global %struct.T { i32 2 },
+
+__device__ EC d_ec;
+// CHECK: @d_ec = addrspace(1) externally_initialized global %struct.EC zeroinitializer,
+__shared__ EC s_ec;
+// CHECK: @s_ec = addrspace(3) global %struct.EC undef,
+__constant__ EC c_ec;
+// CHECK: @c_ec = addrspace(4) externally_initialized global %struct.EC zeroinitializer,
+
+#if ERROR_CASE
+__device__ EC d_ec_i(3);
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}}
+__shared__ EC s_ec_i(3);
+// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
+__constant__ EC c_ec_i(3);
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}}
+
+__device__ EC d_ec_i2 = {3};
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}}
+__shared__ EC s_ec_i2 = {3};
+// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
+__constant__ EC c_ec_i2 = {3};
+// expected-

r257968 - [libclang] Introduce APIs for evaluating a cursor and checking if a macro is builtin/function.

2016-01-15 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Jan 15 18:20:02 2016
New Revision: 257968

URL: http://llvm.org/viewvc/llvm-project?rev=257968&view=rev
Log:
[libclang] Introduce APIs for evaluating a cursor and checking if a macro is 
builtin/function.

rdar://24091595

Added:
cfe/trunk/test/Index/evaluate-cursor.cpp
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=257968&r1=257967&r2=257968&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Fri Jan 15 18:20:02 2016
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 32
+#define CINDEX_VERSION_MINOR 33
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -2431,6 +2431,11 @@ CINDEX_LINKAGE unsigned clang_isStatemen
 CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
 
 /**
+ * \brief Determine whether the given cursor has any attributes.
+ */
+CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
+
+/**
  * \brief Determine whether the given cursor kind represents an invalid
  * cursor.
  */
@@ -3170,6 +3175,24 @@ CINDEX_LINKAGE CXType clang_getCanonical
 CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
 
 /**
+ * \brief Determine whether a  CXCursor that is a macro, is
+ * function like.
+ */
+CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
+
+/**
+ * \brief Determine whether a  CXCursor that is a macro, is a
+ * builtin one.
+ */
+CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
+
+/**
+ * \brief Determine whether a  CXCursor that is a function declaration, is an
+ * inline declaration.
+ */
+CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
+
+/**
  * \brief Determine whether a CXType has the "volatile" qualifier set,
  * without looking through typedefs that may have added "volatile" at
  * a different level.
@@ -3199,6 +3222,11 @@ CINDEX_LINKAGE CXCursor clang_getTypeDec
 CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
 
 /**
+ * Returns the Objective-C type encoding for the specified CXType.
+ */
+CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type); 
+
+/**
  * \brief Retrieve the spelling of a given CXTypeKind.
  */
 CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
@@ -5077,6 +5105,59 @@ CINDEX_LINKAGE void clang_getInclusions(
 CXInclusionVisitor visitor,
 CXClientData client_data);
 
+typedef enum {
+  CXEval_Int = 1 ,
+  CXEval_Float = 2,
+  CXEval_ObjCStrLiteral = 3,
+  CXEval_StrLiteral = 4,
+  CXEval_CFStr = 5,
+  CXEval_Other = 6,
+
+  CXEval_UnExposed = 0
+
+} CXEvalResultKind ;
+
+/**
+ * \brief Evaluation result of a cursor
+ */
+typedef void * CXEvalResult;
+
+/**
+ * \brief If cursor is a statement declaration tries to evaluate the 
+ * statement and if its variable, tries to evaluate its initializer,
+ * into its corresponding type.
+ */
+CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
+
+/**
+ * \brief Returns the kind of the evaluated result.
+ */
+CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
+
+/**
+ * \brief Returns the evaluation result as integer if the
+ * kind is Int.
+ */
+int clang_EvalResult_getAsInt(CXEvalResult E);
+
+/**
+ * \brief Returns the evaluation result as double if the
+ * kind is double.
+ */
+double clang_EvalResult_getAsDouble(CXEvalResult E);
+
+/**
+ * \brief Returns the evaluation result as a constant string if the
+ * kind is other than Int or float. User must not free this pointer,
+ * instead call clang_EvalResult_dispose on the CXEvalResult returned
+ * by clang_Cursor_Evaluate.
+ */
+const char* clang_EvalResult_getAsStr(CXEvalResult E);
+
+/**
+ * \brief Disposes the created Eval memory.
+ */
+void clang_EvalResult_dispose(CXEvalResult E);
 /**
  * @}
  */

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=257968&r1=257967&r2=257968&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Jan 15 18:20:02 2016
@@ -5913,7 +5913,7 @@ void ASTContext::getObjCEncodingForStruc
  QualType *NotEncodedT) const {
   assert(RDecl && "Expected non-null RecordDecl");
   assert(!RDecl->isUnion() && "Should not be called for unions");
-  if (!RDecl->getDefinition())
+  if (!RDecl->getDefinit

r257971 - Introduce -fsanitize-stats flag.

2016-01-15 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Fri Jan 15 18:31:22 2016
New Revision: 257971

URL: http://llvm.org/viewvc/llvm-project?rev=257971&view=rev
Log:
Introduce -fsanitize-stats flag.

This is part of a new statistics gathering feature for the sanitizers.
See clang/docs/SanitizerStats.rst for further info and docs.

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

Added:
cfe/trunk/docs/SanitizerStats.rst
cfe/trunk/test/CodeGen/linker-option.c
cfe/trunk/test/CodeGenCXX/cfi-stats.cpp
Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/docs/index.rst
cfe/trunk/include/clang/AST/ASTConsumer.h
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/Driver/sanitizer-ld.c

Added: cfe/trunk/docs/SanitizerStats.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SanitizerStats.rst?rev=257971&view=auto
==
--- cfe/trunk/docs/SanitizerStats.rst (added)
+++ cfe/trunk/docs/SanitizerStats.rst Fri Jan 15 18:31:22 2016
@@ -0,0 +1,62 @@
+==
+SanitizerStats
+==
+
+.. contents::
+   :local:
+
+Introduction
+
+
+The sanitizers support a simple mechanism for gathering profiling statistics
+to help understand the overhead associated with sanitizers.
+
+How to build and run
+
+
+SanitizerStats can currently only be used with :doc:`ControlFlowIntegrity`.
+In addition to ``-fsanitize=cfi*``, pass the ``-fsanitize-stats`` flag.
+This will cause the program to count the number of times that each control
+flow integrity check in the program fires.
+
+At run time, set the ``SANITIZER_STATS_PATH`` environment variable to direct
+statistics output to a file. The file will be written on process exit.
+The following substitutions will be applied to the environment variable:
+
+  - ``%b`` -- The executable basename.
+  - ``%p`` -- The process ID.
+
+You can also send the ``SIGUSR2`` signal to a process to make it write
+sanitizer statistics immediately.
+
+The ``sanstats`` program can be used to dump statistics. It takes as a
+command line argument the path to a statistics file produced by a program
+compiled with ``-fsanitize-stats``.
+
+The output of ``sanstats`` is in four columns, separated by spaces. The first
+column is the file and line number of the call site. The second column is
+the function name. The third column is the type of statistic gathered (in
+this case, the type of control flow integrity check). The fourth column is
+the call count.
+
+Example:
+
+.. code-block:: console
+
+$ cat -n vcall.cc
+ 1 struct A {
+ 2   virtual void f() {}
+ 3 };
+ 4
+ 5 __attribute__((noinline)) void g(A *a) {
+ 6   a->f();
+ 7 }
+ 8
+ 9 int main() {
+10   A a;
+11   g(&a);
+12 }
+$ clang++ -fsanitize=cfi -flto -fuse-ld=gold vcall.cc -fsanitize-stats -g
+$ SANITIZER_STATS_PATH=a.stats ./a.out
+$ sanstats a.stats
+vcall.cc:6 _Z1gP1A cfi-vcall 1

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=257971&r1=257970&r2=257971&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Fri Jan 15 18:31:22 2016
@@ -1038,6 +1038,11 @@ are listed below.
Enable simple code coverage in addition to certain sanitizers.
See :doc:`SanitizerCoverage` for more details.
 
+**-f[no-]sanitize-stats**
+
+   Enable simple statistics gathering for the enabled sanitizers.
+   See :doc:`SanitizerStats` for more details.
+
 .. option:: -fsanitize-undefined-trap-on-error
 
Deprecated alias for ``-fsanitize-trap=undefined``.

Modified: cfe/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/index.rst?rev=257971&r1=257970&r2=257971&view=diff
==
--- cfe/trunk/docs/index.rst (original)
+++ cfe/trunk/docs/index.rst Fri Jan 15 18:31:22 2016

Re: [PATCH] D16175: Introduce -fsanitize-stats flag.

2016-01-15 Thread Peter Collingbourne via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257971: Introduce -fsanitize-stats flag. (authored by pcc).

Changed prior to commit:
  http://reviews.llvm.org/D16175?vs=44945&id=45056#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16175

Files:
  cfe/trunk/docs/SanitizerStats.rst
  cfe/trunk/docs/UsersManual.rst
  cfe/trunk/docs/index.rst
  cfe/trunk/include/clang/AST/ASTConsumer.h
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Driver/SanitizerArgs.h
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/include/clang/Frontend/CodeGenOptions.h
  cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
  cfe/trunk/lib/CodeGen/CGClass.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CodeGenAction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
  cfe/trunk/lib/Driver/SanitizerArgs.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
  cfe/trunk/lib/Sema/SemaAttr.cpp
  cfe/trunk/test/CodeGen/linker-option.c
  cfe/trunk/test/CodeGenCXX/cfi-stats.cpp
  cfe/trunk/test/Driver/fsanitize.c
  cfe/trunk/test/Driver/sanitizer-ld.c

Index: cfe/trunk/test/CodeGenCXX/cfi-stats.cpp
===
--- cfe/trunk/test/CodeGenCXX/cfi-stats.cpp
+++ cfe/trunk/test/CodeGenCXX/cfi-stats.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall,cfi-nvcall,cfi-derived-cast,cfi-unrelated-cast,cfi-icall -fsanitize-stats -emit-llvm -o - %s | FileCheck --check-prefix=CHECK %s
+
+// CHECK: [[STATS:@[^ ]*]] = internal global { i8*, i32, [5 x [2 x i8*]] } { i8* null, i32 5, [5 x [2 x i8*]]
+// CHECK: {{\[\[}}2 x i8*] zeroinitializer,
+// CHECK: [2 x i8*] [i8* null, i8* inttoptr (i64 2305843009213693952 to i8*)],
+// CHECK: [2 x i8*] [i8* null, i8* inttoptr (i64 4611686018427387904 to i8*)],
+// CHECK: [2 x i8*] [i8* null, i8* inttoptr (i64 6917529027641081856 to i8*)],
+// CHECK: [2 x i8*] [i8* null, i8* inttoptr (i64 -9223372036854775808 to i8*)]] }
+
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* [[CTOR:@[^ ]*]], i8* null }]
+
+struct A {
+  virtual void vf();
+  void nvf();
+};
+struct B : A {};
+
+// CHECK: @vcall
+extern "C" void vcall(A *a) {
+  // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 0
+  a->vf();
+}
+
+// CHECK: @nvcall
+extern "C" void nvcall(A *a) {
+  // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 1
+  a->nvf();
+}
+
+// CHECK: @dcast
+extern "C" void dcast(A *a) {
+  // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 2
+  static_cast(a);
+}
+
+// CHECK: @ucast
+extern "C" void ucast(void *a) {
+  // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 3
+  reinterpret_cast(a);
+}
+
+// CHECK: @icall
+extern "C" void icall(void (*p)()) {
+  // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 4
+  p();
+}
+
+// CHECK: define internal void [[CTOR]]()
+// CHECK-NEXT: call void @__sanitizer_stat_init(i8* bitcast ({ i8*, i32, [5 x [2 x i8*]] }* [[STATS]] to i8*))
+// CHECK-NEXT: ret void
Index: cfe/trunk/test/CodeGen/linker-option.c
===
--- cfe/trunk/test/CodeGen/linker-option.c
+++ cfe/trunk/test/CodeGen/linker-option.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s --linker-option=/include:foo -triple i686-pc-win32 -emit-llvm -o - | FileCheck %s
+
+// CHECK: !llvm.module.flags = !{{{.*}}}
+// CHECK: !{{[0-9]+}} = !{i32 6, !"Linker Options", ![[link_opts:[0-9]+]]}
+// CHECK: ![[link_opts]] = !{![[msvcrt:[0-9]+]]}
+// CHECK: ![[msvcrt]] = !{!"/include:foo"}
+
+int f();
Index: cfe/trunk/test/Driver/sanitizer-ld.c
===
--- cfe/trunk/test/Driver/sanitizer-ld.c
+++ cfe/trunk/test/Driver/sanitizer-ld.c
@@ -345,6 +345,39 @@
 // CHECK-SAFESTACK-LINUX: "-lpthread"
 // CHECK-SAFESTACK-LINUX: "-ldl"
 
+// RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-STATS-LINUX %s
+// CHECK-CFI-STATS-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-STATS-LINUX: "-whole-archive" "{{[^"]*}}libclang_rt.stats_client-x86_64.a" "-no-whole-archive"
+// CHECK-CFI-STATS-LINUX-NOT: "-whole-archive"
+// CHECK-CFI-STATS-LINUX: "{{[^"]*}}libclang_rt.stats-x86_64.a"
+
+// RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \
+// RUN: -targ

Re: r257808 - Don't build jobs for the same Action + ToolChain twice.

2016-01-15 Thread Chris Bieneman via cfe-commits
This change breaks darwin fat binary support.

> ./bin/clang++ ~/dev/scratch/hello_world.cpp -arch armv7 -arch armv7s 
> -isysroot 
> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/
fatal error: 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo:
 /var/folders/pb/95pc7qfx2xl9kr9kg0gg_9ccgn/T/hello_world-1b17ac.out and 
/var/folders/pb/95pc7qfx2xl9kr9kg0gg_9ccgn/T/hello_world-1b17ac.out have 
the same architectures (armv7) and can't be in the same fat output file
clang-3.9: error: lipo command failed with exit code 1 (use -v to see 
invocation)

Can someone more familiar with this code please take a look?

Thanks,

-Chris

> On Jan 14, 2016, at 1:41 PM, Justin Lebar via cfe-commits 
>  wrote:
> 
> Author: jlebar
> Date: Thu Jan 14 15:41:21 2016
> New Revision: 257808
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=257808&view=rev
> Log:
> Don't build jobs for the same Action + ToolChain twice.
> 
> Summary:
> Right now if the Action graph is a DAG and we encounter an action twice,
> we will run it twice.
> 
> This patch is difficult to test as-is, but I have testcases for this as
> used within CUDA compilation.
> 
> Reviewers:
> 
> Subscribers:
> 
> Modified:
>cfe/trunk/include/clang/Driver/Driver.h
>cfe/trunk/lib/Driver/Driver.cpp
> 
> Modified: cfe/trunk/include/clang/Driver/Driver.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=257808&r1=257807&r2=257808&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Driver.h (original)
> +++ cfe/trunk/include/clang/Driver/Driver.h Thu Jan 14 15:41:21 2016
> @@ -21,6 +21,7 @@
> #include "llvm/Support/Path.h" // FIXME: Kill when CompilationInfo lands.
> 
> #include 
> +#include 
> #include 
> #include 
> #include 
> @@ -381,10 +382,13 @@ public:
> 
>   /// BuildJobsForAction - Construct the jobs to perform for the
>   /// action \p A and return an InputInfo for the result of running \p A.
> +  /// Will only construct jobs for a given (Action, ToolChain) pair once.
>   InputInfo BuildJobsForAction(Compilation &C, const Action *A,
>const ToolChain *TC, const char *BoundArch,
>bool AtTopLevel, bool MultipleArchs,
> -   const char *LinkingOutput) const;
> +   const char *LinkingOutput,
> +   std::map std::string>,
> +InputInfo> &CachedResults) const;
> 
>   /// Returns the default name for linked images (e.g., "a.out").
>   const char *getDefaultImageName() const;
> @@ -441,6 +445,16 @@ private:
>   /// the driver mode.
>   std::pair getIncludeExcludeOptionFlagMasks() const;
> 
> +  /// Helper used in BuildJobsForAction.  Doesn't use the cache when building
> +  /// jobs specifically for the given action, but will use the cache when
> +  /// building jobs for the Action's inputs.
> +  InputInfo BuildJobsForActionNoCache(
> +  Compilation &C, const Action *A, const ToolChain *TC,
> +  const char *BoundArch, bool AtTopLevel, bool MultipleArchs,
> +  const char *LinkingOutput,
> +  std::map, InputInfo>
> +  &CachedResults) const;
> +
> public:
>   /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
>   /// return the grouped values as integers. Numbers which are not
> 
> Modified: cfe/trunk/lib/Driver/Driver.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=257808&r1=257807&r2=257808&view=diff
> ==
> --- cfe/trunk/lib/Driver/Driver.cpp (original)
> +++ cfe/trunk/lib/Driver/Driver.cpp Thu Jan 14 15:41:21 2016
> @@ -1632,6 +1632,8 @@ void Driver::BuildJobs(Compilation &C) c
>   if (A->getOption().matches(options::OPT_arch))
> ArchNames.insert(A->getValue());
> 
> +  // Set of (Action, canonical ToolChain triple) pairs we've built jobs for.
> +  std::map, InputInfo> CachedResults;
>   for (Action *A : C.getActions()) {
> // If we are linking an image for multiple archs then the linker wants
> // -arch_multiple and -final_output . Unfortunately, 
> this
> @@ -1651,7 +1653,7 @@ void Driver::BuildJobs(Compilation &C) c
>/*BoundArch*/ nullptr,
>/*AtTopLevel*/ true,
>/*MultipleArchs*/ ArchNames.size() > 1,
> -   /*LinkingOutput*/ LinkingOutput);
> +   /*LinkingOutput*/ LinkingOutput, CachedResults);
>   }
> 
>   // If the user passed -Qunused-arguments or there were errors, don't warn
> @@ -1779,19 +1781,38 @@ static const Tool *selectToolForJob(Comp
>   return ToolForJob;
> }
> 
> -InputInfo Driver::BuildJobsForAction(Compilation &C, const Action *A,
> -   

[PATCH] D16248: [Clang-tidy] rename misc-inefficient-algorithm to performance-inefficient-algorithm

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

Just to reduce number of uncategorized checks, since Clang-tidy has dedicated 
category for performance checks for awhile.

Repository:
  rL LLVM

http://reviews.llvm.org/D16248

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/InefficientAlgorithmCheck.cpp
  clang-tidy/misc/InefficientAlgorithmCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/InefficientAlgorithmCheck.cpp
  clang-tidy/performance/InefficientAlgorithmCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-inefficient-algorithm.rst
  docs/clang-tidy/checks/performance-inefficient-algorithm.rst
  test/clang-tidy/misc-inefficient-algorithm.cpp
  test/clang-tidy/performance-inefficient-algorithm.cpp

Index: clang-tidy/performance/InefficientAlgorithmCheck.h
===
--- clang-tidy/performance/InefficientAlgorithmCheck.h
+++ clang-tidy/performance/InefficientAlgorithmCheck.h
@@ -7,14 +7,14 @@
 //
 //===--===//
 
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INEFFICIENTALGORITHMCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INEFFICIENTALGORITHMCHECK_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_INEFFICIENTALGORITHMCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_INEFFICIENTALGORITHMCHECK_H
 
 #include "../ClangTidy.h"
 
 namespace clang {
 namespace tidy {
-namespace misc {
+namespace performance {
 
 /// Warns on inefficient use of STL algorithms on associative containers.
 ///
@@ -29,8 +29,8 @@
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 };
 
-} // namespace misc
+} // namespace performance
 } // namespace tidy
 } // namespace clang
 
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INEFFICIENTALGORITHMCHECK_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_INEFFICIENTALGORITHMCHECK_H
Index: clang-tidy/performance/CMakeLists.txt
===
--- clang-tidy/performance/CMakeLists.txt
+++ clang-tidy/performance/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyPerformanceModule
+  InefficientAlgorithmCheck.cpp
   PerformanceTidyModule.cpp
   UnnecessaryCopyInitialization.cpp
 
Index: clang-tidy/performance/InefficientAlgorithmCheck.cpp
===
--- clang-tidy/performance/InefficientAlgorithmCheck.cpp
+++ clang-tidy/performance/InefficientAlgorithmCheck.cpp
@@ -16,7 +16,7 @@
 
 namespace clang {
 namespace tidy {
-namespace misc {
+namespace performance {
 
 static bool areTypesCompatible(QualType Left, QualType Right) {
   if (const auto *LeftRefType = Left->getAs())
@@ -153,6 +153,6 @@
   << Hint;
 }
 
-} // namespace misc
+} // namespace performance
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/performance/PerformanceTidyModule.cpp
===
--- clang-tidy/performance/PerformanceTidyModule.cpp
+++ clang-tidy/performance/PerformanceTidyModule.cpp
@@ -10,7 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
-
+#include "InefficientAlgorithmCheck.h"
 #include "UnnecessaryCopyInitialization.h"
 
 namespace clang {
@@ -20,6 +20,8 @@
 class PerformanceModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"performance-inefficient-algorithm");
 CheckFactories.registerCheck(
 "performance-unnecessary-copy-initialization");
   }
Index: clang-tidy/misc/InefficientAlgorithmCheck.h
===
--- clang-tidy/misc/InefficientAlgorithmCheck.h
+++ clang-tidy/misc/InefficientAlgorithmCheck.h
@@ -1,36 +0,0 @@
-//===--- InefficientAlgorithmCheck.h - clang-tidy*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INEFFICIENTALGORITHMCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INEFFICIENTALGORITHMCHECK_H
-
-#include "../ClangTidy.h"
-
-namespace clang {
-namespace tidy {
-namespace misc {
-
-/// Warns on inefficient use of STL algorithms on associative containers.
-///
-/// Associative containers implements some of the algorithms as methods which
-

Re: r257808 - Don't build jobs for the same Action + ToolChain twice.

2016-01-15 Thread Chris Bieneman via cfe-commits
+Eric,

If this patch can’t be quickly fixed, can it please be reverted?

-Chris

> On Jan 15, 2016, at 4:36 PM, Chris Bieneman via cfe-commits 
>  wrote:
> 
> This change breaks darwin fat binary support.
> 
> > ./bin/clang++ ~/dev/scratch/hello_world.cpp -arch armv7 -arch armv7s 
> > -isysroot 
> > /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/
> fatal error: 
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo:
>  /var/folders/pb/95pc7qfx2xl9kr9kg0gg_9ccgn/T/hello_world-1b17ac.out and 
> /var/folders/pb/95pc7qfx2xl9kr9kg0gg_9ccgn/T/hello_world-1b17ac.out have 
> the same architectures (armv7) and can't be in the same fat output file
> clang-3.9: error: lipo command failed with exit code 1 (use -v to see 
> invocation)
> 
> Can someone more familiar with this code please take a look?
> 
> Thanks,
> 
> -Chris
> 
>> On Jan 14, 2016, at 1:41 PM, Justin Lebar via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>> Author: jlebar
>> Date: Thu Jan 14 15:41:21 2016
>> New Revision: 257808
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=257808&view=rev 
>> 
>> Log:
>> Don't build jobs for the same Action + ToolChain twice.
>> 
>> Summary:
>> Right now if the Action graph is a DAG and we encounter an action twice,
>> we will run it twice.
>> 
>> This patch is difficult to test as-is, but I have testcases for this as
>> used within CUDA compilation.
>> 
>> Reviewers:
>> 
>> Subscribers:
>> 
>> Modified:
>>cfe/trunk/include/clang/Driver/Driver.h
>>cfe/trunk/lib/Driver/Driver.cpp
>> 
>> Modified: cfe/trunk/include/clang/Driver/Driver.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=257808&r1=257807&r2=257808&view=diff
>>  
>> 
>> ==
>> --- cfe/trunk/include/clang/Driver/Driver.h (original)
>> +++ cfe/trunk/include/clang/Driver/Driver.h Thu Jan 14 15:41:21 2016
>> @@ -21,6 +21,7 @@
>> #include "llvm/Support/Path.h" // FIXME: Kill when CompilationInfo lands.
>> 
>> #include 
>> +#include 
>> #include 
>> #include 
>> #include 
>> @@ -381,10 +382,13 @@ public:
>> 
>>   /// BuildJobsForAction - Construct the jobs to perform for the
>>   /// action \p A and return an InputInfo for the result of running \p A.
>> +  /// Will only construct jobs for a given (Action, ToolChain) pair once.
>>   InputInfo BuildJobsForAction(Compilation &C, const Action *A,
>>const ToolChain *TC, const char *BoundArch,
>>bool AtTopLevel, bool MultipleArchs,
>> -   const char *LinkingOutput) const;
>> +   const char *LinkingOutput,
>> +   std::map> std::string>,
>> +InputInfo> &CachedResults) const;
>> 
>>   /// Returns the default name for linked images (e.g., "a.out").
>>   const char *getDefaultImageName() const;
>> @@ -441,6 +445,16 @@ private:
>>   /// the driver mode.
>>   std::pair getIncludeExcludeOptionFlagMasks() const;
>> 
>> +  /// Helper used in BuildJobsForAction.  Doesn't use the cache when 
>> building
>> +  /// jobs specifically for the given action, but will use the cache when
>> +  /// building jobs for the Action's inputs.
>> +  InputInfo BuildJobsForActionNoCache(
>> +  Compilation &C, const Action *A, const ToolChain *TC,
>> +  const char *BoundArch, bool AtTopLevel, bool MultipleArchs,
>> +  const char *LinkingOutput,
>> +  std::map, InputInfo>
>> +  &CachedResults) const;
>> +
>> public:
>>   /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
>>   /// return the grouped values as integers. Numbers which are not
>> 
>> Modified: cfe/trunk/lib/Driver/Driver.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=257808&r1=257807&r2=257808&view=diff
>>  
>> 
>> ==
>> --- cfe/trunk/lib/Driver/Driver.cpp (original)
>> +++ cfe/trunk/lib/Driver/Driver.cpp Thu Jan 14 15:41:21 2016
>> @@ -1632,6 +1632,8 @@ void Driver::BuildJobs(Compilation &C) c
>>   if (A->getOption().matches(options::OPT_arch))
>> ArchNames.insert(A->getValue());
>> 
>> +  // Set of (Action, canonical ToolChain triple) pairs we've built jobs for.
>> +  std::map, InputInfo> CachedResults;
>>   for (Action *A : C.getActions()) {
>> // If we are linking an image for multiple archs then the linker wants
>> // -arch_multiple and -final_output . Unfortunately, 
>> this
>> @@ -1651,7 +1653,7

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

2016-01-15 Thread Richard Smith via cfe-commits
On Fri, Jan 15, 2016 at 4:22 PM, Artem Belevich  wrote:
> tra added inline comments.
>
> 
> Comment at: lib/CodeGen/CodeGenModule.cpp:2334
> @@ -2339,1 +2333,3 @@
> +  D->hasAttr())
>  Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy));
> +  else if (!InitExpr) {
> 
> rsmith wrote:
>> As this is a global variable, it should presumably still be statically 
>> zero-initialized.
> There is no way to initialize __shared__ variables. They are rough equivalent 
> of local variables, only in this case CUDA allocates them per kernel 
> invocation from a shared buffer with no guarantees regarding its contents.
>
> They used to be zero-initialized by compiler, but that was intentionally 
> changed to undef in r245786 / http://reviews.llvm.org/D12241

That doesn't seem right. C++ guarantees zero-initialization for all
globals, prior to performing any other initialization.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

It looks like the problem being fixed by D12241 was probably caused by
the __shared__ variables having the wrong linkage.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r257808 - Don't build jobs for the same Action + ToolChain twice.

2016-01-15 Thread Eric Christopher via cfe-commits
I'm afk at the moment please revert and add a test case if you can?

On Fri, Jan 15, 2016, 5:24 PM Chris Bieneman  wrote:

> +Eric,
>
> If this patch can’t be quickly fixed, can it please be reverted?
>
> -Chris
>
> On Jan 15, 2016, at 4:36 PM, Chris Bieneman via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> This change breaks darwin fat binary support.
>
> > ./bin/clang++ ~/dev/scratch/hello_world.cpp -arch armv7 -arch armv7s
> -isysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/
> fatal error:
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo:
> /var/folders/pb/95pc7qfx2xl9kr9kg0gg_9ccgn/T/hello_world-1b17ac.out and
> /var/folders/pb/95pc7qfx2xl9kr9kg0gg_9ccgn/T/hello_world-1b17ac.out
> have the same architectures (armv7) and can't be in the same fat output file
> clang-3.9: error: lipo command failed with exit code 1 (use -v to see
> invocation)
>
> Can someone more familiar with this code please take a look?
>
> Thanks,
>
> -Chris
>
> On Jan 14, 2016, at 1:41 PM, Justin Lebar via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: jlebar
> Date: Thu Jan 14 15:41:21 2016
> New Revision: 257808
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257808&view=rev
> Log:
> Don't build jobs for the same Action + ToolChain twice.
>
> Summary:
> Right now if the Action graph is a DAG and we encounter an action twice,
> we will run it twice.
>
> This patch is difficult to test as-is, but I have testcases for this as
> used within CUDA compilation.
>
> Reviewers:
>
> Subscribers:
>
> Modified:
>cfe/trunk/include/clang/Driver/Driver.h
>cfe/trunk/lib/Driver/Driver.cpp
>
> Modified: cfe/trunk/include/clang/Driver/Driver.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=257808&r1=257807&r2=257808&view=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/Driver.h (original)
> +++ cfe/trunk/include/clang/Driver/Driver.h Thu Jan 14 15:41:21 2016
> @@ -21,6 +21,7 @@
> #include "llvm/Support/Path.h" // FIXME: Kill when CompilationInfo lands.
>
> #include 
> +#include 
> #include 
> #include 
> #include 
> @@ -381,10 +382,13 @@ public:
>
>   /// BuildJobsForAction - Construct the jobs to perform for the
>   /// action \p A and return an InputInfo for the result of running \p A.
> +  /// Will only construct jobs for a given (Action, ToolChain) pair once.
>   InputInfo BuildJobsForAction(Compilation &C, const Action *A,
>const ToolChain *TC, const char *BoundArch,
>bool AtTopLevel, bool MultipleArchs,
> -   const char *LinkingOutput) const;
> +   const char *LinkingOutput,
> +   std::map std::string>,
> +InputInfo> &CachedResults) const;
>
>   /// Returns the default name for linked images (e.g., "a.out").
>   const char *getDefaultImageName() const;
> @@ -441,6 +445,16 @@ private:
>   /// the driver mode.
>   std::pair getIncludeExcludeOptionFlagMasks() const;
>
> +  /// Helper used in BuildJobsForAction.  Doesn't use the cache when
> building
> +  /// jobs specifically for the given action, but will use the cache when
> +  /// building jobs for the Action's inputs.
> +  InputInfo BuildJobsForActionNoCache(
> +  Compilation &C, const Action *A, const ToolChain *TC,
> +  const char *BoundArch, bool AtTopLevel, bool MultipleArchs,
> +  const char *LinkingOutput,
> +  std::map, InputInfo>
> +  &CachedResults) const;
> +
> public:
>   /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
>   /// return the grouped values as integers. Numbers which are not
>
> Modified: cfe/trunk/lib/Driver/Driver.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=257808&r1=257807&r2=257808&view=diff
>
> ==
> --- cfe/trunk/lib/Driver/Driver.cpp (original)
> +++ cfe/trunk/lib/Driver/Driver.cpp Thu Jan 14 15:41:21 2016
> @@ -1632,6 +1632,8 @@ void Driver::BuildJobs(Compilation &C) c
>   if (A->getOption().matches(options::OPT_arch))
> ArchNames.insert(A->getValue());
>
> +  // Set of (Action, canonical ToolChain triple) pairs we've built jobs
> for.
> +  std::map, InputInfo>
> CachedResults;
>   for (Action *A : C.getActions()) {
> // If we are linking an image for multiple archs then the linker wants
> // -arch_multiple and -final_output . Unfortunately,
> this
> @@ -1651,7 +1653,7 @@ void Driver::BuildJobs(Compilation &C) c
>/*BoundArch*/ nullptr,
>/*AtTopLevel*/ true,
>/*MultipleArchs*/ ArchNames.size() > 1,
> -   /*LinkingOutput*/ LinkingOutput);
> +   

Re: r257808 - Don't build jobs for the same Action + ToolChain twice.

2016-01-15 Thread Justin Lebar via cfe-commits
If you revert this you'll have to revert three other dependent
patches.  I'm looking at a fix, if you're able to sit tight for
fifteen minutes or so.

If not, I can at least contribute a testcase; that much is done.

On Fri, Jan 15, 2016 at 5:33 PM, Eric Christopher  wrote:
> I'm afk at the moment please revert and add a test case if you can?
>
>
> On Fri, Jan 15, 2016, 5:24 PM Chris Bieneman  wrote:
>>
>> +Eric,
>>
>> If this patch can’t be quickly fixed, can it please be reverted?
>>
>> -Chris
>>
>> On Jan 15, 2016, at 4:36 PM, Chris Bieneman via cfe-commits
>>  wrote:
>>
>> This change breaks darwin fat binary support.
>>
>> > ./bin/clang++ ~/dev/scratch/hello_world.cpp -arch armv7 -arch armv7s
>> > -isysroot
>> > /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/
>> fatal error:
>> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo:
>> /var/folders/pb/95pc7qfx2xl9kr9kg0gg_9ccgn/T/hello_world-1b17ac.out and
>> /var/folders/pb/95pc7qfx2xl9kr9kg0gg_9ccgn/T/hello_world-1b17ac.out have
>> the same architectures (armv7) and can't be in the same fat output file
>> clang-3.9: error: lipo command failed with exit code 1 (use -v to see
>> invocation)
>>
>> Can someone more familiar with this code please take a look?
>>
>> Thanks,
>>
>> -Chris
>>
>> On Jan 14, 2016, at 1:41 PM, Justin Lebar via cfe-commits
>>  wrote:
>>
>> Author: jlebar
>> Date: Thu Jan 14 15:41:21 2016
>> New Revision: 257808
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=257808&view=rev
>> Log:
>> Don't build jobs for the same Action + ToolChain twice.
>>
>> Summary:
>> Right now if the Action graph is a DAG and we encounter an action twice,
>> we will run it twice.
>>
>> This patch is difficult to test as-is, but I have testcases for this as
>> used within CUDA compilation.
>>
>> Reviewers:
>>
>> Subscribers:
>>
>> Modified:
>>cfe/trunk/include/clang/Driver/Driver.h
>>cfe/trunk/lib/Driver/Driver.cpp
>>
>> Modified: cfe/trunk/include/clang/Driver/Driver.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=257808&r1=257807&r2=257808&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Driver/Driver.h (original)
>> +++ cfe/trunk/include/clang/Driver/Driver.h Thu Jan 14 15:41:21 2016
>> @@ -21,6 +21,7 @@
>> #include "llvm/Support/Path.h" // FIXME: Kill when CompilationInfo lands.
>>
>> #include 
>> +#include 
>> #include 
>> #include 
>> #include 
>> @@ -381,10 +382,13 @@ public:
>>
>>   /// BuildJobsForAction - Construct the jobs to perform for the
>>   /// action \p A and return an InputInfo for the result of running \p A.
>> +  /// Will only construct jobs for a given (Action, ToolChain) pair once.
>>   InputInfo BuildJobsForAction(Compilation &C, const Action *A,
>>const ToolChain *TC, const char *BoundArch,
>>bool AtTopLevel, bool MultipleArchs,
>> -   const char *LinkingOutput) const;
>> +   const char *LinkingOutput,
>> +   std::map> std::string>,
>> +InputInfo> &CachedResults) const;
>>
>>   /// Returns the default name for linked images (e.g., "a.out").
>>   const char *getDefaultImageName() const;
>> @@ -441,6 +445,16 @@ private:
>>   /// the driver mode.
>>   std::pair getIncludeExcludeOptionFlagMasks() const;
>>
>> +  /// Helper used in BuildJobsForAction.  Doesn't use the cache when
>> building
>> +  /// jobs specifically for the given action, but will use the cache when
>> +  /// building jobs for the Action's inputs.
>> +  InputInfo BuildJobsForActionNoCache(
>> +  Compilation &C, const Action *A, const ToolChain *TC,
>> +  const char *BoundArch, bool AtTopLevel, bool MultipleArchs,
>> +  const char *LinkingOutput,
>> +  std::map, InputInfo>
>> +  &CachedResults) const;
>> +
>> public:
>>   /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
>>   /// return the grouped values as integers. Numbers which are not
>>
>> Modified: cfe/trunk/lib/Driver/Driver.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=257808&r1=257807&r2=257808&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Driver/Driver.cpp (original)
>> +++ cfe/trunk/lib/Driver/Driver.cpp Thu Jan 14 15:41:21 2016
>> @@ -1632,6 +1632,8 @@ void Driver::BuildJobs(Compilation &C) c
>>   if (A->getOption().matches(options::OPT_arch))
>> ArchNames.insert(A->getValue());
>>
>> +  // Set of (Action, canonical ToolChain triple) pairs we've built jobs
>> for.
>> +  std::map, InputInfo>
>> CachedResults;
>>   for (Action *A : C.getActions()) {
>> // If we are linking an image for multiple archs then the linker wants
>> //

[PATCH] D16250: Respect bound archs, even when they don't alter the toolchain.

2016-01-15 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: cfe-commits, beanz, echristo.
Herald added a subscriber: aemerson.

It's possible to BindArch without changing the toolchain at all.  For
example, armv7 and armv7s have exactly the same triple.

Therefore the code in the Driver that checks that we're not creating a
job for the same Action twice needs to consider (Action, Toolchain,
BoundArch) tuples.

http://reviews.llvm.org/D16250

Files:
  include/clang/Driver/Driver.h
  lib/Driver/Driver.cpp
  test/Driver/darwin-multiarch-arm.c

Index: test/Driver/darwin-multiarch-arm.c
===
--- /dev/null
+++ test/Driver/darwin-multiarch-arm.c
@@ -0,0 +1,18 @@
+// Check that we compile correctly with multiple ARM -arch options.
+//
+// RUN: %clang -target arm7-apple-darwin10 -### \
+// RUN:   -arch armv7 -arch armv7s %s 2>&1 | FileCheck %s
+
+// CHECK: "-cc1" "-triple" "thumbv7-apple-ios5.0.0"
+// CHECK-SAME: "-o" "[[CC_OUT1:[^"]*]]"
+// CHECK:ld
+// CHECK-SAME: "-o" "[[LD_OUT1:[^"]*]]"
+// CHECK-SAME: "[[CC_OUT1]]"
+// CHECK:"-cc1" "-triple" "thumbv7s-apple-ios5.0.0"
+// CHECK-SAME: "-o" "[[CC_OUT2:[^"]*]]"
+// CHECK:ld
+// CHECK-SAME: "-o" "[[LD_OUT2:[^"]*]]"
+// CHECK-SAME: "[[CC_OUT2]]"
+// CHECK:lipo
+// CHECK-DAG: "[[LD_OUT1]]"
+// CHECK-DAG: "[[LD_OUT2]]"
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1803,8 +1803,15 @@
 bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
 std::map, InputInfo> &CachedResults)
 const {
-  std::pair ActionTC = {
-  A, TC->getTriple().normalize()};
+  // The bound arch is not necessarily represented in the toolchain's triple --
+  // for example, armv7 and armv7s both map to the same triple -- so we need
+  // both in our map.
+  std::string TriplePlusArch = TC->getTriple().normalize();
+  if (BoundArch) {
+TriplePlusArch += "-";
+TriplePlusArch += BoundArch;
+  }
+  std::pair ActionTC = {A, TriplePlusArch};
   auto CachedResult = CachedResults.find(ActionTC);
   if (CachedResult != CachedResults.end()) {
 return CachedResult->second;
Index: include/clang/Driver/Driver.h
===
--- include/clang/Driver/Driver.h
+++ include/clang/Driver/Driver.h
@@ -380,9 +380,9 @@
const llvm::opt::ArgList &Args, phases::ID 
Phase,
Action *Input) const;
 
-  /// BuildJobsForAction - Construct the jobs to perform for the
-  /// action \p A and return an InputInfo for the result of running \p A.
-  /// Will only construct jobs for a given (Action, ToolChain) pair once.
+  /// BuildJobsForAction - Construct the jobs to perform for the action \p A 
and
+  /// return an InputInfo for the result of running \p A.  Will only construct
+  /// jobs for a given (Action, ToolChain, BoundArch) tuple once.
   InputInfo BuildJobsForAction(Compilation &C, const Action *A,
const ToolChain *TC, const char *BoundArch,
bool AtTopLevel, bool MultipleArchs,


Index: test/Driver/darwin-multiarch-arm.c
===
--- /dev/null
+++ test/Driver/darwin-multiarch-arm.c
@@ -0,0 +1,18 @@
+// Check that we compile correctly with multiple ARM -arch options.
+//
+// RUN: %clang -target arm7-apple-darwin10 -### \
+// RUN:   -arch armv7 -arch armv7s %s 2>&1 | FileCheck %s
+
+// CHECK: "-cc1" "-triple" "thumbv7-apple-ios5.0.0"
+// CHECK-SAME: "-o" "[[CC_OUT1:[^"]*]]"
+// CHECK:ld
+// CHECK-SAME: "-o" "[[LD_OUT1:[^"]*]]"
+// CHECK-SAME: "[[CC_OUT1]]"
+// CHECK:"-cc1" "-triple" "thumbv7s-apple-ios5.0.0"
+// CHECK-SAME: "-o" "[[CC_OUT2:[^"]*]]"
+// CHECK:ld
+// CHECK-SAME: "-o" "[[LD_OUT2:[^"]*]]"
+// CHECK-SAME: "[[CC_OUT2]]"
+// CHECK:lipo
+// CHECK-DAG: "[[LD_OUT1]]"
+// CHECK-DAG: "[[LD_OUT2]]"
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1803,8 +1803,15 @@
 bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
 std::map, InputInfo> &CachedResults)
 const {
-  std::pair ActionTC = {
-  A, TC->getTriple().normalize()};
+  // The bound arch is not necessarily represented in the toolchain's triple --
+  // for example, armv7 and armv7s both map to the same triple -- so we need
+  // both in our map.
+  std::string TriplePlusArch = TC->getTriple().normalize();
+  if (BoundArch) {
+TriplePlusArch += "-";
+TriplePlusArch += BoundArch;
+  }
+  std::pair ActionTC = {A, TriplePlusArch};
   auto CachedResult = CachedResults.find(ActionTC);
   if (CachedResult != CachedResults.end()) {
 return CachedResult->second;
Index: include/clang/Driver/Driver.h
===
---

Re: r257808 - Don't build jobs for the same Action + ToolChain twice.

2016-01-15 Thread Justin Lebar via cfe-commits
http://reviews.llvm.org/D16250

On Fri, Jan 15, 2016 at 5:35 PM, Justin Lebar  wrote:
> If you revert this you'll have to revert three other dependent
> patches.  I'm looking at a fix, if you're able to sit tight for
> fifteen minutes or so.
>
> If not, I can at least contribute a testcase; that much is done.
>
> On Fri, Jan 15, 2016 at 5:33 PM, Eric Christopher  wrote:
>> I'm afk at the moment please revert and add a test case if you can?
>>
>>
>> On Fri, Jan 15, 2016, 5:24 PM Chris Bieneman  wrote:
>>>
>>> +Eric,
>>>
>>> If this patch can’t be quickly fixed, can it please be reverted?
>>>
>>> -Chris
>>>
>>> On Jan 15, 2016, at 4:36 PM, Chris Bieneman via cfe-commits
>>>  wrote:
>>>
>>> This change breaks darwin fat binary support.
>>>
>>> > ./bin/clang++ ~/dev/scratch/hello_world.cpp -arch armv7 -arch armv7s
>>> > -isysroot
>>> > /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/
>>> fatal error:
>>> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo:
>>> /var/folders/pb/95pc7qfx2xl9kr9kg0gg_9ccgn/T/hello_world-1b17ac.out and
>>> /var/folders/pb/95pc7qfx2xl9kr9kg0gg_9ccgn/T/hello_world-1b17ac.out have
>>> the same architectures (armv7) and can't be in the same fat output file
>>> clang-3.9: error: lipo command failed with exit code 1 (use -v to see
>>> invocation)
>>>
>>> Can someone more familiar with this code please take a look?
>>>
>>> Thanks,
>>>
>>> -Chris
>>>
>>> On Jan 14, 2016, at 1:41 PM, Justin Lebar via cfe-commits
>>>  wrote:
>>>
>>> Author: jlebar
>>> Date: Thu Jan 14 15:41:21 2016
>>> New Revision: 257808
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=257808&view=rev
>>> Log:
>>> Don't build jobs for the same Action + ToolChain twice.
>>>
>>> Summary:
>>> Right now if the Action graph is a DAG and we encounter an action twice,
>>> we will run it twice.
>>>
>>> This patch is difficult to test as-is, but I have testcases for this as
>>> used within CUDA compilation.
>>>
>>> Reviewers:
>>>
>>> Subscribers:
>>>
>>> Modified:
>>>cfe/trunk/include/clang/Driver/Driver.h
>>>cfe/trunk/lib/Driver/Driver.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Driver/Driver.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=257808&r1=257807&r2=257808&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Driver/Driver.h (original)
>>> +++ cfe/trunk/include/clang/Driver/Driver.h Thu Jan 14 15:41:21 2016
>>> @@ -21,6 +21,7 @@
>>> #include "llvm/Support/Path.h" // FIXME: Kill when CompilationInfo lands.
>>>
>>> #include 
>>> +#include 
>>> #include 
>>> #include 
>>> #include 
>>> @@ -381,10 +382,13 @@ public:
>>>
>>>   /// BuildJobsForAction - Construct the jobs to perform for the
>>>   /// action \p A and return an InputInfo for the result of running \p A.
>>> +  /// Will only construct jobs for a given (Action, ToolChain) pair once.
>>>   InputInfo BuildJobsForAction(Compilation &C, const Action *A,
>>>const ToolChain *TC, const char *BoundArch,
>>>bool AtTopLevel, bool MultipleArchs,
>>> -   const char *LinkingOutput) const;
>>> +   const char *LinkingOutput,
>>> +   std::map>> std::string>,
>>> +InputInfo> &CachedResults) const;
>>>
>>>   /// Returns the default name for linked images (e.g., "a.out").
>>>   const char *getDefaultImageName() const;
>>> @@ -441,6 +445,16 @@ private:
>>>   /// the driver mode.
>>>   std::pair getIncludeExcludeOptionFlagMasks() const;
>>>
>>> +  /// Helper used in BuildJobsForAction.  Doesn't use the cache when
>>> building
>>> +  /// jobs specifically for the given action, but will use the cache when
>>> +  /// building jobs for the Action's inputs.
>>> +  InputInfo BuildJobsForActionNoCache(
>>> +  Compilation &C, const Action *A, const ToolChain *TC,
>>> +  const char *BoundArch, bool AtTopLevel, bool MultipleArchs,
>>> +  const char *LinkingOutput,
>>> +  std::map, InputInfo>
>>> +  &CachedResults) const;
>>> +
>>> public:
>>>   /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
>>>   /// return the grouped values as integers. Numbers which are not
>>>
>>> Modified: cfe/trunk/lib/Driver/Driver.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=257808&r1=257807&r2=257808&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Driver/Driver.cpp (original)
>>> +++ cfe/trunk/lib/Driver/Driver.cpp Thu Jan 14 15:41:21 2016
>>> @@ -1632,6 +1632,8 @@ void Driver::BuildJobs(Compilation &C) c
>>>   if (A->getOption().matches(options::OPT_arch))
>>> ArchNames.insert(A->getValue());
>>>
>>> +  // Set of (Action, canonical To

Re: [PATCH] D15960: Don't build jobs for the same Action + ToolChain twice.

2016-01-15 Thread Justin Lebar via cfe-commits
jlebar accepted this revision.
jlebar added a reviewer: jlebar.
jlebar added a comment.
This revision is now accepted and ready to land.

Pushed in r257808 with echristo's lg (sorry, didn't have the right metadata in 
the commit).


http://reviews.llvm.org/D15960



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


Re: [PATCH] D16250: Respect bound archs, even when they don't alter the toolchain.

2016-01-15 Thread Eric Christopher via cfe-commits
echristo added a comment.

Ultimately they probably shouldn't map to the same toolchain and we can use
that as a key. Looks OK for now though.


http://reviews.llvm.org/D16250



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


Re: [PATCH] D16250: Respect bound archs, even when they don't alter the toolchain.

2016-01-15 Thread Eric Christopher via cfe-commits
Ultimately they probably shouldn't map to the same toolchain and we can use
that as a key. Looks OK for now though.

On Fri, Jan 15, 2016, 5:48 PM Justin Lebar  wrote:

> jlebar created this revision.
> jlebar added a reviewer: tra.
> jlebar added subscribers: cfe-commits, beanz, echristo.
> Herald added a subscriber: aemerson.
>
> It's possible to BindArch without changing the toolchain at all.  For
> example, armv7 and armv7s have exactly the same triple.
>
> Therefore the code in the Driver that checks that we're not creating a
> job for the same Action twice needs to consider (Action, Toolchain,
> BoundArch) tuples.
>
> http://reviews.llvm.org/D16250
>
> Files:
>   include/clang/Driver/Driver.h
>   lib/Driver/Driver.cpp
>   test/Driver/darwin-multiarch-arm.c
>
> Index: test/Driver/darwin-multiarch-arm.c
> ===
> --- /dev/null
> +++ test/Driver/darwin-multiarch-arm.c
> @@ -0,0 +1,18 @@
> +// Check that we compile correctly with multiple ARM -arch options.
> +//
> +// RUN: %clang -target arm7-apple-darwin10 -### \
> +// RUN:   -arch armv7 -arch armv7s %s 2>&1 | FileCheck %s
> +
> +// CHECK: "-cc1" "-triple" "thumbv7-apple-ios5.0.0"
> +// CHECK-SAME: "-o" "[[CC_OUT1:[^"]*]]"
> +// CHECK:ld
> +// CHECK-SAME: "-o" "[[LD_OUT1:[^"]*]]"
> +// CHECK-SAME: "[[CC_OUT1]]"
> +// CHECK:"-cc1" "-triple" "thumbv7s-apple-ios5.0.0"
> +// CHECK-SAME: "-o" "[[CC_OUT2:[^"]*]]"
> +// CHECK:ld
> +// CHECK-SAME: "-o" "[[LD_OUT2:[^"]*]]"
> +// CHECK-SAME: "[[CC_OUT2]]"
> +// CHECK:lipo
> +// CHECK-DAG: "[[LD_OUT1]]"
> +// CHECK-DAG: "[[LD_OUT2]]"
> Index: lib/Driver/Driver.cpp
> ===
> --- lib/Driver/Driver.cpp
> +++ lib/Driver/Driver.cpp
> @@ -1803,8 +1803,15 @@
>  bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
>  std::map, InputInfo>
> &CachedResults)
>  const {
> -  std::pair ActionTC = {
> -  A, TC->getTriple().normalize()};
> +  // The bound arch is not necessarily represented in the toolchain's
> triple --
> +  // for example, armv7 and armv7s both map to the same triple -- so we
> need
> +  // both in our map.
> +  std::string TriplePlusArch = TC->getTriple().normalize();
> +  if (BoundArch) {
> +TriplePlusArch += "-";
> +TriplePlusArch += BoundArch;
> +  }
> +  std::pair ActionTC = {A, TriplePlusArch};
>auto CachedResult = CachedResults.find(ActionTC);
>if (CachedResult != CachedResults.end()) {
>  return CachedResult->second;
> Index: include/clang/Driver/Driver.h
> ===
> --- include/clang/Driver/Driver.h
> +++ include/clang/Driver/Driver.h
> @@ -380,9 +380,9 @@
> const llvm::opt::ArgList &Args, phases::ID
> Phase,
> Action *Input) const;
>
> -  /// BuildJobsForAction - Construct the jobs to perform for the
> -  /// action \p A and return an InputInfo for the result of running \p A.
> -  /// Will only construct jobs for a given (Action, ToolChain) pair once.
> +  /// BuildJobsForAction - Construct the jobs to perform for the action
> \p A and
> +  /// return an InputInfo for the result of running \p A.  Will only
> construct
> +  /// jobs for a given (Action, ToolChain, BoundArch) tuple once.
>InputInfo BuildJobsForAction(Compilation &C, const Action *A,
> const ToolChain *TC, const char *BoundArch,
> bool AtTopLevel, bool MultipleArchs,
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D8822: Proposed fix for PR23076 (conditional branch debug line info)

2016-01-15 Thread David Blaikie via cfe-commits
dblaikie added a subscriber: dblaikie.
dblaikie added a comment.

Apologies for the massively delayed review. I think this is probably good,
but here are some test cases to discuss (& I've cc'd Paul Robinson and
Adrian Prantl, both who work on debug info in LLVM as well, to get their
thoughts)

Given this code:

  1. int main() {
  2. if (
  3. tr()
  4. &&
  5. tr()
  6. )
  7. func(); 8.
  8. if (
1. fa()
2. &&
3. tr()
4. )
5. func();
6. }

G++-4.8:
3, 4, 5, 4, 2, 7
10, 11, 9, 15

Clang before the change:
3, 4, 5, 3, 7
10, 11, 15

Clang after the change:
3, 5, 7
10, 15

The lack of stepping between the evaluation of the LHS and the RHS to the
&& expression seems like a loss, but not a great one. How's everyone else
feel about it? (I imagine we can, with some work, preserve that step while
avoiding the weird backwards step to the start of the expression before
continuing)


http://reviews.llvm.org/D8822



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


Fwd: [PATCH] Proposed fix for PR23076 (conditional branch debug line info)

2016-01-15 Thread David Blaikie via cfe-commits
Forward to the 'new' mailing list.
-- Forwarded message --
From: David Blaikie 
Date: Fri, Jan 15, 2016 at 6:08 PM
Subject: Re: [PATCH] Proposed fix for PR23076 (conditional branch debug
line info)
To: reviews+d8822+public+818b95c17195c...@reviews.llvm.org, "Robinson,
Paul" , Adrian Prantl 
Cc: "Pieb, Wolfgang" , llvm cfe <
cfe-comm...@cs.uiuc.edu>


Apologies for the massively delayed review. I think this is probably good,
but here are some test cases to discuss (& I've cc'd Paul Robinson and
Adrian Prantl, both who work on debug info in LLVM as well, to get their
thoughts)

Given this code:

 1. int main() {
 2.   if (
 3.   tr()
 4.   &&
 5.   tr()
 6.   )
 7. func();
 8.
 9.   if (
10.   fa()
11.   &&
12.   tr()
13.   )
14. func();
15. }

G++-4.8:
3, 4, 5, 4, 2, 7
10, 11, 9, 15

Clang before the change:
3, 4, 5, 3, 7
10, 11, 15

Clang after the change:
3, 5, 7
10, 15

The lack of stepping between the evaluation of the LHS and the RHS to the
&& expression seems like a loss, but not a great one. How's everyone else
feel about it? (I imagine we can, with some work, preserve that step while
avoiding the weird backwards step to the start of the expression before
continuing)

On Fri, May 1, 2015 at 1:00 PM, Wolfgang Pieb <
wolfgang_p...@playstation.sony.com> wrote:

> Hi David, did you have a chance to look at the new patch? There are a
> couple of new tests piggy-backing on the existing test case.
>
>
> http://reviews.llvm.org/D8822
>
> EMAIL PREFERENCES
>   http://reviews.llvm.org/settings/panel/emailpreferences/
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16248: [Clang-tidy] rename misc-inefficient-algorithm to performance-inefficient-algorithm

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

Makes sense. One comment re: documentation.



Comment at: docs/clang-tidy/checks/performance-inefficient-algorithm.rst:1
@@ -1,2 +1,2 @@
-.. title:: clang-tidy - misc-inefficient-algorithm
+.. title:: clang-tidy - performance-inefficient-algorithm
 

I'd leave the old documentation file with a redirect to the new one. See 
examples in the cert module. But instead of calling the old check name 'alias', 
mention that it was renamed. We also don't need the old file to appear in the 
index, so it should be marked `:orphan:` and the add_new_check.py script should 
be updated to not add orphaned files to the list.


Repository:
  rL LLVM

http://reviews.llvm.org/D16248



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


Re: [PATCH] D16248: [Clang-tidy] rename misc-inefficient-algorithm to performance-inefficient-algorithm

2016-01-15 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.


Comment at: docs/clang-tidy/checks/performance-inefficient-algorithm.rst:1
@@ -1,2 +1,2 @@
-.. title:: clang-tidy - misc-inefficient-algorithm
+.. title:: clang-tidy - performance-inefficient-algorithm
 

alexfh wrote:
> I'd leave the old documentation file with a redirect to the new one. See 
> examples in the cert module. But instead of calling the old check name 
> 'alias', mention that it was renamed. We also don't need the old file to 
> appear in the index, so it should be marked `:orphan:` and the 
> add_new_check.py script should be updated to not add orphaned files to the 
> list.
I searched for orphan in documentation and didn't find any. Looks like 
documentation was always renamed in past without leaving traces to old names.

I don't know documentation specific well enough, so will be good idea if it 
will be changed by more knowledgeable person then me.


Repository:
  rL LLVM

http://reviews.llvm.org/D16248



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


Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

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


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4994
@@ +4993,3 @@
+  EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;",
+  typedefDecl(hasUnderlyingType(asString("int");
+  EXPECT_TRUE(matches("typedef const int T;",

sbenza wrote:
> aaron.ballman wrote:
> > LegalizeAdulthood wrote:
> > > aaron.ballman wrote:
> > > > LegalizeAdulthood wrote:
> > > > > aaron.ballman wrote:
> > > > > > Thank you for those examples! Given the following code:
> > > > > > ```
> > > > > > typedef int foo;
> > > > > > typedef foo bar;
> > > > > > 
> > > > > > bar i;
> > > > > > ```
> > > > > > clang-query> match varDecl(hasType(asString("int")))
> > > > > > 0 matches.
> > > > > > clang-query> match varDecl(hasType(asString("foo")))
> > > > > > 0 matches.
> > > > > > clang-query> match varDecl(hasType(asString("bar")))
> > > > > > 
> > > > > > Match #1:
> > > > > > 
> > > > > > E:\Desktop\t.cpp:4:1: note: "root" binds here
> > > > > > bar i;
> > > > > > ^
> > > > > > 1 match.
> > > > > > 
> > > > > > So hasType() looks at what the immediate type is for the 
> > > > > > declaration (which we document, yay us!). Based on that, I don't 
> > > > > > think hasUnderlyingType() makes sense -- you should modify 
> > > > > > hasType() to work on a TypedefNameDecl (not just a TypedefDecl!) so 
> > > > > > that it looks at the immediate type of the type definition. I would 
> > > > > > expect your tests then to result in:
> > > > > > ```
> > > > > > 1: typedef void (fn)(void);
> > > > > > 2: typedef fn foo;
> > > > > > 3: typedef int bar;
> > > > > > 4: typedef int (f);
> > > > > > 5: typedef int (fn2)(int);
> > > > > > clang-query> match typedefDecl(hasType(asString("int")))
> > > > > > 
> > > > > > Match #1:
> > > > > > 
> > > > > > /tmp/a.cpp:3:1: note: "root" binds here
> > > > > > typedef int bar;
> > > > > > ^~~
> > > > > > 
> > > > > > Match #2:
> > > > > > 
> > > > > > /tmp/a.cpp:4:1: note: "root" binds here
> > > > > > typedef int (f);
> > > > > > ^~~
> > > > > > 2 matches.
> > > > > > clang-query> match typedefDecl(hasType(typedefType()))
> > > > > > 
> > > > > > Match #1:
> > > > > > 
> > > > > > /tmp/a.cpp:2:1: note: "root" binds here
> > > > > > typedef fn foo;
> > > > > > ^~
> > > > > > 1 match.
> > > > > > clang-query> match typedefDecl(hasType(parenType()))
> > > > > > 
> > > > > > Match #1:
> > > > > > 
> > > > > > /tmp/a.cpp:1:1: note: "root" binds here
> > > > > > typedef void (fn)(void);
> > > > > > ^~~
> > > > > > 
> > > > > > Match #2:
> > > > > > 
> > > > > > /tmp/a.cpp:4:1: note: "root" binds here
> > > > > > typedef int (f);
> > > > > > ^~~
> > > > > > 
> > > > > > Match #3:
> > > > > > 
> > > > > > /tmp/a.cpp:5:1: note: "root" binds here
> > > > > > typedef int (fn2)(int);
> > > > > > ^~
> > > > > > 3 matches.
> > > > > > clang-query> match 
> > > > > > typedefDecl(hasType(parenType(innerType(functionType()
> > > > > > 
> > > > > > Match #1:
> > > > > > 
> > > > > > /tmp/a.cpp:1:1: note: "root" binds here
> > > > > > typedef void (fn)(void);
> > > > > > ^~~
> > > > > > 
> > > > > > Match #2:
> > > > > > 
> > > > > > /tmp/a.cpp:5:1: note: "root" binds here
> > > > > > typedef int (fn2)(int);
> > > > > > ^~
> > > > > > 2 matches.
> > > > > > ```
> > > > > > The end results are the same, so this is just changing the way the 
> > > > > > information is surfaced to the user that is logically consistent. 
> > > > > > ValueDecls have an immediate type, and so do TypedefDecls. By using 
> > > > > > TypedefNameDecl instead of TypedefDecl, this also covers the case 
> > > > > > where hasType() is useful for an alias-declaration. (We don't 
> > > > > > expose the matcher for that yet, but it seems quite reasonable to 
> > > > > > add in the future, and it would be nice for hasType to 
> > > > > > automatically work with that.)
> > > > > > 
> > > > > > You can implement this with a helper function to handle abstracting 
> > > > > > away the call to getType() vs getUnderlyingType(), then updating 
> > > > > > the hasType() matchers to use it. Something like:
> > > > > > ```
> > > > > > template 
> > > > > > struct UnderlyingTypeGetter {
> > > > > >   static QualType get(const Ty &Node) {
> > > > > > return Node.getType();
> > > > > >   }
> > > > > > };
> > > > > > 
> > > > > > template <>
> > > > > > QualType UnderlyingTypeGetter::get(const 
> > > > > > TypedefNameDecl &Node) {
> > > > > >   return Node.getUnderlyingType();
> > > > > > }
> > > > > > ```
> > > > > > (Somewhere in ASTMatchersInternal.h most likely.)
> > > > > > 
> > > > > When I try to extend `hasType` to work on `TypedefDecl`, I get this 
> > > > > error:
> > > > > 
> > > > > ```
> > > > > error: static assertion failed: right polymorphic conversion
> > > > >  static_assert(TypeListContainsSuperOf::value,
> > >

Re: [PATCH] D16248: [Clang-tidy] rename misc-inefficient-algorithm to performance-inefficient-algorithm

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

Makes sense. One comment re: documentation.



Comment at: docs/clang-tidy/checks/performance-inefficient-algorithm.rst:1
@@ -1,2 +1,2 @@
-.. title:: clang-tidy - misc-inefficient-algorithm
+.. title:: clang-tidy - performance-inefficient-algorithm
 

Eugene.Zelenko wrote:
> alexfh wrote:
> > I'd leave the old documentation file with a redirect to the new one. See 
> > examples in the cert module. But instead of calling the old check name 
> > 'alias', mention that it was renamed. We also don't need the old file to 
> > appear in the index, so it should be marked `:orphan:` and the 
> > add_new_check.py script should be updated to not add orphaned files to the 
> > list.
> I searched for orphan in documentation and didn't find any. Looks like 
> documentation was always renamed in past without leaving traces to old names.
> 
> I don't know documentation specific well enough, so will be good idea if it 
> will be changed by more knowledgeable person then me.
An example of a doc file redirecting to the new location is 
docs/clang-tidy.rst. Specifically, you need to put `:orphan:` as the first line 
and then add redirection directive.


Repository:
  rL LLVM

http://reviews.llvm.org/D16248



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


r257982 - [libclang] Add missing CINDEX_LINKAGE from some new APIs in Index.h.

2016-01-15 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Jan 15 21:01:20 2016
New Revision: 257982

URL: http://llvm.org/viewvc/llvm-project?rev=257982&view=rev
Log:
[libclang] Add missing CINDEX_LINKAGE from some new APIs in Index.h.

Modified:
cfe/trunk/include/clang-c/Index.h

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=257982&r1=257981&r2=257982&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Fri Jan 15 21:01:20 2016
@@ -5132,19 +5132,19 @@ CINDEX_LINKAGE CXEvalResult clang_Cursor
 /**
  * \brief Returns the kind of the evaluated result.
  */
-CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
+CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
 
 /**
  * \brief Returns the evaluation result as integer if the
  * kind is Int.
  */
-int clang_EvalResult_getAsInt(CXEvalResult E);
+CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
 
 /**
  * \brief Returns the evaluation result as double if the
  * kind is double.
  */
-double clang_EvalResult_getAsDouble(CXEvalResult E);
+CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
 
 /**
  * \brief Returns the evaluation result as a constant string if the
@@ -5152,12 +5152,12 @@ double clang_EvalResult_getAsDouble(CXEv
  * instead call clang_EvalResult_dispose on the CXEvalResult returned
  * by clang_Cursor_Evaluate.
  */
-const char* clang_EvalResult_getAsStr(CXEvalResult E);
+CINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E);
 
 /**
  * \brief Disposes the created Eval memory.
  */
-void clang_EvalResult_dispose(CXEvalResult E);
+CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
 /**
  * @}
  */


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


Re: [PATCH] D16250: Respect bound archs, even when they don't alter the toolchain.

2016-01-15 Thread Artem Belevich via cfe-commits
tra added a comment.

Looks OK to me. 
Perhaps BoundArch w/o toolchain is sufficient for the key as toolchain would be 
derived from it.


http://reviews.llvm.org/D16250



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


Re: [PATCH] D16250: Respect bound archs, even when they don't alter the toolchain.

2016-01-15 Thread Justin Lebar via cfe-commits
jlebar added a comment.

In http://reviews.llvm.org/D16250#328552, @tra wrote:

> Looks OK to me. 
>  Perhaps BoundArch w/o toolchain is sufficient for the key as toolchain would 
> be derived from it.


Yeah, it might work, I wasn't convinced it was sound.  The bound TC is derived 
from the original TC plus the arch -- that is, the arch isn't the only piece of 
info that goes into it.  Dunno, once bitten twice shy.

Thank you for the reviews, and thanks again for your patience, Chris.


http://reviews.llvm.org/D16250



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


r257983 - Respect bound archs, even when they don't alter the toolchain.

2016-01-15 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Fri Jan 15 21:30:08 2016
New Revision: 257983

URL: http://llvm.org/viewvc/llvm-project?rev=257983&view=rev
Log:
Respect bound archs, even when they don't alter the toolchain.

Summary:
It's possible to BindArch without changing the toolchain at all.  For
example, armv7 and armv7s have exactly the same toolchain triple.

Therefore the code in the Driver that checks that we're not creating a
job for the same Action twice needs to consider (Action, Toolchain,
BoundArch) tuples.

Reviewers: tra

Subscribers: aemerson, echristo, beanz, cfe-commits

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

Added:
cfe/trunk/test/Driver/darwin-multiarch-arm.c
Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=257983&r1=257982&r2=257983&view=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Fri Jan 15 21:30:08 2016
@@ -380,9 +380,9 @@ public:
const llvm::opt::ArgList &Args, phases::ID 
Phase,
Action *Input) const;
 
-  /// BuildJobsForAction - Construct the jobs to perform for the
-  /// action \p A and return an InputInfo for the result of running \p A.
-  /// Will only construct jobs for a given (Action, ToolChain) pair once.
+  /// BuildJobsForAction - Construct the jobs to perform for the action \p A 
and
+  /// return an InputInfo for the result of running \p A.  Will only construct
+  /// jobs for a given (Action, ToolChain, BoundArch) tuple once.
   InputInfo BuildJobsForAction(Compilation &C, const Action *A,
const ToolChain *TC, const char *BoundArch,
bool AtTopLevel, bool MultipleArchs,

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=257983&r1=257982&r2=257983&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Jan 15 21:30:08 2016
@@ -1803,8 +1803,15 @@ InputInfo Driver::BuildJobsForAction(
 bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
 std::map, InputInfo> &CachedResults)
 const {
-  std::pair ActionTC = {
-  A, TC->getTriple().normalize()};
+  // The bound arch is not necessarily represented in the toolchain's triple --
+  // for example, armv7 and armv7s both map to the same triple -- so we need
+  // both in our map.
+  std::string TriplePlusArch = TC->getTriple().normalize();
+  if (BoundArch) {
+TriplePlusArch += "-";
+TriplePlusArch += BoundArch;
+  }
+  std::pair ActionTC = {A, TriplePlusArch};
   auto CachedResult = CachedResults.find(ActionTC);
   if (CachedResult != CachedResults.end()) {
 return CachedResult->second;

Added: cfe/trunk/test/Driver/darwin-multiarch-arm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-multiarch-arm.c?rev=257983&view=auto
==
--- cfe/trunk/test/Driver/darwin-multiarch-arm.c (added)
+++ cfe/trunk/test/Driver/darwin-multiarch-arm.c Fri Jan 15 21:30:08 2016
@@ -0,0 +1,18 @@
+// Check that we compile correctly with multiple ARM -arch options.
+//
+// RUN: %clang -target arm7-apple-darwin10 -### \
+// RUN:   -arch armv7 -arch armv7s %s 2>&1 | FileCheck %s
+
+// CHECK: "-cc1" "-triple" "thumbv7-apple-ios5.0.0"
+// CHECK-SAME: "-o" "[[CC_OUT1:[^"]*]]"
+// CHECK:ld
+// CHECK-SAME: "-o" "[[LD_OUT1:[^"]*]]"
+// CHECK-SAME: "[[CC_OUT1]]"
+// CHECK:"-cc1" "-triple" "thumbv7s-apple-ios5.0.0"
+// CHECK-SAME: "-o" "[[CC_OUT2:[^"]*]]"
+// CHECK:ld
+// CHECK-SAME: "-o" "[[LD_OUT2:[^"]*]]"
+// CHECK-SAME: "[[CC_OUT2]]"
+// CHECK:lipo
+// CHECK-DAG: "[[LD_OUT1]]"
+// CHECK-DAG: "[[LD_OUT2]]"


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


Re: [PATCH] D16250: Respect bound archs, even when they don't alter the toolchain.

2016-01-15 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257983: Respect bound archs, even when they don't alter the 
toolchain. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D16250?vs=45061&id=45064#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16250

Files:
  cfe/trunk/include/clang/Driver/Driver.h
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/darwin-multiarch-arm.c

Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1803,8 +1803,15 @@
 bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
 std::map, InputInfo> &CachedResults)
 const {
-  std::pair ActionTC = {
-  A, TC->getTriple().normalize()};
+  // The bound arch is not necessarily represented in the toolchain's triple --
+  // for example, armv7 and armv7s both map to the same triple -- so we need
+  // both in our map.
+  std::string TriplePlusArch = TC->getTriple().normalize();
+  if (BoundArch) {
+TriplePlusArch += "-";
+TriplePlusArch += BoundArch;
+  }
+  std::pair ActionTC = {A, TriplePlusArch};
   auto CachedResult = CachedResults.find(ActionTC);
   if (CachedResult != CachedResults.end()) {
 return CachedResult->second;
Index: cfe/trunk/include/clang/Driver/Driver.h
===
--- cfe/trunk/include/clang/Driver/Driver.h
+++ cfe/trunk/include/clang/Driver/Driver.h
@@ -380,9 +380,9 @@
const llvm::opt::ArgList &Args, phases::ID 
Phase,
Action *Input) const;
 
-  /// BuildJobsForAction - Construct the jobs to perform for the
-  /// action \p A and return an InputInfo for the result of running \p A.
-  /// Will only construct jobs for a given (Action, ToolChain) pair once.
+  /// BuildJobsForAction - Construct the jobs to perform for the action \p A 
and
+  /// return an InputInfo for the result of running \p A.  Will only construct
+  /// jobs for a given (Action, ToolChain, BoundArch) tuple once.
   InputInfo BuildJobsForAction(Compilation &C, const Action *A,
const ToolChain *TC, const char *BoundArch,
bool AtTopLevel, bool MultipleArchs,
Index: cfe/trunk/test/Driver/darwin-multiarch-arm.c
===
--- cfe/trunk/test/Driver/darwin-multiarch-arm.c
+++ cfe/trunk/test/Driver/darwin-multiarch-arm.c
@@ -0,0 +1,18 @@
+// Check that we compile correctly with multiple ARM -arch options.
+//
+// RUN: %clang -target arm7-apple-darwin10 -### \
+// RUN:   -arch armv7 -arch armv7s %s 2>&1 | FileCheck %s
+
+// CHECK: "-cc1" "-triple" "thumbv7-apple-ios5.0.0"
+// CHECK-SAME: "-o" "[[CC_OUT1:[^"]*]]"
+// CHECK:ld
+// CHECK-SAME: "-o" "[[LD_OUT1:[^"]*]]"
+// CHECK-SAME: "[[CC_OUT1]]"
+// CHECK:"-cc1" "-triple" "thumbv7s-apple-ios5.0.0"
+// CHECK-SAME: "-o" "[[CC_OUT2:[^"]*]]"
+// CHECK:ld
+// CHECK-SAME: "-o" "[[LD_OUT2:[^"]*]]"
+// CHECK-SAME: "[[CC_OUT2]]"
+// CHECK:lipo
+// CHECK-DAG: "[[LD_OUT1]]"
+// CHECK-DAG: "[[LD_OUT2]]"


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1803,8 +1803,15 @@
 bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
 std::map, InputInfo> &CachedResults)
 const {
-  std::pair ActionTC = {
-  A, TC->getTriple().normalize()};
+  // The bound arch is not necessarily represented in the toolchain's triple --
+  // for example, armv7 and armv7s both map to the same triple -- so we need
+  // both in our map.
+  std::string TriplePlusArch = TC->getTriple().normalize();
+  if (BoundArch) {
+TriplePlusArch += "-";
+TriplePlusArch += BoundArch;
+  }
+  std::pair ActionTC = {A, TriplePlusArch};
   auto CachedResult = CachedResults.find(ActionTC);
   if (CachedResult != CachedResults.end()) {
 return CachedResult->second;
Index: cfe/trunk/include/clang/Driver/Driver.h
===
--- cfe/trunk/include/clang/Driver/Driver.h
+++ cfe/trunk/include/clang/Driver/Driver.h
@@ -380,9 +380,9 @@
const llvm::opt::ArgList &Args, phases::ID Phase,
Action *Input) const;
 
-  /// BuildJobsForAction - Construct the jobs to perform for the
-  /// action \p A and return an InputInfo for the result of running \p A.
-  /// Will only construct jobs for a given (Action, ToolChain) pair once.
+  /// BuildJobsForAction - Construct the jobs to perform for the action \p A and
+  /// return an InputInfo for the result of running \p A.  Will only construct
+  /// jobs for a given (Action, ToolChain, BoundArch) tuple once.
   InputInfo BuildJobsForAction(Compilation &C, const Action *A,

r257984 - [Cygwin] Use -femulated-tls by default since r257718 introduced the new pass.

2016-01-15 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Jan 15 21:44:52 2016
New Revision: 257984

URL: http://llvm.org/viewvc/llvm-project?rev=257984&view=rev
Log:
[Cygwin] Use -femulated-tls by default since r257718 introduced the new pass.

FIXME: Add more targets to use emutls into clang/test/Driver/emulated-tls.cpp.
FIXME: Add cygwin tests into llvm/test/CodeGen/X86. Working in progress.

Added:
cfe/trunk/test/Driver/emulated-tls.cpp
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=257984&r1=257983&r2=257984&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri Jan 15 21:44:52 2016
@@ -74,6 +74,8 @@ Windows Support
 
 Clang's support for building native Windows programs ...
 
+TLS is enabled for Cygwin defaults to -femulated-tls.
+
 
 C Language Changes in Clang
 ---

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=257984&r1=257983&r2=257984&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jan 15 21:44:52 2016
@@ -4597,7 +4597,7 @@ void Clang::ConstructJob(Compilation &C,
   Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
   // Emulated TLS is enabled by default on Android, and can be enabled manually
   // with -femulated-tls.
-  bool EmulatedTLSDefault = Triple.isAndroid();
+  bool EmulatedTLSDefault = Triple.isAndroid() || 
Triple.isWindowsCygwinEnvironment();
   if (Args.hasFlag(options::OPT_femulated_tls, options::OPT_fno_emulated_tls,
EmulatedTLSDefault))
 CmdArgs.push_back("-femulated-tls");

Added: cfe/trunk/test/Driver/emulated-tls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/emulated-tls.cpp?rev=257984&view=auto
==
--- cfe/trunk/test/Driver/emulated-tls.cpp (added)
+++ cfe/trunk/test/Driver/emulated-tls.cpp Fri Jan 15 21:44:52 2016
@@ -0,0 +1,5 @@
+// Cygwin uses emutls. Clang should pass -femulated-tls to cc1 and cc1 should 
pass EmulatedTLS to LLVM CodeGen.
+// FIXME: Add more targets here to use emutls.
+// RUN: %clang -### -std=c++11 -target i686-pc-cygwin %s 2>&1 | FileCheck %s
+
+// CHECK: "-cc1" {{.*}}"-femulated-tls"


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


r257986 - Fix buildbot bustage in Driver/darwin-multiarch-arm.c caused by r257983.

2016-01-15 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Fri Jan 15 22:50:13 2016
New Revision: 257986

URL: http://llvm.org/viewvc/llvm-project?rev=257986&view=rev
Log:
Fix buildbot bustage in Driver/darwin-multiarch-arm.c caused by r257983.

The test was too loose; "ld" was matching directories named "build" in
the path.

Modified:
cfe/trunk/test/Driver/darwin-multiarch-arm.c

Modified: cfe/trunk/test/Driver/darwin-multiarch-arm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-multiarch-arm.c?rev=257986&r1=257985&r2=257986&view=diff
==
--- cfe/trunk/test/Driver/darwin-multiarch-arm.c (original)
+++ cfe/trunk/test/Driver/darwin-multiarch-arm.c Fri Jan 15 22:50:13 2016
@@ -5,14 +5,10 @@
 
 // CHECK: "-cc1" "-triple" "thumbv7-apple-ios5.0.0"
 // CHECK-SAME: "-o" "[[CC_OUT1:[^"]*]]"
-// CHECK:ld
-// CHECK-SAME: "-o" "[[LD_OUT1:[^"]*]]"
-// CHECK-SAME: "[[CC_OUT1]]"
+// CHECK:ld" {{.*}} "-o" "[[LD_OUT1:[^"]*]]" {{.*}} "[[CC_OUT1]]"
 // CHECK:"-cc1" "-triple" "thumbv7s-apple-ios5.0.0"
 // CHECK-SAME: "-o" "[[CC_OUT2:[^"]*]]"
-// CHECK:ld
-// CHECK-SAME: "-o" "[[LD_OUT2:[^"]*]]"
-// CHECK-SAME: "[[CC_OUT2]]"
-// CHECK:lipo
+// CHECK:ld" {{.*}} "-o" "[[LD_OUT2:[^"]*]]" {{.*}} "[[CC_OUT2]]"
+// CHECK:lipo"
 // CHECK-DAG: "[[LD_OUT1]]"
 // CHECK-DAG: "[[LD_OUT2]]"


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


[PATCH] D16259: Add clang-tidy readability-redundant-return check

2016-01-15 Thread Richard via cfe-commits
LegalizeAdulthood created this revision.
LegalizeAdulthood added a reviewer: alexfh.
LegalizeAdulthood added a subscriber: cfe-commits.

This check looks for `return` statements at the end of a function returning 
`void`:

```
void f()
{
  return;
}
```

becomes

```
void f()
{
}
```


http://reviews.llvm.org/D16259

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantReturnCheck.cpp
  clang-tidy/readability/RedundantReturnCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-redundant-return.rst
  test/clang-tidy/readability-redundant-return.cpp

Index: test/clang-tidy/readability-redundant-return.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-return.cpp
@@ -0,0 +1,41 @@
+// RUN: %check_clang_tidy %s readability-redundant-return %t
+
+void g(int i);
+void j();
+
+void f()
+{
+  return;
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: redundant return statement at the end of void function [readability-redundant-return]
+// CHECK-FIXES: {{^}}void f(){{$}}
+// CHECK-FIXES-NEXT: {{^{$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
+
+void g()
+{
+  f();
+  return;
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: redundant return statement
+// CHECK-FIXES: {{^  }}f();{{$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
+
+void g(int i)
+{
+  if (i < 0) {
+return;
+  }
+  if (i < 10) {
+f();
+  }
+}
+
+int h()
+{
+  return 1;
+}
+
+void j()
+{
+}
Index: docs/clang-tidy/checks/readability-redundant-return.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-redundant-return.rst
@@ -0,0 +1,7 @@
+.. title:: clang-tidy - readability-redundant-return
+
+readability-redundant-return
+
+
+This check looks for procedures (functions returning no value) with return
+statements at the end of the function.  Such return statements are redundant.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -76,6 +76,7 @@
readability-implicit-bool-cast
readability-inconsistent-declaration-parameter-name
readability-named-parameter
+   readability-redundant-return
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-simplify-boolean-expr
Index: clang-tidy/readability/RedundantReturnCheck.h
===
--- /dev/null
+++ clang-tidy/readability/RedundantReturnCheck.h
@@ -0,0 +1,36 @@
+//===--- RedundantReturnCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_RETURN_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_RETURN_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// Eliminates redundant `return` statements at the end of a function that
+/// returns `void`.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-return.html
+class RedundantReturnCheck : public ClangTidyCheck {
+public:
+  RedundantReturnCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_RETURN_H
Index: clang-tidy/readability/RedundantReturnCheck.cpp
===
--- /dev/null
+++ clang-tidy/readability/RedundantReturnCheck.cpp
@@ -0,0 +1,60 @@
+//===--- RedundantReturnCheck.cpp - clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "RedundantReturnCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+void RedundantReturnCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  functionDecl(isDefinition(), returns(asString("void")),
+   has(compoundStmt(hasAny

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

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


Comment at: clang-tidy/readability/RedundantReturnCheck.cpp:46-49
@@ +45,6 @@
+  auto ReturnRange = CharSourceRange::getCharRange(
+  Start, Lexer::findLocationAfterToken(
+ Return->getLocEnd(), tok::semi, *Result.SourceManager,
+ Result.Context->getLangOpts(),
+ /*SkipTrailingWhitespaceAndNewLine=*/true));
+

This was a great trick I stole from the unused namespace alias check.  I could 
really use some method for trimming off preceding whitespace for a statement as 
well.  Right now, the `return` statement gets removed, but when it appears on a 
line by itself, it's indentation whitespace is left in place and I'd like to be 
able to remove that as well.  I tried a couple things, but for this first pass 
simply decided to let the test cases allow leading whitespace before the 
closing brace of the function.  One can always use artistic style or 
`clang-format` to reformat the results anyway, so it's not that big a deal I 
suppose.


http://reviews.llvm.org/D16259



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


  1   2   >