Re: [PATCH] D17986: [ASTMatchers] New matcher hasReturnValue added

2016-03-22 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 51259.
baloghadamsoftware added a comment.

LibASTMatchersReference.html regenerated


http://reviews.llvm.org/D17986

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

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -5488,5 +5488,11 @@
   EXPECT_TRUE(notMatches("int i = 0;", expr(nullPointerConstant(;
 }
 
+TEST(StatementMatcher, HasReturnValue) {
+  StatementMatcher RetVal = returnStmt(hasReturnValue(binaryOperator()));
+  EXPECT_TRUE(matches("int F() { int a, b; return a + b; }", RetVal));
+  EXPECT_FALSE(matches("int F() { int a; return a; }", RetVal));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -243,6 +243,7 @@
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasReturnValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);
   REGISTER_MATCHER(hasSingleDecl);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5008,6 +5008,22 @@
   return false;
 }
 
+/// \brief Matches the return value expression of a return statement
+///
+/// Given
+/// \code
+///   return a + b;
+/// \endcode
+/// hasReturnValue(binaryOperator())
+///   matches 'return a + b'
+/// with binaryOperator()
+///   matching 'a + b'
+AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher, 
+  InnerMatcher) {
+  return InnerMatcher.matches(*Node.getRetValue(), Finder, Builder);
+}
+
+
 /// \brief Matches CUDA kernel call expression.
 ///
 /// Example matches,
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -4854,6 +4854,18 @@
 
 
 
+MatcherReturnStmt>hasReturnValueMatcherExpr> 
InnerMatcher
+Matches the return 
value expression of a return statement
+
+Given
+  return a + b;
+hasReturnValue(binaryOperator())
+  matches 'return a + b'
+with binaryOperator()
+  matching 'a + b'
+
+
+
 MatcherStmtExpr>hasAnySubstatementMatcherStmt> 
InnerMatcher
 Matches compound 
statements where at least one substatement matches
 a given matcher. Also matches StmtExprs that have CompoundStmt as children.


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -5488,5 +5488,11 @@
   EXPECT_TRUE(notMatches("int i = 0;", expr(nullPointerConstant(;
 }
 
+TEST(StatementMatcher, HasReturnValue) {
+  StatementMatcher RetVal = returnStmt(hasReturnValue(binaryOperator()));
+  EXPECT_TRUE(matches("int F() { int a, b; return a + b; }", RetVal));
+  EXPECT_FALSE(matches("int F() { int a; return a; }", RetVal));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -243,6 +243,7 @@
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasReturnValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);
   REGISTER_MATCHER(hasSingleDecl);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5008,6 +5008,22 @@
   return false;
 }
 
+/// \brief Matches the return value expression of a return statement
+///
+/// Given
+/// \code
+///   return a + b;
+/// \endcode
+/// hasReturnValue(binaryOperator())
+///   matches 'return a + b'
+/// with binaryOperator()
+///   matching 'a + b'
+AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher, 
+  InnerMatcher) {
+  return InnerMatcher.matches(*Node.getRetValue(), Finder, Builder);
+}
+
+
 /// \brief Matches CUDA kernel call expression.
 ///
 /// Example matches,
Index: docs/LibASTMatchersReference.html
=

Re: [PATCH] D18243: [ASTMatchers] Existing matcher hasAnyArgument fixed

2016-03-22 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 51263.
baloghadamsoftware added a comment.

LibASTMatchersReference.html updated


http://reviews.llvm.org/D18243

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

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1633,10 +1633,15 @@
 
 TEST(Matcher, AnyArgument) {
   StatementMatcher CallArgumentY = callExpr(
-  hasAnyArgument(declRefExpr(to(varDecl(hasName("y"));
+  hasAnyArgument(
+  ignoringParenImpCasts(declRefExpr(to(varDecl(hasName("y")));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(1, y); }", CallArgumentY));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(y, 42); }", CallArgumentY));
   EXPECT_TRUE(notMatches("void x(int, int) { x(1, 2); }", CallArgumentY));
+  
+  StatementMatcher ImplicitCastedArgument = callExpr(
+  hasAnyArgument(implicitCastExpr()));
+  EXPECT_TRUE(matches("void x(long) { int y; x(y); }", 
ImplicitCastedArgument));
 }
 
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2989,18 +2989,13 @@
 ///   matches x(1, y, 42)
 /// with hasAnyArgument(...)
 ///   matching y
-///
-/// FIXME: Currently this will ignore parentheses and implicit casts on
-/// the argument before applying the inner matcher. We'll want to remove
-/// this to allow for greater control by the user once \c ignoreImplicit()
-/// has been implemented.
 AST_POLYMORPHIC_MATCHER_P(hasAnyArgument,
   AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr,
   CXXConstructExpr),
   internal::Matcher, InnerMatcher) {
   for (const Expr *Arg : Node.arguments()) {
 BoundNodesTreeBuilder Result(*Builder);
-if (InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, &Result)) {
+if (InnerMatcher.matches(*Arg, Finder, &Result)) {
   *Builder = std::move(Result);
   return true;
 }
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3636,11 +3636,6 @@
   matches x(1, y, 42)
 with hasAnyArgument(...)
   matching y
-
-FIXME: Currently this will ignore parentheses and implicit casts on
-the argument before applying the inner matcher. We'll want to remove
-this to allow for greater control by the user once ignoreImplicit()
-has been implemented.
 
 
 
@@ -3907,11 +3902,6 @@
   matches x(1, y, 42)
 with hasAnyArgument(...)
   matching y
-
-FIXME: Currently this will ignore parentheses and implicit casts on
-the argument before applying the inner matcher. We'll want to remove
-this to allow for greater control by the user once ignoreImplicit()
-has been implemented.
 
 
 


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1633,10 +1633,15 @@
 
 TEST(Matcher, AnyArgument) {
   StatementMatcher CallArgumentY = callExpr(
-  hasAnyArgument(declRefExpr(to(varDecl(hasName("y"));
+  hasAnyArgument(
+  ignoringParenImpCasts(declRefExpr(to(varDecl(hasName("y")));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(1, y); }", CallArgumentY));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(y, 42); }", CallArgumentY));
   EXPECT_TRUE(notMatches("void x(int, int) { x(1, 2); }", CallArgumentY));
+  
+  StatementMatcher ImplicitCastedArgument = callExpr(
+  hasAnyArgument(implicitCastExpr()));
+  EXPECT_TRUE(matches("void x(long) { int y; x(y); }", ImplicitCastedArgument));
 }
 
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2989,18 +2989,13 @@
 ///   matches x(1, y, 42)
 /// with hasAnyArgument(...)
 ///   matching y
-///
-/// FIXME: Currently this will ignore parentheses and implicit casts on
-/// the argument before applying the inner matcher. We'll want to remove
-/// this to allow for greater control by the user once \c ignoreImplicit()
-/// has been implemented.
 AST_POLYMORPHIC_MATCHER_P(hasAnyArgument,
   AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr,
   CXXConstructExpr),
   internal::Matcher, InnerMatcher) {
   for (const Expr *Arg : Node.argument

Re: [PATCH] D18265: [clang-tidy] New: checker misc-assign-operator-return

2016-03-22 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added a comment.

My first thought was also to extend existing checker 
misc-assign-operator-signature and rename it to just misc-assign-operator. 
However, there is little benefit doing this: the two checkers check different 
locations, one checks the signature while the other one of the return 
statements. Signature is always one, return statements can be multiple per 
function. So the checker function itself would consist of one branching 
statement and report different errors for different locations in the two 
branches. Only some matcher expressions can be common. Of course, if such a 
merge is beneficial from the user's perspective, then we should do it. 
Thoughts, opinions?


http://reviews.llvm.org/D18265



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


Re: [PATCH] D17987: [clang-tidy] Extension of checker misc-misplaced-widening-cast

2016-03-22 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added a comment.

Prerequisites (matchers) are accepted now.


http://reviews.llvm.org/D17987



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


Re: [PATCH] D17440: clang-format: [JS] do not wrap ES6 imports/exports.

2016-03-22 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/TokenAnnotator.cpp:760
@@ +759,3 @@
+  if (CurrentToken->is(tok::kw_export)) {
+// Find the 'from' part of export {...} from '...';
+// The difference here is that "export {...};" should not be treated as

Can you actually have:

  export {a as from};

?


Comment at: lib/Format/TokenAnnotator.cpp:763
@@ +762,3 @@
+// an export.
+while (CurrentToken) {
+  if (CurrentToken->is(tok::semi))

Not a big fan of the code duplication in this loop. How about doing:

  if (Style.Language == FormatStyle::LK_JavaScript &&
  ((Line.First->is(tok::kw_export) && CurrentToken->is(Keywords.kw_from)) ||
   isClosureImportStatement(*CurrentToken)))
return LT_ImportStatement;

in the lower loop? The ImportStatement variable can likely go away then.


http://reviews.llvm.org/D17440



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


r264035 - Fix warning about extra semicolon. NFC.

2016-03-22 Thread Vasileios Kalintiris via cfe-commits
Author: vkalintiris
Date: Tue Mar 22 05:41:20 2016
New Revision: 264035

URL: http://llvm.org/viewvc/llvm-project?rev=264035&view=rev
Log:
Fix warning about extra semicolon. NFC.

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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=264035&r1=264034&r2=264035&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Mar 22 05:41:20 2016
@@ -92,7 +92,7 @@ CGOpenMPRuntimeNVPTX::WorkerFunctionStat
 CodeGenModule &CGM)
 : WorkerFn(nullptr), CGFI(nullptr) {
   createWorkerFunction(CGM);
-};
+}
 
 void CGOpenMPRuntimeNVPTX::WorkerFunctionState::createWorkerFunction(
 CodeGenModule &CGM) {


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


Re: [PATCH] D17986: [ASTMatchers] New matcher hasReturnValue added

2016-03-22 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL264037: [ASTMatchers] New matcher hasReturnValue added 
(authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D17986?vs=51259&id=51266#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17986

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

Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -4854,6 +4854,18 @@
 
 
 
+MatcherReturnStmt>hasReturnValueMatcherExpr> 
InnerMatcher
+Matches the return 
value expression of a return statement
+
+Given
+  return a + b;
+hasReturnValue(binaryOperator())
+  matches 'return a + b'
+with binaryOperator()
+  matching 'a + b'
+
+
+
 MatcherStmtExpr>hasAnySubstatementMatcherStmt> 
InnerMatcher
 Matches compound 
statements where at least one substatement matches
 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -5008,6 +5008,22 @@
   return false;
 }
 
+/// \brief Matches the return value expression of a return statement
+///
+/// Given
+/// \code
+///   return a + b;
+/// \endcode
+/// hasReturnValue(binaryOperator())
+///   matches 'return a + b'
+/// with binaryOperator()
+///   matching 'a + b'
+AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher, 
+  InnerMatcher) {
+  return InnerMatcher.matches(*Node.getRetValue(), Finder, Builder);
+}
+
+
 /// \brief Matches CUDA kernel call expression.
 ///
 /// Example matches,
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -243,6 +243,7 @@
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasReturnValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);
   REGISTER_MATCHER(hasSingleDecl);
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -5488,5 +5488,11 @@
   EXPECT_TRUE(notMatches("int i = 0;", expr(nullPointerConstant(;
 }
 
+TEST(StatementMatcher, HasReturnValue) {
+  StatementMatcher RetVal = returnStmt(hasReturnValue(binaryOperator()));
+  EXPECT_TRUE(matches("int F() { int a, b; return a + b; }", RetVal));
+  EXPECT_FALSE(matches("int F() { int a; return a; }", RetVal));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang


Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -4854,6 +4854,18 @@
 
 
 
+MatcherReturnStmt>hasReturnValueMatcherExpr> InnerMatcher
+Matches the return value expression of a return statement
+
+Given
+  return a + b;
+hasReturnValue(binaryOperator())
+  matches 'return a + b'
+with binaryOperator()
+  matching 'a + b'
+
+
+
 MatcherStmtExpr>hasAnySubstatementMatcherStmt> InnerMatcher
 Matches compound statements where at least one substatement matches
 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -5008,6 +5008,22 @@
   return false;
 }
 
+/// \brief Matches the return value expression of a return statement
+///
+/// Given
+/// \code
+///   return a + b;
+/// \endcode
+/// hasReturnValue(binaryOperator())
+///   matches 'return a + b'
+/// with binaryOperator()
+///   matching 'a + b'
+AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher, 
+  InnerMatcher) {
+  return InnerMatcher.matches(*Node.getRetValue

r264037 - [ASTMatchers] New matcher hasReturnValue added

2016-03-22 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Mar 22 06:03:03 2016
New Revision: 264037

URL: http://llvm.org/viewvc/llvm-project?rev=264037&view=rev
Log:
[ASTMatchers] New matcher hasReturnValue added

Summary: A checker (will be uploaded after this patch) needs to check implicit 
casts. Existing generic matcher "has" ignores implicit casts and parenthesized 
expressions and no specific matcher for matching return value expression 
preexisted. The patch adds such a matcher (hasReturnValue).

Reviewers: klimek, sbenza

Subscribers: xazax.hun, klimek, cfe-commits

Patch by Ádám Balogh!

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

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

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=264037&r1=264036&r2=264037&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Tue Mar 22 06:03:03 2016
@@ -4854,6 +4854,18 @@ Usable as: MatcherReturnStmt>hasReturnValueMatcherExpr> 
InnerMatcher
+Matches the return 
value expression of a return statement
+
+Given
+  return a + b;
+hasReturnValue(binaryOperator())
+  matches 'return a + b'
+with binaryOperator()
+  matching 'a + b'
+
+
+
 MatcherStmtExpr>hasAnySubstatementMatcherStmt> 
InnerMatcher
 Matches compound 
statements where at least one substatement matches
 a given matcher. Also matches StmtExprs that have CompoundStmt as children.

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=264037&r1=264036&r2=264037&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Tue Mar 22 06:03:03 2016
@@ -5008,6 +5008,22 @@ AST_MATCHER_P(Decl, hasAttr, attr::Kind,
   return false;
 }
 
+/// \brief Matches the return value expression of a return statement
+///
+/// Given
+/// \code
+///   return a + b;
+/// \endcode
+/// hasReturnValue(binaryOperator())
+///   matches 'return a + b'
+/// with binaryOperator()
+///   matching 'a + b'
+AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher, 
+  InnerMatcher) {
+  return InnerMatcher.matches(*Node.getRetValue(), Finder, Builder);
+}
+
+
 /// \brief Matches CUDA kernel call expression.
 ///
 /// Example matches,

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=264037&r1=264036&r2=264037&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Tue Mar 22 06:03:03 2016
@@ -243,6 +243,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasReturnValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);
   REGISTER_MATCHER(hasSingleDecl);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=264037&r1=264036&r2=264037&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Tue Mar 22 06:03:03 2016
@@ -5488,5 +5488,11 @@ TEST(NullPointerConstants, Basic) {
   EXPECT_TRUE(notMatches("int i = 0;", expr(nullPointerConstant(;
 }
 
+TEST(StatementMatcher, HasReturnValue) {
+  StatementMatcher RetVal = returnStmt(hasReturnValue(binaryOperator()));
+  EXPECT_TRUE(matches("int F() { int a, b; return a + b; }", RetVal));
+  EXPECT_FALSE(matches("int F() { int a; return a; }", RetVal));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang


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


Re: [PATCH] D18243: [ASTMatchers] Existing matcher hasAnyArgument fixed

2016-03-22 Thread Alexander Kornienko via cfe-commits
alexfh added a subscriber: alexfh.
alexfh added a comment.

>   the fix must be emphasized in the release notes


It seems like the best time to update the release notes is now, in this patch ;)


http://reviews.llvm.org/D18243



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


Re: [PATCH] D17811: [clang-tidy] Add check to detect dangling references in value handlers.

2016-03-22 Thread Jonathan B Coe via cfe-commits
jbcoe added a comment.

Do you have commit access? I can apply this patch for you if not.


http://reviews.llvm.org/D17811



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


Re: [PATCH] D17440: clang-format: [JS] do not wrap ES6 imports/exports.

2016-03-22 Thread Martin Probst via cfe-commits
mprobst marked an inline comment as done.


Comment at: lib/Format/TokenAnnotator.cpp:760
@@ +759,3 @@
+  if (CurrentToken->is(tok::kw_export)) {
+// Find the 'from' part of export {...} from '...';
+// The difference here is that "export {...};" should not be treated as

djasper wrote:
> Can you actually have:
> 
>   export {a as from};
> 
> ?
Good observation. Fixed by specifically looking for `from 'some tring';`.


Comment at: lib/Format/TokenAnnotator.cpp:763
@@ +762,3 @@
+// an export.
+while (CurrentToken) {
+  if (CurrentToken->is(tok::semi))

djasper wrote:
> Not a big fan of the code duplication in this loop. How about doing:
> 
>   if (Style.Language == FormatStyle::LK_JavaScript &&
>   ((Line.First->is(tok::kw_export) && CurrentToken->is(Keywords.kw_from)) 
> ||
>isClosureImportStatement(*CurrentToken)))
> return LT_ImportStatement;
> 
> in the lower loop? The ImportStatement variable can likely go away then.
Merged with the code below. My intent was to not do this check for JavaScript 
code that doesn't start with `import` or `export`, but merging seems fair, too.


http://reviews.llvm.org/D17440



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


Re: [PATCH] D17440: clang-format: [JS] do not wrap ES6 imports/exports.

2016-03-22 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 51267.
mprobst marked an inline comment as done.
mprobst added a comment.

- Address review comments:


http://reviews.llvm.org/D17440

Files:
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -942,21 +942,10 @@
   verifyFormat("import SomeThing from 'some/module.js';");
   verifyFormat("import {X, Y} from 'some/module.js';");
   verifyFormat("import a, {X, Y} from 'some/module.js';");
-  verifyFormat("import {\n"
-   "  VeryLongImportsAreAnnoying,\n"
-   "  VeryLongImportsAreAnnoying,\n"
-   "  VeryLongImportsAreAnnoying,\n"
-   "  VeryLongImportsAreAnnoying\n"
+  verifyFormat("import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,"
+   " VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying"
"} from 'some/module.js';");
-  verifyFormat("import {\n"
-   "  X,\n"
-   "  Y,\n"
-   "} from 'some/module.js';");
-  verifyFormat("import {\n"
-   "  X,\n"
-   "  Y,\n"
-   "} from\n'some/long/module.js';",
-   getGoogleJSStyleWithColumns(20));
+  verifyFormat("import {X, Y,} from 'some/module.js';");
   verifyFormat("import {X as myLocalX, Y as myLocalY} from 'some/module.js';");
   verifyFormat("import * as lib from 'some/module.js';");
   verifyFormat("var x = {import: 1};\nx.import = 2;");
@@ -970,10 +959,19 @@
   verifyFormat("export const x = 12;");
   verifyFormat("export default class X {}");
   verifyFormat("export {X, Y} from 'some/module.js';");
+  verifyFormat("export {X, Y,} from 'some/module.js';");
+  verifyFormat("export {SomeVeryLongExport as X, "
+   "SomeOtherVeryLongExport as Y} from 'some/module.js';");
+  // export without 'from' is wrapped.
+  verifyFormat("export let someRatherLongVariableName =\n"
+   "someSurprisinglyLongVariable + someOtherRatherLongVar;");
+  // ... but not if from is just an identifier.
   verifyFormat("export {\n"
-   "  X,\n"
-   "  Y,\n"
-   "} from 'some/module.js';");
+   "  from as from,\n"
+   "  someSurprisinglyLongVariable\n"
+   "  as from\n"
+   "};",
+   getGoogleJSStyleWithColumns(20));
   verifyFormat("export class C {\n"
"  x: number;\n"
"  y: string;\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -764,13 +764,29 @@
 return LT_ImportStatement;
 }
 
+// import {...} from '...';
+if (Style.Language == FormatStyle::LK_JavaScript &&
+CurrentToken->is(Keywords.kw_import))
+  return LT_ImportStatement;
+
 bool KeywordVirtualFound = false;
 bool ImportStatement = false;
 while (CurrentToken) {
   if (CurrentToken->is(tok::kw_virtual))
 KeywordVirtualFound = true;
-  if (isImportStatement(*CurrentToken))
-ImportStatement = true;
+  if (Style.Language == FormatStyle::LK_JavaScript) {
+// An export followed by "from 'some string';" is a re-export from
+// another module identified by a URI and is treated as a
+// LT_ImportStatement (i.e. prevent wraps on it for long URIs).
+// Just "export {...};" or "export class ..." should not be treated as
+// an import in this sense.
+if (Line.First->is(tok::kw_export) &&
+CurrentToken->is(Keywords.kw_from) && CurrentToken->Next &&
+CurrentToken->Next->isStringLiteral())
+  ImportStatement = true;
+if (isClosureImportStatement(*CurrentToken))
+  ImportStatement = true;
+  }
   if (!consumeToken())
 return LT_Invalid;
 }
@@ -790,11 +806,10 @@
   }
 
 private:
-  bool isImportStatement(const FormatToken &Tok) {
+  bool isClosureImportStatement(const FormatToken &Tok) {
 // FIXME: Closure-library specific stuff should not be hard-coded but be
 // configurable.
-return Style.Language == FormatStyle::LK_JavaScript &&
-   Tok.TokenText == "goog" && Tok.Next && Tok.Next->is(tok::period) &&
+return Tok.TokenText == "goog" && Tok.Next && Tok.Next->is(tok::period) &&
Tok.Next->Next && (Tok.Next->Next->TokenText == "module" ||
   Tok.Next->Next->TokenText == "provide" ||
   Tok.Next->Next->TokenText == "require" ||
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -537,6 +537,7 @@
 
 kw_finally = &IdentTable.get("finally");
 

Re: [PATCH] D17440: clang-format: [JS] do not wrap ES6 imports/exports.

2016-03-22 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 51268.
mprobst added a comment.

Rebase diff on current master.


http://reviews.llvm.org/D17440

Files:
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -942,21 +942,10 @@
   verifyFormat("import SomeThing from 'some/module.js';");
   verifyFormat("import {X, Y} from 'some/module.js';");
   verifyFormat("import a, {X, Y} from 'some/module.js';");
-  verifyFormat("import {\n"
-   "  VeryLongImportsAreAnnoying,\n"
-   "  VeryLongImportsAreAnnoying,\n"
-   "  VeryLongImportsAreAnnoying,\n"
-   "  VeryLongImportsAreAnnoying\n"
+  verifyFormat("import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,"
+   " VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying"
"} from 'some/module.js';");
-  verifyFormat("import {\n"
-   "  X,\n"
-   "  Y,\n"
-   "} from 'some/module.js';");
-  verifyFormat("import {\n"
-   "  X,\n"
-   "  Y,\n"
-   "} from\n'some/long/module.js';",
-   getGoogleJSStyleWithColumns(20));
+  verifyFormat("import {X, Y,} from 'some/module.js';");
   verifyFormat("import {X as myLocalX, Y as myLocalY} from 'some/module.js';");
   verifyFormat("import * as lib from 'some/module.js';");
   verifyFormat("var x = {import: 1};\nx.import = 2;");
@@ -970,10 +959,19 @@
   verifyFormat("export const x = 12;");
   verifyFormat("export default class X {}");
   verifyFormat("export {X, Y} from 'some/module.js';");
+  verifyFormat("export {X, Y,} from 'some/module.js';");
+  verifyFormat("export {SomeVeryLongExport as X, "
+   "SomeOtherVeryLongExport as Y} from 'some/module.js';");
+  // export without 'from' is wrapped.
+  verifyFormat("export let someRatherLongVariableName =\n"
+   "someSurprisinglyLongVariable + someOtherRatherLongVar;");
+  // ... but not if from is just an identifier.
   verifyFormat("export {\n"
-   "  X,\n"
-   "  Y,\n"
-   "} from 'some/module.js';");
+   "  from as from,\n"
+   "  someSurprisinglyLongVariable\n"
+   "  as from\n"
+   "};",
+   getGoogleJSStyleWithColumns(20));
   verifyFormat("export class C {\n"
"  x: number;\n"
"  y: string;\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -764,13 +764,29 @@
 return LT_ImportStatement;
 }
 
+// import {...} from '...';
+if (Style.Language == FormatStyle::LK_JavaScript &&
+CurrentToken->is(Keywords.kw_import))
+  return LT_ImportStatement;
+
 bool KeywordVirtualFound = false;
 bool ImportStatement = false;
 while (CurrentToken) {
   if (CurrentToken->is(tok::kw_virtual))
 KeywordVirtualFound = true;
-  if (isImportStatement(*CurrentToken))
-ImportStatement = true;
+  if (Style.Language == FormatStyle::LK_JavaScript) {
+// An export followed by "from 'some string';" is a re-export from
+// another module identified by a URI and is treated as a
+// LT_ImportStatement (i.e. prevent wraps on it for long URIs).
+// Just "export {...};" or "export class ..." should not be treated as
+// an import in this sense.
+if (Line.First->is(tok::kw_export) &&
+CurrentToken->is(Keywords.kw_from) && CurrentToken->Next &&
+CurrentToken->Next->isStringLiteral())
+  ImportStatement = true;
+if (isClosureImportStatement(*CurrentToken))
+  ImportStatement = true;
+  }
   if (!consumeToken())
 return LT_Invalid;
 }
@@ -790,11 +806,10 @@
   }
 
 private:
-  bool isImportStatement(const FormatToken &Tok) {
+  bool isClosureImportStatement(const FormatToken &Tok) {
 // FIXME: Closure-library specific stuff should not be hard-coded but be
 // configurable.
-return Style.Language == FormatStyle::LK_JavaScript &&
-   Tok.TokenText == "goog" && Tok.Next && Tok.Next->is(tok::period) &&
+return Tok.TokenText == "goog" && Tok.Next && Tok.Next->is(tok::period) &&
Tok.Next->Next && (Tok.Next->Next->TokenText == "module" ||
   Tok.Next->Next->TokenText == "provide" ||
   Tok.Next->Next->TokenText == "require" ||
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -537,6 +537,7 @@
 
 kw_finally = &IdentTable.get("finally");
 kw_function = &IdentTable.get("fun

Re: [PATCH] D17440: clang-format: [JS] do not wrap ES6 imports/exports.

2016-03-22 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 51269.
mprobst added a comment.

- Address review comments:
- Add one more explanatory comment.


http://reviews.llvm.org/D17440

Files:
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -942,21 +942,10 @@
   verifyFormat("import SomeThing from 'some/module.js';");
   verifyFormat("import {X, Y} from 'some/module.js';");
   verifyFormat("import a, {X, Y} from 'some/module.js';");
-  verifyFormat("import {\n"
-   "  VeryLongImportsAreAnnoying,\n"
-   "  VeryLongImportsAreAnnoying,\n"
-   "  VeryLongImportsAreAnnoying,\n"
-   "  VeryLongImportsAreAnnoying\n"
+  verifyFormat("import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,"
+   " VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying"
"} from 'some/module.js';");
-  verifyFormat("import {\n"
-   "  X,\n"
-   "  Y,\n"
-   "} from 'some/module.js';");
-  verifyFormat("import {\n"
-   "  X,\n"
-   "  Y,\n"
-   "} from\n'some/long/module.js';",
-   getGoogleJSStyleWithColumns(20));
+  verifyFormat("import {X, Y,} from 'some/module.js';");
   verifyFormat("import {X as myLocalX, Y as myLocalY} from 'some/module.js';");
   verifyFormat("import * as lib from 'some/module.js';");
   verifyFormat("var x = {import: 1};\nx.import = 2;");
@@ -970,10 +959,19 @@
   verifyFormat("export const x = 12;");
   verifyFormat("export default class X {}");
   verifyFormat("export {X, Y} from 'some/module.js';");
+  verifyFormat("export {X, Y,} from 'some/module.js';");
+  verifyFormat("export {SomeVeryLongExport as X, "
+   "SomeOtherVeryLongExport as Y} from 'some/module.js';");
+  // export without 'from' is wrapped.
+  verifyFormat("export let someRatherLongVariableName =\n"
+   "someSurprisinglyLongVariable + someOtherRatherLongVar;");
+  // ... but not if from is just an identifier.
   verifyFormat("export {\n"
-   "  X,\n"
-   "  Y,\n"
-   "} from 'some/module.js';");
+   "  from as from,\n"
+   "  someSurprisinglyLongVariable\n"
+   "  as from\n"
+   "};",
+   getGoogleJSStyleWithColumns(20));
   verifyFormat("export class C {\n"
"  x: number;\n"
"  y: string;\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -764,13 +764,30 @@
 return LT_ImportStatement;
 }
 
+// import {...} from '...';
+if (Style.Language == FormatStyle::LK_JavaScript &&
+CurrentToken->is(Keywords.kw_import))
+  return LT_ImportStatement;
+
 bool KeywordVirtualFound = false;
 bool ImportStatement = false;
 while (CurrentToken) {
   if (CurrentToken->is(tok::kw_virtual))
 KeywordVirtualFound = true;
-  if (isImportStatement(*CurrentToken))
-ImportStatement = true;
+  if (Style.Language == FormatStyle::LK_JavaScript) {
+// export {...} from '...';
+// An export followed by "from 'some string';" is a re-export from
+// another module identified by a URI and is treated as a
+// LT_ImportStatement (i.e. prevent wraps on it for long URIs).
+// Just "export {...};" or "export class ..." should not be treated as
+// an import in this sense.
+if (Line.First->is(tok::kw_export) &&
+CurrentToken->is(Keywords.kw_from) && CurrentToken->Next &&
+CurrentToken->Next->isStringLiteral())
+  ImportStatement = true;
+if (isClosureImportStatement(*CurrentToken))
+  ImportStatement = true;
+  }
   if (!consumeToken())
 return LT_Invalid;
 }
@@ -790,11 +807,10 @@
   }
 
 private:
-  bool isImportStatement(const FormatToken &Tok) {
+  bool isClosureImportStatement(const FormatToken &Tok) {
 // FIXME: Closure-library specific stuff should not be hard-coded but be
 // configurable.
-return Style.Language == FormatStyle::LK_JavaScript &&
-   Tok.TokenText == "goog" && Tok.Next && Tok.Next->is(tok::period) &&
+return Tok.TokenText == "goog" && Tok.Next && Tok.Next->is(tok::period) &&
Tok.Next->Next && (Tok.Next->Next->TokenText == "module" ||
   Tok.Next->Next->TokenText == "provide" ||
   Tok.Next->Next->TokenText == "require" ||
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -537,6 +537,7 @@
 
 kw_finally 

Re: [PATCH] D17440: clang-format: [JS] do not wrap ES6 imports/exports.

2016-03-22 Thread Martin Probst via cfe-commits
mprobst marked 3 inline comments as done.
mprobst added a comment.

http://reviews.llvm.org/D17440



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


Re: [PATCH] D17987: [clang-tidy] Extension of checker misc-misplaced-widening-cast

2016-03-22 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp:64
@@ -63,3 +63,3 @@
   // bool.
-  !match(findAll(callExpr(hasAnyArgument(DeclRef))), *If, *Result.Context)
+  
!match(findAll(callExpr(hasAnyArgument(ignoringParenImpCasts(DeclRef, *If, 
*Result.Context)
.empty() ||

The line exceeds 80 columns limit. Please clang-format the change.


Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:98
@@ +97,3 @@
+  const auto *Cast = Result.Nodes.getNodeAs("Cast");
+  if (!CheckImplicitCasts && dyn_cast(Cast))
+return;

`isa` should be used instead of `dyn_cast`, when you don't need the 
resulting pointer.


Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:119
@@ -98,4 +118,3 @@
   if (Context.getIntWidth(CastType) == Context.getIntWidth(CalcType)) {
-if (CalcType->isSpecificBuiltinType(BuiltinType::Int) ||
-CalcType->isSpecificBuiltinType(BuiltinType::UInt)) {
-  // There should be a warning when casting from int to long or long long.
+if (CalcType->isSpecificBuiltinType(BuiltinType::SChar) ||
+CalcType->isSpecificBuiltinType(BuiltinType::UChar) ||

`isSpecificBuiltinType` is not the best tool here. Instead, we could get the 
builtin type kinds and work with them 
(`CalcType->getAs()->getKind()` and 
`CastType->getAs()->getKind()` after checking that both are 
`BuiltinTypes`).


Comment at: test/clang-tidy/misc-misplaced-widening-cast.cpp:28
@@ +27,3 @@
+  l = a * b == c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' 
is ineffective, or there is loss of precision before the conversion 
[misc-misplaced-widening-cast]
+  l = c == a * b;

Please truncate "is ineffective, or there is loss of precision before the 
conversion [misc-misplaced-widening-cast]" in all CHECK-MESSAGES lines but the 
first one.


Comment at: test/clang-tidy/misc-misplaced-widening-cast.cpp:41
@@ +40,3 @@
+  long l1 = n << 8;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: either cast from 'unsigned int'
+  long l2 = (long)(n << 8);

It makes sense to leave the `to 'http://reviews.llvm.org/D17987



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


Re: [PATCH] D17811: [clang-tidy] Add check to detect dangling references in value handlers.

2016-03-22 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D17811#380124, @jbcoe wrote:

> Do you have commit access? I can apply this patch for you if not.


He does have commit access.


http://reviews.llvm.org/D17811



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


Re: [PATCH] D17987: [clang-tidy] Extension of checker misc-misplaced-widening-cast

2016-03-22 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added inline comments.


Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:119
@@ -98,4 +118,3 @@
   if (Context.getIntWidth(CastType) == Context.getIntWidth(CalcType)) {
-if (CalcType->isSpecificBuiltinType(BuiltinType::Int) ||
-CalcType->isSpecificBuiltinType(BuiltinType::UInt)) {
-  // There should be a warning when casting from int to long or long long.
+if (CalcType->isSpecificBuiltinType(BuiltinType::SChar) ||
+CalcType->isSpecificBuiltinType(BuiltinType::UChar) ||

alexfh wrote:
> `isSpecificBuiltinType` is not the best tool here. Instead, we could get the 
> builtin type kinds and work with them 
> (`CalcType->getAs()->getKind()` and 
> `CastType->getAs()->getKind()` after checking that both are 
> `BuiltinTypes`).
I do not like it either, just reused the original code and copy-pasted it. I 
also think that getKind() should be used and instead of the long branches we 
could do the comparison using relative size table(s).


http://reviews.llvm.org/D17987



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


[PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-03-22 Thread Richard Barton via cfe-commits
richard.barton.arm created this revision.
richard.barton.arm added reviewers: EricWF, jamesr.
richard.barton.arm added a subscriber: cfe-commits.

Although not testing the annotations feature, the test still needs guarding for 
thread-safety otherwise it will not compile at all.

http://reviews.llvm.org/D18347

Files:
  test/libcxx/t

Index: test/libcxx/t
===
--- test/libcxx/t
+++ test/libcxx/t
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// REQUIRES: thread-safety
+
 // 
 
 // This test does not define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS so it


Index: test/libcxx/t
===
--- test/libcxx/t
+++ test/libcxx/t
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// REQUIRES: thread-safety
+
 // 
 
 // This test does not define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS so it
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r263740 - Revert "For MS ABI, emit dllexport friend functions defined inline in class"

2016-03-22 Thread Stephan Bergmann via cfe-commits

On 03/17/2016 09:06 PM, Reid Kleckner via cfe-commits wrote:

Author: rnk
Date: Thu Mar 17 15:06:58 2016
New Revision: 263740

URL: http://llvm.org/viewvc/llvm-project?rev=263740&view=rev
Log:
Revert "For MS ABI, emit dllexport friend functions defined inline in class"

This reverts commit r263738.

This appears to cause a failure in
CXX/temp/temp.decls/temp.friend/p1.cpp


Ah, indeed, if you stick "-triple %ms_abi_triple" in 
test/CXX/temp/temp.decls/temp.friend/p1.cpp, it would consistently have 
failed on all platforms.


The problem is with friend functions defined inline within class 
templates (instead of classes), as in


  template struct S { friend void f() {} };

But which MSVC apparently wouldn't emit when parsing the class template, 
anyway, so we shouldn't either.


So we should filter out friend functions that are defined within class 
templates:


(a) either in Parser::ParseLexedMethodDef 
(lib/Parse/ParseCXXInlineMethods.cpp) before calling 
ActOnFinishInlineFunctionDef,


(b) or (probably preferably) later in the "Handle friend functions" 
block in HandleInlineFunctionDefinition (lib/CodeGen/ModuleBuilder.cpp).


However, I'm having trouble how to determine that condition, in either 
case.  For (a), I thought that maybe


  CurTemplateDepthTracker.getDepth() != 0

could work, but apparently doesn't.  And for (b),

  !D->getDeclContext()->isDependentContext()

doesn't work, either (as the context of the declaration presumably isn't 
the class template, but rather the surrounding namespace).


Any hints?



Modified:
 cfe/trunk/include/clang/AST/ASTConsumer.h
 cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
 cfe/trunk/include/clang/Sema/Sema.h
 cfe/trunk/lib/CodeGen/CodeGenAction.cpp
 cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
 cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
 cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
 cfe/trunk/lib/Sema/SemaDecl.cpp
 cfe/trunk/test/CodeGenCXX/dllexport.cpp

Modified: cfe/trunk/include/clang/AST/ASTConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTConsumer.h?rev=263740&r1=263739&r2=263740&view=diff
==
--- cfe/trunk/include/clang/AST/ASTConsumer.h (original)
+++ cfe/trunk/include/clang/AST/ASTConsumer.h Thu Mar 17 15:06:58 2016
@@ -55,9 +55,9 @@ public:
/// \returns true to continue parsing, or false to abort parsing.
virtual bool HandleTopLevelDecl(DeclGroupRef D);

-  /// \brief This callback is invoked each time an inline (method or friend)
-  /// function definition in a class is completed.
-  virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {}
+  /// \brief This callback is invoked each time an inline method definition is
+  /// completed.
+  virtual void HandleInlineMethodDefinition(CXXMethodDecl *D) {}

/// HandleInterestingDecl - Handle the specified interesting declaration. 
This
/// is called by the AST reader when deserializing things that might 
interest

Modified: cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/MultiplexConsumer.h?rev=263740&r1=263739&r2=263740&view=diff
==
--- cfe/trunk/include/clang/Frontend/MultiplexConsumer.h (original)
+++ cfe/trunk/include/clang/Frontend/MultiplexConsumer.h Thu Mar 17 15:06:58 
2016
@@ -36,7 +36,7 @@ public:
void Initialize(ASTContext &Context) override;
void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override;
bool HandleTopLevelDecl(DeclGroupRef D) override;
-  void HandleInlineFunctionDefinition(FunctionDecl *D) override;
+  void HandleInlineMethodDefinition(CXXMethodDecl *D) override;
void HandleInterestingDecl(DeclGroupRef D) override;
void HandleTranslationUnit(ASTContext &Ctx) override;
void HandleTagDeclDefinition(TagDecl *D) override;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=263740&r1=263739&r2=263740&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Mar 17 15:06:58 2016
@@ -1773,7 +1773,7 @@ public:
Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body);
Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation);
Decl *ActOnSkippedFunctionBody(Decl *Decl);
-  void ActOnFinishInlineFunctionDef(FunctionDecl *D);
+  void ActOnFinishInlineMethodDef(CXXMethodDecl *D);

/// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
/// attribute for which parsing is delayed.

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=263740&r1=263739&r2=263740&view=diff
===

Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

2016-03-22 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

In http://reviews.llvm.org/D13126#379306, @zaks.anna wrote:

> Why is there such a large jump in the number of warnings reported in the last 
> patch iteration?
>  It went from "1678 projects where scanned. In total I got 124 warnings" to 
> "In 2215 projects it found 875 warnings." Did the number of warnings in the 
> initial 1678 projects stay the same?


No I improved the check.

My previous patch was limited: I have limited this patch hoping that it will be 
easier to triage and review. Right now I only warn if there is assignment and 
RHS is a DeclRefExpr and only for loss of precision.

> Is it possible to take a look at the nature of the false positives, as per 
> NoQ's request above?


I'll try when I get some time.

> This checker would benefit greatly from explaining why the errors occur. For 
> example, where the values of variables are being constrained. Other checkers 
> use BugReporterVisitor to generate the rich diagnostic information. Dow you 
> have plans on how to accomplish that for this checker?


Yes that sounds like a good idea.. I''ll try to look at that.


http://reviews.llvm.org/D13126



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


Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

2016-03-22 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:84
@@ +83,3 @@
+// Can E value be greater or equal than Val?
+static bool canBeGreaterEqual(CheckerContext &C, const Expr *E,
+  unsigned long long Val) {

zaks.anna wrote:
> This function returns true if the value "is" greater or equal, not "can be" 
> greater or equal. The latter would be "return StGE".
> 
> Also, it's slightly better to return the StGE state and use it to report the 
> bug. This way, our assumption is explicitly recorded in the error state.
NoQ made the same comment. I disagree.

int A = 0;
if (X) {
 A = 1000;
}
U8 = A;  // <- Imho; A _can_ be 1000

Imho it's better to say that A _can_ be 1000 unless A is 1000 for all possible 
execution paths through the code.

Do you still think "is" is better than "can be"?


http://reviews.llvm.org/D13126



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


Re: [PATCH] D17955: [OpenCL] Fix pipe builtin bugs

2016-03-22 Thread Yaxun Liu via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


http://reviews.llvm.org/D17955



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


Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

2016-03-22 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added inline comments.


Comment at: test/clang-tidy/readability-non-const-parameter.cpp:116-134
@@ +115,21 @@
+
+// CHECK-MESSAGES: :[[@LINE+1]]:18: warning: parameter 'p' can be const
+int return1(int *p) {
+  // CHECK-FIXES: {{^}}int return1(const int *p) {{{$}}
+  return *p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const
+const int *return2(int *p) {
+  // CHECK-FIXES: {{^}}const int *return2(const int *p) {{{$}}
+  return p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const
+const int *return3(int *p) {
+  // CHECK-FIXES: {{^}}const int *return3(const int *p) {{{$}}
+  return p + 1;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:27: warning: parameter 'p' can be const
+const char *return4(char *p) {

rsmith wrote:
> The wording of this warning, and the name of the check, are highly misleading.
> 
> It's *not* the parameter that can be const, it's the parameter's *pointee*.
I understand. Figuring out a better message is not easy. I and a collegue brain 
stormed:

pointer parameter 'p' could be declared with const 'const int *p'

pointer parameter 'p' could be pointer to const

pointer parameter 'p' declaration could be pointer to const

missing const in pointer parameter 'p' declaration

declaration of pointer parameter 'p' could be 'const int *p'

Do you think any of these would be good?



http://reviews.llvm.org/D15332



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


Re: [PATCH] D18149: Add check for unneeded copies of locals

2016-03-22 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D18149



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


[clang-tools-extra] r264049 - Fix crashes from delayed template parsing code that assumed getBody() would return non-null.

2016-03-22 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Mar 22 08:37:44 2016
New Revision: 264049

URL: http://llvm.org/viewvc/llvm-project?rev=264049&view=rev
Log:
Fix crashes from delayed template parsing code that assumed getBody() would 
return non-null.

Patch by Etienne Bergeron.

Added:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp
clang-tools-extra/trunk/clang-tidy/modernize-redundant-void-arg-delayed.cpp
Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp

Added: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp?rev=264049&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp
 (added)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp
 Tue Mar 22 08:37:44 2016
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- -- 
-fdelayed-template-parsing
+
+template
+struct PositiveFieldBeforeConstructor {
+  PositiveFieldBeforeConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these built-in/pointer fields: F, G, H
+  int F;
+  bool G /* with comment */;
+  int *H;
+};
+// Explicit instantiation.
+template class PositiveFieldBeforeConstructor;
+
+template
+struct PositiveFieldAfterConstructor {
+  PositiveFieldAfterConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these built-in/pointer fields: F, G, H
+  int F;
+  bool G /* with comment */;
+  int *H;
+};
+// Explicit instantiation.
+template class PositiveFieldAfterConstructor;
+
+// This declaration isn't used and won't be parsed 'delayed-template-parsing'.
+// The body of the declaration is 'null' and may cause crash if not handled
+// properly by checkers.
+template
+struct UnusedDelayedConstructor {
+  UnusedDelayedConstructor() {}
+  int F;
+};

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=264049&r1=264048&r2=264049&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Tue Mar 22 08:37:44 2016
@@ -179,6 +179,11 @@ void ProTypeMemberInitCheck::check(const
   const auto *Ctor = Result.Nodes.getNodeAs("ctor");
   const auto &MemberFields = Ctor->getParent()->fields();
 
+  // Skip declarations delayed by late template parsing without a body.
+  const Stmt *Body = Ctor->getBody();
+  if (!Body)
+return;
+
   SmallPtrSet FieldsToInit;
   fieldsRequiringInit(MemberFields, FieldsToInit);
   if (FieldsToInit.empty())
@@ -193,8 +198,8 @@ void ProTypeMemberInitCheck::check(const
   continue;
 FieldsToInit.erase(Init->getMember());
   }
-  removeFieldsInitializedInBody(*Ctor->getBody(), *Result.Context,
-FieldsToInit);
+  removeFieldsInitializedInBody(*Body, *Result.Context, FieldsToInit);
+
   if (FieldsToInit.empty())
 return;
 

Added: 
clang-tools-extra/trunk/clang-tidy/modernize-redundant-void-arg-delayed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize-redundant-void-arg-delayed.cpp?rev=264049&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize-redundant-void-arg-delayed.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/modernize-redundant-void-arg-delayed.cpp 
Tue Mar 22 08:37:44 2016
@@ -0,0 +1,28 @@
+// RUN: %check_clang_tidy %s modernize-redundant-void-arg %t -- -- 
-fdelayed-template-parsing
+
+int foo(void) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: redundant void argument list in 
function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: {{^}}int foo() {{{$}}
+return 0;
+}
+
+template 
+struct MyFoo {
+  int foo(void) {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in 
function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: {{^}}  int foo() {{{$}}
+return 0;
+  }
+};
+// Explicit instantiation.
+template class MyFoo;
+
+template 
+struct MyBar {
+  // This declaration isn't instantiated and won't be parsed 
'delayed-template-parsing'.
+  int foo(void) {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in 
function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: {{^}}  int foo() {{{$}}
+return 0;
+

Re: [PATCH] D18238: [clang-tidy] Fix clang-tidy crashes when using -fdelayed-template-parsing.

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

Commit in r264049, thank you!


http://reviews.llvm.org/D18238



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


Re: [PATCH] D18262: [clang-tidy] Skip reporting of not applicable fixes.

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

LGTM!


http://reviews.llvm.org/D18262



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


[clang-tools-extra] r264050 - Moving files that were placed in the wrong directory from r264049.

2016-03-22 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Mar 22 08:44:36 2016
New Revision: 264050

URL: http://llvm.org/viewvc/llvm-project?rev=264050&view=rev
Log:
Moving files that were placed in the wrong directory from r264049.

Added:

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg-delayed.cpp
Removed:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp
clang-tools-extra/trunk/clang-tidy/modernize-redundant-void-arg-delayed.cpp

Removed: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp?rev=264049&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp
 (removed)
@@ -1,32 +0,0 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- -- 
-fdelayed-template-parsing
-
-template
-struct PositiveFieldBeforeConstructor {
-  PositiveFieldBeforeConstructor() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these built-in/pointer fields: F, G, H
-  int F;
-  bool G /* with comment */;
-  int *H;
-};
-// Explicit instantiation.
-template class PositiveFieldBeforeConstructor;
-
-template
-struct PositiveFieldAfterConstructor {
-  PositiveFieldAfterConstructor() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these built-in/pointer fields: F, G, H
-  int F;
-  bool G /* with comment */;
-  int *H;
-};
-// Explicit instantiation.
-template class PositiveFieldAfterConstructor;
-
-// This declaration isn't used and won't be parsed 'delayed-template-parsing'.
-// The body of the declaration is 'null' and may cause crash if not handled
-// properly by checkers.
-template
-struct UnusedDelayedConstructor {
-  UnusedDelayedConstructor() {}
-  int F;
-};

Removed: 
clang-tools-extra/trunk/clang-tidy/modernize-redundant-void-arg-delayed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize-redundant-void-arg-delayed.cpp?rev=264049&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize-redundant-void-arg-delayed.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize-redundant-void-arg-delayed.cpp 
(removed)
@@ -1,28 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-redundant-void-arg %t -- -- 
-fdelayed-template-parsing
-
-int foo(void) {
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: redundant void argument list in 
function definition [modernize-redundant-void-arg]
-// CHECK-FIXES: {{^}}int foo() {{{$}}
-return 0;
-}
-
-template 
-struct MyFoo {
-  int foo(void) {
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in 
function definition [modernize-redundant-void-arg]
-// CHECK-FIXES: {{^}}  int foo() {{{$}}
-return 0;
-  }
-};
-// Explicit instantiation.
-template class MyFoo;
-
-template 
-struct MyBar {
-  // This declaration isn't instantiated and won't be parsed 
'delayed-template-parsing'.
-  int foo(void) {
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in 
function definition [modernize-redundant-void-arg]
-// CHECK-FIXES: {{^}}  int foo() {{{$}}
-return 0;
-  }
-};

Added: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp?rev=264050&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp
 Tue Mar 22 08:44:36 2016
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- -- 
-fdelayed-template-parsing
+
+template
+struct PositiveFieldBeforeConstructor {
+  PositiveFieldBeforeConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these built-in/pointer fields: F, G, H
+  int F;
+  bool G /* with comment */;
+  int *H;
+};
+// Explicit instantiation.
+template class PositiveFieldBeforeConstructor;
+
+template
+struct PositiveFieldAfterConstructor {
+  PositiveFieldAfterConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these built-in/pointer fields: F, G, H
+  int F;
+  bool G /* with comment */;
+  int *H;
+};
+// Explicit instantiation.
+template class PositiveFieldAfterConstructor;
+
+// This de

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

2016-03-22 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

When running the tests from this patch locally (Win10, MSVC 2015, debug, x64), 
I get:

1>-- Build started: Project: intrinsics_gen, Configuration: Debug x64 --
2>-- Build started: Project: ClangDiagnosticLex, Configuration: Debug x64 
--
3>-- Build started: Project: ClangDiagnosticParse, Configuration: Debug x64 
--
4>-- Build started: Project: ClangDiagnosticSema, Configuration: Debug x64 
--
5>-- Build started: Project: ClangDiagnosticSerialization, Configuration: 
Debug x64 --
6>-- Build started: Project: ClangDiagnosticIndexName, Configuration: Debug 
x64 --
7>-- Build started: Project: ClangDiagnosticGroups, Configuration: Debug 
x64 --
8>-- Build started: Project: ClangStmtNodes, Configuration: Debug x64 --
9>-- Build started: Project: ClangARMNeon, Configuration: Debug x64 --
10>-- Build started: Project: ClangAttrClasses, Configuration: Debug x64 
--
11>-- Build started: Project: ClangAttrDump, Configuration: Debug x64 --
12>-- Build started: Project: ClangAttrHasAttributeImpl, Configuration: 
Debug x64 --
13>-- Build started: Project: ClangAttrImpl, Configuration: Debug x64 --
14>-- Build started: Project: ClangAttrList, Configuration: Debug x64 --
15>-- Build started: Project: ClangAttrPCHRead, Configuration: Debug x64 
--
16>-- Build started: Project: ClangAttrPCHWrite, Configuration: Debug x64 
--
17>-- Build started: Project: ClangAttrParsedAttrImpl, Configuration: Debug 
x64 --
18>-- Build started: Project: ClangAttrParsedAttrKinds, Configuration: 
Debug x64 --
19>-- Build started: Project: ClangAttrParsedAttrList, Configuration: Debug 
x64 --
20>-- Build started: Project: ClangAttrParserStringSwitches, Configuration: 
Debug x64 --
21>-- Build started: Project: ClangAttrSpellingListIndex, Configuration: 
Debug x64 --
22>-- Build started: Project: ClangAttrTemplateInstantiate, Configuration: 
Debug x64 --
23>-- Build started: Project: ClangAttrVisitor, Configuration: Debug x64 
--
24>-- Build started: Project: ClangCommentCommandInfo, Configuration: Debug 
x64 --
25>-- Build started: Project: ClangCommentCommandList, Configuration: Debug 
x64 --
26>-- Build started: Project: ClangCommentHTMLNamedCharacterReferences, 
Configuration: Debug x64 --
27>-- Build started: Project: ClangCommentHTMLTags, Configuration: Debug 
x64 --
28>-- Build started: Project: ClangCommentHTMLTagsProperties, 
Configuration: Debug x64 --
29>-- Build started: Project: ClangCommentNodes, Configuration: Debug x64 
--
30>-- Build started: Project: ClangDeclNodes, Configuration: Debug x64 
--
31>-- Build started: Project: ClangDiagnosticAST, Configuration: Debug x64 
--
32>-- Build started: Project: ClangDiagnosticAnalysis, Configuration: Debug 
x64 --
33>-- Build started: Project: ClangDiagnosticComment, Configuration: Debug 
x64 --
34>-- Build started: Project: ClangDiagnosticCommon, Configuration: Debug 
x64 --
35>-- Build started: Project: ClangDiagnosticDriver, Configuration: Debug 
x64 --
36>-- Build started: Project: ClangDiagnosticFrontend, Configuration: Debug 
x64 --
37>-- Build started: Project: AttributeCompatFuncTableGen, Configuration: 
Debug x64 --
38>-- Build started: Project: ClangDriverOptions, Configuration: Debug x64 
--
39>-- Build started: Project: clang-headers, Configuration: Debug x64 --
2>  Updating DiagnosticLexKinds.inc...
8>  Updating StmtNodes.inc...
5>  Updating DiagnosticSerializationKinds.inc...
9>  Updating arm_neon.inc...
1>  Updating Attributes.inc...
40>-- Build started: Project: AMDGPUCommonTableGen, Configuration: Debug 
x64 --
41>-- Build started: Project: AArch64CommonTableGen, Configuration: Debug 
x64 --
42>-- Build started: Project: XCoreCommonTableGen, Configuration: Debug x64 
--
43>-- Build started: Project: ARMCommonTableGen, Configuration: Debug x64 
--
44>-- Build started: Project: X86CommonTableGen, Configuration: Debug x64 
--
45>-- Build started: Project: MSP430CommonTableGen, Configuration: Debug 
x64 --
46>-- Build started: Project: HexagonCommonTableGen, Configuration: Debug 
x64 --
47>-- Build started: Project: SparcCommonTableGen, Configuration: Debug x64 
--
48>-- Build started: Project: SystemZCommonTableGen, Configuration: Debug 
x64 --
49>-- Build started: Project: PowerPCCommonTableGen, Configuration: Debug 
x64 --
50>-- Build started: Project: BPFCommonTableGen, Configuration: Debug x64 
--
51>-- Build started: Project: NVPTXCommonTableGen, Configuration: Debug x64 
--
52>-- Build started: Project: MipsCommonTableGen, Configuration: Debug x64 
--
24>  Updating CommentCommandInfo.inc...
20>  Updating AttrParserStringSwit

Re: [PATCH] D18286: [OPENMP] private and firstprivate clauses of teams code generation for nvptx

2016-03-22 Thread Carlo Bertolli via cfe-commits
carlo.bertolli added a comment.

Hi Alexey

Thanks for your comment. The suggested change will not work as I intended in my 
patch when using the host as a device. This happens when you select the 
following options:
-fomptargets=powerpc64le-ibm-linux-gnu -fopenmp-is-device

In this case we generate device code and the target is ppc64. In ppc64 we need 
to generate a call to kmpc_fork_teams. In your proposed change, we treat all 
devices in an undistinguished way and we do not generate a call to fork_teams.
There are various reasons why we should not do that, the most clear ones to me 
being:

- When using the host as host or as target device we generate different codes. 
This would mess up with performance profiling.

- On a host it is still important to have teams as that may be the place where 
coarse grain parallelism comes from.

If you still want no specialization in CGOpenMPRuntimeNVPTX, we will need to 
check if we are targeting a device and if that device is an nvptx one.

I know that the problem is that we have two CodeGen objects being created in 
different places if we target nvptx or host. However, by the way the interface 
is currently structured, I do not see any way out of this duplication.

Thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D18286



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


Re: [PATCH] D17440: clang-format: [JS] do not wrap ES6 imports/exports.

2016-03-22 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good. Do you have commit access now?


http://reviews.llvm.org/D17440



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


Re: [PATCH] D17440: clang-format: [JS] do not wrap ES6 imports/exports.

2016-03-22 Thread Martin Probst via cfe-commits
mprobst added a comment.

I've asked for it, but don't have it yet. Feel free to commit on by behalf.


http://reviews.llvm.org/D17440



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


Re: clang-tidy modernize-use-override

2016-03-22 Thread Aaron Ballman via cfe-commits
On Mon, Mar 21, 2016 at 11:22 AM, Robert Bolter via cfe-commits
 wrote:
> Hi,
>
> First time poster here, Please advise…

Thank you for the patches, and welcome!

One piece of advice: it's easier for code reviewers to review
unrelated patches in separate email chains.

Also, if you use Phab instead of email, it makes tracking the code
reviews a bit easier (but is not a requirement for submitting
patches); you can find more information at:
http://llvm.org/docs/Phabricator.html

It's also helpful to CC reviewers directly when submitting a patch, if
you can figure out who to add (and if you don't know, it's fine to
simply mention that in the patch submission, the community can help
find reviewers). I've CCed a few reviewers that do excellent work on
clang-tidy.

Patch review below.

> From 1cebd57efd542b010ac9c9da54e3ab2e097beb33 Mon Sep 17 00:00:00 2001
> From: Rob 
> Date: Mon, 21 Mar 2016 12:14:26 +
> Subject: [PATCH] modernize-use-override fix for const=0 (without spaces) and
>  __declspec(dll_export) attributes
>
> ---
>  clang-tidy/modernize/UseOverrideCheck.cpp | 17 +++---
>  test/clang-tidy/modernize-use-override-ms.cpp | 45 
> +++
>  test/clang-tidy/modernize-use-override.cpp|  7 -
>  3 files changed, 64 insertions(+), 5 deletions(-)
>  create mode 100644 test/clang-tidy/modernize-use-override-ms.cpp
>
> diff --git a/clang-tidy/modernize/UseOverrideCheck.cpp 
> b/clang-tidy/modernize/UseOverrideCheck.cpp
> index a335748..acc0b4a 100644
> --- a/clang-tidy/modernize/UseOverrideCheck.cpp
> +++ b/clang-tidy/modernize/UseOverrideCheck.cpp
> @@ -118,9 +118,11 @@ void UseOverrideCheck::check(const 
> MatchFinder::MatchResult &Result) {
>if (!HasFinal && !HasOverride) {
>  SourceLocation InsertLoc;
>  StringRef ReplacementText = "override ";
> +SourceLocation MethodLoc = Method->getLocation();
>
>  for (Token T : Tokens) {
> -  if (T.is(tok::kw___attribute)) {
> +  if (T.is(tok::kw___attribute) &&
> +  !(Sources.isBeforeInTranslationUnit(T.getLocation(), MethodLoc))) {
>  InsertLoc = T.getLocation();
>  break;
>}
> @@ -128,12 +130,15 @@ void UseOverrideCheck::check(const 
> MatchFinder::MatchResult &Result) {
>
>  if (Method->hasAttrs()) {
>for (const clang::Attr *A : Method->getAttrs()) {
> -if (!A->isImplicit()) {
> +if (!A->isImplicit() && !A->isInherited()) {
>SourceLocation Loc =
>Sources.getExpansionLoc(A->getRange().getBegin());
>if (!InsertLoc.isValid() ||
> -  Sources.isBeforeInTranslationUnit(Loc, InsertLoc))
> -InsertLoc = Loc;
> +  Sources.isBeforeInTranslationUnit(Loc, InsertLoc)) {
> +// skip attributes that precede the method identifier

Comments should be complete sentences (properly capitalized and punctuated).

> +if (!Sources.isBeforeInTranslationUnit(Loc, MethodLoc))
> +  InsertLoc = Loc;
> +  }

I think you can combine these if statements into:
if ((InsertLoc.isInvalid() || Sources.isBeforeInTranslationUnit(Loc,
InsertLoc)) &&
!Sources.isBeforeInTranslationUnit(Loc, MethodLoc))
  InsertLoc = Loc;

>  }
>}
>  }
> @@ -163,6 +168,10 @@ void UseOverrideCheck::check(const 
> MatchFinder::MatchResult &Result) {
>  Tokens.back().is(tok::kw_delete)) &&
>GetText(Tokens[Tokens.size() - 2], Sources) == "=") {
>  InsertLoc = Tokens[Tokens.size() - 2].getLocation();
> +// check if we need to insert a space

Same comments about comments here.

> +if ((Tokens[Tokens.size() - 2].getFlags() & Token::LeadingSpace) == 
> 0) {
> +  ReplacementText = " override ";
> +}

I think it would be more clear for the replacement text assignment be
moved below, where ReplacementText is being set to = " override".


>} else if (GetText(Tokens.back(), Sources) == "ABSTRACT") {
>  InsertLoc = Tokens.back().getLocation();
>}
> diff --git a/test/clang-tidy/modernize-use-override-ms.cpp 
> b/test/clang-tidy/modernize-use-override-ms.cpp
> new file mode 100644
> index 000..7ec56cd
> --- /dev/null
> +++ b/test/clang-tidy/modernize-use-override-ms.cpp
> @@ -0,0 +1,45 @@
> +// RUN: %check_clang_tidy %s modernize-use-override %t
> +
> +// This attribute type is inherited and precedes the declaration
> +#define EXPORT __declspec(dllexport)
> +
> +class EXPORT ExpBaseMacro {
> +  virtual void a();
> +};
> +
> +class __declspec(dllexport) ExpBase {
> +  virtual void a();
> +};
> +
> +class BaseMacro {
> +  virtual EXPORT void a();
> +};
> +
> +class Base {
> +  virtual __declspec(dllexport) void a();
> +};
> +
> +
> +class EXPORT ExpDerivedMacro : public ExpBaseMacro {
> +  virtual void a();
> +  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using

Please use the entire warning diagnostic text the first time it
appears in the test file. The rest

Re: [PATCH] D9888: [OPENMP] Driver support for OpenMP offloading

2016-03-22 Thread Michael Kuron via cfe-commits
mkuron added a comment.

The three smaller patches into which you divided this one appear to be missing 
some things. For example, `AddOpenMPLinkerScript` in //lib/Driver/Tools.cpp// 
from this patch appears to still be necessary to get the desired functionality, 
but it is not present in any of the three.


http://reviews.llvm.org/D9888



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


Re: [PATCH] D18265: [clang-tidy] New: checker misc-assign-operator-return

2016-03-22 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

As user I could tell that it's much easier to have one check which will check 
all nuances of particular language construction then multiple checks.


http://reviews.llvm.org/D18265



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


Re: [PATCH] D18286: [OPENMP] private and firstprivate clauses of teams code generation for nvptx

2016-03-22 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 51285.
carlo.bertolli added a comment.

To make clear my comment I an updating the patch following Alexey's comment and 
modifying it to make it work.
You can see that now we have the following check:
CGM.getTarget().getTriple().getArch() == llvm::Triple::nvptx ||
CGM.getTarget().getTriple().getArch() == llvm::Triple::nvptx64


Repository:
  rL LLVM

http://reviews.llvm.org/D18286

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/nvptx_teams_firstprivate_codegen.cpp
  test/OpenMP/nvptx_teams_private_codegen.cpp

Index: test/OpenMP/nvptx_teams_private_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_teams_private_codegen.cpp
@@ -0,0 +1,539 @@
+// RUN: %clang_cc1  -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fomptargets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1  -verify -fopenmp -x c++ -std=c++11 -triple nvptx64-unknown-unknown -fomptargets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fomp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1  -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fomptargets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1  -verify -fopenmp -x c++ -std=c++11 -triple nvptx-unknown-unknown -fomptargets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fomp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+
+
+template
+struct TT{
+  tx X;
+  ty Y;
+};
+
+// TCHECK: [[TT:%.+]] = type { i64, i8 }
+// TCHECK: [[S1:%.+]] = type { double }
+
+int foo(int n) {
+  int a = 0;
+  short aa = 0;
+  float b[10];
+  float bn[n];
+  double c[5][10];
+  double cn[5][n];
+  TT d;
+  
+  #pragma omp target private(a)
+  #pragma omp teams private(a)
+  {
+  }
+
+  // generate both private variables
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[A2:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK-NOT: store {{.+}}, {{.+}} [[A]],
+  // TCHECK:  ret void
+  
+
+  // a is implictly firstprivate
+  #pragma omp target
+  #pragma omp teams private(a)
+  {
+  }
+
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK-NOT: store {{.+}}, {{.+}} [[A]],
+  // TCHECK:  ret void  
+
+  #pragma omp target firstprivate(a)
+  #pragma omp teams private(a)
+  {
+  }
+
+  // because of firstprivate, a.addr and a parameter are
+  // created. This is fine, as long as we do not use a.addr
+  // TCHECK:  define void @__omp_offloading_{{.+}}({{.+}})
+  // TCHECK:  [[A_ADDR:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[ATA:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[ATE:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK-NOT: store {{.+}}, {{.+}} [[ATE]],
+  // TCHECK:  ret void  
+
+  #pragma omp target private(a)
+  #pragma omp teams private(a)
+  {
+a = 1;
+  }
+
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[ATA:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[ATE:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[ATE]],
+  // TCHECK-NOT:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[ATA]],
+  // TCHECK:  ret void
+
+  #pragma omp target
+  #pragma omp teams private(a)
+  {
+a = 1;
+  }
+
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[A]],
+  // TCHECK:  ret void
+
+  #pragma omp target firstprivate(a)
+  #pragma omp teams private(a)
+  {
+a = 1;
+  }
+
+  // check that we store in a without looking at the parameter
+  // TCHECK:  define void @__omp_offloading_{{.+}}({{.+}})
+  // TCHECK:  [[A_ADDR:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[ATA:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[ATE:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[ATE]],
+  // TCHECK:  ret void
+
+  #pragma omp target private(a, aa)
+  #pragma omp teams private(a,aa)
+  {
+a = 1;
+aa = 1;
+  }
+
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[ATA:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[A2TA:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[ATE:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[A2TE:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[ATE]],
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* [[A2TE]],
+  // TCHECK:  ret void
+  
+  #pragma omp target
+  #pragma omp teams private(a,aa)
+  {
+a = 1;
+aa = 1;
+  }
+
+  // TCHECK:  define void @__omp_offloading_{{.+}}()
+  // TCHECK:  [[A:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  [[A2:%.+]] = alloca i{{[0-9]+}},
+  // TCHECK:  store i{{[0-9]+}} 1, i{{[0-9]+}}* 

Re: [PATCH] D18262: [clang-tidy] Skip reporting of not applicable fixes.

2016-03-22 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG. Thanks for the fix!


http://reviews.llvm.org/D18262



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


Re: [PATCH] D18293: [clang-tidy] Fix redundant-string-init check with msvc 14 headers.

2016-03-22 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG


http://reviews.llvm.org/D18293



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


r264055 - clang-format: [JS] do not wrap ES6 imports/exports.

2016-03-22 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Mar 22 09:32:20 2016
New Revision: 264055

URL: http://llvm.org/viewvc/llvm-project?rev=264055&view=rev
Log:
clang-format: [JS] do not wrap ES6 imports/exports.

"import ... from '...';" and "export ... from '...';" should be treated
the same as goog.require/provide/module/forwardDeclare calls.

Patch by Martin Probst.

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

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=264055&r1=264054&r2=264055&view=diff
==
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Tue Mar 22 09:32:20 2016
@@ -537,6 +537,7 @@ struct AdditionalKeywords {
 
 kw_finally = &IdentTable.get("finally");
 kw_function = &IdentTable.get("function");
+kw_from = &IdentTable.get("from");
 kw_import = &IdentTable.get("import");
 kw_is = &IdentTable.get("is");
 kw_let = &IdentTable.get("let");
@@ -583,6 +584,7 @@ struct AdditionalKeywords {
   // JavaScript keywords.
   IdentifierInfo *kw_finally;
   IdentifierInfo *kw_function;
+  IdentifierInfo *kw_from;
   IdentifierInfo *kw_import;
   IdentifierInfo *kw_is;
   IdentifierInfo *kw_let;

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=264055&r1=264054&r2=264055&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Mar 22 09:32:20 2016
@@ -764,13 +764,30 @@ public:
 return LT_ImportStatement;
 }
 
+// import {...} from '...';
+if (Style.Language == FormatStyle::LK_JavaScript &&
+CurrentToken->is(Keywords.kw_import))
+  return LT_ImportStatement;
+
 bool KeywordVirtualFound = false;
 bool ImportStatement = false;
 while (CurrentToken) {
   if (CurrentToken->is(tok::kw_virtual))
 KeywordVirtualFound = true;
-  if (isImportStatement(*CurrentToken))
-ImportStatement = true;
+  if (Style.Language == FormatStyle::LK_JavaScript) {
+// export {...} from '...';
+// An export followed by "from 'some string';" is a re-export from
+// another module identified by a URI and is treated as a
+// LT_ImportStatement (i.e. prevent wraps on it for long URIs).
+// Just "export {...};" or "export class ..." should not be treated as
+// an import in this sense.
+if (Line.First->is(tok::kw_export) &&
+CurrentToken->is(Keywords.kw_from) && CurrentToken->Next &&
+CurrentToken->Next->isStringLiteral())
+  ImportStatement = true;
+if (isClosureImportStatement(*CurrentToken))
+  ImportStatement = true;
+  }
   if (!consumeToken())
 return LT_Invalid;
 }
@@ -790,11 +807,10 @@ public:
   }
 
 private:
-  bool isImportStatement(const FormatToken &Tok) {
+  bool isClosureImportStatement(const FormatToken &Tok) {
 // FIXME: Closure-library specific stuff should not be hard-coded but be
 // configurable.
-return Style.Language == FormatStyle::LK_JavaScript &&
-   Tok.TokenText == "goog" && Tok.Next && Tok.Next->is(tok::period) &&
+return Tok.TokenText == "goog" && Tok.Next && Tok.Next->is(tok::period) &&
Tok.Next->Next && (Tok.Next->Next->TokenText == "module" ||
   Tok.Next->Next->TokenText == "provide" ||
   Tok.Next->Next->TokenText == "require" ||

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=264055&r1=264054&r2=264055&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Mar 22 09:32:20 2016
@@ -942,21 +942,10 @@ TEST_F(FormatTestJS, Modules) {
   verifyFormat("import SomeThing from 'some/module.js';");
   verifyFormat("import {X, Y} from 'some/module.js';");
   verifyFormat("import a, {X, Y} from 'some/module.js';");
-  verifyFormat("import {\n"
-   "  VeryLongImportsAreAnnoying,\n"
-   "  VeryLongImportsAreAnnoying,\n"
-   "  VeryLongImportsAreAnnoying,\n"
-   "  VeryLongImportsAreAnnoying\n"
+  verifyFormat("import {VeryLongImportsAreAnnoying, 
VeryLongImportsAreAnnoying,"
+   " VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying"
"} from 'some/module.js';");
-  verifyFormat("import {\n"
-   "  X,\n"
-   "  Y,\n"
-   "} from 'some/module.js';");
-  verifyFormat("import {\n"
- 

Re: [PATCH] D17440: clang-format: [JS] do not wrap ES6 imports/exports.

2016-03-22 Thread Daniel Jasper via cfe-commits
djasper closed this revision.
djasper added a comment.

Submitted as r264055.


http://reviews.llvm.org/D17440



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


Re: [PATCH] D18243: [ASTMatchers] Existing matcher hasAnyArgument fixed

2016-03-22 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 51287.
baloghadamsoftware added a comment.

Release notes updated.


http://reviews.llvm.org/D18243

Files:
  docs/LibASTMatchersReference.html
  docs/ReleaseNotes.rst
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1633,10 +1633,15 @@
 
 TEST(Matcher, AnyArgument) {
   StatementMatcher CallArgumentY = callExpr(
-  hasAnyArgument(declRefExpr(to(varDecl(hasName("y"));
+  hasAnyArgument(
+  ignoringParenImpCasts(declRefExpr(to(varDecl(hasName("y")));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(1, y); }", CallArgumentY));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(y, 42); }", CallArgumentY));
   EXPECT_TRUE(notMatches("void x(int, int) { x(1, 2); }", CallArgumentY));
+  
+  StatementMatcher ImplicitCastedArgument = callExpr(
+  hasAnyArgument(implicitCastExpr()));
+  EXPECT_TRUE(matches("void x(long) { int y; x(y); }", 
ImplicitCastedArgument));
 }
 
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2989,18 +2989,13 @@
 ///   matches x(1, y, 42)
 /// with hasAnyArgument(...)
 ///   matching y
-///
-/// FIXME: Currently this will ignore parentheses and implicit casts on
-/// the argument before applying the inner matcher. We'll want to remove
-/// this to allow for greater control by the user once \c ignoreImplicit()
-/// has been implemented.
 AST_POLYMORPHIC_MATCHER_P(hasAnyArgument,
   AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr,
   CXXConstructExpr),
   internal::Matcher, InnerMatcher) {
   for (const Expr *Arg : Node.arguments()) {
 BoundNodesTreeBuilder Result(*Builder);
-if (InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, &Result)) {
+if (InnerMatcher.matches(*Arg, Finder, &Result)) {
   *Builder = std::move(Result);
   return true;
 }
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -119,6 +119,12 @@
 AST Matchers
 
 
+- hasAnyArgument: Matcher no longer ignores parentheses and implicit casts on
+  the argument before applying the inner matcher. The fix was done allow for
+  greater control by the user. In all existing checkers that use this matcher
+  all instances of code hasAnyArgument() must be changed to
+  hasAnyArgument(ignoringParenImpCasts()).
+
 ...
 
 libclang
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3636,11 +3636,6 @@
   matches x(1, y, 42)
 with hasAnyArgument(...)
   matching y
-
-FIXME: Currently this will ignore parentheses and implicit casts on
-the argument before applying the inner matcher. We'll want to remove
-this to allow for greater control by the user once ignoreImplicit()
-has been implemented.
 
 
 
@@ -3907,11 +3902,6 @@
   matches x(1, y, 42)
 with hasAnyArgument(...)
   matching y
-
-FIXME: Currently this will ignore parentheses and implicit casts on
-the argument before applying the inner matcher. We'll want to remove
-this to allow for greater control by the user once ignoreImplicit()
-has been implemented.
 
 
 


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1633,10 +1633,15 @@
 
 TEST(Matcher, AnyArgument) {
   StatementMatcher CallArgumentY = callExpr(
-  hasAnyArgument(declRefExpr(to(varDecl(hasName("y"));
+  hasAnyArgument(
+  ignoringParenImpCasts(declRefExpr(to(varDecl(hasName("y")));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(1, y); }", CallArgumentY));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(y, 42); }", CallArgumentY));
   EXPECT_TRUE(notMatches("void x(int, int) { x(1, 2); }", CallArgumentY));
+  
+  StatementMatcher ImplicitCastedArgument = callExpr(
+  hasAnyArgument(implicitCastExpr()));
+  EXPECT_TRUE(matches("void x(long) { int y; x(y); }", ImplicitCastedArgument));
 }
 
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2989,18 +2989,13 @@
 ///   matches x(1, y, 42)
 /// with hasAnyArgument

Re: [PATCH] D9888: [OPENMP] Driver support for OpenMP offloading

2016-03-22 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Michael,

In http://reviews.llvm.org/D9888#380225, @mkuron wrote:

> The three smaller patches into which you divided this one appear to be 
> missing some things. For example, `AddOpenMPLinkerScript` in 
> //lib/Driver/Tools.cpp// from this patch appears to still be necessary to get 
> the desired functionality, but it is not present in any of the three.


Those three patches do not add any OpenMP specific code yet, so they do not 
cover the whole implementation I have here. I am doing things in a slightly 
different way in the new patches given the feedback I had in the mailing list 
and I am waiting to review to see if the approach I have in there is 
acceptable. If so, I'll continue with the OpenMP related patches afterwards.

Thanks,
Samuel


http://reviews.llvm.org/D9888



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


Re: [PATCH] D18149: Add check for unneeded copies of locals

2016-03-22 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG



Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:21
@@ +20,3 @@
+
+void recordFixes(const VarDecl &Var, ASTContext &Context,
+ DiagnosticBuilder &Diagnostic) {

nit: Alternatively, you could return llvm::Optional and apply it in 
the caller. Might result in a bit better separation of responsibilities.


http://reviews.llvm.org/D18149



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


Re: [PATCH] D18149: Add check for unneeded copies of locals

2016-03-22 Thread Matt Kulukundis via cfe-commits
fowles added inline comments.


Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:21
@@ +20,3 @@
+
+void recordFixes(const VarDecl &Var, ASTContext &Context,
+ DiagnosticBuilder &Diagnostic) {

I am inclined to just leave it as is for the moment, this is already isolated 
code that doesn't escape the current file.


http://reviews.llvm.org/D18149



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


Re: [PATCH] D18149: Add check for unneeded copies of locals

2016-03-22 Thread Matt Kulukundis via cfe-commits
fowles updated this revision to Diff 51289.
fowles added a comment.

rebased to latest.  Can someone submit this for me I don't have commit bits.


http://reviews.llvm.org/D18149

Files:
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.h
  docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst
  test/clang-tidy/performance-unnecessary-copy-initialization.cpp

Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -1,28 +1,33 @@
 // RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
 
 struct ExpensiveToCopyType {
-  ExpensiveToCopyType() {}
-  virtual ~ExpensiveToCopyType() {}
-  const ExpensiveToCopyType &reference() const { return *this; }
-  void nonConstMethod() {}
+  ExpensiveToCopyType();
+  virtual ~ExpensiveToCopyType();
+  const ExpensiveToCopyType &reference() const;
+  void nonConstMethod();
+  bool constMethod() const;
 };
 
 struct TrivialToCopyType {
-  const TrivialToCopyType &reference() const { return *this; }
+  const TrivialToCopyType &reference() const;
 };
 
-const ExpensiveToCopyType &ExpensiveTypeReference() {
-  static const ExpensiveToCopyType *Type = new ExpensiveToCopyType();
-  return *Type;
-}
+struct WeirdCopyCtorType {
+  WeirdCopyCtorType();
+  WeirdCopyCtorType(const WeirdCopyCtorType &w, bool oh_yes = true);
 
-const TrivialToCopyType &TrivialTypeReference() {
-  static const TrivialToCopyType *Type = new TrivialToCopyType();
-  return *Type;
-}
+  void nonConstMethod();
+  bool constMethod() const;
+};
+
+ExpensiveToCopyType global_expensive_to_copy_type;
+
+const ExpensiveToCopyType &ExpensiveTypeReference();
+const TrivialToCopyType &TrivialTypeReference();
 
 void mutate(ExpensiveToCopyType &);
 void mutate(ExpensiveToCopyType *);
+void useAsConstPointer(const ExpensiveToCopyType *);
 void useAsConstReference(const ExpensiveToCopyType &);
 void useByValue(ExpensiveToCopyType);
 
@@ -203,23 +208,133 @@
   ExpensiveToCopyType Obj;
 };
 
-#define UNNECESSARY_COPY_INIT_IN_MACRO_BODY(TYPE)	\
-  void functionWith##TYPE(const TYPE& T) {		\
-auto AssignedInMacro = T.reference();		\
-  }			\
+#define UNNECESSARY_COPY_INIT_IN_MACRO_BODY(TYPE)  \
+  void functionWith##TYPE(const TYPE &T) { \
+auto AssignedInMacro = T.reference();  \
+  }\
 // Ensure fix is not applied.
 // CHECK-FIXES: auto AssignedInMacro = T.reference();
 
-
 UNNECESSARY_COPY_INIT_IN_MACRO_BODY(ExpensiveToCopyType)
 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: the variable 'AssignedInMacro' is copy-constructed
 
-#define UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(ARGUMENT)	\
-  ARGUMENT
+#define UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(ARGUMENT) ARGUMENT
 
 void PositiveMacroArgument(const ExpensiveToCopyType &Obj) {
   UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(auto CopyInMacroArg = Obj.reference());
   // CHECK-MESSAGES: [[@LINE-1]]:48: warning: the variable 'CopyInMacroArg' is copy-constructed
   // Ensure fix is not applied.
   // CHECK-FIXES: auto CopyInMacroArg = Obj.reference()
 }
+
+void PositiveLocalCopyConstMethodInvoked() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_1 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_1' of the variable 'orig' is never modified; consider avoiding the copy [performance-unnecessary-copy-initialization]
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_1 = orig;
+  copy_1.constMethod();
+  orig.constMethod();
+}
+
+void PositiveLocalCopyUsingExplicitCopyCtor() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_2(orig);
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_2'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_2(orig);
+  copy_2.constMethod();
+  orig.constMethod();
+}
+
+void PositiveLocalCopyCopyIsArgument(const ExpensiveToCopyType &orig) {
+  ExpensiveToCopyType copy_3 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_3'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_3 = orig;
+  copy_3.constMethod();
+}
+
+void PositiveLocalCopyUsedAsConstRef() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_4 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_4'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_4 = orig;
+  useAsConstReference(orig);
+}
+
+void PositiveLocalCopyTwice() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_5 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_5'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_5 = orig;
+  ExpensiveToCopyType copy_6 = copy_5;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warni

Re: [PATCH] D17491: Add performance check to flag function parameters of expensive to copy types that can be safely converted to const references.

2016-03-22 Thread Matt Kulukundis via cfe-commits
fowles added a subscriber: fowles.


Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:8
@@ +7,3 @@
+  void nonConstMethod() {}
+  virtual ~ExpensiveToCopyType() {}
+};

you don't actually need to fill in these methods, just declare them


Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:52
@@ +51,3 @@
+void positiveUnnamedParam(const ExpensiveToCopyType) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the const qualified parameter #1
+}

no fix for this case?


http://reviews.llvm.org/D17491



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


Re: [PATCH] D17981: [clang-tidy] Fix clang-tidy to support parsing of assembly statements.

2016-03-22 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Adding Manuel, who might have better ideas.

In http://reviews.llvm.org/D17981#374904, @rnk wrote:

> In http://reviews.llvm.org/D17981#374553, @etienneb wrote:
>
> > This is a huge difference. I didn't expect dependencies to bring so much 
> > code.
> >  I'm not a fan of having an empty statement and increasing false positives 
> > ratio.
> >  Would it be possible to skip whole declarations with asm-stm, and flag 
> > them as "ignored / not parsable"?
>
>
> I don't actually think there are that many false positives, but I wanted to 
> hear from Alex in case I'm wrong. I was hoping he had better ideas on how to 
> suppress a diagnostic error in clang and run the clang-tidy checks anyway.


I'm not familiar with the capabilities of MS-asm blocks, but if they can 
contain function calls, for example, we might lose valuable information, if we 
skip them. The possibility of a false positive depends on a specific check, 
it's hard to tell in general. There's also a more generic thing that can stop 
working properly: finding compilation errors inside asm blocks and applying 
fixes to these errors (if there are any fixes generated from parsing MS-asm 
blocks). Not sure how frequently this will happen though.

> My best idea is that we make this diagnostic a default-error warning and then 
> build with -Wno-unparseable-assembly or something. That's not a very good 
> solution, though. =\


Yes, not a very good solution for the reasons outlined above.

> 

> 

> > We could gate this code under a define. I'm not a fan of define, but it 
> > seems to be a compromise for the size.

> 

> > 

> 

> > Something like: LIBTOOLING_ENABLE_INLINE_ASM_PARSER

> 

> > 

> 

> > If we decide to pursue that direction, then it should probably be for every 
> > tools.

> 

> 

> I'd really rather not do that.


What's your concern? If we want parsing code inside MS asm blocks like the 
compiler does, we'll need to pay the cost of the asm parser. If the binary size 
is a large problem here, can we maybe reduce the set of dependencies of the MS 
asm parser?

In any case, I'm sure many users don't need this functionality, so it should be 
made compile-time configurable.


http://reviews.llvm.org/D17981



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


Re: r264021 - [Perf-training] Fixing an issue with multi-threading PGO generation

2016-03-22 Thread Vedant Kumar via cfe-commits
I think setting `cc1_env["LLVM_PROFILE_FILE"] = os.devnull` would be simpler.

vedant

> On Mar 21, 2016, at 7:55 PM, Chris Bieneman via cfe-commits 
>  wrote:
> 
> Author: cbieneman
> Date: Mon Mar 21 21:55:40 2016
> New Revision: 264021
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=264021&view=rev
> Log:
> [Perf-training] Fixing an issue with multi-threading PGO generation
> 
> When LIT parallelizes the profraw file generation we need to generate unique 
> temp filenames then clean them up after the driver executes.
> 
> 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=264021&r1=264020&r2=264021&view=diff
> ==
> --- cfe/trunk/utils/perf-training/perf-helper.py (original)
> +++ cfe/trunk/utils/perf-training/perf-helper.py Mon Mar 21 21:55:40 2016
> @@ -16,6 +16,7 @@ import argparse
> import time
> import bisect
> import shlex
> +import tempfile
> 
> test_env = { 'PATH': os.environ['PATH'] }
> 
> @@ -149,10 +150,12 @@ def cc1(args):
> 
>   # clear the profile file env, so that we don't generate profdata
>   # when capturing the cc1 command
> +  handle, profraw_file = tempfile.mkstemp()
> +  os.close(handle)
>   cc1_env = test_env
> -  cc1_env["LLVM_PROFILE_FILE"] = "driver.prfraw"
> +  cc1_env["LLVM_PROFILE_FILE"] = profraw_file
>   cc1_cmd = get_cc1_command_for_args(cmd, cc1_env)
> -  os.remove("driver.prfraw")
> +  os.remove(profraw_file)
> 
>   subprocess.check_call(cc1_cmd)
>   return 0;
> 
> 
> ___
> 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


r264063 - [Perf-training] Cleanup based on feedback from Sean Silvas

2016-03-22 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Mar 22 11:27:35 2016
New Revision: 264063

URL: http://llvm.org/viewvc/llvm-project?rev=264063&view=rev
Log:
[Perf-training] Cleanup based on feedback from Sean Silvas

Sean provided feedback based on r257934 on cfe-commits. This change addresses 
that feedback.

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=264063&r1=264062&r2=264063&view=diff
==
--- cfe/trunk/utils/perf-training/perf-helper.py (original)
+++ cfe/trunk/utils/perf-training/perf-helper.py Tue Mar 22 11:27:35 2016
@@ -99,9 +99,11 @@ def dtrace(args):
   if sys.platform == "darwin":
 dtrace_args.append('-xmangled')
 
-  f = open("%d.dtrace" % os.getpid(), "w")
   start_time = time.time()
-  subprocess.check_call(dtrace_args, stdout=f, stderr=subprocess.PIPE)
+
+  with open("%d.dtrace" % os.getpid(), "w") as f:
+subprocess.check_call(dtrace_args, stdout=f, stderr=subprocess.PIPE)
+
   elapsed = time.time() - start_time
   print("... data collection took %.4fs" % elapsed)
 
@@ -111,7 +113,7 @@ def get_cc1_command_for_args(cmd, env):
   # Find the cc1 command used by the compiler. To do this we execute the
   # compiler with '-###' to figure out what it wants to do.
   cmd = cmd + ['-###']
-  cc_output = check_output(cmd, stderr=subprocess.STDOUT, env=env).strip()
+  cc_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, 
env=env).strip()
   cc_commands = []
   for ln in cc_output.split('\n'):
   # Filter out known garbage.
@@ -246,13 +248,6 @@ def parse_dtrace_symbol_file(path, all_s
 for s in possible_symbols:
   yield (current_timestamp, s)
 
-def check_output(*popen_args, **popen_kwargs):
-p = subprocess.Popen(stdout=subprocess.PIPE, *popen_args, **popen_kwargs)
-stdout,stderr = p.communicate()
-if p.wait() != 0:
-raise RuntimeError("process failed")
-return stdout
-
 def uniq(list):
   seen = set()
   for item in list:
@@ -346,7 +341,7 @@ def genOrderFile(args):
   # If the user gave us a binary, get all the symbols in the binary by
   # snarfing 'nm' output.
   if opts.binary_path is not None:
- output = check_output(['nm', '-P', opts.binary_path])
+ output = subprocess.check_output(['nm', '-P', opts.binary_path])
  lines = output.split("\n")
  all_symbols = [ln.split(' ',1)[0]
 for ln in lines


___
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-03-22 Thread Chris Bieneman via cfe-commits
Sean,

All good feedback.

Using print_function was done in r257936 with some other feedback from Bogner.

The rest of your feedback I believe I have addressed in r264063.

-Chris

> On Mar 21, 2016, at 9:21 PM, Sean Silva  wrote:
> 
> 
> 
> On Fri, Jan 15, 2016 at 1:21 PM, Chris Bieneman via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> 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.
> 
> 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/l

r264064 - [Perf-training] Using os.devnull instead of a temp file

2016-03-22 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Mar 22 11:33:23 2016
New Revision: 264064

URL: http://llvm.org/viewvc/llvm-project?rev=264064&view=rev
Log:
[Perf-training] Using os.devnull instead of a temp file

This is based on post-commit feedback from Vedant. Totally didn't know that 
existed and worked on Windows.

Thanks Vedant!

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=264064&r1=264063&r2=264064&view=diff
==
--- cfe/trunk/utils/perf-training/perf-helper.py (original)
+++ cfe/trunk/utils/perf-training/perf-helper.py Tue Mar 22 11:33:23 2016
@@ -152,12 +152,9 @@ def cc1(args):
 
   # clear the profile file env, so that we don't generate profdata
   # when capturing the cc1 command
-  handle, profraw_file = tempfile.mkstemp()
-  os.close(handle)
   cc1_env = test_env
-  cc1_env["LLVM_PROFILE_FILE"] = profraw_file
+  cc1_env["LLVM_PROFILE_FILE"] = os.devnull
   cc1_cmd = get_cc1_command_for_args(cmd, cc1_env)
-  os.remove(profraw_file)
 
   subprocess.check_call(cc1_cmd)
   return 0;


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


Re: r264021 - [Perf-training] Fixing an issue with multi-threading PGO generation

2016-03-22 Thread Chris Bieneman via cfe-commits
I totally didn’t know python had a portable way to do that!

Updated in r264064.

Thanks!
-Chris

> On Mar 22, 2016, at 9:26 AM, Vedant Kumar  wrote:
> 
> I think setting `cc1_env["LLVM_PROFILE_FILE"] = os.devnull` would be simpler.
> 
> vedant
> 
>> On Mar 21, 2016, at 7:55 PM, Chris Bieneman via cfe-commits 
>>  wrote:
>> 
>> Author: cbieneman
>> Date: Mon Mar 21 21:55:40 2016
>> New Revision: 264021
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=264021&view=rev
>> Log:
>> [Perf-training] Fixing an issue with multi-threading PGO generation
>> 
>> When LIT parallelizes the profraw file generation we need to generate unique 
>> temp filenames then clean them up after the driver executes.
>> 
>> 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=264021&r1=264020&r2=264021&view=diff
>> ==
>> --- cfe/trunk/utils/perf-training/perf-helper.py (original)
>> +++ cfe/trunk/utils/perf-training/perf-helper.py Mon Mar 21 21:55:40 2016
>> @@ -16,6 +16,7 @@ import argparse
>> import time
>> import bisect
>> import shlex
>> +import tempfile
>> 
>> test_env = { 'PATH': os.environ['PATH'] }
>> 
>> @@ -149,10 +150,12 @@ def cc1(args):
>> 
>>  # clear the profile file env, so that we don't generate profdata
>>  # when capturing the cc1 command
>> +  handle, profraw_file = tempfile.mkstemp()
>> +  os.close(handle)
>>  cc1_env = test_env
>> -  cc1_env["LLVM_PROFILE_FILE"] = "driver.prfraw"
>> +  cc1_env["LLVM_PROFILE_FILE"] = profraw_file
>>  cc1_cmd = get_cc1_command_for_args(cmd, cc1_env)
>> -  os.remove("driver.prfraw")
>> +  os.remove(profraw_file)
>> 
>>  subprocess.check_call(cc1_cmd)
>>  return 0;
>> 
>> 
>> ___
>> 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


r264065 - [MS ABI] Assign an inheritance model for the dest of a member pointer upcast

2016-03-22 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Mar 22 11:44:39 2016
New Revision: 264065

URL: http://llvm.org/viewvc/llvm-project?rev=264065&view=rev
Log:
[MS ABI] Assign an inheritance model for the dest of a member pointer upcast

While we correctly assigned an inheritance model for the source of a
member pointer upcast, we did not do so for the destination.

This fixes PR27030.

Added:
cfe/trunk/test/CodeGenCXX/pr27030.cpp
Modified:
cfe/trunk/lib/Sema/SemaCast.cpp

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=264065&r1=264064&r2=264065&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Tue Mar 22 11:44:39 2016
@@ -1402,8 +1402,10 @@ TryStaticMemberPointerUpcast(Sema &Self,
 
   // Lock down the inheritance model right now in MS ABI, whether or not the
   // pointee types are the same.
-  if (Self.Context.getTargetInfo().getCXXABI().isMicrosoft())
+  if (Self.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
 (void)Self.isCompleteType(OpRange.getBegin(), SrcType);
+(void)Self.isCompleteType(OpRange.getBegin(), DestType);
+  }
 
   // T == T, modulo cv
   if (!Self.Context.hasSameUnqualifiedType(SrcMemPtr->getPointeeType(),

Added: cfe/trunk/test/CodeGenCXX/pr27030.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pr27030.cpp?rev=264065&view=auto
==
--- cfe/trunk/test/CodeGenCXX/pr27030.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/pr27030.cpp Tue Mar 22 11:44:39 2016
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s
+struct A {};
+struct B : A {};
+extern "C" {
+extern int B::*a;
+void test1() { (int A::*)(a); }
+}
+// CHECK-LABEL: define void @test1(
+// CHECK: %[[load:.*]]   = load i32, i32* @a
+// CHECK: %[[memptr_cmp:.*]] = icmp ne i32 %[[load]], -1
+// CHECK: br i1 %[[memptr_cmp]]
+
+// CHECK: %[[adj:.*]] = sub nsw i32 %[[load]], 0
+// CHECK: %[[nv_adj:.*]] = select i1 true, i32 %[[adj]], i32 0
+// CHECK: br label %memptr.converted
+
+// CHECK: %[[memptr_converted:.*]] = phi i32 [ -1, {{.*}} ], [ %[[nv_adj]], 
{{.*}} ]


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


Re: [PATCH] D17861: [OpenCL] Accept __attribute__((nosvm))

2016-03-22 Thread Yaxun Liu via cfe-commits
yaxunl marked an inline comment as done.


Comment at: include/clang/Basic/Attr.td:701
@@ -699,1 +700,3 @@
 
+def OpenCLNoSVM : Attr {
+  let Spellings = [GNU<"nosvm">];

aaron.ballman wrote:
> yaxunl wrote:
> > aaron.ballman wrote:
> > > Since the attribute is ignored by clang, you should inherit from 
> > > IgnoredAttr.
> > I tried that from beginning. If I inherit from IgnoredAttr, it seems to be 
> > ignored by the parser and won't reach the sema check part, and I cannot 
> > emit error msg based on OpenCL version.
> Ah. so it isn't *totally* ignored. Okay, in that case, you should set ASTNode 
> = 0 and SemaHandler = 0.
If I set ASTNode = 0 and SemaHandler = 0, tablegen will not generate an id 
AT_OpenCLNoSVM to identify this attribute, and I cannot diagnose its invalid 
usage in SemaDeclAttr.cpp due to that. Then it seems the only viable place to 
diagnose its invalid usage is in Parser::ParseGNUAttributes. However currently 
Parser::ParseGNUAttributes only does generic processing of GNU attributes and 
does not diagnose specific attribute. Since there is no id for NoSVM attribute, 
I have to diagnose based on its name string.

Do we really want to do this?


Repository:
  rL LLVM

http://reviews.llvm.org/D17861



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


r264066 - Make build bots happy

2016-03-22 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Mar 22 12:10:07 2016
New Revision: 264066

URL: http://llvm.org/viewvc/llvm-project?rev=264066&view=rev
Log:
Make build bots happy

BasicBlock's lose their names for some builders, don't mention such
names.

Modified:
cfe/trunk/test/CodeGenCXX/pr27030.cpp

Modified: cfe/trunk/test/CodeGenCXX/pr27030.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pr27030.cpp?rev=264066&r1=264065&r2=264066&view=diff
==
--- cfe/trunk/test/CodeGenCXX/pr27030.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/pr27030.cpp Tue Mar 22 12:10:07 2016
@@ -12,6 +12,5 @@ void test1() { (int A::*)(a); }
 
 // CHECK: %[[adj:.*]] = sub nsw i32 %[[load]], 0
 // CHECK: %[[nv_adj:.*]] = select i1 true, i32 %[[adj]], i32 0
-// CHECK: br label %memptr.converted
 
 // CHECK: %[[memptr_converted:.*]] = phi i32 [ -1, {{.*}} ], [ %[[nv_adj]], 
{{.*}} ]


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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread Yaxun Liu via cfe-commits
yaxunl updated the summary for this revision.
yaxunl removed rL LLVM as the repository for this revision.
yaxunl updated this revision to Diff 51297.
yaxunl added a comment.

Simplify description of this attribute in AttrDocs since it causes some 
confusion.


http://reviews.llvm.org/D18095

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/attr-linkonce-odr-linkage.c
  test/Sema/attr-linkonce-odr-linkage.c

Index: test/Sema/attr-linkonce-odr-linkage.c
===
--- /dev/null
+++ test/Sema/attr-linkonce-odr-linkage.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+extern int g0 __attribute__((linkonce_odr_linkage));
+int g2 __attribute__((linkonce_odr_linkage));
+int __attribute__((linkonce_odr_linkage)) g4(void);
+void __attribute__((linkonce_odr_linkage)) g5(void) {
+}
+
+struct __attribute__((linkonce_odr_linkage)) s0 {}; // expected-warning {{'linkonce_odr_linkage' attribute only applies to variables and functions}}
+
+static int x __attribute__((linkonce_odr_linkage)); // expected-error {{weak declaration cannot have internal linkage}}
+
+int C; // expected-note {{previous definition is here}}
+extern int C __attribute__((linkonce_odr_linkage)); // expected-warning {{an already-declared variable is made a weak_import declaration}}
+
+static int pr14946_x;
+extern int pr14946_x  __attribute__((linkonce_odr_linkage)); // expected-error {{weak declaration cannot have internal linkage}}
+
+static void pr14946_f();
+void pr14946_f() __attribute__((linkonce_odr_linkage)); // expected-error {{weak declaration cannot have internal linkage}}
Index: test/CodeGen/attr-linkonce-odr-linkage.c
===
--- /dev/null
+++ test/CodeGen/attr-linkonce-odr-linkage.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu < %s | FileCheck %s
+
+// CHECK: @a = linkonce_odr global i32 0
+__attribute__((linkonce_odr_linkage)) int a;
+
+// CHECK: define linkonce_odr void @test1_g()
+void test1_g(void) __attribute__((linkonce_odr_linkage));
+
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3611,6 +3611,19 @@
   InternalLinkageAttr(Range, Context, AttrSpellingListIndex);
 }
 
+LinkOnceODRLinkageAttr *
+Sema::mergeLinkOnceODRLinkageAttr(Decl *D, SourceRange Range,
+  IdentifierInfo *Ident,
+  unsigned AttrSpellingListIndex) {
+  if (checkAttrMutualExclusion(*this, D, Range, Ident) ||
+  checkAttrMutualExclusion(*this, D, Range, Ident))
+return nullptr;
+
+  return ::new (Context) LinkOnceODRLinkageAttr(Range,
+Context,
+AttrSpellingListIndex);
+}
+
 MinSizeAttr *Sema::mergeMinSizeAttr(Decl *D, SourceRange Range,
 unsigned AttrSpellingListIndex) {
   if (OptimizeNoneAttr *Optnone = D->getAttr()) {
@@ -5206,6 +5219,14 @@
 D->addAttr(Internal);
 }
 
+static void handleLinkOnceODRLinkageAttr(Sema &S, Decl *D,
+  const AttributeList &Attr) {
+  if (LinkOnceODRLinkageAttr *LinkOnce =
+  S.mergeLinkOnceODRLinkageAttr(D, Attr.getRange(), Attr.getName(),
+Attr.getAttributeSpellingListIndex()))
+D->addAttr(LinkOnce);
+}
+
 /// Handles semantic checking for features that are common to all attributes,
 /// such as checking whether a parameter was properly specified, or the correct
 /// number of arguments were passed, etc.
@@ -5701,6 +5722,8 @@
   case AttributeList::AT_InternalLinkage:
 handleInternalLinkageAttr(S, D, Attr);
 break;
+  case AttributeList::AT_LinkOnceODRLinkage:
+handleLinkOnceODRLinkageAttr(S, D, Attr);
 
   // Microsoft attributes:
   case AttributeList::AT_MSNoVTable:
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -752,7 +752,6 @@
 llvm::GlobalValue::LinkageTypes
 CodeGenModule::getFunctionLinkage(GlobalDecl GD) {
   const auto *D = cast(GD.getDecl());
-
   GVALinkage Linkage = getContext().GetGVALinkageForFunction(D);
 
   if (isa(D) &&
@@ -2626,6 +2625,9 @@
 
 llvm::GlobalValue::LinkageTypes CodeGenModule::getLLVMLinkageForDeclarator(
 const DeclaratorDecl *D, GVALinkage Linkage, bool IsConstantVariable) {
+  if (D->hasAttr())
+return llvm::GlobalVariable::LinkOnceODRLinkage;
+
   if (Linkage == GVA_Internal)
 return llvm::Function::InternalLinkage;
 
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/c

Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

If __attribute__((linkonce_odr_linkage)) is not a proper name for explicitly 
setting linkage, how about __attribute((linkage=linkonce_odr))? This can be 
extended to other linkages too.


http://reviews.llvm.org/D18095



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


Re: [PATCH] D18293: [clang-tidy] Fix redundant-string-init check with msvc 14 headers.

2016-03-22 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 51298.
etienneb added a comment.

Rebased + fixing invalid paths.

The diff paths were wrong, invalid diff.


http://reviews.llvm.org/D18293

Files:
  clang-tidy/readability/RedundantStringInitCheck.cpp
  test/clang-tidy/readability-redundant-string-init-msvc.cpp
  test/clang-tidy/readability-redundant-string-init.cpp

Index: test/clang-tidy/readability-redundant-string-init.cpp
===
--- test/clang-tidy/readability-redundant-string-init.cpp
+++ test/clang-tidy/readability-redundant-string-init.cpp
@@ -84,3 +84,50 @@
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: redundant string initialization
   // CHECK-FIXES: N
 }
+
+typedef std::string MyString;
+#define STRING MyString
+#define DECL_STRING(name, val) STRING name = val
+
+void i() {
+  MyString a = "";
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: redundant string initialization
+  // CHECK-FIXES: MyString a;
+  STRING b = "";
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: redundant string initialization
+  // CHECK-FIXES: STRING b;
+  MyString c = "" "" "";
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: redundant string initialization
+  // CHECK-FIXES: MyString c;
+  STRING d = "" "" "";
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: redundant string initialization
+  // CHECK-FIXES: STRING d;
+  DECL_STRING(e, "");
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+
+  MyString f = "u";
+  STRING g = "u";
+  DECL_STRING(h, "u");
+}
+
+#define EMPTY_STR ""
+void j() {
+  std::string a(EMPTY_STR);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES: std::string a;
+  std::string b = (EMPTY_STR);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES: std::string b;
+
+  std::string c(EMPTY_STR "u" EMPTY_STR);
+}
+
+void k() {
+  std::string a = "", b = "", c = "";
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-MESSAGES: [[@LINE-2]]:23: warning: redundant string initialization
+  // CHECK-MESSAGES: [[@LINE-3]]:31: warning: redundant string initialization
+  // CHECK-FIXES: std::string a, b, c;
+
+  std::string d = "u", e = "u", f = "u";
+}
Index: test/clang-tidy/readability-redundant-string-init-msvc.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-string-init-msvc.cpp
@@ -0,0 +1,122 @@
+// RUN: %check_clang_tidy %s readability-redundant-string-init %t
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template , typename A = std::allocator>
+struct basic_string {
+  basic_string();
+  basic_string(const basic_string&);
+  // MSVC headers define two constructors instead of using optional arguments.
+  basic_string(const C *);
+  basic_string(const C *, const A &);
+  ~basic_string();
+};
+typedef basic_string string;
+typedef basic_string wstring;
+}
+
+void f() {
+  std::string a = "";
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization [readability-redundant-string-init]
+  // CHECK-FIXES: std::string a;
+  std::string b("");
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES: std::string b;
+  std::string c = R"()";
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES: std::string c;
+  std::string d(R"()");
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES: std::string d;
+
+  std::string u = "u";
+  std::string w("w");
+  std::string x = R"(x)";
+  std::string y(R"(y)");
+  std::string z;
+}
+
+void g() {
+  std::wstring a = L"";
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
+  // CHECK-FIXES: std::wstring a;
+  std::wstring b(L"");
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
+  // CHECK-FIXES: std::wstring b;
+  std::wstring c = LR"()";
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
+  // CHECK-FIXES: std::wstring c;
+  std::wstring d(LR"()");
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
+  // CHECK-FIXES: std::wstring d;
+
+  std::wstring u = L"u";
+  std::wstring w(L"w");
+  std::wstring x = LR"(x)";
+  std::wstring y(LR"(y)");
+  std::wstring z;
+}
+// RUN: %check_clang_tidy %s readability-redundant-string-init %t
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template , typename A = std::allocator>
+struct basic_string {
+  basic_string();
+  basic_string(const basic_string&);
+  // MSVC headers define two constructors instead of using optional arguments.
+  basic_string(const C *);
+  basic_string(const C *, const A &);
+  ~basic_string();
+};
+typedef basic_string string;
+typedef basic_string wstring;
+}
+
+void f() {
+  std::string a = "";

Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

2016-03-22 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: test/clang-tidy/readability-non-const-parameter.cpp:116-134
@@ +115,21 @@
+
+// CHECK-MESSAGES: :[[@LINE+1]]:18: warning: parameter 'p' can be const
+int return1(int *p) {
+  // CHECK-FIXES: {{^}}int return1(const int *p) {{{$}}
+  return *p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const
+const int *return2(int *p) {
+  // CHECK-FIXES: {{^}}const int *return2(const int *p) {{{$}}
+  return p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const
+const int *return3(int *p) {
+  // CHECK-FIXES: {{^}}const int *return3(const int *p) {{{$}}
+  return p + 1;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:27: warning: parameter 'p' can be const
+const char *return4(char *p) {

danielmarjamaki wrote:
> rsmith wrote:
> > The wording of this warning, and the name of the check, are highly 
> > misleading.
> > 
> > It's *not* the parameter that can be const, it's the parameter's *pointee*.
> I understand. Figuring out a better message is not easy. I and a collegue 
> brain stormed:
> 
> pointer parameter 'p' could be declared with const 'const int *p'
> 
> pointer parameter 'p' could be pointer to const
> 
> pointer parameter 'p' declaration could be pointer to const
> 
> missing const in pointer parameter 'p' declaration
> 
> declaration of pointer parameter 'p' could be 'const int *p'
> 
> Do you think any of these would be good?
> 
Regarding the name of the check, I can't think of anything better only things 
that are longer but aren't substantially more clear in revealing the intent of 
the check.  IMO, you don't blindly run clang-tidy checks based on the name, you 
run them after reading what they do and deciding if you want that 
transformation or not.

In order of my preference:

  - pointer parameter 'p' could be pointer to const
  - declaration of pointer parameter 'p' could be 'const int *p'

I might use the word 'can' instead of the world 'could', but that's a very 
minor quibble.


http://reviews.llvm.org/D15332



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


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

2016-03-22 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

Looks like I forgot to remove brace initializers from the test files. I will 
fix that.

Chris Lattner has given me commit access now, so I can commit on my own.


http://reviews.llvm.org/D16529



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


Re: r263740 - Revert "For MS ABI, emit dllexport friend functions defined inline in class"

2016-03-22 Thread Reid Kleckner via cfe-commits
Ugh, templates and friend function definitions strike again!

I think this is where "semantic" vs. "lexical" DeclContexts come into play.
Try doing D->getLexicalDeclContext()->isDependentContext().

On Tue, Mar 22, 2016 at 5:23 AM, Stephan Bergmann 
wrote:

> On 03/17/2016 09:06 PM, Reid Kleckner via cfe-commits wrote:
>
>> Author: rnk
>> Date: Thu Mar 17 15:06:58 2016
>> New Revision: 263740
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=263740&view=rev
>> Log:
>> Revert "For MS ABI, emit dllexport friend functions defined inline in
>> class"
>>
>> This reverts commit r263738.
>>
>> This appears to cause a failure in
>> CXX/temp/temp.decls/temp.friend/p1.cpp
>>
>
> Ah, indeed, if you stick "-triple %ms_abi_triple" in
> test/CXX/temp/temp.decls/temp.friend/p1.cpp, it would consistently have
> failed on all platforms.
>
> The problem is with friend functions defined inline within class templates
> (instead of classes), as in
>
>   template struct S { friend void f() {} };
>
> But which MSVC apparently wouldn't emit when parsing the class template,
> anyway, so we shouldn't either.
>
> So we should filter out friend functions that are defined within class
> templates:
>
> (a) either in Parser::ParseLexedMethodDef
> (lib/Parse/ParseCXXInlineMethods.cpp) before calling
> ActOnFinishInlineFunctionDef,
>
> (b) or (probably preferably) later in the "Handle friend functions" block
> in HandleInlineFunctionDefinition (lib/CodeGen/ModuleBuilder.cpp).
>
> However, I'm having trouble how to determine that condition, in either
> case.  For (a), I thought that maybe
>
>   CurTemplateDepthTracker.getDepth() != 0
>
> could work, but apparently doesn't.  And for (b),
>
>   !D->getDeclContext()->isDependentContext()
>
> doesn't work, either (as the context of the declaration presumably isn't
> the class template, but rather the surrounding namespace).
>
> Any hints?
>
>
>
> Modified:
>>  cfe/trunk/include/clang/AST/ASTConsumer.h
>>  cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
>>  cfe/trunk/include/clang/Sema/Sema.h
>>  cfe/trunk/lib/CodeGen/CodeGenAction.cpp
>>  cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
>>  cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
>>  cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
>>  cfe/trunk/lib/Sema/SemaDecl.cpp
>>  cfe/trunk/test/CodeGenCXX/dllexport.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/ASTConsumer.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTConsumer.h?rev=263740&r1=263739&r2=263740&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/ASTConsumer.h (original)
>> +++ cfe/trunk/include/clang/AST/ASTConsumer.h Thu Mar 17 15:06:58 2016
>> @@ -55,9 +55,9 @@ public:
>> /// \returns true to continue parsing, or false to abort parsing.
>> virtual bool HandleTopLevelDecl(DeclGroupRef D);
>>
>> -  /// \brief This callback is invoked each time an inline (method or
>> friend)
>> -  /// function definition in a class is completed.
>> -  virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {}
>> +  /// \brief This callback is invoked each time an inline method
>> definition is
>> +  /// completed.
>> +  virtual void HandleInlineMethodDefinition(CXXMethodDecl *D) {}
>>
>> /// HandleInterestingDecl - Handle the specified interesting
>> declaration. This
>> /// is called by the AST reader when deserializing things that might
>> interest
>>
>> Modified: cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/MultiplexConsumer.h?rev=263740&r1=263739&r2=263740&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Frontend/MultiplexConsumer.h (original)
>> +++ cfe/trunk/include/clang/Frontend/MultiplexConsumer.h Thu Mar 17
>> 15:06:58 2016
>> @@ -36,7 +36,7 @@ public:
>> void Initialize(ASTContext &Context) override;
>> void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override;
>> bool HandleTopLevelDecl(DeclGroupRef D) override;
>> -  void HandleInlineFunctionDefinition(FunctionDecl *D) override;
>> +  void HandleInlineMethodDefinition(CXXMethodDecl *D) override;
>> void HandleInterestingDecl(DeclGroupRef D) override;
>> void HandleTranslationUnit(ASTContext &Ctx) override;
>> void HandleTagDeclDefinition(TagDecl *D) override;
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=263740&r1=263739&r2=263740&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Mar 17 15:06:58 2016
>> @@ -1773,7 +1773,7 @@ public:
>> Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body);
>> Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *B

Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-03-22 Thread Eric Fiselier via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

I think this diff is messed up a little.  Could you upload a fixed diff?


http://reviews.llvm.org/D18347



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


[clang-tools-extra] r264069 - [clang-tidy] Fix redundant-string-init check with msvc 14 headers.

2016-03-22 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Tue Mar 22 12:39:36 2016
New Revision: 264069

URL: http://llvm.org/viewvc/llvm-project?rev=264069&view=rev
Log:
[clang-tidy] Fix redundant-string-init check with msvc 14 headers.

Summary:
The string constructors are not defined using optional parameters and are not 
recognized by the redundant-string-init checker.

The following patch fixes the redundant-string-init checker for the Visual 
Studio 14 headers file.
The matcher now accept both variant (with 1 and 2 parameters).

Also added new unittests.

Similar issue than: [[ http://reviews.llvm.org/D18285 | review ]]

In the xstring.h header, the constructors are defined this way:
```
basic_string(const _Myt& _Right) [...]
basic_string(const _Myt& _Right, const _Alloc& _Al) [...]
```

Reviewers: alexfh, hokein

Subscribers: cfe-commits

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

Added:

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp?rev=264069&r1=264068&r2=264069&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp 
Tue Mar 22 12:39:36 2016
@@ -20,31 +20,48 @@ namespace {
 
 AST_MATCHER(StringLiteral, lengthIsZero) { return Node.getLength() == 0; }
 
+AST_MATCHER_P(Expr, ignoringImplicit,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  return InnerMatcher.matches(*Node.IgnoreImplicit(), Finder, Builder);
+}
+
 } // namespace
 
 void RedundantStringInitCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
 
-  const auto StringCtorExpr = cxxConstructExpr(
-  hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
-  argumentCountIs(2),
-  hasArgument(0, ignoringParenImpCasts(stringLiteral(lengthIsZero(,
-  hasArgument(1, cxxDefaultArgExpr()));
-
-  // string foo = "";
-  // OR
-  // string bar("");
+  // Match string constructor.
+  const auto StringConstructorExpr = expr(anyOf(
+  cxxConstructExpr(argumentCountIs(1),
+   hasDeclaration(cxxMethodDecl(hasName("basic_string",
+  // If present, the second argument is the alloc object which must not
+  // be present explicitly.
+  cxxConstructExpr(argumentCountIs(2),
+   hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
+   hasArgument(1, cxxDefaultArgExpr();
+
+  // Match a string constructor expression with an empty string literal.
+  const auto EmptyStringCtorExpr =
+  cxxConstructExpr(StringConstructorExpr,
+  hasArgument(0, ignoringParenImpCasts(
+ stringLiteral(lengthIsZero();
+
+  const auto EmptyStringCtorExprWithTemporaries =
+  expr(ignoringImplicit(
+  cxxConstructExpr(StringConstructorExpr,
+  hasArgument(0, ignoringImplicit(EmptyStringCtorExpr);
+
+  // Match a variable declaration with an empty string literal as initializer.
+  // Examples:
+  // string foo = "";
+  // string bar("");
   Finder->addMatcher(
   namedDecl(varDecl(hasType(cxxRecordDecl(hasName("basic_string"))),
 hasInitializer(
-expr(anyOf(StringCtorExpr,
-   exprWithCleanups(has(expr(anyOf(
-   StringCtorExpr,
-   cxxConstructExpr(hasArgument(
-   0, cxxBindTemporaryExpr(has(
-  StringCtorExpr))
-.bind("expr"
+expr(anyOf(EmptyStringCtorExpr,
+   EmptyStringCtorExprWithTemporaries))
+.bind("expr"
   .bind("decl"),
   this);
 }

Added: 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp?rev=264069&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp
 Tue Mar 22 12:39:36 2016
@@ -0,0 +1,122 @@
+// RUN: %check_clang_tidy %s readability-redundant-string-init %

[PATCH] D18360: Add AIX Target/ToolChain to Clang Driver

2016-03-22 Thread Andrew Paprocki via cfe-commits
apaprocki created this revision.
apaprocki added a subscriber: cfe-commits.

This patch adds Clang driver support for the AIX platform.  This allows Clang 
to be used for compiling code / checking for errors, but does not allow for 
building executables, as AIX uses XCOFF and not ELF.

After applying this patch and the underlying D18359:

```
$ clang -v
clang version 3.8.0 (tags/RELEASE_380/final)
Target: powerpc-ibm-aix7.1.0.0
Thread model: posix
InstalledDir: /tmp/llvm-3.8/bin
Found candidate GCC installation: 
/tmp/gcc-4.8/lib/gcc/powerpc-ibm-aix7.1.0.0/4.8.5
Selected GCC installation: /tmp/gcc-4.8/lib/gcc/powerpc-ibm-aix7.1.0.0/4.8.5
Candidate multilib: .;@maix32
Candidate multilib: ppc64;@maix64
Selected multilib: .;@maix32
```

http://reviews.llvm.org/D18360

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  tools/libclang/CIndexer.cpp

Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -643,6 +643,24 @@
   Tool *buildLinker() const override;
 };
 
+class LLVM_LIBRARY_VISIBILITY AIX : public Generic_GCC {
+public:
+  AIX(const Driver &D, const llvm::Triple &Triple,
+  const llvm::opt::ArgList &Args);
+
+  bool IsIntegratedAssemblerDefault() const override { return true; }
+
+  void AddClangCXXStdlibIncludeArgs(
+  const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const override;
+
+  unsigned GetDefaultDwarfVersion() const override { return 2; }
+
+protected:
+  Tool *buildAssembler() const override;
+  Tool *buildLinker() const override;
+};
+
 class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
 public:
   MinGW(const Driver &D, const llvm::Triple &Triple,
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -649,6 +649,34 @@
 };
 } // end namespace solaris
 
+/// aix -- Directly call AIX assembler and linker
+namespace aix {
+class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
+public:
+  Assembler(const ToolChain &TC) : Tool("aix::Assembler", "assembler", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
+
+class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
+public:
+  Linker(const ToolChain &TC) : Tool("aix::Linker", "linker", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
+}  // end namespace aix
+
 /// dragonfly -- Directly call GNU Binutils assembler and linker
 namespace dragonfly {
 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1719,13 +1719,14 @@
 // Filter to remove Multilibs that don't exist as a suffix to Path
 class FilterNonExistent {
   StringRef Base;
+  StringRef Crt;
   vfs::FileSystem &VFS;
 
 public:
-  FilterNonExistent(StringRef Base, vfs::FileSystem &VFS)
-  : Base(Base), VFS(VFS) {}
+  FilterNonExistent(StringRef Base, StringRef Crt, vfs::FileSystem &VFS)
+  : Base(Base), Crt(Crt), VFS(VFS) {}
   bool operator()(const Multilib &M) {
-return !VFS.exists(Base + M.gccSuffix() + "/crtbegin.o");
+return !VFS.exists(Base + M.gccSuffix() + Crt);
   }
 };
 } // end anonymous namespace
@@ -1811,7 +1812,7 @@
   // /usr
   //   /lib  <= crt*.o files compiled with '-mips32'
 
-  FilterNonExistent NonExistent(Path, D.getVFS());
+  FilterNonExistent NonExistent(Path, "/crtbegin.o", D.getVFS());
 
   // Check for FSF toolchain multilibs
   MultilibSet FSFMipsMultilibs;
@@ -2112,6 +2113,40 @@
   return false;
 }
 
+static bool findAIXBiarchMultilibs(const Driver &D,
+   const llvm::Triple &TargetTriple,
+   StringRef Path, const ArgList &Args,
+   bool NeedsBiarchSuffix,
+   DetectedMultilibs &Result) {
+  Multilib Default = Multilib()
+   .flag("+maix32")
+   .flag("-maix64");
+  Multilib Alt64 = Multilib()
+   .gccSuffix("/ppc64")
+   .includeSuffix("/ppc64")
+   .flag("-maix32")
+   .flag("+maix64");
+
+ 

Re: [PATCH] D17811: [clang-tidy] Add check to detect dangling references in value handlers.

2016-03-22 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

In http://reviews.llvm.org/D17811#380124, @jbcoe wrote:

> Do you have commit access? I can apply this patch for you if not.


I do.
I am waiting on http://reviews.llvm.org/D18275 to fix the problem with using 
internal::HasNameMatcher directly.


http://reviews.llvm.org/D17811



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


r264071 - StaticAnalyzer: Avoid an unintentional copy

2016-03-22 Thread Justin Bogner via cfe-commits
Author: bogner
Date: Tue Mar 22 12:50:05 2016
New Revision: 264071

URL: http://llvm.org/viewvc/llvm-project?rev=264071&view=rev
Log:
StaticAnalyzer: Avoid an unintentional copy

The range here isn't over references, so using `auto &` here incites a
copy. Switching to `auto *` would do, but we might as well list an
explicit type for clarity.

Found by -Wrange-loop-analysis.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp?rev=264071&r1=264070&r2=264071&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp Tue Mar 22 
12:50:05 2016
@@ -168,7 +168,7 @@ public:
 const ASTRecordLayout &RL) {
 CharUnits PaddingSum;
 CharUnits Offset = ASTContext.toCharUnitsFromBits(RL.getFieldOffset(0));
-for (const auto &FD : RD->fields()) {
+for (const FieldDecl *FD : RD->fields()) {
   // This checker only cares about the padded size of the
   // field, and not the data size. If the field is a record
   // with tail padding, then we won't put that number in our


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


Re: [PATCH] D18262: [clang-tidy] Skip reporting of not applicable fixes.

2016-03-22 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 51305.
etienneb added a comment.

rebase + fixing invalid paths


http://reviews.llvm.org/D18262

Files:
  clang-tidy/ClangTidy.cpp
  test/clang-tidy/misc-macro-parentheses-cmdline.cpp

Index: test/clang-tidy/misc-macro-parentheses-cmdline.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-macro-parentheses-cmdline.cpp
@@ -0,0 +1,10 @@
+// RUN: %check_clang_tidy %s misc-macro-parentheses %t -- -- -DVAL=0+0
+
+// The previous command-line is producing warnings and fixes with the source
+// locations from a virtual buffer. VAL is replaced by '0+0'.
+// Fixes could not be applied and should not be reported.
+int foo() { return VAL; }
+
+#define V 0+0
+int bar() { return V; }
+// CHECK-FIXES: #define V (0+0)
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -128,13 +128,20 @@
   auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
   << Message.Message << Name;
   for (const tooling::Replacement &Fix : Error.Fix) {
-SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
-Files.makeAbsolutePath(FixAbsoluteFilePath);
-SourceLocation FixLoc =
-getLocation(FixAbsoluteFilePath, Fix.getOffset());
-SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
-Diag << FixItHint::CreateReplacement(SourceRange(FixLoc, FixEndLoc),
- Fix.getReplacementText());
+// Retrieve the source range for applicable fixes. Macro definitions
+// on the command line have locations in a virtual buffer and don't
+// have valid file paths and are therefore not applicable.
+SourceRange Range;
+SourceLocation FixLoc;
+if (Fix.isApplicable()) {
+  SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
+  Files.makeAbsolutePath(FixAbsoluteFilePath);
+  FixLoc = getLocation(FixAbsoluteFilePath, Fix.getOffset());
+  SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
+  Range = SourceRange(FixLoc, FixEndLoc);
+  Diag << FixItHint::CreateReplacement(Range, 
Fix.getReplacementText());
+}
+  
 ++TotalFixes;
 if (ApplyFixes) {
   bool Success = Fix.isApplicable() && Fix.apply(Rewrite);


Index: test/clang-tidy/misc-macro-parentheses-cmdline.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-macro-parentheses-cmdline.cpp
@@ -0,0 +1,10 @@
+// RUN: %check_clang_tidy %s misc-macro-parentheses %t -- -- -DVAL=0+0
+
+// The previous command-line is producing warnings and fixes with the source
+// locations from a virtual buffer. VAL is replaced by '0+0'.
+// Fixes could not be applied and should not be reported.
+int foo() { return VAL; }
+
+#define V 0+0
+int bar() { return V; }
+// CHECK-FIXES: #define V (0+0)
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -128,13 +128,20 @@
   auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
   << Message.Message << Name;
   for (const tooling::Replacement &Fix : Error.Fix) {
-SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
-Files.makeAbsolutePath(FixAbsoluteFilePath);
-SourceLocation FixLoc =
-getLocation(FixAbsoluteFilePath, Fix.getOffset());
-SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
-Diag << FixItHint::CreateReplacement(SourceRange(FixLoc, FixEndLoc),
- Fix.getReplacementText());
+// Retrieve the source range for applicable fixes. Macro definitions
+// on the command line have locations in a virtual buffer and don't
+// have valid file paths and are therefore not applicable.
+SourceRange Range;
+SourceLocation FixLoc;
+if (Fix.isApplicable()) {
+  SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
+  Files.makeAbsolutePath(FixAbsoluteFilePath);
+  FixLoc = getLocation(FixAbsoluteFilePath, Fix.getOffset());
+  SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
+  Range = SourceRange(FixLoc, FixEndLoc);
+  Diag << FixItHint::CreateReplacement(Range, Fix.getReplacementText());
+}
+  
 ++TotalFixes;
 if (ApplyFixes) {
   bool Success = Fix.isApplicable() && Fix.apply(Rewrite);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r264073 - [clang-tidy] Skip reporting of not applicable fixes.

2016-03-22 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Tue Mar 22 12:51:27 2016
New Revision: 264073

URL: http://llvm.org/viewvc/llvm-project?rev=264073&view=rev
Log:
[clang-tidy] Skip reporting of not applicable fixes.

Summary:
Invalid source location are causing clang-tidy to crash when manipulating an 
invalid file.

Macro definitions on the command line have locations in a virtual buffer and 
therefore
don't have a corresponding valid FilePath.

A recent patch added path conversion to absolute path. As the FilePath may now 
be empty,
the result of makeAbsolutePath may incorrectly be the folder WorkingDir.  The 
crash occurs
in getLocation which is not able to find the appropriate FileEntry (null 
pointer).

```
  SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
  Files.makeAbsolutePath(FixAbsoluteFilePath);
  FixLoc = getLocation(FixAbsoluteFilePath, Fix.getOffset());
```

With relative path, the code was not crashing because getLocation was skipping 
empty path.



Example of code:

```
int main() { return X; }
```

With the given command-line:

```
clang-tidy test.cc --checks=misc-macro-*  --  -DX=0+0
```

Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

Added:
clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses-cmdline.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=264073&r1=264072&r2=264073&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Tue Mar 22 12:51:27 2016
@@ -128,13 +128,20 @@ public:
   auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
   << Message.Message << Name;
   for (const tooling::Replacement &Fix : Error.Fix) {
-SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
-Files.makeAbsolutePath(FixAbsoluteFilePath);
-SourceLocation FixLoc =
-getLocation(FixAbsoluteFilePath, Fix.getOffset());
-SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
-Diag << FixItHint::CreateReplacement(SourceRange(FixLoc, FixEndLoc),
- Fix.getReplacementText());
+// Retrieve the source range for applicable fixes. Macro definitions
+// on the command line have locations in a virtual buffer and don't
+// have valid file paths and are therefore not applicable.
+SourceRange Range;
+SourceLocation FixLoc;
+if (Fix.isApplicable()) {
+  SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
+  Files.makeAbsolutePath(FixAbsoluteFilePath);
+  FixLoc = getLocation(FixAbsoluteFilePath, Fix.getOffset());
+  SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
+  Range = SourceRange(FixLoc, FixEndLoc);
+  Diag << FixItHint::CreateReplacement(Range, 
Fix.getReplacementText());
+}
+  
 ++TotalFixes;
 if (ApplyFixes) {
   bool Success = Fix.isApplicable() && Fix.apply(Rewrite);

Added: 
clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses-cmdline.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses-cmdline.cpp?rev=264073&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses-cmdline.cpp 
(added)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses-cmdline.cpp 
Tue Mar 22 12:51:27 2016
@@ -0,0 +1,10 @@
+// RUN: %check_clang_tidy %s misc-macro-parentheses %t -- -- -DVAL=0+0
+
+// The previous command-line is producing warnings and fixes with the source
+// locations from a virtual buffer. VAL is replaced by '0+0'.
+// Fixes could not be applied and should not be reported.
+int foo() { return VAL; }
+
+#define V 0+0
+int bar() { return V; }
+// CHECK-FIXES: #define V (0+0)


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


Re: [PATCH] D17821: [OpenCL] Complete image types support

2016-03-22 Thread Anastasia Stulova via cfe-commits
Anastasia updated this revision to Diff 51303.
Anastasia added a comment.

Thanks to Aleksey Bader for rebasing this patch to ToT and fixing some tests 
issues!


http://reviews.llvm.org/D17821

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/OpenCLImageTypes.def
  include/clang/AST/Type.h
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/CodeGenOpenCL/images.cl
  test/CodeGenOpenCL/opencl_types.cl
  test/SemaOpenCL/images.cl
  test/SemaOpenCL/invalid-access-qualifier.cl
  test/SemaOpenCL/invalid-image.cl
  test/SemaOpenCL/invalid-kernel-parameters.cl
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1454,18 +1454,9 @@
   case BuiltinType::Void:
   case BuiltinType::NullPtr:
   case BuiltinType::Dependent:
-  case BuiltinType::OCLImage1d:
-  case BuiltinType::OCLImage1dArray:
-  case BuiltinType::OCLImage1dBuffer:
-  case BuiltinType::OCLImage2d:
-  case BuiltinType::OCLImage2dArray:
-  case BuiltinType::OCLImage2dDepth:
-  case BuiltinType::OCLImage2dArrayDepth:
-  case BuiltinType::OCLImage2dMSAA:
-  case BuiltinType::OCLImage2dArrayMSAA:
-  case BuiltinType::OCLImage2dMSAADepth:
-  case BuiltinType::OCLImage2dArrayMSAADepth:
-  case BuiltinType::OCLImage3d:
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)   \
+  case BuiltinType::Id:
+#include "clang/AST/OpenCLImageTypes.def"
   case BuiltinType::OCLSampler:
   case BuiltinType::OCLEvent:
   case BuiltinType::OCLClkEvent:
Index: test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- test/SemaOpenCL/invalid-kernel-parameters.cl
+++ test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -27,7 +27,7 @@
   // TODO: Clean up needed - we don't really need to check for image, event, etc
   // as a note here any longer.
   // They are diagnosed as an error for all struct fields (OpenCL v1.2 s6.9b,r).
-  image2d_t imageField; // expected-note{{field of illegal type 'image2d_t' declared here}} expected-error{{the 'image2d_t' type cannot be used to declare a structure or union field}}
+  image2d_t imageField; // expected-note{{field of illegal type '__read_only image2d_t' declared here}} expected-error{{the '__read_only image2d_t' type cannot be used to declare a structure or union field}}
 } FooImage2D;
 
 kernel void image_in_struct_arg(FooImage2D arg) { } // expected-error{{struct kernel parameters may not contain pointers}}
Index: test/SemaOpenCL/invalid-image.cl
===
--- test/SemaOpenCL/invalid-image.cl
+++ test/SemaOpenCL/invalid-image.cl
@@ -1,8 +1,8 @@
 // RUN: %clang_cc1 -verify %s
 
-void test1(image1d_t *i){} // expected-error {{pointer to type 'image1d_t' is invalid in OpenCL}}
+void test1(image1d_t *i){} // expected-error {{pointer to type '__read_only image1d_t' is invalid in OpenCL}}
 
 void test2(image1d_t i) {
-  image1d_t ti; // expected-error {{type 'image1d_t' can only be used as a function parameter}}
-  image1d_t ai[] = {i,i};// expected-error {{array of 'image1d_t' type is invalid in OpenCL}}
+  image1d_t ti; // expected-error {{type '__read_only image1d_t' can only be used as a function parameter}}
+  image1d_t ai[] = {i,i};// expected-error {{array of '__read_only image1d_t' type is invalid in OpenCL}}
 }
Index: test/SemaOpenCL/invalid-access-qualifier.cl
===
--- test/SemaOpenCL/invalid-access-qualifier.cl
+++ test/SemaOpenCL/invalid-access-qualifier.cl
@@ -10,5 +10,5 @@
 #ifdef CL20
 void test4(read_write pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'pipe'}}
 #else
-void test4(__read_write image1d_t i){} // expected-error{{access qualifier '__read_write' can not be used for 'image1d_t' earlier than OpenCL2.0 version}}
+void test4(__read_write image1d_t i){} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' earlier than OpenCL2.0 version}}
 #endif
Index: test/SemaOpenCL/im

[clang-tools-extra] r264075 - [clang-tidy] Fix redundant-string-cstr check with msvc 14 headers.

2016-03-22 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Tue Mar 22 13:00:13 2016
New Revision: 264075

URL: http://llvm.org/viewvc/llvm-project?rev=264075&view=rev
Log:
[clang-tidy] Fix redundant-string-cstr check with msvc 14 headers.

Summary:
The string constructors are not defined using optional parameters and are not 
recognize by the checker.

The constructor defined in the MSVC header is defined with 1 parameter. 
Therefore, patterns are not recognized by the checker.
The current patch add support to accept constructor with only one parameter.

Repro on a Visual Studio 14 installation with the following code:
```
void f1(const std::string &s) {
  f1(s.c_str());
}
```

In the xstring.h header, the constructors are defined this way:
```
basic_string(const _Myt& _Right) [...]
basic_string(const _Myt& _Right, const _Alloc& _Al) [...]
```

The CXXConstructExpr to recognize only contains 1 parameter.
```
CXXConstructExpr 0x3f1a070  'const 
std::string':'const class std::basic_string, class
 std::allocator >' 'void (const char *) __attribute__((thiscall))'
`-CXXMemberCallExpr 0x3f1a008  'const char *'
  `-MemberExpr 0x3f19fe0  '' .c_str 
0x3cc22f8
`-DeclRefExpr 0x3f19fc8  'const std::string':'const class 
std::basic_string, class 
std::allocator >' lvalue ParmVar 0x3f19c80 's' 'const std::string &'
```

Reviewers: aaron.ballman, alexfh

Subscribers: aemerson

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

Added:

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp?rev=264075&r1=264074&r2=264075&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp 
Tue Mar 22 13:00:13 2016
@@ -85,23 +85,29 @@ void RedundantStringCStrCheck::registerM
   if (!getLangOpts().CPlusPlus)
 return;
 
-  Finder->addMatcher(
+  // Match string constructor.
+  const auto StringConstructorExpr = expr(anyOf(
+  cxxConstructExpr(
+  argumentCountIs(1),
+  hasDeclaration(cxxMethodDecl(hasName(StringConstructor,
   cxxConstructExpr(
-  hasDeclaration(cxxMethodDecl(hasName(StringConstructor))),
   argumentCountIs(2),
-  // The first argument must have the form x.c_str() or p->c_str()
-  // where the method is string::c_str().  We can use the copy
-  // constructor of string instead (or the compiler might share
-  // the string object).
-  hasArgument(0, cxxMemberCallExpr(
- callee(memberExpr().bind("member")),
- callee(cxxMethodDecl(hasName(StringCStrMethod))),
- on(expr().bind("arg")))
- .bind("call")),
-  // The second argument is the alloc object which must not be
-  // present explicitly.
-  hasArgument(1, cxxDefaultArgExpr())),
+  hasDeclaration(cxxMethodDecl(hasName(StringConstructor))),
+  // If present, the second argument is the alloc object which must not
+  // be present explicitly.
+  hasArgument(1, cxxDefaultArgExpr();
+
+  // Match a call to the string 'c_str()' method.
+  const auto StringCStrCallExpr = cxxMemberCallExpr(
+callee(memberExpr().bind("member")),
+callee(cxxMethodDecl(hasName(StringCStrMethod))),
+on(expr().bind("arg"))).bind("call");
+
+  Finder->addMatcher(
+  cxxConstructExpr(StringConstructorExpr,
+   hasArgument(0, StringCStrCallExpr)),
   this);
+
   Finder->addMatcher(
   cxxConstructExpr(
   // Implicit constructors of these classes are overloaded
@@ -117,11 +123,7 @@ void RedundantStringCStrCheck::registerM
   // a constructor from string which is more efficient (avoids
   // strlen), so we can construct StringRef from the string
   // directly.
-  hasArgument(0, cxxMemberCallExpr(
- callee(memberExpr().bind("member")),
- callee(cxxMethodDecl(hasName(StringCStrMethod))),
- on(expr().bind("arg")))
- .bind("call"))),
+  hasArgument(0, StringCStrCallExpr)),
   this);
 }
 

Added: 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp?rev=264075&view=auto
=

Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

2016-03-22 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:84
@@ +83,3 @@
+// Can E value be greater or equal than Val?
+static bool canBeGreaterEqual(CheckerContext &C, const Expr *E,
+  unsigned long long Val) {

danielmarjamaki wrote:
> zaks.anna wrote:
> > This function returns true if the value "is" greater or equal, not "can be" 
> > greater or equal. The latter would be "return StGE".
> > 
> > Also, it's slightly better to return the StGE state and use it to report 
> > the bug. This way, our assumption is explicitly recorded in the error state.
> NoQ made the same comment. I disagree.
> 
> int A = 0;
> if (X) {
>  A = 1000;
> }
> U8 = A;  // <- Imho; A _can_ be 1000
> 
> Imho it's better to say that A _can_ be 1000 unless A is 1000 for all 
> possible execution paths through the code.
> 
> Do you still think "is" is better than "can be"?
The Clang Static Analyzer performs path sensitive analysis of the program. (It 
does not merge the paths at the "U8 = A" statement!!!) You will only be 
changing the state along a single execution path of this program. Along that 
path, A will always be 1000. 

When analyzing your example, the analyzer is going to separately analyze 2 
paths:
1st path: A=0; X != 0; A =1000; U8 = A; // Here U8 is definitely 1000.
2d  path: A=0; X == 0; U8 = A;   // Here U8 is definitely 0.

This video contains an intuitive explanation of symbolic execution technique we 
use: http://llvm.org/devmtg/2012-11/videos/Zaks-Rose-Checker24Hours.mp4


http://reviews.llvm.org/D13126



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


Re: r264071 - StaticAnalyzer: Avoid an unintentional copy

2016-03-22 Thread David Blaikie via cfe-commits
On Tue, Mar 22, 2016 at 10:50 AM, Justin Bogner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: bogner
> Date: Tue Mar 22 12:50:05 2016
> New Revision: 264071
>
> URL: http://llvm.org/viewvc/llvm-project?rev=264071&view=rev
> Log:
> StaticAnalyzer: Avoid an unintentional copy
>

Just to be clear - it sounds like a copy happens here regardless. It's just
best to be explicit so readers aren't confused about that. (sounds like the
iterator produces results by value (probably non-standard for an iterator
to do that, but probably not uncommon) & so taking a reference to it does
reference lifetime extension, etc) Now we're being explicit aobut the
pointer being copied, rather than implying that we refer to a pointer kept
inside the sequence/container.


>
> The range here isn't over references, so using `auto &` here incites a
> copy. Switching to `auto *` would do, but we might as well list an
> explicit type for clarity.
>
> Found by -Wrange-loop-analysis.
>
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp?rev=264071&r1=264070&r2=264071&view=diff
>
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp Tue Mar 22
> 12:50:05 2016
> @@ -168,7 +168,7 @@ public:
>  const ASTRecordLayout &RL) {
>  CharUnits PaddingSum;
>  CharUnits Offset =
> ASTContext.toCharUnitsFromBits(RL.getFieldOffset(0));
> -for (const auto &FD : RD->fields()) {
> +for (const FieldDecl *FD : RD->fields()) {
>// This checker only cares about the padded size of the
>// field, and not the data size. If the field is a record
>// with tail padding, then we won't put that number in our
>
>
> ___
> 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] D18363: Fix typo s/initalize/initialize/

2016-03-22 Thread Stephen Hines via cfe-commits
srhines accepted this revision.
srhines added a comment.
This revision is now accepted and ready to land.

I think this is trivial enough for me to accept. I also added cfe-commits, so 
that they at least have a chance to review/comment.


Repository:
  rL LLVM

http://reviews.llvm.org/D18363



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


[PATCH] D18365: [clang-tidy] Fix broken test with redundant string init (msvc).

2016-03-22 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added reviewers: rnk, alexfh.
etienneb added a subscriber: cfe-commits.

There is a silly bug that got introduced after fixing incorrect paths with this 
patch:
http://reviews.llvm.org/D18293

The tests was present twice in the file.

http://reviews.llvm.org/D18365

Files:
  test/clang-tidy/readability-redundant-string-init-msvc.cpp

Index: test/clang-tidy/readability-redundant-string-init-msvc.cpp
===
--- test/clang-tidy/readability-redundant-string-init-msvc.cpp
+++ test/clang-tidy/readability-redundant-string-init-msvc.cpp
@@ -59,64 +59,3 @@
   std::wstring y(LR"(y)");
   std::wstring z;
 }
-// RUN: %check_clang_tidy %s readability-redundant-string-init %t
-
-namespace std {
-template 
-class allocator {};
-template 
-class char_traits {};
-template , typename A = 
std::allocator>
-struct basic_string {
-  basic_string();
-  basic_string(const basic_string&);
-  // MSVC headers define two constructors instead of using optional arguments.
-  basic_string(const C *);
-  basic_string(const C *, const A &);
-  ~basic_string();
-};
-typedef basic_string string;
-typedef basic_string wstring;
-}
-
-void f() {
-  std::string a = "";
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization 
[readability-redundant-string-init]
-  // CHECK-FIXES: std::string a;
-  std::string b("");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string b;
-  std::string c = R"()";
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string c;
-  std::string d(R"()");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string d;
-
-  std::string u = "u";
-  std::string w("w");
-  std::string x = R"(x)";
-  std::string y(R"(y)");
-  std::string z;
-}
-
-void g() {
-  std::wstring a = L"";
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring a;
-  std::wstring b(L"");
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring b;
-  std::wstring c = LR"()";
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring c;
-  std::wstring d(LR"()");
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring d;
-
-  std::wstring u = L"u";
-  std::wstring w(L"w");
-  std::wstring x = LR"(x)";
-  std::wstring y(LR"(y)");
-  std::wstring z;
-}


Index: test/clang-tidy/readability-redundant-string-init-msvc.cpp
===
--- test/clang-tidy/readability-redundant-string-init-msvc.cpp
+++ test/clang-tidy/readability-redundant-string-init-msvc.cpp
@@ -59,64 +59,3 @@
   std::wstring y(LR"(y)");
   std::wstring z;
 }
-// RUN: %check_clang_tidy %s readability-redundant-string-init %t
-
-namespace std {
-template 
-class allocator {};
-template 
-class char_traits {};
-template , typename A = std::allocator>
-struct basic_string {
-  basic_string();
-  basic_string(const basic_string&);
-  // MSVC headers define two constructors instead of using optional arguments.
-  basic_string(const C *);
-  basic_string(const C *, const A &);
-  ~basic_string();
-};
-typedef basic_string string;
-typedef basic_string wstring;
-}
-
-void f() {
-  std::string a = "";
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization [readability-redundant-string-init]
-  // CHECK-FIXES: std::string a;
-  std::string b("");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string b;
-  std::string c = R"()";
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string c;
-  std::string d(R"()");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string d;
-
-  std::string u = "u";
-  std::string w("w");
-  std::string x = R"(x)";
-  std::string y(R"(y)");
-  std::string z;
-}
-
-void g() {
-  std::wstring a = L"";
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring a;
-  std::wstring b(L"");
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring b;
-  std::wstring c = LR"()";
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring c;
-  std::wstring d(LR"()");
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring d;
-
-  std::wstring u = L"u";
-  std::wstring w(L"w");
-  std::wstring x = LR"(x)";
-  std::wstring y(LR"(y)");
-  std::wstring z;
-}
___
cfe-commits mailing list
cfe-commits@lists

Re: [PATCH] D18365: [clang-tidy] Fix broken test with redundant string init (msvc).

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

lgtm


http://reviews.llvm.org/D18365



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


Re: [PATCH] D17955: [OpenCL] Fix pipe builtin bugs

2016-03-22 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl:1
@@ -1,2 +1,2 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 

Could you add a test case that fails before your modification here to show that 
your change improves on it!


http://reviews.llvm.org/D17955



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


Re: [PATCH] D17596: [OpenCL] Add ocl and spir version for spir target

2016-03-22 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM!


http://reviews.llvm.org/D17596



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


[clang-tools-extra] r264080 - [clang-tidy] Fix broken test with redundant string init (msvc).

2016-03-22 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Tue Mar 22 13:21:17 2016
New Revision: 264080

URL: http://llvm.org/viewvc/llvm-project?rev=264080&view=rev
Log:
[clang-tidy] Fix broken test with redundant string init (msvc).

Summary:
There is a silly bug that got introduced after fixing incorrect paths with this 
patch:
http://reviews.llvm.org/D18293

The tests was present twice in the file.

Reviewers: alexfh, rnk

Subscribers: cfe-commits

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

Modified:

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp?rev=264080&r1=264079&r2=264080&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp
 Tue Mar 22 13:21:17 2016
@@ -59,64 +59,3 @@ void g() {
   std::wstring y(LR"(y)");
   std::wstring z;
 }
-// RUN: %check_clang_tidy %s readability-redundant-string-init %t
-
-namespace std {
-template 
-class allocator {};
-template 
-class char_traits {};
-template , typename A = 
std::allocator>
-struct basic_string {
-  basic_string();
-  basic_string(const basic_string&);
-  // MSVC headers define two constructors instead of using optional arguments.
-  basic_string(const C *);
-  basic_string(const C *, const A &);
-  ~basic_string();
-};
-typedef basic_string string;
-typedef basic_string wstring;
-}
-
-void f() {
-  std::string a = "";
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization 
[readability-redundant-string-init]
-  // CHECK-FIXES: std::string a;
-  std::string b("");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string b;
-  std::string c = R"()";
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string c;
-  std::string d(R"()");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string d;
-
-  std::string u = "u";
-  std::string w("w");
-  std::string x = R"(x)";
-  std::string y(R"(y)");
-  std::string z;
-}
-
-void g() {
-  std::wstring a = L"";
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring a;
-  std::wstring b(L"");
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring b;
-  std::wstring c = LR"()";
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring c;
-  std::wstring d(LR"()");
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring d;
-
-  std::wstring u = L"u";
-  std::wstring w(L"w");
-  std::wstring x = LR"(x)";
-  std::wstring y(LR"(y)");
-  std::wstring z;
-}


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


Re: [PATCH] D17552: Pass -backend-option to LLVM when there is no target machine

2016-03-22 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM, apart from small remark on the test!



Comment at: test/Frontend/backend-option.c:2
@@ +1,3 @@
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - 2>&1 | 
FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - -triple 
spir-unknown-unknown 2>&1 | FileCheck %s
+// CHECK: Pass execution timing report

I think conceptually it's not correct to pass spir target with C module, 
although it doesn't make any difference here for this test. I would still 
change it to some x86 one.


http://reviews.llvm.org/D17552



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


Re: [PATCH] D18325: export additional header modules from xmmintrin

2016-03-22 Thread John Thompson via cfe-commits
jtsoftware edited reviewers, added: rsmith; removed: probinson, silvas.
jtsoftware updated this revision to Diff 51313.
jtsoftware added a comment.

Right.  Also undoing moving stuff around.  How about this?  Thanks.


http://reviews.llvm.org/D18325

Files:
  lib/Headers/module.modulemap
  test/Headers/xmmintrin.c

Index: test/Headers/xmmintrin.c
===
--- test/Headers/xmmintrin.c
+++ test/Headers/xmmintrin.c
@@ -23,3 +23,7 @@
   return _mm_add_sd(__a, __b);
 }
 
+#if __STDC_HOSTED__
+// Make sure stdlib.h symbols are accessible.
+void *p = NULL;
+#endif
Index: lib/Headers/module.modulemap
===
--- lib/Headers/module.modulemap
+++ lib/Headers/module.modulemap
@@ -44,6 +44,7 @@
 }
 
 explicit module sse {
+  export mm_malloc
   export mmx
   export sse2 // note: for hackish  dependency
   header "xmmintrin.h"


Index: test/Headers/xmmintrin.c
===
--- test/Headers/xmmintrin.c
+++ test/Headers/xmmintrin.c
@@ -23,3 +23,7 @@
   return _mm_add_sd(__a, __b);
 }
 
+#if __STDC_HOSTED__
+// Make sure stdlib.h symbols are accessible.
+void *p = NULL;
+#endif
Index: lib/Headers/module.modulemap
===
--- lib/Headers/module.modulemap
+++ lib/Headers/module.modulemap
@@ -44,6 +44,7 @@
 }
 
 explicit module sse {
+  export mm_malloc
   export mmx
   export sse2 // note: for hackish  dependency
   header "xmmintrin.h"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17552: Pass -backend-option to LLVM when there is no target machine

2016-03-22 Thread Yaxun Liu via cfe-commits
yaxunl marked an inline comment as done.


Comment at: test/Frontend/backend-option.c:2
@@ +1,3 @@
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - 2>&1 | 
FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - -triple 
spir-unknown-unknown 2>&1 | FileCheck %s
+// CHECK: Pass execution timing report

Anastasia wrote:
> I think conceptually it's not correct to pass spir target with C module, 
> although it doesn't make any difference here for this test. I would still 
> change it to some x86 one.
if we change it to x86, it has a target machine, so the test no longer 
reproduce the original issue.

How about add -x cl for the second command to force the source to be treated as 
cl source code, then it can reproduce the original issue and at the same time 
is valid for spir target?


http://reviews.llvm.org/D17552



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


Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-03-22 Thread Richard Barton via cfe-commits
richard.barton.arm updated this revision to Diff 51316.
richard.barton.arm added a comment.

Sorry - not sure what happened there. That looks better for me.


http://reviews.llvm.org/D18347

Files:
  test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp

Index: 
test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
===
--- 
test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
+++ 
test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// REQUIRES: thread-safety
+
 // 
 
 // This test does not define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS so it


Index: test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
===
--- test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
+++ test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// REQUIRES: thread-safety
+
 // 
 
 // This test does not define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS so it
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-03-22 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I don't actually understand this change. This test should compile with or 
without "-Wthread-safety" warning. This test doesn't actually turn the 
annotations on, that's the point. If annotations were actually enabled this 
test would fail to compile.

Could you explain the error your seeing here?


http://reviews.llvm.org/D18347



___
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-03-22 Thread Sean Silva via cfe-commits
Thanks!

On Tue, Mar 22, 2016 at 9:34 AM, Chris Bieneman  wrote:

> Sean,
>
> All good feedback.
>
> Using print_function was done in r257936 with some other feedback from
> Bogner.
>
> The rest of your feedback I believe I have addressed in r264063.
>
> -Chris
>
> On Mar 21, 2016, at 9:21 PM, Sean Silva  wrote:
>
>
>
> On Fri, Jan 15, 2016 at 1:21 PM, Chris Bieneman via cfe-commits <
> cfe-commits@lists.llvm.org> 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.
>>
>> 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
>>
>> ===

Re: [PATCH] D17552: Pass -backend-option to LLVM when there is no target machine

2016-03-22 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/Frontend/backend-option.c:2
@@ +1,3 @@
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - 2>&1 | 
FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - -triple 
spir-unknown-unknown 2>&1 | FileCheck %s
+// CHECK: Pass execution timing report

yaxunl wrote:
> Anastasia wrote:
> > I think conceptually it's not correct to pass spir target with C module, 
> > although it doesn't make any difference here for this test. I would still 
> > change it to some x86 one.
> if we change it to x86, it has a target machine, so the test no longer 
> reproduce the original issue.
> 
> How about add -x cl for the second command to force the source to be treated 
> as cl source code, then it can reproduce the original issue and at the same 
> time is valid for spir target?
Sure!


http://reviews.llvm.org/D17552



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


Buildbot numbers for week of 3/06/2016 - 3/12/2016

2016-03-22 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 3/06/2016 - 3/12/2016.

Thanks

Galina


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):

 buildername| builds |
changes | status change ratio
++-+-
 perf-x86_64-penryn-O3-polly| 62 |
39 |62.9
 clang-ppc64le-linux-lnt| 81 |
40 |49.4
 perf-x86_64-penryn-O3-polly-parallel-fast  |179 |
87 |48.6
 lldb-windows7-android  | 93 |
43 |46.2
 libcxx-libcxxabi-x86_64-linux-debian   |  8
|   3 |37.5
 clang-cmake-armv7-a15-selfhost | 33 |
10 |30.3
 sanitizer-x86_64-linux | 86 |
22 |25.6
 lldb-x86_64-ubuntu-14.04-android   |117 |
30 |25.6
 lldb-x86_64-darwin-13.4|114 |
26 |22.8
 clang-cmake-aarch64-full   | 38
|   6 |15.8
 clang-ppc64be-linux-multistage |126 |
19 |15.1
 clang-x86-win2008-selfhost |129 |
17 |13.2
 clang-cmake-armv7-a15  |144 |
18 |12.5
 sanitizer-ppc64le-linux| 49
|   6 |12.2
 sanitizer-x86_64-linux-bootstrap   | 51
|   6 |11.8
 llvm-clang-lld-x86_64-debian-fast  |173 |
20 |11.6
 sanitizer-ppc64be-linux|103 |
11 |10.7
 clang-cmake-thumbv7-a15|154 |
16 |10.4
 lldb-x86_64-ubuntu-14.04-cmake |196 |
20 |10.2
 clang-ppc64le-linux|177 |
18 |10.2
 clang-cmake-aarch64-quick  |143 |
14 | 9.8
 llvm-mips-linux| 62
|   6 | 9.7
 clang-x64-ninja-win7   |166 |
15 | 9.0
 clang-ppc64be-linux-lnt|201 |
18 | 9.0
 sanitizer-x86_64-linux-fast|182 |
16 | 8.8
 clang-ppc64be-linux|228 |
20 | 8.8
 clang-cmake-armv7-a15-selfhost-neon| 23
|   2 | 8.7
 clang-cmake-mips   | 95
|   8 | 8.4
 clang-bpf-build|247 |
20 | 8.1
 clang-atom-d525-fedora-rel | 76
|   6 | 7.9
 clang-s390x-linux  |231 |
18 | 7.8
 clang-cmake-aarch64-42vma  |156 |
12 | 7.7
 clang-x86_64-debian-fast   |130 |
10 | 7.7
 lldb-x86-windows-msvc2015  |181 |
12 | 6.6
 clang-hexagon-elf  |244 |
16 | 6.6
 clang-cmake-armv7-a15-full | 96
|   6 | 6.3
 lldb-x86_64-ubuntu-14.04-buildserver   |136
|   8 | 5.9
 perf-x86_64-penryn-O3-polly-unprofitable   |182 |
10 | 5.5
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   |335 |
18 | 5.4
 lldb-amd64-ninja-freebsd11 |279 |
14 | 5.0
 polly-amd64-linux  |174
|   8 | 4.6
 sanitizer-x86_64-linux-fuzzer  |174
|   8 | 4.6
 lld-x86_64-win7|175
|   8 | 4.6
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast |335 |
14 | 4.2
 llvm-sphinx-docs   | 88
|   3 | 3.4
 lld-x86_64-darwin13|123
|   4 | 3.3
 llvm-hexagon-elf   |1

Buildbot numbers for week of 3/13/2016 - 3/19/2016

2016-03-22 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 3/13/2016 - 3/19/2016.

Thanks

Galina


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):

 buildername| builds |
changes | status change ratio
++-+-
 perf-x86_64-penryn-O3-polly| 51 |
38 |74.5
 perf-x86_64-penryn-O3-polly-parallel-fast  |203 |
115 |56.7
 clang-ppc64le-linux-lnt| 79 |
44 |55.7
 lldb-x86_64-darwin-13.4|118 |
43 |36.4
 lldb-windows7-android  | 96 |
18 |18.8
 clang-x86-win2008-selfhost | 94 |
16 |17.0
 clang-x64-ninja-win7   |157 |
26 |16.6
 sanitizer-ppc64le-linux| 50
|   8 |16.0
 sanitizer-x86_64-linux | 89 |
14 |15.7
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 13
|   2 |15.4
 sanitizer-x86_64-linux-bootstrap   | 47
|   6 |12.8
 clang-cmake-armv7-a15-selfhost | 33
|   4 |12.1
 perf-x86_64-penryn-O3-polly-fast   | 20
|   2 |10.0
 lldb-x86_64-ubuntu-14.04-cmake |200 |
20 |10.0
 clang-atom-d525-fedora-rel | 89
|   8 | 9.0
 perf-x86_64-penryn-O3  | 45
|   4 | 8.9
 lldb-x86_64-ubuntu-14.04-android   |117 |
10 | 8.5
 clang-native-aarch64-full  | 12
|   1 | 8.3
 clang-ppc64be-linux-multistage |124 |
10 | 8.1
 clang-cmake-aarch64-full   | 37
|   3 | 8.1
 clang-bpf-build|253 |
20 | 7.9
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   |311 |
22 | 7.1
 clang-ppc64be-linux-lnt|197 |
14 | 7.1
 lld-x86_64-freebsd |173 |
12 | 6.9
 clang-s390x-linux  |232 |
16 | 6.9
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast |310 |
20 | 6.5
 clang-hexagon-elf  |248 |
16 | 6.5
 lld-x86_64-darwin13|236 |
15 | 6.4
 clang-cmake-aarch64-quick  |140
|   9 | 6.4
 clang-cmake-thumbv7-a15|158 |
10 | 6.3
 clang-ppc64be-linux|229 |
14 | 6.1
 sanitizer-ppc64be-linux|104
|   6 | 5.8
 clang-cmake-armv7-a15  |146
|   8 | 5.5
 llvm-clang-lld-x86_64-debian-fast  |154
|   8 | 5.2
 llvm-hexagon-elf   |192 |
10 | 5.2
 clang-native-arm-lnt   |122
|   6 | 4.9
 clang-ppc64le-linux|170
|   8 | 4.7
 lld-x86_64-win7|239 |
10 | 4.2
 clang-cmake-armv7-a15-full |101
|   4 | 4.0
 perf-x86_64-penryn-O3-polly-unprofitable   |167
|   6 | 3.6
 llvm-mips-linux| 59
|   2 | 3.4
 sanitizer-x86_64-linux-fast|187
|   6 | 3.2
 clang-x86_64-linux-abi-test|258
|   8 | 3.1
 polly-amd64-linux  |194
|   6 | 3.1
 lldb-amd64-ninja-netbsd7   |135
|   4 | 3.0
 lldb-x86-windows-msvc2015  |169
|   5 | 3.0
 sanitizer-x86_64-li

Re: [PATCH] D18325: export additional header modules from xmmintrin

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

LGTM


http://reviews.llvm.org/D18325



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


Re: [PATCH] D18199: CodeGen: Implement IR generation for the relative vtable ABI (PR26723).

2016-03-22 Thread Peter Collingbourne via cfe-commits
pcc updated this revision to Diff 51324.
pcc added a comment.

- Use llvm.load.relative (http://reviews.llvm.org/D18367)


http://reviews.llvm.org/D18199

Files:
  docs/UsersManual.rst
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CGVTables.h
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/debug-info-virtual-fn-relative.cpp
  test/CodeGenCXX/vtable-relative-abi.cpp

Index: test/CodeGenCXX/vtable-relative-abi.cpp
===
--- /dev/null
+++ test/CodeGenCXX/vtable-relative-abi.cpp
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -funstable-c++-abi-classes -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ITANIUM %s
+// RUN: %clang_cc1 %s -triple x86_64-unknown-windows-msvc -funstable-c++-abi-classes -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MS %s
+
+// CHECK-ITANIUM: @_ZTV1S = unnamed_addr constant { i8*, i8*, i32, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1S to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f1Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32 }, { i8*, i8*, i32, i32 }* @_ZTV1S, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f2Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32 }, { i8*, i8*, i32, i32 }* @_ZTV1S, i32 0, i32 2) to i64)) to i32) }, align 8
+// CHECK-MS: @0 = private unnamed_addr constant { i8*, i32, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4S@@6B@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"\01?f1@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @0, i32 0, i32 1) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"\01?f2@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @0, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7S@@6B@")
+struct S {
+  S();
+  virtual void f1();
+  virtual void f2();
+};
+
+// CHECK-ITANIUM: @_ZTV1T = unnamed_addr constant { i8*, i8*, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1T to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @_ZN1T1gEv to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32 }, { i8*, i8*, i32 }* @_ZTV1T, i32 0, i32 2) to i64)) to i32) }
+// CHECK-MS: @1 = private unnamed_addr constant { i8*, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4T@@6B@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @"\01?g@T@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32 }, { i8*, i32 }* @1, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7T@@6B@")
+struct T {
+  T();
+  virtual void g();
+};
+
+// CHECK-ITANIUM: @_ZTV1U = unnamed_addr constant { i8*, i8*, i32, i32, i8*, i8*, i32 } { i8* null, i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64 }* @_ZTI1U to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.U*)* @_ZN1U2f1Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32, i8*, i8*, i32 }, { i8*, i8*, i32, i32, i8*, i8*, i32 }* @_ZTV1U, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f2Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32, i8*, i8*, i32 }, { i8*, i8*, i32, i32, i8*, i8*, i32 }* @_ZTV1U, i32 0, i32 2) to i64)) to i32), i8* inttoptr (i64 -8 to i8*), i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64 }* @_ZTI1U to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @_ZN1T1gEv to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32, i8*, i8*, i32 }, { i8*, i8*, i32, i32, i8*, i8*, i32 }* @_ZTV1U, i32 0, i32 6) to i64)) to i32) }, align 8
+// CHECK-MS: @2 = private unnamed_addr constant { i8*, i32, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4U@@6BS@@@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.U*)* @"\01?f1@U@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @2, i32 0, i32 1) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"\01?f2@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @2, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7U@@6BS@@@")
+// CHECK-MS: @3 = private unnamed_addr constant { i8*, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4U@@6BT@@@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @"\01?g@T@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32 }, { i8*, i32 }* @3, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7U@@6BT@@@")
+struct U : S, T {
+  U();
+  virtual void f1();
+};
+
+S::S() {}
+void S::f1() {}
+
+T::T() {}
+void T::g() {}
+
+U::U() {}
+void U::f1() {}
+
+struct V {
+  virtua

Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread John McCall via cfe-commits
rjmccall added a comment.

You still don't actually want linkonce_odr linkage.  You don't want the weak 
definition to be inlined, so it can't be ODR, and you want to force it to be 
emitted in your library, so it can't be linkonce.  You just want weak linkage.  
There's an existing attribute for that.

At best, you want a pass on your completed library to promote any still-weak 
definitions to strong.  That is not something we can usefully support in an 
attribute; it needs a custom pass.

Dropping unused definitions from your library when it's linked into an actual 
application is just standard dead-code stripping and does not need a special 
linkage.


http://reviews.llvm.org/D18095



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


Re: [PATCH] D17552: Pass -backend-option to LLVM when there is no target machine

2016-03-22 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 51326.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Add -x cl to the test when compiling it for spir target.


http://reviews.llvm.org/D17552

Files:
  lib/CodeGen/BackendUtil.cpp
  test/Frontend/backend-option.c

Index: test/Frontend/backend-option.c
===
--- /dev/null
+++ test/Frontend/backend-option.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - 2>&1 | 
FileCheck %s
+// RUN: %clang_cc1 %s -x cl -emit-llvm -backend-option -time-passes -o - 
-triple spir-unknown-unknown 2>&1 | FileCheck %s
+// CHECK: Pass execution timing report
+
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -97,6 +97,9 @@
 return PerFunctionPasses;
   }
 
+  /// Set LLVM command line options passed through -backend-option.
+  void setCommandLineOpts();
+
   void CreatePasses(FunctionInfoIndex *FunctionIndex);
 
   /// Generates the TargetMachine.
@@ -444,6 +447,24 @@
   PMBuilder.populateModulePassManager(*MPM);
 }
 
+void EmitAssemblyHelper::setCommandLineOpts() {
+  SmallVector BackendArgs;
+  BackendArgs.push_back("clang"); // Fake program name.
+  if (!CodeGenOpts.DebugPass.empty()) {
+BackendArgs.push_back("-debug-pass");
+BackendArgs.push_back(CodeGenOpts.DebugPass.c_str());
+  }
+  if (!CodeGenOpts.LimitFloatPrecision.empty()) {
+BackendArgs.push_back("-limit-float-precision");
+BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str());
+  }
+  for (const std::string &BackendOption : CodeGenOpts.BackendOptions)
+BackendArgs.push_back(BackendOption.c_str());
+  BackendArgs.push_back(nullptr);
+  llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
+BackendArgs.data());
+}
+
 TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) {
   // Create the TargetMachine for generating code.
   std::string Error;
@@ -466,22 +487,6 @@
   assert(CodeModel != ~0u && "invalid code model!");
   llvm::CodeModel::Model CM = static_cast(CodeModel);
 
-  SmallVector BackendArgs;
-  BackendArgs.push_back("clang"); // Fake program name.
-  if (!CodeGenOpts.DebugPass.empty()) {
-BackendArgs.push_back("-debug-pass");
-BackendArgs.push_back(CodeGenOpts.DebugPass.c_str());
-  }
-  if (!CodeGenOpts.LimitFloatPrecision.empty()) {
-BackendArgs.push_back("-limit-float-precision");
-BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str());
-  }
-  for (const std::string &BackendOption : CodeGenOpts.BackendOptions)
-BackendArgs.push_back(BackendOption.c_str());
-  BackendArgs.push_back(nullptr);
-  llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
-BackendArgs.data());
-
   std::string FeaturesStr =
   llvm::join(TargetOpts.Features.begin(), TargetOpts.Features.end(), ",");
 
@@ -620,6 +625,8 @@
   raw_pwrite_stream *OS) {
   TimeRegion Region(llvm::TimePassesIsEnabled ? &CodeGenerationTime : nullptr);
 
+  setCommandLineOpts();
+
   bool UsesCodeGen = (Action != Backend_EmitNothing &&
   Action != Backend_EmitBC &&
   Action != Backend_EmitLL);


Index: test/Frontend/backend-option.c
===
--- /dev/null
+++ test/Frontend/backend-option.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - 2>&1 | FileCheck %s
+// RUN: %clang_cc1 %s -x cl -emit-llvm -backend-option -time-passes -o - -triple spir-unknown-unknown 2>&1 | FileCheck %s
+// CHECK: Pass execution timing report
+
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -97,6 +97,9 @@
 return PerFunctionPasses;
   }
 
+  /// Set LLVM command line options passed through -backend-option.
+  void setCommandLineOpts();
+
   void CreatePasses(FunctionInfoIndex *FunctionIndex);
 
   /// Generates the TargetMachine.
@@ -444,6 +447,24 @@
   PMBuilder.populateModulePassManager(*MPM);
 }
 
+void EmitAssemblyHelper::setCommandLineOpts() {
+  SmallVector BackendArgs;
+  BackendArgs.push_back("clang"); // Fake program name.
+  if (!CodeGenOpts.DebugPass.empty()) {
+BackendArgs.push_back("-debug-pass");
+BackendArgs.push_back(CodeGenOpts.DebugPass.c_str());
+  }
+  if (!CodeGenOpts.LimitFloatPrecision.empty()) {
+BackendArgs.push_back("-limit-float-precision");
+BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str());
+  }
+  for (const std::string &BackendOption : CodeGenOpts.BackendOptions)
+BackendArgs.push_back(BackendOption.c_str());
+  BackendArgs.push_back(nullptr);
+  llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
+Ba

[PATCH] D18373: [CUDA] Don't allow templated variadic functions.

2016-03-22 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

http://reviews.llvm.org/D18373

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaCUDA/vararg.cu

Index: test/SemaCUDA/vararg.cu
===
--- test/SemaCUDA/vararg.cu
+++ test/SemaCUDA/vararg.cu
@@ -35,6 +35,12 @@
 // expected-error@-2 {{CUDA device code does not support variadic functions}}
 #endif
 
+template 
+__device__ void vararg(T t, ...) {}
+#ifdef EXPECT_VARARG_ERR
+// expected-error@-2 {{CUDA device code does not support variadic functions}}
+#endif
+
 extern "C" __device__ int printf(const char* fmt, ...);  // OK, special case.
 
 // Definition of printf not allowed.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8341,6 +8341,28 @@
 isExplicitSpecialization || isFunctionTemplateSpecialization);
   }
 
+  if (getLangOpts().CUDA) {
+IdentifierInfo *II = NewFD->getIdentifier();
+if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
+NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
+  if (!R->getAs()->getReturnType()->isScalarType())
+Diag(NewFD->getLocation(), diag::err_config_scalar_return);
+
+  Context.setcudaConfigureCallDecl(NewFD);
+}
+
+// Variadic functions, other than a *declaration* of printf, are not 
allowed
+// in device-side CUDA code, unless someone passed
+// -fcuda-allow-variadic-functions.
+if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->isVariadic() &&
+(NewFD->hasAttr() ||
+ NewFD->hasAttr()) &&
+!(II && II->isStr("printf") && NewFD->isExternC() &&
+  !D.isFunctionDefinition())) {
+  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
+}
+  }
+
   if (getLangOpts().CPlusPlus) {
 if (FunctionTemplate) {
   if (NewFD->isInvalidDecl())
@@ -8390,28 +8412,6 @@
 
   MarkUnusedFileScopedDecl(NewFD);
 
-  if (getLangOpts().CUDA) {
-IdentifierInfo *II = NewFD->getIdentifier();
-if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
-NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
-  if (!R->getAs()->getReturnType()->isScalarType())
-Diag(NewFD->getLocation(), diag::err_config_scalar_return);
-
-  Context.setcudaConfigureCallDecl(NewFD);
-}
-
-// Variadic functions, other than a *declaration* of printf, are not 
allowed
-// in device-side CUDA code, unless someone passed
-// -fcuda-allow-variadic-functions.
-if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->isVariadic() &&
-(NewFD->hasAttr() ||
- NewFD->hasAttr()) &&
-!(II && II->isStr("printf") && NewFD->isExternC() &&
-  !D.isFunctionDefinition())) {
-  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
-}
-  }
-
   // Here we have an function template explicit specialization at class scope.
   // The actually specialization will be postponed to template instatiation
   // time via the ClassScopeFunctionSpecializationDecl node.


Index: test/SemaCUDA/vararg.cu
===
--- test/SemaCUDA/vararg.cu
+++ test/SemaCUDA/vararg.cu
@@ -35,6 +35,12 @@
 // expected-error@-2 {{CUDA device code does not support variadic functions}}
 #endif
 
+template 
+__device__ void vararg(T t, ...) {}
+#ifdef EXPECT_VARARG_ERR
+// expected-error@-2 {{CUDA device code does not support variadic functions}}
+#endif
+
 extern "C" __device__ int printf(const char* fmt, ...);  // OK, special case.
 
 // Definition of printf not allowed.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8341,6 +8341,28 @@
 isExplicitSpecialization || isFunctionTemplateSpecialization);
   }
 
+  if (getLangOpts().CUDA) {
+IdentifierInfo *II = NewFD->getIdentifier();
+if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
+NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
+  if (!R->getAs()->getReturnType()->isScalarType())
+Diag(NewFD->getLocation(), diag::err_config_scalar_return);
+
+  Context.setcudaConfigureCallDecl(NewFD);
+}
+
+// Variadic functions, other than a *declaration* of printf, are not allowed
+// in device-side CUDA code, unless someone passed
+// -fcuda-allow-variadic-functions.
+if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->isVariadic() &&
+(NewFD->hasAttr() ||
+ NewFD->hasAttr()) &&
+!(II && II->isStr("printf") && NewFD->isExternC() &&
+  !D.isFunctionDefinition())) {
+  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
+}
+  }
+
   if (getLangOpts().CPlusPlus) {
 if (FunctionTemplate) {
   if (NewFD->isI

Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

Sorry my previous example may have caused some confusion.

Previously I said I wanted to override function definitions. However the only 
reason we want to add this attribute is so that unused functions will be 
dropped by the linker.


http://reviews.llvm.org/D18095



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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread John McCall via cfe-commits
rjmccall added a comment.

Does your linker not supported dead-code stripping?


http://reviews.llvm.org/D18095



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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread John McCall via cfe-commits
rjmccall added a comment.

You could also get this effect by somehow making the definitions linkonce_odr 
when they're linked in from the library.  Or you could simply use the classic 
static-archive technique of putting each symbol in its own object file and 
linking against the whole thing as a static archive (.a), which only pulls in 
object files that provide symbols that are used.

Regardless, linkonce won't get the effect you want, because (1) linkonce 
definitions can be dropped at any time when they're not used, so they won't be 
emitted in the library if they're not used there, and (2) the overriding 
definitions will be strong.


http://reviews.llvm.org/D18095



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


Re: [PATCH] D18170: [CUDA][OpenMP] Create generic offload toolchains

2016-03-22 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: include/clang/Driver/Action.h:79
@@ +78,3 @@
+OFFLOAD_None = 0x00,
+OFFLOAD_CUDA = 0x01,
+  };

Nit: All-caps CUDA looks weird here. _Cuda may be better choice.
If you can shorten the prefix that would be nice, too. OK_ is already taken, 
though. OFK_?


Comment at: include/clang/Driver/Compilation.h:42
@@ +41,3 @@
+  /// The tool chain of the offload host.
+  const ToolChain *OffloadHostToolChain;
+

This could be generalized into yet another toolchain kind and handled the same 
way as offload toolchains.


Comment at: include/clang/Driver/Compilation.h:46
@@ +45,3 @@
+  /// the host has to support.
+  unsigned OffloadHostKinds;
+

This could use a more descriptive name. ActiveOffloadMask?


Comment at: include/clang/Driver/Compilation.h:51
@@ -43,1 +50,3 @@
+  typedef std::pair OffloadToolChainTy;
+  SmallVector OrderedOffloadingToolchains;
 

Using std::multimap here would probably make 
specific_offload_kind_iterator unnecessary and would simplify toolchain lookup.


Comment at: lib/Driver/Driver.cpp:406
@@ +405,3 @@
+  // We need to generate a CUDA toolchain if any of the inputs has a CUDA type.
+  for (auto &I : Inputs)
+// Have we founs a CUDA file? If so generate the toolchain.

llvm::any_of() could be useful here:


```
if (llvm::any_of(Inputs, [](auto &I) { return types::isCuda(I.first)})) {
  ...addOffloadDeviceToolchain();
}
```


Comment at: lib/Driver/Driver.cpp:419
@@ +418,3 @@
+  //
+  // Add support for other offloading programming models here.
+  //

TODO:


Comment at: lib/Driver/Driver.cpp:543
@@ -520,1 +542,3 @@
 
+  // Get the toolchains for the offloading devices, if any.
+  CreateOffloadingDeviceToolChains(*C, Inputs);

Get is somewhat misplaced here. Perhaps populate or initialize would work 
better.


http://reviews.llvm.org/D18170



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


Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-03-22 Thread Richard Barton via cfe-commits
richard.barton.arm added a comment.

Hi Eric

Sorry for the delay - I originally detected the failure while not running in a 
totally clean environment with clean sources, but I can reproduce on clean code.

I can reproduce by building with clean clang and libcxx sources:
cmake -DLLVM_PATH=/work/ricbar01/llvm_oss/ -DLIBCXX_CXX_ABI=libcxxabi 
-DLIBCXX_CXX_ABI_INCLUDE_PATHS=../../libcxxabi_oss/include 
-DCMAKE_C_COMPILER=/work/ricbar01/llvm_oss/build/bin/clang 
-DCMAKE_CXX_COMPILER=/work/ricbar01/llvm_oss/build/bin/clang++ 
-DLIBCXX_ENABLE_THREADS=OFF -DLIBCXX_ENABLE_SHARED=OFF 
-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF ..

I get errors like:
/work/ricbar01/libcxx_oss/test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp:21:8:
 error: no type named 'mutex' in namespace 'std'

  std::mutex m;

From eyeballing the include/mutex it looks like the mutex class is #ifdeffec 
out when _LIBCPP_HAS_NO_THREADS is unset.


http://reviews.llvm.org/D18347



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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread Tom Stellard via cfe-commits
tstellarAMD added a comment.

Hi John,

The problem we are trying to solve here is linking a LLVM bitcode program 
(OpenCL kernel in this specific case) with an LLVM bitcode library (OpenCL 
builtin library) and having the resulting LLVM bitcode module contain only the 
program code and the library functions that it uses.

The solution for this problem that we are using for libclc is to compile the 
OpenCL library to bitcode and then run a post-processing pass: 
https://github.com/llvm-mirror/libclc/blob/master/utils/prepare-builtins.cpp on 
the bitcode to set the linkage of the library functions to linkonce_odr.  Doing 
this gives us what we are looking for, because the LLVM IR linker will drop all 
the linkonce_odr definitions that aren't used when it links the bitcode library 
in with the program.

The rationale for this specific patch was that if we could apply the 
linkonce_odr attribute to the functions at the source level, then we could 
avoid having to use the LLVM IR post-processing pass, which seems like a much 
cleaner and more portable solution.

Based on this comment:

> You could also get this effect by somehow making the definitions linkonce_odr 
> when they're linked in from the library.


It seems like you are suggesting that a post-processing pass like we have would 
be better, but I'm not sure if you had the complete picture of what we were 
trying to do.  GIven the problem I've described above is a post-processing pass 
the way to go or do you have some other suggestion?

Thanks,
Tom


http://reviews.llvm.org/D18095



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


Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-03-22 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I think the correct fix is "// UNSUPPORTED: libcpp-has-no-threads"


http://reviews.llvm.org/D18347



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


  1   2   >