[PATCH] D50346: Add getBeginLoc API to replace getLocStart

2018-08-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D50346

Files:
  include/clang/AST/Comment.h
  include/clang/AST/Decl.h
  include/clang/AST/DeclBase.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclObjC.h
  include/clang/AST/DeclarationName.h
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/ExprOpenMP.h
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RawCommentList.h
  include/clang/AST/Stmt.h
  include/clang/AST/StmtCXX.h
  include/clang/AST/StmtObjC.h
  include/clang/AST/StmtOpenMP.h
  include/clang/AST/TypeLoc.h
  include/clang/Sema/DeclSpec.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/Stmt.cpp
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -6121,7 +6121,8 @@
 StartToken, StartTokenByteOffset);
   }
 
-  SourceLocation getLocStart() const LLVM_READONLY {
+  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc();  }
+  SourceLocation getBeginLoc() const LLVM_READONLY {
 return FExpr->getLocStart().getLocWithOffset(Offset);
   }
 
Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -275,8 +275,8 @@
   llvm_unreachable("unknown statement kind!");
 }
 
-SourceLocation Stmt::getLocStart() const {
-//  llvm::errs() << "getLocStart() for " << getStmtClassName() << "\n";
+SourceLocation Stmt::getBeginLoc() const {
+//  llvm::errs() << "getBeginLoc() for " << getStmtClassName() << "\n";
   switch (getStmtClass()) {
   case Stmt::NoStmtClass: llvm_unreachable("statement without class");
 #define ABSTRACT_STMT(type)
Index: lib/AST/ExprCXX.cpp
===
--- lib/AST/ExprCXX.cpp
+++ lib/AST/ExprCXX.cpp
@@ -89,7 +89,7 @@
 }
 
 // CXXScalarValueInitExpr
-SourceLocation CXXScalarValueInitExpr::getLocStart() const {
+SourceLocation CXXScalarValueInitExpr::getBeginLoc() const {
   return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : RParenLoc;
 }
 
@@ -450,7 +450,7 @@
   return E;
 }
 
-SourceLocation CXXConstructExpr::getLocStart() const {
+SourceLocation CXXConstructExpr::getBeginLoc() const {
   if (isa(this))
 return cast(this)->getLocStart();
   return Loc;
@@ -691,7 +691,7 @@
   return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize);
 }
 
-SourceLocation CXXFunctionalCastExpr::getLocStart() const {
+SourceLocation CXXFunctionalCastExpr::getBeginLoc() const {
   return getTypeInfoAsWritten()->getTypeLoc().getLocStart();
 }
 
@@ -776,7 +776,7 @@
CXXConstructExpr::CK_Complete, ParenOrBraceRange),
   Type(TSI) {}
 
-SourceLocation CXXTemporaryObjectExpr::getLocStart() const {
+SourceLocation CXXTemporaryObjectExpr::getBeginLoc() const {
   return Type->getTypeLoc().getBeginLoc();
 }
 
@@ -1104,7 +1104,7 @@
   return new (Mem) CXXUnresolvedConstructExpr(Empty, NumArgs);
 }
 
-SourceLocation CXXUnresolvedConstructExpr::getLocStart() const {
+SourceLocation CXXUnresolvedConstructExpr::getBeginLoc() const {
   return Type->getTypeLoc().getBeginLoc();
 }
 
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -447,7 +447,7 @@
   return new (Mem) DeclRefExpr(EmptyShell());
 }
 
-SourceLocation DeclRefExpr::getLocStart() const {
+SourceLocation DeclRefExpr::getBeginLoc() const {
   if (hasQualifier())
 return getQualifierLoc().getBeginLoc();
   return getNameInfo().getLocStart();
@@ -1358,7 +1358,7 @@
   return FnType->getReturnType();
 }
 
-SourceLocation CallExpr::getLocStart() const {
+SourceLocation CallExpr::getBeginLoc() const {
   if (isa(this))
 return cast(this)->getLocStart();
 
@@ -1529,7 +1529,7 @@
   return E;
 }
 
-SourceLocation MemberExpr::getLocStart() const {
+SourceLocation MemberExpr::getBeginLoc() const {
   if (isImplicitAccess()) {
 if (hasQualifier())
   return getQualifierLoc().getBeginLoc();
@@ -2016,7 +2016,7 @@
   return Lit && Lit->getValue() == 0;
 }
 
-SourceLocation InitListExpr::getLocStart() const {
+SourceLocation InitListExpr::getBeginLoc() const {
   if (InitListExpr *SyntacticForm = getSyntacticForm())
 return SyntacticForm->getLocStart();
   SourceLocation Beg = LBraceLoc;
@@ -3847,7 +3847,7 @@
  DIE->getDesignator(size()-1)->getLocEnd());
 }
 
-SourceLocation DesignatedInitExpr::getLocStart() const {
+SourceLocation DesignatedInitExpr::getBeginLoc() const {
   SourceLocation StartLoc;
   auto *DIE = const_cast(this);
   Designator &First = *DIE->getDesignator(0);
@@ -3921,7 +3921,7 @@
   BaseAndUpdaterExprs[1] = ILE;
 }
 
-SourceLocation DesignatedInitUpdateExpr::getLocStart() const {
+SourceLocation DesignatedInitUpdateExpr::get

[PATCH] D50348: :Add getEndLoc API to replace getLocEnd

2018-08-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D50348

Files:
  include/clang/AST/Comment.h
  include/clang/AST/Decl.h
  include/clang/AST/DeclBase.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclObjC.h
  include/clang/AST/DeclarationName.h
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/ExprOpenMP.h
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RawCommentList.h
  include/clang/AST/Stmt.h
  include/clang/AST/StmtCXX.h
  include/clang/AST/StmtObjC.h
  include/clang/AST/StmtOpenMP.h
  include/clang/AST/TypeLoc.h
  include/clang/Sema/DeclSpec.h
  lib/AST/DeclObjC.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/Stmt.cpp
  lib/AST/StmtObjC.cpp
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -6126,7 +6126,8 @@
 return FExpr->getLocStart().getLocWithOffset(Offset);
   }
 
-  SourceLocation getLocEnd() const LLVM_READONLY { return FExpr->getLocEnd(); }
+  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc();  }
+  SourceLocation getEndLoc() const LLVM_READONLY { return FExpr->getLocEnd(); }
 };
 
 }  // namespace
Index: lib/AST/StmtObjC.cpp
===
--- lib/AST/StmtObjC.cpp
+++ lib/AST/StmtObjC.cpp
@@ -64,7 +64,7 @@
   return new (Mem) ObjCAtTryStmt(EmptyShell(), NumCatchStmts, HasFinally);
 }
 
-SourceLocation ObjCAtTryStmt::getLocEnd() const {
+SourceLocation ObjCAtTryStmt::getEndLoc() const {
   if (HasFinally)
 return getFinallyStmt()->getLocEnd();
   if (NumCatchStmts)
Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -288,7 +288,7 @@
   llvm_unreachable("unknown statement kind");
 }
 
-SourceLocation Stmt::getLocEnd() const {
+SourceLocation Stmt::getEndLoc() const {
   switch (getStmtClass()) {
   case Stmt::NoStmtClass: llvm_unreachable("statement without class");
 #define ABSTRACT_STMT(type)
Index: lib/AST/ExprCXX.cpp
===
--- lib/AST/ExprCXX.cpp
+++ lib/AST/ExprCXX.cpp
@@ -250,7 +250,7 @@
   return QualType();
 }
 
-SourceLocation CXXPseudoDestructorExpr::getLocEnd() const {
+SourceLocation CXXPseudoDestructorExpr::getEndLoc() const {
   SourceLocation End = DestroyedType.getLocation();
   if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
 End = TInfo->getTypeLoc().getLocalSourceRange().getEnd();
@@ -456,7 +456,7 @@
   return Loc;
 }
 
-SourceLocation CXXConstructExpr::getLocEnd() const {
+SourceLocation CXXConstructExpr::getEndLoc() const {
   if (isa(this))
 return cast(this)->getLocEnd();
 
@@ -695,7 +695,7 @@
   return getTypeInfoAsWritten()->getTypeLoc().getLocStart();
 }
 
-SourceLocation CXXFunctionalCastExpr::getLocEnd() const {
+SourceLocation CXXFunctionalCastExpr::getEndLoc() const {
   return RParenLoc.isValid() ? RParenLoc : getSubExpr()->getLocEnd();
 }
 
@@ -780,7 +780,7 @@
   return Type->getTypeLoc().getBeginLoc();
 }
 
-SourceLocation CXXTemporaryObjectExpr::getLocEnd() const {
+SourceLocation CXXTemporaryObjectExpr::getEndLoc() const {
   SourceLocation Loc = getParenOrBraceRange().getEnd();
   if (Loc.isInvalid() && getNumArgs())
 Loc = getArg(getNumArgs()-1)->getLocEnd();
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -452,7 +452,7 @@
 return getQualifierLoc().getBeginLoc();
   return getNameInfo().getLocStart();
 }
-SourceLocation DeclRefExpr::getLocEnd() const {
+SourceLocation DeclRefExpr::getEndLoc() const {
   if (hasExplicitTemplateArgs())
 return getRAngleLoc();
   return getNameInfo().getLocEnd();
@@ -1367,7 +1367,7 @@
 begin = getArg(0)->getLocStart();
   return begin;
 }
-SourceLocation CallExpr::getLocEnd() const {
+SourceLocation CallExpr::getEndLoc() const {
   if (isa(this))
 return cast(this)->getLocEnd();
 
@@ -1543,7 +1543,7 @@
 return BaseStartLoc;
   return MemberLoc;
 }
-SourceLocation MemberExpr::getLocEnd() const {
+SourceLocation MemberExpr::getEndLoc() const {
   SourceLocation EndLoc = getMemberNameInfo().getEndLoc();
   if (hasExplicitTemplateArgs())
 EndLoc = getRAngleLoc();
@@ -2034,7 +2034,7 @@
   return Beg;
 }
 
-SourceLocation InitListExpr::getLocEnd() const {
+SourceLocation InitListExpr::getEndLoc() const {
   if (InitListExpr *SyntacticForm = getSyntacticForm())
 return SyntacticForm->getLocEnd();
   SourceLocation End = RBraceLoc;
@@ -3862,7 +3862,7 @@
   return StartLoc;
 }
 
-SourceLocation DesignatedInitExpr::getLocEnd() const {
+SourceLocation DesignatedInitExpr::getEndLoc() const {
   return getInit()->getLocEnd();
 }
 
@@ -3925,7 +3925,7 @@
   return getBase()->getLocStart();

[PATCH] D50349: Port getStartLoc -> getBeginLoc

2018-08-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a reviewer: teemperor.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D50349

Files:
  include/clang/AST/Decl.h
  lib/AST/ASTImporter.cpp
  lib/Analysis/CloneDetection.cpp
  lib/CodeGen/CoverageMappingGen.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -530,7 +530,7 @@
   ProgramStateRef State = Pred->getState();
   const LocationContext *LCtx = Pred->getLocationContext();
   PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
-CNE->getStartLoc(),
+CNE->getBeginLoc(),
 "Error evaluating New Allocator Call");
   CallEventManager &CEMgr = getStateManager().getCallEventManager();
   CallEventRef Call =
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -223,7 +223,7 @@
 
 void ASTStmtWriter::VisitDeclStmt(DeclStmt *S) {
   VisitStmt(S);
-  Record.AddSourceLocation(S->getStartLoc());
+  Record.AddSourceLocation(S->getBeginLoc());
   Record.AddSourceLocation(S->getEndLoc());
   DeclGroupRef DG = S->getDeclGroup();
   for (DeclGroupRef::iterator D = DG.begin(), DEnd = DG.end(); D != DEnd; ++D)
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6875,7 +6875,7 @@
   if (!getDerived().AlwaysRebuild() && !DeclChanged)
 return S;
 
-  return getDerived().RebuildDeclStmt(Decls, S->getStartLoc(), S->getEndLoc());
+  return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
 }
 
 template
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -2066,7 +2066,7 @@
   assert(DS && "first part of for range not a decl stmt");
 
   if (!DS->isSingleDecl()) {
-Diag(DS->getStartLoc(), diag::err_type_defined_in_for_range);
+Diag(DS->getBeginLoc(), diag::err_type_defined_in_for_range);
 return StmtError();
   }
 
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -117,7 +117,7 @@
   }
 
   SpellingRegion(SourceManager &SM, SourceMappingRegion &R)
-  : SpellingRegion(SM, R.getStartLoc(), R.getEndLoc()) {}
+  : SpellingRegion(SM, R.getBeginLoc(), R.getEndLoc()) {}
 
   /// Check if the start and end locations appear in source order, i.e
   /// top->bottom, left->right.
@@ -230,7 +230,7 @@
 llvm::SmallSet Visited;
 SmallVector, 8> FileLocs;
 for (const auto &Region : SourceRegions) {
-  SourceLocation Loc = Region.getStartLoc();
+  SourceLocation Loc = Region.getBeginLoc();
   FileID File = SM.getFileID(Loc);
   if (!Visited.insert(File).second)
 continue;
@@ -312,7 +312,7 @@
 for (const auto &Region : SourceRegions) {
   assert(Region.hasEndLoc() && "incomplete region");
 
-  SourceLocation LocStart = Region.getStartLoc();
+  SourceLocation LocStart = Region.getBeginLoc();
   assert(SM.getFileID(LocStart).isValid() && "region in invalid file");
 
   // Ignore regions from system headers.
@@ -503,7 +503,7 @@
 DeferredRegion = None;
 
 // If the region ends in an expansion, find the expansion site.
-FileID StartFile = SM.getFileID(DR.getStartLoc());
+FileID StartFile = SM.getFileID(DR.getBeginLoc());
 if (SM.getFileID(DeferredEndLoc) != StartFile) {
   if (isNestedIn(DeferredEndLoc, StartFile)) {
 do {
@@ -516,12 +516,12 @@
 
 // The parent of this deferred region ends where the containing decl ends,
 // so the region isn't useful.
-if (DR.getStartLoc() == DeferredEndLoc)
+if (DR.getBeginLoc() == DeferredEndLoc)
   return Index;
 
 // If we're visiting statements in non-source order (e.g switch cases or
 // a loop condition) we can't construct a sensible deferred region.
-if (!SpellingRegion(SM, DR.getStartLoc(), DeferredEndLoc).isInSourceOrder())
+if (!SpellingRegion(SM, DR.getBeginLoc(), DeferredEndLoc).isInSourceOrder())
   return Index;
 
 DR.setGap(true);
@@ -563,7 +563,7 @@
 while (RegionStack.size() > ParentIndex) {
   SourceMappingRegion &Region = RegionStack.back();
   if (Region.hasStartLoc()) {
-SourceLocation StartLoc = Region.getStartLoc();
+SourceLocation StartLoc = Region.getBeginLoc();
 SourceLocation EndLoc = Region.hasEndLoc()
 

[PATCH] D50347: Add getBeginLoc API to replace getStartLoc

2018-08-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a reviewer: teemperor.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D50347

Files:
  include/clang/AST/ExprCXX.h
  include/clang/AST/Stmt.h
  include/clang/Analysis/CloneDetection.h
  lib/CodeGen/CoverageMappingGen.cpp


Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -67,7 +67,8 @@
 
   void setStartLoc(SourceLocation Loc) { LocStart = Loc; }
 
-  SourceLocation getStartLoc() const {
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
+  SourceLocation getBeginLoc() const {
 assert(LocStart && "Region has no start location");
 return *LocStart;
   }
Index: include/clang/Analysis/CloneDetection.h
===
--- include/clang/Analysis/CloneDetection.h
+++ include/clang/Analysis/CloneDetection.h
@@ -122,7 +122,8 @@
   /// Returns the start sourcelocation of the first statement in this sequence.
   ///
   /// This method should only be called on a non-empty StmtSequence object.
-  SourceLocation getStartLoc() const;
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
+  SourceLocation getBeginLoc() const;
 
   /// Returns the end sourcelocation of the last statement in this sequence.
   ///
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -523,7 +523,7 @@
   DeclGroupRef getDeclGroup() { return DG; }
   void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
 
-  SourceLocation getStartLoc() const { return StartLoc; }
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
   void setStartLoc(SourceLocation L) { StartLoc = L; }
   SourceLocation getEndLoc() const { return EndLoc; }
   void setEndLoc(SourceLocation L) { EndLoc = L; }
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -2069,7 +2069,8 @@
 return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
   }
 
-  SourceLocation getStartLoc() const { return Range.getBegin(); }
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
+  SourceLocation getBeginLoc() const { return Range.getBegin(); }
   SourceLocation getEndLoc() const { return Range.getEnd(); }
 
   SourceRange getDirectInitRange() const { return DirectInitRange; }
@@ -2079,7 +2080,6 @@
   }
 
   SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc();  }
-  SourceLocation getBeginLoc() const LLVM_READONLY { return getStartLoc(); }
   SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
 
   static bool classof(const Stmt *T) {


Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -67,7 +67,8 @@
 
   void setStartLoc(SourceLocation Loc) { LocStart = Loc; }
 
-  SourceLocation getStartLoc() const {
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
+  SourceLocation getBeginLoc() const {
 assert(LocStart && "Region has no start location");
 return *LocStart;
   }
Index: include/clang/Analysis/CloneDetection.h
===
--- include/clang/Analysis/CloneDetection.h
+++ include/clang/Analysis/CloneDetection.h
@@ -122,7 +122,8 @@
   /// Returns the start sourcelocation of the first statement in this sequence.
   ///
   /// This method should only be called on a non-empty StmtSequence object.
-  SourceLocation getStartLoc() const;
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
+  SourceLocation getBeginLoc() const;
 
   /// Returns the end sourcelocation of the last statement in this sequence.
   ///
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -523,7 +523,7 @@
   DeclGroupRef getDeclGroup() { return DG; }
   void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
 
-  SourceLocation getStartLoc() const { return StartLoc; }
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
   void setStartLoc(SourceLocation L) { StartLoc = L; }
   SourceLocation getEndLoc() const { return EndLoc; }
   void setEndLoc(SourceLocation L) { EndLoc = L; }
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -2069,7 +2069,8 @@
 return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
   }
 
-  SourceLocation getStartLoc() const { return

[PATCH] D50350: Port getLocStart -> getBeginLoc

2018-08-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added subscribers: cfe-commits, jfb, whisperity, jholewinski.
Herald added a reviewer: teemperor.

Repository:
  rC Clang

https://reviews.llvm.org/D50350

Files:
  docs/RAVFrontendAction.rst
  include/clang/AST/Comment.h
  include/clang/AST/Decl.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclObjC.h
  include/clang/AST/DeclarationName.h
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/ExprOpenMP.h
  include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h
  include/clang/AST/RawCommentList.h
  include/clang/AST/Stmt.h
  include/clang/AST/StmtCXX.h
  include/clang/AST/StmtDataCollectors.td
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/Sema/Initialization.h
  include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  lib/ARCMigrate/ObjCMT.cpp
  lib/ARCMigrate/TransAPIUses.cpp
  lib/ARCMigrate/TransAutoreleasePool.cpp
  lib/ARCMigrate/TransGCCalls.cpp
  lib/ARCMigrate/TransProtectedScope.cpp
  lib/ARCMigrate/TransRetainReleaseDealloc.cpp
  lib/ARCMigrate/TransUnbridgedCasts.cpp
  lib/ARCMigrate/TransformActions.cpp
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ASTStructuralEquivalence.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclObjC.cpp
  lib/AST/DeclOpenMP.cpp
  lib/AST/DeclTemplate.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/RawCommentList.cpp
  lib/AST/SelectorLocationsKind.cpp
  lib/AST/Stmt.cpp
  lib/AST/StmtPrinter.cpp
  lib/Analysis/AnalysisDeclContext.cpp
  lib/Analysis/CloneDetection.cpp
  lib/Analysis/Consumed.cpp
  lib/Analysis/LiveVariables.cpp
  lib/Analysis/ReachableCode.cpp
  lib/Analysis/ThreadSafety.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGCoroutine.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenPGO.cpp
  lib/CodeGen/CoverageMappingGen.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Frontend/Rewrite/RewriteModernObjC.cpp
  lib/Frontend/Rewrite/RewriteObjC.cpp
  lib/Index/IndexBody.cpp
  lib/Index/IndexDecl.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseObjc.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/AnalysisBasedWarnings.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaAttr.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaObjCProperty.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaPseudoObject.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/SemaStmtAsm.cpp
  lib/Sema/SemaStmtAttr.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
  lib/StaticAnalyzer/Checkers/TraversalChecker.cpp
  lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Core/CheckerHelpers.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  lib/Tooling/Refactoring/Extract/Extract.cpp
  lib/Tooling/Refactoring/Rename/USRFinder.cpp
  lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  tools/clang-func-mapping/ClangFnMapGen.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/CXIndexDataConsumer.cpp
  unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cp

[PATCH] D50353: Remove deprecated API

2018-08-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a reviewer: teemperor.
Herald added a subscriber: cfe-commits.
Herald added a reviewer: teemperor.

Repository:
  rC Clang

https://reviews.llvm.org/D50353

Files:
  include/clang/AST/Comment.h
  include/clang/AST/Decl.h
  include/clang/AST/DeclBase.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclObjC.h
  include/clang/AST/DeclarationName.h
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/ExprOpenMP.h
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RawCommentList.h
  include/clang/AST/Stmt.h
  include/clang/AST/StmtCXX.h
  include/clang/AST/StmtObjC.h
  include/clang/AST/StmtOpenMP.h
  include/clang/AST/TypeLoc.h
  include/clang/Analysis/CloneDetection.h
  include/clang/Sema/DeclSpec.h
  lib/CodeGen/CoverageMappingGen.cpp
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -6121,12 +6121,10 @@
 StartToken, StartTokenByteOffset);
   }
 
-  [[deprecated]] SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc();  }
   SourceLocation getBeginLoc() const LLVM_READONLY {
 return FExpr->getBeginLoc().getLocWithOffset(Offset);
   }
 
-  [[deprecated]] SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc();  }
   SourceLocation getEndLoc() const LLVM_READONLY { return FExpr->getEndLoc(); }
 };
 
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -67,7 +67,6 @@
 
   void setStartLoc(SourceLocation Loc) { LocStart = Loc; }
 
-  [[deprecated]] SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
   SourceLocation getBeginLoc() const {
 assert(LocStart && "Region has no start location");
 return *LocStart;
Index: include/clang/Sema/DeclSpec.h
===
--- include/clang/Sema/DeclSpec.h
+++ include/clang/Sema/DeclSpec.h
@@ -505,9 +505,7 @@
   const CXXScopeSpec &getTypeSpecScope() const { return TypeScope; }
 
   SourceRange getSourceRange() const LLVM_READONLY { return Range; }
-  [[deprecated]] SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc();  }
   SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
-  [[deprecated]] SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc();  }
   SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
 
   SourceLocation getTypeSpecWidthLoc() const { return TSWRange.getBegin(); }
@@ -1122,9 +1120,7 @@
   SourceRange getSourceRange() const LLVM_READONLY {
 return SourceRange(StartLocation, EndLocation);
   }
-  [[deprecated]] SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc();  }
   SourceLocation getBeginLoc() const LLVM_READONLY { return StartLocation; }
-  [[deprecated]] SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc();  }
   SourceLocation getEndLoc() const LLVM_READONLY { return EndLocation; }
 };
 
@@ -1874,9 +1870,7 @@
 
   /// Get the source range that spans this declarator.
   SourceRange getSourceRange() const LLVM_READONLY { return Range; }
-  [[deprecated]] SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc();  }
   SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
-  [[deprecated]] SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc();  }
   SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
 
   void SetSourceRange(SourceRange R) { Range = R; }
Index: include/clang/Analysis/CloneDetection.h
===
--- include/clang/Analysis/CloneDetection.h
+++ include/clang/Analysis/CloneDetection.h
@@ -122,7 +122,6 @@
   /// Returns the start sourcelocation of the first statement in this sequence.
   ///
   /// This method should only be called on a non-empty StmtSequence object.
-  [[deprecated]] SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
   SourceLocation getBeginLoc() const;
 
   /// Returns the end sourcelocation of the last statement in this sequence.
Index: include/clang/AST/TypeLoc.h
===
--- include/clang/AST/TypeLoc.h
+++ include/clang/AST/TypeLoc.h
@@ -151,8 +151,6 @@
 return SourceRange(getBeginLoc(), getEndLoc());
   }
 
-  [[deprecated]] SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc();  }
-  [[deprecated]] SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc();  }
 
   /// Get the local source range.
   SourceRange getLocalSourceRange() const {
Index: include/clang/AST/StmtOpenMP.h

[PATCH] D50355: Port getLocEnd -> getEndLoc

2018-08-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added subscribers: cfe-commits, kbarton, ioeric, nemanjai.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50355

Files:
  change-namespace/ChangeNamespace.cpp
  clang-move/ClangMove.cpp
  clang-tidy/android/CloexecCheck.cpp
  clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tidy/bugprone/CopyConstructorInitCheck.cpp
  clang-tidy/bugprone/InaccurateEraseCheck.cpp
  clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp
  clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
  clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
  clang-tidy/bugprone/UnusedRaiiCheck.cpp
  clang-tidy/cppcoreguidelines/NoMallocCheck.cpp
  clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp
  clang-tidy/fuchsia/DefaultArgumentsCheck.cpp
  clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tidy/google/ExplicitConstructorCheck.cpp
  clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tidy/misc/StaticAssertCheck.cpp
  clang-tidy/misc/UnusedAliasDeclsCheck.cpp
  clang-tidy/misc/UnusedParametersCheck.cpp
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tidy/modernize/AvoidBindCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/modernize/RedundantVoidArgCheck.cpp
  clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tidy/modernize/UseEqualsDeleteCheck.cpp
  clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
  clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tidy/performance/MoveConstArgCheck.cpp
  clang-tidy/readability/AvoidConstParamsInDecls.cpp
  clang-tidy/readability/BracesAroundStatementsCheck.cpp
  clang-tidy/readability/DeleteNullPointerCheck.cpp
  clang-tidy/readability/FunctionSizeCheck.cpp
  clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  clang-tidy/readability/MisleadingIndentationCheck.cpp
  clang-tidy/readability/RedundantControlFlowCheck.cpp
  clang-tidy/readability/SimplifyBooleanExprCheck.cpp
  clang-tidy/readability/SimplifySubscriptExprCheck.cpp
  clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
  unittests/clang-tidy/OverlappingReplacementsTest.cpp

Index: unittests/clang-tidy/OverlappingReplacementsTest.cpp
===
--- unittests/clang-tidy/OverlappingReplacementsTest.cpp
+++ unittests/clang-tidy/OverlappingReplacementsTest.cpp
@@ -52,7 +52,7 @@
 auto *Cond = If->getCond();
 SourceRange Range = Cond->getSourceRange();
 if (auto *D = If->getConditionVariable()) {
-  Range = SourceRange(D->getBeginLoc(), D->getLocEnd());
+  Range = SourceRange(D->getBeginLoc(), D->getEndLoc());
 }
 diag(Range.getBegin(), "the cake is a lie") << FixItHint::CreateReplacement(
 CharSourceRange::getTokenRange(Range), "false");
Index: clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
===
--- clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
+++ clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
@@ -52,15 +52,15 @@
 return;
 
   SourceLocation AfterPtr = Lexer::getLocForEndOfToken(
-  PtrExpr->getLocEnd(), 0, *Result.SourceManager, getLangOpts());
+  PtrExpr->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
 
   diag(DeleteExpr->getBeginLoc(),
"prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> "
"objects")
   << FixItHint::CreateRemoval(CharSourceRange::getCharRange(
  DeleteExpr->getBeginLoc(), PtrExpr->getBeginLoc()))
   << FixItHint::CreateReplacement(
- CharSourceRange::getTokenRange(AfterPtr, DeleteExpr->getLocEnd()),
+ CharSourceRange::getTokenRange(AfterPtr, DeleteExpr->getEndLoc()),
  " = nullptr");
 }
 
Index: clang-tidy/readability/SimplifySubscriptExprCheck.cpp
===
--- clang-tidy/readability/SimplifySubscriptExprCheck.cpp
+++ clang-tidy/readability/SimplifySubscriptExprCheck.cpp
@@ -63,7 +63,7 @@
 DiagBuilder << FixItHint::CreateInsertion(Member->getBeginLoc(), "(*")
 << FixItHint::CreateInsertion(Member->getOperatorLoc(), ")");
   DiagBuilder << FixItHint::CreateRemoval(
-  {Member->getOperatorLoc(), Call->getLocEnd()});
+  {Member->getOperatorLoc(), Call->getEndLoc()});
 }
 
 void SimplifySubscriptExprCheck::storeOptions(
Index: clang-tidy/readability/SimplifyBooleanExprCheck.cpp
===
--- clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -385,7 +385,7 @@
const Expr *ReplaceWith, bool Negated) {
 std::string Replacement =
 replacementExpression(Result, Negated, ReplaceWith);
-SourceRange Range(LHS->getB

[PATCH] D50349: Port getStartLoc -> getBeginLoc

2018-08-07 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Thanks Hans. Yes, I made these patches with some simple sed oneliners.

Once these are approved in principle, I'll re-generate them before pushing.

I have also run clang-format on them, but didn't update Phab with the results 
to reduce noise.


Repository:
  rC Clang

https://reviews.llvm.org/D50349



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


[PATCH] D50409: Remove obsolete set call

2018-08-07 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added reviewers: rsmith, dblaikie.
Herald added a subscriber: cfe-commits.

Case case of the switch statement here makes the same call, but it is
already done at the start of the function.


Repository:
  rC Clang

https://reviews.llvm.org/D50409

Files:
  lib/Sema/SemaDecl.cpp


Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -4954,7 +4954,6 @@
   case UnqualifiedIdKind::IK_ImplicitSelfParam:
   case UnqualifiedIdKind::IK_Identifier:
 NameInfo.setName(Name.Identifier);
-NameInfo.setLoc(Name.StartLocation);
 return NameInfo;
 
   case UnqualifiedIdKind::IK_DeductionGuideName: {
@@ -4981,14 +4980,12 @@
 
 NameInfo.setName(
 Context.DeclarationNames.getCXXDeductionGuideName(Template));
-NameInfo.setLoc(Name.StartLocation);
 return NameInfo;
   }
 
   case UnqualifiedIdKind::IK_OperatorFunctionId:
 NameInfo.setName(Context.DeclarationNames.getCXXOperatorName(
Name.OperatorFunctionId.Operator));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.getInfo().CXXOperatorName.BeginOpNameLoc
   = Name.OperatorFunctionId.SymbolLocations[0];
 NameInfo.getInfo().CXXOperatorName.EndOpNameLoc
@@ -4998,7 +4995,6 @@
   case UnqualifiedIdKind::IK_LiteralOperatorId:
 NameInfo.setName(Context.DeclarationNames.getCXXLiteralOperatorName(
Name.Identifier));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setCXXLiteralOperatorNameLoc(Name.EndLocation);
 return NameInfo;
 
@@ -5009,7 +5005,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXConversionFunctionName(
Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }
@@ -5021,7 +5016,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXConstructorName(
   Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }
@@ -5043,7 +5037,6 @@
 
 NameInfo.setName(Context.DeclarationNames.getCXXConstructorName(
 Context.getCanonicalType(CurClassType)));
-NameInfo.setLoc(Name.StartLocation);
 // FIXME: should we retrieve TypeSourceInfo?
 NameInfo.setNamedTypeInfo(nullptr);
 return NameInfo;
@@ -5056,7 +5049,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXDestructorName(
   Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }


Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -4954,7 +4954,6 @@
   case UnqualifiedIdKind::IK_ImplicitSelfParam:
   case UnqualifiedIdKind::IK_Identifier:
 NameInfo.setName(Name.Identifier);
-NameInfo.setLoc(Name.StartLocation);
 return NameInfo;
 
   case UnqualifiedIdKind::IK_DeductionGuideName: {
@@ -4981,14 +4980,12 @@
 
 NameInfo.setName(
 Context.DeclarationNames.getCXXDeductionGuideName(Template));
-NameInfo.setLoc(Name.StartLocation);
 return NameInfo;
   }
 
   case UnqualifiedIdKind::IK_OperatorFunctionId:
 NameInfo.setName(Context.DeclarationNames.getCXXOperatorName(
Name.OperatorFunctionId.Operator));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.getInfo().CXXOperatorName.BeginOpNameLoc
   = Name.OperatorFunctionId.SymbolLocations[0];
 NameInfo.getInfo().CXXOperatorName.EndOpNameLoc
@@ -4998,7 +4995,6 @@
   case UnqualifiedIdKind::IK_LiteralOperatorId:
 NameInfo.setName(Context.DeclarationNames.getCXXLiteralOperatorName(
Name.Identifier));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setCXXLiteralOperatorNameLoc(Name.EndLocation);
 return NameInfo;
 
@@ -5009,7 +5005,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXConversionFunctionName(
Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }
@@ -5021,7 +5016,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXConstructorName(
   Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }
@@ -5043,7 +5037,6 @@
 
  

[PATCH] D50346: Add getBeginLoc API to replace getLocStart

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339372: Add getBeginLoc API to replace getLocStart (authored 
by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50346?vs=159357&id=159983#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50346

Files:
  cfe/trunk/include/clang/AST/Comment.h
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/include/clang/AST/DeclBase.h
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/include/clang/AST/DeclObjC.h
  cfe/trunk/include/clang/AST/DeclarationName.h
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/include/clang/AST/ExprCXX.h
  cfe/trunk/include/clang/AST/ExprObjC.h
  cfe/trunk/include/clang/AST/ExprOpenMP.h
  cfe/trunk/include/clang/AST/OpenMPClause.h
  cfe/trunk/include/clang/AST/RawCommentList.h
  cfe/trunk/include/clang/AST/Stmt.h
  cfe/trunk/include/clang/AST/StmtCXX.h
  cfe/trunk/include/clang/AST/StmtObjC.h
  cfe/trunk/include/clang/AST/StmtOpenMP.h
  cfe/trunk/include/clang/Sema/DeclSpec.h
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/ExprCXX.cpp
  cfe/trunk/lib/AST/Stmt.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp

Index: cfe/trunk/lib/AST/Stmt.cpp
===
--- cfe/trunk/lib/AST/Stmt.cpp
+++ cfe/trunk/lib/AST/Stmt.cpp
@@ -275,8 +275,8 @@
   llvm_unreachable("unknown statement kind!");
 }
 
-SourceLocation Stmt::getLocStart() const {
-//  llvm::errs() << "getLocStart() for " << getStmtClassName() << "\n";
+SourceLocation Stmt::getBeginLoc() const {
+  //  llvm::errs() << "getBeginLoc() for " << getStmtClassName() << "\n";
   switch (getStmtClass()) {
   case Stmt::NoStmtClass: llvm_unreachable("statement without class");
 #define ABSTRACT_STMT(type)
Index: cfe/trunk/lib/AST/ExprCXX.cpp
===
--- cfe/trunk/lib/AST/ExprCXX.cpp
+++ cfe/trunk/lib/AST/ExprCXX.cpp
@@ -89,7 +89,7 @@
 }
 
 // CXXScalarValueInitExpr
-SourceLocation CXXScalarValueInitExpr::getLocStart() const {
+SourceLocation CXXScalarValueInitExpr::getBeginLoc() const {
   return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : RParenLoc;
 }
 
@@ -450,7 +450,7 @@
   return E;
 }
 
-SourceLocation CXXConstructExpr::getLocStart() const {
+SourceLocation CXXConstructExpr::getBeginLoc() const {
   if (isa(this))
 return cast(this)->getLocStart();
   return Loc;
@@ -707,7 +707,7 @@
   return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize);
 }
 
-SourceLocation CXXFunctionalCastExpr::getLocStart() const {
+SourceLocation CXXFunctionalCastExpr::getBeginLoc() const {
   return getTypeInfoAsWritten()->getTypeLoc().getLocStart();
 }
 
@@ -792,7 +792,7 @@
CXXConstructExpr::CK_Complete, ParenOrBraceRange),
   Type(TSI) {}
 
-SourceLocation CXXTemporaryObjectExpr::getLocStart() const {
+SourceLocation CXXTemporaryObjectExpr::getBeginLoc() const {
   return Type->getTypeLoc().getBeginLoc();
 }
 
@@ -1120,7 +1120,7 @@
   return new (Mem) CXXUnresolvedConstructExpr(Empty, NumArgs);
 }
 
-SourceLocation CXXUnresolvedConstructExpr::getLocStart() const {
+SourceLocation CXXUnresolvedConstructExpr::getBeginLoc() const {
   return Type->getTypeLoc().getBeginLoc();
 }
 
Index: cfe/trunk/lib/AST/Expr.cpp
===
--- cfe/trunk/lib/AST/Expr.cpp
+++ cfe/trunk/lib/AST/Expr.cpp
@@ -447,7 +447,7 @@
   return new (Mem) DeclRefExpr(EmptyShell());
 }
 
-SourceLocation DeclRefExpr::getLocStart() const {
+SourceLocation DeclRefExpr::getBeginLoc() const {
   if (hasQualifier())
 return getQualifierLoc().getBeginLoc();
   return getNameInfo().getLocStart();
@@ -1358,7 +1358,7 @@
   return FnType->getReturnType();
 }
 
-SourceLocation CallExpr::getLocStart() const {
+SourceLocation CallExpr::getBeginLoc() const {
   if (isa(this))
 return cast(this)->getLocStart();
 
@@ -1529,7 +1529,7 @@
   return E;
 }
 
-SourceLocation MemberExpr::getLocStart() const {
+SourceLocation MemberExpr::getBeginLoc() const {
   if (isImplicitAccess()) {
 if (hasQualifier())
   return getQualifierLoc().getBeginLoc();
@@ -2039,7 +2039,7 @@
   return Lit && Lit->getValue() == 0;
 }
 
-SourceLocation InitListExpr::getLocStart() const {
+SourceLocation InitListExpr::getBeginLoc() const {
   if (InitListExpr *SyntacticForm = getSyntacticForm())
 return SyntacticForm->getLocStart();
   SourceLocation Beg = LBraceLoc;
@@ -3870,7 +3870,7 @@
  DIE->getDesignator(size()-1)->getLocEnd());
 }
 
-SourceLocation DesignatedInitExpr::getLocStart() const {
+SourceLocation DesignatedInitExpr::getBeginLoc() const {
   SourceLocation StartLoc;
   auto *DIE = const_cast(this);
   Designator &First = *DIE->getDesignator(0);
@@ -3944,7 +3944,7 @@
   BaseAndUpdaterExprs[1] = ILE;
 }
 
-SourceLocation DesignatedInitUpd

[PATCH] D50346: Add getBeginLoc API to replace getLocStart

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339372: Add getBeginLoc API to replace getLocStart (authored 
by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50346?vs=159357&id=159984#toc

Repository:
  rC Clang

https://reviews.llvm.org/D50346

Files:
  include/clang/AST/Comment.h
  include/clang/AST/Decl.h
  include/clang/AST/DeclBase.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclObjC.h
  include/clang/AST/DeclarationName.h
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/ExprOpenMP.h
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RawCommentList.h
  include/clang/AST/Stmt.h
  include/clang/AST/StmtCXX.h
  include/clang/AST/StmtObjC.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Sema/DeclSpec.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/Stmt.cpp
  lib/Sema/SemaChecking.cpp

Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -447,7 +447,7 @@
   return new (Mem) DeclRefExpr(EmptyShell());
 }
 
-SourceLocation DeclRefExpr::getLocStart() const {
+SourceLocation DeclRefExpr::getBeginLoc() const {
   if (hasQualifier())
 return getQualifierLoc().getBeginLoc();
   return getNameInfo().getLocStart();
@@ -1358,7 +1358,7 @@
   return FnType->getReturnType();
 }
 
-SourceLocation CallExpr::getLocStart() const {
+SourceLocation CallExpr::getBeginLoc() const {
   if (isa(this))
 return cast(this)->getLocStart();
 
@@ -1529,7 +1529,7 @@
   return E;
 }
 
-SourceLocation MemberExpr::getLocStart() const {
+SourceLocation MemberExpr::getBeginLoc() const {
   if (isImplicitAccess()) {
 if (hasQualifier())
   return getQualifierLoc().getBeginLoc();
@@ -2039,7 +2039,7 @@
   return Lit && Lit->getValue() == 0;
 }
 
-SourceLocation InitListExpr::getLocStart() const {
+SourceLocation InitListExpr::getBeginLoc() const {
   if (InitListExpr *SyntacticForm = getSyntacticForm())
 return SyntacticForm->getLocStart();
   SourceLocation Beg = LBraceLoc;
@@ -3870,7 +3870,7 @@
  DIE->getDesignator(size()-1)->getLocEnd());
 }
 
-SourceLocation DesignatedInitExpr::getLocStart() const {
+SourceLocation DesignatedInitExpr::getBeginLoc() const {
   SourceLocation StartLoc;
   auto *DIE = const_cast(this);
   Designator &First = *DIE->getDesignator(0);
@@ -3944,7 +3944,7 @@
   BaseAndUpdaterExprs[1] = ILE;
 }
 
-SourceLocation DesignatedInitUpdateExpr::getLocStart() const {
+SourceLocation DesignatedInitUpdateExpr::getBeginLoc() const {
   return getBase()->getLocStart();
 }
 
Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -275,8 +275,8 @@
   llvm_unreachable("unknown statement kind!");
 }
 
-SourceLocation Stmt::getLocStart() const {
-//  llvm::errs() << "getLocStart() for " << getStmtClassName() << "\n";
+SourceLocation Stmt::getBeginLoc() const {
+  //  llvm::errs() << "getBeginLoc() for " << getStmtClassName() << "\n";
   switch (getStmtClass()) {
   case Stmt::NoStmtClass: llvm_unreachable("statement without class");
 #define ABSTRACT_STMT(type)
Index: lib/AST/ExprCXX.cpp
===
--- lib/AST/ExprCXX.cpp
+++ lib/AST/ExprCXX.cpp
@@ -89,7 +89,7 @@
 }
 
 // CXXScalarValueInitExpr
-SourceLocation CXXScalarValueInitExpr::getLocStart() const {
+SourceLocation CXXScalarValueInitExpr::getBeginLoc() const {
   return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : RParenLoc;
 }
 
@@ -450,7 +450,7 @@
   return E;
 }
 
-SourceLocation CXXConstructExpr::getLocStart() const {
+SourceLocation CXXConstructExpr::getBeginLoc() const {
   if (isa(this))
 return cast(this)->getLocStart();
   return Loc;
@@ -707,7 +707,7 @@
   return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize);
 }
 
-SourceLocation CXXFunctionalCastExpr::getLocStart() const {
+SourceLocation CXXFunctionalCastExpr::getBeginLoc() const {
   return getTypeInfoAsWritten()->getTypeLoc().getLocStart();
 }
 
@@ -792,7 +792,7 @@
CXXConstructExpr::CK_Complete, ParenOrBraceRange),
   Type(TSI) {}
 
-SourceLocation CXXTemporaryObjectExpr::getLocStart() const {
+SourceLocation CXXTemporaryObjectExpr::getBeginLoc() const {
   return Type->getTypeLoc().getBeginLoc();
 }
 
@@ -1120,7 +1120,7 @@
   return new (Mem) CXXUnresolvedConstructExpr(Empty, NumArgs);
 }
 
-SourceLocation CXXUnresolvedConstructExpr::getLocStart() const {
+SourceLocation CXXUnresolvedConstructExpr::getBeginLoc() const {
   return Type->getTypeLoc().getBeginLoc();
 }
 
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -6121,7 +6121,8 @@
 

[PATCH] D50347: Add getBeginLoc API to replace getStartLoc

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339373: Add getBeginLoc API to replace getStartLoc (authored 
by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50347?vs=159358&id=159986#toc

Repository:
  rC Clang

https://reviews.llvm.org/D50347

Files:
  include/clang/AST/ExprCXX.h
  include/clang/AST/Stmt.h
  include/clang/Analysis/CloneDetection.h
  lib/CodeGen/CoverageMappingGen.cpp


Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -67,7 +67,8 @@
 
   void setStartLoc(SourceLocation Loc) { LocStart = Loc; }
 
-  SourceLocation getStartLoc() const {
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); }
+  SourceLocation getBeginLoc() const {
 assert(LocStart && "Region has no start location");
 return *LocStart;
   }
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -2094,7 +2094,8 @@
 return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
   }
 
-  SourceLocation getStartLoc() const { return Range.getBegin(); }
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); }
+  SourceLocation getBeginLoc() const { return Range.getBegin(); }
   SourceLocation getEndLoc() const { return Range.getEnd(); }
 
   SourceRange getDirectInitRange() const { return DirectInitRange; }
@@ -2104,7 +2105,6 @@
   }
 
   SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
-  SourceLocation getBeginLoc() const LLVM_READONLY { return getStartLoc(); }
   SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
 
   static bool classof(const Stmt *T) {
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -523,7 +523,7 @@
   DeclGroupRef getDeclGroup() { return DG; }
   void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
 
-  SourceLocation getStartLoc() const { return StartLoc; }
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); }
   void setStartLoc(SourceLocation L) { StartLoc = L; }
   SourceLocation getEndLoc() const { return EndLoc; }
   void setEndLoc(SourceLocation L) { EndLoc = L; }
Index: include/clang/Analysis/CloneDetection.h
===
--- include/clang/Analysis/CloneDetection.h
+++ include/clang/Analysis/CloneDetection.h
@@ -122,7 +122,8 @@
   /// Returns the start sourcelocation of the first statement in this sequence.
   ///
   /// This method should only be called on a non-empty StmtSequence object.
-  SourceLocation getStartLoc() const;
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); }
+  SourceLocation getBeginLoc() const;
 
   /// Returns the end sourcelocation of the last statement in this sequence.
   ///


Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -67,7 +67,8 @@
 
   void setStartLoc(SourceLocation Loc) { LocStart = Loc; }
 
-  SourceLocation getStartLoc() const {
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); }
+  SourceLocation getBeginLoc() const {
 assert(LocStart && "Region has no start location");
 return *LocStart;
   }
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -2094,7 +2094,8 @@
 return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
   }
 
-  SourceLocation getStartLoc() const { return Range.getBegin(); }
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); }
+  SourceLocation getBeginLoc() const { return Range.getBegin(); }
   SourceLocation getEndLoc() const { return Range.getEnd(); }
 
   SourceRange getDirectInitRange() const { return DirectInitRange; }
@@ -2104,7 +2105,6 @@
   }
 
   SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
-  SourceLocation getBeginLoc() const LLVM_READONLY { return getStartLoc(); }
   SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
 
   static bool classof(const Stmt *T) {
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -523,7 +523,7 @@
   DeclGroupRef getDeclGroup() { return DG; }
   void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
 
-  SourceLocation getStartLoc() const { return StartLoc; }
+  SourceLocation getStartLoc() con

[PATCH] D50347: Add getBeginLoc API to replace getStartLoc

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339373: Add getBeginLoc API to replace getStartLoc (authored 
by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50347?vs=159358&id=159985#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50347

Files:
  cfe/trunk/include/clang/AST/ExprCXX.h
  cfe/trunk/include/clang/AST/Stmt.h
  cfe/trunk/include/clang/Analysis/CloneDetection.h
  cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp


Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
===
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
@@ -67,7 +67,8 @@
 
   void setStartLoc(SourceLocation Loc) { LocStart = Loc; }
 
-  SourceLocation getStartLoc() const {
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); }
+  SourceLocation getBeginLoc() const {
 assert(LocStart && "Region has no start location");
 return *LocStart;
   }
Index: cfe/trunk/include/clang/AST/Stmt.h
===
--- cfe/trunk/include/clang/AST/Stmt.h
+++ cfe/trunk/include/clang/AST/Stmt.h
@@ -523,7 +523,7 @@
   DeclGroupRef getDeclGroup() { return DG; }
   void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
 
-  SourceLocation getStartLoc() const { return StartLoc; }
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); }
   void setStartLoc(SourceLocation L) { StartLoc = L; }
   SourceLocation getEndLoc() const { return EndLoc; }
   void setEndLoc(SourceLocation L) { EndLoc = L; }
Index: cfe/trunk/include/clang/AST/ExprCXX.h
===
--- cfe/trunk/include/clang/AST/ExprCXX.h
+++ cfe/trunk/include/clang/AST/ExprCXX.h
@@ -2094,7 +2094,8 @@
 return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
   }
 
-  SourceLocation getStartLoc() const { return Range.getBegin(); }
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); }
+  SourceLocation getBeginLoc() const { return Range.getBegin(); }
   SourceLocation getEndLoc() const { return Range.getEnd(); }
 
   SourceRange getDirectInitRange() const { return DirectInitRange; }
@@ -2104,7 +2105,6 @@
   }
 
   SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
-  SourceLocation getBeginLoc() const LLVM_READONLY { return getStartLoc(); }
   SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
 
   static bool classof(const Stmt *T) {
Index: cfe/trunk/include/clang/Analysis/CloneDetection.h
===
--- cfe/trunk/include/clang/Analysis/CloneDetection.h
+++ cfe/trunk/include/clang/Analysis/CloneDetection.h
@@ -122,7 +122,8 @@
   /// Returns the start sourcelocation of the first statement in this sequence.
   ///
   /// This method should only be called on a non-empty StmtSequence object.
-  SourceLocation getStartLoc() const;
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); }
+  SourceLocation getBeginLoc() const;
 
   /// Returns the end sourcelocation of the last statement in this sequence.
   ///


Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
===
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
@@ -67,7 +67,8 @@
 
   void setStartLoc(SourceLocation Loc) { LocStart = Loc; }
 
-  SourceLocation getStartLoc() const {
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); }
+  SourceLocation getBeginLoc() const {
 assert(LocStart && "Region has no start location");
 return *LocStart;
   }
Index: cfe/trunk/include/clang/AST/Stmt.h
===
--- cfe/trunk/include/clang/AST/Stmt.h
+++ cfe/trunk/include/clang/AST/Stmt.h
@@ -523,7 +523,7 @@
   DeclGroupRef getDeclGroup() { return DG; }
   void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
 
-  SourceLocation getStartLoc() const { return StartLoc; }
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); }
   void setStartLoc(SourceLocation L) { StartLoc = L; }
   SourceLocation getEndLoc() const { return EndLoc; }
   void setEndLoc(SourceLocation L) { EndLoc = L; }
Index: cfe/trunk/include/clang/AST/ExprCXX.h
===
--- cfe/trunk/include/clang/AST/ExprCXX.h
+++ cfe/trunk/include/clang/AST/ExprCXX.h
@@ -2094,7 +2094,8 @@
 return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
   }
 
-  SourceLocation getStartLoc() const { return Range.getBegin(); }
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); }
+  Sour

[PATCH] D50348: :Add getEndLoc API to replace getLocEnd

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339374: Add getEndLoc API to replace getLocEnd (authored by 
steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50348?vs=159359&id=159987#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50348

Files:
  cfe/trunk/include/clang/AST/Comment.h
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/include/clang/AST/DeclBase.h
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/include/clang/AST/DeclObjC.h
  cfe/trunk/include/clang/AST/DeclarationName.h
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/include/clang/AST/ExprCXX.h
  cfe/trunk/include/clang/AST/ExprObjC.h
  cfe/trunk/include/clang/AST/ExprOpenMP.h
  cfe/trunk/include/clang/AST/OpenMPClause.h
  cfe/trunk/include/clang/AST/RawCommentList.h
  cfe/trunk/include/clang/AST/Stmt.h
  cfe/trunk/include/clang/AST/StmtCXX.h
  cfe/trunk/include/clang/AST/StmtObjC.h
  cfe/trunk/include/clang/AST/StmtOpenMP.h
  cfe/trunk/include/clang/Sema/DeclSpec.h
  cfe/trunk/lib/AST/DeclObjC.cpp
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/ExprCXX.cpp
  cfe/trunk/lib/AST/Stmt.cpp
  cfe/trunk/lib/AST/StmtObjC.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp

Index: cfe/trunk/lib/AST/Stmt.cpp
===
--- cfe/trunk/lib/AST/Stmt.cpp
+++ cfe/trunk/lib/AST/Stmt.cpp
@@ -288,7 +288,7 @@
   llvm_unreachable("unknown statement kind");
 }
 
-SourceLocation Stmt::getLocEnd() const {
+SourceLocation Stmt::getEndLoc() const {
   switch (getStmtClass()) {
   case Stmt::NoStmtClass: llvm_unreachable("statement without class");
 #define ABSTRACT_STMT(type)
Index: cfe/trunk/lib/AST/DeclObjC.cpp
===
--- cfe/trunk/lib/AST/DeclObjC.cpp
+++ cfe/trunk/lib/AST/DeclObjC.cpp
@@ -969,7 +969,7 @@
   return this;
 }
 
-SourceLocation ObjCMethodDecl::getLocEnd() const {
+SourceLocation ObjCMethodDecl::getEndLoc() const {
   if (Stmt *Body = getBody())
 return Body->getLocEnd();
   return DeclEndLoc;
Index: cfe/trunk/lib/AST/ExprCXX.cpp
===
--- cfe/trunk/lib/AST/ExprCXX.cpp
+++ cfe/trunk/lib/AST/ExprCXX.cpp
@@ -250,7 +250,7 @@
   return QualType();
 }
 
-SourceLocation CXXPseudoDestructorExpr::getLocEnd() const {
+SourceLocation CXXPseudoDestructorExpr::getEndLoc() const {
   SourceLocation End = DestroyedType.getLocation();
   if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
 End = TInfo->getTypeLoc().getLocalSourceRange().getEnd();
@@ -456,7 +456,7 @@
   return Loc;
 }
 
-SourceLocation CXXConstructExpr::getLocEnd() const {
+SourceLocation CXXConstructExpr::getEndLoc() const {
   if (isa(this))
 return cast(this)->getLocEnd();
 
@@ -711,7 +711,7 @@
   return getTypeInfoAsWritten()->getTypeLoc().getLocStart();
 }
 
-SourceLocation CXXFunctionalCastExpr::getLocEnd() const {
+SourceLocation CXXFunctionalCastExpr::getEndLoc() const {
   return RParenLoc.isValid() ? RParenLoc : getSubExpr()->getLocEnd();
 }
 
@@ -796,7 +796,7 @@
   return Type->getTypeLoc().getBeginLoc();
 }
 
-SourceLocation CXXTemporaryObjectExpr::getLocEnd() const {
+SourceLocation CXXTemporaryObjectExpr::getEndLoc() const {
   SourceLocation Loc = getParenOrBraceRange().getEnd();
   if (Loc.isInvalid() && getNumArgs())
 Loc = getArg(getNumArgs()-1)->getLocEnd();
Index: cfe/trunk/lib/AST/StmtObjC.cpp
===
--- cfe/trunk/lib/AST/StmtObjC.cpp
+++ cfe/trunk/lib/AST/StmtObjC.cpp
@@ -64,7 +64,7 @@
   return new (Mem) ObjCAtTryStmt(EmptyShell(), NumCatchStmts, HasFinally);
 }
 
-SourceLocation ObjCAtTryStmt::getLocEnd() const {
+SourceLocation ObjCAtTryStmt::getEndLoc() const {
   if (HasFinally)
 return getFinallyStmt()->getLocEnd();
   if (NumCatchStmts)
Index: cfe/trunk/lib/AST/Expr.cpp
===
--- cfe/trunk/lib/AST/Expr.cpp
+++ cfe/trunk/lib/AST/Expr.cpp
@@ -452,7 +452,7 @@
 return getQualifierLoc().getBeginLoc();
   return getNameInfo().getLocStart();
 }
-SourceLocation DeclRefExpr::getLocEnd() const {
+SourceLocation DeclRefExpr::getEndLoc() const {
   if (hasExplicitTemplateArgs())
 return getRAngleLoc();
   return getNameInfo().getLocEnd();
@@ -1367,7 +1367,7 @@
 begin = getArg(0)->getLocStart();
   return begin;
 }
-SourceLocation CallExpr::getLocEnd() const {
+SourceLocation CallExpr::getEndLoc() const {
   if (isa(this))
 return cast(this)->getLocEnd();
 
@@ -1543,7 +1543,7 @@
 return BaseStartLoc;
   return MemberLoc;
 }
-SourceLocation MemberExpr::getLocEnd() const {
+SourceLocation MemberExpr::getEndLoc() const {
   SourceLocation EndLoc = getMemberNameInfo().getEndLoc();
   if (hasExplicitTemplateArgs())
 EndLoc = getRAngleLoc();

[PATCH] D50346: Add getBeginLoc API to replace getLocStart

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Accepted as part of a whole-branch review here: 
http://clang-developers.42468.n3.nabble.com/getLocStart-versus-getStartLoc-td4061010.html


Repository:
  rC Clang

https://reviews.llvm.org/D50346



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


[PATCH] D50347: Add getBeginLoc API to replace getStartLoc

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Accepted as part of a whole-branch review here: 
http://clang-developers.42468.n3.nabble.com/getLocStart-versus-getStartLoc-td4061010.html


Repository:
  rC Clang

https://reviews.llvm.org/D50347



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


[PATCH] D50348: :Add getEndLoc API to replace getLocEnd

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Accepted as part of a whole-branch review here: 
http://clang-developers.42468.n3.nabble.com/getLocStart-versus-getStartLoc-td4061010.html


Repository:
  rL LLVM

https://reviews.llvm.org/D50348



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


[PATCH] D50349: Port getStartLoc -> getBeginLoc

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire accepted this revision.
steveire added a comment.

Accepted as part of a whole-branch review here: 
http://clang-developers.42468.n3.nabble.com/getLocStart-versus-getStartLoc-td4061010.html


Repository:
  rC Clang

https://reviews.llvm.org/D50349



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


[PATCH] D50350: Port getLocStart -> getBeginLoc

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Accepted as part of a whole-branch review here: 
http://clang-developers.42468.n3.nabble.com/getLocStart-versus-getStartLoc-td4061010.html


Repository:
  rC Clang

https://reviews.llvm.org/D50350



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


[PATCH] D50351: Port getLocEnd -> getEndLoc

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire accepted this revision.
steveire added a comment.

Accepted as part of a whole-branch review here: 
http://clang-developers.42468.n3.nabble.com/getLocStart-versus-getStartLoc-td4061010.html


Repository:
  rC Clang

https://reviews.llvm.org/D50351



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


[PATCH] D50349: Port getStartLoc -> getBeginLoc

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339384: Port getStartLoc -> getBeginLoc (authored by 
steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50349?vs=159360&id=15#toc

Repository:
  rC Clang

https://reviews.llvm.org/D50349

Files:
  include/clang/AST/Decl.h
  lib/AST/ASTImporter.cpp
  lib/Analysis/CloneDetection.cpp
  lib/CodeGen/CoverageMappingGen.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

Index: include/clang/AST/Decl.h
===
--- include/clang/AST/Decl.h
+++ include/clang/AST/Decl.h
@@ -81,7 +81,7 @@
 /// A client can read the relevant info using TypeLoc wrappers, e.g:
 /// @code
 /// TypeLoc TL = TypeSourceInfo->getTypeLoc();
-/// TL.getStartLoc().print(OS, SrcMgr);
+/// TL.getBeginLoc().print(OS, SrcMgr);
 /// @endcode
 class alignas(8) TypeSourceInfo {
   // Contains a memory block after the class, used for type source information,
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -2066,7 +2066,7 @@
   assert(DS && "first part of for range not a decl stmt");
 
   if (!DS->isSingleDecl()) {
-Diag(DS->getStartLoc(), diag::err_type_defined_in_for_range);
+Diag(DS->getBeginLoc(), diag::err_type_defined_in_for_range);
 return StmtError();
   }
 
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6875,7 +6875,7 @@
   if (!getDerived().AlwaysRebuild() && !DeclChanged)
 return S;
 
-  return getDerived().RebuildDeclStmt(Decls, S->getStartLoc(), S->getEndLoc());
+  return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
 }
 
 template
Index: lib/Analysis/CloneDetection.cpp
===
--- lib/Analysis/CloneDetection.cpp
+++ lib/Analysis/CloneDetection.cpp
@@ -45,8 +45,8 @@
   // Otherwise check if the start and end locations of the current sequence
   // surround the other sequence.
   bool StartIsInBounds =
-  SM.isBeforeInTranslationUnit(getStartLoc(), Other.getStartLoc()) ||
-  getStartLoc() == Other.getStartLoc();
+  SM.isBeforeInTranslationUnit(getBeginLoc(), Other.getBeginLoc()) ||
+  getBeginLoc() == Other.getBeginLoc();
   if (!StartIsInBounds)
 return false;
 
@@ -84,7 +84,7 @@
 SourceLocation StmtSequence::getEndLoc() const { return back()->getLocEnd(); }
 
 SourceRange StmtSequence::getSourceRange() const {
-  return SourceRange(getStartLoc(), getEndLoc());
+  return SourceRange(getBeginLoc(), getEndLoc());
 }
 
 void CloneDetector::analyzeCodeBody(const Decl *D) {
@@ -433,7 +433,7 @@
 
   // Look up what macros expanded into the current statement.
   std::string MacroStack =
-  data_collection::getMacroStack(Seq.getStartLoc(), Context);
+  data_collection::getMacroStack(Seq.getBeginLoc(), Context);
 
   // First, check if ParentMacroStack is not empty which means we are currently
   // dealing with a parent statement which was expanded from a macro.
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -223,7 +223,7 @@
 
 void ASTStmtWriter::VisitDeclStmt(DeclStmt *S) {
   VisitStmt(S);
-  Record.AddSourceLocation(S->getStartLoc());
+  Record.AddSourceLocation(S->getBeginLoc());
   Record.AddSourceLocation(S->getEndLoc());
   DeclGroupRef DG = S->getDeclGroup();
   for (DeclGroupRef::iterator D = DG.begin(), DEnd = DG.end(); D != DEnd; ++D)
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -117,7 +117,7 @@
   }
 
   SpellingRegion(SourceManager &SM, SourceMappingRegion &R)
-  : SpellingRegion(SM, R.getStartLoc(), R.getEndLoc()) {}
+  : SpellingRegion(SM, R.getBeginLoc(), R.getEndLoc()) {}
 
   /// Check if the start and end locations appear in source order, i.e
   /// top->bottom, left->right.
@@ -230,7 +230,7 @@
 llvm::SmallSet Visited;
 SmallVector, 8> FileLocs;
 for (const auto &Region : SourceRegions) {
-  SourceLocation Loc = Region.getStartLoc();
+  SourceLocation Loc = Region.getBeginLoc();
   FileID File = SM.getFileID(Loc);
   if (!Visited.insert(File).second)
 continue;
@@ -312,7 +312,7 @@
 for (const auto &Region : SourceRegions) {
   assert(Region.hasEndLoc() && "incomplete region");
 
-  SourceLocation LocStart = Region.getStartLoc();
+  SourceLocation LocStart = Region.getBeginLoc();
   assert

[PATCH] D50350: Port getLocStart -> getBeginLoc

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339385: Port getLocStart -> getBeginLoc (authored by 
steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50350?vs=159361&id=160002#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50350

Files:
  cfe/trunk/docs/RAVFrontendAction.rst
  cfe/trunk/include/clang/AST/Comment.h
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/include/clang/AST/DeclObjC.h
  cfe/trunk/include/clang/AST/DeclarationName.h
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/include/clang/AST/ExprCXX.h
  cfe/trunk/include/clang/AST/ExprObjC.h
  cfe/trunk/include/clang/AST/ExprOpenMP.h
  cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h
  cfe/trunk/include/clang/AST/RawCommentList.h
  cfe/trunk/include/clang/AST/Stmt.h
  cfe/trunk/include/clang/AST/StmtCXX.h
  cfe/trunk/include/clang/AST/StmtDataCollectors.td
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/include/clang/Sema/Initialization.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
  cfe/trunk/lib/ARCMigrate/TransAPIUses.cpp
  cfe/trunk/lib/ARCMigrate/TransAutoreleasePool.cpp
  cfe/trunk/lib/ARCMigrate/TransGCCalls.cpp
  cfe/trunk/lib/ARCMigrate/TransProtectedScope.cpp
  cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
  cfe/trunk/lib/ARCMigrate/TransUnbridgedCasts.cpp
  cfe/trunk/lib/ARCMigrate/TransformActions.cpp
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/ASTDumper.cpp
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/lib/AST/DeclObjC.cpp
  cfe/trunk/lib/AST/DeclOpenMP.cpp
  cfe/trunk/lib/AST/DeclTemplate.cpp
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/ExprCXX.cpp
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/AST/RawCommentList.cpp
  cfe/trunk/lib/AST/SelectorLocationsKind.cpp
  cfe/trunk/lib/AST/Stmt.cpp
  cfe/trunk/lib/AST/StmtPrinter.cpp
  cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
  cfe/trunk/lib/Analysis/CloneDetection.cpp
  cfe/trunk/lib/Analysis/Consumed.cpp
  cfe/trunk/lib/Analysis/LiveVariables.cpp
  cfe/trunk/lib/Analysis/ReachableCode.cpp
  cfe/trunk/lib/Analysis/ThreadSafety.cpp
  cfe/trunk/lib/CodeGen/CGAtomic.cpp
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/CodeGen/CGClass.cpp
  cfe/trunk/lib/CodeGen/CGCoroutine.cpp
  cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
  cfe/trunk/lib/CodeGen/CGException.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprCXX.cpp
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/CodeGen/CGObjC.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/lib/CodeGen/CGStmt.cpp
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
  cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp
  cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
  cfe/trunk/lib/Index/IndexBody.cpp
  cfe/trunk/lib/Index/IndexDecl.cpp
  cfe/trunk/lib/Index/USRGeneration.cpp
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Parse/ParseExprCXX.cpp
  cfe/trunk/lib/Parse/ParseObjc.cpp
  cfe/trunk/lib/Parse/ParseStmt.cpp
  cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
  cfe/trunk/lib/Sema/JumpDiagnostics.cpp
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Sema/SemaAttr.cpp
  cfe/trunk/lib/Sema/SemaCast.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/lib/Sema/SemaCoroutine.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaDeclObjC.cpp
  cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/lib/Sema/SemaExprObjC.cpp
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/lib/Sema/SemaLambda.cpp
  cfe/trunk/lib/Sema/SemaLookup.cpp
  cfe/trunk/lib/Sema/SemaObjCProperty.cpp
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/lib/Sema/SemaPseudoObject.cpp
  cfe/trunk/lib/Sema/SemaStmt.cpp
  cfe/trunk/lib/Sema/SemaStmtAsm.cpp
  cfe/trunk/lib/Sema/SemaStmtAttr.cpp
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
  cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
  cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
  cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/lib/Serializatio

[PATCH] D50350: Port getLocStart -> getBeginLoc

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339385: Port getLocStart -> getBeginLoc (authored by 
steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50350?vs=159361&id=160001#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50350

Files:
  docs/RAVFrontendAction.rst
  include/clang/AST/Comment.h
  include/clang/AST/Decl.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclObjC.h
  include/clang/AST/DeclarationName.h
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/ExprOpenMP.h
  include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h
  include/clang/AST/RawCommentList.h
  include/clang/AST/Stmt.h
  include/clang/AST/StmtCXX.h
  include/clang/AST/StmtDataCollectors.td
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/Sema/Initialization.h
  include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  lib/ARCMigrate/ObjCMT.cpp
  lib/ARCMigrate/TransAPIUses.cpp
  lib/ARCMigrate/TransAutoreleasePool.cpp
  lib/ARCMigrate/TransGCCalls.cpp
  lib/ARCMigrate/TransProtectedScope.cpp
  lib/ARCMigrate/TransRetainReleaseDealloc.cpp
  lib/ARCMigrate/TransUnbridgedCasts.cpp
  lib/ARCMigrate/TransformActions.cpp
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ASTStructuralEquivalence.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclObjC.cpp
  lib/AST/DeclOpenMP.cpp
  lib/AST/DeclTemplate.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/RawCommentList.cpp
  lib/AST/SelectorLocationsKind.cpp
  lib/AST/Stmt.cpp
  lib/AST/StmtPrinter.cpp
  lib/Analysis/AnalysisDeclContext.cpp
  lib/Analysis/CloneDetection.cpp
  lib/Analysis/Consumed.cpp
  lib/Analysis/LiveVariables.cpp
  lib/Analysis/ReachableCode.cpp
  lib/Analysis/ThreadSafety.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGCoroutine.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenPGO.cpp
  lib/CodeGen/CoverageMappingGen.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Frontend/Rewrite/RewriteModernObjC.cpp
  lib/Frontend/Rewrite/RewriteObjC.cpp
  lib/Index/IndexBody.cpp
  lib/Index/IndexDecl.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseObjc.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/AnalysisBasedWarnings.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaAttr.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaObjCProperty.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaPseudoObject.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/SemaStmtAsm.cpp
  lib/Sema/SemaStmtAttr.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
  lib/StaticAnalyzer/Checkers/TraversalChecker.cpp
  lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Core/CheckerHelpers.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  lib/Tooling/Refactoring/Extract/Extract.cpp
  lib/Tooling/Refactoring/Rename/USRFinder.cpp
  lib/Tooling/Refactorin

[PATCH] D50354: Port getLocStart -> getBeginLoc

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Accepted as part of a whole-branch review here: 
http://clang-developers.42468.n3.nabble.com/getLocStart-versus-getStartLoc-td4061010.html


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50354



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


[PATCH] D50355: Port getLocEnd -> getEndLoc

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339401: Port getLocEnd -> getEndLoc (authored by 
steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50355?vs=159367&id=160025#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50355

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/CopyConstructorInitCheck.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/InaccurateEraseCheck.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/UnusedRaiiCheck.cpp
  clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/NoMallocCheck.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp
  clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
  clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/AvoidBindCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tools-extra/trunk/clang-tidy/performance/MoveConstArgCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp
  clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/DeleteNullPointerCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/MisleadingIndentationCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
  clang-tools-extra/trunk/unittests/clang-tidy/OverlappingReplacementsTest.cpp

Index: clang-tools-extra/trunk/unittests/clang-tidy/OverlappingReplacementsTest.cpp
===
--- clang-tools-extra/trunk/unittests/clang-tidy/OverlappingReplacementsTest.cpp
+++ clang-tools-extra/trunk/unittests/clang-tidy/OverlappingReplacementsTest.cpp
@@ -52,7 +52,7 @@
 auto *Cond = If->getCond();
 SourceRange Range = Cond->getSourceRange();
 if (auto *D = If->getConditionVariable()) {
-  Range = SourceRange(D->getBeginLoc(), D->getLocEnd());
+  Range = SourceRange(D->getBeginLoc(), D->getEndLoc());
 }
 diag(Range.getBegin(), "the cake is a lie") << FixItHint::CreateReplacement(
 CharSourceRange::getTokenRange(Range), "false");
Index: clang-tools-extra/trunk/clang-tidy/bugprone/CopyConstructorInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/CopyConstructorInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/CopyConstructorInitCheck.cpp
@@ -81,7 +81,7 @@
 if (CtorInitIsWritten) {
   if (!ParamName.empty())
 SafeFixIts.push_back(
-FixItHint::CreateInsertion(CExpr->getLocEnd(), ParamName));
+FixItHint::CreateInsertion(CExpr->getEndLoc(), ParamName));
 } else {
   if (Init->getSourceLocation().isMacroID() ||
   Ctor->getLocation().isMacroID() || ShouldNotDoFixit)
Index: cla

[PATCH] D50409: Remove obsolete set call

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339402: Remove obsolete set call (authored by steveire, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50409?vs=159602&id=160026#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50409

Files:
  lib/Sema/SemaDecl.cpp


Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -4949,7 +4949,6 @@
   case UnqualifiedIdKind::IK_ImplicitSelfParam:
   case UnqualifiedIdKind::IK_Identifier:
 NameInfo.setName(Name.Identifier);
-NameInfo.setLoc(Name.StartLocation);
 return NameInfo;
 
   case UnqualifiedIdKind::IK_DeductionGuideName: {
@@ -4976,14 +4975,12 @@
 
 NameInfo.setName(
 Context.DeclarationNames.getCXXDeductionGuideName(Template));
-NameInfo.setLoc(Name.StartLocation);
 return NameInfo;
   }
 
   case UnqualifiedIdKind::IK_OperatorFunctionId:
 NameInfo.setName(Context.DeclarationNames.getCXXOperatorName(
Name.OperatorFunctionId.Operator));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.getInfo().CXXOperatorName.BeginOpNameLoc
   = Name.OperatorFunctionId.SymbolLocations[0];
 NameInfo.getInfo().CXXOperatorName.EndOpNameLoc
@@ -4993,7 +4990,6 @@
   case UnqualifiedIdKind::IK_LiteralOperatorId:
 NameInfo.setName(Context.DeclarationNames.getCXXLiteralOperatorName(
Name.Identifier));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setCXXLiteralOperatorNameLoc(Name.EndLocation);
 return NameInfo;
 
@@ -5004,7 +5000,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXConversionFunctionName(
Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }
@@ -5016,7 +5011,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXConstructorName(
   Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }
@@ -5038,7 +5032,6 @@
 
 NameInfo.setName(Context.DeclarationNames.getCXXConstructorName(
 Context.getCanonicalType(CurClassType)));
-NameInfo.setLoc(Name.StartLocation);
 // FIXME: should we retrieve TypeSourceInfo?
 NameInfo.setNamedTypeInfo(nullptr);
 return NameInfo;
@@ -5051,7 +5044,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXDestructorName(
   Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }


Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -4949,7 +4949,6 @@
   case UnqualifiedIdKind::IK_ImplicitSelfParam:
   case UnqualifiedIdKind::IK_Identifier:
 NameInfo.setName(Name.Identifier);
-NameInfo.setLoc(Name.StartLocation);
 return NameInfo;
 
   case UnqualifiedIdKind::IK_DeductionGuideName: {
@@ -4976,14 +4975,12 @@
 
 NameInfo.setName(
 Context.DeclarationNames.getCXXDeductionGuideName(Template));
-NameInfo.setLoc(Name.StartLocation);
 return NameInfo;
   }
 
   case UnqualifiedIdKind::IK_OperatorFunctionId:
 NameInfo.setName(Context.DeclarationNames.getCXXOperatorName(
Name.OperatorFunctionId.Operator));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.getInfo().CXXOperatorName.BeginOpNameLoc
   = Name.OperatorFunctionId.SymbolLocations[0];
 NameInfo.getInfo().CXXOperatorName.EndOpNameLoc
@@ -4993,7 +4990,6 @@
   case UnqualifiedIdKind::IK_LiteralOperatorId:
 NameInfo.setName(Context.DeclarationNames.getCXXLiteralOperatorName(
Name.Identifier));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setCXXLiteralOperatorNameLoc(Name.EndLocation);
 return NameInfo;
 
@@ -5004,7 +5000,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXConversionFunctionName(
Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }
@@ -5016,7 +5011,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXConstructorName(
   Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }
@@ -5038

[PATCH] D50409: Remove obsolete set call

2018-08-09 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339402: Remove obsolete set call (authored by steveire, 
committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50409

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -4949,7 +4949,6 @@
   case UnqualifiedIdKind::IK_ImplicitSelfParam:
   case UnqualifiedIdKind::IK_Identifier:
 NameInfo.setName(Name.Identifier);
-NameInfo.setLoc(Name.StartLocation);
 return NameInfo;
 
   case UnqualifiedIdKind::IK_DeductionGuideName: {
@@ -4976,14 +4975,12 @@
 
 NameInfo.setName(
 Context.DeclarationNames.getCXXDeductionGuideName(Template));
-NameInfo.setLoc(Name.StartLocation);
 return NameInfo;
   }
 
   case UnqualifiedIdKind::IK_OperatorFunctionId:
 NameInfo.setName(Context.DeclarationNames.getCXXOperatorName(
Name.OperatorFunctionId.Operator));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.getInfo().CXXOperatorName.BeginOpNameLoc
   = Name.OperatorFunctionId.SymbolLocations[0];
 NameInfo.getInfo().CXXOperatorName.EndOpNameLoc
@@ -4993,7 +4990,6 @@
   case UnqualifiedIdKind::IK_LiteralOperatorId:
 NameInfo.setName(Context.DeclarationNames.getCXXLiteralOperatorName(
Name.Identifier));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setCXXLiteralOperatorNameLoc(Name.EndLocation);
 return NameInfo;
 
@@ -5004,7 +5000,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXConversionFunctionName(
Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }
@@ -5016,7 +5011,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXConstructorName(
   Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }
@@ -5038,7 +5032,6 @@
 
 NameInfo.setName(Context.DeclarationNames.getCXXConstructorName(
 Context.getCanonicalType(CurClassType)));
-NameInfo.setLoc(Name.StartLocation);
 // FIXME: should we retrieve TypeSourceInfo?
 NameInfo.setNamedTypeInfo(nullptr);
 return NameInfo;
@@ -5051,7 +5044,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXDestructorName(
   Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -4949,7 +4949,6 @@
   case UnqualifiedIdKind::IK_ImplicitSelfParam:
   case UnqualifiedIdKind::IK_Identifier:
 NameInfo.setName(Name.Identifier);
-NameInfo.setLoc(Name.StartLocation);
 return NameInfo;
 
   case UnqualifiedIdKind::IK_DeductionGuideName: {
@@ -4976,14 +4975,12 @@
 
 NameInfo.setName(
 Context.DeclarationNames.getCXXDeductionGuideName(Template));
-NameInfo.setLoc(Name.StartLocation);
 return NameInfo;
   }
 
   case UnqualifiedIdKind::IK_OperatorFunctionId:
 NameInfo.setName(Context.DeclarationNames.getCXXOperatorName(
Name.OperatorFunctionId.Operator));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.getInfo().CXXOperatorName.BeginOpNameLoc
   = Name.OperatorFunctionId.SymbolLocations[0];
 NameInfo.getInfo().CXXOperatorName.EndOpNameLoc
@@ -4993,7 +4990,6 @@
   case UnqualifiedIdKind::IK_LiteralOperatorId:
 NameInfo.setName(Context.DeclarationNames.getCXXLiteralOperatorName(
Name.Identifier));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setCXXLiteralOperatorNameLoc(Name.EndLocation);
 return NameInfo;
 
@@ -5004,7 +5000,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXConversionFunctionName(
Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }
@@ -5016,7 +5011,6 @@
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXConstructorName(
   Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 ret

[PATCH] D50661: Add a newline to SourceLocation dump output

2018-08-13 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a subscriber: cfe-commits.

Migrate callers to print().

dump() should be useful to downstreams and third parties as a debugging
aid.  Everyone trips up on this and creates confusing output.


Repository:
  rC Clang

https://reviews.llvm.org/D50661

Files:
  lib/ARCMigrate/TransGCAttrs.cpp
  lib/AST/CommentLexer.cpp
  lib/Analysis/LiveVariables.cpp
  lib/Basic/Diagnostic.cpp
  lib/Basic/SourceLocation.cpp
  lib/Lex/Preprocessor.cpp


Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -250,7 +250,7 @@
 }
 
 void Preprocessor::DumpLocation(SourceLocation Loc) const {
-  Loc.dump(SourceMgr);
+  Loc.print(llvm::errs(), SourceMgr);
 }
 
 void Preprocessor::DumpMacro(const MacroInfo &MI) const {
Index: lib/Basic/SourceLocation.cpp
===
--- lib/Basic/SourceLocation.cpp
+++ lib/Basic/SourceLocation.cpp
@@ -77,6 +77,7 @@
 
 LLVM_DUMP_METHOD void SourceLocation::dump(const SourceManager &SM) const {
   print(llvm::errs(), SM);
+  llvm::errs() << '\n';
 }
 
 
//===--===//
Index: lib/Basic/Diagnostic.cpp
===
--- lib/Basic/Diagnostic.cpp
+++ lib/Basic/Diagnostic.cpp
@@ -239,7 +239,7 @@
 void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr,
StringRef DiagName) const {
   llvm::errs() << "diagnostic state at ";
-  CurDiagStateLoc.dump(SrcMgr);
+  CurDiagStateLoc.print(llvm::errs(), SrcMgr);
   llvm::errs() << ": " << CurDiagState << "\n";
 
   for (auto &F : Files) {
@@ -261,7 +261,7 @@
  << Decomp.first.getHashValue() << "> ";
 SrcMgr.getLocForStartOfFile(Decomp.first)
   .getLocWithOffset(Decomp.second)
-  .dump(SrcMgr);
+  .print(llvm::errs(), SrcMgr);
   }
   if (File.HasLocalTransitions)
 llvm::errs() << " has_local_transitions";
@@ -281,7 +281,7 @@
 llvm::errs() << "  ";
 SrcMgr.getLocForStartOfFile(ID)
   .getLocWithOffset(Transition.Offset)
-  .dump(SrcMgr);
+  .print(llvm::errs(), SrcMgr);
 llvm::errs() << ": state " << Transition.State << ":\n";
   };
 
Index: lib/Analysis/LiveVariables.cpp
===
--- lib/Analysis/LiveVariables.cpp
+++ lib/Analysis/LiveVariables.cpp
@@ -626,7 +626,7 @@
  de = declVec.end(); di != de; ++di) {
   llvm::errs() << " " << (*di)->getDeclName().getAsString()
<< " <";
-  (*di)->getLocation().dump(M);
+  (*di)->getLocation().print(llvm::errs(), M);
   llvm::errs() << ">\n";
 }
   }
Index: lib/AST/CommentLexer.cpp
===
--- lib/AST/CommentLexer.cpp
+++ lib/AST/CommentLexer.cpp
@@ -21,7 +21,7 @@
 
 void Token::dump(const Lexer &L, const SourceManager &SM) const {
   llvm::errs() << "comments::Token Kind=" << Kind << " ";
-  Loc.dump(SM);
+  Loc.print(llvm::errs(), SM);
   llvm::errs() << " " << Length << " \"" << L.getSpelling(*this, SM) << "\"\n";
 }
 
Index: lib/ARCMigrate/TransGCAttrs.cpp
===
--- lib/ARCMigrate/TransGCAttrs.cpp
+++ lib/ARCMigrate/TransGCAttrs.cpp
@@ -340,7 +340,7 @@
 llvm::errs() << "KIND: "
 << (Attr.Kind == GCAttrOccurrence::Strong ? "strong" : "weak");
 llvm::errs() << "\nLOC: ";
-Attr.Loc.dump(Pass.Ctx.getSourceManager());
+Attr.Loc.print(llvm::errs(), Pass.Ctx.getSourceManager());
 llvm::errs() << "\nTYPE: ";
 Attr.ModifiedType.dump();
 if (Attr.Dcl) {


Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -250,7 +250,7 @@
 }
 
 void Preprocessor::DumpLocation(SourceLocation Loc) const {
-  Loc.dump(SourceMgr);
+  Loc.print(llvm::errs(), SourceMgr);
 }
 
 void Preprocessor::DumpMacro(const MacroInfo &MI) const {
Index: lib/Basic/SourceLocation.cpp
===
--- lib/Basic/SourceLocation.cpp
+++ lib/Basic/SourceLocation.cpp
@@ -77,6 +77,7 @@
 
 LLVM_DUMP_METHOD void SourceLocation::dump(const SourceManager &SM) const {
   print(llvm::errs(), SM);
+  llvm::errs() << '\n';
 }
 
 //===--===//
Index: lib/Basic/Diagnostic.cpp
===
--- lib/Basic/Diagnostic.cpp
+++ lib/Basic/Diagnostic.cpp
@@ -239,7 +239,7 @@
 void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr,
StringRef DiagName) const {
   llvm::errs() << "diagnostic 

[PATCH] D50662: Add dump() method for SourceRange

2018-08-13 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D50662

Files:
  include/clang/Basic/SourceLocation.h
  lib/Basic/SourceLocation.cpp


Index: lib/Basic/SourceLocation.cpp
===
--- lib/Basic/SourceLocation.cpp
+++ lib/Basic/SourceLocation.cpp
@@ -80,6 +80,14 @@
   llvm::errs() << '\n';
 }
 
+LLVM_DUMP_METHOD void SourceRange::dump(const SourceManager &SM) const {
+  llvm::errs() << '[';
+  B.print(llvm::errs(), SM);
+  llvm::errs() << ",\n ";
+  E.print(llvm::errs(), SM);
+  llvm::errs() << "]\n";
+}
+
 
//===--===//
 // FullSourceLoc
 
//===--===//
Index: include/clang/Basic/SourceLocation.h
===
--- include/clang/Basic/SourceLocation.h
+++ include/clang/Basic/SourceLocation.h
@@ -220,6 +220,8 @@
   bool operator!=(const SourceRange &X) const {
 return B != X.B || E != X.E;
   }
+
+  void dump(const SourceManager &SM) const;
 };
 
 /// Represents a character-granular source range.


Index: lib/Basic/SourceLocation.cpp
===
--- lib/Basic/SourceLocation.cpp
+++ lib/Basic/SourceLocation.cpp
@@ -80,6 +80,14 @@
   llvm::errs() << '\n';
 }
 
+LLVM_DUMP_METHOD void SourceRange::dump(const SourceManager &SM) const {
+  llvm::errs() << '[';
+  B.print(llvm::errs(), SM);
+  llvm::errs() << ",\n ";
+  E.print(llvm::errs(), SM);
+  llvm::errs() << "]\n";
+}
+
 //===--===//
 // FullSourceLoc
 //===--===//
Index: include/clang/Basic/SourceLocation.h
===
--- include/clang/Basic/SourceLocation.h
+++ include/clang/Basic/SourceLocation.h
@@ -220,6 +220,8 @@
   bool operator!=(const SourceRange &X) const {
 return B != X.B || E != X.E;
   }
+
+  void dump(const SourceManager &SM) const;
 };
 
 /// Represents a character-granular source range.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41217: [Concepts] Concept Specialization Expressions

2018-08-13 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: include/clang/AST/DeclTemplate.h:3063
   SourceRange getSourceRange() const override LLVM_READONLY {
-return SourceRange(getLocation(), getLocation());
+return SourceRange(getLocation(), getConstraintExpr()->getLocEnd());
   }

`getLocEnd` is deprecated and will be removed soon. See 
http://clang-developers.42468.n3.nabble.com/API-Removal-Notice-4-weeks-getStartLoc-getLocStart-getLocEnd-td4061566.html


Repository:
  rC Clang

https://reviews.llvm.org/D41217



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


[PATCH] D50666: Fix Stmt::ignoreImplicit

2018-08-13 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added reviewers: rsmith, dblaikie, klimek.
Herald added a subscriber: cfe-commits.

A CXXBindTemporaryExpr can appear inside an ImplicitCastExpr, and was
not ignored previously.

Fixes the case reported in PR37327.


Repository:
  rC Clang

https://reviews.llvm.org/D50666

Files:
  lib/AST/Stmt.cpp
  unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1302,6 +1302,45 @@
   varDecl(has(ignoringImplicit(cxxConstructExpr());
 }
 
+TEST(IgnoringImplicit, MatchesNestedImplicit) {
+  EXPECT_TRUE(matches(R"(
+
+struct OtherType;
+
+struct SomeType
+{
+SomeType() {}
+SomeType(const OtherType&) {}
+SomeType& operator=(OtherType const&) { return *this; }
+};
+
+struct OtherType
+{
+OtherType() {}
+~OtherType() {}
+};
+
+OtherType something()
+{
+return {};
+}
+
+int main()
+{
+SomeType i = something();
+}
+)"
+  , varDecl(
+  hasName("i"),
+  hasInitializer(exprWithCleanups(has(
+cxxConstructExpr(has(expr(ignoringImplicit(cxxConstructExpr(
+  has(expr(ignoringImplicit(callExpr(
+  )
+)))
+  )
+  ));
+}
+
 TEST(IgnoringImplicit, DoesNotMatchIncorrectly) {
   EXPECT_TRUE(
   notMatches("class C {}; C a = C();", varDecl(has(cxxConstructExpr();
Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -113,17 +113,23 @@
 Stmt *Stmt::IgnoreImplicit() {
   Stmt *s = this;
 
-  if (auto *ewc = dyn_cast(s))
-s = ewc->getSubExpr();
+  Stmt *lasts = nullptr;
 
-  if (auto *mte = dyn_cast(s))
-s = mte->GetTemporaryExpr();
+  while (s != lasts) {
+lasts = s;
 
-  if (auto *bte = dyn_cast(s))
-s = bte->getSubExpr();
+if (auto *ewc = dyn_cast(s))
+  s = ewc->getSubExpr();
 
-  while (auto *ice = dyn_cast(s))
-s = ice->getSubExpr();
+if (auto *mte = dyn_cast(s))
+  s = mte->GetTemporaryExpr();
+
+if (auto *bte = dyn_cast(s))
+  s = bte->getSubExpr();
+
+if (auto *ice = dyn_cast(s))
+  s = ice->getSubExpr();
+  }
 
   return s;
 }


Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1302,6 +1302,45 @@
   varDecl(has(ignoringImplicit(cxxConstructExpr());
 }
 
+TEST(IgnoringImplicit, MatchesNestedImplicit) {
+  EXPECT_TRUE(matches(R"(
+
+struct OtherType;
+
+struct SomeType
+{
+SomeType() {}
+SomeType(const OtherType&) {}
+SomeType& operator=(OtherType const&) { return *this; }
+};
+
+struct OtherType
+{
+OtherType() {}
+~OtherType() {}
+};
+
+OtherType something()
+{
+return {};
+}
+
+int main()
+{
+SomeType i = something();
+}
+)"
+  , varDecl(
+  hasName("i"),
+  hasInitializer(exprWithCleanups(has(
+cxxConstructExpr(has(expr(ignoringImplicit(cxxConstructExpr(
+  has(expr(ignoringImplicit(callExpr(
+  )
+)))
+  )
+  ));
+}
+
 TEST(IgnoringImplicit, DoesNotMatchIncorrectly) {
   EXPECT_TRUE(
   notMatches("class C {}; C a = C();", varDecl(has(cxxConstructExpr();
Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -113,17 +113,23 @@
 Stmt *Stmt::IgnoreImplicit() {
   Stmt *s = this;
 
-  if (auto *ewc = dyn_cast(s))
-s = ewc->getSubExpr();
+  Stmt *lasts = nullptr;
 
-  if (auto *mte = dyn_cast(s))
-s = mte->GetTemporaryExpr();
+  while (s != lasts) {
+lasts = s;
 
-  if (auto *bte = dyn_cast(s))
-s = bte->getSubExpr();
+if (auto *ewc = dyn_cast(s))
+  s = ewc->getSubExpr();
 
-  while (auto *ice = dyn_cast(s))
-s = ice->getSubExpr();
+if (auto *mte = dyn_cast(s))
+  s = mte->GetTemporaryExpr();
+
+if (auto *bte = dyn_cast(s))
+  s = bte->getSubExpr();
+
+if (auto *ice = dyn_cast(s))
+  s = ice->getSubExpr();
+  }
 
   return s;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50738: Remove vestiges of configure buildsystem

2018-08-14 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added subscribers: cfe-commits, mgorny.

Remove also the condition to allow in-source builds when using MSVC_IDE.
This may be vestigial and date from a time when llvm CMakeLists.txt had
a similar condition.  The llvm file does not have such a condition, so
this brings them in sync.


Repository:
  rC Clang

https://reviews.llvm.org/D50738

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -285,26 +285,14 @@
 set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
-if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
-  message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite 
"
-"the makefiles distributed with LLVM. Please create a directory and run cmake "
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
+  message(FATAL_ERROR "In-source builds are not allowed. "
+"Please create a directory and run cmake "
 "from there, passing the path to this source directory as the last argument. "
 "This process created the file `CMakeCache.txt' and the directory "
 "`CMakeFiles'. Please delete them.")
 endif()
 
-if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
-  file(GLOB_RECURSE
-tablegenned_files_on_include_dir
-"${CLANG_SOURCE_DIR}/include/clang/*.inc")
-  if( tablegenned_files_on_include_dir )
-message(FATAL_ERROR "Apparently there is a previous in-source build, "
-"probably as the result of running `configure' and `make' on "
-"${CLANG_SOURCE_DIR}. This may cause problems. The suspicious files are:\n"
-"${tablegenned_files_on_include_dir}\nPlease clean the source directory.")
-  endif()
-endif()
-
 # If CLANG_VERSION_* is specified, use it, if not use LLVM_VERSION_*.
 if(NOT DEFINED CLANG_VERSION_MAJOR)
   set(CLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -285,26 +285,14 @@
 set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
-if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
-  message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite "
-"the makefiles distributed with LLVM. Please create a directory and run cmake "
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
+  message(FATAL_ERROR "In-source builds are not allowed. "
+"Please create a directory and run cmake "
 "from there, passing the path to this source directory as the last argument. "
 "This process created the file `CMakeCache.txt' and the directory "
 "`CMakeFiles'. Please delete them.")
 endif()
 
-if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
-  file(GLOB_RECURSE
-tablegenned_files_on_include_dir
-"${CLANG_SOURCE_DIR}/include/clang/*.inc")
-  if( tablegenned_files_on_include_dir )
-message(FATAL_ERROR "Apparently there is a previous in-source build, "
-"probably as the result of running `configure' and `make' on "
-"${CLANG_SOURCE_DIR}. This may cause problems. The suspicious files are:\n"
-"${tablegenned_files_on_include_dir}\nPlease clean the source directory.")
-  endif()
-endif()
-
 # If CLANG_VERSION_* is specified, use it, if not use LLVM_VERSION_*.
 if(NOT DEFINED CLANG_VERSION_MAJOR)
   set(CLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50666: Fix Stmt::ignoreImplicit

2018-08-14 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339730: Fix Stmt::ignoreImplicit (authored by steveire, 
committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50666

Files:
  cfe/trunk/lib/AST/Stmt.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1321,6 +1321,45 @@
   varDecl(has(ignoringImplicit(cxxConstructExpr());
 }
 
+TEST(IgnoringImplicit, MatchesNestedImplicit) {
+  EXPECT_TRUE(matches(R"(
+
+struct OtherType;
+
+struct SomeType
+{
+SomeType() {}
+SomeType(const OtherType&) {}
+SomeType& operator=(OtherType const&) { return *this; }
+};
+
+struct OtherType
+{
+OtherType() {}
+~OtherType() {}
+};
+
+OtherType something()
+{
+return {};
+}
+
+int main()
+{
+SomeType i = something();
+}
+)"
+  , varDecl(
+  hasName("i"),
+  hasInitializer(exprWithCleanups(has(
+cxxConstructExpr(has(expr(ignoringImplicit(cxxConstructExpr(
+  has(expr(ignoringImplicit(callExpr(
+  )
+)))
+  )
+  ));
+}
+
 TEST(IgnoringImplicit, DoesNotMatchIncorrectly) {
   EXPECT_TRUE(
   notMatches("class C {}; C a = C();", varDecl(has(cxxConstructExpr();
Index: cfe/trunk/lib/AST/Stmt.cpp
===
--- cfe/trunk/lib/AST/Stmt.cpp
+++ cfe/trunk/lib/AST/Stmt.cpp
@@ -113,17 +113,23 @@
 Stmt *Stmt::IgnoreImplicit() {
   Stmt *s = this;
 
-  if (auto *ewc = dyn_cast(s))
-s = ewc->getSubExpr();
+  Stmt *lasts = nullptr;
 
-  if (auto *mte = dyn_cast(s))
-s = mte->GetTemporaryExpr();
+  while (s != lasts) {
+lasts = s;
 
-  if (auto *bte = dyn_cast(s))
-s = bte->getSubExpr();
+if (auto *ewc = dyn_cast(s))
+  s = ewc->getSubExpr();
 
-  while (auto *ice = dyn_cast(s))
-s = ice->getSubExpr();
+if (auto *mte = dyn_cast(s))
+  s = mte->GetTemporaryExpr();
+
+if (auto *bte = dyn_cast(s))
+  s = bte->getSubExpr();
+
+if (auto *ice = dyn_cast(s))
+  s = ice->getSubExpr();
+  }
 
   return s;
 }


Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1321,6 +1321,45 @@
   varDecl(has(ignoringImplicit(cxxConstructExpr());
 }
 
+TEST(IgnoringImplicit, MatchesNestedImplicit) {
+  EXPECT_TRUE(matches(R"(
+
+struct OtherType;
+
+struct SomeType
+{
+SomeType() {}
+SomeType(const OtherType&) {}
+SomeType& operator=(OtherType const&) { return *this; }
+};
+
+struct OtherType
+{
+OtherType() {}
+~OtherType() {}
+};
+
+OtherType something()
+{
+return {};
+}
+
+int main()
+{
+SomeType i = something();
+}
+)"
+  , varDecl(
+  hasName("i"),
+  hasInitializer(exprWithCleanups(has(
+cxxConstructExpr(has(expr(ignoringImplicit(cxxConstructExpr(
+  has(expr(ignoringImplicit(callExpr(
+  )
+)))
+  )
+  ));
+}
+
 TEST(IgnoringImplicit, DoesNotMatchIncorrectly) {
   EXPECT_TRUE(
   notMatches("class C {}; C a = C();", varDecl(has(cxxConstructExpr();
Index: cfe/trunk/lib/AST/Stmt.cpp
===
--- cfe/trunk/lib/AST/Stmt.cpp
+++ cfe/trunk/lib/AST/Stmt.cpp
@@ -113,17 +113,23 @@
 Stmt *Stmt::IgnoreImplicit() {
   Stmt *s = this;
 
-  if (auto *ewc = dyn_cast(s))
-s = ewc->getSubExpr();
+  Stmt *lasts = nullptr;
 
-  if (auto *mte = dyn_cast(s))
-s = mte->GetTemporaryExpr();
+  while (s != lasts) {
+lasts = s;
 
-  if (auto *bte = dyn_cast(s))
-s = bte->getSubExpr();
+if (auto *ewc = dyn_cast(s))
+  s = ewc->getSubExpr();
 
-  while (auto *ice = dyn_cast(s))
-s = ice->getSubExpr();
+if (auto *mte = dyn_cast(s))
+  s = mte->GetTemporaryExpr();
+
+if (auto *bte = dyn_cast(s))
+  s = bte->getSubExpr();
+
+if (auto *ice = dyn_cast(s))
+  s = ice->getSubExpr();
+  }
 
   return s;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50767: [C++2a] Parsing and semantic analysis for contracts (P0542R5)

2018-08-15 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: lib/Parse/ParseStmt.cpp:272
 bool HasLeadingEmptyMacro = Tok.hasLeadingEmptyMacro();
-return Actions.ActOnNullStmt(ConsumeToken(), HasLeadingEmptyMacro);
+SourceLocation SemiLoc = ConsumeToken();
+return Actions.ActOnNullStmt(SemiLoc, HasLeadingEmptyMacro,

Any reason to create the intermediate variable here, instead of leaving the 
`ConsumeToken()` call where it was?


Repository:
  rC Clang

https://reviews.llvm.org/D50767



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


[PATCH] D50764: [AST] Make NullStmt final and give it factory functions

2018-08-15 Thread Stephen Kelly via Phabricator via cfe-commits
steveire accepted this revision.
steveire added a comment.
This revision is now accepted and ready to land.

This looks like a NFC change.

Given that the next patch moves these methods out of line, you might consider 
introducing them out of line here (and moving the constructors out of line). 
That would make the next patch easier to review because the addition of 
assertion handling would be move visible.

LGTM, but I'm new here, so you may want to wait for another reviewer if you 
wish.


Repository:
  rC Clang

https://reviews.llvm.org/D50764



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


[PATCH] D50661: Add a newline to SourceLocation dump output

2018-08-15 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339810: Add a newline to SourceLocation dump output 
(authored by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50661

Files:
  cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
  cfe/trunk/lib/AST/CommentLexer.cpp
  cfe/trunk/lib/Analysis/LiveVariables.cpp
  cfe/trunk/lib/Basic/Diagnostic.cpp
  cfe/trunk/lib/Basic/SourceLocation.cpp
  cfe/trunk/lib/Lex/Preprocessor.cpp


Index: cfe/trunk/lib/Lex/Preprocessor.cpp
===
--- cfe/trunk/lib/Lex/Preprocessor.cpp
+++ cfe/trunk/lib/Lex/Preprocessor.cpp
@@ -250,7 +250,7 @@
 }
 
 void Preprocessor::DumpLocation(SourceLocation Loc) const {
-  Loc.dump(SourceMgr);
+  Loc.print(llvm::errs(), SourceMgr);
 }
 
 void Preprocessor::DumpMacro(const MacroInfo &MI) const {
Index: cfe/trunk/lib/AST/CommentLexer.cpp
===
--- cfe/trunk/lib/AST/CommentLexer.cpp
+++ cfe/trunk/lib/AST/CommentLexer.cpp
@@ -21,7 +21,7 @@
 
 void Token::dump(const Lexer &L, const SourceManager &SM) const {
   llvm::errs() << "comments::Token Kind=" << Kind << " ";
-  Loc.dump(SM);
+  Loc.print(llvm::errs(), SM);
   llvm::errs() << " " << Length << " \"" << L.getSpelling(*this, SM) << "\"\n";
 }
 
Index: cfe/trunk/lib/Analysis/LiveVariables.cpp
===
--- cfe/trunk/lib/Analysis/LiveVariables.cpp
+++ cfe/trunk/lib/Analysis/LiveVariables.cpp
@@ -626,7 +626,7 @@
  de = declVec.end(); di != de; ++di) {
   llvm::errs() << " " << (*di)->getDeclName().getAsString()
<< " <";
-  (*di)->getLocation().dump(M);
+  (*di)->getLocation().print(llvm::errs(), M);
   llvm::errs() << ">\n";
 }
   }
Index: cfe/trunk/lib/Basic/SourceLocation.cpp
===
--- cfe/trunk/lib/Basic/SourceLocation.cpp
+++ cfe/trunk/lib/Basic/SourceLocation.cpp
@@ -77,6 +77,7 @@
 
 LLVM_DUMP_METHOD void SourceLocation::dump(const SourceManager &SM) const {
   print(llvm::errs(), SM);
+  llvm::errs() << '\n';
 }
 
 
//===--===//
Index: cfe/trunk/lib/Basic/Diagnostic.cpp
===
--- cfe/trunk/lib/Basic/Diagnostic.cpp
+++ cfe/trunk/lib/Basic/Diagnostic.cpp
@@ -239,7 +239,7 @@
 void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr,
StringRef DiagName) const {
   llvm::errs() << "diagnostic state at ";
-  CurDiagStateLoc.dump(SrcMgr);
+  CurDiagStateLoc.print(llvm::errs(), SrcMgr);
   llvm::errs() << ": " << CurDiagState << "\n";
 
   for (auto &F : Files) {
@@ -261,7 +261,7 @@
  << Decomp.first.getHashValue() << "> ";
 SrcMgr.getLocForStartOfFile(Decomp.first)
   .getLocWithOffset(Decomp.second)
-  .dump(SrcMgr);
+  .print(llvm::errs(), SrcMgr);
   }
   if (File.HasLocalTransitions)
 llvm::errs() << " has_local_transitions";
@@ -281,7 +281,7 @@
 llvm::errs() << "  ";
 SrcMgr.getLocForStartOfFile(ID)
   .getLocWithOffset(Transition.Offset)
-  .dump(SrcMgr);
+  .print(llvm::errs(), SrcMgr);
 llvm::errs() << ": state " << Transition.State << ":\n";
   };
 
Index: cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
===
--- cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
+++ cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
@@ -340,7 +340,7 @@
 llvm::errs() << "KIND: "
 << (Attr.Kind == GCAttrOccurrence::Strong ? "strong" : "weak");
 llvm::errs() << "\nLOC: ";
-Attr.Loc.dump(Pass.Ctx.getSourceManager());
+Attr.Loc.print(llvm::errs(), Pass.Ctx.getSourceManager());
 llvm::errs() << "\nTYPE: ";
 Attr.ModifiedType.dump();
 if (Attr.Dcl) {


Index: cfe/trunk/lib/Lex/Preprocessor.cpp
===
--- cfe/trunk/lib/Lex/Preprocessor.cpp
+++ cfe/trunk/lib/Lex/Preprocessor.cpp
@@ -250,7 +250,7 @@
 }
 
 void Preprocessor::DumpLocation(SourceLocation Loc) const {
-  Loc.dump(SourceMgr);
+  Loc.print(llvm::errs(), SourceMgr);
 }
 
 void Preprocessor::DumpMacro(const MacroInfo &MI) const {
Index: cfe/trunk/lib/AST/CommentLexer.cpp
===
--- cfe/trunk/lib/AST/CommentLexer.cpp
+++ cfe/trunk/lib/AST/CommentLexer.cpp
@@ -21,7 +21,7 @@
 
 void Token::dump(const Lexer &L, const SourceManager &SM) const {
   llvm::errs() << "comments::Token Kind=" << Kind << " ";
-  Loc.dump(SM);
+  Loc.print(llvm::errs(), SM);
   llvm::errs() << " " << Length << " \"" << L.getSpelling(*this, SM) << "\"\n";
 }
 
Index: cfe/trunk/lib/Analysi

[PATCH] D50662: Add dump() method for SourceRange

2018-08-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 161570.
steveire added a comment.

Add dump() and supporting methods to SourceRange


Repository:
  rC Clang

https://reviews.llvm.org/D50662

Files:
  include/clang/Basic/SourceLocation.h
  lib/Basic/SourceLocation.cpp


Index: lib/Basic/SourceLocation.cpp
===
--- lib/Basic/SourceLocation.cpp
+++ lib/Basic/SourceLocation.cpp
@@ -80,6 +80,26 @@
   llvm::errs() << '\n';
 }
 
+LLVM_DUMP_METHOD void SourceRange::dump(const SourceManager &SM) const {
+  print(llvm::errs(), SM);
+}
+
+void SourceRange::print(raw_ostream &OS, const SourceManager &SM) const {
+  OS << '[';
+  B.print(OS, SM);
+  OS << ",\n ";
+  E.print(OS, SM);
+  OS << "]\n";
+}
+
+LLVM_DUMP_METHOD std::string
+SourceRange::printToString(const SourceManager &SM) const {
+  std::string S;
+  llvm::raw_string_ostream OS(S);
+  print(OS, SM);
+  return OS.str();
+}
+
 
//===--===//
 // FullSourceLoc
 
//===--===//
Index: include/clang/Basic/SourceLocation.h
===
--- include/clang/Basic/SourceLocation.h
+++ include/clang/Basic/SourceLocation.h
@@ -220,6 +220,10 @@
   bool operator!=(const SourceRange &X) const {
 return B != X.B || E != X.E;
   }
+
+  void print(raw_ostream &OS, const SourceManager &SM) const;
+  std::string printToString(const SourceManager &SM) const;
+  void dump(const SourceManager &SM) const;
 };
 
 /// Represents a character-granular source range.


Index: lib/Basic/SourceLocation.cpp
===
--- lib/Basic/SourceLocation.cpp
+++ lib/Basic/SourceLocation.cpp
@@ -80,6 +80,26 @@
   llvm::errs() << '\n';
 }
 
+LLVM_DUMP_METHOD void SourceRange::dump(const SourceManager &SM) const {
+  print(llvm::errs(), SM);
+}
+
+void SourceRange::print(raw_ostream &OS, const SourceManager &SM) const {
+  OS << '[';
+  B.print(OS, SM);
+  OS << ",\n ";
+  E.print(OS, SM);
+  OS << "]\n";
+}
+
+LLVM_DUMP_METHOD std::string
+SourceRange::printToString(const SourceManager &SM) const {
+  std::string S;
+  llvm::raw_string_ostream OS(S);
+  print(OS, SM);
+  return OS.str();
+}
+
 //===--===//
 // FullSourceLoc
 //===--===//
Index: include/clang/Basic/SourceLocation.h
===
--- include/clang/Basic/SourceLocation.h
+++ include/clang/Basic/SourceLocation.h
@@ -220,6 +220,10 @@
   bool operator!=(const SourceRange &X) const {
 return B != X.B || E != X.E;
   }
+
+  void print(raw_ostream &OS, const SourceManager &SM) const;
+  std::string printToString(const SourceManager &SM) const;
+  void dump(const SourceManager &SM) const;
 };
 
 /// Represents a character-granular source range.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50662: Add dump() method for SourceRange

2018-08-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Thanks, I've done that now.


Repository:
  rC Clang

https://reviews.llvm.org/D50662



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


[PATCH] D51069: Notify pending API removal in the release notes

2018-08-21 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D51069

Files:
  ReleaseNotes.rst


Index: ReleaseNotes.rst
===
--- ReleaseNotes.rst
+++ ReleaseNotes.rst
@@ -265,7 +265,10 @@
 Clang. If upgrading an external codebase that uses Clang as a library,
 this section should help get you past the largest hurdles of upgrading.
 
--  ...
+- The methods ``getLocStart``, ``getStartLoc`` and ``getLocEnd`` in the AST 
+  classes are deprecated.  New APIs ``getBeginLoc`` and ``getEndLoc`` should 
+  be used instead.  While the old methods remain in this release, they will 
+  not be present in the next release of Clang.
 
 AST Matchers
 


Index: ReleaseNotes.rst
===
--- ReleaseNotes.rst
+++ ReleaseNotes.rst
@@ -265,7 +265,10 @@
 Clang. If upgrading an external codebase that uses Clang as a library,
 this section should help get you past the largest hurdles of upgrading.
 
--  ...
+- The methods ``getLocStart``, ``getStartLoc`` and ``getLocEnd`` in the AST 
+  classes are deprecated.  New APIs ``getBeginLoc`` and ``getEndLoc`` should 
+  be used instead.  While the old methods remain in this release, they will 
+  not be present in the next release of Clang.
 
 AST Matchers
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51079: Update the docs for using LLVM toolset in Visual Studio

2018-08-21 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: hans.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D51079

Files:
  docs/UsersManual.rst


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -2711,25 +2711,26 @@
 up using e.g. `vcvarsall.bat 
`_.
 
 clang-cl can also be used from inside Visual Studio by selecting the LLVM
-Platform Toolset. The toolset is installed by the LLVM installer, which can be
-downloaded from the `LLVM release `_ or
-`snapshot build `_ web pages. To use the toolset,
-select a project in Solution Explorer, open its Property Page (Alt+F7), and in
-the "General" section of "Configuration Properties" change "Platform Toolset"
-to e.g. LLVM-vs2014.
+Platform Toolset. The toolset is not part of the installer, but may be 
installed
+separately from the
+`Visual Studio Marketplace 
`_.
+To use the toolset, select a project in Solution Explorer, open its Property
+Page (Alt+F7), and in the "General" section of "Configuration Properties"
+change "Platform Toolset" to LLVM.  Doing so enables an additional Property
+Page for selecting the clang-cl executable to use for builds.
 
 To use the toolset with MSBuild directly, invoke it with e.g.
-``/p:PlatformToolset=LLVM-vs2014``. This allows trying out the clang-cl
-toolchain without modifying your project files.
+``/p:PlatformToolset=LLVM``. This allows trying out the clang-cl toolchain
+without modifying your project files.
 
 It's also possible to point MSBuild at clang-cl without changing toolset by
 passing ``/p:CLToolPath=c:\llvm\bin /p:CLToolExe=clang-cl.exe``.
 
 When using CMake and the Visual Studio generators, the toolset can be set with 
the ``-T`` flag:
 
   ::
 
-cmake -G"Visual Studio 15 2017" -T LLVM-vs2014 ..
+cmake -G"Visual Studio 15 2017" -T LLVM ..
 
 When using CMake with the Ninja generator, set the ``CMAKE_C_COMPILER`` and
 ``CMAKE_CXX_COMPILER`` variables to clang-cl:


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -2711,25 +2711,26 @@
 up using e.g. `vcvarsall.bat `_.
 
 clang-cl can also be used from inside Visual Studio by selecting the LLVM
-Platform Toolset. The toolset is installed by the LLVM installer, which can be
-downloaded from the `LLVM release `_ or
-`snapshot build `_ web pages. To use the toolset,
-select a project in Solution Explorer, open its Property Page (Alt+F7), and in
-the "General" section of "Configuration Properties" change "Platform Toolset"
-to e.g. LLVM-vs2014.
+Platform Toolset. The toolset is not part of the installer, but may be installed
+separately from the
+`Visual Studio Marketplace `_.
+To use the toolset, select a project in Solution Explorer, open its Property
+Page (Alt+F7), and in the "General" section of "Configuration Properties"
+change "Platform Toolset" to LLVM.  Doing so enables an additional Property
+Page for selecting the clang-cl executable to use for builds.
 
 To use the toolset with MSBuild directly, invoke it with e.g.
-``/p:PlatformToolset=LLVM-vs2014``. This allows trying out the clang-cl
-toolchain without modifying your project files.
+``/p:PlatformToolset=LLVM``. This allows trying out the clang-cl toolchain
+without modifying your project files.
 
 It's also possible to point MSBuild at clang-cl without changing toolset by
 passing ``/p:CLToolPath=c:\llvm\bin /p:CLToolExe=clang-cl.exe``.
 
 When using CMake and the Visual Studio generators, the toolset can be set with the ``-T`` flag:
 
   ::
 
-cmake -G"Visual Studio 15 2017" -T LLVM-vs2014 ..
+cmake -G"Visual Studio 15 2017" -T LLVM ..
 
 When using CMake with the Ninja generator, set the ``CMAKE_C_COMPILER`` and
 ``CMAKE_CXX_COMPILER`` variables to clang-cl:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51069: Notify pending API removal in the release notes

2018-08-21 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

@hans Could you commit this on my behalf? I was not able to do it myself for 
some reason.

$ svn commit 
svn: E175002: Commit failed (details follow):
svn: E175002: Unexpected HTTP status 400 'Bad Request' on 
'/svn/llvm-project/!svn/act/2ca88059-6dd7-44fe-aa3e-9fc9f021f0bb'


Repository:
  rC Clang

https://reviews.llvm.org/D51069



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


[PATCH] D51079: Update the docs for using LLVM toolset in Visual Studio

2018-08-21 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

@hans Consider backporting this.


Repository:
  rC Clang

https://reviews.llvm.org/D51079



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


[PATCH] D51079: Update the docs for using LLVM toolset in Visual Studio

2018-08-21 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340376: Update the docs for using LLVM toolset in Visual 
Studio (authored by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51079?vs=161863&id=161870#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51079

Files:
  cfe/trunk/docs/UsersManual.rst


Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -2711,25 +2711,26 @@
 up using e.g. `vcvarsall.bat 
`_.
 
 clang-cl can also be used from inside Visual Studio by selecting the LLVM
-Platform Toolset. The toolset is installed by the LLVM installer, which can be
-downloaded from the `LLVM release `_ or
-`snapshot build `_ web pages. To use the toolset,
-select a project in Solution Explorer, open its Property Page (Alt+F7), and in
-the "General" section of "Configuration Properties" change "Platform Toolset"
-to e.g. LLVM-vs2014.
+Platform Toolset. The toolset is not part of the installer, but may be 
installed
+separately from the
+`Visual Studio Marketplace 
`_.
+To use the toolset, select a project in Solution Explorer, open its Property
+Page (Alt+F7), and in the "General" section of "Configuration Properties"
+change "Platform Toolset" to LLVM.  Doing so enables an additional Property
+Page for selecting the clang-cl executable to use for builds.
 
 To use the toolset with MSBuild directly, invoke it with e.g.
-``/p:PlatformToolset=LLVM-vs2014``. This allows trying out the clang-cl
-toolchain without modifying your project files.
+``/p:PlatformToolset=LLVM``. This allows trying out the clang-cl toolchain
+without modifying your project files.
 
 It's also possible to point MSBuild at clang-cl without changing toolset by
 passing ``/p:CLToolPath=c:\llvm\bin /p:CLToolExe=clang-cl.exe``.
 
 When using CMake and the Visual Studio generators, the toolset can be set with 
the ``-T`` flag:
 
   ::
 
-cmake -G"Visual Studio 15 2017" -T LLVM-vs2014 ..
+cmake -G"Visual Studio 15 2017" -T LLVM ..
 
 When using CMake with the Ninja generator, set the ``CMAKE_C_COMPILER`` and
 ``CMAKE_CXX_COMPILER`` variables to clang-cl:


Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -2711,25 +2711,26 @@
 up using e.g. `vcvarsall.bat `_.
 
 clang-cl can also be used from inside Visual Studio by selecting the LLVM
-Platform Toolset. The toolset is installed by the LLVM installer, which can be
-downloaded from the `LLVM release `_ or
-`snapshot build `_ web pages. To use the toolset,
-select a project in Solution Explorer, open its Property Page (Alt+F7), and in
-the "General" section of "Configuration Properties" change "Platform Toolset"
-to e.g. LLVM-vs2014.
+Platform Toolset. The toolset is not part of the installer, but may be installed
+separately from the
+`Visual Studio Marketplace `_.
+To use the toolset, select a project in Solution Explorer, open its Property
+Page (Alt+F7), and in the "General" section of "Configuration Properties"
+change "Platform Toolset" to LLVM.  Doing so enables an additional Property
+Page for selecting the clang-cl executable to use for builds.
 
 To use the toolset with MSBuild directly, invoke it with e.g.
-``/p:PlatformToolset=LLVM-vs2014``. This allows trying out the clang-cl
-toolchain without modifying your project files.
+``/p:PlatformToolset=LLVM``. This allows trying out the clang-cl toolchain
+without modifying your project files.
 
 It's also possible to point MSBuild at clang-cl without changing toolset by
 passing ``/p:CLToolPath=c:\llvm\bin /p:CLToolExe=clang-cl.exe``.
 
 When using CMake and the Visual Studio generators, the toolset can be set with the ``-T`` flag:
 
   ::
 
-cmake -G"Visual Studio 15 2017" -T LLVM-vs2014 ..
+cmake -G"Visual Studio 15 2017" -T LLVM ..
 
 When using CMake with the Ninja generator, set the ``CMAKE_C_COMPILER`` and
 ``CMAKE_CXX_COMPILER`` variables to clang-cl:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50662: Add dump() method for SourceRange

2018-08-23 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 162280.
steveire added a comment.

Add dump() and supporting methods to SourceRange


Repository:
  rC Clang

https://reviews.llvm.org/D50662

Files:
  include/clang/Basic/SourceLocation.h
  lib/Basic/SourceLocation.cpp
  unittests/Basic/SourceManagerTest.cpp

Index: unittests/Basic/SourceManagerTest.cpp
===
--- unittests/Basic/SourceManagerTest.cpp
+++ unittests/Basic/SourceManagerTest.cpp
@@ -155,6 +155,53 @@
   EXPECT_EQ(1U, SourceMgr.getColumnNumber(MainFileID, 0, nullptr));
 }
 
+TEST_F(SourceManagerTest, locationPrintTest) {
+  const char *header =
+"#define IDENTITY(x) x\n";
+
+  const char *Source =
+"int x;\n"
+"include \"test-header.h\"\n"
+"IDENTITY(int y);\n"
+"int z;";
+
+  std::unique_ptr HeaderBuf =
+  llvm::MemoryBuffer::getMemBuffer(header);
+  std::unique_ptr Buf =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+
+  const FileEntry *sourceFile = FileMgr.getVirtualFile("/mainFile.cpp",
+ Buf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(sourceFile, std::move(Buf));
+
+
+  const FileEntry *headerFile = FileMgr.getVirtualFile("/test-header.h",
+ HeaderBuf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(headerFile, std::move(HeaderBuf));
+
+  FileID MainFileID = SourceMgr.getOrCreateFileID(sourceFile, SrcMgr::C_User);
+  SourceMgr.setMainFileID(MainFileID);
+
+  auto beginLoc = SourceMgr.getLocForStartOfFile(MainFileID);
+  auto endLoc = SourceMgr.getLocForEndOfFile(MainFileID);
+
+  auto beginEOLLoc = SourceMgr.translateLineCol(MainFileID, 1, 7);
+
+  // TODO: How do I get a loc in another file?
+  auto headerLoc = SourceMgr.getSpellingLoc(SourceMgr.translateLineCol(MainFileID, 3, 5));
+
+  EXPECT_EQ(beginLoc.printToString(SourceMgr), "/mainFile.cpp:1:1");
+  EXPECT_EQ(endLoc.printToString(SourceMgr), "/mainFile.cpp:4:7");
+
+  EXPECT_EQ(beginEOLLoc.printToString(SourceMgr), "/mainFile.cpp:1:7");
+  EXPECT_EQ(headerLoc.printToString(SourceMgr), "TODO");
+
+  EXPECT_EQ(SourceRange(beginLoc, beginLoc).printToString(SourceMgr), "");
+  EXPECT_EQ(SourceRange(beginLoc, beginEOLLoc).printToString(SourceMgr), "");
+  EXPECT_EQ(SourceRange(beginLoc, endLoc).printToString(SourceMgr), "");
+  EXPECT_EQ(SourceRange(beginLoc, headerLoc).printToString(SourceMgr), "");
+}
+
 #if defined(LLVM_ON_UNIX)
 
 TEST_F(SourceManagerTest, getMacroArgExpandedLocation) {
Index: lib/Basic/SourceLocation.cpp
===
--- lib/Basic/SourceLocation.cpp
+++ lib/Basic/SourceLocation.cpp
@@ -80,6 +80,60 @@
   llvm::errs() << '\n';
 }
 
+LLVM_DUMP_METHOD void SourceRange::dump(const SourceManager &SM) const {
+  print(llvm::errs(), SM);
+  llvm::errs() << '\n';
+}
+
+static PresumedLoc printDifference(raw_ostream &OS, const SourceManager &SM, SourceLocation Loc, PresumedLoc Previous)
+{
+  if (Loc.isFileID()) {
+
+PresumedLoc PLoc = SM.getPresumedLoc(Loc);
+
+if (PLoc.isInvalid()) {
+  OS << "";
+  return Previous;
+}
+
+if (Previous.isInvalid() || strcmp(PLoc.getFilename(), Previous.getFilename()) != 0) {
+  OS << PLoc.getFilename() << ':' << PLoc.getLine()
+ << ':' << PLoc.getColumn();
+} else if (Previous.isInvalid() || PLoc.getLine() != Previous.getLine()) {
+  OS << "line" << ':' << PLoc.getLine()
+ << ':' << PLoc.getColumn();
+} else {
+  OS << "col" << ':' << PLoc.getColumn();
+}
+return PLoc;
+  }
+  auto printedLoc = printDifference(OS, SM, SM.getExpansionLoc(Loc), Previous);
+
+  OS << " ';
+  return printedLoc;
+}
+
+void SourceRange::print(raw_ostream &OS, const SourceManager &SM) const {
+
+  OS << '<';
+  auto printedLoc = printDifference(OS, SM, B, {});
+  if (B != E) {
+OS << ", ";
+printDifference(OS, SM, E, printedLoc);
+  }
+  OS << '>';
+}
+
+LLVM_DUMP_METHOD std::string
+SourceRange::printToString(const SourceManager &SM) const {
+  std::string S;
+  llvm::raw_string_ostream OS(S);
+  print(OS, SM);
+  return OS.str();
+}
+
 //===--===//
 // FullSourceLoc
 //===--===//
Index: include/clang/Basic/SourceLocation.h
===
--- include/clang/Basic/SourceLocation.h
+++ include/clang/Basic/SourceLocation.h
@@ -220,6 +220,10 @@
   bool operator!=(const SourceRange &X) const {
 return B != X.B || E != X.E;
   }
+
+  void print(raw_ostream &OS, const SourceManager &SM) const;
+  std::string printToString(const SourceManager &SM) const;
+  void dump(const SourceManager &SM) const;
 };
 
 /// Represents a character-granular source range.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.

[PATCH] D50662: Add dump() method for SourceRange

2018-08-23 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 162282.
steveire marked 3 inline comments as done.
steveire added a comment.

Add dump() and supporting methods to SourceRange


Repository:
  rC Clang

https://reviews.llvm.org/D50662

Files:
  include/clang/Basic/SourceLocation.h
  lib/Basic/SourceLocation.cpp
  unittests/Basic/SourceManagerTest.cpp

Index: unittests/Basic/SourceManagerTest.cpp
===
--- unittests/Basic/SourceManagerTest.cpp
+++ unittests/Basic/SourceManagerTest.cpp
@@ -155,6 +155,52 @@
   EXPECT_EQ(1U, SourceMgr.getColumnNumber(MainFileID, 0, nullptr));
 }
 
+TEST_F(SourceManagerTest, locationPrintTest) {
+  const char *header =
+"#define IDENTITY(x) x\n";
+
+  const char *Source =
+"int x;\n"
+"include \"test-header.h\"\n"
+"IDENTITY(int y);\n"
+"int z;";
+
+  std::unique_ptr HeaderBuf =
+  llvm::MemoryBuffer::getMemBuffer(header);
+  std::unique_ptr Buf =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+
+  const FileEntry *sourceFile = FileMgr.getVirtualFile("/mainFile.cpp",
+ Buf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(sourceFile, std::move(Buf));
+
+  const FileEntry *headerFile = FileMgr.getVirtualFile("/test-header.h",
+ HeaderBuf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(headerFile, std::move(HeaderBuf));
+
+  FileID MainFileID = SourceMgr.getOrCreateFileID(sourceFile, SrcMgr::C_User);
+  SourceMgr.setMainFileID(MainFileID);
+
+  auto beginLoc = SourceMgr.getLocForStartOfFile(MainFileID);
+  auto endLoc = SourceMgr.getLocForEndOfFile(MainFileID);
+
+  auto beginEOLLoc = SourceMgr.translateLineCol(MainFileID, 1, 7);
+
+  // TODO: How do I get a loc in another file?
+  auto headerLoc = SourceMgr.getSpellingLoc(SourceMgr.translateLineCol(MainFileID, 3, 5));
+
+  EXPECT_EQ(beginLoc.printToString(SourceMgr), "/mainFile.cpp:1:1");
+  EXPECT_EQ(endLoc.printToString(SourceMgr), "/mainFile.cpp:4:7");
+
+  EXPECT_EQ(beginEOLLoc.printToString(SourceMgr), "/mainFile.cpp:1:7");
+  EXPECT_EQ(headerLoc.printToString(SourceMgr), "TODO");
+
+  EXPECT_EQ(SourceRange(beginLoc, beginLoc).printToString(SourceMgr), "");
+  EXPECT_EQ(SourceRange(beginLoc, beginEOLLoc).printToString(SourceMgr), "");
+  EXPECT_EQ(SourceRange(beginLoc, endLoc).printToString(SourceMgr), "");
+  EXPECT_EQ(SourceRange(beginLoc, headerLoc).printToString(SourceMgr), "");
+}
+
 #if defined(LLVM_ON_UNIX)
 
 TEST_F(SourceManagerTest, getMacroArgExpandedLocation) {
Index: lib/Basic/SourceLocation.cpp
===
--- lib/Basic/SourceLocation.cpp
+++ lib/Basic/SourceLocation.cpp
@@ -80,6 +80,60 @@
   llvm::errs() << '\n';
 }
 
+LLVM_DUMP_METHOD void SourceRange::dump(const SourceManager &SM) const {
+  print(llvm::errs(), SM);
+  llvm::errs() << '\n';
+}
+
+static PresumedLoc printDifference(raw_ostream &OS, const SourceManager &SM, SourceLocation Loc, PresumedLoc Previous)
+{
+  if (Loc.isFileID()) {
+
+PresumedLoc PLoc = SM.getPresumedLoc(Loc);
+
+if (PLoc.isInvalid()) {
+  OS << "";
+  return Previous;
+}
+
+if (Previous.isInvalid() || strcmp(PLoc.getFilename(), Previous.getFilename()) != 0) {
+  OS << PLoc.getFilename() << ':' << PLoc.getLine()
+ << ':' << PLoc.getColumn();
+} else if (Previous.isInvalid() || PLoc.getLine() != Previous.getLine()) {
+  OS << "line" << ':' << PLoc.getLine()
+ << ':' << PLoc.getColumn();
+} else {
+  OS << "col" << ':' << PLoc.getColumn();
+}
+return PLoc;
+  }
+  auto printedLoc = printDifference(OS, SM, SM.getExpansionLoc(Loc), Previous);
+
+  OS << " ';
+  return printedLoc;
+}
+
+void SourceRange::print(raw_ostream &OS, const SourceManager &SM) const {
+
+  OS << '<';
+  auto printedLoc = printDifference(OS, SM, B, {});
+  if (B != E) {
+OS << ", ";
+printDifference(OS, SM, E, printedLoc);
+  }
+  OS << '>';
+}
+
+LLVM_DUMP_METHOD std::string
+SourceRange::printToString(const SourceManager &SM) const {
+  std::string S;
+  llvm::raw_string_ostream OS(S);
+  print(OS, SM);
+  return OS.str();
+}
+
 //===--===//
 // FullSourceLoc
 //===--===//
Index: include/clang/Basic/SourceLocation.h
===
--- include/clang/Basic/SourceLocation.h
+++ include/clang/Basic/SourceLocation.h
@@ -220,6 +220,10 @@
   bool operator!=(const SourceRange &X) const {
 return B != X.B || E != X.E;
   }
+
+  void print(raw_ostream &OS, const SourceManager &SM) const;
+  std::string printToString(const SourceManager &SM) const;
+  void dump(const SourceManager &SM) const;
 };
 
 /// Represents a character-granular source range.
___
cfe-commits mailing list

[PATCH] D50662: Add dump() method for SourceRange

2018-08-23 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: unittests/Basic/SourceManagerTest.cpp:189
+
+  // TODO: How do I get a loc in another file?
+  auto headerLoc = 
SourceMgr.getSpellingLoc(SourceMgr.translateLineCol(MainFileID, 3, 5));

I don't know how to resolve this TODO, and somehow test a range between two 
files.


Repository:
  rC Clang

https://reviews.llvm.org/D50662



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


[PATCH] D50738: Remove vestiges of configure buildsystem

2018-08-23 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 162283.
steveire added a comment.

Remove vestiges of configure buildsystem


Repository:
  rC Clang

https://reviews.llvm.org/D50738

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -285,26 +285,14 @@
 set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
-if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
-  message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite 
"
-"the makefiles distributed with LLVM. Please create a directory and run cmake "
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
+  message(FATAL_ERROR "In-source builds are not allowed. "
+"Please create a directory and run cmake "
 "from there, passing the path to this source directory as the last argument. "
 "This process created the file `CMakeCache.txt' and the directory "
 "`CMakeFiles'. Please delete them.")
 endif()
 
-if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
-  file(GLOB_RECURSE
-tablegenned_files_on_include_dir
-"${CLANG_SOURCE_DIR}/include/clang/*.inc")
-  if( tablegenned_files_on_include_dir )
-message(FATAL_ERROR "Apparently there is a previous in-source build, "
-"probably as the result of running `configure' and `make' on "
-"${CLANG_SOURCE_DIR}. This may cause problems. The suspicious files are:\n"
-"${tablegenned_files_on_include_dir}\nPlease clean the source directory.")
-  endif()
-endif()
-
 # If CLANG_VERSION_* is specified, use it, if not use LLVM_VERSION_*.
 if(NOT DEFINED CLANG_VERSION_MAJOR)
   set(CLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -285,26 +285,14 @@
 set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
-if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
-  message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite "
-"the makefiles distributed with LLVM. Please create a directory and run cmake "
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
+  message(FATAL_ERROR "In-source builds are not allowed. "
+"Please create a directory and run cmake "
 "from there, passing the path to this source directory as the last argument. "
 "This process created the file `CMakeCache.txt' and the directory "
 "`CMakeFiles'. Please delete them.")
 endif()
 
-if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
-  file(GLOB_RECURSE
-tablegenned_files_on_include_dir
-"${CLANG_SOURCE_DIR}/include/clang/*.inc")
-  if( tablegenned_files_on_include_dir )
-message(FATAL_ERROR "Apparently there is a previous in-source build, "
-"probably as the result of running `configure' and `make' on "
-"${CLANG_SOURCE_DIR}. This may cause problems. The suspicious files are:\n"
-"${tablegenned_files_on_include_dir}\nPlease clean the source directory.")
-  endif()
-endif()
-
 # If CLANG_VERSION_* is specified, use it, if not use LLVM_VERSION_*.
 if(NOT DEFINED CLANG_VERSION_MAJOR)
   set(CLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51192: Fix reported range of partial token replacement

2018-08-23 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added reviewers: klimek, rsmith.
Herald added a subscriber: cfe-commits.

Fixes bug: 38678


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51192

Files:
  clang-tidy/ClangTidy.cpp


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -125,7 +125,6 @@
   // Retrieve the source range for applicable fixes. Macro definitions
   // on the command line have locations in a virtual buffer and don't
   // have valid file paths and are therefore not applicable.
-  SourceRange Range;
   SourceLocation FixLoc;
   ++TotalFixes;
   bool CanBeApplied = false;
@@ -166,7 +165,7 @@
 FixLoc = getLocation(FixAbsoluteFilePath, Repl.getOffset());
 SourceLocation FixEndLoc =
 FixLoc.getLocWithOffset(Repl.getLength());
-Range = SourceRange(FixLoc, FixEndLoc);
+CharSourceRange Range = CharSourceRange::getCharRange(FixLoc, 
FixEndLoc);
 Diag << FixItHint::CreateReplacement(Range,
  Repl.getReplacementText());
   }


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -125,7 +125,6 @@
   // Retrieve the source range for applicable fixes. Macro definitions
   // on the command line have locations in a virtual buffer and don't
   // have valid file paths and are therefore not applicable.
-  SourceRange Range;
   SourceLocation FixLoc;
   ++TotalFixes;
   bool CanBeApplied = false;
@@ -166,7 +165,7 @@
 FixLoc = getLocation(FixAbsoluteFilePath, Repl.getOffset());
 SourceLocation FixEndLoc =
 FixLoc.getLocWithOffset(Repl.getLength());
-Range = SourceRange(FixLoc, FixEndLoc);
+CharSourceRange Range = CharSourceRange::getCharRange(FixLoc, FixEndLoc);
 Diag << FixItHint::CreateReplacement(Range,
  Repl.getReplacementText());
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51192: Fix reported range of partial token replacement

2018-08-23 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 162288.
steveire added a comment.

Fix reported range of partial token replacement


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51192

Files:
  clang-tidy/ClangTidy.cpp


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -125,7 +125,6 @@
   // Retrieve the source range for applicable fixes. Macro definitions
   // on the command line have locations in a virtual buffer and don't
   // have valid file paths and are therefore not applicable.
-  SourceRange Range;
   SourceLocation FixLoc;
   ++TotalFixes;
   bool CanBeApplied = false;
@@ -166,7 +165,7 @@
 FixLoc = getLocation(FixAbsoluteFilePath, Repl.getOffset());
 SourceLocation FixEndLoc =
 FixLoc.getLocWithOffset(Repl.getLength());
-Range = SourceRange(FixLoc, FixEndLoc);
+CharSourceRange Range = 
CharSourceRange::getCharRange(SourceRange(FixLoc, FixEndLoc));
 Diag << FixItHint::CreateReplacement(Range,
  Repl.getReplacementText());
   }


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -125,7 +125,6 @@
   // Retrieve the source range for applicable fixes. Macro definitions
   // on the command line have locations in a virtual buffer and don't
   // have valid file paths and are therefore not applicable.
-  SourceRange Range;
   SourceLocation FixLoc;
   ++TotalFixes;
   bool CanBeApplied = false;
@@ -166,7 +165,7 @@
 FixLoc = getLocation(FixAbsoluteFilePath, Repl.getOffset());
 SourceLocation FixEndLoc =
 FixLoc.getLocWithOffset(Repl.getLength());
-Range = SourceRange(FixLoc, FixEndLoc);
+CharSourceRange Range = CharSourceRange::getCharRange(SourceRange(FixLoc, FixEndLoc));
 Diag << FixItHint::CreateReplacement(Range,
  Repl.getReplacementText());
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51258: Extract parseBindID method

2018-08-25 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D51258

Files:
  include/clang/ASTMatchers/Dynamic/Parser.h
  lib/ASTMatchers/Dynamic/Parser.cpp

Index: lib/ASTMatchers/Dynamic/Parser.cpp
===
--- lib/ASTMatchers/Dynamic/Parser.cpp
+++ lib/ASTMatchers/Dynamic/Parser.cpp
@@ -359,6 +359,43 @@
   return parseMatcherExpressionImpl(NameToken, Value);
 }
 
+bool Parser::parseBindID(std::string &BindID, TokenInfo &CloseToken) {
+  // Parse .bind("foo")
+  assert(Tokenizer->peekNextToken().Kind == TokenInfo::TK_Period);
+  Tokenizer->consumeNextToken(); // consume the period.
+  const TokenInfo BindToken = Tokenizer->consumeNextToken();
+  if (BindToken.Kind == TokenInfo::TK_CodeCompletion) {
+addCompletion(BindToken, MatcherCompletion("bind(\"", "bind", 1));
+return false;
+  }
+
+  const TokenInfo OpenToken = Tokenizer->consumeNextToken();
+  const TokenInfo IDToken = Tokenizer->consumeNextToken();
+  CloseToken = Tokenizer->consumeNextToken();
+
+  // TODO: We could use different error codes for each/some to be more
+  //   explicit about the syntax error.
+  if (BindToken.Kind != TokenInfo::TK_Ident ||
+  BindToken.Text != TokenInfo::ID_Bind) {
+Error->addError(BindToken.Range, Error->ET_ParserMalformedBindExpr);
+return false;
+  }
+  if (OpenToken.Kind != TokenInfo::TK_OpenParen) {
+Error->addError(OpenToken.Range, Error->ET_ParserMalformedBindExpr);
+return false;
+  }
+  if (IDToken.Kind != TokenInfo::TK_Literal || !IDToken.Value.isString()) {
+Error->addError(IDToken.Range, Error->ET_ParserMalformedBindExpr);
+return false;
+  }
+  if (CloseToken.Kind != TokenInfo::TK_CloseParen) {
+Error->addError(CloseToken.Range, Error->ET_ParserMalformedBindExpr);
+return false;
+  }
+  BindID = IDToken.Value.getString();
+  return true;
+}
+
 /// Parse and validate a matcher expression.
 /// \return \c true on success, in which case \c Value has the matcher parsed.
 ///   If the input is malformed, or some argument has an error, it
@@ -425,38 +462,9 @@
 
   std::string BindID;
   if (Tokenizer->peekNextToken().Kind == TokenInfo::TK_Period) {
-// Parse .bind("foo")
-Tokenizer->consumeNextToken();  // consume the period.
-const TokenInfo BindToken = Tokenizer->consumeNextToken();
-if (BindToken.Kind == TokenInfo::TK_CodeCompletion) {
-  addCompletion(BindToken, MatcherCompletion("bind(\"", "bind", 1));
+TokenInfo CloseToken;
+if (!parseBindID(BindID, CloseToken))
   return false;
-}
-
-const TokenInfo OpenToken = Tokenizer->consumeNextToken();
-const TokenInfo IDToken = Tokenizer->consumeNextToken();
-const TokenInfo CloseToken = Tokenizer->consumeNextToken();
-
-// TODO: We could use different error codes for each/some to be more
-//   explicit about the syntax error.
-if (BindToken.Kind != TokenInfo::TK_Ident ||
-BindToken.Text != TokenInfo::ID_Bind) {
-  Error->addError(BindToken.Range, Error->ET_ParserMalformedBindExpr);
-  return false;
-}
-if (OpenToken.Kind != TokenInfo::TK_OpenParen) {
-  Error->addError(OpenToken.Range, Error->ET_ParserMalformedBindExpr);
-  return false;
-}
-if (IDToken.Kind != TokenInfo::TK_Literal || !IDToken.Value.isString()) {
-  Error->addError(IDToken.Range, Error->ET_ParserMalformedBindExpr);
-  return false;
-}
-if (CloseToken.Kind != TokenInfo::TK_CloseParen) {
-  Error->addError(CloseToken.Range, Error->ET_ParserMalformedBindExpr);
-  return false;
-}
-BindID = IDToken.Value.getString();
   }
 
   if (!Ctor)
Index: include/clang/ASTMatchers/Dynamic/Parser.h
===
--- include/clang/ASTMatchers/Dynamic/Parser.h
+++ include/clang/ASTMatchers/Dynamic/Parser.h
@@ -234,6 +234,7 @@
  const NamedValueMap *NamedValues,
  Diagnostics *Error);
 
+  bool parseBindID(std::string &BindID, TokenInfo &endToken);
   bool parseExpressionImpl(VariantValue *Value);
   bool parseMatcherExpressionImpl(const TokenInfo &NameToken,
   VariantValue *Value);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51259: Allow binding to NamedValue resulting from let expression

2018-08-25 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D51259

Files:
  lib/ASTMatchers/Dynamic/Parser.cpp
  unittests/ASTMatchers/Dynamic/ParserTest.cpp


Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -359,6 +359,44 @@
   Comps[2].MatcherDecl);
 }
 
+TEST(ParserTest, ParseBindOnLet) {
+
+  auto NamedValues = getTestNamedValues();
+
+  Diagnostics Error;
+
+  {
+llvm::Optional topLevelLetBinding(
+Parser::parseMatcherExpression("hasParamA.bind(\"parmABinding\")",
+   nullptr, &NamedValues, &Error));
+EXPECT_EQ("", Error.toStringFull());
+auto M = topLevelLetBinding->unconditionalConvertTo();
+
+EXPECT_TRUE(matchAndVerifyResultTrue(
+"void foo(int a);", M,
+llvm::make_unique>("parmABinding")));
+EXPECT_TRUE(matchAndVerifyResultFalse(
+"void foo(int b);", M,
+llvm::make_unique>("parmABinding")));
+  }
+
+  {
+llvm::Optional nestedLetBinding(
+Parser::parseMatcherExpression(
+"functionDecl(hasParamA.bind(\"parmABinding\"))", nullptr,
+&NamedValues, &Error));
+EXPECT_EQ("", Error.toStringFull());
+auto M = nestedLetBinding->unconditionalConvertTo();
+
+EXPECT_TRUE(matchAndVerifyResultTrue(
+"void foo(int a);", M,
+llvm::make_unique>("parmABinding")));
+EXPECT_TRUE(matchAndVerifyResultFalse(
+"void foo(int b);", M,
+llvm::make_unique>("parmABinding")));
+  }
+}
+
 }  // end anonymous namespace
 }  // end namespace dynamic
 }  // end namespace ast_matchers
Index: lib/ASTMatchers/Dynamic/Parser.cpp
===
--- lib/ASTMatchers/Dynamic/Parser.cpp
+++ lib/ASTMatchers/Dynamic/Parser.cpp
@@ -339,8 +339,28 @@
 if (const VariantValue NamedValue =
 NamedValues ? NamedValues->lookup(NameToken.Text)
 : VariantValue()) {
-  *Value = NamedValue;
-  return true;
+
+  if (Tokenizer->nextTokenKind() != TokenInfo::TK_Period) {
+*Value = NamedValue;
+return true;
+  }
+
+  std::string BindID;
+  TokenInfo EndToken;
+  if (!parseBindID(BindID, EndToken))
+return false;
+
+  assert(NamedValue.isMatcher());
+  llvm::Optional Result =
+  NamedValue.getMatcher().getSingleMatcher();
+  if (Result.hasValue()) {
+llvm::Optional Bound = Result->tryBind(BindID);
+if (Bound.hasValue()) {
+  *Value = VariantMatcher::SingleMatcher(*Bound);
+  return true;
+}
+  }
+  return false;
 }
 // If the syntax is correct and the name is not a matcher either, report
 // unknown named value.


Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -359,6 +359,44 @@
   Comps[2].MatcherDecl);
 }
 
+TEST(ParserTest, ParseBindOnLet) {
+
+  auto NamedValues = getTestNamedValues();
+
+  Diagnostics Error;
+
+  {
+llvm::Optional topLevelLetBinding(
+Parser::parseMatcherExpression("hasParamA.bind(\"parmABinding\")",
+   nullptr, &NamedValues, &Error));
+EXPECT_EQ("", Error.toStringFull());
+auto M = topLevelLetBinding->unconditionalConvertTo();
+
+EXPECT_TRUE(matchAndVerifyResultTrue(
+"void foo(int a);", M,
+llvm::make_unique>("parmABinding")));
+EXPECT_TRUE(matchAndVerifyResultFalse(
+"void foo(int b);", M,
+llvm::make_unique>("parmABinding")));
+  }
+
+  {
+llvm::Optional nestedLetBinding(
+Parser::parseMatcherExpression(
+"functionDecl(hasParamA.bind(\"parmABinding\"))", nullptr,
+&NamedValues, &Error));
+EXPECT_EQ("", Error.toStringFull());
+auto M = nestedLetBinding->unconditionalConvertTo();
+
+EXPECT_TRUE(matchAndVerifyResultTrue(
+"void foo(int a);", M,
+llvm::make_unique>("parmABinding")));
+EXPECT_TRUE(matchAndVerifyResultFalse(
+"void foo(int b);", M,
+llvm::make_unique>("parmABinding")));
+  }
+}
+
 }  // end anonymous namespace
 }  // end namespace dynamic
 }  // end namespace ast_matchers
Index: lib/ASTMatchers/Dynamic/Parser.cpp
===
--- lib/ASTMatchers/Dynamic/Parser.cpp
+++ lib/ASTMatchers/Dynamic/Parser.cpp
@@ -339,8 +339,28 @@
 if (const VariantValue NamedValue =
 NamedValues ? NamedValues->lookup(NameToken.Text)
 : VariantValue()) {
-  *Value = NamedValue;
-  return true;
+
+  if (Tokenizer->nextTokenKind() != TokenInfo::TK_Period) {
+ 

[PATCH] D51260: Extract runCommandsInFile method

2018-08-25 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51260

Files:
  clang-query/tool/ClangQuery.cpp


Index: clang-query/tool/ClangQuery.cpp
===
--- clang-query/tool/ClangQuery.cpp
+++ clang-query/tool/ClangQuery.cpp
@@ -58,6 +58,24 @@
   cl::value_desc("file"),
   cl::cat(ClangQueryCategory));
 
+int runCommandsInFile(const char* exeName, std::string const& fileName, 
QuerySession& QS)
+{
+std::ifstream Input(fileName.c_str());
+if (!Input.is_open()) {
+  llvm::errs() << exeName << ": cannot open " << fileName << "\n";
+  return 1;
+}
+while (Input.good()) {
+  std::string Line;
+  std::getline(Input, Line);
+
+  QueryRef Q = QueryParser::parse(Line, QS);
+  if (!Q->run(llvm::outs(), QS))
+return 1;
+}
+return 0;
+}
+
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
@@ -84,19 +102,8 @@
 }
   } else if (!CommandFiles.empty()) {
 for (auto I = CommandFiles.begin(), E = CommandFiles.end(); I != E; ++I) {
-  std::ifstream Input(I->c_str());
-  if (!Input.is_open()) {
-llvm::errs() << argv[0] << ": cannot open " << *I << "\n";
-return 1;
-  }
-  while (Input.good()) {
-std::string Line;
-std::getline(Input, Line);
-
-QueryRef Q = QueryParser::parse(Line, QS);
-if (!Q->run(llvm::outs(), QS))
-  return 1;
-  }
+  if (auto err = runCommandsInFile(argv[0], *I, QS))
+return err;
 }
   } else {
 LineEditor LE("clang-query");


Index: clang-query/tool/ClangQuery.cpp
===
--- clang-query/tool/ClangQuery.cpp
+++ clang-query/tool/ClangQuery.cpp
@@ -58,6 +58,24 @@
   cl::value_desc("file"),
   cl::cat(ClangQueryCategory));
 
+int runCommandsInFile(const char* exeName, std::string const& fileName, QuerySession& QS)
+{
+std::ifstream Input(fileName.c_str());
+if (!Input.is_open()) {
+  llvm::errs() << exeName << ": cannot open " << fileName << "\n";
+  return 1;
+}
+while (Input.good()) {
+  std::string Line;
+  std::getline(Input, Line);
+
+  QueryRef Q = QueryParser::parse(Line, QS);
+  if (!Q->run(llvm::outs(), QS))
+return 1;
+}
+return 0;
+}
+
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
@@ -84,19 +102,8 @@
 }
   } else if (!CommandFiles.empty()) {
 for (auto I = CommandFiles.begin(), E = CommandFiles.end(); I != E; ++I) {
-  std::ifstream Input(I->c_str());
-  if (!Input.is_open()) {
-llvm::errs() << argv[0] << ": cannot open " << *I << "\n";
-return 1;
-  }
-  while (Input.good()) {
-std::string Line;
-std::getline(Input, Line);
-
-QueryRef Q = QueryParser::parse(Line, QS);
-if (!Q->run(llvm::outs(), QS))
-  return 1;
-  }
+  if (auto err = runCommandsInFile(argv[0], *I, QS))
+return err;
 }
   } else {
 LineEditor LE("clang-query");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51261: Add preload option to clang-query

2018-08-25 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a subscriber: cfe-commits.

This allows loading a file with pre-defined let commands for example.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51261

Files:
  clang-query/tool/ClangQuery.cpp


Index: clang-query/tool/ClangQuery.cpp
===
--- clang-query/tool/ClangQuery.cpp
+++ clang-query/tool/ClangQuery.cpp
@@ -58,6 +58,11 @@
   cl::value_desc("file"),
   cl::cat(ClangQueryCategory));
 
+static cl::opt PreloadFile(
+"preload",
+cl::desc("Preload commands from file and start interactive mode"),
+cl::value_desc("file"), cl::cat(ClangQueryCategory));
+
 int runCommandsInFile(const char* exeName, std::string const& fileName, 
QuerySession& QS)
 {
 std::ifstream Input(fileName.c_str());
@@ -86,6 +91,12 @@
 return 1;
   }
 
+  if ((!Commands.empty() || !CommandFiles.empty()) && !PreloadFile.empty()) {
+llvm::errs() << argv[0]
+ << ": cannot specify both -c or -f with --preload\n";
+return 1;
+  }
+
   ClangTool Tool(OptionsParser.getCompilations(),
  OptionsParser.getSourcePathList());
   std::vector> ASTs;
@@ -106,6 +117,10 @@
 return err;
 }
   } else {
+if (!PreloadFile.empty()) {
+  if (auto err = runCommandsInFile(argv[0], PreloadFile, QS))
+return err;
+}
 LineEditor LE("clang-query");
 LE.setListCompleter([&QS](StringRef Line, size_t Pos) {
   return QueryParser::complete(Line, Pos, QS);


Index: clang-query/tool/ClangQuery.cpp
===
--- clang-query/tool/ClangQuery.cpp
+++ clang-query/tool/ClangQuery.cpp
@@ -58,6 +58,11 @@
   cl::value_desc("file"),
   cl::cat(ClangQueryCategory));
 
+static cl::opt PreloadFile(
+"preload",
+cl::desc("Preload commands from file and start interactive mode"),
+cl::value_desc("file"), cl::cat(ClangQueryCategory));
+
 int runCommandsInFile(const char* exeName, std::string const& fileName, QuerySession& QS)
 {
 std::ifstream Input(fileName.c_str());
@@ -86,6 +91,12 @@
 return 1;
   }
 
+  if ((!Commands.empty() || !CommandFiles.empty()) && !PreloadFile.empty()) {
+llvm::errs() << argv[0]
+ << ": cannot specify both -c or -f with --preload\n";
+return 1;
+  }
+
   ClangTool Tool(OptionsParser.getCompilations(),
  OptionsParser.getSourcePathList());
   std::vector> ASTs;
@@ -106,6 +117,10 @@
 return err;
 }
   } else {
+if (!PreloadFile.empty()) {
+  if (auto err = runCommandsInFile(argv[0], PreloadFile, QS))
+return err;
+}
 LineEditor LE("clang-query");
 LE.setListCompleter([&QS](StringRef Line, size_t Pos) {
   return QueryParser::complete(Line, Pos, QS);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50353: Remove deprecated API

2018-08-30 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

@rsmith Could you approve this please?


Repository:
  rC Clang

https://reviews.llvm.org/D50353



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


[PATCH] D50662: Add dump() method for SourceRange

2018-08-30 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341140: Add dump() method for SourceRange (authored by 
steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50662?vs=162282&id=163440#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50662

Files:
  cfe/trunk/include/clang/Basic/SourceLocation.h
  cfe/trunk/lib/Basic/SourceLocation.cpp
  cfe/trunk/unittests/Basic/SourceManagerTest.cpp

Index: cfe/trunk/unittests/Basic/SourceManagerTest.cpp
===
--- cfe/trunk/unittests/Basic/SourceManagerTest.cpp
+++ cfe/trunk/unittests/Basic/SourceManagerTest.cpp
@@ -155,6 +155,54 @@
   EXPECT_EQ(1U, SourceMgr.getColumnNumber(MainFileID, 0, nullptr));
 }
 
+TEST_F(SourceManagerTest, locationPrintTest) {
+  const char *header = "#define IDENTITY(x) x\n";
+
+  const char *Source = "int x;\n"
+   "include \"test-header.h\"\n"
+   "IDENTITY(int y);\n"
+   "int z;";
+
+  std::unique_ptr HeaderBuf =
+  llvm::MemoryBuffer::getMemBuffer(header);
+  std::unique_ptr Buf =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+
+  const FileEntry *SourceFile =
+  FileMgr.getVirtualFile("/mainFile.cpp", Buf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(SourceFile, std::move(Buf));
+
+  const FileEntry *HeaderFile =
+  FileMgr.getVirtualFile("/test-header.h", HeaderBuf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(HeaderFile, std::move(HeaderBuf));
+
+  FileID MainFileID = SourceMgr.getOrCreateFileID(SourceFile, SrcMgr::C_User);
+  FileID HeaderFileID = SourceMgr.getOrCreateFileID(HeaderFile, SrcMgr::C_User);
+  SourceMgr.setMainFileID(MainFileID);
+
+  auto BeginLoc = SourceMgr.getLocForStartOfFile(MainFileID);
+  auto EndLoc = SourceMgr.getLocForEndOfFile(MainFileID);
+
+  auto BeginEOLLoc = SourceMgr.translateLineCol(MainFileID, 1, 7);
+
+  auto HeaderLoc = SourceMgr.getLocForStartOfFile(HeaderFileID);
+
+  EXPECT_EQ(BeginLoc.printToString(SourceMgr), "/mainFile.cpp:1:1");
+  EXPECT_EQ(EndLoc.printToString(SourceMgr), "/mainFile.cpp:4:7");
+
+  EXPECT_EQ(BeginEOLLoc.printToString(SourceMgr), "/mainFile.cpp:1:7");
+  EXPECT_EQ(HeaderLoc.printToString(SourceMgr), "/test-header.h:1:1");
+
+  EXPECT_EQ(SourceRange(BeginLoc, BeginLoc).printToString(SourceMgr),
+"");
+  EXPECT_EQ(SourceRange(BeginLoc, BeginEOLLoc).printToString(SourceMgr),
+"");
+  EXPECT_EQ(SourceRange(BeginLoc, EndLoc).printToString(SourceMgr),
+"");
+  EXPECT_EQ(SourceRange(BeginLoc, HeaderLoc).printToString(SourceMgr),
+"");
+}
+
 #if defined(LLVM_ON_UNIX)
 
 TEST_F(SourceManagerTest, getMacroArgExpandedLocation) {
Index: cfe/trunk/include/clang/Basic/SourceLocation.h
===
--- cfe/trunk/include/clang/Basic/SourceLocation.h
+++ cfe/trunk/include/clang/Basic/SourceLocation.h
@@ -220,6 +220,10 @@
   bool operator!=(const SourceRange &X) const {
 return B != X.B || E != X.E;
   }
+
+  void print(raw_ostream &OS, const SourceManager &SM) const;
+  std::string printToString(const SourceManager &SM) const;
+  void dump(const SourceManager &SM) const;
 };
 
 /// Represents a character-granular source range.
Index: cfe/trunk/lib/Basic/SourceLocation.cpp
===
--- cfe/trunk/lib/Basic/SourceLocation.cpp
+++ cfe/trunk/lib/Basic/SourceLocation.cpp
@@ -80,6 +80,60 @@
   llvm::errs() << '\n';
 }
 
+LLVM_DUMP_METHOD void SourceRange::dump(const SourceManager &SM) const {
+  print(llvm::errs(), SM);
+  llvm::errs() << '\n';
+}
+
+static PresumedLoc PrintDifference(raw_ostream &OS, const SourceManager &SM,
+   SourceLocation Loc, PresumedLoc Previous) {
+  if (Loc.isFileID()) {
+
+PresumedLoc PLoc = SM.getPresumedLoc(Loc);
+
+if (PLoc.isInvalid()) {
+  OS << "";
+  return Previous;
+}
+
+if (Previous.isInvalid() ||
+strcmp(PLoc.getFilename(), Previous.getFilename()) != 0) {
+  OS << PLoc.getFilename() << ':' << PLoc.getLine() << ':'
+ << PLoc.getColumn();
+} else if (Previous.isInvalid() || PLoc.getLine() != Previous.getLine()) {
+  OS << "line" << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
+} else {
+  OS << "col" << ':' << PLoc.getColumn();
+}
+return PLoc;
+  }
+  auto PrintedLoc = PrintDifference(OS, SM, SM.getExpansionLoc(Loc), Previous);
+
+  OS << " ';
+  return PrintedLoc;
+}
+
+void SourceRange::print(raw_ostream &OS, const SourceManager &SM) const {
+
+  OS << '<';
+  auto PrintedLoc = PrintDifference(OS, SM, B, {});
+  if (B != E) {
+OS << ", ";
+PrintDifference(OS, SM, E, PrintedLoc);
+  }
+  OS << '>';
+}
+
+LLVM_DUMP_METHOD std::string
+Source

[PATCH] D51258: Extract parseBindID method

2018-08-30 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341141: Extract parseBindID method (authored by steveire, 
committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51258?vs=162552&id=163441#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51258

Files:
  cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
  cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp


Index: cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
===
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
@@ -234,6 +234,7 @@
  const NamedValueMap *NamedValues,
  Diagnostics *Error);
 
+  bool parseBindID(std::string &BindID);
   bool parseExpressionImpl(VariantValue *Value);
   bool parseMatcherExpressionImpl(const TokenInfo &NameToken,
   VariantValue *Value);
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
@@ -359,6 +359,43 @@
   return parseMatcherExpressionImpl(NameToken, Value);
 }
 
+bool Parser::parseBindID(std::string &BindID) {
+  // Parse .bind("foo")
+  assert(Tokenizer->peekNextToken().Kind == TokenInfo::TK_Period);
+  Tokenizer->consumeNextToken(); // consume the period.
+  const TokenInfo BindToken = Tokenizer->consumeNextToken();
+  if (BindToken.Kind == TokenInfo::TK_CodeCompletion) {
+addCompletion(BindToken, MatcherCompletion("bind(\"", "bind", 1));
+return false;
+  }
+
+  const TokenInfo OpenToken = Tokenizer->consumeNextToken();
+  const TokenInfo IDToken = Tokenizer->consumeNextToken();
+  const TokenInfo CloseToken = Tokenizer->consumeNextToken();
+
+  // TODO: We could use different error codes for each/some to be more
+  //   explicit about the syntax error.
+  if (BindToken.Kind != TokenInfo::TK_Ident ||
+  BindToken.Text != TokenInfo::ID_Bind) {
+Error->addError(BindToken.Range, Error->ET_ParserMalformedBindExpr);
+return false;
+  }
+  if (OpenToken.Kind != TokenInfo::TK_OpenParen) {
+Error->addError(OpenToken.Range, Error->ET_ParserMalformedBindExpr);
+return false;
+  }
+  if (IDToken.Kind != TokenInfo::TK_Literal || !IDToken.Value.isString()) {
+Error->addError(IDToken.Range, Error->ET_ParserMalformedBindExpr);
+return false;
+  }
+  if (CloseToken.Kind != TokenInfo::TK_CloseParen) {
+Error->addError(CloseToken.Range, Error->ET_ParserMalformedBindExpr);
+return false;
+  }
+  BindID = IDToken.Value.getString();
+  return true;
+}
+
 /// Parse and validate a matcher expression.
 /// \return \c true on success, in which case \c Value has the matcher parsed.
 ///   If the input is malformed, or some argument has an error, it
@@ -425,38 +462,8 @@
 
   std::string BindID;
   if (Tokenizer->peekNextToken().Kind == TokenInfo::TK_Period) {
-// Parse .bind("foo")
-Tokenizer->consumeNextToken();  // consume the period.
-const TokenInfo BindToken = Tokenizer->consumeNextToken();
-if (BindToken.Kind == TokenInfo::TK_CodeCompletion) {
-  addCompletion(BindToken, MatcherCompletion("bind(\"", "bind", 1));
+if (!parseBindID(BindID))
   return false;
-}
-
-const TokenInfo OpenToken = Tokenizer->consumeNextToken();
-const TokenInfo IDToken = Tokenizer->consumeNextToken();
-const TokenInfo CloseToken = Tokenizer->consumeNextToken();
-
-// TODO: We could use different error codes for each/some to be more
-//   explicit about the syntax error.
-if (BindToken.Kind != TokenInfo::TK_Ident ||
-BindToken.Text != TokenInfo::ID_Bind) {
-  Error->addError(BindToken.Range, Error->ET_ParserMalformedBindExpr);
-  return false;
-}
-if (OpenToken.Kind != TokenInfo::TK_OpenParen) {
-  Error->addError(OpenToken.Range, Error->ET_ParserMalformedBindExpr);
-  return false;
-}
-if (IDToken.Kind != TokenInfo::TK_Literal || !IDToken.Value.isString()) {
-  Error->addError(IDToken.Range, Error->ET_ParserMalformedBindExpr);
-  return false;
-}
-if (CloseToken.Kind != TokenInfo::TK_CloseParen) {
-  Error->addError(CloseToken.Range, Error->ET_ParserMalformedBindExpr);
-  return false;
-}
-BindID = IDToken.Value.getString();
   }
 
   if (!Ctor)


Index: cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
===
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
@@ -234,6 +234,7 @@
  const NamedValueMap *NamedValues,
  Diagnostics *Error);
 
+  bool parseBindID(std::string &BindID);
   bool parseExpressionImpl(VariantValue *

[PATCH] D51259: Allow binding to NamedValue resulting from let expression

2018-08-30 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341142: Allow binding to NamedValue resulting from let 
expression (authored by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51259?vs=162553&id=163442#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51259

Files:
  cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
  cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp


Index: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
@@ -339,8 +339,27 @@
 if (const VariantValue NamedValue =
 NamedValues ? NamedValues->lookup(NameToken.Text)
 : VariantValue()) {
-  *Value = NamedValue;
-  return true;
+
+  if (Tokenizer->nextTokenKind() != TokenInfo::TK_Period) {
+*Value = NamedValue;
+return true;
+  }
+
+  std::string BindID;
+  if (!parseBindID(BindID))
+return false;
+
+  assert(NamedValue.isMatcher());
+  llvm::Optional Result =
+  NamedValue.getMatcher().getSingleMatcher();
+  if (Result.hasValue()) {
+llvm::Optional Bound = Result->tryBind(BindID);
+if (Bound.hasValue()) {
+  *Value = VariantMatcher::SingleMatcher(*Bound);
+  return true;
+}
+  }
+  return false;
 }
 // If the syntax is correct and the name is not a matcher either, report
 // unknown named value.
Index: cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -359,6 +359,44 @@
   Comps[2].MatcherDecl);
 }
 
+TEST(ParserTest, ParseBindOnLet) {
+
+  auto NamedValues = getTestNamedValues();
+
+  Diagnostics Error;
+
+  {
+llvm::Optional TopLevelLetBinding(
+Parser::parseMatcherExpression("hasParamA.bind(\"parmABinding\")",
+   nullptr, &NamedValues, &Error));
+EXPECT_EQ("", Error.toStringFull());
+auto M = TopLevelLetBinding->unconditionalConvertTo();
+
+EXPECT_TRUE(matchAndVerifyResultTrue(
+"void foo(int a);", M,
+llvm::make_unique>("parmABinding")));
+EXPECT_TRUE(matchAndVerifyResultFalse(
+"void foo(int b);", M,
+llvm::make_unique>("parmABinding")));
+  }
+
+  {
+llvm::Optional NestedLetBinding(
+Parser::parseMatcherExpression(
+"functionDecl(hasParamA.bind(\"parmABinding\"))", nullptr,
+&NamedValues, &Error));
+EXPECT_EQ("", Error.toStringFull());
+auto M = NestedLetBinding->unconditionalConvertTo();
+
+EXPECT_TRUE(matchAndVerifyResultTrue(
+"void foo(int a);", M,
+llvm::make_unique>("parmABinding")));
+EXPECT_TRUE(matchAndVerifyResultFalse(
+"void foo(int b);", M,
+llvm::make_unique>("parmABinding")));
+  }
+}
+
 }  // end anonymous namespace
 }  // end namespace dynamic
 }  // end namespace ast_matchers


Index: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
@@ -339,8 +339,27 @@
 if (const VariantValue NamedValue =
 NamedValues ? NamedValues->lookup(NameToken.Text)
 : VariantValue()) {
-  *Value = NamedValue;
-  return true;
+
+  if (Tokenizer->nextTokenKind() != TokenInfo::TK_Period) {
+*Value = NamedValue;
+return true;
+  }
+
+  std::string BindID;
+  if (!parseBindID(BindID))
+return false;
+
+  assert(NamedValue.isMatcher());
+  llvm::Optional Result =
+  NamedValue.getMatcher().getSingleMatcher();
+  if (Result.hasValue()) {
+llvm::Optional Bound = Result->tryBind(BindID);
+if (Bound.hasValue()) {
+  *Value = VariantMatcher::SingleMatcher(*Bound);
+  return true;
+}
+  }
+  return false;
 }
 // If the syntax is correct and the name is not a matcher either, report
 // unknown named value.
Index: cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -359,6 +359,44 @@
   Comps[2].MatcherDecl);
 }
 
+TEST(ParserTest, ParseBindOnLet) {
+
+  auto NamedValues = getTestNamedValues();
+
+  Diagnostics Error;
+
+  {
+llvm::Optional TopLevelLetBinding(
+Parser::parseMatcherExpression("hasParamA.bind(\"parmABinding\")",
+   nullptr, &NamedValues, &Error));
+EXPECT_EQ("", 

[PATCH] D51259: Allow binding to NamedValue resulting from let expression

2018-08-30 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC341142: Allow binding to NamedValue resulting from let 
expression (authored by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51259?vs=162553&id=163443#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51259

Files:
  lib/ASTMatchers/Dynamic/Parser.cpp
  unittests/ASTMatchers/Dynamic/ParserTest.cpp


Index: lib/ASTMatchers/Dynamic/Parser.cpp
===
--- lib/ASTMatchers/Dynamic/Parser.cpp
+++ lib/ASTMatchers/Dynamic/Parser.cpp
@@ -339,8 +339,27 @@
 if (const VariantValue NamedValue =
 NamedValues ? NamedValues->lookup(NameToken.Text)
 : VariantValue()) {
-  *Value = NamedValue;
-  return true;
+
+  if (Tokenizer->nextTokenKind() != TokenInfo::TK_Period) {
+*Value = NamedValue;
+return true;
+  }
+
+  std::string BindID;
+  if (!parseBindID(BindID))
+return false;
+
+  assert(NamedValue.isMatcher());
+  llvm::Optional Result =
+  NamedValue.getMatcher().getSingleMatcher();
+  if (Result.hasValue()) {
+llvm::Optional Bound = Result->tryBind(BindID);
+if (Bound.hasValue()) {
+  *Value = VariantMatcher::SingleMatcher(*Bound);
+  return true;
+}
+  }
+  return false;
 }
 // If the syntax is correct and the name is not a matcher either, report
 // unknown named value.
Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -359,6 +359,44 @@
   Comps[2].MatcherDecl);
 }
 
+TEST(ParserTest, ParseBindOnLet) {
+
+  auto NamedValues = getTestNamedValues();
+
+  Diagnostics Error;
+
+  {
+llvm::Optional TopLevelLetBinding(
+Parser::parseMatcherExpression("hasParamA.bind(\"parmABinding\")",
+   nullptr, &NamedValues, &Error));
+EXPECT_EQ("", Error.toStringFull());
+auto M = TopLevelLetBinding->unconditionalConvertTo();
+
+EXPECT_TRUE(matchAndVerifyResultTrue(
+"void foo(int a);", M,
+llvm::make_unique>("parmABinding")));
+EXPECT_TRUE(matchAndVerifyResultFalse(
+"void foo(int b);", M,
+llvm::make_unique>("parmABinding")));
+  }
+
+  {
+llvm::Optional NestedLetBinding(
+Parser::parseMatcherExpression(
+"functionDecl(hasParamA.bind(\"parmABinding\"))", nullptr,
+&NamedValues, &Error));
+EXPECT_EQ("", Error.toStringFull());
+auto M = NestedLetBinding->unconditionalConvertTo();
+
+EXPECT_TRUE(matchAndVerifyResultTrue(
+"void foo(int a);", M,
+llvm::make_unique>("parmABinding")));
+EXPECT_TRUE(matchAndVerifyResultFalse(
+"void foo(int b);", M,
+llvm::make_unique>("parmABinding")));
+  }
+}
+
 }  // end anonymous namespace
 }  // end namespace dynamic
 }  // end namespace ast_matchers


Index: lib/ASTMatchers/Dynamic/Parser.cpp
===
--- lib/ASTMatchers/Dynamic/Parser.cpp
+++ lib/ASTMatchers/Dynamic/Parser.cpp
@@ -339,8 +339,27 @@
 if (const VariantValue NamedValue =
 NamedValues ? NamedValues->lookup(NameToken.Text)
 : VariantValue()) {
-  *Value = NamedValue;
-  return true;
+
+  if (Tokenizer->nextTokenKind() != TokenInfo::TK_Period) {
+*Value = NamedValue;
+return true;
+  }
+
+  std::string BindID;
+  if (!parseBindID(BindID))
+return false;
+
+  assert(NamedValue.isMatcher());
+  llvm::Optional Result =
+  NamedValue.getMatcher().getSingleMatcher();
+  if (Result.hasValue()) {
+llvm::Optional Bound = Result->tryBind(BindID);
+if (Bound.hasValue()) {
+  *Value = VariantMatcher::SingleMatcher(*Bound);
+  return true;
+}
+  }
+  return false;
 }
 // If the syntax is correct and the name is not a matcher either, report
 // unknown named value.
Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -359,6 +359,44 @@
   Comps[2].MatcherDecl);
 }
 
+TEST(ParserTest, ParseBindOnLet) {
+
+  auto NamedValues = getTestNamedValues();
+
+  Diagnostics Error;
+
+  {
+llvm::Optional TopLevelLetBinding(
+Parser::parseMatcherExpression("hasParamA.bind(\"parmABinding\")",
+   nullptr, &NamedValues, &Error));
+EXPECT_EQ("", Error.toStringFull());
+auto M = TopLevelLetBinding->unconditionalConvertTo();
+
+EXPECT_TRUE(matchAndVerifyResultTrue(
+"void foo(int a);", M,
+llvm::make_u

[PATCH] D51258: Extract parseBindID method

2018-08-30 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked an inline comment as done.
steveire added inline comments.



Comment at: lib/ASTMatchers/Dynamic/Parser.cpp:362
 
+bool Parser::parseBindID(std::string &BindID, TokenInfo &CloseToken) {
+  // Parse .bind("foo")

klimek wrote:
> CloseToken seems to not be used afterwards either here or in the follow-up 
> patch?
Good catch, thanks. Fixed before committing.


Repository:
  rL LLVM

https://reviews.llvm.org/D51258



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


[PATCH] D51261: Add preload option to clang-query

2018-08-30 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE341145: Add preload option to clang-query (authored by 
steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51261?vs=162555&id=163445#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51261

Files:
  clang-query/tool/ClangQuery.cpp


Index: clang-query/tool/ClangQuery.cpp
===
--- clang-query/tool/ClangQuery.cpp
+++ clang-query/tool/ClangQuery.cpp
@@ -58,6 +58,11 @@
   cl::value_desc("file"),
   cl::cat(ClangQueryCategory));
 
+static cl::opt PreloadFile(
+"preload",
+cl::desc("Preload commands from file and start interactive mode"),
+cl::value_desc("file"), cl::cat(ClangQueryCategory));
+
 bool runCommandsInFile(const char *ExeName, std::string const &FileName,
QuerySession &QS) {
   std::ifstream Input(FileName.c_str());
@@ -86,6 +91,12 @@
 return 1;
   }
 
+  if ((!Commands.empty() || !CommandFiles.empty()) && !PreloadFile.empty()) {
+llvm::errs() << argv[0]
+ << ": cannot specify both -c or -f with --preload\n";
+return 1;
+  }
+
   ClangTool Tool(OptionsParser.getCompilations(),
  OptionsParser.getSourcePathList());
   std::vector> ASTs;
@@ -106,6 +117,10 @@
 return 1;
 }
   } else {
+if (!PreloadFile.empty()) {
+  if (runCommandsInFile(argv[0], PreloadFile, QS))
+return 1;
+}
 LineEditor LE("clang-query");
 LE.setListCompleter([&QS](StringRef Line, size_t Pos) {
   return QueryParser::complete(Line, Pos, QS);


Index: clang-query/tool/ClangQuery.cpp
===
--- clang-query/tool/ClangQuery.cpp
+++ clang-query/tool/ClangQuery.cpp
@@ -58,6 +58,11 @@
   cl::value_desc("file"),
   cl::cat(ClangQueryCategory));
 
+static cl::opt PreloadFile(
+"preload",
+cl::desc("Preload commands from file and start interactive mode"),
+cl::value_desc("file"), cl::cat(ClangQueryCategory));
+
 bool runCommandsInFile(const char *ExeName, std::string const &FileName,
QuerySession &QS) {
   std::ifstream Input(FileName.c_str());
@@ -86,6 +91,12 @@
 return 1;
   }
 
+  if ((!Commands.empty() || !CommandFiles.empty()) && !PreloadFile.empty()) {
+llvm::errs() << argv[0]
+ << ": cannot specify both -c or -f with --preload\n";
+return 1;
+  }
+
   ClangTool Tool(OptionsParser.getCompilations(),
  OptionsParser.getSourcePathList());
   std::vector> ASTs;
@@ -106,6 +117,10 @@
 return 1;
 }
   } else {
+if (!PreloadFile.empty()) {
+  if (runCommandsInFile(argv[0], PreloadFile, QS))
+return 1;
+}
 LineEditor LE("clang-query");
 LE.setListCompleter([&QS](StringRef Line, size_t Pos) {
   return QueryParser::complete(Line, Pos, QS);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51260: Extract runCommandsInFile method

2018-08-30 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341144: Extract runCommandsInFile method (authored by 
steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51260?vs=162554&id=163444#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51260

Files:
  clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp


Index: clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
===
--- clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
+++ clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
@@ -58,6 +58,24 @@
   cl::value_desc("file"),
   cl::cat(ClangQueryCategory));
 
+bool runCommandsInFile(const char *ExeName, std::string const &FileName,
+   QuerySession &QS) {
+  std::ifstream Input(FileName.c_str());
+  if (!Input.is_open()) {
+llvm::errs() << ExeName << ": cannot open " << FileName << "\n";
+return 1;
+  }
+  while (Input.good()) {
+std::string Line;
+std::getline(Input, Line);
+
+QueryRef Q = QueryParser::parse(Line, QS);
+if (!Q->run(llvm::outs(), QS))
+  return true;
+  }
+  return false;
+}
+
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
@@ -84,19 +102,8 @@
 }
   } else if (!CommandFiles.empty()) {
 for (auto I = CommandFiles.begin(), E = CommandFiles.end(); I != E; ++I) {
-  std::ifstream Input(I->c_str());
-  if (!Input.is_open()) {
-llvm::errs() << argv[0] << ": cannot open " << *I << "\n";
+  if (runCommandsInFile(argv[0], *I, QS))
 return 1;
-  }
-  while (Input.good()) {
-std::string Line;
-std::getline(Input, Line);
-
-QueryRef Q = QueryParser::parse(Line, QS);
-if (!Q->run(llvm::outs(), QS))
-  return 1;
-  }
 }
   } else {
 LineEditor LE("clang-query");


Index: clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
===
--- clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
+++ clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
@@ -58,6 +58,24 @@
   cl::value_desc("file"),
   cl::cat(ClangQueryCategory));
 
+bool runCommandsInFile(const char *ExeName, std::string const &FileName,
+   QuerySession &QS) {
+  std::ifstream Input(FileName.c_str());
+  if (!Input.is_open()) {
+llvm::errs() << ExeName << ": cannot open " << FileName << "\n";
+return 1;
+  }
+  while (Input.good()) {
+std::string Line;
+std::getline(Input, Line);
+
+QueryRef Q = QueryParser::parse(Line, QS);
+if (!Q->run(llvm::outs(), QS))
+  return true;
+  }
+  return false;
+}
+
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
@@ -84,19 +102,8 @@
 }
   } else if (!CommandFiles.empty()) {
 for (auto I = CommandFiles.begin(), E = CommandFiles.end(); I != E; ++I) {
-  std::ifstream Input(I->c_str());
-  if (!Input.is_open()) {
-llvm::errs() << argv[0] << ": cannot open " << *I << "\n";
+  if (runCommandsInFile(argv[0], *I, QS))
 return 1;
-  }
-  while (Input.good()) {
-std::string Line;
-std::getline(Input, Line);
-
-QueryRef Q = QueryParser::parse(Line, QS);
-if (!Q->run(llvm::outs(), QS))
-  return 1;
-  }
 }
   } else {
 LineEditor LE("clang-query");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51260: Extract runCommandsInFile method

2018-08-30 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked 2 inline comments as done.
steveire added a comment.

Thanks, I fixed the issues before committing. This commit was a prerequisite to 
https://reviews.llvm.org/D51261


Repository:
  rL LLVM

https://reviews.llvm.org/D51260



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


[PATCH] D51192: Fix reported range of partial token replacement

2018-08-30 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 163447.
steveire added a comment.

Move comment


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51192

Files:
  clang-tidy/ClangTidy.cpp


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -122,10 +122,6 @@
   << Message.Message << Name;
   for (const auto &FileAndReplacements : Error.Fix) {
 for (const auto &Repl : FileAndReplacements.second) {
-  // Retrieve the source range for applicable fixes. Macro definitions
-  // on the command line have locations in a virtual buffer and don't
-  // have valid file paths and are therefore not applicable.
-  SourceRange Range;
   SourceLocation FixLoc;
   ++TotalFixes;
   bool CanBeApplied = false;
@@ -166,7 +162,11 @@
 FixLoc = getLocation(FixAbsoluteFilePath, Repl.getOffset());
 SourceLocation FixEndLoc =
 FixLoc.getLocWithOffset(Repl.getLength());
-Range = SourceRange(FixLoc, FixEndLoc);
+// Retrieve the source range for applicable fixes. Macro 
definitions
+// on the command line have locations in a virtual buffer and don't
+// have valid file paths and are therefore not applicable.
+CharSourceRange Range =
+CharSourceRange::getCharRange(SourceRange(FixLoc, FixEndLoc));
 Diag << FixItHint::CreateReplacement(Range,
  Repl.getReplacementText());
   }


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -122,10 +122,6 @@
   << Message.Message << Name;
   for (const auto &FileAndReplacements : Error.Fix) {
 for (const auto &Repl : FileAndReplacements.second) {
-  // Retrieve the source range for applicable fixes. Macro definitions
-  // on the command line have locations in a virtual buffer and don't
-  // have valid file paths and are therefore not applicable.
-  SourceRange Range;
   SourceLocation FixLoc;
   ++TotalFixes;
   bool CanBeApplied = false;
@@ -166,7 +162,11 @@
 FixLoc = getLocation(FixAbsoluteFilePath, Repl.getOffset());
 SourceLocation FixEndLoc =
 FixLoc.getLocWithOffset(Repl.getLength());
-Range = SourceRange(FixLoc, FixEndLoc);
+// Retrieve the source range for applicable fixes. Macro definitions
+// on the command line have locations in a virtual buffer and don't
+// have valid file paths and are therefore not applicable.
+CharSourceRange Range =
+CharSourceRange::getCharRange(SourceRange(FixLoc, FixEndLoc));
 Diag << FixItHint::CreateReplacement(Range,
  Repl.getReplacementText());
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50738: Remove vestiges of configure buildsystem

2018-08-30 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341146: Remove vestiges of configure buildsystem (authored 
by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50738?vs=162283&id=163448#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50738

Files:
  cfe/trunk/CMakeLists.txt


Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -289,25 +289,13 @@
 set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
-  message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite 
"
-"the makefiles distributed with LLVM. Please create a directory and run cmake "
+  message(FATAL_ERROR "In-source builds are not allowed. "
+"Please create a directory and run cmake "
 "from there, passing the path to this source directory as the last argument. "
 "This process created the file `CMakeCache.txt' and the directory "
 "`CMakeFiles'. Please delete them.")
 endif()
 
-if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
-  file(GLOB_RECURSE
-tablegenned_files_on_include_dir
-"${CLANG_SOURCE_DIR}/include/clang/*.inc")
-  if( tablegenned_files_on_include_dir )
-message(FATAL_ERROR "Apparently there is a previous in-source build, "
-"probably as the result of running `configure' and `make' on "
-"${CLANG_SOURCE_DIR}. This may cause problems. The suspicious files are:\n"
-"${tablegenned_files_on_include_dir}\nPlease clean the source directory.")
-  endif()
-endif()
-
 # If CLANG_VERSION_* is specified, use it, if not use LLVM_VERSION_*.
 if(NOT DEFINED CLANG_VERSION_MAJOR)
   set(CLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})


Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -289,25 +289,13 @@
 set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
-  message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite "
-"the makefiles distributed with LLVM. Please create a directory and run cmake "
+  message(FATAL_ERROR "In-source builds are not allowed. "
+"Please create a directory and run cmake "
 "from there, passing the path to this source directory as the last argument. "
 "This process created the file `CMakeCache.txt' and the directory "
 "`CMakeFiles'. Please delete them.")
 endif()
 
-if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
-  file(GLOB_RECURSE
-tablegenned_files_on_include_dir
-"${CLANG_SOURCE_DIR}/include/clang/*.inc")
-  if( tablegenned_files_on_include_dir )
-message(FATAL_ERROR "Apparently there is a previous in-source build, "
-"probably as the result of running `configure' and `make' on "
-"${CLANG_SOURCE_DIR}. This may cause problems. The suspicious files are:\n"
-"${tablegenned_files_on_include_dir}\nPlease clean the source directory.")
-  endif()
-endif()
-
 # If CLANG_VERSION_* is specified, use it, if not use LLVM_VERSION_*.
 if(NOT DEFINED CLANG_VERSION_MAJOR)
   set(CLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51714: CMake: Deprecate using llvm-config to detect llvm installation

2018-09-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire accepted this revision.
steveire added a comment.
This revision is now accepted and ready to land.

Brilliant, I've wanted to do this for years, and I still have many improvements 
to the LLVM/Clang cmake files on my todo list. Good to know others are 
similarly motivated.




Comment at: CMakeLists.txt:13
 message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
+message(WARNING "Using llvm-config to detect the LLVM installation is \
+  deprecated.  The installed cmake files should be used \

message(DEPRECATION) is designed for deprecation messages. It announces itself 
as a "CMake Deprecation Warning at CMakeLists.txt:6 (message):".

The user can silence the warning with `-Wno-deprecated` or make it an error 
with `Wdeprecated` since old versions of CMake: 
https://cmake.org/pipermail/cmake-developers/2013-July/019634.html


Repository:
  rC Clang

https://reviews.llvm.org/D51714



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


[PATCH] D51192: Fix reported range of partial token replacement

2018-09-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

How? This is 'private' code. I don't think it's worth changing that or creating 
a test with a huge amount of infrastructure in order to test this indirectly.

Am I missing something?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51192



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


[PATCH] D51192: Fix reported range of partial token replacement

2018-09-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.



In https://reviews.llvm.org/D51192#1226282, @aaron.ballman wrote:

> In https://reviews.llvm.org/D51192#1226257, @steveire wrote:
>
> > How? This is 'private' code. I don't think it's worth changing that or 
> > creating a test with a huge amount of infrastructure in order to test this 
> > indirectly.
>
>
> This is changing the observable behavior of the tool, so it should have tests 
> unless they're impossible to write.


Yes. The current behavior is not tested. I agree that tests are better than no 
tests.

>> Am I missing something?
> 
> I'd probably pipe the diagnostic output to a temporary file that gets 
> FileChecked with strict whitespace to see if the underlines from the 
> diagnostic match the expected locations. We do this in a few Clang tests, 
> like SemaCXX\struct-class-redecl.cpp or Misc\wrong-encoding.c.

Doesn't this require building-in a new check to clang-tidy which exists only 
for the purpose of the test? Otherwise how would a test similar to 
`SemaCXX\struct-class-redecl.cpp` work? What would be in the `RUN` line?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51192



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


[PATCH] D51192: Fix reported range of partial token replacement

2018-09-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

As far as I know, no existing clang-tidy checks are affected. I discovered this 
while implementing a custom check. See 
https://bugs.llvm.org/show_bug.cgi?id=38678

By the way, is there some keyword I should use in commit messages to link to 
bugs properly?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51192



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


[PATCH] D51192: Fix reported range of partial token replacement

2018-09-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Thanks.

The `arc` tool already inserted `Differential Revision:` into my git commit, 
but that's not what I wonder about. I'm looking for something I can insert into 
my git commit so that the bug will automatically be closed when I commit (and 
so that the bug will get a link to this PR when the PR is created). Does such a 
thing exist here?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51192



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


[PATCH] D51192: Fix reported range of partial token replacement

2018-09-06 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE341583: Fix reported range of partial token replacement 
(authored by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51192?vs=163447&id=164275#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51192

Files:
  clang-tidy/ClangTidy.cpp


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -122,10 +122,6 @@
   << Message.Message << Name;
   for (const auto &FileAndReplacements : Error.Fix) {
 for (const auto &Repl : FileAndReplacements.second) {
-  // Retrieve the source range for applicable fixes. Macro definitions
-  // on the command line have locations in a virtual buffer and don't
-  // have valid file paths and are therefore not applicable.
-  SourceRange Range;
   SourceLocation FixLoc;
   ++TotalFixes;
   bool CanBeApplied = false;
@@ -166,7 +162,11 @@
 FixLoc = getLocation(FixAbsoluteFilePath, Repl.getOffset());
 SourceLocation FixEndLoc =
 FixLoc.getLocWithOffset(Repl.getLength());
-Range = SourceRange(FixLoc, FixEndLoc);
+// Retrieve the source range for applicable fixes. Macro 
definitions
+// on the command line have locations in a virtual buffer and don't
+// have valid file paths and are therefore not applicable.
+CharSourceRange Range =
+CharSourceRange::getCharRange(SourceRange(FixLoc, FixEndLoc));
 Diag << FixItHint::CreateReplacement(Range,
  Repl.getReplacementText());
   }


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -122,10 +122,6 @@
   << Message.Message << Name;
   for (const auto &FileAndReplacements : Error.Fix) {
 for (const auto &Repl : FileAndReplacements.second) {
-  // Retrieve the source range for applicable fixes. Macro definitions
-  // on the command line have locations in a virtual buffer and don't
-  // have valid file paths and are therefore not applicable.
-  SourceRange Range;
   SourceLocation FixLoc;
   ++TotalFixes;
   bool CanBeApplied = false;
@@ -166,7 +162,11 @@
 FixLoc = getLocation(FixAbsoluteFilePath, Repl.getOffset());
 SourceLocation FixEndLoc =
 FixLoc.getLocWithOffset(Repl.getLength());
-Range = SourceRange(FixLoc, FixEndLoc);
+// Retrieve the source range for applicable fixes. Macro definitions
+// on the command line have locations in a virtual buffer and don't
+// have valid file paths and are therefore not applicable.
+CharSourceRange Range =
+CharSourceRange::getCharRange(SourceRange(FixLoc, FixEndLoc));
 Diag << FixItHint::CreateReplacement(Range,
  Repl.getReplacementText());
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51865: [clang-tidy] Added a test -export-fixes with relative paths.

2018-09-13 Thread Stephen Kelly via Phabricator via cfe-commits
steveire accepted this revision.
steveire added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51865



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


[PATCH] D49100: Avoid returning an invalid end source loc

2018-07-24 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 157116.
steveire retitled this revision from "Inline DeclarationNameInfo::getLocEnd 
into callers" to "Avoid returning an invalid end source loc".
steveire edited the summary of this revision.

Repository:
  rC Clang

https://reviews.llvm.org/D49100

Files:
  include/clang/AST/DeclarationName.h
  lib/AST/DeclarationName.cpp


Index: lib/AST/DeclarationName.cpp
===
--- lib/AST/DeclarationName.cpp
+++ lib/AST/DeclarationName.cpp
@@ -689,7 +689,7 @@
   llvm_unreachable("Unexpected declaration name kind");
 }
 
-SourceLocation DeclarationNameInfo::getEndLoc() const {
+SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
   switch (Name.getNameKind()) {
   case DeclarationName::Identifier:
   case DeclarationName::CXXDeductionGuideName:
Index: include/clang/AST/DeclarationName.h
===
--- include/clang/AST/DeclarationName.h
+++ include/clang/AST/DeclarationName.h
@@ -558,7 +558,7 @@
   SourceLocation getBeginLoc() const { return NameLoc; }
 
   /// getEndLoc - Retrieve the location of the last token.
-  SourceLocation getEndLoc() const;
+  SourceLocation getEndLoc() const { return getLocEnd(); }
 
   /// getSourceRange - The range of the declaration name.
   SourceRange getSourceRange() const LLVM_READONLY {
@@ -570,9 +570,11 @@
   }
 
   SourceLocation getLocEnd() const LLVM_READONLY {
-SourceLocation EndLoc = getEndLoc();
+SourceLocation EndLoc = getEndLocPrivate();
 return EndLoc.isValid() ? EndLoc : getLocStart();
   }
+private:
+  SourceLocation getEndLocPrivate() const;
 };
 
 /// Insertion operator for diagnostics.  This allows sending DeclarationName's


Index: lib/AST/DeclarationName.cpp
===
--- lib/AST/DeclarationName.cpp
+++ lib/AST/DeclarationName.cpp
@@ -689,7 +689,7 @@
   llvm_unreachable("Unexpected declaration name kind");
 }
 
-SourceLocation DeclarationNameInfo::getEndLoc() const {
+SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
   switch (Name.getNameKind()) {
   case DeclarationName::Identifier:
   case DeclarationName::CXXDeductionGuideName:
Index: include/clang/AST/DeclarationName.h
===
--- include/clang/AST/DeclarationName.h
+++ include/clang/AST/DeclarationName.h
@@ -558,7 +558,7 @@
   SourceLocation getBeginLoc() const { return NameLoc; }
 
   /// getEndLoc - Retrieve the location of the last token.
-  SourceLocation getEndLoc() const;
+  SourceLocation getEndLoc() const { return getLocEnd(); }
 
   /// getSourceRange - The range of the declaration name.
   SourceRange getSourceRange() const LLVM_READONLY {
@@ -570,9 +570,11 @@
   }
 
   SourceLocation getLocEnd() const LLVM_READONLY {
-SourceLocation EndLoc = getEndLoc();
+SourceLocation EndLoc = getEndLocPrivate();
 return EndLoc.isValid() ? EndLoc : getLocStart();
   }
+private:
+  SourceLocation getEndLocPrivate() const;
 };
 
 /// Insertion operator for diagnostics.  This allows sending DeclarationName's
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-07-30 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In https://reviews.llvm.org/D49840#1176405, @klimek wrote:

> Usually we use match(anyOf(node), hasDescendant(node)). Or did I 
> misunderstand what you want?


See http://lists.llvm.org/pipermail/cfe-dev/2018-July/058625.html for a bug 
that prevents this working.


Repository:
  rC Clang

https://reviews.llvm.org/D49840



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


[PATCH] D49100: Avoid returning an invalid end source loc

2018-07-30 Thread Stephen Kelly via Phabricator via cfe-commits
steveire closed this revision.
steveire added a comment.

Committed in SVN revision 338301.


Repository:
  rC Clang

https://reviews.llvm.org/D49100



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


[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

- The scripts will continue to work at least until `set output` is removed, 
which is not going to happen soon.
- A comma-delimited list of options means that if I have `foo, bar, bat`  
enabled and want to add `bang`, I need to `set output foo, bar, bat, bang`. Or 
alternatively if I want to remove `bat`, I need to write out all the others. I 
don't think that's suitable.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

> What's more, given that clang-output has no real documentation to speak of, 
> how will users even *know* to update their scripts?

The release notes will tell them.

But your comment also raises a different point: If there is so little 
clang-query documentation, what justification is there for relying on current 
behavior?

Also, what scripts are you referring to that rely on clang-query? Do we know of 
any that are expected to work long-term without maintenance (unlikely, as the 
AST itself is not stable), or is this concern imagined?

> can you expound on your concerns?

After this patch, the user writes

  set dump-output true

or `false`.

and after the follow-up (https://reviews.llvm.org/D52859) they write

  set matcher-output true

After more features I have in the pipeline they will write other similar 
commands.

With my command-design, if a user wants to enable dump output in addition to 
what they have, they just

  set dump-output true

In your design, they have to recall/find out what options are currently 
enabled, and add them in a comma separated list. That is not user-friendly.

> wonder whether set blah-output options are mutually exclusive or not.

These options are obviously and clearly toggles. There is definitely no reason 
to think that they are mutually exclusive any more than there is reason to 
think `set output dump` is mutually exclusive with `set bind-root false`.

And even if someone did wonder that, they would just try it and learn that they 
are toggles.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-10 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

>   you have to find the right place to stick the `set dump-output true` in 
> order to enable it.

What do you mean "the right place"?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-10 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

> I don't see this functionality being so critical that we need to deprecate 
> the existing spelling when there are backwards compatible options available, 
> which is why I'm opposed to this patch going in with the proposed syntax.

I don't think we're going to go anywhere except around in circles :). I don't 
see your comma separated syntax as viable. Maybe there is a third way that both 
of us don't see.

I tried to catch you on IRC without success. Thanks for the reviews! I 
appreciate your time. I'll see if I can find a different reviewer for this in a 
while.

Thanks,


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 170304.
steveire added a comment.

Rename dump-output to ast-output.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857

Files:
  clang-query/Query.cpp
  clang-query/Query.h
  clang-query/QueryParser.cpp
  clang-query/QuerySession.h
  unittests/clang-query/QueryEngineTest.cpp
  unittests/clang-query/QueryParserTest.cpp

Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -59,6 +59,35 @@
   EXPECT_EQ("unexpected extra input: ' me'", cast(Q)->ErrStr);
 }
 
+TEST_F(QueryParserTest, Deprecated) {
+  QueryRef Q = parse("set output");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
+cast(Q)->ErrStr);
+
+  Q = parse("set output foo");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
+cast(Q)->ErrStr);
+
+  Q = parse("set output dump");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ(&QuerySession::DumpOutput, cast(Q)->Var);
+  std::string Str;
+  llvm::raw_string_ostream OS(Str);
+  Q->run(OS, QS);
+  EXPECT_EQ(true, QS.DumpOutput);
+  EXPECT_EQ(false, QS.DiagOutput);
+  EXPECT_EQ(false, QS.PrintOutput);
+
+  std::vector Comps =
+  QueryParser::complete("", 0, QS);
+  Comps = QueryParser::complete("set o", 5, QS);
+  ASSERT_EQ(1u, Comps.size());
+  EXPECT_EQ("utput ", Comps[0].TypedText);
+  EXPECT_EQ("output", Comps[0].DisplayText);
+}
+
 TEST_F(QueryParserTest, Set) {
   QueryRef Q = parse("set");
   ASSERT_TRUE(isa(Q));
@@ -68,24 +97,24 @@
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unknown variable: 'foo'", cast(Q)->ErrStr);
 
-  Q = parse("set output");
+  Q = parse("set dump-output");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
+  EXPECT_EQ("expected 'true' or 'false', got ''",
 cast(Q)->ErrStr);
 
   Q = parse("set bind-root true foo");
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unexpected extra input: ' foo'", cast(Q)->ErrStr);
 
-  Q = parse("set output foo");
+  Q = parse("set dump-output foo");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
+  EXPECT_EQ("expected 'true' or 'false', got 'foo'",
 cast(Q)->ErrStr);
 
-  Q = parse("set output dump");
-  ASSERT_TRUE(isa >(Q));
-  EXPECT_EQ(&QuerySession::OutKind, cast >(Q)->Var);
-  EXPECT_EQ(OK_Dump, cast >(Q)->Value);
+  Q = parse("set dump-output true");
+  ASSERT_TRUE(isa>(Q));
+  EXPECT_EQ(&QuerySession::DumpOutput, cast>(Q)->Var);
+  EXPECT_EQ(true, cast>(Q)->Value);
 
   Q = parse("set bind-root foo");
   ASSERT_TRUE(isa(Q));
@@ -174,10 +203,16 @@
   EXPECT_EQ("unlet ", Comps[5].TypedText);
   EXPECT_EQ("unlet", Comps[5].DisplayText);
 
-  Comps = QueryParser::complete("set o", 5, QS);
+  Comps = QueryParser::complete("set d", 5, QS);
+  ASSERT_EQ(2u, Comps.size());
+  EXPECT_EQ("ump-output ", Comps[0].TypedText);
+  EXPECT_EQ("dump-output", Comps[0].DisplayText);
+  EXPECT_EQ("iag-output ", Comps[1].TypedText);
+  EXPECT_EQ("diag-output", Comps[1].DisplayText);
+  Comps = QueryParser::complete("set du", 6, QS);
   ASSERT_EQ(1u, Comps.size());
-  EXPECT_EQ("utput ", Comps[0].TypedText);
-  EXPECT_EQ("output", Comps[0].DisplayText);
+  EXPECT_EQ("mp-output ", Comps[0].TypedText);
+  EXPECT_EQ("dump-output", Comps[0].DisplayText);
 
   Comps = QueryParser::complete("match while", 11, QS);
   ASSERT_EQ(1u, Comps.size());
Index: unittests/clang-query/QueryEngineTest.cpp
===
--- unittests/clang-query/QueryEngineTest.cpp
+++ unittests/clang-query/QueryEngineTest.cpp
@@ -48,6 +48,24 @@
   llvm::raw_string_ostream OS;
 };
 
+TEST_F(QueryEngineTest, Deprecated) {
+  DynTypedMatcher FooMatcher = functionDecl(hasName("foo1"));
+
+  EXPECT_TRUE(SetOutputQuery(&QuerySession::PrintOutput).run(OS, S));
+  EXPECT_TRUE(MatchQuery(FooMatcher).run(OS, S));
+
+  EXPECT_TRUE(OS.str().find("Binding for \"root\":\nvoid foo1()") !=
+  std::string::npos);
+
+  Str.clear();
+
+  EXPECT_TRUE(SetOutputQuery(&QuerySession::DumpOutput).run(OS, S));
+  EXPECT_TRUE(MatchQuery(FooMatcher).run(OS, S));
+  EXPECT_TRUE(OS.str().find("FunctionDecl") != std::string::npos);
+
+  Str.clear();
+}
+
 TEST_F(QueryEngineTest, Basic) {
   DynTypedMatcher FnMatcher = functionDecl();
   DynTypedMatcher FooMatcher = functionDecl(hasName("foo1"));
@@ -92,22 +110,36 @@
 
   Str.clear();
 
-  EXPECT_TRUE(
-  SetQuery(&QuerySession::OutKind, OK_Print).run(OS, S));
+  EXPECT_TRUE(SetQuery(&QuerySession::DiagOutput, false).run(OS, S));
+  EXPECT_TRUE(SetQuery(&QuerySession::PrintOutput, true).run(OS, S));
   EXPECT_TRUE(MatchQuery(FooMatcher).run(OS, S));
 
   EXPECT_TRUE(OS.str().find("Binding for \"root\":\nvoid foo1()") !=
   std::string::npos);
 
   Str.clear();
 
-  EXPECT_TRUE(SetQuery(&QuerySession::OutKind, OK_Du

[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 170305.
steveire added a comment.

Fix tests


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857

Files:
  clang-query/Query.cpp
  clang-query/Query.h
  clang-query/QueryParser.cpp
  clang-query/QuerySession.h
  unittests/clang-query/QueryEngineTest.cpp
  unittests/clang-query/QueryParserTest.cpp

Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -59,6 +59,35 @@
   EXPECT_EQ("unexpected extra input: ' me'", cast(Q)->ErrStr);
 }
 
+TEST_F(QueryParserTest, Deprecated) {
+  QueryRef Q = parse("set output");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
+cast(Q)->ErrStr);
+
+  Q = parse("set output foo");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
+cast(Q)->ErrStr);
+
+  Q = parse("set output dump");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ(&QuerySession::DumpOutput, cast(Q)->Var);
+  std::string Str;
+  llvm::raw_string_ostream OS(Str);
+  Q->run(OS, QS);
+  EXPECT_EQ(true, QS.DumpOutput);
+  EXPECT_EQ(false, QS.DiagOutput);
+  EXPECT_EQ(false, QS.PrintOutput);
+
+  std::vector Comps =
+  QueryParser::complete("", 0, QS);
+  Comps = QueryParser::complete("set o", 5, QS);
+  ASSERT_EQ(1u, Comps.size());
+  EXPECT_EQ("utput ", Comps[0].TypedText);
+  EXPECT_EQ("output", Comps[0].DisplayText);
+}
+
 TEST_F(QueryParserTest, Set) {
   QueryRef Q = parse("set");
   ASSERT_TRUE(isa(Q));
@@ -68,24 +97,24 @@
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unknown variable: 'foo'", cast(Q)->ErrStr);
 
-  Q = parse("set output");
+  Q = parse("set ast-output");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
+  EXPECT_EQ("expected 'true' or 'false', got ''",
 cast(Q)->ErrStr);
 
   Q = parse("set bind-root true foo");
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unexpected extra input: ' foo'", cast(Q)->ErrStr);
 
-  Q = parse("set output foo");
+  Q = parse("set ast-output foo");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
+  EXPECT_EQ("expected 'true' or 'false', got 'foo'",
 cast(Q)->ErrStr);
 
-  Q = parse("set output dump");
-  ASSERT_TRUE(isa >(Q));
-  EXPECT_EQ(&QuerySession::OutKind, cast >(Q)->Var);
-  EXPECT_EQ(OK_Dump, cast >(Q)->Value);
+  Q = parse("set ast-output true");
+  ASSERT_TRUE(isa>(Q));
+  EXPECT_EQ(&QuerySession::DumpOutput, cast>(Q)->Var);
+  EXPECT_EQ(true, cast>(Q)->Value);
 
   Q = parse("set bind-root foo");
   ASSERT_TRUE(isa(Q));
@@ -174,10 +203,16 @@
   EXPECT_EQ("unlet ", Comps[5].TypedText);
   EXPECT_EQ("unlet", Comps[5].DisplayText);
 
-  Comps = QueryParser::complete("set o", 5, QS);
+  Comps = QueryParser::complete("set d", 5, QS);
+  ASSERT_EQ(2u, Comps.size());
+  EXPECT_EQ("ump-output ", Comps[0].TypedText);
+  EXPECT_EQ("ast-output", Comps[0].DisplayText);
+  EXPECT_EQ("iag-output ", Comps[1].TypedText);
+  EXPECT_EQ("diag-output", Comps[1].DisplayText);
+  Comps = QueryParser::complete("set du", 6, QS);
   ASSERT_EQ(1u, Comps.size());
-  EXPECT_EQ("utput ", Comps[0].TypedText);
-  EXPECT_EQ("output", Comps[0].DisplayText);
+  EXPECT_EQ("mp-output ", Comps[0].TypedText);
+  EXPECT_EQ("ast-output", Comps[0].DisplayText);
 
   Comps = QueryParser::complete("match while", 11, QS);
   ASSERT_EQ(1u, Comps.size());
Index: unittests/clang-query/QueryEngineTest.cpp
===
--- unittests/clang-query/QueryEngineTest.cpp
+++ unittests/clang-query/QueryEngineTest.cpp
@@ -48,6 +48,24 @@
   llvm::raw_string_ostream OS;
 };
 
+TEST_F(QueryEngineTest, Deprecated) {
+  DynTypedMatcher FooMatcher = functionDecl(hasName("foo1"));
+
+  EXPECT_TRUE(SetOutputQuery(&QuerySession::PrintOutput).run(OS, S));
+  EXPECT_TRUE(MatchQuery(FooMatcher).run(OS, S));
+
+  EXPECT_TRUE(OS.str().find("Binding for \"root\":\nvoid foo1()") !=
+  std::string::npos);
+
+  Str.clear();
+
+  EXPECT_TRUE(SetOutputQuery(&QuerySession::ASTOutput).run(OS, S));
+  EXPECT_TRUE(MatchQuery(FooMatcher).run(OS, S));
+  EXPECT_TRUE(OS.str().find("FunctionDecl") != std::string::npos);
+
+  Str.clear();
+}
+
 TEST_F(QueryEngineTest, Basic) {
   DynTypedMatcher FnMatcher = functionDecl();
   DynTypedMatcher FooMatcher = functionDecl(hasName("foo1"));
@@ -92,22 +110,36 @@
 
   Str.clear();
 
-  EXPECT_TRUE(
-  SetQuery(&QuerySession::OutKind, OK_Print).run(OS, S));
+  EXPECT_TRUE(SetQuery(&QuerySession::DiagOutput, false).run(OS, S));
+  EXPECT_TRUE(SetQuery(&QuerySession::PrintOutput, true).run(OS, S));
   EXPECT_TRUE(MatchQuery(FooMatcher).run(OS, S));
 
   EXPECT_TRUE(OS.str().find("Binding for \"root\":\nvoid foo1()") !=
   std::string::npos);
 
   Str.clear();
 
-  EXPECT_TRUE(SetQuery(&QuerySession::OutKind, OK_Dump).run(OS, S));
+  EXPECT_TRU

[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 170306.
steveire added a comment.

Fix test


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857

Files:
  clang-query/Query.cpp
  clang-query/Query.h
  clang-query/QueryParser.cpp
  clang-query/QuerySession.h
  unittests/clang-query/QueryEngineTest.cpp
  unittests/clang-query/QueryParserTest.cpp

Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -59,6 +59,35 @@
   EXPECT_EQ("unexpected extra input: ' me'", cast(Q)->ErrStr);
 }
 
+TEST_F(QueryParserTest, Deprecated) {
+  QueryRef Q = parse("set output");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
+cast(Q)->ErrStr);
+
+  Q = parse("set output foo");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
+cast(Q)->ErrStr);
+
+  Q = parse("set output dump");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ(&QuerySession::DumpOutput, cast(Q)->Var);
+  std::string Str;
+  llvm::raw_string_ostream OS(Str);
+  Q->run(OS, QS);
+  EXPECT_EQ(true, QS.DumpOutput);
+  EXPECT_EQ(false, QS.DiagOutput);
+  EXPECT_EQ(false, QS.PrintOutput);
+
+  std::vector Comps =
+  QueryParser::complete("", 0, QS);
+  Comps = QueryParser::complete("set o", 5, QS);
+  ASSERT_EQ(1u, Comps.size());
+  EXPECT_EQ("utput ", Comps[0].TypedText);
+  EXPECT_EQ("output", Comps[0].DisplayText);
+}
+
 TEST_F(QueryParserTest, Set) {
   QueryRef Q = parse("set");
   ASSERT_TRUE(isa(Q));
@@ -68,24 +97,24 @@
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unknown variable: 'foo'", cast(Q)->ErrStr);
 
-  Q = parse("set output");
+  Q = parse("set ast-output");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
+  EXPECT_EQ("expected 'true' or 'false', got ''",
 cast(Q)->ErrStr);
 
   Q = parse("set bind-root true foo");
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unexpected extra input: ' foo'", cast(Q)->ErrStr);
 
-  Q = parse("set output foo");
+  Q = parse("set ast-output foo");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
+  EXPECT_EQ("expected 'true' or 'false', got 'foo'",
 cast(Q)->ErrStr);
 
-  Q = parse("set output dump");
-  ASSERT_TRUE(isa >(Q));
-  EXPECT_EQ(&QuerySession::OutKind, cast >(Q)->Var);
-  EXPECT_EQ(OK_Dump, cast >(Q)->Value);
+  Q = parse("set ast-output true");
+  ASSERT_TRUE(isa>(Q));
+  EXPECT_EQ(&QuerySession::DumpOutput, cast>(Q)->Var);
+  EXPECT_EQ(true, cast>(Q)->Value);
 
   Q = parse("set bind-root foo");
   ASSERT_TRUE(isa(Q));
@@ -174,10 +203,14 @@
   EXPECT_EQ("unlet ", Comps[5].TypedText);
   EXPECT_EQ("unlet", Comps[5].DisplayText);
 
-  Comps = QueryParser::complete("set o", 5, QS);
+  Comps = QueryParser::complete("set d", 5, QS);
   ASSERT_EQ(1u, Comps.size());
-  EXPECT_EQ("utput ", Comps[0].TypedText);
-  EXPECT_EQ("output", Comps[0].DisplayText);
+  EXPECT_EQ("iag-output ", Comps[1].TypedText);
+  EXPECT_EQ("diag-output", Comps[1].DisplayText);
+  Comps = QueryParser::complete("set a", 6, QS);
+  ASSERT_EQ(1u, Comps.size());
+  EXPECT_EQ("st-output ", Comps[0].TypedText);
+  EXPECT_EQ("ast-output", Comps[0].DisplayText);
 
   Comps = QueryParser::complete("match while", 11, QS);
   ASSERT_EQ(1u, Comps.size());
Index: unittests/clang-query/QueryEngineTest.cpp
===
--- unittests/clang-query/QueryEngineTest.cpp
+++ unittests/clang-query/QueryEngineTest.cpp
@@ -48,6 +48,24 @@
   llvm::raw_string_ostream OS;
 };
 
+TEST_F(QueryEngineTest, Deprecated) {
+  DynTypedMatcher FooMatcher = functionDecl(hasName("foo1"));
+
+  EXPECT_TRUE(SetOutputQuery(&QuerySession::PrintOutput).run(OS, S));
+  EXPECT_TRUE(MatchQuery(FooMatcher).run(OS, S));
+
+  EXPECT_TRUE(OS.str().find("Binding for \"root\":\nvoid foo1()") !=
+  std::string::npos);
+
+  Str.clear();
+
+  EXPECT_TRUE(SetOutputQuery(&QuerySession::ASTOutput).run(OS, S));
+  EXPECT_TRUE(MatchQuery(FooMatcher).run(OS, S));
+  EXPECT_TRUE(OS.str().find("FunctionDecl") != std::string::npos);
+
+  Str.clear();
+}
+
 TEST_F(QueryEngineTest, Basic) {
   DynTypedMatcher FnMatcher = functionDecl();
   DynTypedMatcher FooMatcher = functionDecl(hasName("foo1"));
@@ -92,22 +110,36 @@
 
   Str.clear();
 
-  EXPECT_TRUE(
-  SetQuery(&QuerySession::OutKind, OK_Print).run(OS, S));
+  EXPECT_TRUE(SetQuery(&QuerySession::DiagOutput, false).run(OS, S));
+  EXPECT_TRUE(SetQuery(&QuerySession::PrintOutput, true).run(OS, S));
   EXPECT_TRUE(MatchQuery(FooMatcher).run(OS, S));
 
   EXPECT_TRUE(OS.str().find("Binding for \"root\":\nvoid foo1()") !=
   std::string::npos);
 
   Str.clear();
 
-  EXPECT_TRUE(SetQuery(&QuerySession::OutKind, OK_Dump).run(OS, S));
+  EXPECT_TRUE(SetQuery(&QuerySession::PrintOutput, false).run(OS, S));
+  EXPECT_TRUE(SetQuery(&QuerySession::AST

[PATCH] D52859: [clang-query] Add option to print matcher expression

2018-10-20 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344840: [clang-query] Add option to print matcher expression 
(authored by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52859?vs=168219&id=170307#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52859

Files:
  clang-tools-extra/trunk/clang-query/Query.cpp
  clang-tools-extra/trunk/clang-query/Query.h
  clang-tools-extra/trunk/clang-query/QueryParser.cpp
  clang-tools-extra/trunk/clang-query/QuerySession.h
  clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp

Index: clang-tools-extra/trunk/clang-query/QueryParser.cpp
===
--- clang-tools-extra/trunk/clang-query/QueryParser.cpp
+++ clang-tools-extra/trunk/clang-query/QueryParser.cpp
@@ -142,7 +142,12 @@
   PQK_Quit
 };
 
-enum ParsedQueryVariable { PQV_Invalid, PQV_Output, PQV_BindRoot };
+enum ParsedQueryVariable {
+  PQV_Invalid,
+  PQV_Output,
+  PQV_BindRoot,
+  PQV_PrintMatcher
+};
 
 QueryRef makeInvalidQueryFromDiagnostics(const Diagnostics &Diag) {
   std::string ErrStr;
@@ -214,21 +219,23 @@
   return completeMatcherExpression();
 
 Diagnostics Diag;
+auto MatcherSource = StringRef(Begin, End - Begin).trim();
 Optional Matcher = Parser::parseMatcherExpression(
-StringRef(Begin, End - Begin), nullptr, &QS.NamedValues, &Diag);
+MatcherSource, nullptr, &QS.NamedValues, &Diag);
 if (!Matcher) {
   return makeInvalidQueryFromDiagnostics(Diag);
 }
-return new MatchQuery(*Matcher);
+return new MatchQuery(MatcherSource, *Matcher);
   }
 
   case PQK_Set: {
 StringRef VarStr;
-ParsedQueryVariable Var = LexOrCompleteWord(this,
- VarStr)
-  .Case("output", PQV_Output)
-  .Case("bind-root", PQV_BindRoot)
-  .Default(PQV_Invalid);
+ParsedQueryVariable Var =
+LexOrCompleteWord(this, VarStr)
+.Case("output", PQV_Output)
+.Case("bind-root", PQV_BindRoot)
+.Case("print-matcher", PQV_PrintMatcher)
+.Default(PQV_Invalid);
 if (VarStr.empty())
   return new InvalidQuery("expected variable name");
 if (Var == PQV_Invalid)
@@ -242,6 +249,9 @@
 case PQV_BindRoot:
   Q = parseSetBool(&QuerySession::BindRoot);
   break;
+case PQV_PrintMatcher:
+  Q = parseSetBool(&QuerySession::PrintMatcher);
+  break;
 case PQV_Invalid:
   llvm_unreachable("Invalid query kind");
 }
Index: clang-tools-extra/trunk/clang-query/QuerySession.h
===
--- clang-tools-extra/trunk/clang-query/QuerySession.h
+++ clang-tools-extra/trunk/clang-query/QuerySession.h
@@ -25,11 +25,13 @@
 class QuerySession {
 public:
   QuerySession(llvm::ArrayRef> ASTs)
-  : ASTs(ASTs), OutKind(OK_Diag), BindRoot(true), Terminate(false) {}
+  : ASTs(ASTs), OutKind(OK_Diag), BindRoot(true), PrintMatcher(false),
+Terminate(false) {}
 
   llvm::ArrayRef> ASTs;
   OutputKind OutKind;
   bool BindRoot;
+  bool PrintMatcher;
   bool Terminate;
   llvm::StringMap NamedValues;
 };
Index: clang-tools-extra/trunk/clang-query/Query.h
===
--- clang-tools-extra/trunk/clang-query/Query.h
+++ clang-tools-extra/trunk/clang-query/Query.h
@@ -83,12 +83,15 @@
 
 /// Query for "match MATCHER".
 struct MatchQuery : Query {
-  MatchQuery(const ast_matchers::dynamic::DynTypedMatcher &Matcher)
-  : Query(QK_Match), Matcher(Matcher) {}
+  MatchQuery(StringRef Source,
+ const ast_matchers::dynamic::DynTypedMatcher &Matcher)
+  : Query(QK_Match), Matcher(Matcher), Source(Source) {}
   bool run(llvm::raw_ostream &OS, QuerySession &QS) const override;
 
   ast_matchers::dynamic::DynTypedMatcher Matcher;
 
+  StringRef Source;
+
   static bool classof(const Query *Q) { return Q->Kind == QK_Match; }
 };
 
Index: clang-tools-extra/trunk/clang-query/Query.cpp
===
--- clang-tools-extra/trunk/clang-query/Query.cpp
+++ clang-tools-extra/trunk/clang-query/Query.cpp
@@ -41,6 +41,8 @@
 "as part of other expressions.\n"
 "  set bind-root (true|false)"
 "Set whether to bind the root matcher to \"root\".\n"
+"  set print-matcher (true|false)"
+"Set whether to print the current matcher,\n"
 "  set output (diag|print|dump)  "
 "Set whether to print bindings as diagnostics,\n"
 ""
@@ -86,6 +88,12 @@
 }
 Finder.matchAST(AST->getASTContext());
 
+if (QS.PrintMatcher) {
+  std::string prefixText = "Matcher: ";
+  OS << "\n  " << prefixTex

[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 170308.
steveire added a comment.

Update test


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857

Files:
  clang-query/Query.cpp
  clang-query/Query.h
  clang-query/QueryParser.cpp
  clang-query/QuerySession.h
  unittests/clang-query/QueryEngineTest.cpp
  unittests/clang-query/QueryParserTest.cpp

Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -59,6 +59,35 @@
   EXPECT_EQ("unexpected extra input: ' me'", cast(Q)->ErrStr);
 }
 
+TEST_F(QueryParserTest, Deprecated) {
+  QueryRef Q = parse("set output");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
+cast(Q)->ErrStr);
+
+  Q = parse("set output foo");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
+cast(Q)->ErrStr);
+
+  Q = parse("set output dump");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ(&QuerySession::ASTOutput, cast(Q)->Var);
+  std::string Str;
+  llvm::raw_string_ostream OS(Str);
+  Q->run(OS, QS);
+  EXPECT_EQ(true, QS.ASTOutput);
+  EXPECT_EQ(false, QS.DiagOutput);
+  EXPECT_EQ(false, QS.PrintOutput);
+
+  std::vector Comps =
+  QueryParser::complete("", 0, QS);
+  Comps = QueryParser::complete("set o", 5, QS);
+  ASSERT_EQ(1u, Comps.size());
+  EXPECT_EQ("utput ", Comps[0].TypedText);
+  EXPECT_EQ("output", Comps[0].DisplayText);
+}
+
 TEST_F(QueryParserTest, Set) {
   QueryRef Q = parse("set");
   ASSERT_TRUE(isa(Q));
@@ -68,24 +97,24 @@
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unknown variable: 'foo'", cast(Q)->ErrStr);
 
-  Q = parse("set output");
+  Q = parse("set ast-output");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
+  EXPECT_EQ("expected 'true' or 'false', got ''",
 cast(Q)->ErrStr);
 
   Q = parse("set bind-root true foo");
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unexpected extra input: ' foo'", cast(Q)->ErrStr);
 
-  Q = parse("set output foo");
+  Q = parse("set ast-output foo");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
+  EXPECT_EQ("expected 'true' or 'false', got 'foo'",
 cast(Q)->ErrStr);
 
-  Q = parse("set output dump");
-  ASSERT_TRUE(isa >(Q));
-  EXPECT_EQ(&QuerySession::OutKind, cast >(Q)->Var);
-  EXPECT_EQ(OK_Dump, cast >(Q)->Value);
+  Q = parse("set ast-output true");
+  ASSERT_TRUE(isa>(Q));
+  EXPECT_EQ(&QuerySession::ASTOutput, cast>(Q)->Var);
+  EXPECT_EQ(true, cast>(Q)->Value);
 
   Q = parse("set bind-root foo");
   ASSERT_TRUE(isa(Q));
@@ -174,10 +203,14 @@
   EXPECT_EQ("unlet ", Comps[5].TypedText);
   EXPECT_EQ("unlet", Comps[5].DisplayText);
 
-  Comps = QueryParser::complete("set o", 5, QS);
+  Comps = QueryParser::complete("set d", 5, QS);
   ASSERT_EQ(1u, Comps.size());
-  EXPECT_EQ("utput ", Comps[0].TypedText);
-  EXPECT_EQ("output", Comps[0].DisplayText);
+  EXPECT_EQ("iag-output ", Comps[0].TypedText);
+  EXPECT_EQ("diag-output", Comps[0].DisplayText);
+  Comps = QueryParser::complete("set a", 5, QS);
+  ASSERT_EQ(1u, Comps.size());
+  EXPECT_EQ("st-output ", Comps[0].TypedText);
+  EXPECT_EQ("ast-output", Comps[0].DisplayText);
 
   Comps = QueryParser::complete("match while", 11, QS);
   ASSERT_EQ(1u, Comps.size());
Index: unittests/clang-query/QueryEngineTest.cpp
===
--- unittests/clang-query/QueryEngineTest.cpp
+++ unittests/clang-query/QueryEngineTest.cpp
@@ -48,6 +48,24 @@
   llvm::raw_string_ostream OS;
 };
 
+TEST_F(QueryEngineTest, Deprecated) {
+  DynTypedMatcher FooMatcher = functionDecl(hasName("foo1"));
+
+  EXPECT_TRUE(SetOutputQuery(&QuerySession::PrintOutput).run(OS, S));
+  EXPECT_TRUE(MatchQuery("functionDecl(hasName(\"foo1\"))", FooMatcher).run(OS, S));
+
+  EXPECT_TRUE(OS.str().find("Binding for \"root\":\nvoid foo1()") !=
+  std::string::npos);
+
+  Str.clear();
+
+  EXPECT_TRUE(SetOutputQuery(&QuerySession::ASTOutput).run(OS, S));
+  EXPECT_TRUE(MatchQuery("functionDecl(hasName(\"foo1\"))", FooMatcher).run(OS, S));
+  EXPECT_TRUE(OS.str().find("FunctionDecl") != std::string::npos);
+
+  Str.clear();
+}
+
 TEST_F(QueryEngineTest, Basic) {
   DynTypedMatcher FnMatcher = functionDecl();
   DynTypedMatcher FooMatcher = functionDecl(hasName("foo1"));
@@ -94,22 +112,36 @@
 
   Str.clear();
 
-  EXPECT_TRUE(
-  SetQuery(&QuerySession::OutKind, OK_Print).run(OS, S));
+  EXPECT_TRUE(SetQuery(&QuerySession::DiagOutput, false).run(OS, S));
+  EXPECT_TRUE(SetQuery(&QuerySession::PrintOutput, true).run(OS, S));
   EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
 
   EXPECT_TRUE(OS.str().find("Binding for \"root\":\nvoid foo1()") !=
   std::string::npos);
 
   Str.clear();
 
-  EXPECT_TRUE(SetQuery(&QuerySession::OutKind, OK_Dump).run(OS, S));
+  EXPECT_TRUE(SetQuery(&Q

[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Perhaps the best solution is to introduce this new API, but not deprecate the 
existing 'exclusive' API.

What do you think?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 170310.
steveire added a comment.

Don't deprecate existing API


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857

Files:
  clang-query/Query.cpp
  clang-query/Query.h
  clang-query/QueryParser.cpp
  clang-query/QuerySession.h
  unittests/clang-query/QueryEngineTest.cpp
  unittests/clang-query/QueryParserTest.cpp

Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -59,6 +59,35 @@
   EXPECT_EQ("unexpected extra input: ' me'", cast(Q)->ErrStr);
 }
 
+TEST_F(QueryParserTest, Exclusive) {
+  QueryRef Q = parse("set output");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
+cast(Q)->ErrStr);
+
+  Q = parse("set output foo");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
+cast(Q)->ErrStr);
+
+  Q = parse("set output dump");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ(&QuerySession::ASTOutput, cast(Q)->Var);
+  std::string Str;
+  llvm::raw_string_ostream OS(Str);
+  Q->run(OS, QS);
+  EXPECT_EQ(true, QS.ASTOutput);
+  EXPECT_EQ(false, QS.DiagOutput);
+  EXPECT_EQ(false, QS.PrintOutput);
+
+  std::vector Comps =
+  QueryParser::complete("", 0, QS);
+  Comps = QueryParser::complete("set o", 5, QS);
+  ASSERT_EQ(1u, Comps.size());
+  EXPECT_EQ("utput ", Comps[0].TypedText);
+  EXPECT_EQ("output", Comps[0].DisplayText);
+}
+
 TEST_F(QueryParserTest, Set) {
   QueryRef Q = parse("set");
   ASSERT_TRUE(isa(Q));
@@ -68,24 +97,24 @@
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unknown variable: 'foo'", cast(Q)->ErrStr);
 
-  Q = parse("set output");
+  Q = parse("set ast-output");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
+  EXPECT_EQ("expected 'true' or 'false', got ''",
 cast(Q)->ErrStr);
 
   Q = parse("set bind-root true foo");
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unexpected extra input: ' foo'", cast(Q)->ErrStr);
 
-  Q = parse("set output foo");
+  Q = parse("set ast-output foo");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
+  EXPECT_EQ("expected 'true' or 'false', got 'foo'",
 cast(Q)->ErrStr);
 
-  Q = parse("set output dump");
-  ASSERT_TRUE(isa >(Q));
-  EXPECT_EQ(&QuerySession::OutKind, cast >(Q)->Var);
-  EXPECT_EQ(OK_Dump, cast >(Q)->Value);
+  Q = parse("set ast-output true");
+  ASSERT_TRUE(isa>(Q));
+  EXPECT_EQ(&QuerySession::ASTOutput, cast>(Q)->Var);
+  EXPECT_EQ(true, cast>(Q)->Value);
 
   Q = parse("set bind-root foo");
   ASSERT_TRUE(isa(Q));
@@ -174,10 +203,14 @@
   EXPECT_EQ("unlet ", Comps[5].TypedText);
   EXPECT_EQ("unlet", Comps[5].DisplayText);
 
-  Comps = QueryParser::complete("set o", 5, QS);
+  Comps = QueryParser::complete("set d", 5, QS);
   ASSERT_EQ(1u, Comps.size());
-  EXPECT_EQ("utput ", Comps[0].TypedText);
-  EXPECT_EQ("output", Comps[0].DisplayText);
+  EXPECT_EQ("iag-output ", Comps[0].TypedText);
+  EXPECT_EQ("diag-output", Comps[0].DisplayText);
+  Comps = QueryParser::complete("set a", 5, QS);
+  ASSERT_EQ(1u, Comps.size());
+  EXPECT_EQ("st-output ", Comps[0].TypedText);
+  EXPECT_EQ("ast-output", Comps[0].DisplayText);
 
   Comps = QueryParser::complete("match while", 11, QS);
   ASSERT_EQ(1u, Comps.size());
Index: unittests/clang-query/QueryEngineTest.cpp
===
--- unittests/clang-query/QueryEngineTest.cpp
+++ unittests/clang-query/QueryEngineTest.cpp
@@ -48,6 +48,24 @@
   llvm::raw_string_ostream OS;
 };
 
+TEST_F(QueryEngineTest, Exclusive) {
+  DynTypedMatcher FooMatcher = functionDecl(hasName("foo1"));
+
+  EXPECT_TRUE(SetOutputQuery(&QuerySession::PrintOutput).run(OS, S));
+  EXPECT_TRUE(MatchQuery("functionDecl(hasName(\"foo1\"))", FooMatcher).run(OS, S));
+
+  EXPECT_TRUE(OS.str().find("Binding for \"root\":\nvoid foo1()") !=
+  std::string::npos);
+
+  Str.clear();
+
+  EXPECT_TRUE(SetOutputQuery(&QuerySession::ASTOutput).run(OS, S));
+  EXPECT_TRUE(MatchQuery("functionDecl(hasName(\"foo1\"))", FooMatcher).run(OS, S));
+  EXPECT_TRUE(OS.str().find("FunctionDecl") != std::string::npos);
+
+  Str.clear();
+}
+
 TEST_F(QueryEngineTest, Basic) {
   DynTypedMatcher FnMatcher = functionDecl();
   DynTypedMatcher FooMatcher = functionDecl(hasName("foo1"));
@@ -94,22 +112,36 @@
 
   Str.clear();
 
-  EXPECT_TRUE(
-  SetQuery(&QuerySession::OutKind, OK_Print).run(OS, S));
+  EXPECT_TRUE(SetQuery(&QuerySession::DiagOutput, false).run(OS, S));
+  EXPECT_TRUE(SetQuery(&QuerySession::PrintOutput, true).run(OS, S));
   EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
 
   EXPECT_TRUE(OS.str().find("Binding for \"root\":\nvoid foo1()") !=
   std::string::npos);
 
   Str.clear();
 
-  EXPECT_TRUE(SetQuery(&QuerySession::OutKind, OK_Dump).run(OS, S));
+  EXPECT_T

[PATCH] D53498: Re-word command help for clang-query

2018-10-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

This will make it possible to easily

- Add new commands which accept  parameters
- Extend the list of features


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53498

Files:
  clang-query/Query.cpp


Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -43,12 +43,17 @@
 "Set whether to bind the root matcher to \"root\".\n"
 "  set print-matcher (true|false)"
 "Set whether to print the current matcher,\n"
-"  set output (diag|print|dump)  "
-"Set whether to print bindings as diagnostics,\n"
-""
-"AST pretty prints or AST dumps.\n"
+"  set output   "
+"Set whether to output only  content.\n"
 "  quit, q   "
-"Terminates the query session.\n\n";
+"Terminates the query session.\n\n"
+"Several commands accept a  parameter. The available features 
are:\n\n"
+"  print "
+"pretty-print bound nodes\n"
+"  diag  "
+"diagnostic location for bound nodes\n"
+"  dump  "
+"Detailed AST output for bound nodes\n\n";
   return true;
 }
 


Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -43,12 +43,17 @@
 "Set whether to bind the root matcher to \"root\".\n"
 "  set print-matcher (true|false)"
 "Set whether to print the current matcher,\n"
-"  set output (diag|print|dump)  "
-"Set whether to print bindings as diagnostics,\n"
-""
-"AST pretty prints or AST dumps.\n"
+"  set output   "
+"Set whether to output only  content.\n"
 "  quit, q   "
-"Terminates the query session.\n\n";
+"Terminates the query session.\n\n"
+"Several commands accept a  parameter. The available features are:\n\n"
+"  print "
+"pretty-print bound nodes\n"
+"  diag  "
+"diagnostic location for bound nodes\n"
+"  dump  "
+"Detailed AST output for bound nodes\n\n";
   return true;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53500: Add 'detailed-ast' output as an alias for 'dump'

2018-10-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

Future development can then dump other content than AST.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53500

Files:
  clang-query/Query.cpp
  clang-query/Query.h
  clang-query/QueryParser.cpp


Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -111,10 +111,11 @@
   unsigned OutKind = LexOrCompleteWord(this, ValStr)
  .Case("diag", OK_Diag)
  .Case("print", OK_Print)
- .Case("dump", OK_Dump)
+ .Case("detailed-ast", OK_DetailedAST)
+ .Case("dump", OK_DetailedAST)
  .Default(~0u);
   if (OutKind == ~0u) {
-return new InvalidQuery("expected 'diag', 'print' or 'dump', got '" +
+return new InvalidQuery("expected 'diag', 'print', 'detailed-ast' or 
'dump', got '" +
 ValStr + "'");
   }
   return new SetQuery(&QuerySession::OutKind, OutputKind(OutKind));
Index: clang-query/Query.h
===
--- clang-query/Query.h
+++ clang-query/Query.h
@@ -18,7 +18,7 @@
 namespace clang {
 namespace query {
 
-enum OutputKind { OK_Diag, OK_Print, OK_Dump };
+enum OutputKind { OK_Diag, OK_Print, OK_DetailedAST };
 
 enum QueryKind {
   QK_Invalid,
Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -52,8 +52,10 @@
 "pretty-print bound nodes\n"
 "  diag  "
 "diagnostic location for bound nodes\n"
+"  detailed-ast  "
+"Detailed AST output for bound nodes\n"
 "  dump  "
-"Detailed AST output for bound nodes\n\n";
+"Detailed AST output for bound nodes (alias of deatiled-ast)\n\n";
   return true;
 }
 
@@ -123,7 +125,7 @@
   OS << "\n";
   break;
 }
-case OK_Dump: {
+case OK_DetailedAST: {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.dump(OS, AST->getSourceManager());
   OS << "\n";


Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -111,10 +111,11 @@
   unsigned OutKind = LexOrCompleteWord(this, ValStr)
  .Case("diag", OK_Diag)
  .Case("print", OK_Print)
- .Case("dump", OK_Dump)
+ .Case("detailed-ast", OK_DetailedAST)
+ .Case("dump", OK_DetailedAST)
  .Default(~0u);
   if (OutKind == ~0u) {
-return new InvalidQuery("expected 'diag', 'print' or 'dump', got '" +
+return new InvalidQuery("expected 'diag', 'print', 'detailed-ast' or 'dump', got '" +
 ValStr + "'");
   }
   return new SetQuery(&QuerySession::OutKind, OutputKind(OutKind));
Index: clang-query/Query.h
===
--- clang-query/Query.h
+++ clang-query/Query.h
@@ -18,7 +18,7 @@
 namespace clang {
 namespace query {
 
-enum OutputKind { OK_Diag, OK_Print, OK_Dump };
+enum OutputKind { OK_Diag, OK_Print, OK_DetailedAST };
 
 enum QueryKind {
   QK_Invalid,
Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -52,8 +52,10 @@
 "pretty-print bound nodes\n"
 "  diag  "
 "diagnostic location for bound nodes\n"
+"  detailed-ast  "
+"Detailed AST output for bound nodes\n"
 "  dump  "
-"Detailed AST output for bound nodes\n\n";
+"Detailed AST output for bound nodes (alias of deatiled-ast)\n\n";
   return true;
 }
 
@@ -123,7 +125,7 @@
   OS << "\n";
   break;
 }
-case OK_Dump: {
+case OK_DetailedAST: {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.dump(OS, AST->getSourceManager());
   OS << "\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53498: Re-word command help for clang-query

2018-10-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 170419.
steveire added a comment.

Format


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53498

Files:
  clang-query/Query.cpp


Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -43,12 +43,18 @@
 "Set whether to bind the root matcher to \"root\".\n"
 "  set print-matcher (true|false)"
 "Set whether to print the current matcher,\n"
-"  set output (diag|print|dump)  "
-"Set whether to print bindings as diagnostics,\n"
-""
-"AST pretty prints or AST dumps.\n"
+"  set output   "
+"Set whether to output only  content.\n"
 "  quit, q   "
-"Terminates the query session.\n\n";
+"Terminates the query session.\n\n"
+"Several commands accept a  parameter. The available features 
"
+"are:\n\n"
+"  print "
+"pretty-print bound nodes\n"
+"  diag  "
+"diagnostic location for bound nodes\n"
+"  dump  "
+"Detailed AST output for bound nodes\n\n";
   return true;
 }
 


Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -43,12 +43,18 @@
 "Set whether to bind the root matcher to \"root\".\n"
 "  set print-matcher (true|false)"
 "Set whether to print the current matcher,\n"
-"  set output (diag|print|dump)  "
-"Set whether to print bindings as diagnostics,\n"
-""
-"AST pretty prints or AST dumps.\n"
+"  set output   "
+"Set whether to output only  content.\n"
 "  quit, q   "
-"Terminates the query session.\n\n";
+"Terminates the query session.\n\n"
+"Several commands accept a  parameter. The available features "
+"are:\n\n"
+"  print "
+"pretty-print bound nodes\n"
+"  diag  "
+"diagnostic location for bound nodes\n"
+"  dump  "
+"Detailed AST output for bound nodes\n\n";
   return true;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53500: Add 'detailed-ast' output as an alias for 'dump'

2018-10-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 170420.
steveire added a comment.

Format


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53500

Files:
  clang-query/Query.cpp
  clang-query/Query.h
  clang-query/QueryParser.cpp


Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -111,11 +111,13 @@
   unsigned OutKind = LexOrCompleteWord(this, ValStr)
  .Case("diag", OK_Diag)
  .Case("print", OK_Print)
- .Case("dump", OK_Dump)
+ .Case("detailed-ast", OK_DetailedAST)
+ .Case("dump", OK_DetailedAST)
  .Default(~0u);
   if (OutKind == ~0u) {
-return new InvalidQuery("expected 'diag', 'print' or 'dump', got '" +
-ValStr + "'");
+return new InvalidQuery(
+"expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
+"'");
   }
   return new SetQuery(&QuerySession::OutKind, OutputKind(OutKind));
 }
Index: clang-query/Query.h
===
--- clang-query/Query.h
+++ clang-query/Query.h
@@ -18,7 +18,7 @@
 namespace clang {
 namespace query {
 
-enum OutputKind { OK_Diag, OK_Print, OK_Dump };
+enum OutputKind { OK_Diag, OK_Print, OK_DetailedAST };
 
 enum QueryKind {
   QK_Invalid,
Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -53,8 +53,10 @@
 "pretty-print bound nodes\n"
 "  diag  "
 "diagnostic location for bound nodes\n"
+"  detailed-ast  "
+"Detailed AST output for bound nodes\n"
 "  dump  "
-"Detailed AST output for bound nodes\n\n";
+"Detailed AST output for bound nodes (alias of deatiled-ast)\n\n";
   return true;
 }
 
@@ -124,7 +126,7 @@
   OS << "\n";
   break;
 }
-case OK_Dump: {
+case OK_DetailedAST: {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.dump(OS, AST->getSourceManager());
   OS << "\n";


Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -111,11 +111,13 @@
   unsigned OutKind = LexOrCompleteWord(this, ValStr)
  .Case("diag", OK_Diag)
  .Case("print", OK_Print)
- .Case("dump", OK_Dump)
+ .Case("detailed-ast", OK_DetailedAST)
+ .Case("dump", OK_DetailedAST)
  .Default(~0u);
   if (OutKind == ~0u) {
-return new InvalidQuery("expected 'diag', 'print' or 'dump', got '" +
-ValStr + "'");
+return new InvalidQuery(
+"expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
+"'");
   }
   return new SetQuery(&QuerySession::OutKind, OutputKind(OutKind));
 }
Index: clang-query/Query.h
===
--- clang-query/Query.h
+++ clang-query/Query.h
@@ -18,7 +18,7 @@
 namespace clang {
 namespace query {
 
-enum OutputKind { OK_Diag, OK_Print, OK_Dump };
+enum OutputKind { OK_Diag, OK_Print, OK_DetailedAST };
 
 enum QueryKind {
   QK_Invalid,
Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -53,8 +53,10 @@
 "pretty-print bound nodes\n"
 "  diag  "
 "diagnostic location for bound nodes\n"
+"  detailed-ast  "
+"Detailed AST output for bound nodes\n"
 "  dump  "
-"Detailed AST output for bound nodes\n\n";
+"Detailed AST output for bound nodes (alias of deatiled-ast)\n\n";
   return true;
 }
 
@@ -124,7 +126,7 @@
   OS << "\n";
   break;
 }
-case OK_Dump: {
+case OK_DetailedAST: {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.dump(OS, AST->getSourceManager());
   OS << "\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53501: [clang-query] Refactor Output settings to booleans

2018-10-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

This will make it possible to add non-exclusive mode output.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53501

Files:
  clang-query/Query.cpp
  clang-query/Query.h
  clang-query/QueryParser.cpp
  clang-query/QuerySession.h

Index: clang-query/QuerySession.h
===
--- clang-query/QuerySession.h
+++ clang-query/QuerySession.h
@@ -25,11 +25,16 @@
 class QuerySession {
 public:
   QuerySession(llvm::ArrayRef> ASTs)
-  : ASTs(ASTs), OutKind(OK_Diag), BindRoot(true), PrintMatcher(false),
+  : ASTs(ASTs), PrintOutput(true), DiagOutput(true),
+DetailedASTOutput(false), BindRoot(true), PrintMatcher(false),
 Terminate(false) {}
 
   llvm::ArrayRef> ASTs;
-  OutputKind OutKind;
+
+  bool PrintOutput;
+  bool DiagOutput;
+  bool DetailedASTOutput;
+
   bool BindRoot;
   bool PrintMatcher;
   bool Terminate;
Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -119,7 +119,17 @@
 "expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
 "'");
   }
-  return new SetQuery(&QuerySession::OutKind, OutputKind(OutKind));
+
+  switch (OutKind) {
+  case OK_DetailedAST:
+return new SetExclusiveOutputQuery(&QuerySession::DetailedASTOutput);
+  case OK_Diag:
+return new SetExclusiveOutputQuery(&QuerySession::DiagOutput);
+  case OK_Print:
+return new SetExclusiveOutputQuery(&QuerySession::PrintOutput);
+  }
+
+  llvm_unreachable("Invalid output kind");
 }
 
 QueryRef QueryParser::endQuery(QueryRef Q) {
Index: clang-query/Query.h
===
--- clang-query/Query.h
+++ clang-query/Query.h
@@ -10,9 +10,11 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_H
 
+#include "QuerySession.h"
 #include "clang/ASTMatchers/Dynamic/VariantValue.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
+
 #include 
 
 namespace clang {
@@ -133,6 +135,23 @@
   T Value;
 };
 
+// Implements the exclusive 'set output dump|diag|print' options
+struct SetExclusiveOutputQuery : Query {
+  SetExclusiveOutputQuery(bool QuerySession::*Var)
+  : Query(QK_SetOutputKind), Var(Var) {}
+  bool run(llvm::raw_ostream &OS, QuerySession &QS) const override {
+QS.DiagOutput = false;
+QS.DetailedASTOutput = false;
+QS.PrintOutput = false;
+QS.*Var = true;
+return true;
+  }
+
+  static bool classof(const Query *Q) { return Q->Kind == QK_SetOutputKind; }
+
+  bool QuerySession::*Var;
+};
+
 } // namespace query
 } // namespace clang
 
Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -107,8 +107,7 @@
 
   for (auto BI = MI->getMap().begin(), BE = MI->getMap().end(); BI != BE;
++BI) {
-switch (QS.OutKind) {
-case OK_Diag: {
+if (QS.DiagOutput) {
   clang::SourceRange R = BI->second.getSourceRange();
   if (R.isValid()) {
 TextDiagnostic TD(OS, AST->getASTContext().getLangOpts(),
@@ -120,19 +119,18 @@
   }
   break;
 }
-case OK_Print: {
+if (QS.PrintOutput) {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.print(OS, AST->getASTContext().getPrintingPolicy());
   OS << "\n";
   break;
 }
-case OK_DetailedAST: {
+if (QS.DetailedASTOutput) {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.dump(OS, AST->getSourceManager());
   OS << "\n";
   break;
 }
-}
   }
 
   if (MI->getMap().empty())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53500: Add 'detailed-ast' output as an alias for 'dump'

2018-10-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 170427.
steveire added a comment.

Update tests


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53500

Files:
  clang-query/Query.cpp
  clang-query/Query.h
  clang-query/QueryParser.cpp
  unittests/clang-query/QueryEngineTest.cpp
  unittests/clang-query/QueryParserTest.cpp

Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -70,22 +70,27 @@
 
   Q = parse("set output");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
+  EXPECT_EQ("expected 'diag', 'print', 'detailed-ast' or 'dump', got ''",
 cast(Q)->ErrStr);
 
   Q = parse("set bind-root true foo");
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unexpected extra input: ' foo'", cast(Q)->ErrStr);
 
   Q = parse("set output foo");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
+  EXPECT_EQ("expected 'diag', 'print', 'detailed-ast' or 'dump', got 'foo'",
 cast(Q)->ErrStr);
 
   Q = parse("set output dump");
   ASSERT_TRUE(isa >(Q));
   EXPECT_EQ(&QuerySession::OutKind, cast >(Q)->Var);
-  EXPECT_EQ(OK_Dump, cast >(Q)->Value);
+  EXPECT_EQ(OK_DetailedAST, cast>(Q)->Value);
+
+  Q = parse("set output detailed-ast");
+  ASSERT_TRUE(isa>(Q));
+  EXPECT_EQ(&QuerySession::OutKind, cast>(Q)->Var);
+  EXPECT_EQ(OK_DetailedAST, cast>(Q)->Value);
 
   Q = parse("set bind-root foo");
   ASSERT_TRUE(isa(Q));
Index: unittests/clang-query/QueryEngineTest.cpp
===
--- unittests/clang-query/QueryEngineTest.cpp
+++ unittests/clang-query/QueryEngineTest.cpp
@@ -103,7 +103,8 @@
 
   Str.clear();
 
-  EXPECT_TRUE(SetQuery(&QuerySession::OutKind, OK_Dump).run(OS, S));
+  EXPECT_TRUE(
+  SetQuery(&QuerySession::OutKind, OK_DetailedAST).run(OS, S));
   EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
 
   EXPECT_TRUE(OS.str().find("FunctionDecl") != std::string::npos);
Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -111,11 +111,13 @@
   unsigned OutKind = LexOrCompleteWord(this, ValStr)
  .Case("diag", OK_Diag)
  .Case("print", OK_Print)
- .Case("dump", OK_Dump)
+ .Case("detailed-ast", OK_DetailedAST)
+ .Case("dump", OK_DetailedAST)
  .Default(~0u);
   if (OutKind == ~0u) {
-return new InvalidQuery("expected 'diag', 'print' or 'dump', got '" +
-ValStr + "'");
+return new InvalidQuery(
+"expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
+"'");
   }
   return new SetQuery(&QuerySession::OutKind, OutputKind(OutKind));
 }
Index: clang-query/Query.h
===
--- clang-query/Query.h
+++ clang-query/Query.h
@@ -18,7 +18,7 @@
 namespace clang {
 namespace query {
 
-enum OutputKind { OK_Diag, OK_Print, OK_Dump };
+enum OutputKind { OK_Diag, OK_Print, OK_DetailedAST };
 
 enum QueryKind {
   QK_Invalid,
Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -53,8 +53,10 @@
 "pretty-print bound nodes\n"
 "  diag  "
 "diagnostic location for bound nodes\n"
+"  detailed-ast  "
+"Detailed AST output for bound nodes\n"
 "  dump  "
-"Detailed AST output for bound nodes\n\n";
+"Detailed AST output for bound nodes (alias of deatiled-ast)\n\n";
   return true;
 }
 
@@ -124,7 +126,7 @@
   OS << "\n";
   break;
 }
-case OK_Dump: {
+case OK_DetailedAST: {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.dump(OS, AST->getSourceManager());
   OS << "\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53501: [clang-query] Refactor Output settings to booleans

2018-10-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 170431.
steveire added a comment.

Update tests


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53501

Files:
  clang-query/Query.cpp
  clang-query/Query.h
  clang-query/QueryParser.cpp
  clang-query/QuerySession.h
  unittests/clang-query/QueryEngineTest.cpp
  unittests/clang-query/QueryParserTest.cpp

Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -83,14 +83,12 @@
 cast(Q)->ErrStr);
 
   Q = parse("set output dump");
-  ASSERT_TRUE(isa >(Q));
-  EXPECT_EQ(&QuerySession::OutKind, cast >(Q)->Var);
-  EXPECT_EQ(OK_DetailedAST, cast>(Q)->Value);
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ(&QuerySession::DetailedASTOutput, cast(Q)->Var);
 
   Q = parse("set output detailed-ast");
-  ASSERT_TRUE(isa>(Q));
-  EXPECT_EQ(&QuerySession::OutKind, cast>(Q)->Var);
-  EXPECT_EQ(OK_DetailedAST, cast>(Q)->Value);
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ(&QuerySession::DetailedASTOutput, cast(Q)->Var);
 
   Q = parse("set bind-root foo");
   ASSERT_TRUE(isa(Q));
Index: unittests/clang-query/QueryEngineTest.cpp
===
--- unittests/clang-query/QueryEngineTest.cpp
+++ unittests/clang-query/QueryEngineTest.cpp
@@ -95,16 +95,16 @@
   Str.clear();
 
   EXPECT_TRUE(
-  SetQuery(&QuerySession::OutKind, OK_Print).run(OS, S));
+  SetExclusiveOutputQuery(&QuerySession::PrintOutput).run(OS, S));
   EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
 
   EXPECT_TRUE(OS.str().find("Binding for \"root\":\nvoid foo1()") !=
   std::string::npos);
 
   Str.clear();
 
   EXPECT_TRUE(
-  SetQuery(&QuerySession::OutKind, OK_DetailedAST).run(OS, S));
+  SetExclusiveOutputQuery(&QuerySession::DetailedASTOutput).run(OS, S));
   EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
 
   EXPECT_TRUE(OS.str().find("FunctionDecl") != std::string::npos);
Index: clang-query/QuerySession.h
===
--- clang-query/QuerySession.h
+++ clang-query/QuerySession.h
@@ -25,11 +25,16 @@
 class QuerySession {
 public:
   QuerySession(llvm::ArrayRef> ASTs)
-  : ASTs(ASTs), OutKind(OK_Diag), BindRoot(true), PrintMatcher(false),
+  : ASTs(ASTs), PrintOutput(false), DiagOutput(true),
+DetailedASTOutput(false), BindRoot(true), PrintMatcher(false),
 Terminate(false) {}
 
   llvm::ArrayRef> ASTs;
-  OutputKind OutKind;
+
+  bool PrintOutput;
+  bool DiagOutput;
+  bool DetailedASTOutput;
+
   bool BindRoot;
   bool PrintMatcher;
   bool Terminate;
Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -119,7 +119,17 @@
 "expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
 "'");
   }
-  return new SetQuery(&QuerySession::OutKind, OutputKind(OutKind));
+
+  switch (OutKind) {
+  case OK_DetailedAST:
+return new SetExclusiveOutputQuery(&QuerySession::DetailedASTOutput);
+  case OK_Diag:
+return new SetExclusiveOutputQuery(&QuerySession::DiagOutput);
+  case OK_Print:
+return new SetExclusiveOutputQuery(&QuerySession::PrintOutput);
+  }
+
+  llvm_unreachable("Invalid output kind");
 }
 
 QueryRef QueryParser::endQuery(QueryRef Q) {
Index: clang-query/Query.h
===
--- clang-query/Query.h
+++ clang-query/Query.h
@@ -10,9 +10,11 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_H
 
+#include "QuerySession.h"
 #include "clang/ASTMatchers/Dynamic/VariantValue.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
+
 #include 
 
 namespace clang {
@@ -133,6 +135,23 @@
   T Value;
 };
 
+// Implements the exclusive 'set output dump|diag|print' options
+struct SetExclusiveOutputQuery : Query {
+  SetExclusiveOutputQuery(bool QuerySession::*Var)
+  : Query(QK_SetOutputKind), Var(Var) {}
+  bool run(llvm::raw_ostream &OS, QuerySession &QS) const override {
+QS.DiagOutput = false;
+QS.DetailedASTOutput = false;
+QS.PrintOutput = false;
+QS.*Var = true;
+return true;
+  }
+
+  static bool classof(const Query *Q) { return Q->Kind == QK_SetOutputKind; }
+
+  bool QuerySession::*Var;
+};
+
 } // namespace query
 } // namespace clang
 
Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -107,8 +107,7 @@
 
   for (auto BI = MI->getMap().begin(), BE = MI->getMap().end(); BI != BE;
++BI) {
-switch (QS.OutKind) {
-case OK_Diag: {
+if (QS.DiagOutput) {
   clang::SourceRange R = BI->second.getSourceRange();
  

[PATCH] D52857: [clang-query] Add non-exclusive output API

2018-10-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 170435.
steveire retitled this revision from "[clang-query] Add non-exclusive output 
API   " to "[clang-query] Add non-exclusive output API".
steveire added a comment.

New design


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857

Files:
  clang-query/Query.h
  clang-query/QueryParser.cpp
  clang-query/QueryParser.h
  unittests/clang-query/QueryEngineTest.cpp
  unittests/clang-query/QueryParserTest.cpp

Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -90,6 +90,14 @@
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ(&QuerySession::DetailedASTOutput, cast(Q)->Var);
 
+  Q = parse("set enable-output detailed-ast");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ(&QuerySession::DetailedASTOutput, cast(Q)->Var);
+
+  Q = parse("set disable-output detailed-ast");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ(&QuerySession::DetailedASTOutput, cast(Q)->Var);
+
   Q = parse("set bind-root foo");
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("expected 'true' or 'false', got 'foo'",
Index: unittests/clang-query/QueryEngineTest.cpp
===
--- unittests/clang-query/QueryEngineTest.cpp
+++ unittests/clang-query/QueryEngineTest.cpp
@@ -111,6 +111,21 @@
 
   Str.clear();
 
+  EXPECT_TRUE(
+  EnableOutputQuery(&QuerySession::DiagOutput).run(OS, S));
+  EXPECT_TRUE(
+  EnableOutputQuery(&QuerySession::DetailedASTOutput).run(OS, S));
+  EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
+
+  {
+auto Output = OS.str();
+EXPECT_TRUE(Output.find("FunctionDecl") != std::string::npos);
+EXPECT_TRUE(Output.find("foo.cc:1:1: note: \"root\" binds here") !=
+std::string::npos);
+  }
+
+  Str.clear();
+
   EXPECT_TRUE(SetQuery(&QuerySession::BindRoot, false).run(OS, S));
   EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
 
Index: clang-query/QueryParser.h
===
--- clang-query/QueryParser.h
+++ clang-query/QueryParser.h
@@ -44,6 +44,7 @@
   template  struct LexOrCompleteWord;
 
   QueryRef parseSetBool(bool QuerySession::*Var);
+  template
   QueryRef parseSetOutputKind();
   QueryRef completeMatcherExpression();
 
Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -106,6 +106,7 @@
   return new SetQuery(Var, Value);
 }
 
+template
 QueryRef QueryParser::parseSetOutputKind() {
   StringRef ValStr;
   unsigned OutKind = LexOrCompleteWord(this, ValStr)
@@ -122,11 +123,11 @@
 
   switch (OutKind) {
   case OK_DetailedAST:
-return new SetExclusiveOutputQuery(&QuerySession::DetailedASTOutput);
+return new QueryType(&QuerySession::DetailedASTOutput);
   case OK_Diag:
-return new SetExclusiveOutputQuery(&QuerySession::DiagOutput);
+return new QueryType(&QuerySession::DiagOutput);
   case OK_Print:
-return new SetExclusiveOutputQuery(&QuerySession::PrintOutput);
+return new QueryType(&QuerySession::PrintOutput);
   }
 
   llvm_unreachable("Invalid output kind");
@@ -157,6 +158,8 @@
 enum ParsedQueryVariable {
   PQV_Invalid,
   PQV_Output,
+  PQV_EnableOutput,
+  PQV_DisableOutput,
   PQV_BindRoot,
   PQV_PrintMatcher
 };
@@ -245,6 +248,8 @@
 ParsedQueryVariable Var =
 LexOrCompleteWord(this, VarStr)
 .Case("output", PQV_Output)
+.Case("enable-output", PQV_EnableOutput)
+.Case("disable-output", PQV_DisableOutput)
 .Case("bind-root", PQV_BindRoot)
 .Case("print-matcher", PQV_PrintMatcher)
 .Default(PQV_Invalid);
@@ -256,7 +261,13 @@
 QueryRef Q;
 switch (Var) {
 case PQV_Output:
-  Q = parseSetOutputKind();
+  Q = parseSetOutputKind();
+  break;
+case PQV_EnableOutput:
+  Q = parseSetOutputKind();
+  break;
+case PQV_DisableOutput:
+  Q = parseSetOutputKind();
   break;
 case PQV_BindRoot:
   Q = parseSetBool(&QuerySession::BindRoot);
Index: clang-query/Query.h
===
--- clang-query/Query.h
+++ clang-query/Query.h
@@ -152,6 +152,30 @@
   bool QuerySession::*Var;
 };
 
+// Implements the non-exclusive 'set output dump|diag|print' options
+struct SetNonExclusiveOutputQuery : Query {
+  SetNonExclusiveOutputQuery(bool QuerySession::*Var, bool Value) : Query(QK_SetOutputKind), Var(Var), Value(Value) {}
+  bool run(llvm::raw_ostream &OS, QuerySession &QS) const override {
+QS.*Var = Value;
+return true;
+  }
+
+  static bool classof(const Query *Q) { return Q->Kind == QK_SetOutputKind; }
+
+  bool QuerySession::*Var;
+  bool Value;
+};
+
+struct EnableOutputQuery : SetNonExclusiveOutputQuery
+{
+  EnableOutputQuery(bool QuerySession:

[PATCH] D52857: [clang-query] Add non-exclusive output API

2018-10-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 170439.
steveire added a comment.

Update docs


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857

Files:
  clang-query/Query.cpp
  clang-query/Query.h
  clang-query/QueryParser.cpp
  clang-query/QueryParser.h
  unittests/clang-query/QueryEngineTest.cpp
  unittests/clang-query/QueryParserTest.cpp

Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -90,6 +90,14 @@
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ(&QuerySession::DetailedASTOutput, cast(Q)->Var);
 
+  Q = parse("set enable-output detailed-ast");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ(&QuerySession::DetailedASTOutput, cast(Q)->Var);
+
+  Q = parse("set disable-output detailed-ast");
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ(&QuerySession::DetailedASTOutput, cast(Q)->Var);
+
   Q = parse("set bind-root foo");
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("expected 'true' or 'false', got 'foo'",
Index: unittests/clang-query/QueryEngineTest.cpp
===
--- unittests/clang-query/QueryEngineTest.cpp
+++ unittests/clang-query/QueryEngineTest.cpp
@@ -111,6 +111,21 @@
 
   Str.clear();
 
+  EXPECT_TRUE(
+  EnableOutputQuery(&QuerySession::DiagOutput).run(OS, S));
+  EXPECT_TRUE(
+  EnableOutputQuery(&QuerySession::DetailedASTOutput).run(OS, S));
+  EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
+
+  {
+auto Output = OS.str();
+EXPECT_TRUE(Output.find("FunctionDecl") != std::string::npos);
+EXPECT_TRUE(Output.find("foo.cc:1:1: note: \"root\" binds here") !=
+std::string::npos);
+  }
+
+  Str.clear();
+
   EXPECT_TRUE(SetQuery(&QuerySession::BindRoot, false).run(OS, S));
   EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
 
Index: clang-query/QueryParser.h
===
--- clang-query/QueryParser.h
+++ clang-query/QueryParser.h
@@ -44,6 +44,7 @@
   template  struct LexOrCompleteWord;
 
   QueryRef parseSetBool(bool QuerySession::*Var);
+  template
   QueryRef parseSetOutputKind();
   QueryRef completeMatcherExpression();
 
Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -106,6 +106,7 @@
   return new SetQuery(Var, Value);
 }
 
+template
 QueryRef QueryParser::parseSetOutputKind() {
   StringRef ValStr;
   unsigned OutKind = LexOrCompleteWord(this, ValStr)
@@ -122,11 +123,11 @@
 
   switch (OutKind) {
   case OK_DetailedAST:
-return new SetExclusiveOutputQuery(&QuerySession::DetailedASTOutput);
+return new QueryType(&QuerySession::DetailedASTOutput);
   case OK_Diag:
-return new SetExclusiveOutputQuery(&QuerySession::DiagOutput);
+return new QueryType(&QuerySession::DiagOutput);
   case OK_Print:
-return new SetExclusiveOutputQuery(&QuerySession::PrintOutput);
+return new QueryType(&QuerySession::PrintOutput);
   }
 
   llvm_unreachable("Invalid output kind");
@@ -157,6 +158,8 @@
 enum ParsedQueryVariable {
   PQV_Invalid,
   PQV_Output,
+  PQV_EnableOutput,
+  PQV_DisableOutput,
   PQV_BindRoot,
   PQV_PrintMatcher
 };
@@ -245,6 +248,8 @@
 ParsedQueryVariable Var =
 LexOrCompleteWord(this, VarStr)
 .Case("output", PQV_Output)
+.Case("enable-output", PQV_EnableOutput)
+.Case("disable-output", PQV_DisableOutput)
 .Case("bind-root", PQV_BindRoot)
 .Case("print-matcher", PQV_PrintMatcher)
 .Default(PQV_Invalid);
@@ -256,7 +261,13 @@
 QueryRef Q;
 switch (Var) {
 case PQV_Output:
-  Q = parseSetOutputKind();
+  Q = parseSetOutputKind();
+  break;
+case PQV_EnableOutput:
+  Q = parseSetOutputKind();
+  break;
+case PQV_DisableOutput:
+  Q = parseSetOutputKind();
   break;
 case PQV_BindRoot:
   Q = parseSetBool(&QuerySession::BindRoot);
Index: clang-query/Query.h
===
--- clang-query/Query.h
+++ clang-query/Query.h
@@ -152,6 +152,30 @@
   bool QuerySession::*Var;
 };
 
+// Implements the non-exclusive 'set output dump|diag|print' options
+struct SetNonExclusiveOutputQuery : Query {
+  SetNonExclusiveOutputQuery(bool QuerySession::*Var, bool Value) : Query(QK_SetOutputKind), Var(Var), Value(Value) {}
+  bool run(llvm::raw_ostream &OS, QuerySession &QS) const override {
+QS.*Var = Value;
+return true;
+  }
+
+  static bool classof(const Query *Q) { return Q->Kind == QK_SetOutputKind; }
+
+  bool QuerySession::*Var;
+  bool Value;
+};
+
+struct EnableOutputQuery : SetNonExclusiveOutputQuery
+{
+  EnableOutputQuery(bool QuerySession::*Var) : SetNonExclusiveOutputQuery(Var, true) { }
+};
+
+struct DisableOutputQuery : SetNonExclusiveOutputQue

[PATCH] D52857: [clang-query] Add non-exclusive output API

2018-10-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

> This seems confusing to me because I would expect set foo bar to set the 
> value of a variable foo to bar,

This is already not the case with `set output diag` etc.

That said, I don't mind spelling this ` output foo`. It's not 
my decision. It's up to the reviewers.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D52857: [clang-query] Add non-exclusive output API

2018-10-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

> This is already not the case with set output diag etc.

Oh, I'm wrong here. I misread your post, sorry.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D52857: [clang-query] Add non-exclusive output API

2018-10-23 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

I prefer the API from Peter. I think it's a good additional step from where 
Aaron and I reached in IRC discussion (this patch currently).

I can change the patch to use that later if you agree Aaron?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D52857: [clang-query] Add non-exclusive output API

2018-10-23 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Yep, that's the suggestion. That will result in commands such as:

- `enable output detailed-ast`
- `disable output detailed-ast`
- `set output detailed-ast`
- `enable output diag`
- `disable output diag`
- `set output diag`

etc, which I think addresses all concerns.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D53498: Re-word command help for clang-query

2018-10-24 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE345192: [clang-query] Re-word command help (authored by 
steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53498?vs=170419&id=170972#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53498

Files:
  clang-query/Query.cpp


Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -43,12 +43,18 @@
 "Set whether to bind the root matcher to \"root\".\n"
 "  set print-matcher (true|false)"
 "Set whether to print the current matcher,\n"
-"  set output (diag|print|dump)  "
-"Set whether to print bindings as diagnostics,\n"
-""
-"AST pretty prints or AST dumps.\n"
+"  set output   "
+"Set whether to output only  content.\n"
 "  quit, q   "
-"Terminates the query session.\n\n";
+"Terminates the query session.\n\n"
+"Several commands accept a  parameter. The available features 
"
+"are:\n\n"
+"  print "
+"Pretty-print bound nodes.\n"
+"  diag  "
+"Diagnostic location for bound nodes.\n"
+"  dump  "
+"Detailed AST output for bound nodes.\n\n";
   return true;
 }
 


Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -43,12 +43,18 @@
 "Set whether to bind the root matcher to \"root\".\n"
 "  set print-matcher (true|false)"
 "Set whether to print the current matcher,\n"
-"  set output (diag|print|dump)  "
-"Set whether to print bindings as diagnostics,\n"
-""
-"AST pretty prints or AST dumps.\n"
+"  set output   "
+"Set whether to output only  content.\n"
 "  quit, q   "
-"Terminates the query session.\n\n";
+"Terminates the query session.\n\n"
+"Several commands accept a  parameter. The available features "
+"are:\n\n"
+"  print "
+"Pretty-print bound nodes.\n"
+"  diag  "
+"Diagnostic location for bound nodes.\n"
+"  dump  "
+"Detailed AST output for bound nodes.\n\n";
   return true;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53500: Add 'detailed-ast' output as an alias for 'dump'

2018-10-24 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE345193: [clang-query] Add 'detailed-ast' output 
as an alias for 'dump' (authored by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53500?vs=170427&id=170973#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53500

Files:
  clang-query/Query.cpp
  clang-query/Query.h
  clang-query/QueryParser.cpp
  unittests/clang-query/QueryEngineTest.cpp
  unittests/clang-query/QueryParserTest.cpp

Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -70,22 +70,27 @@
 
   Q = parse("set output");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
+  EXPECT_EQ("expected 'diag', 'print', 'detailed-ast' or 'dump', got ''",
 cast(Q)->ErrStr);
 
   Q = parse("set bind-root true foo");
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unexpected extra input: ' foo'", cast(Q)->ErrStr);
 
   Q = parse("set output foo");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
+  EXPECT_EQ("expected 'diag', 'print', 'detailed-ast' or 'dump', got 'foo'",
 cast(Q)->ErrStr);
 
   Q = parse("set output dump");
   ASSERT_TRUE(isa >(Q));
   EXPECT_EQ(&QuerySession::OutKind, cast >(Q)->Var);
-  EXPECT_EQ(OK_Dump, cast >(Q)->Value);
+  EXPECT_EQ(OK_DetailedAST, cast>(Q)->Value);
+
+  Q = parse("set output detailed-ast");
+  ASSERT_TRUE(isa>(Q));
+  EXPECT_EQ(&QuerySession::OutKind, cast>(Q)->Var);
+  EXPECT_EQ(OK_DetailedAST, cast>(Q)->Value);
 
   Q = parse("set bind-root foo");
   ASSERT_TRUE(isa(Q));
Index: unittests/clang-query/QueryEngineTest.cpp
===
--- unittests/clang-query/QueryEngineTest.cpp
+++ unittests/clang-query/QueryEngineTest.cpp
@@ -103,7 +103,8 @@
 
   Str.clear();
 
-  EXPECT_TRUE(SetQuery(&QuerySession::OutKind, OK_Dump).run(OS, S));
+  EXPECT_TRUE(
+  SetQuery(&QuerySession::OutKind, OK_DetailedAST).run(OS, S));
   EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
 
   EXPECT_TRUE(OS.str().find("FunctionDecl") != std::string::npos);
Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -53,8 +53,10 @@
 "Pretty-print bound nodes.\n"
 "  diag  "
 "Diagnostic location for bound nodes.\n"
+"  detailed-ast  "
+"Detailed AST output for bound nodes.\n"
 "  dump  "
-"Detailed AST output for bound nodes.\n\n";
+"Detailed AST output for bound nodes (alias of detailed-ast).\n\n";
   return true;
 }
 
@@ -124,7 +126,7 @@
   OS << "\n";
   break;
 }
-case OK_Dump: {
+case OK_DetailedAST: {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.dump(OS, AST->getSourceManager());
   OS << "\n";
Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -111,11 +111,13 @@
   unsigned OutKind = LexOrCompleteWord(this, ValStr)
  .Case("diag", OK_Diag)
  .Case("print", OK_Print)
- .Case("dump", OK_Dump)
+ .Case("detailed-ast", OK_DetailedAST)
+ .Case("dump", OK_DetailedAST)
  .Default(~0u);
   if (OutKind == ~0u) {
-return new InvalidQuery("expected 'diag', 'print' or 'dump', got '" +
-ValStr + "'");
+return new InvalidQuery(
+"expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
+"'");
   }
   return new SetQuery(&QuerySession::OutKind, OutputKind(OutKind));
 }
Index: clang-query/Query.h
===
--- clang-query/Query.h
+++ clang-query/Query.h
@@ -18,7 +18,7 @@
 namespace clang {
 namespace query {
 
-enum OutputKind { OK_Diag, OK_Print, OK_Dump };
+enum OutputKind { OK_Diag, OK_Print, OK_DetailedAST };
 
 enum QueryKind {
   QK_Invalid,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   6   7   8   9   10   >