Re: [PATCH] D19843: Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-05-18 Thread Marek Kurdej via cfe-commits
curdeius added a subscriber: curdeius.
curdeius added a comment.

Some minor remarks. Sorry for being finicky :).



Comment at: include/clang/Basic/VirtualFileSystem.h:97
@@ +96,3 @@
+  return Status->getName();
+else
+  return Status.getError();

No else needed after return.


Comment at: lib/Lex/PPDirectives.cpp:1673
@@ +1672,3 @@
+  if (File && !File->tryGetRealPathName().empty() &&
+!Diags->isIgnored(diag::pp_nonportable_path, FilenameTok.getLocation())) {
+StringRef Name = LangOpts.MSVCCompat ? NormalizedPath.c_str() : Filename;

May you create a bool variable for this long condition and name it so that it's 
clear what it checks?


Comment at: lib/Lex/PPDirectives.cpp:1678-1700
@@ +1677,25 @@
+  llvm::sys::path::end(Name));
+auto iRealPathComponent = llvm::sys::path::rbegin(RealPathName);
+auto iRealPathComponentEnd = llvm::sys::path::rend(RealPathName);
+int Cnt = 0;
+bool SuggestReplacement = false;
+for(auto& Component : llvm::reverse(Components)) {
+  if ("." == Component) {
+  } else if (".." == Component) {
+++Cnt;
+  } else if (Cnt) {
+--Cnt;
+  } else if (iRealPathComponent != iRealPathComponentEnd) {
+if (Component != *iRealPathComponent) {
+  // If these path components differ by more than just case, then we
+  // may be looking at symlinked paths. Bail on this diagnostic to 
avoid
+  // noisy false positives.
+  SuggestReplacement = iRealPathComponent->equals_lower(Component);
+  if (!SuggestReplacement)
+break;
+  Component = *iRealPathComponent;
+}
+++iRealPathComponent;
+  }
+}
+if (SuggestReplacement) {

Could you extract a function for this chunk? Something like `bool 
SuggestReplacement = simplifyPath(Components);`.
The `HandleIncludeDirective` method is already lng enough.


http://reviews.llvm.org/D19843



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


Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57569.
hokein marked an inline comment as done.
hokein added a comment.

Make a node matcher for unresolvedLookupExpr type.


http://reviews.llvm.org/D20326

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -16,6 +16,7 @@
  public:
   static int ii;
 };
+template  class J {};
 
 class Base {
  public:
@@ -29,6 +30,7 @@
 int UnusedFunc() { return 1; }
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
+template  int UsedInTemplateFunc() { return 1; }
 
 class ostream {
 public:
@@ -70,6 +72,13 @@
 using n::cout;
 using n::endl;
 
+using n::UsedInTemplateFunc;
+using n::J;
+template  void Callee() {
+  J j;
+  UsedInTemplateFunc();
+}
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,20 +10,30 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
+namespace {
+// FIXME: Move this node matcher to ASTMatcher.
+AST_MATCHER(Stmt, unresolvedLookupExpr) {
+  return isa(Node);
+}
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
   Finder->addMatcher(declRefExpr().bind("used"), this);
+  Finder->addMatcher(callExpr(callee(unresolvedLookupExpr())).bind("used"),
+ this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -81,6 +91,14 @@
   removeFromFoundDecls(VD);
 }
   }
+  // Check the uninstantiated template function usage.
+  if (auto *CE = Result.Nodes.getNodeAs("used")) {
+auto *ULE = dyn_cast(CE->getCallee());
+for (auto I = ULE->decls_begin(), E = ULE->decls_end(); I != E; ++I) {
+  if (auto *USD = dyn_cast(I.getDecl()))
+removeFromFoundDecls(USD->getTargetDecl()->getCanonicalDecl());
+}
+  }
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {


Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -16,6 +16,7 @@
  public:
   static int ii;
 };
+template  class J {};
 
 class Base {
  public:
@@ -29,6 +30,7 @@
 int UnusedFunc() { return 1; }
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
+template  int UsedInTemplateFunc() { return 1; }
 
 class ostream {
 public:
@@ -70,6 +72,13 @@
 using n::cout;
 using n::endl;
 
+using n::UsedInTemplateFunc;
+using n::J;
+template  void Callee() {
+  J j;
+  UsedInTemplateFunc();
+}
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,20 +10,30 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
+namespace {
+// FIXME: Move this node matcher to ASTMatcher.
+AST_MATCHER(Stmt, unresolvedLookupExpr) {
+  return isa(Node);
+}
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
   Finder->addMatcher(declRefExpr().bind("used"), this);
+  Finder->addMatcher(callExpr(callee(unresolvedLookupExpr())).bind("used"),
+ this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -81,6 +91,14 @@
   removeFromFoundDecls(VD);
 }
   }
+  // Check the uninstantiated template fun

Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:24
@@ +23,3 @@
+// FIXME: Add a node matcher for UnresolvedLookupExpr in ASTMatcher.
+AST_MATCHER(CallExpr, hasUnresolvedLookupExpr) {
+  return isa(Node.getCallee());

alexfh wrote:
> Sorry for being unclear. Please change this to the node matcher in this 
> patch. You can move the matcher to the ASTMatchers.h as a follow-up. 
> `hasUnresolvedLookupExpr` is not in line with the matchers design: the 
> `CallExpr` node has no property `UnresolvedLookupExpr`. You'll also be able 
> to bind the `UnresolvedLookupExpr` to an identifier and make the code in 
> `check()` slightly shorter.
Done. But currently we can't bind the `UnresolvedLookupExpr` directly since the 
`AST_MATCHER` doesn't provide a bind function here.


http://reviews.llvm.org/D20326



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


r269888 - Make clang-format cleaner remove redundant commas in list and redundant colon in constructor initializer.

2016-05-18 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed May 18 03:02:56 2016
New Revision: 269888

URL: http://llvm.org/viewvc/llvm-project?rev=269888&view=rev
Log:
Make clang-format cleaner remove redundant commas in list and redundant colon 
in constructor initializer.

Summary: Make clang-format cleaner remove redundant commas/colons in 
constructor initializer list.

Reviewers: klimek, djasper

Subscribers: cfe-commits, klimek

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

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=269888&r1=269887&r2=269888&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed May 18 03:02:56 2016
@@ -1765,6 +1765,15 @@ public:
 
 checkEmptyNamespace(AnnotatedLines);
 
+for (auto &Line : AnnotatedLines) {
+  if (Line->Affected) {
+cleanupRight(Line->First, tok::comma, tok::comma);
+cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
+cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
+cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
+  }
+}
+
 return generateFixes();
   }
 
@@ -1853,6 +1862,45 @@ private:
 return true;
   }
 
+  // Checks pairs {start, start->next},..., {end->previous, end} and deletes 
one
+  // of the token in the pair if the left token has \p LK token kind and the
+  // right token has \p RK token kind. If \p DeleteLeft is true, the left token
+  // is deleted on match; otherwise, the right token is deleted.
+  template 
+  void cleanupPair(FormatToken *Start, LeftKind LK, RightKind RK,
+   bool DeleteLeft) {
+auto NextNotDeleted = [this](const FormatToken &Tok) -> FormatToken * {
+  for (auto *Res = Tok.Next; Res; Res = Res->Next)
+if (!Res->is(tok::comment) &&
+DeletedTokens.find(Res) == DeletedTokens.end())
+  return Res;
+  return nullptr;
+};
+for (auto *Left = Start; Left;) {
+  auto *Right = NextNotDeleted(*Left);
+  if (!Right)
+break;
+  if (Left->is(LK) && Right->is(RK)) {
+deleteToken(DeleteLeft ? Left : Right);
+// If the right token is deleted, we should keep the left token
+// unchanged and pair it with the new right token.
+if (!DeleteLeft)
+  continue;
+  }
+  Left = Right;
+}
+  }
+
+  template 
+  void cleanupLeft(FormatToken *Start, LeftKind LK, RightKind RK) {
+cleanupPair(Start, LK, RK, /*DeleteLeft=*/true);
+  }
+
+  template 
+  void cleanupRight(FormatToken *Start, LeftKind LK, RightKind RK) {
+cleanupPair(Start, LK, RK, /*DeleteLeft=*/false);
+  }
+
   // Delete the given token.
   inline void deleteToken(FormatToken *Tok) {
 if (Tok)

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=269888&r1=269887&r2=269888&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed May 18 03:02:56 2016
@@ -920,6 +920,10 @@ private:
   Contexts.back().IsExpression = false;
 } else if (Current.is(TT_LambdaArrow) || Current.is(Keywords.kw_assert)) {
   Contexts.back().IsExpression = Style.Language == FormatStyle::LK_Java;
+} else if (Current.Previous &&
+   Current.Previous->is(TT_CtorInitializerColon)) {
+  Contexts.back().IsExpression = true;
+  Contexts.back().InCtorInitializer = true;
 } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) {
   for (FormatToken *Previous = Current.Previous;
Previous && Previous->isOneOf(tok::star, tok::amp);
@@ -927,10 +931,6 @@ private:
 Previous->Type = TT_PointerOrReference;
   if (Line.MustBeDeclaration && !Contexts.front().InCtorInitializer)
 Contexts.back().IsExpression = false;
-} else if (Current.Previous &&
-   Current.Previous->is(TT_CtorInitializerColon)) {
-  Contexts.back().IsExpression = true;
-  Contexts.back().InCtorInitializer = true;
 } else if (Current.is(tok::kw_new)) {
   Contexts.back().CanBeExpression = false;
 } else if (Current.isOneOf(tok::semi, tok::exclaim)) {

Modified: cfe/trunk/unittests/Format/CleanupTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CleanupTest.cpp?rev=269888&r1=269887&r2=269888&view=diff
==
--- cfe/trunk/unittests/Format/CleanupTest.cpp (original)
+++ cfe/trunk/unittests/Format/CleanupTest.cpp Wed May 18 03:02:56 2016
@@ -113,6 +113,133 @@ TEST_F(CleanupTest, EmptyNamespaceWit

Re: [PATCH] D19804: Make clang-format cleaner remove redundant commas in list and redundant colon in constructor initializer.

2016-05-18 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269888: Make clang-format cleaner remove redundant commas in 
list and redundant colon… (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D19804?vs=57146&id=57570#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19804

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/CleanupTest.cpp

Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -920,17 +920,17 @@
   Contexts.back().IsExpression = false;
 } else if (Current.is(TT_LambdaArrow) || Current.is(Keywords.kw_assert)) {
   Contexts.back().IsExpression = Style.Language == FormatStyle::LK_Java;
+} else if (Current.Previous &&
+   Current.Previous->is(TT_CtorInitializerColon)) {
+  Contexts.back().IsExpression = true;
+  Contexts.back().InCtorInitializer = true;
 } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) {
   for (FormatToken *Previous = Current.Previous;
Previous && Previous->isOneOf(tok::star, tok::amp);
Previous = Previous->Previous)
 Previous->Type = TT_PointerOrReference;
   if (Line.MustBeDeclaration && !Contexts.front().InCtorInitializer)
 Contexts.back().IsExpression = false;
-} else if (Current.Previous &&
-   Current.Previous->is(TT_CtorInitializerColon)) {
-  Contexts.back().IsExpression = true;
-  Contexts.back().InCtorInitializer = true;
 } else if (Current.is(tok::kw_new)) {
   Contexts.back().CanBeExpression = false;
 } else if (Current.isOneOf(tok::semi, tok::exclaim)) {
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1765,6 +1765,15 @@
 
 checkEmptyNamespace(AnnotatedLines);
 
+for (auto &Line : AnnotatedLines) {
+  if (Line->Affected) {
+cleanupRight(Line->First, tok::comma, tok::comma);
+cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
+cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
+cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
+  }
+}
+
 return generateFixes();
   }
 
@@ -1853,6 +1862,45 @@
 return true;
   }
 
+  // Checks pairs {start, start->next},..., {end->previous, end} and deletes one
+  // of the token in the pair if the left token has \p LK token kind and the
+  // right token has \p RK token kind. If \p DeleteLeft is true, the left token
+  // is deleted on match; otherwise, the right token is deleted.
+  template 
+  void cleanupPair(FormatToken *Start, LeftKind LK, RightKind RK,
+   bool DeleteLeft) {
+auto NextNotDeleted = [this](const FormatToken &Tok) -> FormatToken * {
+  for (auto *Res = Tok.Next; Res; Res = Res->Next)
+if (!Res->is(tok::comment) &&
+DeletedTokens.find(Res) == DeletedTokens.end())
+  return Res;
+  return nullptr;
+};
+for (auto *Left = Start; Left;) {
+  auto *Right = NextNotDeleted(*Left);
+  if (!Right)
+break;
+  if (Left->is(LK) && Right->is(RK)) {
+deleteToken(DeleteLeft ? Left : Right);
+// If the right token is deleted, we should keep the left token
+// unchanged and pair it with the new right token.
+if (!DeleteLeft)
+  continue;
+  }
+  Left = Right;
+}
+  }
+
+  template 
+  void cleanupLeft(FormatToken *Start, LeftKind LK, RightKind RK) {
+cleanupPair(Start, LK, RK, /*DeleteLeft=*/true);
+  }
+
+  template 
+  void cleanupRight(FormatToken *Start, LeftKind LK, RightKind RK) {
+cleanupPair(Start, LK, RK, /*DeleteLeft=*/false);
+  }
+
   // Delete the given token.
   inline void deleteToken(FormatToken *Tok) {
 if (Tok)
Index: cfe/trunk/unittests/Format/CleanupTest.cpp
===
--- cfe/trunk/unittests/Format/CleanupTest.cpp
+++ cfe/trunk/unittests/Format/CleanupTest.cpp
@@ -113,6 +113,133 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST_F(CleanupTest, CtorInitializationSimpleRedundantComma) {
+  std::string Code = "class A {\nA() : , {} };";
+  std::string Expected = "class A {\nA()  {} };";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(17, 0));
+  Ranges.push_back(tooling::Range(19, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  Code = "class A {\nA() : x(1), {} };";
+  Expected = "class A {\nA() : x(1) {} };";
+  Ranges.clear();
+  Ranges.push_back(tooling::Range(23, 0));
+  Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  Code = "class A {\nA() :{} };";
+  Expected = "class A {\nA() {} };";
+  Ran

Re: [PATCH] D19084: [scan-build] fix warnings emitted on Clang AST code base

2016-05-18 Thread Apelete Seketeli via cfe-commits
apelete updated this revision to Diff 57571.
apelete retitled this revision from "[scan-build] fix warnings emitted on Clang 
AST code base " to "[scan-build] fix warnings emitted on Clang AST code base".
apelete added a comment.

[scan-build] fix warnings emitted on Clang AST code base

Changes since last revision:

- lib/AST/ASTDiagnostic.cpp: replace if() condition by assert to ensure that 
template diffing print message is done only when both 'FromTD' and 'ToTD' are 
non-null.


http://reviews.llvm.org/D19084

Files:
  lib/AST/ASTDiagnostic.cpp
  lib/AST/DeclObjC.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/NestedNameSpecifier.cpp

Index: lib/AST/NestedNameSpecifier.cpp
===
--- lib/AST/NestedNameSpecifier.cpp
+++ lib/AST/NestedNameSpecifier.cpp
@@ -456,7 +456,9 @@
   Buffer = NewBuffer;
   BufferCapacity = NewCapacity;
 }
-
+
+assert(Buffer && "Buffer cannot be NULL");
+
 memcpy(Buffer + BufferSize, Start, End - Start);
 BufferSize += End-Start;
   }
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -1989,6 +1989,7 @@
 static bool HandleLValueArrayAdjustment(EvalInfo &Info, const Expr *E,
 LValue &LVal, QualType EltTy,
 int64_t Adjustment) {
+  assert(E && "expression to be evaluated must be not NULL");
   CharUnits SizeOfPointee;
   if (!HandleSizeof(Info, E->getExprLoc(), EltTy, SizeOfPointee))
 return false;
Index: lib/AST/DeclObjC.cpp
===
--- lib/AST/DeclObjC.cpp
+++ lib/AST/DeclObjC.cpp
@@ -1577,8 +1577,10 @@
   data().IvarList = layout[0].Ivar; Ix++;
   curIvar = data().IvarList;
 }
-for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++)
+for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++) {
+  assert(curIvar && "instance variable is NULL, stop iterating through 
layout");
   curIvar->setNextIvar(layout[Ix].Ivar);
+}
   }
 }
   }
Index: lib/AST/ASTDiagnostic.cpp
===
--- lib/AST/ASTDiagnostic.cpp
+++ lib/AST/ASTDiagnostic.cpp
@@ -1684,6 +1684,8 @@
 }
 
 if (Same) {
+  assert((FromTD && ToTD) &&
+ "Same implies both template arguments are non-null.");
   OS << "template " << FromTD->getNameAsString();
 } else if (!PrintTree) {
   OS << (FromDefault ? "(default) template " : "template ");


Index: lib/AST/NestedNameSpecifier.cpp
===
--- lib/AST/NestedNameSpecifier.cpp
+++ lib/AST/NestedNameSpecifier.cpp
@@ -456,7 +456,9 @@
   Buffer = NewBuffer;
   BufferCapacity = NewCapacity;
 }
-
+
+assert(Buffer && "Buffer cannot be NULL");
+
 memcpy(Buffer + BufferSize, Start, End - Start);
 BufferSize += End-Start;
   }
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -1989,6 +1989,7 @@
 static bool HandleLValueArrayAdjustment(EvalInfo &Info, const Expr *E,
 LValue &LVal, QualType EltTy,
 int64_t Adjustment) {
+  assert(E && "expression to be evaluated must be not NULL");
   CharUnits SizeOfPointee;
   if (!HandleSizeof(Info, E->getExprLoc(), EltTy, SizeOfPointee))
 return false;
Index: lib/AST/DeclObjC.cpp
===
--- lib/AST/DeclObjC.cpp
+++ lib/AST/DeclObjC.cpp
@@ -1577,8 +1577,10 @@
   data().IvarList = layout[0].Ivar; Ix++;
   curIvar = data().IvarList;
 }
-for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++)
+for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++) {
+  assert(curIvar && "instance variable is NULL, stop iterating through layout");
   curIvar->setNextIvar(layout[Ix].Ivar);
+}
   }
 }
   }
Index: lib/AST/ASTDiagnostic.cpp
===
--- lib/AST/ASTDiagnostic.cpp
+++ lib/AST/ASTDiagnostic.cpp
@@ -1684,6 +1684,8 @@
 }
 
 if (Same) {
+  assert((FromTD && ToTD) &&
+ "Same implies both template arguments are non-null.");
   OS << "template " << FromTD->getNameAsString();
 } else if (!PrintTree) {
   OS << (FromDefault ? "(default) template " : "template ");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20171: Support for MSVS default calling convention options (/Gd, /Gz, /Gv, /Gr)

2016-05-18 Thread Alexander Makarov via cfe-commits
a.makarov added a comment.

Thanks!


http://reviews.llvm.org/D20171



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


r269889 - [clang-format] Make FormatTokenLess::operator() const.

2016-05-18 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed May 18 03:14:49 2016
New Revision: 269889

URL: http://llvm.org/viewvc/llvm-project?rev=269889&view=rev
Log:
[clang-format] Make FormatTokenLess::operator() const.

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=269889&r1=269888&r2=269889&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed May 18 03:14:49 2016
@@ -1938,7 +1938,7 @@ private:
   struct FormatTokenLess {
 FormatTokenLess(const SourceManager &SM) : SM(SM) {}
 
-bool operator()(const FormatToken *LHS, const FormatToken *RHS) {
+bool operator()(const FormatToken *LHS, const FormatToken *RHS) const {
   return SM.isBeforeInTranslationUnit(LHS->Tok.getLocation(),
   RHS->Tok.getLocation());
 }


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


Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

2016-05-18 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:24
@@ +23,3 @@
+// FIXME: Move this node matcher to ASTMatcher.
+AST_MATCHER(Stmt, unresolvedLookupExpr) {
+  return isa(Node);

That's because we need a node matcher, not narrowing matcher. I guess, this 
should work:

  const internal::VariadicAllOfMatcher 
unresolvedLookupExpr;


http://reviews.llvm.org/D20326



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


Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:24
@@ +23,3 @@
+// FIXME: Move this node matcher to ASTMatcher.
+AST_MATCHER(Stmt, unresolvedLookupExpr) {
+  return isa(Node);

alexfh wrote:
> That's because we need a node matcher, not narrowing matcher. I guess, this 
> should work:
> 
>   const internal::VariadicAllOfMatcher 
> unresolvedLookupExpr;
Yeah. But as the name indicates, `VariadicAllOfMatcher` is used internally in 
ASTMatcher, is it reasonable to use it here? I can't find such usage in 
clang-tidy side. 


http://reviews.llvm.org/D20326



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


Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

2016-05-18 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:24
@@ +23,3 @@
+// FIXME: Move this node matcher to ASTMatcher.
+AST_MATCHER(Stmt, unresolvedLookupExpr) {
+  return isa(Node);

hokein wrote:
> alexfh wrote:
> > That's because we need a node matcher, not narrowing matcher. I guess, this 
> > should work:
> > 
> >   const internal::VariadicAllOfMatcher 
> > unresolvedLookupExpr;
> Yeah. But as the name indicates, `VariadicAllOfMatcher` is used internally in 
> ASTMatcher, is it reasonable to use it here? I can't find such usage in 
> clang-tidy side. 
There are far fewer nodes in the AST than their properties, so the core 
matchers library should contain all node matchers. Thus, the user code is not 
supposed to create any node matchers and the corresponding API is considered an 
implementation detail of the matchers library. It's fine to use internal API 
here for a short period until we move the matcher to the core matchers library.


http://reviews.llvm.org/D20326



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


Re: [PATCH] D20354: [include-fixer] Ignore non-scoped enum declaration during search.

2016-05-18 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg



Comment at: include-fixer/SymbolIndexManager.cpp:45
@@ +44,3 @@
+  while (IdentiferContext != Names.rend() &&
+ SymbolContext != Symbol.getContexts().end()) {
+if (SymbolContext->second == *IdentiferContext) {

It looks like we should rewrite this loop with early exits eventually. Not sure 
if that's a net win right now so I'm also fine with doing that when the code 
becomes more complex the next time.


Repository:
  rL LLVM

http://reviews.llvm.org/D20354



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


Re: [PATCH] D20325: Add ARM cdp intrinsics

2016-05-18 Thread Renato Golin via cfe-commits
On 18 May 2016 at 03:45, Tim Northover via cfe-commits
 wrote:
> Well yes, it's probably got orders of magnitude less bugs than the
> backend for a start.

:D


> Generally we're far more relaxed as long as a specification is on the
> way. We're up to to v8.2 in LLVM proper already, and I don't think
> even the v8.1 specification is public (all I can find is a blog
> announcing it).

That's a good point...

It shouldn't hurt to add this one, I agree, I just don't want us
changing again when the spec comes out because of some silly typo.

I mean, even that is irrelevant, but I don't like to set the precedent
where we start implementing random things and changing our minds every
other month.

Still, for this patch to go in, it'll need some more changes... I'll
comment on the patch, since it seems Phab didn't pick up your reply...
:(

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


Re: [PATCH] D20329: [clang-include-fixer] Added Vim integration for clang-include-fixer.

2016-05-18 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

I expect the insertion code in the python part to cause trouble in the future 
again but I guess this is fine for now.

Can you add a section to include-fixer.rst on how to set this up?


http://reviews.llvm.org/D20329



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


Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57576.
hokein added a comment.

Create a  node matcher for UnresolvedLookupExpr.


http://reviews.llvm.org/D20326

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -16,6 +16,7 @@
  public:
   static int ii;
 };
+template  class J {};
 
 class Base {
  public:
@@ -29,6 +30,7 @@
 int UnusedFunc() { return 1; }
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
+template  int UsedInTemplateFunc() { return 1; }
 
 class ostream {
 public:
@@ -70,6 +72,13 @@
 using n::cout;
 using n::endl;
 
+using n::UsedInTemplateFunc;
+using n::J;
+template  void Callee() {
+  J j;
+  UsedInTemplateFunc();
+}
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,20 +10,29 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
+namespace {
+// FIXME: Move this node matcher to ASTMatcher.
+const internal::VariadicDynCastAllOfMatcher
+unresolvedLookupExpr;
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
   Finder->addMatcher(declRefExpr().bind("used"), this);
+  Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
+ this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -81,6 +90,13 @@
   removeFromFoundDecls(VD);
 }
   }
+  // Check the uninstantiated template function usage.
+  if (auto *ULE = Result.Nodes.getNodeAs("used")) {
+for (auto I = ULE->decls_begin(), E = ULE->decls_end(); I != E; ++I) {
+  if (auto *USD = dyn_cast(I.getDecl()))
+removeFromFoundDecls(USD->getTargetDecl()->getCanonicalDecl());
+}
+  }
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {


Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -16,6 +16,7 @@
  public:
   static int ii;
 };
+template  class J {};
 
 class Base {
  public:
@@ -29,6 +30,7 @@
 int UnusedFunc() { return 1; }
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
+template  int UsedInTemplateFunc() { return 1; }
 
 class ostream {
 public:
@@ -70,6 +72,13 @@
 using n::cout;
 using n::endl;
 
+using n::UsedInTemplateFunc;
+using n::J;
+template  void Callee() {
+  J j;
+  UsedInTemplateFunc();
+}
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,20 +10,29 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
+namespace {
+// FIXME: Move this node matcher to ASTMatcher.
+const internal::VariadicDynCastAllOfMatcher
+unresolvedLookupExpr;
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
   Finder->addMatcher(declRefExpr().bind("used"), this);
+  Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
+ this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -81,6 +90,13 @@
   removeFromFoundDecls(VD);
 }
   }
+  // Check the uninstantiated template function usage.
+  if (auto *ULE = Result.Nodes.getNodeAs("used

Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:24
@@ +23,3 @@
+// FIXME: Move this node matcher to ASTMatcher.
+const internal::VariadicDynCastAllOfMatcher
+unresolvedLookupExpr;

Sounds good. Done.


http://reviews.llvm.org/D20326



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


Re: [PATCH] D20354: [include-fixer] Ignore non-scoped enum declaration during search.

2016-05-18 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269890: [include-fixer] Ignore non-scoped enum declaration 
during search. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20354?vs=57572&id=57577#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20354

Files:
  clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
  clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Index: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
===
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
@@ -41,10 +41,16 @@
   auto SymbolContext = Symbol.getContexts().begin();
   auto IdentiferContext = Names.rbegin() + 1; // Skip identifier name;
   // Match the remaining context names.
-  for (; IdentiferContext != Names.rend() &&
- SymbolContext != Symbol.getContexts().end();
-   ++IdentiferContext, ++SymbolContext) {
-if (SymbolContext->second != *IdentiferContext) {
+  while (IdentiferContext != Names.rend() &&
+ SymbolContext != Symbol.getContexts().end()) {
+if (SymbolContext->second == *IdentiferContext) {
+  ++IdentiferContext;
+  ++SymbolContext;
+} else if (SymbolContext->first ==
+   find_all_symbols::SymbolInfo::ContextType::EnumDecl) {
+  // Skip non-scoped enum context.
+  ++SymbolContext;
+} else {
   IsMatched = false;
   break;
 }
Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -62,6 +62,10 @@
   SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar.h\"",
  1, {{SymbolInfo::ContextType::Namespace, "b"},
  {SymbolInfo::ContextType::Namespace, "a"}}),
+  SymbolInfo("Green", SymbolInfo::SymbolKind::Class, "\"color.h\"",
+ 1, {{SymbolInfo::ContextType::EnumDecl, "Color"},
+ {SymbolInfo::ContextType::Namespace, "b"},
+ {SymbolInfo::ContextType::Namespace, "a"}}),
   };
   auto SymbolIndexMgr = llvm::make_unique();
   SymbolIndexMgr->addSymbolIndex(
@@ -166,6 +170,12 @@
   EXPECT_EQ("#include \"bar.h\"\nnamespace A { b::bar b; }\n",
 runIncludeFixer("namespace A { b::bar b; }\n"));
 }
+
+TEST(IncludeFixer, EnumConstantSymbols) {
+  EXPECT_EQ("#include \"color.h\"\nint test = a::b::Green;\n",
+runIncludeFixer("int test = a::b::Green;\n"));
+}
+
 } // namespace
 } // namespace include_fixer
 } // namespace clang


Index: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
===
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
@@ -41,10 +41,16 @@
   auto SymbolContext = Symbol.getContexts().begin();
   auto IdentiferContext = Names.rbegin() + 1; // Skip identifier name;
   // Match the remaining context names.
-  for (; IdentiferContext != Names.rend() &&
- SymbolContext != Symbol.getContexts().end();
-   ++IdentiferContext, ++SymbolContext) {
-if (SymbolContext->second != *IdentiferContext) {
+  while (IdentiferContext != Names.rend() &&
+ SymbolContext != Symbol.getContexts().end()) {
+if (SymbolContext->second == *IdentiferContext) {
+  ++IdentiferContext;
+  ++SymbolContext;
+} else if (SymbolContext->first ==
+   find_all_symbols::SymbolInfo::ContextType::EnumDecl) {
+  // Skip non-scoped enum context.
+  ++SymbolContext;
+} else {
   IsMatched = false;
   break;
 }
Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -62,6 +62,10 @@
   SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar.h\"",
  1, {{SymbolInfo::ContextType::Namespace, "b"},
  {SymbolInfo::ContextType::Namespace, "a"}}),
+  SymbolInfo("Green", SymbolInfo::SymbolKind::Class, "\"color.h\"",
+ 1, {{SymbolInfo::ContextType::EnumDecl, "Color"},
+ {SymbolInfo::ContextType::Namespace, "b"},
+ {SymbolInfo::ContextType::Namespace, "a"}}),
   };
   auto SymbolIndexMgr = llvm::make_unique();
   SymbolIndexMgr->addSymbolIndex(
@@ -166,6 +170,12 @@
   EXPECT_EQ(

[clang-tools-extra] r269890 - [include-fixer] Ignore non-scoped enum declaration during search.

2016-05-18 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed May 18 04:04:43 2016
New Revision: 269890

URL: http://llvm.org/viewvc/llvm-project?rev=269890&view=rev
Log:
[include-fixer] Ignore non-scoped enum declaration during search.

Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

Modified:
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=269890&r1=269889&r2=269890&view=diff
==
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Wed May 18 
04:04:43 2016
@@ -41,10 +41,16 @@ SymbolIndexManager::search(llvm::StringR
   auto SymbolContext = Symbol.getContexts().begin();
   auto IdentiferContext = Names.rbegin() + 1; // Skip identifier name;
   // Match the remaining context names.
-  for (; IdentiferContext != Names.rend() &&
- SymbolContext != Symbol.getContexts().end();
-   ++IdentiferContext, ++SymbolContext) {
-if (SymbolContext->second != *IdentiferContext) {
+  while (IdentiferContext != Names.rend() &&
+ SymbolContext != Symbol.getContexts().end()) {
+if (SymbolContext->second == *IdentiferContext) {
+  ++IdentiferContext;
+  ++SymbolContext;
+} else if (SymbolContext->first ==
+   find_all_symbols::SymbolInfo::ContextType::EnumDecl) {
+  // Skip non-scoped enum context.
+  ++SymbolContext;
+} else {
   IsMatched = false;
   break;
 }

Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=269890&r1=269889&r2=269890&view=diff
==
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Wed 
May 18 04:04:43 2016
@@ -62,6 +62,10 @@ static std::string runIncludeFixer(
   SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar.h\"",
  1, {{SymbolInfo::ContextType::Namespace, "b"},
  {SymbolInfo::ContextType::Namespace, "a"}}),
+  SymbolInfo("Green", SymbolInfo::SymbolKind::Class, "\"color.h\"",
+ 1, {{SymbolInfo::ContextType::EnumDecl, "Color"},
+ {SymbolInfo::ContextType::Namespace, "b"},
+ {SymbolInfo::ContextType::Namespace, "a"}}),
   };
   auto SymbolIndexMgr = llvm::make_unique();
   SymbolIndexMgr->addSymbolIndex(
@@ -166,6 +170,12 @@ TEST(IncludeFixer, ScopedNamespaceSymbol
   EXPECT_EQ("#include \"bar.h\"\nnamespace A { b::bar b; }\n",
 runIncludeFixer("namespace A { b::bar b; }\n"));
 }
+
+TEST(IncludeFixer, EnumConstantSymbols) {
+  EXPECT_EQ("#include \"color.h\"\nint test = a::b::Green;\n",
+runIncludeFixer("int test = a::b::Green;\n"));
+}
+
 } // namespace
 } // namespace include_fixer
 } // namespace clang


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


r269891 - Support for MSVS default calling convention options (/Gd, /Gz, /Gv,

2016-05-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed May 18 04:06:38 2016
New Revision: 269891

URL: http://llvm.org/viewvc/llvm-project?rev=269891&view=rev
Log:
Support for MSVS default calling convention options (/Gd, /Gz, /Gv,
/Gr), by Alexander Makarov

Patch for bug #27711
Differential Revision: http://reviews.llvm.org/D20171

Added:
cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=269891&r1=269890&r2=269891&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Wed May 18 04:06:38 2016
@@ -172,6 +172,7 @@ BENIGN_LANGOPT(AccessControl , 1, 1,
 LANGOPT(CharIsSigned  , 1, 1, "signed char")
 LANGOPT(ShortWChar, 1, 0, "unsigned short wchar_t")
 ENUM_LANGOPT(MSPointerToMemberRepresentationMethod, 
PragmaMSPointersToMembersKind, 2, PPTMK_BestCase, "member-pointer 
representation method")
+ENUM_LANGOPT(DefaultCallingConv, DefaultCallingConvention, 3, DCC_None, 
"default calling convention")
 
 LANGOPT(ShortEnums, 1, 0, "short enum types")
 
@@ -216,7 +217,6 @@ LANGOPT(ObjCSubscriptingLegacyRuntime
 LANGOPT(FakeAddressSpaceMap , 1, 0, "OpenCL fake address space map")
 ENUM_LANGOPT(AddressSpaceMapMangling , AddrSpaceMapMangling, 2, ASMM_Target, 
"OpenCL address space map mangling mode")
 
-LANGOPT(MRTD , 1, 0, "-mrtd calling convention")
 BENIGN_LANGOPT(DelayedTemplateParsing , 1, 0, "delayed template parsing")
 LANGOPT(BlocksRuntimeOptional , 1, 0, "optional blocks runtime")
 

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=269891&r1=269890&r2=269891&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Wed May 18 04:06:38 2016
@@ -65,6 +65,14 @@ public:
 PPTMK_FullGeneralityVirtualInheritance
   };
 
+  enum DefaultCallingConvention {
+DCC_None,
+DCC_CDecl,
+DCC_FastCall,
+DCC_StdCall,
+DCC_VectorCall
+  };
+
   enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off };
 
   enum MSVCMajorVersion {

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=269891&r1=269890&r2=269891&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Wed May 18 04:06:38 2016
@@ -610,6 +610,8 @@ def fnative_half_arguments_and_returns :
   HelpText<"Use the native __fp16 type for arguments and returns (and skip 
ABI-specific lowering)">;
 def fallow_half_arguments_and_returns : Flag<["-"], 
"fallow-half-arguments-and-returns">,
   HelpText<"Allow function arguments and returns of type half">;
+def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">,
+  HelpText<"Set default MS calling convention">;
 
 // C++ TSes.
 def fcoroutines : Flag<["-"], "fcoroutines">,

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=269891&r1=269890&r2=269891&view=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Wed May 18 04:06:38 2016
@@ -268,6 +268,15 @@ def _SLASH_Y_ : CLFlag<"Y-">,
 def _SLASH_Fp : CLJoined<"Fp">,
   HelpText<"Set pch filename (with /Yc and /Yu)">, MetaVarName<"">;
 
+def _SLASH_Gd : CLFlag<"Gd">,
+  HelpText<"Set __cdecl as a default calling convention">;
+def _SLASH_Gr : CLFlag<"Gr">,
+  HelpText<"Set __fastcall as a default calling convention">;
+def _SLASH_Gz : CLFlag<"Gz">,
+  HelpText<"Set __stdcall as a default calling convention">;
+def _SLASH_Gv : CLFlag<"Gv">,
+  HelpText<"Set __vectorcall as a default calling convention">;
+
 // Ignored:
 
 def _SLASH_analyze_ : CLIgnoredFlag<"analyze-">;
@@ -279,7 +288,6 @@ def _SLASH_errorReport : CLIgnoredJoined
 def _SLASH_Fd : CLIgnoredJoined<"Fd">;
 def _SLASH_FC : CLIgnoredFlag<"FC">;
 def _SLASH_FS : CLIgnoredFlag<"FS">, HelpText<"Force synchronous PDB writes">;
-def _SLASH_Gd : CLIgnoredFlag<"Gd">;
 def _SLASH_GF : CLIgnoredFlag<"GF">;
 def _SLASH_GS_ : CLIg

Re: [PATCH] D20171: Support for MSVS default calling convention options (/Gd, /Gz, /Gv, /Gr)

2016-05-18 Thread Alexey Bataev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269891: Support for MSVS default calling convention options 
(/Gd, /Gz, /Gv, (authored by ABataev).

Changed prior to commit:
  http://reviews.llvm.org/D20171?vs=57344&id=57579#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20171

Files:
  cfe/trunk/include/clang/Basic/LangOptions.def
  cfe/trunk/include/clang/Basic/LangOptions.h
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Driver/CLCompatOptions.td
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp

Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -610,6 +610,8 @@
   HelpText<"Use the native __fp16 type for arguments and returns (and skip ABI-specific lowering)">;
 def fallow_half_arguments_and_returns : Flag<["-"], "fallow-half-arguments-and-returns">,
   HelpText<"Allow function arguments and returns of type half">;
+def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">,
+  HelpText<"Set default MS calling convention">;
 
 // C++ TSes.
 def fcoroutines : Flag<["-"], "fcoroutines">,
Index: cfe/trunk/include/clang/Driver/CLCompatOptions.td
===
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td
@@ -268,6 +268,15 @@
 def _SLASH_Fp : CLJoined<"Fp">,
   HelpText<"Set pch filename (with /Yc and /Yu)">, MetaVarName<"">;
 
+def _SLASH_Gd : CLFlag<"Gd">,
+  HelpText<"Set __cdecl as a default calling convention">;
+def _SLASH_Gr : CLFlag<"Gr">,
+  HelpText<"Set __fastcall as a default calling convention">;
+def _SLASH_Gz : CLFlag<"Gz">,
+  HelpText<"Set __stdcall as a default calling convention">;
+def _SLASH_Gv : CLFlag<"Gv">,
+  HelpText<"Set __vectorcall as a default calling convention">;
+
 // Ignored:
 
 def _SLASH_analyze_ : CLIgnoredFlag<"analyze-">;
@@ -279,7 +288,6 @@
 def _SLASH_Fd : CLIgnoredJoined<"Fd">;
 def _SLASH_FC : CLIgnoredFlag<"FC">;
 def _SLASH_FS : CLIgnoredFlag<"FS">, HelpText<"Force synchronous PDB writes">;
-def _SLASH_Gd : CLIgnoredFlag<"Gd">;
 def _SLASH_GF : CLIgnoredFlag<"GF">;
 def _SLASH_GS_ : CLIgnoredFlag<"GS-">;
 def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">;
@@ -324,12 +332,9 @@
 def _SLASH_GL_ : CLFlag<"GL-">;
 def _SLASH_Gm : CLFlag<"Gm">;
 def _SLASH_Gm_ : CLFlag<"Gm-">;
-def _SLASH_Gr : CLFlag<"Gr">;
 def _SLASH_GS : CLFlag<"GS">;
 def _SLASH_GT : CLFlag<"GT">;
 def _SLASH_Guard : CLJoined<"guard:">;
-def _SLASH_Gv : CLFlag<"Gv">;
-def _SLASH_Gz : CLFlag<"Gz">;
 def _SLASH_GZ : CLFlag<"GZ">;
 def _SLASH_H : CLFlag<"H">;
 def _SLASH_homeparams : CLFlag<"homeparams">;
Index: cfe/trunk/include/clang/Basic/LangOptions.h
===
--- cfe/trunk/include/clang/Basic/LangOptions.h
+++ cfe/trunk/include/clang/Basic/LangOptions.h
@@ -65,6 +65,14 @@
 PPTMK_FullGeneralityVirtualInheritance
   };
 
+  enum DefaultCallingConvention {
+DCC_None,
+DCC_CDecl,
+DCC_FastCall,
+DCC_StdCall,
+DCC_VectorCall
+  };
+
   enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off };
 
   enum MSVCMajorVersion {
Index: cfe/trunk/include/clang/Basic/LangOptions.def
===
--- cfe/trunk/include/clang/Basic/LangOptions.def
+++ cfe/trunk/include/clang/Basic/LangOptions.def
@@ -172,6 +172,7 @@
 LANGOPT(CharIsSigned  , 1, 1, "signed char")
 LANGOPT(ShortWChar, 1, 0, "unsigned short wchar_t")
 ENUM_LANGOPT(MSPointerToMemberRepresentationMethod, PragmaMSPointersToMembersKind, 2, PPTMK_BestCase, "member-pointer representation method")
+ENUM_LANGOPT(DefaultCallingConv, DefaultCallingConvention, 3, DCC_None, "default calling convention")
 
 LANGOPT(ShortEnums, 1, 0, "short enum types")
 
@@ -216,7 +217,6 @@
 LANGOPT(FakeAddressSpaceMap , 1, 0, "OpenCL fake address space map")
 ENUM_LANGOPT(AddressSpaceMapMangling , AddrSpaceMapMangling, 2, ASMM_Target, "OpenCL address space map mangling mode")
 
-LANGOPT(MRTD , 1, 0, "-mrtd calling convention")
 BENIGN_LANGOPT(DelayedTemplateParsing , 1, 0, "delayed template parsing")
 LANGOPT(BlocksRuntimeOptional , 1, 0, "optional blocks runtime")
 
Index: cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp
===
--- cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp
+++ cfe/trunk/test/CodeGenCXX/default_calling_conv.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fdefault-calling-conv=cdecl -emit-llvm -o - %s | FileCheck %s --check-prefix=CDECL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i786-unkn

[PATCH] D20356: clang-rename: handle non-inline ctor definitions when renaming classes

2016-05-18 Thread Miklos Vajna via cfe-commits
vmiklos created this revision.
vmiklos added reviewers: cfe-commits, klimek.

The result of the test was C::D(), not D::D().

http://reviews.llvm.org/D20356

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/CtorDefTest.cpp

Index: test/clang-rename/CtorDefTest.cpp
===
--- /dev/null
+++ test/clang-rename/CtorDefTest.cpp
@@ -0,0 +1,15 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=133 -new-name=D %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+C();
+};
+
+C::C() // CHECK: D::D()
+{
+}
+
+// Use grep -FUbo 'C'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -79,6 +79,11 @@
 }
   }
 }
+
+if (getUSRForDecl(ConstructorDecl) == USR) {
+  // This takes care of the class name part of a non-inline ctor 
definition.
+  LocationsFound.push_back(ConstructorDecl->getLocStart());
+}
 return true;
   }
 


Index: test/clang-rename/CtorDefTest.cpp
===
--- /dev/null
+++ test/clang-rename/CtorDefTest.cpp
@@ -0,0 +1,15 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=133 -new-name=D %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+C();
+};
+
+C::C() // CHECK: D::D()
+{
+}
+
+// Use grep -FUbo 'C'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -79,6 +79,11 @@
 }
   }
 }
+
+if (getUSRForDecl(ConstructorDecl) == USR) {
+  // This takes care of the class name part of a non-inline ctor definition.
+  LocationsFound.push_back(ConstructorDecl->getLocStart());
+}
 return true;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20325: Add ARM cdp intrinsics

2016-05-18 Thread Ranjeet Singh via cfe-commits
rs marked an inline comment as done.
rs added a comment.

> It's been our stance for a long time to require docs to approve changes, 
> however small. I don't want to relax that which I think is a good constraint, 
> not for such a seemly irrelevant issue.

> I also doubt this will be the only addition in the new ACLE, so why not 
> release the document, and then submit all changes then?

> Or, maybe I am mistaken, and this is really that important... is it?


Thanks for reviewing.

It's not that important to have the intrinsic added before the document is 
released. I'll upload a new patch without the intrinsic in arm_acle.h and I'll 
move the assembly test to LLVM.


Repository:
  rL LLVM

http://reviews.llvm.org/D20325



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


Re: [PATCH] D20287: [Coverage] Ensure that the hash for a used function is non-zero.

2016-05-18 Thread Igor Kudrin via cfe-commits
ikudrin added a comment.

In http://reviews.llvm.org/D20287#431055, @davidxl wrote:

> On the other hand, I wonder what is the real root cause of the problem.  The 
> dummy function record does not have its 'own' profile counts, so
>
>   if (std::error_code EC = ProfileReader.getFunctionCounts(
>   Record.FunctionName, Record.FunctionHash, Counts)) {
>
>
> call in CoverageMapping::load (..)
>
> method should return the the counts of the used  function even with zero 
> functionhash.  What did I miss?


There are no problems in ProfileReader, because only real functions have their 
profile counts. The problem is in 
`VersionedCovMapFuncRecordReader::readFunctionRecords(...)`, which has 
difficulties in distinguishing real and dummy coverage mapping records, so that 
it might load improper ones in some cases.


http://reviews.llvm.org/D20287



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


[clang-tools-extra] r269894 - [include-fixer] Run tests with -fno-ms-compatibility.

2016-05-18 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed May 18 04:28:45 2016
New Revision: 269894

URL: http://llvm.org/viewvc/llvm-project?rev=269894&view=rev
Log:
[include-fixer] Run tests with -fno-ms-compatibility.

Something behind that flag makes us get fewer typo correction callbacks,
unbreak the tests on windows for now.

Modified:
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=269894&r1=269893&r2=269894&view=diff
==
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Wed 
May 18 04:28:45 2016
@@ -27,7 +27,9 @@ static bool runOnCode(tooling::ToolActio
   new vfs::InMemoryFileSystem);
   llvm::IntrusiveRefCntPtr Files(
   new FileManager(FileSystemOptions(), InMemoryFileSystem));
-  std::vector Args = {"include_fixer", "-fsyntax-only", FileName};
+  // FIXME: Investigate why -fms-compatibility breaks tests.
+  std::vector Args = {"include_fixer", "-fsyntax-only",
+   "-fno-ms-compatibility", FileName};
   Args.insert(Args.end(), ExtraArgs.begin(), ExtraArgs.end());
   tooling::ToolInvocation Invocation(
   Args, ToolAction, Files.get(),
@@ -130,8 +132,6 @@ TEST(IncludeFixer, MinimizeInclude) {
 runIncludeFixer("a::b::foo bar;\n", IncludePath));
 }
 
-#ifndef _WIN32
-// It doesn't pass for targeting win32. Investigating.
 TEST(IncludeFixer, NestedName) {
   // Some tests don't pass for target *-win32.
   std::vector args = {"-target", "x86_64-unknown-unknown"};
@@ -149,7 +149,6 @@ TEST(IncludeFixer, NestedName) {
 "namespace a {}\nint a = a::b::foo(0);\n",
 runIncludeFixer("namespace a {}\nint a = a::b::foo(0);\n", args));
 }
-#endif
 
 TEST(IncludeFixer, MultipleMissingSymbols) {
   EXPECT_EQ("#include \nstd::string bar;\nstd::sting foo;\n",


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


Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

2016-05-18 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG



Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:95
@@ +94,3 @@
+  if (auto *ULE = Result.Nodes.getNodeAs("used")) {
+for (auto I = ULE->decls_begin(), E = ULE->decls_end(); I != E; ++I) {
+  if (auto *USD = dyn_cast(I.getDecl()))

Range-based for loop, maybe?


http://reviews.llvm.org/D20326



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


[clang-tools-extra] r269896 - [clang-tidy] Fix a functional change from r269656.

2016-05-18 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed May 18 04:48:46 2016
New Revision: 269896

URL: http://llvm.org/viewvc/llvm-project?rev=269896&view=rev
Log:
[clang-tidy] Fix a functional change from r269656.

Instead of forming char ranges that patch made us form token ranges,
which behave subtly different. Sadly I'm only seeing this as part of a
larger test case that I haven't fully reduced yet.

Modified:
clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp

Modified: clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp?rev=269896&r1=269895&r2=269896&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp Wed May 18 
04:48:46 2016
@@ -254,8 +254,8 @@ std::vector IncludeSorter::Ge
   // Otherwise report the current block edit and start a new block.
 } else {
   if (CurrentEndLine) {
-Fixes.push_back(
-FixItHint::CreateReplacement(CurrentRange, CurrentText));
+Fixes.push_back(FixItHint::CreateReplacement(
+CharSourceRange::getCharRange(CurrentRange), CurrentText));
   }
 
   CurrentEndLine = LineEdit.first;
@@ -265,7 +265,8 @@ std::vector IncludeSorter::Ge
   }
   // Finally, report the current block edit if there is one.
   if (CurrentEndLine) {
-Fixes.push_back(FixItHint::CreateReplacement(CurrentRange, CurrentText));
+Fixes.push_back(FixItHint::CreateReplacement(
+CharSourceRange::getCharRange(CurrentRange), CurrentText));
   }
 
   // Reset the remaining internal state.


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


Re: [PATCH] D20325: Add ARM cdp intrinsics

2016-05-18 Thread Renato Golin via cfe-commits
rengolin added a comment.

Thanks Ranjeet,

The tests don't really need the new builtin to exist at all and can be added 
now.

When you submit the __arm_cdp patch, you just need to make sure Clang generates 
a call to @llvm.arm.cdp and everything else will be covered.

cheers,
--renato


Repository:
  rL LLVM

http://reviews.llvm.org/D20325



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


Re: [PATCH] D20349: Fix a clang bug in lambda capture of 'this'

2016-05-18 Thread Faisal Vali via cfe-commits
Thanks for the work here - but this bug is a duplicate of this:
https://llvm.org/bugs/show_bug.cgi?id=27507, which unearthed some
other subtle bugs with the cv capture of *this by copy.
I've submitted a patch for review here: http://reviews.llvm.org/D19783
that addresses both issues - about 2-3 weeks ago -  given the
nastiness of this bug, the fact that it was introduced by one of my
patches and that there is now a second report of the bug - and that I
feel reasonably good about the fix - I'll commit this patch before the
weekend, unless Richard raises an issue.


Faisal Vali



On Tue, May 17, 2016 at 11:23 PM, Taewook Oh  wrote:
> twoh created this revision.
> twoh added reviewers: faisalv, rsmith.
> twoh added a subscriber: cfe-commits.
>
> (This is a fix for Bug 27797 https://llvm.org/bugs/show_bug.cgi?id=27797).
>
> Currently when RebuildLambdaScopeInfo() function in lib/Sema/SemaDecl.cpp 
> observes lambda capturing 'this', it calls Sema::getCurrentThisType() to get 
> the type of 'this'. However, clang (revision 269789) crashes with an 
> assertion failure inside Sema::getCurrentThisType() if template instantiation 
> creates nested lambdas. Inside, Sema::getCurrentThisType(), there is an 
> assertion saying that getCurLambda() never returns nullptr, but nest lambdas 
> created by template instantiation makes getCurLambda() returns nullptr.
>
> Actually, even without the assertion failure, calling 
> Sema::getCurrentThisType() from RebuildLambdaScopeInfo() seems wrong. When 
> there are nested lambdas, what is required from Sema::getCurrentThisType() is 
> a type of 'this' for nesting lambda, while what is supposed to be returned 
> from Sema::getCurrentThisType() is a type of 'this' for nested lambda.
>
> This patch addresses this issue and makes RebuildLambdaScopeInfo() compute 
> the correct 'this' type.
>
> http://reviews.llvm.org/D20349
>
> Files:
>   lib/Sema/SemaDecl.cpp
>
> Index: lib/Sema/SemaDecl.cpp
> ===
> --- lib/Sema/SemaDecl.cpp
> +++ lib/Sema/SemaDecl.cpp
> @@ -11109,8 +11109,16 @@
>CaptureType, /*Expr*/ nullptr);
>
>  } else if (C.capturesThis()) {
> +  QualType ThisTy = CallOperator->getThisType(S.Context);
> +  QualType BaseTy = ThisTy->getPointeeType();
> +  if (C.getCaptureKind() == LCK_StarThis &&
> +  CallOperator->isConst() &&
> +  !BaseTy.isConstQualified()) {
> +BaseTy.addConst();
> +ThisTy = S.Context.getPointerType(BaseTy);
> +  }
>LSI->addThisCapture(/*Nested*/ false, C.getLocation(),
> -  S.getCurrentThisType(), /*Expr*/ nullptr,
> +  ThisTy, /*Expr*/ nullptr,
>C.getCaptureKind() == LCK_StarThis);
>  } else {
>LSI->addVLATypeCapture(C.getLocation(), I->getType());
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57586.
hokein marked an inline comment as done.
hokein added a comment.

Use for-range loop.


http://reviews.llvm.org/D20326

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -16,6 +16,7 @@
  public:
   static int ii;
 };
+template  class J {};
 
 class Base {
  public:
@@ -29,6 +30,7 @@
 int UnusedFunc() { return 1; }
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
+template  int UsedInTemplateFunc() { return 1; }
 
 class ostream {
 public:
@@ -70,6 +72,13 @@
 using n::cout;
 using n::endl;
 
+using n::UsedInTemplateFunc;
+using n::J;
+template  void Callee() {
+  J j;
+  UsedInTemplateFunc();
+}
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,20 +10,29 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
+namespace {
+// FIXME: Move this node matcher to ASTMatcher.
+const internal::VariadicDynCastAllOfMatcher
+unresolvedLookupExpr;
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
   Finder->addMatcher(declRefExpr().bind("used"), this);
+  Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
+ this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -81,6 +90,13 @@
   removeFromFoundDecls(VD);
 }
   }
+  // Check the uninstantiated template function usage.
+  if (const auto *ULE = Result.Nodes.getNodeAs("used")) {
+for (const NamedDecl* ND : ULE->decls()) {
+  if (const auto *USD = dyn_cast(ND))
+removeFromFoundDecls(USD->getTargetDecl()->getCanonicalDecl());
+}
+  }
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {


Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -16,6 +16,7 @@
  public:
   static int ii;
 };
+template  class J {};
 
 class Base {
  public:
@@ -29,6 +30,7 @@
 int UnusedFunc() { return 1; }
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
+template  int UsedInTemplateFunc() { return 1; }
 
 class ostream {
 public:
@@ -70,6 +72,13 @@
 using n::cout;
 using n::endl;
 
+using n::UsedInTemplateFunc;
+using n::J;
+template  void Callee() {
+  J j;
+  UsedInTemplateFunc();
+}
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,20 +10,29 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
+namespace {
+// FIXME: Move this node matcher to ASTMatcher.
+const internal::VariadicDynCastAllOfMatcher
+unresolvedLookupExpr;
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
   Finder->addMatcher(declRefExpr().bind("used"), this);
+  Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
+ this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -81,6 +90,13 @@
   removeFromFoundDecls(VD);
 }
   }
+  // Check the uninstantiated template function usage.
+  if (const auto *ULE = Result.Nodes.getNodeAs("used")) {
+

Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.
hokein added a comment.

http://reviews.llvm.org/D20326



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


Re: [PATCH] D20356: clang-rename: handle non-inline ctor definitions when renaming classes

2016-05-18 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D20356



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


Re: [clang-tools-extra] r269896 - [clang-tidy] Fix a functional change from r269656.

2016-05-18 Thread Alexander Kornienko via cfe-commits
Thank you for fixing this!

On Wed, May 18, 2016 at 11:48 AM, Benjamin Kramer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: d0k
> Date: Wed May 18 04:48:46 2016
> New Revision: 269896
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269896&view=rev
> Log:
> [clang-tidy] Fix a functional change from r269656.
>
> Instead of forming char ranges that patch made us form token ranges,
> which behave subtly different. Sadly I'm only seeing this as part of a
> larger test case that I haven't fully reduced yet.
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp
>
> Modified: clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp?rev=269896&r1=269895&r2=269896&view=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp (original)
> +++ clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp Wed May 18
> 04:48:46 2016
> @@ -254,8 +254,8 @@ std::vector IncludeSorter::Ge
>// Otherwise report the current block edit and start a new block.
>  } else {
>if (CurrentEndLine) {
> -Fixes.push_back(
> -FixItHint::CreateReplacement(CurrentRange, CurrentText));
> +Fixes.push_back(FixItHint::CreateReplacement(
> +CharSourceRange::getCharRange(CurrentRange), CurrentText));
>}
>
>CurrentEndLine = LineEdit.first;
> @@ -265,7 +265,8 @@ std::vector IncludeSorter::Ge
>}
>// Finally, report the current block edit if there is one.
>if (CurrentEndLine) {
> -Fixes.push_back(FixItHint::CreateReplacement(CurrentRange,
> CurrentText));
> +Fixes.push_back(FixItHint::CreateReplacement(
> +CharSourceRange::getCharRange(CurrentRange), CurrentText));
>}
>
>// Reset the remaining internal state.
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D20358: Convert AVX non-temporal store builtins to LLVM-native IR.

2016-05-18 Thread michael zuckerman via cfe-commits
m_zuckerman created this revision.
m_zuckerman added a reviewer: craig.topper.
m_zuckerman added subscribers: delena, cfe-commits.

http://reviews.llvm.org/D20358

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx512f-builtins.c

Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -6571,10 +6571,13 @@
   }
   case X86::BI__builtin_ia32_movntps:
   case X86::BI__builtin_ia32_movntps256:
+  case X86::BI__builtin_ia32_movntps512:
   case X86::BI__builtin_ia32_movntpd:
   case X86::BI__builtin_ia32_movntpd256:
+  case X86::BI__builtin_ia32_movntpd512:
   case X86::BI__builtin_ia32_movntdq:
   case X86::BI__builtin_ia32_movntdq256:
+  case X86::BI__builtin_ia32_movntdq512:
   case X86::BI__builtin_ia32_movnti:
   case X86::BI__builtin_ia32_movnti64: {
 llvm::MDNode *Node = llvm::MDNode::get(
Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -5529,7 +5529,8 @@
 
 void test_mm512_stream_si512(__m512i * __P, __m512i __A) {
   // CHECK-LABEL: @test_mm512_stream_si512
-  // CHECK: @llvm.x86.avx512.storent.q.512
+  // CHECK-NOT: call
+  // CHECK: store <8 x i64> %3, <8 x i64>* %2, align 64, !nontemporal !1
   _mm512_stream_si512(__P, __A); 
 }
 
@@ -5541,13 +5542,15 @@
 
 void test_mm512_stream_pd(double *__P, __m512d __A) {
   // CHECK-LABEL: @test_mm512_stream_pd
-  // CHECK: @llvm.x86.avx512.storent.pd.512
+  // CHECK-NOT: call
+  // CHECK: store <8 x double> %3, <8 x double>* %cast.i, align 64, 
!nontemporal !1
   return _mm512_stream_pd(__P, __A); 
 }
 
 void test_mm512_stream_ps(float *__P, __m512 __A) {
   // CHECK-LABEL: @test_mm512_stream_ps
-  // CHECK: @llvm.x86.avx512.storent.ps.512
+  // CHECK-NOT: call
+  // CHECK: store <16 x float> %3, <16 x float>* %cast.i, align 64, 
!nontemporal !1
   _mm512_stream_ps(__P, __A); 
 }
 


Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -6571,10 +6571,13 @@
   }
   case X86::BI__builtin_ia32_movntps:
   case X86::BI__builtin_ia32_movntps256:
+  case X86::BI__builtin_ia32_movntps512:
   case X86::BI__builtin_ia32_movntpd:
   case X86::BI__builtin_ia32_movntpd256:
+  case X86::BI__builtin_ia32_movntpd512:
   case X86::BI__builtin_ia32_movntdq:
   case X86::BI__builtin_ia32_movntdq256:
+  case X86::BI__builtin_ia32_movntdq512:
   case X86::BI__builtin_ia32_movnti:
   case X86::BI__builtin_ia32_movnti64: {
 llvm::MDNode *Node = llvm::MDNode::get(
Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -5529,7 +5529,8 @@
 
 void test_mm512_stream_si512(__m512i * __P, __m512i __A) {
   // CHECK-LABEL: @test_mm512_stream_si512
-  // CHECK: @llvm.x86.avx512.storent.q.512
+  // CHECK-NOT: call
+  // CHECK: store <8 x i64> %3, <8 x i64>* %2, align 64, !nontemporal !1
   _mm512_stream_si512(__P, __A); 
 }
 
@@ -5541,13 +5542,15 @@
 
 void test_mm512_stream_pd(double *__P, __m512d __A) {
   // CHECK-LABEL: @test_mm512_stream_pd
-  // CHECK: @llvm.x86.avx512.storent.pd.512
+  // CHECK-NOT: call
+  // CHECK: store <8 x double> %3, <8 x double>* %cast.i, align 64, !nontemporal !1
   return _mm512_stream_pd(__P, __A); 
 }
 
 void test_mm512_stream_ps(float *__P, __m512 __A) {
   // CHECK-LABEL: @test_mm512_stream_ps
-  // CHECK: @llvm.x86.avx512.storent.ps.512
+  // CHECK-NOT: call
+  // CHECK: store <16 x float> %3, <16 x float>* %cast.i, align 64, !nontemporal !1
   _mm512_stream_ps(__P, __A); 
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D20359: Convert AVX non-temporal store builtins to LLVM-native IR. This was previously done for SSE builtins.

2016-05-18 Thread michael zuckerman via cfe-commits
m_zuckerman created this revision.
m_zuckerman added a reviewer: craig.topper.
m_zuckerman added subscribers: delena, cfe-commits, AsafBadouh, igorb.

http://reviews.llvm.org/D20359

Files:
  include/llvm/IR/IntrinsicsX86.td
  lib/Target/X86/X86IntrinsicsInfo.h
  test/CodeGen/X86/avx512-intrinsics.ll

Index: lib/Target/X86/X86IntrinsicsInfo.h
===
--- lib/Target/X86/X86IntrinsicsInfo.h
+++ lib/Target/X86/X86IntrinsicsInfo.h
@@ -276,9 +276,6 @@
   X86_INTRINSIC_DATA(avx512_scattersiv4_si, SCATTER, X86::VPSCATTERDDZ128mr, 
0),
   X86_INTRINSIC_DATA(avx512_scattersiv8_sf, SCATTER, X86::VSCATTERDPSZ256mr, 
0),
   X86_INTRINSIC_DATA(avx512_scattersiv8_si, SCATTER, X86::VPSCATTERDDZ256mr, 
0),
-  X86_INTRINSIC_DATA(avx512_storent_pd_512, STOREANT, ISD::DELETED_NODE, 0),
-  X86_INTRINSIC_DATA(avx512_storent_ps_512, STOREANT, ISD::DELETED_NODE, 0),
-  X86_INTRINSIC_DATA(avx512_storent_q_512,  STOREANT, ISD::DELETED_NODE, 0),
   X86_INTRINSIC_DATA(rdpmc, RDPMC,  X86ISD::RDPMC_DAG, 0),
   X86_INTRINSIC_DATA(rdrand_16, RDRAND, X86ISD::RDRAND, 0),
   X86_INTRINSIC_DATA(rdrand_32, RDRAND, X86ISD::RDRAND, 0),
Index: include/llvm/IR/IntrinsicsX86.td
===
--- include/llvm/IR/IntrinsicsX86.td
+++ include/llvm/IR/IntrinsicsX86.td
@@ -2234,18 +2234,6 @@
   [IntrArgMemOnly]>;
 }
 
-// Store ops using non-temporal hint
-let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
-  def int_x86_avx512_storent_q_512 :
-GCCBuiltin<"__builtin_ia32_movntdq512">,
-Intrinsic<[], [llvm_ptr_ty, llvm_v8i64_ty], [IntrArgMemOnly]>;
-  def int_x86_avx512_storent_pd_512 :
-GCCBuiltin<"__builtin_ia32_movntpd512">,
-Intrinsic<[], [llvm_ptr_ty, llvm_v8f64_ty], [IntrArgMemOnly]>;
-  def int_x86_avx512_storent_ps_512 :
-GCCBuiltin<"__builtin_ia32_movntps512">,
-Intrinsic<[], [llvm_ptr_ty, llvm_v16f32_ty], [IntrArgMemOnly]>;
-}
 
//===--===//
 // AVX2
 
Index: test/CodeGen/X86/avx512-intrinsics.ll
===
--- test/CodeGen/X86/avx512-intrinsics.ll
+++ test/CodeGen/X86/avx512-intrinsics.ll
@@ -7413,39 +7413,6 @@
   ret <2 x double> %res4
 }
 
-declare void @llvm.x86.avx512.storent.q.512(i8*, <8 x i64>)
-
-define void@test_storent_q_512(<8 x i64> %data, i8* %ptr) {
-; CHECK-LABEL: test_storent_q_512:
-; CHECK:   ## BB#0:
-; CHECK-NEXT:vmovntdq %zmm0, (%rdi)
-; CHECK-NEXT:retq
-  call void @llvm.x86.avx512.storent.q.512(i8* %ptr, <8 x i64> %data)
-  ret void
-}
-
-declare void @llvm.x86.avx512.storent.pd.512(i8*, <8 x double>)
-
-define void @test_storent_pd_512(<8 x double> %data, i8* %ptr) {
-; CHECK-LABEL: test_storent_pd_512:
-; CHECK:   ## BB#0:
-; CHECK-NEXT:vmovntpd %zmm0, (%rdi)
-; CHECK-NEXT:retq
-  call void @llvm.x86.avx512.storent.pd.512(i8* %ptr, <8 x double> %data)
-  ret void
-}
-
-declare void @llvm.x86.avx512.storent.ps.512(i8*, <16 x float>)
-
-define void @test_storent_ps_512(<16 x float> %data, i8* %ptr) {
-; CHECK-LABEL: test_storent_ps_512:
-; CHECK:   ## BB#0:
-; CHECK-NEXT:vmovntps %zmm0, (%rdi)
-; CHECK-NEXT:retq
-  call void @llvm.x86.avx512.storent.ps.512(i8* %ptr, <16 x float> %data)
-  ret void
-}
-
 declare i16 @llvm.x86.avx512.ptestnm.d.512(<16 x i32>, <16 x i32>, i16 %x2)
 
 define i16@test_int_x86_avx512_ptestnm_d_512(<16 x i32> %x0, <16 x i32> %x1, 
i16 %x2) {


Index: lib/Target/X86/X86IntrinsicsInfo.h
===
--- lib/Target/X86/X86IntrinsicsInfo.h
+++ lib/Target/X86/X86IntrinsicsInfo.h
@@ -276,9 +276,6 @@
   X86_INTRINSIC_DATA(avx512_scattersiv4_si, SCATTER, X86::VPSCATTERDDZ128mr, 0),
   X86_INTRINSIC_DATA(avx512_scattersiv8_sf, SCATTER, X86::VSCATTERDPSZ256mr, 0),
   X86_INTRINSIC_DATA(avx512_scattersiv8_si, SCATTER, X86::VPSCATTERDDZ256mr, 0),
-  X86_INTRINSIC_DATA(avx512_storent_pd_512, STOREANT, ISD::DELETED_NODE, 0),
-  X86_INTRINSIC_DATA(avx512_storent_ps_512, STOREANT, ISD::DELETED_NODE, 0),
-  X86_INTRINSIC_DATA(avx512_storent_q_512,  STOREANT, ISD::DELETED_NODE, 0),
   X86_INTRINSIC_DATA(rdpmc, RDPMC,  X86ISD::RDPMC_DAG, 0),
   X86_INTRINSIC_DATA(rdrand_16, RDRAND, X86ISD::RDRAND, 0),
   X86_INTRINSIC_DATA(rdrand_32, RDRAND, X86ISD::RDRAND, 0),
Index: include/llvm/IR/IntrinsicsX86.td
===
--- include/llvm/IR/IntrinsicsX86.td
+++ include/llvm/IR/IntrinsicsX86.td
@@ -2234,18 +2234,6 @@
   [IntrArgMemOnly]>;
 }
 
-// Store ops using non-temporal hint
-let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
-  def int_x86_avx512_storent_q_512 :
-GCCBuiltin<"__builtin_ia32_movntdq512">,
-Intrinsic<[], [llvm_ptr_ty, llvm_v8i64_ty], [IntrArgMemOnly]>;
-  def int_x86_avx512_st

[PATCH] D20360: [ASTMatcher] Add a node matcher for UnresolvedLookupExpr.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: alexfh.
hokein added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

http://reviews.llvm.org/D20360

Files:
  docs/LibASTMatchersReference.html
  docs/tools/dump_ast_matchers.py
  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
@@ -1132,6 +1132,16 @@
  declaratorDecl(hasTypeLoc(loc(asString("int"));
 }
 
+TEST(Matcher, UnresolvedLookupExpr) {
+  EXPECT_TRUE(matches("template"
+  "T foo() { T a; return a; }"
+  "template"
+  "void bar() {"
+  "  foo();"
+  "}",
+  unresolvedLookupExpr()));
+}
+
 TEST(Matcher, Call) {
   // FIXME: Do we want to overload Call() to directly take
   // Matcher, too?
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -397,6 +397,7 @@
   REGISTER_MATCHER(unaryOperator);
   REGISTER_MATCHER(unaryTransformType);
   REGISTER_MATCHER(unless);
+  REGISTER_MATCHER(unresolvedLookupExpr);
   REGISTER_MATCHER(unresolvedUsingTypenameDecl);
   REGISTER_MATCHER(unresolvedUsingValueDecl);
   REGISTER_MATCHER(userDefinedLiteral);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1086,6 +1086,24 @@
   Decl,
   UsingDirectiveDecl> usingDirectiveDecl;
 
+/// \brief Matches reference to a name which can be able to look up during
+/// parsing but could not be resolved to a specific declaration.
+///
+/// Given
+/// \code
+///   template
+///   T foo() { T a; return a; }
+///   template
+///   void bar() {
+/// foo();
+///   }
+/// \endcode
+/// unresolvedLookupExpr()
+///   matches \code foo() \endcode
+const internal::VariadicDynCastAllOfMatcher<
+   Stmt,
+   UnresolvedLookupExpr> unresolvedLookupExpr;
+
 /// \brief Matches unresolved using value declarations.
 ///
 /// Given
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -1275,6 +1275,21 @@
 
 
 
+MatcherStmt>unresolvedLookupExprMatcherUnresolvedLookupExpr>...
+Matches 
reference to a name which can be able to look up during
+parsing but could not be resolved to a specific declaration.
+
+Given
+  template
+  T foo() { T a; return a; }
+  template
+  void bar() {
+foo();
+  }
+unresolvedLookupExpr()
+  matches foo() 
+
+
 MatcherStmt>userDefinedLiteralMatcherUserDefinedLiteral>...
 Matches user 
defined literal operator call.
 


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1132,6 +1132,16 @@
  declaratorDecl(hasTypeLoc(loc(asString("int"));
 }
 
+TEST(Matcher, UnresolvedLookupExpr) {
+  EXPECT_TRUE(matches("template"
+  "T foo() { T a; return a; }"
+  "template"
+  "void bar() {"
+  "  foo();"
+  "}",
+  unresolvedLookupExpr()));
+}
+
 TEST(Matcher, Call) {
   // FIXME: Do we want to overload Call() to directly take
   // Matcher, too?
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -397,6 +397,7 @@
   REGISTER_MATCHER(unaryOperator);
   REGISTER_MATCHER(unaryTransformType);
   REGISTER_MATCHER(unless);
+  REGISTER_MATCHER(unresolvedLookupExpr);
   REGISTER_MATCHER(unresolvedUsingTypenameDecl);
   REGISTER_MATCHER(unresolvedUsingValueDecl);
   REGISTER_MATCHER(userDefinedLiteral);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1086,6 +1086,24 @@
   Decl,
   UsingDirectiveDecl> usingDirectiveDecl;
 
+/// \brief Matches reference to a name which can be able to look up during
+/// parsing but could not be resolved t

[clang-tools-extra] r269906 - [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

2016-05-18 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed May 18 06:49:34 2016
New Revision: 269906

URL: http://llvm.org/viewvc/llvm-project?rev=269906&view=rev
Log:
[clang-tidy] Fix a template function false positive in misc-unused-using-decls 
check.

Summary: Ignore warning uninstantiated template function usages.

Reviewers: djasper, alexfh

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp?rev=269906&r1=269905&r2=269906&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp Wed May 
18 06:49:34 2016
@@ -10,6 +10,7 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
@@ -18,12 +19,20 @@ namespace clang {
 namespace tidy {
 namespace misc {
 
+namespace {
+// FIXME: Move this node matcher to ASTMatcher.
+const internal::VariadicDynCastAllOfMatcher
+unresolvedLookupExpr;
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
   Finder->addMatcher(declRefExpr().bind("used"), this);
+  Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
+ this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -81,6 +90,13 @@ void UnusedUsingDeclsCheck::check(const
   removeFromFoundDecls(VD);
 }
   }
+  // Check the uninstantiated template function usage.
+  if (const auto *ULE = Result.Nodes.getNodeAs("used")) {
+for (const NamedDecl* ND : ULE->decls()) {
+  if (const auto *USD = dyn_cast(ND))
+removeFromFoundDecls(USD->getTargetDecl()->getCanonicalDecl());
+}
+  }
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp?rev=269906&r1=269905&r2=269906&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp Wed May 
18 06:49:34 2016
@@ -16,6 +16,7 @@ class I {
  public:
   static int ii;
 };
+template  class J {};
 
 class Base {
  public:
@@ -29,6 +30,7 @@ int UsedFunc() { return 1; }
 int UnusedFunc() { return 1; }
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
+template  int UsedInTemplateFunc() { return 1; }
 
 class ostream {
 public:
@@ -70,6 +72,13 @@ using n::UnusedFunc; // UnusedFunc
 using n::cout;
 using n::endl;
 
+using n::UsedInTemplateFunc;
+using n::J;
+template  void Callee() {
+  J j;
+  UsedInTemplateFunc();
+}
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \


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


Re: [PATCH] D20326: [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.

2016-05-18 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269906: [clang-tidy] Fix a template function false positive 
in misc-unused-using… (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20326?vs=57586&id=57591#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20326

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp

Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,20 +10,29 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
+namespace {
+// FIXME: Move this node matcher to ASTMatcher.
+const internal::VariadicDynCastAllOfMatcher
+unresolvedLookupExpr;
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
   Finder->addMatcher(declRefExpr().bind("used"), this);
+  Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
+ this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -81,6 +90,13 @@
   removeFromFoundDecls(VD);
 }
   }
+  // Check the uninstantiated template function usage.
+  if (const auto *ULE = Result.Nodes.getNodeAs("used")) {
+for (const NamedDecl* ND : ULE->decls()) {
+  if (const auto *USD = dyn_cast(ND))
+removeFromFoundDecls(USD->getTargetDecl()->getCanonicalDecl());
+}
+  }
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
@@ -16,6 +16,7 @@
  public:
   static int ii;
 };
+template  class J {};
 
 class Base {
  public:
@@ -29,6 +30,7 @@
 int UnusedFunc() { return 1; }
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
+template  int UsedInTemplateFunc() { return 1; }
 
 class ostream {
 public:
@@ -70,6 +72,13 @@
 using n::cout;
 using n::endl;
 
+using n::UsedInTemplateFunc;
+using n::J;
+template  void Callee() {
+  J j;
+  UsedInTemplateFunc();
+}
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \


Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,20 +10,29 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
+namespace {
+// FIXME: Move this node matcher to ASTMatcher.
+const internal::VariadicDynCastAllOfMatcher
+unresolvedLookupExpr;
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
   Finder->addMatcher(declRefExpr().bind("used"), this);
+  Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
+ this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -81,6 +90,13 @@
   removeFromFoundDecls(VD);
 }
   }
+  // Check the uninstantiated template function usage.
+  if (const auto *ULE = Result.Nodes.getNodeAs("used")) {
+for (const NamedDecl* ND : ULE->decls()) {
+  if (const auto *USD = dyn_cast(ND))
+removeFromFoundDecls(USD->getTargetDecl()->getCanonicalDecl());
+}
+  }
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
=

Re: [PATCH] D20360: [ASTMatcher] Add a node matcher for UnresolvedLookupExpr.

2016-05-18 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

The changes to docs/tools/dump_ast_matchers.py look to be spurious, can they be 
reverted?



Comment at: include/clang/ASTMatchers/ASTMatchers.h:1089
@@ -1088,1 +1088,3 @@
 
+/// \brief Matches reference to a name which can be able to look up during
+/// parsing but could not be resolved to a specific declaration.

s/which can be able to look up/that can be looked up


http://reviews.llvm.org/D20360



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


Re: [PATCH] D20360: [ASTMatcher] Add a node matcher for UnresolvedLookupExpr.

2016-05-18 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D20360#432874, @aaron.ballman wrote:

> The changes to docs/tools/dump_ast_matchers.py look to be spurious, can they 
> be reverted?


The script should be executable, so the change looks fine to me.


http://reviews.llvm.org/D20360



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


r269910 - Update for llvm change.

2016-05-18 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed May 18 06:58:56 2016
New Revision: 269910

URL: http://llvm.org/viewvc/llvm-project?rev=269910&view=rev
Log:
Update for llvm change.

Modified:
cfe/trunk/lib/Parse/ParseStmtAsm.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=269910&r1=269909&r2=269910&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Wed May 18 06:58:56 2016
@@ -572,8 +572,8 @@ StmtResult Parser::ParseMicrosoftAsmStat
 
   llvm::SourceMgr TempSrcMgr;
   llvm::MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &TempSrcMgr);
-  MOFI->InitMCObjectFileInfo(TheTriple, llvm::Reloc::Default,
- llvm::CodeModel::Default, Ctx);
+  MOFI->InitMCObjectFileInfo(TheTriple, /*PIG*/ false, 
llvm::CodeModel::Default,
+ Ctx);
   std::unique_ptr Buffer =
   llvm::MemoryBuffer::getMemBuffer(AsmString, "");
 

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=269910&r1=269909&r2=269910&view=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Wed May 18 06:58:56 2016
@@ -326,19 +326,18 @@ static bool ExecuteAssembler(AssemblerIn
 
   MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr);
 
-  llvm::Reloc::Model RM = llvm::Reloc::Default;
+  bool PIC = false;
   if (Opts.RelocationModel == "static") {
-RM = llvm::Reloc::Static;
+PIC = false;
   } else if (Opts.RelocationModel == "pic") {
-RM = llvm::Reloc::PIC_;
+PIC = true;
   } else {
 assert(Opts.RelocationModel == "dynamic-no-pic" &&
"Invalid PIC model!");
-RM = llvm::Reloc::DynamicNoPIC;
+PIC = false;
   }
 
-  MOFI->InitMCObjectFileInfo(Triple(Opts.Triple), RM,
- CodeModel::Default, Ctx);
+  MOFI->InitMCObjectFileInfo(Triple(Opts.Triple), PIC, CodeModel::Default, 
Ctx);
   if (Opts.SaveTemporaryLabels)
 Ctx.setAllowTemporaryLabels(false);
   if (Opts.GenDwarfForAssembly)


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


Re: [PATCH] D20360: [ASTMatcher] Add a node matcher for UnresolvedLookupExpr.

2016-05-18 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D20360#432878, @alexfh wrote:

> In http://reviews.llvm.org/D20360#432874, @aaron.ballman wrote:
>
> > The changes to docs/tools/dump_ast_matchers.py look to be spurious, can 
> > they be reverted?
>
>
> The script should be executable, so the change looks fine to me.


World executable? That's a bit presumptuous. ;-) 0744 may be fine, but 0755 
does not seem correct to me.

Regardless, I think that it should be a separate commit, not part of this one 
as a drive-by (it has security implications, and that deserves review).


http://reviews.llvm.org/D20360



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


Re: [PATCH] D19796: Add new intrinsic support for MONITORX and MWAITX instructions.

2016-05-18 Thread Ashutosh Nema via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269907: Add new intrinsic support for MONITORX and MWAITX 
instructions (authored by Ashutosh).

Changed prior to commit:
  http://reviews.llvm.org/D19796?vs=55788&id=57593#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19796

Files:
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Headers/CMakeLists.txt
  cfe/trunk/lib/Headers/module.modulemap
  cfe/trunk/lib/Headers/mwaitxintrin.h
  cfe/trunk/lib/Headers/x86intrin.h
  cfe/trunk/test/CodeGen/builtins-x86.c

Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -2273,6 +2273,7 @@
   bool HasXSAVEOPT = false;
   bool HasXSAVEC = false;
   bool HasXSAVES = false;
+  bool HasMWAITX = false;
   bool HasPKU = false;
   bool HasCLFLUSHOPT = false;
   bool HasPCOMMIT = false;
@@ -2947,6 +2948,7 @@
   case CK_BDVER4:
 setFeatureEnabledImpl(Features, "avx2", true);
 setFeatureEnabledImpl(Features, "bmi2", true);
+setFeatureEnabledImpl(Features, "mwaitx", true);
 // FALLTHROUGH
   case CK_BDVER3:
 setFeatureEnabledImpl(Features, "fsgsbase", true);
@@ -3266,6 +3268,8 @@
   HasXSAVEC = true;
 } else if (Feature == "+xsaves") {
   HasXSAVES = true;
+} else if (Feature == "+mwaitx") {
+  HasMWAITX = true;
 } else if (Feature == "+pku") {
   HasPKU = true;
 } else if (Feature == "+clflushopt") {
@@ -3538,6 +3542,9 @@
   if (HasTBM)
 Builder.defineMacro("__TBM__");
 
+  if (HasMWAITX)
+Builder.defineMacro("__MWAITX__");
+
   switch (XOPLevel) {
   case XOP:
 Builder.defineMacro("__XOP__");
Index: cfe/trunk/lib/Headers/mwaitxintrin.h
===
--- cfe/trunk/lib/Headers/mwaitxintrin.h
+++ cfe/trunk/lib/Headers/mwaitxintrin.h
@@ -0,0 +1,47 @@
+/*=== mwaitxintrin.h - MONITORX/MWAITX intrinsics --===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+#ifndef __X86INTRIN_H
+#error "Never use  directly; include  instead."
+#endif
+
+#ifndef _MWAITXINTRIN_H
+#define _MWAITXINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__,  __target__("mwaitx")))
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm_monitorx(void const * __p, unsigned __extensions, unsigned __hints)
+{
+  __builtin_ia32_monitorx((void *)__p, __extensions, __hints);
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm_mwaitx(unsigned __extensions, unsigned __hints, unsigned __clock)
+{
+  __builtin_ia32_mwaitx(__extensions, __hints, __clock);
+}
+
+#undef __DEFAULT_FN_ATTRS 
+
+#endif /* _MWAITXINTRIN_H */
Index: cfe/trunk/lib/Headers/CMakeLists.txt
===
--- cfe/trunk/lib/Headers/CMakeLists.txt
+++ cfe/trunk/lib/Headers/CMakeLists.txt
@@ -78,6 +78,7 @@
   xsaveoptintrin.h
   xsavecintrin.h
   xsavesintrin.h
+  mwaitxintrin.h
   xtestintrin.h
   avx512ifmaintrin.h
   avx512ifmavlintrin.h
Index: cfe/trunk/lib/Headers/x86intrin.h
===
--- cfe/trunk/lib/Headers/x86intrin.h
+++ cfe/trunk/lib/Headers/x86intrin.h
@@ -76,6 +76,10 @@
 #include 
 #endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__MWAITX__)
+#include 
+#endif
+
 /* FIXME: LWP */
 
 #endif /* __X86INTRIN_H */
Index: cfe/trunk/lib/Headers/module.modulemap
===
--- cfe/trunk/lib/Headers/module.modulemap
+++ cfe/trunk/lib/Headers/module.modulemap
@@ -125,6 +125,10 @@
   export pclmul
  

r269907 - Add new intrinsic support for MONITORX and MWAITX instructions

2016-05-18 Thread Ashutosh Nema via cfe-commits
Author: ashutosh
Date: Wed May 18 06:56:23 2016
New Revision: 269907

URL: http://llvm.org/viewvc/llvm-project?rev=269907&view=rev
Log:
Add new intrinsic support for MONITORX and MWAITX instructions

Summary:
MONITORX/MWAITX instructions provide similar capability to the MONITOR/MWAIT
pair while adding a timer function, such that another termination of the MWAITX
instruction occurs when the timer expires. The presence of the MONITORX and 
MWAITX instructions is indicated by CPUID 8000_0001, ECX, bit 29.

The MONITORX and MWAITX instructions are intercepted by the same bits that
intercept MONITOR and MWAIT. MONITORX instruction establishes a range to be
monitored. MWAITX instruction causes the processor to stop instruction
execution and enter an implementation-dependent optimized state until
occurrence of a class of events.

Opcode of MONITORX instruction is "0F 01 FA". Opcode of MWAITX instruction is
"0F 01 FB". These opcode information is used in adding tests for the
disassembler.

These instructions are enabled for AMD's bdver4 architecture.

Patch by Ganesh Gopalasubramanian!

Reviewers: echristo, craig.topper

Subscribers: RKSimon, joker.eph, llvm-commits, cfe-commits

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

Added:
cfe/trunk/lib/Headers/mwaitxintrin.h
Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/module.modulemap
cfe/trunk/lib/Headers/x86intrin.h
cfe/trunk/test/CodeGen/builtins-x86.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=269907&r1=269906&r2=269907&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed May 18 06:56:23 2016
@@ -2272,5 +2272,9 @@ TARGET_BUILTIN(__builtin_ia32_cvtusi2sd6
 TARGET_BUILTIN(__builtin_ia32_cvtusi2ss32, "V4fV4fUiIi","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvtusi2ss64, "V4fV4fULLiIi","","avx512f")
 
+// MONITORX/MWAITX
+TARGET_BUILTIN(__builtin_ia32_monitorx, "vv*UiUi", "", "mwaitx")
+TARGET_BUILTIN(__builtin_ia32_mwaitx, "vUiUiUi", "", "mwaitx")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=269907&r1=269906&r2=269907&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed May 18 06:56:23 2016
@@ -1425,6 +1425,7 @@ def mno_xsave : Flag<["-"], "mno-xsave">
 def mno_xsaveopt : Flag<["-"], "mno-xsaveopt">, Group;
 def mno_xsavec : Flag<["-"], "mno-xsavec">, Group;
 def mno_xsaves : Flag<["-"], "mno-xsaves">, Group;
+def mno_mwaitx : Flag<["-"], "mno-mwaitx">, Group;
 def mno_pku : Flag<["-"], "mno-pku">, Group;
 
 def munaligned_access : Flag<["-"], "munaligned-access">, 
Group,
@@ -1610,6 +1611,7 @@ def mxsave : Flag<["-"], "mxsave">, Grou
 def mxsaveopt : Flag<["-"], "mxsaveopt">, Group;
 def mxsavec : Flag<["-"], "mxsavec">, Group;
 def mxsaves : Flag<["-"], "mxsaves">, Group;
+def mmwaitx : Flag<["-"], "mmwaitx">, Group;
 def mips16 : Flag<["-"], "mips16">, Group;
 def mno_mips16 : Flag<["-"], "mno-mips16">, Group;
 def mmicromips : Flag<["-"], "mmicromips">, Group;

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=269907&r1=269906&r2=269907&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed May 18 06:56:23 2016
@@ -2273,6 +2273,7 @@ class X86TargetInfo : public TargetInfo
   bool HasXSAVEOPT = false;
   bool HasXSAVEC = false;
   bool HasXSAVES = false;
+  bool HasMWAITX = false;
   bool HasPKU = false;
   bool HasCLFLUSHOPT = false;
   bool HasPCOMMIT = false;
@@ -2947,6 +2948,7 @@ bool X86TargetInfo::initFeatureMap(
   case CK_BDVER4:
 setFeatureEnabledImpl(Features, "avx2", true);
 setFeatureEnabledImpl(Features, "bmi2", true);
+setFeatureEnabledImpl(Features, "mwaitx", true);
 // FALLTHROUGH
   case CK_BDVER3:
 setFeatureEnabledImpl(Features, "fsgsbase", true);
@@ -3266,6 +3268,8 @@ bool X86TargetInfo::handleTargetFeatures
   HasXSAVEC = true;
 } else if (Feature == "+xsaves") {
   HasXSAVES = true;
+} else if (Feature == "+mwaitx") {
+  HasMWAITX = true;
 } else if (Feature == "+pku") {
   HasPKU = true;
 } else if (Feature == "+clflushopt") {
@@ -3538,6 +3542,9 @@ void X86TargetInfo::getTargetDefines(con
   if (HasTBM)
 Builder.defineMacro("__TBM__");
 
+  if (HasMWAITX)
+Builder.defineMacro("__MWAITX__"

Re: Patch submission for bug 27400

2016-05-18 Thread Alexander Kornienko via cfe-commits
Thank you for the patch! Note, however, that most clang-tidy reviews are
done using Phabricator (see llvm.org/docs/Phabricator.html). It's not
required, but it makes the reviews much easier (and much easier to keep
track of).

On Tue, May 17, 2016 at 10:47 PM, Mads Ravn via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Cool :) don't the sweat the time. I was just a little excited. Small patch
> but it's nice to get started somewhere.
>
> Best regards,
> Mads Ravn
>
> > On May 17, 2016, at 2:59 AM, Mads Ravn  wrote:
> >
> > Hi guys,
> >
> > I just wanted to check up on this patch. I heard I could just reply to
> this mail and see if I could 'ping' anyone in this regard. Hope it's OK.
>
> Sorry for the delay! This looks good. Committed as r269786.
>
> thanks,
> vedant
>
> >
> > Best regards,
> > Mads Ravn
> >
> > On Thu, May 12, 2016 at 6:11 PM Mads Ravn  wrote:
> > Hi,
> >
> > I have fixed the things you mentioned now. I have attached the new patch
> to this email.
> >
> > Best regards,
> > Mads Ravn
> >
> > On Wed, May 11, 2016 at 11:54 PM Vedant Kumar  wrote:
> > Hi,
> >
> > Thanks for the patch!
> >
> > This patch is missing a small, lit-style test case. You can find
> examples of test cases here:
> >
> >   extra/test/clang-tidy/
> >
> > Apart from that, my only other nit-pick is that llvm uses 2-space
> indents, and spaces between "if" and "(".
> >
> > If you reply to this list with an updated patch, someone would be happy
> to commit it for you.
> >
> > best
> > vedant
> >
> > > On May 11, 2016, at 10:01 AM, Mads Ravn via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> > >
> > > Hi,
> > >
> > > I would like to submit a patch for
> https://llvm.org/bugs/show_bug.cgi?id=27400 .
> > >
> > > Beside attaching the patch, is there anything I should be aware of? I
> have not submitted a patch before.
> > >
> > > You can find the patch attached to this mail.
> > >
> > > Kind regards,
> > > Mads Ravn
> > >
> ___
> > > cfe-commits mailing list
> > > cfe-commits@lists.llvm.org
> > > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-05-18 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:3724
@@ +3723,3 @@
+  bool Matched = false;
+  for (const auto *Overridden : Node.overridden_methods()) {
+BoundNodesTreeBuilder OverriddenBuilder(*Builder);

courbet wrote:
> Thanks for the catch. Unfortunately there are a lot of errors in the file 
> that prevent me to run clang-format. Any hint to handle that efficiently ?
There's a script that you can use to reformat just the contents of a diff: 
http://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting


http://reviews.llvm.org/D19324



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


Re: [PATCH] D20360: [ASTMatcher] Add a node matcher for UnresolvedLookupExpr.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57596.
hokein marked an inline comment as done.
hokein added a comment.

Address review comments.


http://reviews.llvm.org/D20360

Files:
  docs/LibASTMatchersReference.html
  docs/tools/dump_ast_matchers.py
  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
@@ -1132,6 +1132,16 @@
  declaratorDecl(hasTypeLoc(loc(asString("int"));
 }
 
+TEST(Matcher, UnresolvedLookupExpr) {
+  EXPECT_TRUE(matches("template"
+  "T foo() { T a; return a; }"
+  "template"
+  "void bar() {"
+  "  foo();"
+  "}",
+  unresolvedLookupExpr()));
+}
+
 TEST(Matcher, Call) {
   // FIXME: Do we want to overload Call() to directly take
   // Matcher, too?
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -397,6 +397,7 @@
   REGISTER_MATCHER(unaryOperator);
   REGISTER_MATCHER(unaryTransformType);
   REGISTER_MATCHER(unless);
+  REGISTER_MATCHER(unresolvedLookupExpr);
   REGISTER_MATCHER(unresolvedUsingTypenameDecl);
   REGISTER_MATCHER(unresolvedUsingValueDecl);
   REGISTER_MATCHER(userDefinedLiteral);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1086,6 +1086,24 @@
   Decl,
   UsingDirectiveDecl> usingDirectiveDecl;
 
+/// \brief Matches reference to a name that can be looked up during parsing
+/// but could not be resolved to a specific declaration.
+///
+/// Given
+/// \code
+///   template
+///   T foo() { T a; return a; }
+///   template
+///   void bar() {
+/// foo();
+///   }
+/// \endcode
+/// unresolvedLookupExpr()
+///   matches \code foo() \endcode
+const internal::VariadicDynCastAllOfMatcher<
+   Stmt,
+   UnresolvedLookupExpr> unresolvedLookupExpr;
+
 /// \brief Matches unresolved using value declarations.
 ///
 /// Given
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -1275,6 +1275,21 @@
 
 
 
+MatcherStmt>unresolvedLookupExprMatcherUnresolvedLookupExpr>...
+Matches 
reference to a name that can be looked up during parsing
+but could not be resolved to a specific declaration.
+
+Given
+  template
+  T foo() { T a; return a; }
+  template
+  void bar() {
+foo();
+  }
+unresolvedLookupExpr()
+  matches foo() 
+
+
 MatcherStmt>userDefinedLiteralMatcherUserDefinedLiteral>...
 Matches user 
defined literal operator call.
 


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1132,6 +1132,16 @@
  declaratorDecl(hasTypeLoc(loc(asString("int"));
 }
 
+TEST(Matcher, UnresolvedLookupExpr) {
+  EXPECT_TRUE(matches("template"
+  "T foo() { T a; return a; }"
+  "template"
+  "void bar() {"
+  "  foo();"
+  "}",
+  unresolvedLookupExpr()));
+}
+
 TEST(Matcher, Call) {
   // FIXME: Do we want to overload Call() to directly take
   // Matcher, too?
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -397,6 +397,7 @@
   REGISTER_MATCHER(unaryOperator);
   REGISTER_MATCHER(unaryTransformType);
   REGISTER_MATCHER(unless);
+  REGISTER_MATCHER(unresolvedLookupExpr);
   REGISTER_MATCHER(unresolvedUsingTypenameDecl);
   REGISTER_MATCHER(unresolvedUsingValueDecl);
   REGISTER_MATCHER(userDefinedLiteral);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1086,6 +1086,24 @@
   Decl,
   UsingDirectiveDecl> usingDirectiveDecl;
 
+/// \brief Matches reference to a name that can be looked up during parsing
+/// but could not be resolved to a specific declaratio

Re: [PATCH] D20325: Add ARM cdp intrinsics

2016-05-18 Thread James Molloy via cfe-commits
Hi,

To add my oar in, I agree with Tim here. It is regrettable but true that
documentation, be that the ARMARM or ACLE tends to lag behind our
development. If LLVM wants to be at the leading edge of architecture
support (I hope it does!) then patches will just have to be accepted
without pointers to existing documentation, because the documentation is
still in draft. It's either that or wait until the documentation is ready,
which can be quite some time (there is no v8.1A ARMARM yet...)

The ACLE in particular stays in draft for some time, because it often waits
for implementations to be done in GCC and LLVM to see if the specification
is actually workable!

Cheers,

James

On Wed, 18 May 2016 at 11:03 Renato Golin via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> rengolin added a comment.
>
> Thanks Ranjeet,
>
> The tests don't really need the new builtin to exist at all and can be
> added now.
>
> When you submit the __arm_cdp patch, you just need to make sure Clang
> generates a call to @llvm.arm.cdp and everything else will be covered.
>
> cheers,
> --renato
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D20325
>
>
>
> ___
> 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] D20360: [ASTMatcher] Add a node matcher for UnresolvedLookupExpr.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57597.
hokein added a comment.

Remove modification of dump_ast_matchers.py


http://reviews.llvm.org/D20360

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
@@ -1132,6 +1132,16 @@
  declaratorDecl(hasTypeLoc(loc(asString("int"));
 }
 
+TEST(Matcher, UnresolvedLookupExpr) {
+  EXPECT_TRUE(matches("template"
+  "T foo() { T a; return a; }"
+  "template"
+  "void bar() {"
+  "  foo();"
+  "}",
+  unresolvedLookupExpr()));
+}
+
 TEST(Matcher, Call) {
   // FIXME: Do we want to overload Call() to directly take
   // Matcher, too?
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -397,6 +397,7 @@
   REGISTER_MATCHER(unaryOperator);
   REGISTER_MATCHER(unaryTransformType);
   REGISTER_MATCHER(unless);
+  REGISTER_MATCHER(unresolvedLookupExpr);
   REGISTER_MATCHER(unresolvedUsingTypenameDecl);
   REGISTER_MATCHER(unresolvedUsingValueDecl);
   REGISTER_MATCHER(userDefinedLiteral);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1086,6 +1086,24 @@
   Decl,
   UsingDirectiveDecl> usingDirectiveDecl;
 
+/// \brief Matches reference to a name that can be looked up during parsing
+/// but could not be resolved to a specific declaration.
+///
+/// Given
+/// \code
+///   template
+///   T foo() { T a; return a; }
+///   template
+///   void bar() {
+/// foo();
+///   }
+/// \endcode
+/// unresolvedLookupExpr()
+///   matches \code foo() \endcode
+const internal::VariadicDynCastAllOfMatcher<
+   Stmt,
+   UnresolvedLookupExpr> unresolvedLookupExpr;
+
 /// \brief Matches unresolved using value declarations.
 ///
 /// Given
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -1275,6 +1275,21 @@
 
 
 
+MatcherStmt>unresolvedLookupExprMatcherUnresolvedLookupExpr>...
+Matches 
reference to a name that can be looked up during parsing
+but could not be resolved to a specific declaration.
+
+Given
+  template
+  T foo() { T a; return a; }
+  template
+  void bar() {
+foo();
+  }
+unresolvedLookupExpr()
+  matches foo() 
+
+
 MatcherStmt>userDefinedLiteralMatcherUserDefinedLiteral>...
 Matches user 
defined literal operator call.
 


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1132,6 +1132,16 @@
  declaratorDecl(hasTypeLoc(loc(asString("int"));
 }
 
+TEST(Matcher, UnresolvedLookupExpr) {
+  EXPECT_TRUE(matches("template"
+  "T foo() { T a; return a; }"
+  "template"
+  "void bar() {"
+  "  foo();"
+  "}",
+  unresolvedLookupExpr()));
+}
+
 TEST(Matcher, Call) {
   // FIXME: Do we want to overload Call() to directly take
   // Matcher, too?
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -397,6 +397,7 @@
   REGISTER_MATCHER(unaryOperator);
   REGISTER_MATCHER(unaryTransformType);
   REGISTER_MATCHER(unless);
+  REGISTER_MATCHER(unresolvedLookupExpr);
   REGISTER_MATCHER(unresolvedUsingTypenameDecl);
   REGISTER_MATCHER(unresolvedUsingValueDecl);
   REGISTER_MATCHER(userDefinedLiteral);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1086,6 +1086,24 @@
   Decl,
   UsingDirectiveDecl> usingDirectiveDecl;
 
+/// \brief Matches reference to a name that can be looked up during parsing
+/// but could not be resolved to a specific declaration.
+///
+/// Given
+/// \code
+///   template
+///   T f

Re: [PATCH] D20360: [ASTMatcher] Add a node matcher for UnresolvedLookupExpr.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein added a comment.

> ! In http://reviews.llvm.org/D20360#432882, @aaron.ballman wrote:

>  World executable? That's a bit presumptuous. ;-) 0744 may be fine, but 0755 
> does not seem correct to me.

> 

> Regardless, I think that it should be a separate commit, not part of this one 
> as a drive-by (it has security implications, and that deserves review).


Has been removed now. Will sent a separate commit for it.


http://reviews.llvm.org/D20360



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


Re: [PATCH] D20325: Add ARM cdp intrinsics

2016-05-18 Thread Renato Golin via cfe-commits
On 18 May 2016 at 13:18, James Molloy  wrote:
> The ACLE in particular stays in draft for some time, because it often waits
> for implementations to be done in GCC and LLVM to see if the specification
> is actually workable!

I can't imagine ARM sharing a draft, so this is actually a better
argument than "ARMv8.1 is not out yet".

I'm not against the whole idea, but there are three different patches
in there that need to be separated and analysed on their own merit.

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


Re: [PATCH] D20360: [ASTMatcher] Add a node matcher for UnresolvedLookupExpr.

2016-05-18 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/D20360



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


Re: [PATCH] D20360: [ASTMatcher] Add a node matcher for UnresolvedLookupExpr.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57600.
hokein added a comment.

Rebase to master.


http://reviews.llvm.org/D20360

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

Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -177,6 +177,15 @@
   EXPECT_TRUE(notMatches("enum X {};", Matcher));
 }
 
+TEST(Matcher, UnresolvedLookupExpr) {
+  EXPECT_TRUE(matches("template"
+  "T foo() { T a; return a; }"
+  "template"
+  "void bar() {"
+  "  foo();"
+  "}",
+  unresolvedLookupExpr()));
+}
 
 TEST(Matcher, Call) {
   // FIXME: Do we want to overload Call() to directly take
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -399,6 +399,7 @@
   REGISTER_MATCHER(unaryOperator);
   REGISTER_MATCHER(unaryTransformType);
   REGISTER_MATCHER(unless);
+  REGISTER_MATCHER(unresolvedLookupExpr);
   REGISTER_MATCHER(unresolvedUsingTypenameDecl);
   REGISTER_MATCHER(unresolvedUsingValueDecl);
   REGISTER_MATCHER(userDefinedLiteral);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1086,6 +1086,24 @@
   Decl,
   UsingDirectiveDecl> usingDirectiveDecl;
 
+/// \brief Matches reference to a name that can be looked up during parsing
+/// but could not be resolved to a specific declaration.
+///
+/// Given
+/// \code
+///   template
+///   T foo() { T a; return a; }
+///   template
+///   void bar() {
+/// foo();
+///   }
+/// \endcode
+/// unresolvedLookupExpr()
+///   matches \code foo() \endcode
+const internal::VariadicDynCastAllOfMatcher<
+   Stmt,
+   UnresolvedLookupExpr> unresolvedLookupExpr;
+
 /// \brief Matches unresolved using value declarations.
 ///
 /// Given
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -1275,6 +1275,21 @@
 
 
 
+MatcherStmt>unresolvedLookupExprMatcherUnresolvedLookupExpr>...
+Matches 
reference to a name that can be looked up during parsing
+but could not be resolved to a specific declaration.
+
+Given
+  template
+  T foo() { T a; return a; }
+  template
+  void bar() {
+foo();
+  }
+unresolvedLookupExpr()
+  matches foo() 
+
+
 MatcherStmt>userDefinedLiteralMatcherUserDefinedLiteral>...
 Matches user 
defined literal operator call.
 


Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -177,6 +177,15 @@
   EXPECT_TRUE(notMatches("enum X {};", Matcher));
 }
 
+TEST(Matcher, UnresolvedLookupExpr) {
+  EXPECT_TRUE(matches("template"
+  "T foo() { T a; return a; }"
+  "template"
+  "void bar() {"
+  "  foo();"
+  "}",
+  unresolvedLookupExpr()));
+}
 
 TEST(Matcher, Call) {
   // FIXME: Do we want to overload Call() to directly take
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -399,6 +399,7 @@
   REGISTER_MATCHER(unaryOperator);
   REGISTER_MATCHER(unaryTransformType);
   REGISTER_MATCHER(unless);
+  REGISTER_MATCHER(unresolvedLookupExpr);
   REGISTER_MATCHER(unresolvedUsingTypenameDecl);
   REGISTER_MATCHER(unresolvedUsingValueDecl);
   REGISTER_MATCHER(userDefinedLiteral);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1086,6 +1086,24 @@
   Decl,
   UsingDirectiveDecl> usingDirectiveDecl;
 
+/// \brief Matches reference to a name that can be looked up during parsing
+/// but could not be resolved to a specific declaration.
+///
+/// Given
+/// \code
+///   template
+///   T foo() { T a; return a; }
+///   template
+///   void bar() {
+/// foo();
+///   }
+/// \endco

Re: [PATCH] D20321: [Clang][AVX512][intrinsics] Fix vperm intrinsics.

2016-05-18 Thread michael zuckerman via cfe-commits
m_zuckerman accepted this revision.
m_zuckerman added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rL LLVM

http://reviews.llvm.org/D20321



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


Re: [PATCH] D20112: [OpenMP] Add support for the 'private pointer' flag to signal variables captured in target regions and used in first-private clauses.

2016-05-18 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Please, update to latest revision. I made some changes in firstprivates that 
may affect your patch. Will review it after it.


http://reviews.llvm.org/D20112



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


Re: [PATCH] D20111: [OpenMP] Adjust map type bits according to latest spec and use zero size array sections for pointers.

2016-05-18 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4873-4877
@@ -4880,1 +4872,7 @@
+OMP_MAP_IS_PTR = 0x10,
+/// \brief This flags signals that an argument is the first one relating to
+/// a map/private clause expression. For some cases a single
+/// map/privatization results in multiple arguments passed to the runtime
+/// library.
+OMP_MAP_FIRST_REF = 0x20,
 /// \brief Pass the element to the device by value.

I think multiple arguments for the same mapped/privatized decls must not be 
passed to runtime lib at all. Do we really need it?


http://reviews.llvm.org/D20111



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


[PATCH] D20362: [clang-format] Make formatReplacements() also sort #includes.

2016-05-18 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added reviewers: bkramer, djasper.
ioeric added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

[clang-format] Make formatReplacements() also sort #includes.

http://reviews.llvm.org/D20362

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11559,6 +11559,31 @@
   EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
 }
 
+TEST_F(ReplacementTest, SortIncludesAfterReplacement) {
+  std::string Code = "#include \"a.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "int main() {\n"
+ "  return 0;\n"
+ "}";
+  std::string Expected = "#include \"a.h\"\n"
+ "#include \"b.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "int main() {\n"
+ "  return 0;\n"
+ "}";
+  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 1, 1), 0, "#include 
\"b.h\"\n"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.SortIncludes = true;
+  auto FinalReplaces = formatReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -2140,13 +2140,23 @@
  const tooling::Replacements &Replaces,
  const FormatStyle &Style) {
   // We need to use lambda function here since there are two versions of
+  // `sortIncludes`.
+  auto SortIncludes = [](const FormatStyle &Style, StringRef Code,
+ std::vector Ranges,
+ StringRef FileName) -> tooling::Replacements {
+return sortIncludes(Style, Code, Ranges, FileName);
+  };
+  tooling::Replacements SortedReplaces =
+  processReplacements(SortIncludes, Code, Replaces, Style);
+
+  // We need to use lambda function here since there are two versions of
   // `reformat`.
   auto Reformat = [](const FormatStyle &Style, StringRef Code,
  std::vector Ranges,
  StringRef FileName) -> tooling::Replacements {
 return reformat(Style, Code, Ranges, FileName);
   };
-  return processReplacements(Reformat, Code, Replaces, Style);
+  return processReplacements(Reformat, Code, SortedReplaces, Style);
 }
 
 tooling::Replacements


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11559,6 +11559,31 @@
   EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
 }
 
+TEST_F(ReplacementTest, SortIncludesAfterReplacement) {
+  std::string Code = "#include \"a.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "int main() {\n"
+ "  return 0;\n"
+ "}";
+  std::string Expected = "#include \"a.h\"\n"
+ "#include \"b.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "int main() {\n"
+ "  return 0;\n"
+ "}";
+  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 1, 1), 0, "#include \"b.h\"\n"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.SortIncludes = true;
+  auto FinalReplaces = formatReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -2140,13 +2140,23 @@
  const tooling::Replacements &Replaces,
  const FormatStyle &Style) {
   // We need to use lambda function here since there are two versions of
+  // `sortIncludes`.
+  auto SortIncludes = [](const FormatStyle &Style, StringRef Code,
+ std::vector Ranges,
+ StringRef FileName) -> tooling::Replacements {
+return sortIncludes(Style, Code, Ranges, FileName);
+  };
+  tooling::Replacements SortedReplaces 

r269914 - [Mips] Finetuning MIPS32 Android default variants

2016-05-18 Thread Petar Jovanovic via cfe-commits
Author: petarj
Date: Wed May 18 07:46:06 2016
New Revision: 269914

URL: http://llvm.org/viewvc/llvm-project?rev=269914&view=rev
Log:
[Mips] Finetuning MIPS32 Android default variants

MIPS32 Android defaults to FPXX ("-fpxx").
MIPS32R6 Android defaults to FP64A ("-mfp64 -mno-odd-spreg").

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/test/Driver/clang-translation.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=269914&r1=269913&r2=269914&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed May 18 07:46:06 2016
@@ -1359,8 +1359,9 @@ static void getMIPSTargetFeatures(const
   AddTargetFeature(Args, Features, options::OPT_mmsa, options::OPT_mno_msa,
"msa");
 
-  // Add the last -mfp32/-mfpxx/-mfp64 or if none are given and the ABI is O32
-  // pass -mfpxx
+  // Add the last -mfp32/-mfpxx/-mfp64, if none are given and the ABI is O32
+  // pass -mfpxx, or if none are given and fp64a is default, pass fp64 and
+  // nooddspreg.
   if (Arg *A = Args.getLastArg(options::OPT_mfp32, options::OPT_mfpxx,
options::OPT_mfp64)) {
 if (A->getOption().matches(options::OPT_mfp32))
@@ -1373,6 +1374,9 @@ static void getMIPSTargetFeatures(const
   } else if (mips::shouldUseFPXX(Args, Triple, CPUName, ABIName, FloatABI)) {
 Features.push_back(Args.MakeArgString("+fpxx"));
 Features.push_back(Args.MakeArgString("+nooddspreg"));
+  } else if (mips::isFP64ADefault(Triple, CPUName)) {
+Features.push_back(Args.MakeArgString("+fp64"));
+Features.push_back(Args.MakeArgString("+nooddspreg"));
   }
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
@@ -7039,10 +7043,21 @@ bool mips::isNaN2008(const ArgList &Args
   return false;
 }
 
+bool mips::isFP64ADefault(const llvm::Triple &Triple, StringRef CPUName) {
+  if (!Triple.isAndroid())
+return false;
+
+  // Android MIPS32R6 defaults to FP64A.
+  return llvm::StringSwitch(CPUName)
+  .Case("mips32r6", true)
+  .Default(false);
+}
+
 bool mips::isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName,
  StringRef ABIName, mips::FloatABI FloatABI) {
   if (Triple.getVendor() != llvm::Triple::ImaginationTechnologies &&
-  Triple.getVendor() != llvm::Triple::MipsTechnologies)
+  Triple.getVendor() != llvm::Triple::MipsTechnologies &&
+  !Triple.isAndroid())
 return false;
 
   if (ABIName != "32")

Modified: cfe/trunk/lib/Driver/Tools.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=269914&r1=269913&r2=269914&view=diff
==
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Wed May 18 07:46:06 2016
@@ -299,6 +299,7 @@ std::string getMipsABILibSuffix(const ll
 bool hasMipsAbiArg(const llvm::opt::ArgList &Args, const char *Value);
 bool isUCLibc(const llvm::opt::ArgList &Args);
 bool isNaN2008(const llvm::opt::ArgList &Args, const llvm::Triple &Triple);
+bool isFP64ADefault(const llvm::Triple &Triple, StringRef CPUName);
 bool isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName,
StringRef ABIName, mips::FloatABI FloatABI);
 bool shouldUseFPXX(const llvm::opt::ArgList &Args, const llvm::Triple &Triple,

Modified: cfe/trunk/test/Driver/clang-translation.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-translation.c?rev=269914&r1=269913&r2=269914&view=diff
==
--- cfe/trunk/test/Driver/clang-translation.c (original)
+++ cfe/trunk/test/Driver/clang-translation.c Wed May 18 07:46:06 2016
@@ -246,8 +246,19 @@
 // MIPSEL-ANDROID: clang
 // MIPSEL-ANDROID: "-cc1"
 // MIPSEL-ANDROID: "-target-cpu" "mips32"
+// MIPSEL-ANDROID: "-target-feature" "+fpxx"
+// MIPSEL-ANDROID: "-target-feature" "+nooddspreg"
 // MIPSEL-ANDROID: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsel-linux-android -### -S %s -mcpu=mips32r6 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSEL-ANDROID-R6 %s
+// MIPSEL-ANDROID-R6: clang
+// MIPSEL-ANDROID-R6: "-cc1"
+// MIPSEL-ANDROID-R6: "-target-cpu" "mips32r6"
+// MIPSEL-ANDROID-R6: "-target-feature" "+fp64"
+// MIPSEL-ANDROID-R6: "-target-feature" "+nooddspreg"
+// MIPSEL-ANDROID-R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64 %s
 // MIPS64: clang


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


Re: [PATCH] D20345: [Mips] Finetuning MIPS32 Android default variants

2016-05-18 Thread Petar Jovanovic via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269914: [Mips] Finetuning MIPS32 Android default variants 
(authored by petarj).

Changed prior to commit:
  http://reviews.llvm.org/D20345?vs=57543&id=57603#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20345

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Driver/Tools.h
  cfe/trunk/test/Driver/clang-translation.c

Index: cfe/trunk/test/Driver/clang-translation.c
===
--- cfe/trunk/test/Driver/clang-translation.c
+++ cfe/trunk/test/Driver/clang-translation.c
@@ -246,8 +246,19 @@
 // MIPSEL-ANDROID: clang
 // MIPSEL-ANDROID: "-cc1"
 // MIPSEL-ANDROID: "-target-cpu" "mips32"
+// MIPSEL-ANDROID: "-target-feature" "+fpxx"
+// MIPSEL-ANDROID: "-target-feature" "+nooddspreg"
 // MIPSEL-ANDROID: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsel-linux-android -### -S %s -mcpu=mips32r6 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSEL-ANDROID-R6 %s
+// MIPSEL-ANDROID-R6: clang
+// MIPSEL-ANDROID-R6: "-cc1"
+// MIPSEL-ANDROID-R6: "-target-cpu" "mips32r6"
+// MIPSEL-ANDROID-R6: "-target-feature" "+fp64"
+// MIPSEL-ANDROID-R6: "-target-feature" "+nooddspreg"
+// MIPSEL-ANDROID-R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64 %s
 // MIPS64: clang
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -1359,8 +1359,9 @@
   AddTargetFeature(Args, Features, options::OPT_mmsa, options::OPT_mno_msa,
"msa");
 
-  // Add the last -mfp32/-mfpxx/-mfp64 or if none are given and the ABI is O32
-  // pass -mfpxx
+  // Add the last -mfp32/-mfpxx/-mfp64, if none are given and the ABI is O32
+  // pass -mfpxx, or if none are given and fp64a is default, pass fp64 and
+  // nooddspreg.
   if (Arg *A = Args.getLastArg(options::OPT_mfp32, options::OPT_mfpxx,
options::OPT_mfp64)) {
 if (A->getOption().matches(options::OPT_mfp32))
@@ -1373,6 +1374,9 @@
   } else if (mips::shouldUseFPXX(Args, Triple, CPUName, ABIName, FloatABI)) {
 Features.push_back(Args.MakeArgString("+fpxx"));
 Features.push_back(Args.MakeArgString("+nooddspreg"));
+  } else if (mips::isFP64ADefault(Triple, CPUName)) {
+Features.push_back(Args.MakeArgString("+fp64"));
+Features.push_back(Args.MakeArgString("+nooddspreg"));
   }
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
@@ -7039,10 +7043,21 @@
   return false;
 }
 
+bool mips::isFP64ADefault(const llvm::Triple &Triple, StringRef CPUName) {
+  if (!Triple.isAndroid())
+return false;
+
+  // Android MIPS32R6 defaults to FP64A.
+  return llvm::StringSwitch(CPUName)
+  .Case("mips32r6", true)
+  .Default(false);
+}
+
 bool mips::isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName,
  StringRef ABIName, mips::FloatABI FloatABI) {
   if (Triple.getVendor() != llvm::Triple::ImaginationTechnologies &&
-  Triple.getVendor() != llvm::Triple::MipsTechnologies)
+  Triple.getVendor() != llvm::Triple::MipsTechnologies &&
+  !Triple.isAndroid())
 return false;
 
   if (ABIName != "32")
Index: cfe/trunk/lib/Driver/Tools.h
===
--- cfe/trunk/lib/Driver/Tools.h
+++ cfe/trunk/lib/Driver/Tools.h
@@ -299,6 +299,7 @@
 bool hasMipsAbiArg(const llvm::opt::ArgList &Args, const char *Value);
 bool isUCLibc(const llvm::opt::ArgList &Args);
 bool isNaN2008(const llvm::opt::ArgList &Args, const llvm::Triple &Triple);
+bool isFP64ADefault(const llvm::Triple &Triple, StringRef CPUName);
 bool isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName,
StringRef ABIName, mips::FloatABI FloatABI);
 bool shouldUseFPXX(const llvm::opt::ArgList &Args, const llvm::Triple &Triple,


Index: cfe/trunk/test/Driver/clang-translation.c
===
--- cfe/trunk/test/Driver/clang-translation.c
+++ cfe/trunk/test/Driver/clang-translation.c
@@ -246,8 +246,19 @@
 // MIPSEL-ANDROID: clang
 // MIPSEL-ANDROID: "-cc1"
 // MIPSEL-ANDROID: "-target-cpu" "mips32"
+// MIPSEL-ANDROID: "-target-feature" "+fpxx"
+// MIPSEL-ANDROID: "-target-feature" "+nooddspreg"
 // MIPSEL-ANDROID: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsel-linux-android -### -S %s -mcpu=mips32r6 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSEL-ANDROID-R6 %s
+// MIPSEL-ANDROID-R6: clang
+// MIPSEL-ANDROID-R6: "-cc1"
+// MIPSEL-ANDROID-R6: "-target-cpu" "mips32r6"
+// MIPSEL-ANDROID-R6: "-target-feature" "+fp64"
+// MIPSEL-ANDROID-R6: "-target-feature" "+nooddspreg"
+// MIPSEL-ANDROID-R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64 %s
 // MIPS64: clang
Index: cf

Re: [PATCH] D20362: [clang-format] Make formatReplacements() also sort #includes.

2016-05-18 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. I am not even certain whether we want to keep a separate 
sortIncludes in the interface at all, but as this doesn't change the public 
API, it doesn't hurt.


http://reviews.llvm.org/D20362



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


r269916 - [ASTMatcher] Add a node matcher for UnresolvedLookupExpr.

2016-05-18 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed May 18 07:53:59 2016
New Revision: 269916

URL: http://llvm.org/viewvc/llvm-project?rev=269916&view=rev
Log:
[ASTMatcher] Add a node matcher for UnresolvedLookupExpr.

Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, klimek, cfe-commits

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

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

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=269916&r1=269915&r2=269916&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Wed May 18 07:53:59 2016
@@ -1275,6 +1275,21 @@ Example matches !a
 
 
 
+MatcherStmt>unresolvedLookupExprMatcherUnresolvedLookupExpr>...
+Matches 
reference to a name that can be looked up during parsing
+but could not be resolved to a specific declaration.
+
+Given
+  template
+  T foo() { T a; return a; }
+  template
+  void bar() {
+foo();
+  }
+unresolvedLookupExpr()
+  matches foo() 
+
+
 MatcherStmt>userDefinedLiteralMatcherUserDefinedLiteral>...
 Matches user 
defined literal operator call.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=269916&r1=269915&r2=269916&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Wed May 18 07:53:59 2016
@@ -1086,6 +1086,24 @@ const internal::VariadicDynCastAllOfMatc
   Decl,
   UsingDirectiveDecl> usingDirectiveDecl;
 
+/// \brief Matches reference to a name that can be looked up during parsing
+/// but could not be resolved to a specific declaration.
+///
+/// Given
+/// \code
+///   template
+///   T foo() { T a; return a; }
+///   template
+///   void bar() {
+/// foo();
+///   }
+/// \endcode
+/// unresolvedLookupExpr()
+///   matches \code foo() \endcode
+const internal::VariadicDynCastAllOfMatcher<
+   Stmt,
+   UnresolvedLookupExpr> unresolvedLookupExpr;
+
 /// \brief Matches unresolved using value declarations.
 ///
 /// Given

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=269916&r1=269915&r2=269916&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Wed May 18 07:53:59 2016
@@ -399,6 +399,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(unaryOperator);
   REGISTER_MATCHER(unaryTransformType);
   REGISTER_MATCHER(unless);
+  REGISTER_MATCHER(unresolvedLookupExpr);
   REGISTER_MATCHER(unresolvedUsingTypenameDecl);
   REGISTER_MATCHER(unresolvedUsingValueDecl);
   REGISTER_MATCHER(userDefinedLiteral);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp?rev=269916&r1=269915&r2=269916&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Wed May 18 07:53:59 
2016
@@ -177,6 +177,15 @@ TEST(EnumConstant, Matches) {
   EXPECT_TRUE(notMatches("enum X {};", Matcher));
 }
 
+TEST(Matcher, UnresolvedLookupExpr) {
+  EXPECT_TRUE(matches("template"
+  "T foo() { T a; return a; }"
+  "template"
+  "void bar() {"
+  "  foo();"
+  "}",
+  unresolvedLookupExpr()));
+}
 
 TEST(Matcher, Call) {
   // FIXME: Do we want to overload Call() to directly take


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


Re: [PATCH] D20360: [ASTMatcher] Add a node matcher for UnresolvedLookupExpr.

2016-05-18 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269916: [ASTMatcher] Add a node matcher for 
UnresolvedLookupExpr. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20360?vs=57600&id=57605#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20360

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

Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -1086,6 +1086,24 @@
   Decl,
   UsingDirectiveDecl> usingDirectiveDecl;
 
+/// \brief Matches reference to a name that can be looked up during parsing
+/// but could not be resolved to a specific declaration.
+///
+/// Given
+/// \code
+///   template
+///   T foo() { T a; return a; }
+///   template
+///   void bar() {
+/// foo();
+///   }
+/// \endcode
+/// unresolvedLookupExpr()
+///   matches \code foo() \endcode
+const internal::VariadicDynCastAllOfMatcher<
+   Stmt,
+   UnresolvedLookupExpr> unresolvedLookupExpr;
+
 /// \brief Matches unresolved using value declarations.
 ///
 /// Given
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -399,6 +399,7 @@
   REGISTER_MATCHER(unaryOperator);
   REGISTER_MATCHER(unaryTransformType);
   REGISTER_MATCHER(unless);
+  REGISTER_MATCHER(unresolvedLookupExpr);
   REGISTER_MATCHER(unresolvedUsingTypenameDecl);
   REGISTER_MATCHER(unresolvedUsingValueDecl);
   REGISTER_MATCHER(userDefinedLiteral);
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -177,6 +177,15 @@
   EXPECT_TRUE(notMatches("enum X {};", Matcher));
 }
 
+TEST(Matcher, UnresolvedLookupExpr) {
+  EXPECT_TRUE(matches("template"
+  "T foo() { T a; return a; }"
+  "template"
+  "void bar() {"
+  "  foo();"
+  "}",
+  unresolvedLookupExpr()));
+}
 
 TEST(Matcher, Call) {
   // FIXME: Do we want to overload Call() to directly take
Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -1275,6 +1275,21 @@
 
 
 
+MatcherStmt>unresolvedLookupExprMatcherUnresolvedLookupExpr>...
+Matches 
reference to a name that can be looked up during parsing
+but could not be resolved to a specific declaration.
+
+Given
+  template
+  T foo() { T a; return a; }
+  template
+  void bar() {
+foo();
+  }
+unresolvedLookupExpr()
+  matches foo() 
+
+
 MatcherStmt>userDefinedLiteralMatcherUserDefinedLiteral>...
 Matches user 
defined literal operator call.
 


Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -1086,6 +1086,24 @@
   Decl,
   UsingDirectiveDecl> usingDirectiveDecl;
 
+/// \brief Matches reference to a name that can be looked up during parsing
+/// but could not be resolved to a specific declaration.
+///
+/// Given
+/// \code
+///   template
+///   T foo() { T a; return a; }
+///   template
+///   void bar() {
+/// foo();
+///   }
+/// \endcode
+/// unresolvedLookupExpr()
+///   matches \code foo() \endcode
+const internal::VariadicDynCastAllOfMatcher<
+   Stmt,
+   UnresolvedLookupExpr> unresolvedLookupExpr;
+
 /// \brief Matches unresolved using value declarations.
 ///
 /// Given
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -399,6 +399,7 @@
   REGISTER_MATCHER(unaryOperator);
   REGISTER_MATCHER(unaryTransformType);
   REGISTER_MATCHER(unless);
+  REGISTER_MATCHER(unresolvedLookupExpr);
   REGISTER_MATCHER(unresolvedUsingTypenameDecl);
   REGISTER_MATCHER(unresolvedUsingValueDecl);
   REGISTER_MATCHER(userDefinedLiteral);
Index: cfe/trunk/unittests/AST

[clang-tools-extra] r269918 - [clang-tidy] Fix misc-unused-using-decls test failure in windows

2016-05-18 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed May 18 08:07:13 2016
New Revision: 269918

URL: http://llvm.org/viewvc/llvm-project?rev=269918&view=rev
Log:
[clang-tidy] Fix misc-unused-using-decls test failure in windows
buildbot.

Modified:
clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp?rev=269918&r1=269917&r2=269918&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp Wed May 
18 08:07:13 2016
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-unused-using-decls %t
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -- 
-fno-delayed-template-parsing
 
 // - Definitions -
 template  class vector {};


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


[PATCH] D20365: [PATCH] clang-tidy: Bug 27731 - modernize-pass-by-value suggest using std::move for types that perform copies on move

2016-05-18 Thread Mads Ravn via cfe-commits
madsravn created this revision.
madsravn added reviewers: alexfh, vsk, djasper, klimek.
madsravn added a subscriber: cfe-commits.

This is a patch for bug: https://llvm.org/bugs/show_bug.cgi?id=27731

I have excluded types which are trivially copyable from being called with 
std::move in the modernizer. In the current state another modernizer will catch 
them and change them back, thus creating a cyclic behaviour.

http://reviews.llvm.org/D20365

Files:
  clang-tidy/modernize/PassByValueCheck.cpp
  test/clang-tidy/modernize-pass-by-value.cpp

Index: test/clang-tidy/modernize-pass-by-value.cpp
===
--- test/clang-tidy/modernize-pass-by-value.cpp
+++ test/clang-tidy/modernize-pass-by-value.cpp
@@ -194,3 +194,9 @@
   Movable M;
 };
 
+// Test that types that are trivially copyable will not use std::move. This 
will
+// cause problems with misc-move-const-arg, as it will revert it.
+struct T {
+  std::array a_;
+  T(std::array a) : a_(a) {}
+};
Index: clang-tidy/modernize/PassByValueCheck.cpp
===
--- clang-tidy/modernize/PassByValueCheck.cpp
+++ clang-tidy/modernize/PassByValueCheck.cpp
@@ -181,6 +181,11 @@
   if (!paramReferredExactlyOnce(Ctor, ParamDecl))
 return;
 
+  // If the parameter is trivial to copy, don't move it. Moving a trivivally
+  // copyable type will cause a problem with modernize-pass-by-value
+  if (ParamDecl->getType().isTriviallyCopyableType(*Result.Context)) 
+return;
+
   auto Diag = diag(ParamDecl->getLocStart(), "pass by value and use 
std::move");
 
   // Iterate over all declarations of the constructor.


Index: test/clang-tidy/modernize-pass-by-value.cpp
===
--- test/clang-tidy/modernize-pass-by-value.cpp
+++ test/clang-tidy/modernize-pass-by-value.cpp
@@ -194,3 +194,9 @@
   Movable M;
 };
 
+// Test that types that are trivially copyable will not use std::move. This will
+// cause problems with misc-move-const-arg, as it will revert it.
+struct T {
+  std::array a_;
+  T(std::array a) : a_(a) {}
+};
Index: clang-tidy/modernize/PassByValueCheck.cpp
===
--- clang-tidy/modernize/PassByValueCheck.cpp
+++ clang-tidy/modernize/PassByValueCheck.cpp
@@ -181,6 +181,11 @@
   if (!paramReferredExactlyOnce(Ctor, ParamDecl))
 return;
 
+  // If the parameter is trivial to copy, don't move it. Moving a trivivally
+  // copyable type will cause a problem with modernize-pass-by-value
+  if (ParamDecl->getType().isTriviallyCopyableType(*Result.Context)) 
+return;
+
   auto Diag = diag(ParamDecl->getLocStart(), "pass by value and use std::move");
 
   // Iterate over all declarations of the constructor.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r269921 - [X86][SSE3] Sync with llvm/test/CodeGen/X86/sse3-intrinsics-fast-isel.ll

2016-05-18 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed May 18 08:17:39 2016
New Revision: 269921

URL: http://llvm.org/viewvc/llvm-project?rev=269921&view=rev
Log:
[X86][SSE3] Sync with llvm/test/CodeGen/X86/sse3-intrinsics-fast-isel.ll

Modified:
cfe/trunk/test/CodeGen/sse3-builtins.c

Modified: cfe/trunk/test/CodeGen/sse3-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse3-builtins.c?rev=269921&r1=269920&r2=269921&view=diff
==
--- cfe/trunk/test/CodeGen/sse3-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse3-builtins.c Wed May 18 08:17:39 2016
@@ -52,6 +52,8 @@ __m128i test_mm_lddqu_si128(__m128i cons
 __m128d test_mm_loaddup_pd(double const* P) {
   // CHECK-LABEL: test_mm_loaddup_pd
   // CHECK: load double*
+  // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 0
+  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 1
   return _mm_loaddup_pd(P);
 }
 


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


Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-18 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: lib/Format/SortJavaScriptImports.cpp:46-47
@@ +45,4 @@
+// An ES6 module reference.
+//
+// ES6 implements a module system, where individual modules (~= source files)
+// can reference other modules, either importing symbols from them, or 
exporting

Thanks, this is much better.


Comment at: lib/Format/SortJavaScriptImports.cpp:84-85
@@ +83,4 @@
+  // comments.
+  SourceLocation Start;
+  SourceLocation End;
+};

Any reason you're not using a SourceRange?


Comment at: lib/Format/SortJavaScriptImports.cpp:93-96
@@ +92,6 @@
+return LHS.Category < RHS.Category;
+  if (LHS.Category == JsModuleReference::ReferenceCategory::SIDE_EFFECT)
+// Side effect imports might be ordering sensitive. Consider them equal so
+// that they maintain their relative order in the stable sort below.
+return false;
+  // Empty URLs sort *last* (for export {...};).

Doesn't that break strict weak ordering requirements?

x = non-side-effect (url: a)
y = side-effect (url: b)
z = non-side-effect (url: c)
now x and y are incomparable:
!(x < y) // because x.url < y.url
&& !(y < x) // because of y == side-effect
but x and z are comparable:
x < z
breaks transitivity of incomparability 
(https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings)

To keep them equal, wouldn't you need:
  if (LHS == SIDE_EFFECT && RHS == SIDE_EFFECT)
return false;
(that would at least seem symmetric)


Comment at: lib/Format/SortJavaScriptImports.cpp:128
@@ +127,3 @@
+
+SmallVector Imports;
+SourceLocation LastStart;

It seems like you can pull the loop below into its own function 
parseModuleReferences or something.


Comment at: lib/Format/SortJavaScriptImports.cpp:129
@@ +128,3 @@
+SmallVector Imports;
+SourceLocation LastStart;
+for (auto Line : AnnotatedLines) {

LastStart is just the start of the currently processed module reference, right? 
I'd just call it Start then.


Comment at: lib/Format/SortJavaScriptImports.cpp:135
@@ +134,3 @@
+  LineEnd = Line->Last;
+  JsModuleReference Reference;
+  skipComments();

Why are you defining this here, far before its use?

I think this code might be slightly simpler (for me to understand) if you just 
pulled Reference out of the loop, and got rid of LastStart.




http://reviews.llvm.org/D20198



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


[clang-tools-extra] r269923 - [include-fixer] Don't insert #includes if a fatal error occurred.

2016-05-18 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed May 18 08:32:38 2016
New Revision: 269923

URL: http://llvm.org/viewvc/llvm-project?rev=269923&view=rev
Log:
[include-fixer] Don't insert #includes if a fatal error occurred.

This typically happens when the user didn't setup include paths correctly
and the fixer starts adding garbage includes. Avoid that. Disable the error
limit though, as we might hit that easily with missing includes and still
want to fix those cases.

Added:
clang-tools-extra/trunk/test/include-fixer/exit_on_fatal.cpp
Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=269923&r1=269922&r2=269923&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Wed May 18 08:32:38 
2016
@@ -390,6 +390,10 @@ bool IncludeFixerActionFactory::runInvoc
  /*ShouldOwnClient=*/true);
   Compiler.createSourceManager(*Files);
 
+  // We abort on fatal errors so don't let a large number of errors become
+  // fatal. A missing #include can cause thousands of errors.
+  Compiler.getDiagnostics().setErrorLimit(0);
+
   // Run the parser, gather missing includes.
   auto ScopedToolAction =
   llvm::make_unique(SymbolIndexMgr, MinimizeIncludePaths);
@@ -401,8 +405,9 @@ bool IncludeFixerActionFactory::runInvoc
 Replacements);
 
   // Technically this should only return true if we're sure that we have a
-  // parseable file. We don't know that though.
-  return true;
+  // parseable file. We don't know that though. Only inform users of fatal
+  // errors.
+  return !Compiler.getDiagnostics().hasFatalErrorOccurred();
 }
 
 } // namespace include_fixer

Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=269923&r1=269922&r2=269923&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Wed May 18 
08:32:38 2016
@@ -108,7 +108,11 @@ int includeFixerMain(int argc, const cha
   include_fixer::IncludeFixerActionFactory Factory(
   *SymbolIndexMgr, Replacements, MinimizeIncludePaths);
 
-  tool.run(&Factory); // Always succeeds.
+  if (tool.run(&Factory) != 0) {
+llvm::errs()
+<< "Clang died with a fatal error! (incorrect include paths?)\n";
+return 1;
+  }
 
   if (!Quiet)
 for (const tooling::Replacement &Replacement : Replacements)

Added: clang-tools-extra/trunk/test/include-fixer/exit_on_fatal.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/include-fixer/exit_on_fatal.cpp?rev=269923&view=auto
==
--- clang-tools-extra/trunk/test/include-fixer/exit_on_fatal.cpp (added)
+++ clang-tools-extra/trunk/test/include-fixer/exit_on_fatal.cpp Wed May 18 
08:32:38 2016
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+// RUN: sed -e 's#//.*$##' %s > %t.cpp
+// RUN: not clang-include-fixer -db=fixed -input='foo= "foo.h"' %t.cpp --
+// RUN: FileCheck %s -input-file=%t.cpp
+
+// CHECK-NOT: #include
+// CHECK: #include "doesnotexist.h"
+// CHECK-NEXT: foo f;
+
+#include "doesnotexist.h"
+foo f;


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


r269924 - [clang-format] Make formatReplacements() also sort #includes.

2016-05-18 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed May 18 08:43:48 2016
New Revision: 269924

URL: http://llvm.org/viewvc/llvm-project?rev=269924&view=rev
Log:
[clang-format] Make formatReplacements() also sort #includes.

Summary: [clang-format] Make formatReplacements() also sort #includes.

Reviewers: bkramer, djasper

Subscribers: klimek, cfe-commits

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

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=269924&r1=269923&r2=269924&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed May 18 08:43:48 2016
@@ -2140,13 +2140,23 @@ tooling::Replacements formatReplacements
  const tooling::Replacements &Replaces,
  const FormatStyle &Style) {
   // We need to use lambda function here since there are two versions of
+  // `sortIncludes`.
+  auto SortIncludes = [](const FormatStyle &Style, StringRef Code,
+ std::vector Ranges,
+ StringRef FileName) -> tooling::Replacements {
+return sortIncludes(Style, Code, Ranges, FileName);
+  };
+  tooling::Replacements SortedReplaces =
+  processReplacements(SortIncludes, Code, Replaces, Style);
+
+  // We need to use lambda function here since there are two versions of
   // `reformat`.
   auto Reformat = [](const FormatStyle &Style, StringRef Code,
  std::vector Ranges,
  StringRef FileName) -> tooling::Replacements {
 return reformat(Style, Code, Ranges, FileName);
   };
-  return processReplacements(Reformat, Code, Replaces, Style);
+  return processReplacements(Reformat, Code, SortedReplaces, Style);
 }
 
 tooling::Replacements

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=269924&r1=269923&r2=269924&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed May 18 08:43:48 2016
@@ -11559,6 +11559,31 @@ TEST_F(ReplacementTest, FixOnlyAffectedC
   EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
 }
 
+TEST_F(ReplacementTest, SortIncludesAfterReplacement) {
+  std::string Code = "#include \"a.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "int main() {\n"
+ "  return 0;\n"
+ "}";
+  std::string Expected = "#include \"a.h\"\n"
+ "#include \"b.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "int main() {\n"
+ "  return 0;\n"
+ "}";
+  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 1, 1), 0, "#include 
\"b.h\"\n"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.SortIncludes = true;
+  auto FinalReplaces = formatReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang


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


Re: [PATCH] D20362: [clang-format] Make formatReplacements() also sort #includes.

2016-05-18 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269924: [clang-format] Make formatReplacements() also sort 
#includes. (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D20362?vs=57601&id=57612#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20362

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp

Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -2140,13 +2140,23 @@
  const tooling::Replacements &Replaces,
  const FormatStyle &Style) {
   // We need to use lambda function here since there are two versions of
+  // `sortIncludes`.
+  auto SortIncludes = [](const FormatStyle &Style, StringRef Code,
+ std::vector Ranges,
+ StringRef FileName) -> tooling::Replacements {
+return sortIncludes(Style, Code, Ranges, FileName);
+  };
+  tooling::Replacements SortedReplaces =
+  processReplacements(SortIncludes, Code, Replaces, Style);
+
+  // We need to use lambda function here since there are two versions of
   // `reformat`.
   auto Reformat = [](const FormatStyle &Style, StringRef Code,
  std::vector Ranges,
  StringRef FileName) -> tooling::Replacements {
 return reformat(Style, Code, Ranges, FileName);
   };
-  return processReplacements(Reformat, Code, Replaces, Style);
+  return processReplacements(Reformat, Code, SortedReplaces, Style);
 }
 
 tooling::Replacements
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -11559,6 +11559,31 @@
   EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
 }
 
+TEST_F(ReplacementTest, SortIncludesAfterReplacement) {
+  std::string Code = "#include \"a.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "int main() {\n"
+ "  return 0;\n"
+ "}";
+  std::string Expected = "#include \"a.h\"\n"
+ "#include \"b.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "int main() {\n"
+ "  return 0;\n"
+ "}";
+  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 1, 1), 0, "#include 
\"b.h\"\n"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.SortIncludes = true;
+  auto FinalReplaces = formatReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -2140,13 +2140,23 @@
  const tooling::Replacements &Replaces,
  const FormatStyle &Style) {
   // We need to use lambda function here since there are two versions of
+  // `sortIncludes`.
+  auto SortIncludes = [](const FormatStyle &Style, StringRef Code,
+ std::vector Ranges,
+ StringRef FileName) -> tooling::Replacements {
+return sortIncludes(Style, Code, Ranges, FileName);
+  };
+  tooling::Replacements SortedReplaces =
+  processReplacements(SortIncludes, Code, Replaces, Style);
+
+  // We need to use lambda function here since there are two versions of
   // `reformat`.
   auto Reformat = [](const FormatStyle &Style, StringRef Code,
  std::vector Ranges,
  StringRef FileName) -> tooling::Replacements {
 return reformat(Style, Code, Ranges, FileName);
   };
-  return processReplacements(Reformat, Code, Replaces, Style);
+  return processReplacements(Reformat, Code, SortedReplaces, Style);
 }
 
 tooling::Replacements
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -11559,6 +11559,31 @@
   EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
 }
 
+TEST_F(ReplacementTest, SortIncludesAfterReplacement) {
+  std::string Code = "#include \"a.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "int main() {\n"
+ "  return 0;\n"
+ "}";
+  std::string Expected = "#

r269926 - [X86][SSE41] Sync with llvm/test/CodeGen/X86/sse41-intrinsics-fast-isel.ll

2016-05-18 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed May 18 08:47:16 2016
New Revision: 269926

URL: http://llvm.org/viewvc/llvm-project?rev=269926&view=rev
Log:
[X86][SSE41] Sync with llvm/test/CodeGen/X86/sse41-intrinsics-fast-isel.ll

Modified:
cfe/trunk/test/CodeGen/sse41-builtins.c

Modified: cfe/trunk/test/CodeGen/sse41-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse41-builtins.c?rev=269926&r1=269925&r2=269926&view=diff
==
--- cfe/trunk/test/CodeGen/sse41-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse41-builtins.c Wed May 18 08:47:16 2016
@@ -155,21 +155,21 @@ __m128i test_mm_cvtepu32_epi64(__m128i a
 
 __m128d test_mm_dp_pd(__m128d x, __m128d y) {
   // CHECK-LABEL: test_mm_dp_pd
-  // CHECK: call <2 x double> @llvm.x86.sse41.dppd
-  return _mm_dp_pd(x, y, 2);
+  // CHECK: call <2 x double> @llvm.x86.sse41.dppd(<2 x double> {{.*}}, <2 x 
double> {{.*}}, i8 7)
+  return _mm_dp_pd(x, y, 7);
 }
 
 __m128 test_mm_dp_ps(__m128 x, __m128 y) {
   // CHECK-LABEL: test_mm_dp_ps
-  // CHECK: call <4 x float> @llvm.x86.sse41.dpps
-  return _mm_dp_ps(x, y, 2);
+  // CHECK: call <4 x float> @llvm.x86.sse41.dpps(<4 x float> {{.*}}, <4 x 
float> {{.*}}, i8 7)
+  return _mm_dp_ps(x, y, 7);
 }
 
 int test_mm_extract_epi8(__m128i x) {
   // CHECK-LABEL: test_mm_extract_epi8
-  // CHECK: extractelement <16 x i8> %{{.*}}, i32 0
+  // CHECK: extractelement <16 x i8> %{{.*}}, i32 1
   // CHECK: zext i8 %{{.*}} to i32
-  return _mm_extract_epi8(x, 16);
+  return _mm_extract_epi8(x, 1);
 }
 
 int test_mm_extract_epi32(__m128i x) {
@@ -233,8 +233,8 @@ __m128i test_mm_insert_epi64(__m128i x,
 
 __m128 test_mm_insert_ps(__m128 x, __m128 y) {
   // CHECK-LABEL: test_mm_insert_ps
-  // CHECK: call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %{{.*}}, <4 
x float> %{{.*}}, i8 5)
-  return _mm_insert_ps(x, y, 5);
+  // CHECK: call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %{{.*}}, <4 
x float> %{{.*}}, i8 4)
+  return _mm_insert_ps(x, y, 4);
 }
 
 __m128i test_mm_max_epi8(__m128i x, __m128i y) {
@@ -243,18 +243,18 @@ __m128i test_mm_max_epi8(__m128i x, __m1
   return _mm_max_epi8(x, y);
 }
 
-__m128i test_mm_max_epu16(__m128i x, __m128i y) {
-  // CHECK-LABEL: test_mm_max_epu16
-  // CHECK: call <8 x i16> @llvm.x86.sse41.pmaxuw(<8 x i16> %{{.*}}, <8 x i16> 
%{{.*}})
-  return _mm_max_epu16(x, y);
-}
-
 __m128i test_mm_max_epi32(__m128i x, __m128i y) {
   // CHECK-LABEL: test_mm_max_epi32
   // CHECK: call <4 x i32> @llvm.x86.sse41.pmaxsd(<4 x i32> %{{.*}}, <4 x i32> 
%{{.*}})
   return _mm_max_epi32(x, y);
 }
 
+__m128i test_mm_max_epu16(__m128i x, __m128i y) {
+  // CHECK-LABEL: test_mm_max_epu16
+  // CHECK: call <8 x i16> @llvm.x86.sse41.pmaxuw(<8 x i16> %{{.*}}, <8 x i16> 
%{{.*}})
+  return _mm_max_epu16(x, y);
+}
+
 __m128i test_mm_max_epu32(__m128i x, __m128i y) {
   // CHECK-LABEL: test_mm_max_epu32
   // CHECK: call <4 x i32> @llvm.x86.sse41.pmaxud(<4 x i32> %{{.*}}, <4 x i32> 
%{{.*}})
@@ -267,18 +267,18 @@ __m128i test_mm_min_epi8(__m128i x, __m1
   return _mm_min_epi8(x, y);
 }
 
-__m128i test_mm_min_epu16(__m128i x, __m128i y) {
-  // CHECK-LABEL: test_mm_min_epu16
-  // CHECK: call <8 x i16> @llvm.x86.sse41.pminuw(<8 x i16> %{{.*}}, <8 x i16> 
%{{.*}})
-  return _mm_min_epu16(x, y);
-}
-
 __m128i test_mm_min_epi32(__m128i x, __m128i y) {
   // CHECK-LABEL: test_mm_min_epi32
   // CHECK: call <4 x i32> @llvm.x86.sse41.pminsd(<4 x i32> %{{.*}}, <4 x i32> 
%{{.*}})
   return _mm_min_epi32(x, y);
 }
 
+__m128i test_mm_min_epu16(__m128i x, __m128i y) {
+  // CHECK-LABEL: test_mm_min_epu16
+  // CHECK: call <8 x i16> @llvm.x86.sse41.pminuw(<8 x i16> %{{.*}}, <8 x i16> 
%{{.*}})
+  return _mm_min_epu16(x, y);
+}
+
 __m128i test_mm_min_epu32(__m128i x, __m128i y) {
   // CHECK-LABEL: test_mm_min_epu32
   // CHECK: call <4 x i32> @llvm.x86.sse41.pminud(<4 x i32> %{{.*}}, <4 x i32> 
%{{.*}})


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


Re: [PATCH] D20365: [PATCH] clang-tidy: Bug 27731 - modernize-pass-by-value suggest using std::move for types that perform copies on move

2016-05-18 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Do you need me to submit the patch for you?

Next time please create diff with the full context 
(http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface).

Thank you!


http://reviews.llvm.org/D20365



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


[PATCH] D20366: [ASTMatcher] Make dump_ast_matchers.py executable.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: aaron.ballman.
hokein added a subscriber: cfe-commits.

http://reviews.llvm.org/D20366

Files:
  docs/tools/dump_ast_matchers.py



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


Re: [PATCH] D20366: [ASTMatcher] Make dump_ast_matchers.py executable.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein added a comment.

I don't why the diff shows 755 here. But in my local directory, it's 
`rwxr--r--`.


http://reviews.llvm.org/D20366



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


Re: [PATCH] D20366: [ASTMatcher] Make dump_ast_matchers.py executable.

2016-05-18 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D20366#433052, @hokein wrote:

> I don't why the diff shows 755 here. But in my local directory, it's 
> `rwxr--r--`.


Yeah, I'm not certain either (I've never used phab for reviewing this sort of 
thing). I would prefer this to be 0744 so that it is not group or world 
executable.


http://reviews.llvm.org/D20366



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


Re: [PATCH] D20329: [clang-include-fixer] Added Vim integration for clang-include-fixer.

2016-05-18 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 57615.
ioeric added a comment.

- Added docs for Vim integration into include-fixer.rst.


http://reviews.llvm.org/D20329

Files:
  docs/include-fixer.rst
  include-fixer/tool/ClangIncludeFixer.cpp
  include-fixer/tool/clang-include-fixer.py

Index: include-fixer/tool/clang-include-fixer.py
===
--- /dev/null
+++ include-fixer/tool/clang-include-fixer.py
@@ -0,0 +1,65 @@
+# This file is a minimal clang-include-fixer vim-integration. To install:
+# - Change 'binary' if clang-include-fixer is not on the path (see below).
+# - Add to your .vimrc:
+#
+#   map ,cf :pyf path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+#
+# This enables clang-include-fixer for NORMAL and VISUAL mode. Change ",cf" to
+# another binding if you need clang-include-fixer on a different key.
+#
+# To set up clang-include-fixer, see http://clang.llvm.org/extra/include-fixer.html
+#
+# With this integration you can press the bound key and clang-include-fixer will
+# be run on the current buffer.
+#
+# It operates on the current, potentially unsaved buffer and does not create
+# or save any files. To revert a fix, just undo.
+
+import argparse
+import subprocess
+import sys
+import vim
+
+# set g:clang_include_fixer_path to the path to clang-include-fixer if it is not
+# on the path.
+# Change this to the full path if clang-include-fixer is not on the path.
+binary = 'clang-include-fixer'
+if vim.eval('exists("g:clang_include_fixer_path")') == "1":
+  binary = vim.eval('g:clang_include_fixer_path')
+
+def main():
+  parser = argparse.ArgumentParser(
+  description='Vim integration for clang-include-fixer')
+  parser.add_argument('-db', default='yaml',
+  help='clang-include-fixer input format.')
+  parser.add_argument('-input', default='',
+  help='String to initialize the database.')
+  args = parser.parse_args()
+
+  # Get the current text.
+  buf = vim.current.buffer
+  text = '\n'.join(buf)
+
+  # Call clang-include-fixer.
+  command = [binary, "-stdin", "-db="+args.db, "-input="+args.input,
+ vim.current.buffer.name]
+  p = subprocess.Popen(command,
+   stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+   stdin=subprocess.PIPE)
+  stdout, stderr = p.communicate(input=text)
+
+  # If successful, replace buffer contents.
+  if stderr:
+print stderr
+
+  if stdout:
+lines = stdout.splitlines()
+for line in lines:
+  line_num, text = line.split(",")
+  # clang-include-fixer provides 1-based line number
+  line_num = int(line_num) - 1
+  print 'Inserting "{0}" at line {1}'.format(text, line_num)
+  vim.current.buffer[line_num:line_num] = [text]
+
+if __name__ == '__main__':
+  main()
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -47,11 +47,40 @@
 cl::opt Quiet("q", cl::desc("Reduce terminal output"), cl::init(false),
 cl::cat(IncludeFixerCategory));
 
+cl::opt
+STDINMode("stdin",
+  cl::desc("Override source file's content (in the overlaying\n"
+   "virtual file system) with input from  and run\n"
+   "the tool on the new content with the compilation\n"
+   "options of the source file. This mode is currently\n"
+   "used for editor integration."),
+  cl::init(false), cl::cat(IncludeFixerCategory));
+
 int includeFixerMain(int argc, const char **argv) {
   tooling::CommonOptionsParser options(argc, argv, IncludeFixerCategory);
   tooling::ClangTool tool(options.getCompilations(),
   options.getSourcePathList());
 
+  // In STDINMode, we override the file content with the  input.
+  // Since `tool.mapVirtualFile` takes `StringRef`, we define `Code` outside of
+  // the if-block so that `Code` is not released after the if-block.
+  std::unique_ptr Code;
+  if (STDINMode) {
+assert(options.getSourcePathList().size() == 1 &&
+   "Expect exactly one file path in STDINMode.");
+llvm::ErrorOr> CodeOrErr =
+MemoryBuffer::getSTDIN();
+if (std::error_code EC = CodeOrErr.getError()) {
+  errs() << EC.message() << "\n";
+  return 1;
+}
+Code = std::move(CodeOrErr.get());
+if (Code->getBufferSize() == 0)
+  return 0;  // Skip empty files.
+
+tool.mapVirtualFile(options.getSourcePathList().front(), Code->getBuffer());
+  }
+
   // Set up data source.
   auto SymbolIndexMgr = llvm::make_unique();
   switch (DatabaseFormat) {
@@ -121,6 +150,15 @@
   SourceManager SM(Diagnostics, tool.getFiles());
   Diagnostics.setClient(&DiagnosticPrinter, false);
 
+  if (STDINMode) {
+for (const tooling::Replacement &Replacement : Replacemen

Re: [PATCH] D20196: [clang-tidy] Inefficient string operation

2016-05-18 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Please create a diff with the full context: 
http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface



Comment at: clang-tidy/performance/InefficientStringAdditionCheck.cpp:84
@@ +83,3 @@
+  const auto DiagMsg =
+  "Inefficient string concatenation, use operator+= or "
+  "std::basic_string::append instead";

nit: Warning messages are not full sentences, so they should not start with a 
capital letter and should not end with a period.

Please also change the comma to a semicolon `;`.


Comment at: clang-tidy/performance/InefficientStringAdditionCheck.cpp:85
@@ +84,3 @@
+  "Inefficient string concatenation, use operator+= or "
+  "std::basic_string::append instead";
+

`std::basic_string::append` is correct, but is an unnecessary detail. I'd 
suggest changing this to `string::append` or to just `append()`.


http://reviews.llvm.org/D20196



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


[clang-tools-extra] r269927 - [clang-include-fixer] Added Vim integration for clang-include-fixer.

2016-05-18 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed May 18 09:10:16 2016
New Revision: 269927

URL: http://llvm.org/viewvc/llvm-project?rev=269927&view=rev
Log:
[clang-include-fixer] Added Vim integration for clang-include-fixer.

Summary: [clang-include-fixer] Added Vim integration for clang-include-fixer.

Reviewers: hokein, bkramer

Subscribers: cfe-commits

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

Added:
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
Modified:
clang-tools-extra/trunk/docs/include-fixer.rst
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp

Modified: clang-tools-extra/trunk/docs/include-fixer.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/include-fixer.rst?rev=269927&r1=269926&r2=269927&view=diff
==
--- clang-tools-extra/trunk/docs/include-fixer.rst (original)
+++ clang-tools-extra/trunk/docs/include-fixer.rst Wed May 18 09:10:16 2016
@@ -51,6 +51,20 @@ database for LLVM, any project built by
   $ clang-include-fixer -db=yaml path/to/file/with/missing/include.cpp
 Added #include "foo.h"
 
+Integrate with Vim
+---
+To run `clang-include-fixer` on a potentially unsaved buffer in Vim. Add the
+following key binding to your ``.vimrc``:
+
+.. code-block:: console
+
+  map ,cf :pyf 
path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+
+This enables `clang-include-fixer` for NORMAL and VISUAL mode. Change ``,cf`` 
to
+another binding if you need clang-include-fixer on a different key.
+
+See ``clang-include-fixer.py`` for more details.
+
 How it Works
 
 

Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=269927&r1=269926&r2=269927&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Wed May 18 
09:10:16 2016
@@ -47,11 +47,40 @@ cl::opt
 cl::opt Quiet("q", cl::desc("Reduce terminal output"), cl::init(false),
 cl::cat(IncludeFixerCategory));
 
+cl::opt
+STDINMode("stdin",
+  cl::desc("Override source file's content (in the overlaying\n"
+   "virtual file system) with input from  and run\n"
+   "the tool on the new content with the compilation\n"
+   "options of the source file. This mode is currently\n"
+   "used for editor integration."),
+  cl::init(false), cl::cat(IncludeFixerCategory));
+
 int includeFixerMain(int argc, const char **argv) {
   tooling::CommonOptionsParser options(argc, argv, IncludeFixerCategory);
   tooling::ClangTool tool(options.getCompilations(),
   options.getSourcePathList());
 
+  // In STDINMode, we override the file content with the  input.
+  // Since `tool.mapVirtualFile` takes `StringRef`, we define `Code` outside of
+  // the if-block so that `Code` is not released after the if-block.
+  std::unique_ptr Code;
+  if (STDINMode) {
+assert(options.getSourcePathList().size() == 1 &&
+   "Expect exactly one file path in STDINMode.");
+llvm::ErrorOr> CodeOrErr =
+MemoryBuffer::getSTDIN();
+if (std::error_code EC = CodeOrErr.getError()) {
+  errs() << EC.message() << "\n";
+  return 1;
+}
+Code = std::move(CodeOrErr.get());
+if (Code->getBufferSize() == 0)
+  return 0;  // Skip empty files.
+
+tool.mapVirtualFile(options.getSourcePathList().front(), 
Code->getBuffer());
+  }
+
   // Set up data source.
   auto SymbolIndexMgr = llvm::make_unique();
   switch (DatabaseFormat) {
@@ -125,6 +154,15 @@ int includeFixerMain(int argc, const cha
   SourceManager SM(Diagnostics, tool.getFiles());
   Diagnostics.setClient(&DiagnosticPrinter, false);
 
+  if (STDINMode) {
+for (const tooling::Replacement &Replacement : Replacements) {
+  FileID ID = SM.getMainFileID();
+  unsigned LineNum = SM.getLineNumber(ID, Replacement.getOffset());
+  llvm::outs() << LineNum << "," << Replacement.getReplacementText();
+}
+return 0;
+  }
+
   // Write replacements to disk.
   Rewriter Rewrites(SM, LangOptions());
   tooling::applyAllReplacements(Replacements, Rewrites);

Added: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py?rev=269927&view=auto
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py (added)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py Wed May 
18 09:10:16 2016
@@ -0,0 +1,65 @@
+# This file is 

Re: [PATCH] D20329: [clang-include-fixer] Added Vim integration for clang-include-fixer.

2016-05-18 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269927: [clang-include-fixer] Added Vim integration for 
clang-include-fixer. (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D20329?vs=57615&id=57618#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20329

Files:
  clang-tools-extra/trunk/docs/include-fixer.rst
  clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
  clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py

Index: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
===
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
@@ -0,0 +1,65 @@
+# This file is a minimal clang-include-fixer vim-integration. To install:
+# - Change 'binary' if clang-include-fixer is not on the path (see below).
+# - Add to your .vimrc:
+#
+#   map ,cf :pyf path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/clang-include-fixer.py
+#
+# This enables clang-include-fixer for NORMAL and VISUAL mode. Change ",cf" to
+# another binding if you need clang-include-fixer on a different key.
+#
+# To set up clang-include-fixer, see http://clang.llvm.org/extra/include-fixer.html
+#
+# With this integration you can press the bound key and clang-include-fixer will
+# be run on the current buffer.
+#
+# It operates on the current, potentially unsaved buffer and does not create
+# or save any files. To revert a fix, just undo.
+
+import argparse
+import subprocess
+import sys
+import vim
+
+# set g:clang_include_fixer_path to the path to clang-include-fixer if it is not
+# on the path.
+# Change this to the full path if clang-include-fixer is not on the path.
+binary = 'clang-include-fixer'
+if vim.eval('exists("g:clang_include_fixer_path")') == "1":
+  binary = vim.eval('g:clang_include_fixer_path')
+
+def main():
+  parser = argparse.ArgumentParser(
+  description='Vim integration for clang-include-fixer')
+  parser.add_argument('-db', default='yaml',
+  help='clang-include-fixer input format.')
+  parser.add_argument('-input', default='',
+  help='String to initialize the database.')
+  args = parser.parse_args()
+
+  # Get the current text.
+  buf = vim.current.buffer
+  text = '\n'.join(buf)
+
+  # Call clang-include-fixer.
+  command = [binary, "-stdin", "-db="+args.db, "-input="+args.input,
+ vim.current.buffer.name]
+  p = subprocess.Popen(command,
+   stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+   stdin=subprocess.PIPE)
+  stdout, stderr = p.communicate(input=text)
+
+  # If successful, replace buffer contents.
+  if stderr:
+print stderr
+
+  if stdout:
+lines = stdout.splitlines()
+for line in lines:
+  line_num, text = line.split(",")
+  # clang-include-fixer provides 1-based line number
+  line_num = int(line_num) - 1
+  print 'Inserting "{0}" at line {1}'.format(text, line_num)
+  vim.current.buffer[line_num:line_num] = [text]
+
+if __name__ == '__main__':
+  main()
Index: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
@@ -47,11 +47,40 @@
 cl::opt Quiet("q", cl::desc("Reduce terminal output"), cl::init(false),
 cl::cat(IncludeFixerCategory));
 
+cl::opt
+STDINMode("stdin",
+  cl::desc("Override source file's content (in the overlaying\n"
+   "virtual file system) with input from  and run\n"
+   "the tool on the new content with the compilation\n"
+   "options of the source file. This mode is currently\n"
+   "used for editor integration."),
+  cl::init(false), cl::cat(IncludeFixerCategory));
+
 int includeFixerMain(int argc, const char **argv) {
   tooling::CommonOptionsParser options(argc, argv, IncludeFixerCategory);
   tooling::ClangTool tool(options.getCompilations(),
   options.getSourcePathList());
 
+  // In STDINMode, we override the file content with the  input.
+  // Since `tool.mapVirtualFile` takes `StringRef`, we define `Code` outside of
+  // the if-block so that `Code` is not released after the if-block.
+  std::unique_ptr Code;
+  if (STDINMode) {
+assert(options.getSourcePathList().size() == 1 &&
+   "Expect exactly one file path in STDINMode.");
+llvm::ErrorOr> CodeOrErr =
+MemoryBuffer::getSTDIN();
+if (std::error_code EC = CodeOrErr.getError()) {
+  errs() << EC.message() << "\n";
+  return 1;
+}
+Code = std::move(CodeOrErr.get());
+if (Code->getBufferSize() == 0)
+  return 0;  // S

Re: [PATCH] D20367: [clang-tidy] Use unresolvedLookupExpr node matcher from ASTMatcher.

2016-05-18 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269928: [clang-tidy] Use unresolvedLookupExpr node matcher 
from ASTMatcher. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20367?vs=57616&id=57619#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20367

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp

Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,21 +10,14 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
-namespace {
-// FIXME: Move this node matcher to ASTMatcher.
-const internal::VariadicDynCastAllOfMatcher
-unresolvedLookupExpr;
-}
-
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));


Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,21 +10,14 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
-namespace {
-// FIXME: Move this node matcher to ASTMatcher.
-const internal::VariadicDynCastAllOfMatcher
-unresolvedLookupExpr;
-}
-
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r269928 - [clang-tidy] Use unresolvedLookupExpr node matcher from ASTMatcher.

2016-05-18 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed May 18 09:11:20 2016
New Revision: 269928

URL: http://llvm.org/viewvc/llvm-project?rev=269928&view=rev
Log:
[clang-tidy] Use unresolvedLookupExpr node matcher from ASTMatcher.

Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp?rev=269928&r1=269927&r2=269928&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp Wed May 
18 09:11:20 2016
@@ -10,7 +10,6 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
@@ -19,12 +18,6 @@ namespace clang {
 namespace tidy {
 namespace misc {
 
-namespace {
-// FIXME: Move this node matcher to ASTMatcher.
-const internal::VariadicDynCastAllOfMatcher
-unresolvedLookupExpr;
-}
-
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));


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


[PATCH] D20367: [clang-tidy] Use unresolvedLookupExpr node matcher from ASTMatcher.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: alexfh.
hokein added a subscriber: cfe-commits.

http://reviews.llvm.org/D20367

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp

Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,21 +10,14 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
-namespace {
-// FIXME: Move this node matcher to ASTMatcher.
-const internal::VariadicDynCastAllOfMatcher
-unresolvedLookupExpr;
-}
-
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));


Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,21 +10,14 @@
 #include "UnusedUsingDeclsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
-namespace {
-// FIXME: Move this node matcher to ASTMatcher.
-const internal::VariadicDynCastAllOfMatcher
-unresolvedLookupExpr;
-}
-
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20367: [clang-tidy] Use unresolvedLookupExpr node matcher from ASTMatcher.

2016-05-18 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


http://reviews.llvm.org/D20367



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


Re: [PATCH] D20329: [clang-include-fixer] Added Vim integration for clang-include-fixer.

2016-05-18 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D20329



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


Re: [PATCH] D20277: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.

2016-05-18 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.h:30
@@ -29,1 +29,3 @@
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void registerPPCallbacks(clang::CompilerInstance &Compiler) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;

s/clang:://


Repository:
  rL LLVM

http://reviews.llvm.org/D20277



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


Re: [PATCH] D20277: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.

2016-05-18 Thread Felix Berger via cfe-commits
flx marked 4 inline comments as done.
flx added a comment.

Thanks for the feedback!


http://reviews.llvm.org/D20277



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


Re: [PATCH] D20277: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.

2016-05-18 Thread Felix Berger via cfe-commits
flx added inline comments.


Comment at: clang-tidy/utils/TypeTraits.cpp:131
@@ +130,3 @@
+  for (const auto *Constructor : Record->ctors()) {
+if (Constructor->isMoveConstructor() && !Constructor->isDeleted())
+  return true;

Sorry I missed this. Will address it in the next revision.


http://reviews.llvm.org/D20277



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


Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-18 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 57621.
mprobst marked 2 inline comments as done.
mprobst added a comment.

- address review comments
- - extract parseModuleReferences


http://reviews.llvm.org/D20198

Files:
  include/clang/Format/Format.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/SortJavaScriptImports.cpp
  lib/Format/SortJavaScriptImports.h
  lib/Format/TokenAnalyzer.cpp
  lib/Format/TokenAnalyzer.h
  unittests/Format/CMakeLists.txt
  unittests/Format/SortImportsTestJS.cpp

Index: unittests/Format/SortImportsTestJS.cpp
===
--- /dev/null
+++ unittests/Format/SortImportsTestJS.cpp
@@ -0,0 +1,137 @@
+//===- unittest/Format/SortImportsTestJS.cpp - JS import sort unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+namespace {
+
+class SortImportsTestJS : public ::testing::Test {
+protected:
+  std::vector GetCodeRange(StringRef Code) {
+return std::vector(1, tooling::Range(0, Code.size()));
+  }
+
+  std::string sort(StringRef Code, StringRef FileName = "input.js") {
+auto Ranges = GetCodeRange(Code);
+std::string Sorted =
+applyAllReplacements(Code, sortIncludes(Style, Code, Ranges, FileName));
+return applyAllReplacements(Sorted,
+reformat(Style, Sorted, Ranges, FileName));
+  }
+
+  void verifySort(llvm::StringRef Expected, llvm::StringRef Code) {
+std::string Result = sort(Code);
+EXPECT_EQ(Expected.str(), Result) << "Formatted:\n" << Result;
+  }
+
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+};
+
+TEST_F(SortImportsTestJS, BasicSorting) {
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;",
+ "import {sym} from 'a';\n"
+ "import {sym} from 'c';\n"
+ "import {sym} from 'b';\n"
+ "let x = 1;");
+}
+
+TEST_F(SortImportsTestJS, Comments) {
+  verifySort("/** @fileoverview This is a great file. */\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n"
+ "import {sym} from 'b'; // from //foo:bar\n",
+ "/** @fileoverview This is a great file. */\n"
+ "import {sym} from 'b'; // from //foo:bar\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n");
+}
+
+TEST_F(SortImportsTestJS, SortStar) {
+  verifySort("import * as foo from 'a';\n"
+ "import {sym} from 'a';\n"
+ "import * as bar from 'b';\n",
+ "import {sym} from 'a';\n"
+ "import * as foo from 'a';\n"
+ "import * as bar from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, AliasesSymbols) {
+  verifySort("import {sym1 as alias1} from 'b';\n"
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n",
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n"
+ "import {sym1 as alias1} from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, GroupImports) {
+  verifySort("import {a} from 'absolute';\n"
+ "\n"
+ "import {b} from '../parent';\n"
+ "import {b} from '../parent/nested';\n"
+ "\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from './relative/path/nested';\n"
+ "\n"
+ "let x = 1;\n",
+ "import {b} from './relative/path/nested';\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from '../parent/nested';\n"
+ "import {b} from '../parent';\n"
+ "import {a} from 'absolute';\n"
+ "let x = 1;\n");
+}
+
+TEST_F(SortImportsTestJS, Exports) {
+  verifySort("import {S} from 'bpath';\n"
+ "\n"
+ "import {T} from './cpath';\n"
+ "\n"
+ "export {A, B} from 'apath';\n"
+ "export {P} from '../parent';\n"
+ "export {R} from './relative';\n"
+ "export {S};\n"
+ "\n"
+ "let x = 1;\n"
+ "export y = 1;\n",
+ "export {R} from './relative';\n"
+ "import {T} from './cpath';\n"
+ "export {S};\n"
+ "export {A, B} from 'apath';\n"
+ "import {S} from 'bpath';\n"
+ "export {P} from '../parent';\n"
+ "let x

Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-18 Thread Martin Probst via cfe-commits
mprobst marked 6 inline comments as done.
mprobst added a comment.

PTAL.



Comment at: lib/Format/SortJavaScriptImports.cpp:93-96
@@ +92,6 @@
+return LHS.Category < RHS.Category;
+  if (LHS.Category == JsModuleReference::ReferenceCategory::SIDE_EFFECT)
+// Side effect imports might be ordering sensitive. Consider them equal so
+// that they maintain their relative order in the stable sort below.
+return false;
+  // Empty URLs sort *last* (for export {...};).

klimek wrote:
> Doesn't that break strict weak ordering requirements?
> 
> x = non-side-effect (url: a)
> y = side-effect (url: b)
> z = non-side-effect (url: c)
> now x and y are incomparable:
> !(x < y) // because x.url < y.url
> && !(y < x) // because of y == side-effect
> but x and z are comparable:
> x < z
> breaks transitivity of incomparability 
> (https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings)
> 
> To keep them equal, wouldn't you need:
>   if (LHS == SIDE_EFFECT && RHS == SIDE_EFFECT)
> return false;
> (that would at least seem symmetric)
As discussed offline, the comparison before makes sure that RHS == SIDE_EFFECT 
here.

Added a comment.


Comment at: lib/Format/SortJavaScriptImports.cpp:135
@@ +134,3 @@
+  LineEnd = Line->Last;
+  JsModuleReference Reference;
+  skipComments();

klimek wrote:
> Why are you defining this here, far before its use?
> 
> I think this code might be slightly simpler (for me to understand) if you 
> just pulled Reference out of the loop, and got rid of LastStart.
> 
> 
As discussed offline, moved the declaration a bit down.

I think exposing just a `SourceLocation Start` makes the algorithm easier to 
read, otherwise it'd look like a whole `JsModuleReference` could leave the 
loop, which is never the case. It explicitly points out we only have state 
outside of the loop to track the start.


http://reviews.llvm.org/D20198



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


Re: [clang-tools-extra] r269918 - [clang-tidy] Fix misc-unused-using-decls test failure in windows

2016-05-18 Thread Nico Weber via cfe-commits
Doesn't look like this helped:
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/12300

On Wed, May 18, 2016 at 9:07 AM, Haojian Wu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: hokein
> Date: Wed May 18 08:07:13 2016
> New Revision: 269918
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269918&view=rev
> Log:
> [clang-tidy] Fix misc-unused-using-decls test failure in windows
> buildbot.
>
> Modified:
> clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
>
> Modified:
> clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp?rev=269918&r1=269917&r2=269918&view=diff
>
> ==
> --- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
> (original)
> +++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
> Wed May 18 08:07:13 2016
> @@ -1,4 +1,4 @@
> -// RUN: %check_clang_tidy %s misc-unused-using-decls %t
> +// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- --
> -fno-delayed-template-parsing
>
>  // - Definitions -
>  template  class vector {};
>
>
> ___
> 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] D20366: [ASTMatcher] Make dump_ast_matchers.py executable.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein added a comment.

In http://reviews.llvm.org/D20366#433054, @aaron.ballman wrote:

> Yeah, I'm not certain either (I've never used phab for reviewing this sort of 
> thing). I would prefer this to be 0744 so that it is not group or world 
> executable.


No idea on this now. I tried `chmod 744` either in `git.core.filemode=true` or 
in  `git.core.filemode=false`, the git always shows 755 in the commit :(.


http://reviews.llvm.org/D20366



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


Re: [PATCH] D20277: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.

2016-05-18 Thread Felix Berger via cfe-commits
flx removed rL LLVM as the repository for this revision.
flx updated this revision to Diff 57620.

http://reviews.llvm.org/D20277

Files:
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tidy/performance/UnnecessaryValueParamCheck.h
  clang-tidy/utils/CMakeLists.txt
  clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tidy/utils/DeclRefExprUtils.h
  clang-tidy/utils/Matchers.h
  clang-tidy/utils/TypeTraits.cpp
  clang-tidy/utils/TypeTraits.h
  test/clang-tidy/performance-unnecessary-value-param.cpp

Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -1,5 +1,7 @@
 // RUN: %check_clang_tidy %s performance-unnecessary-value-param %t
 
+// CHECK-FIXES: #include 
+
 struct ExpensiveToCopyType {
   const ExpensiveToCopyType & constReference() const {
 return *this;
@@ -30,6 +32,15 @@
   void constMethod() const;
 };
 
+struct ExpensiveMovableType {
+  ExpensiveMovableType();
+  ExpensiveMovableType(ExpensiveMovableType &&) = default;
+  ExpensiveMovableType(const ExpensiveMovableType &) = default;
+  ExpensiveMovableType &operator=(const ExpensiveMovableType &) = default;
+  ExpensiveMovableType &operator=(ExpensiveMovableType &&) = default;
+  ~ExpensiveMovableType();
+};
+
 void positiveExpensiveConstValue(const ExpensiveToCopyType Obj);
 // CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& Obj);
 void positiveExpensiveConstValue(const ExpensiveToCopyType Obj) {
@@ -180,3 +191,36 @@
 void NegativeMoveOnlyTypePassedByValue(MoveOnlyType M) {
   M.constMethod();
 }
+
+void PositiveMoveOnCopyConstruction(ExpensiveMovableType E) {
+  auto F = E;
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: parameter 'E' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
+  // CHECK-FIXES: auto F = std::move(E);
+}
+
+void PositiveConstRefNotMoveSinceReferencedMultipleTimes(ExpensiveMovableType E) {
+  // CHECK-MESSAGES: [[@LINE-1]]:79: warning: the parameter 'E' is copied
+  // CHECK-FIXES: void PositiveConstRefNotMoveSinceReferencedMultipleTimes(const ExpensiveMovableType& E) {
+  auto F = E;
+  auto G = E;
+}
+
+void PositiveMoveOnCopyAssignment(ExpensiveMovableType E) {
+  ExpensiveMovableType F;
+  F = E;
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: parameter 'E' is passed by value
+  // CHECK-FIXES: F = std::move(E);
+}
+
+void PositiveConstRefNotMoveConstructible(ExpensiveToCopyType T) {
+  // CHECK-MESSAGES: [[@LINE-1]]:63: warning: the parameter 'T' is copied
+  // CHECK-FIXES: void PositiveConstRefNotMoveConstructible(const ExpensiveToCopyType& T) {
+  auto U = T;
+}
+
+void PositiveConstRefNotMoveAssignable(ExpensiveToCopyType A) {
+  // CHECK-MESSAGES: [[@LINE-1]]:60: warning: the parameter 'A' is copied
+  // CHECK-FIXES: void PositiveConstRefNotMoveAssignable(const ExpensiveToCopyType& A) {
+  ExpensiveToCopyType B;
+  B = A;
+}
Index: clang-tidy/utils/TypeTraits.h
===
--- clang-tidy/utils/TypeTraits.h
+++ clang-tidy/utils/TypeTraits.h
@@ -29,6 +29,12 @@
 bool recordIsTriviallyDefaultConstructible(const RecordDecl &RecordDecl,
const ASTContext &Context);
 
+// Returns true if Type has a non-deleted move constructor.
+bool hasMoveConstructor(QualType Type);
+
+// Return true if Type has a non-deleted move assignment operator.
+bool hasMoveAssignmentOperator(QualType Type);
+
 } // type_traits
 } // namespace utils
 } // namespace tidy
Index: clang-tidy/utils/TypeTraits.cpp
===
--- clang-tidy/utils/TypeTraits.cpp
+++ clang-tidy/utils/TypeTraits.cpp
@@ -123,6 +123,28 @@
   return false;
 }
 
+bool hasMoveConstructor(QualType Type) {
+  auto *Record = Type->getAsCXXRecordDecl();
+  if (!Record || !Record->hasDefinition())
+return false;
+  for (const auto *Constructor : Record->ctors()) {
+if (Constructor->isMoveConstructor() && !Constructor->isDeleted())
+  return true;
+  }
+  return false;
+}
+
+bool hasMoveAssignmentOperator(QualType Type) {
+  auto *Record = Type->getAsCXXRecordDecl();
+  if (!Record || !Record->hasDefinition())
+return false;
+  for (const auto *Method : Record->methods()) {
+if (Method->isMoveAssignmentOperator() && !Method->isDeleted())
+  return true;
+  }
+  return false;
+}
+
 } // namespace type_traits
 } // namespace utils
 } // namespace tidy
Index: clang-tidy/utils/Matchers.h
===
--- clang-tidy/utils/Matchers.h
+++ clang-tidy/utils/Matchers.h
@@ -40,6 +40,9 @@
   Node, Finder->getASTContext());
 }
 
+// Returns QualType matcher for references to const.
+ast_matchers::TypeMatcher isConstReference();
+
 } // namespace matc

r269932 - Removed duplicate SSE42 builtin tests from avx-builtins.c

2016-05-18 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed May 18 09:32:16 2016
New Revision: 269932

URL: http://llvm.org/viewvc/llvm-project?rev=269932&view=rev
Log:
Removed duplicate SSE42 builtin tests from avx-builtins.c

Modified:
cfe/trunk/test/CodeGen/avx-builtins.c

Modified: cfe/trunk/test/CodeGen/avx-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-builtins.c?rev=269932&r1=269931&r2=269932&view=diff
==
--- cfe/trunk/test/CodeGen/avx-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx-builtins.c Wed May 18 09:32:16 2016
@@ -24,76 +24,6 @@ __m256i test__mm256_loadu_si256(void* p)
   return _mm256_loadu_si256(p);
 }
 
-__m128i test_mm_cmpestrm(__m128i A, int LA, __m128i B, int LB) {
-  // CHECK: @llvm.x86.sse42.pcmpestrm128
-  return _mm_cmpestrm(A, LA, B, LB, 7);
-}
-
-int test_mm_cmpestri(__m128i A, int LA, __m128i B, int LB) {
-  // CHECK: @llvm.x86.sse42.pcmpestri128
-  return _mm_cmpestri(A, LA, B, LB, 7);
-}
-
-int test_mm_cmpestra(__m128i A, int LA, __m128i B, int LB) {
-  // CHECK: @llvm.x86.sse42.pcmpestria128
-  return _mm_cmpestra(A, LA, B, LB, 7);
-}
-
-int test_mm_cmpestrc(__m128i A, int LA, __m128i B, int LB) {
-  // CHECK: @llvm.x86.sse42.pcmpestric128
-  return _mm_cmpestrc(A, LA, B, LB, 7);
-}
-
-int test_mm_cmpestro(__m128i A, int LA, __m128i B, int LB) {
-  // CHECK: @llvm.x86.sse42.pcmpestrio128
-  return _mm_cmpestro(A, LA, B, LB, 7);
-}
-
-int test_mm_cmpestrs(__m128i A, int LA, __m128i B, int LB) {
-  // CHECK: @llvm.x86.sse42.pcmpestris128
-  return _mm_cmpestrs(A, LA, B, LB, 7);
-}
-
-int test_mm_cmpestrz(__m128i A, int LA, __m128i B, int LB) {
-  // CHECK: @llvm.x86.sse42.pcmpestriz128
-  return _mm_cmpestrz(A, LA, B, LB, 7);
-}
-
-__m128i test_mm_cmpistrm(__m128i A, __m128i B) {
-  // CHECK: @llvm.x86.sse42.pcmpistrm128
-  return _mm_cmpistrm(A, B, 7);
-}
-
-int test_mm_cmpistri(__m128i A, __m128i B) {
-  // CHECK: @llvm.x86.sse42.pcmpistri128
-  return _mm_cmpistri(A, B, 7);
-}
-
-int test_mm_cmpistra(__m128i A, __m128i B) {
-  // CHECK: @llvm.x86.sse42.pcmpistria128
-  return _mm_cmpistra(A, B, 7);
-}
-
-int test_mm_cmpistrc(__m128i A, __m128i B) {
-  // CHECK: @llvm.x86.sse42.pcmpistric128
-  return _mm_cmpistrc(A, B, 7);
-}
-
-int test_mm_cmpistro(__m128i A, __m128i B) {
-  // CHECK: @llvm.x86.sse42.pcmpistrio128
-  return _mm_cmpistro(A, B, 7);
-}
-
-int test_mm_cmpistrs(__m128i A, __m128i B) {
-  // CHECK: @llvm.x86.sse42.pcmpistris128
-  return _mm_cmpistrs(A, B, 7);
-}
-
-int test_mm_cmpistrz(__m128i A, __m128i B) {
-  // CHECK: @llvm.x86.sse42.pcmpistriz128
-  return _mm_cmpistrz(A, B, 7);
-}
-
 int test_extract_epi32(__m256i __a) {
   // CHECK-LABEL: @test_extract_epi32
   // CHECK: [[SHIFT1:%[^ ]+]] = and i32 %{{.*}}, 7


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


Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-18 Thread Martin Probst via cfe-commits
mprobst added a comment.

PTAL.


http://reviews.llvm.org/D20198



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


Re: [PATCH] D20360: [ASTMatcher] Add a node matcher for UnresolvedLookupExpr.

2016-05-18 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D20360#432882, @aaron.ballman wrote:

> In http://reviews.llvm.org/D20360#432878, @alexfh wrote:
>
> > In http://reviews.llvm.org/D20360#432874, @aaron.ballman wrote:
> >
> > > The changes to docs/tools/dump_ast_matchers.py look to be spurious, can 
> > > they be reverted?
> >
> >
> > The script should be executable, so the change looks fine to me.
>
>
> World executable? That's a bit presumptuous. ;-) 0744 may be fine, but 0755 
> does not seem correct to me.
>
> Regardless, I think that it should be a separate commit, not part of this one 
> as a drive-by (it has security implications, and that deserves review).


Not sure there's any benefit (or any added security) in limiting execution bit 
to the owner. I've never seen files with 0744 permission mask and when I tried 
to find some on my machine, I only found a few CUPS binaries. In any case, 
svn:executable does not allow much customization: 
http://svnbook.red-bean.com/en/1.7/svn.advanced.props.file-portability.html#svn.advanced.props.special.executable


Repository:
  rL LLVM

http://reviews.llvm.org/D20360



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


[PATCH] D20369: [ASTMatcher] Fix a ASTMatcher test failure on Windows.

2016-05-18 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added reviewers: alexfh, aaron.ballman.
hokein added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

http://reviews.llvm.org/D20369

Files:
  unittests/ASTMatchers/ASTMatchersTest.h

Index: unittests/ASTMatchers/ASTMatchersTest.h
===
--- unittests/ASTMatchers/ASTMatchersTest.h
+++ unittests/ASTMatchers/ASTMatchersTest.h
@@ -79,6 +79,8 @@
   // Some tests need rtti/exceptions on
   Args.push_back("-frtti");
   Args.push_back("-fexceptions");
+  // Keep the same template handling behavior on Windows and Linux.
+  Args.push_back("-fno-delayed-template-parsing");
   if (!runToolOnCodeWithArgs(
   Factory->create(), Code, Args, Filename, "clang-tool",
   std::make_shared(), VirtualMappedFiles)) {


Index: unittests/ASTMatchers/ASTMatchersTest.h
===
--- unittests/ASTMatchers/ASTMatchersTest.h
+++ unittests/ASTMatchers/ASTMatchersTest.h
@@ -79,6 +79,8 @@
   // Some tests need rtti/exceptions on
   Args.push_back("-frtti");
   Args.push_back("-fexceptions");
+  // Keep the same template handling behavior on Windows and Linux.
+  Args.push_back("-fno-delayed-template-parsing");
   if (!runToolOnCodeWithArgs(
   Factory->create(), Code, Args, Filename, "clang-tool",
   std::make_shared(), VirtualMappedFiles)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20366: [ASTMatcher] Make dump_ast_matchers.py executable.

2016-05-18 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D20366#433103, @hokein wrote:

> In http://reviews.llvm.org/D20366#433054, @aaron.ballman wrote:
>
> > Yeah, I'm not certain either (I've never used phab for reviewing this sort 
> > of thing). I would prefer this to be 0744 so that it is not group or world 
> > executable.
>
>
> No idea on this now. I tried `chmod 744` either in `git.core.filemode=true` 
> or in  `git.core.filemode=false`, the git always shows 755 in the commit :(.


It sounds like this may be a git thing and what you really want is 
svn:executable. However, the documentation doesn't specify *what* permissions 
that file winds up with 
(http://svnbook.red-bean.com/en/1.7/svn.advanced.props.file-portability.html#svn.advanced.props.special.executable).

What's the harm in leaving the props at 0644?


http://reviews.llvm.org/D20366



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


Re: [PATCH] D20369: [ASTMatcher] Fix a ASTMatcher test failure on Windows.

2016-05-18 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Hrm, I kind of worry about this masking bugs when delayed template parsing is 
enabled (which it is by default on MSVC-built versions of clang).


http://reviews.llvm.org/D20369



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


r269934 - [Hexagon] Recognize "q" and "v" in inline-asm as register constraints

2016-05-18 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Wed May 18 09:56:14 2016
New Revision: 269934

URL: http://llvm.org/viewvc/llvm-project?rev=269934&view=rev
Log:
[Hexagon] Recognize "q" and "v" in inline-asm as register constraints

Clang follow-up to r269933.

Added:
cfe/trunk/test/CodeGen/hexagon-inline-asm.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=269934&r1=269933&r2=269934&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed May 18 09:56:14 2016
@@ -6016,7 +6016,16 @@ public:
 
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &Info) const override {
-return true;
+switch (*Name) {
+  case 'v':
+  case 'q':
+if (HasHVX) {
+  Info.setAllowsRegister();
+  return true;
+}
+break;
+}
+return false;
   }
 
   void getTargetDefines(const LangOptions &Opts,

Added: cfe/trunk/test/CodeGen/hexagon-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/hexagon-inline-asm.c?rev=269934&view=auto
==
--- cfe/trunk/test/CodeGen/hexagon-inline-asm.c (added)
+++ cfe/trunk/test/CodeGen/hexagon-inline-asm.c Wed May 18 09:56:14 2016
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple hexagon-unknown-elf -target-feature +hvx -emit-llvm 
-o - %s | FileCheck %s
+
+typedef int v64 __attribute__((__vector_size__(64)))
+__attribute__((aligned(64)));
+
+void foo(v64 v0, v64 v1, v64 *p) {
+  v64 q0;
+  asm ("%0 = vgtw(%1.w,%2.w)" : "=q"(q0) : "v"(v0), "v"(v1));
+// CHECK: call <16 x i32> asm "$0 = vgtw($1.w,$2.w)", "=q,v,v"(<16 x 
i32>{{.*}}, <16 x i32>{{.*}})
+  *p = q0;
+}


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


Re: [PATCH] D20369: [ASTMatcher] Fix a ASTMatcher test failure on Windows.

2016-05-18 Thread Nico Weber via cfe-commits
thakis added a subscriber: thakis.
thakis added a comment.

I agree with Aaron. Maybe you could change Matcher.UnresolvedLookupExpr to call 
bar() from a new function foo() so that it gets instantiated?


http://reviews.llvm.org/D20369



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


Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-18 Thread Manuel Klimek via cfe-commits
klimek added a comment.

We're getting there. Couple of nits left.



Comment at: lib/Format/SortJavaScriptImports.cpp:94-97
@@ +93,6 @@
+// Side effect imports might be ordering sensitive. Consider them equal so
+// that they maintain their relative order in the stable sort below.
+// This retains transitivity because LHS.Category == RHS.Category here.
+return false;
+  // Empty URLs sort *last* (for export {...};).
+  if (LHS.URL.empty() != RHS.URL.empty())

Yea, completely missed that the != above.


Comment at: lib/Format/SortJavaScriptImports.cpp:128
@@ +127,3 @@
+SmallVector References;
+parseModuleReferences(Keywords, AnnotatedLines, References);
+

Return by value.


Comment at: lib/Format/SortJavaScriptImports.cpp:216-217
@@ +215,4 @@
+break;
+  Current = Line->First;
+  LineEnd = Line->Last;
+  skipComments();

Both of these are used only once, perhaps inline?


Comment at: lib/Format/SortJavaScriptImports.cpp:229
@@ +228,3 @@
+  Reference.Range.setBegin(Start);
+  Start = SourceLocation();
+  if (!parseModuleReference(Keywords, Reference))

I'd put that down after References.push_back so calculating the Reference is at 
least a single flow.


http://reviews.llvm.org/D20198



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


Re: [PATCH] D20369: [ASTMatcher] Fix a ASTMatcher test failure on Windows.

2016-05-18 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.

I like this approach much better, thank you. LGTM!


http://reviews.llvm.org/D20369



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


  1   2   >