Re: r338301 - Avoid returning an invalid end source loc

2018-08-07 Thread Stephen Kelly via cfe-commits


Hi David,

I'm happy to add a test case, but I don't know how to catch this case. 
It's not obvious to me if any code path intentionally creates a 
DeclarationNameInfo with a valid start loc and an invalid end loc. Can 
you suggest a test case?


Thanks,

Stephen.

On 07/08/18 03:23, David Blaikie wrote:

test case?

On Mon, Jul 30, 2018 at 1:39 PM Stephen Kelly via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:


Author: steveire
Date: Mon Jul 30 13:39:14 2018
New Revision: 338301

URL: http://llvm.org/viewvc/llvm-project?rev=338301&view=rev
Log:
Avoid returning an invalid end source loc

Modified:
    cfe/trunk/include/clang/AST/DeclarationName.h
    cfe/trunk/lib/AST/DeclarationName.cpp

Modified: cfe/trunk/include/clang/AST/DeclarationName.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclarationName.h?rev=338301&r1=338300&r2=338301&view=diff

==
--- cfe/trunk/include/clang/AST/DeclarationName.h (original)
+++ cfe/trunk/include/clang/AST/DeclarationName.h Mon Jul 30
13:39:14 2018
@@ -558,7 +558,7 @@ public:
   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 @@ public:
   }

   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

Modified: cfe/trunk/lib/AST/DeclarationName.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclarationName.cpp?rev=338301&r1=338300&r2=338301&view=diff

==
--- cfe/trunk/lib/AST/DeclarationName.cpp (original)
+++ cfe/trunk/lib/AST/DeclarationName.cpp Mon Jul 30 13:39:14 2018
@@ -689,7 +689,7 @@ void DeclarationNameInfo::printName(raw_
   llvm_unreachable("Unexpected declaration name kind");
 }

-SourceLocation DeclarationNameInfo::getEndLoc() const {
+SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
   switch (Name.getNameKind()) {
   case DeclarationName::Identifier:
   case DeclarationName::CXXDeductionGuideName:


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



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


Re: r338301 - Avoid returning an invalid end source loc

2018-08-07 Thread Stephen Kelly via cfe-commits


Ok, I can look into adding the assertion and run the tests with it to 
see if anything comes up.


I made a tool which dumps SourceLocations reachable from an AST node (I 
intend to integrate it into clang-query), and I noticed the large amount 
of mixing of get{Start,End}Loc and getLoc{Start,End} (see other pending 
reviews). I reviewed all of them and found that this method is the only 
case where a pair of methods of that name pattern differ in what they 
return (by eye, at least), so I thought it should be fixed.


Thanks,

Stephen.

On 07/08/18 23:18, David Blaikie wrote:
If it never comes up, maybe an assertion would suffice? (& if the 
assertion ever does fire - hey, we've found a test case to use)


How'd you find this/what motivated you to make the change?

On Tue, Aug 7, 2018 at 3:11 PM Stephen Kelly <mailto:steve...@gmail.com>> wrote:



Hi David,

I'm happy to add a test case, but I don't know how to catch this
case. It's not obvious to me if any code path intentionally
creates a DeclarationNameInfo with a valid start loc and an
invalid end loc. Can you suggest a test case?

Thanks,

Stephen.


On 07/08/18 03:23, David Blaikie wrote:

test case?

On Mon, Jul 30, 2018 at 1:39 PM Stephen Kelly via cfe-commits
mailto:cfe-commits@lists.llvm.org>>
wrote:

Author: steveire
Date: Mon Jul 30 13:39:14 2018
New Revision: 338301

URL: http://llvm.org/viewvc/llvm-project?rev=338301&view=rev
Log:
Avoid returning an invalid end source loc

Modified:
    cfe/trunk/include/clang/AST/DeclarationName.h
    cfe/trunk/lib/AST/DeclarationName.cpp

Modified: cfe/trunk/include/clang/AST/DeclarationName.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclarationName.h?rev=338301&r1=338300&r2=338301&view=diff

==
--- cfe/trunk/include/clang/AST/DeclarationName.h (original)
+++ cfe/trunk/include/clang/AST/DeclarationName.h Mon Jul 30
13:39:14 2018
@@ -558,7 +558,7 @@ public:
   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 @@ public:
   }

   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

Modified: cfe/trunk/lib/AST/DeclarationName.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclarationName.cpp?rev=338301&r1=338300&r2=338301&view=diff

==
--- cfe/trunk/lib/AST/DeclarationName.cpp (original)
+++ cfe/trunk/lib/AST/DeclarationName.cpp Mon Jul 30 13:39:14
2018
@@ -689,7 +689,7 @@ void DeclarationNameInfo::printName(raw_
   llvm_unreachable("Unexpected declaration name kind");
 }

-SourceLocation DeclarationNameInfo::getEndLoc() const {
+SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
   switch (Name.getNameKind()) {
   case DeclarationName::Identifier:
   case DeclarationName::CXXDeductionGuideName:


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





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


r339372 - Add getBeginLoc API to replace getLocStart

2018-08-09 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Aug  9 13:05:03 2018
New Revision: 339372

URL: http://llvm.org/viewvc/llvm-project?rev=339372&view=rev
Log:
Add getBeginLoc API to replace getLocStart

Subscribers: cfe-commits

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

Modified:
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

Modified: cfe/trunk/include/clang/AST/Comment.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=339372&r1=339371&r2=339372&view=diff
==
--- cfe/trunk/include/clang/AST/Comment.h (original)
+++ cfe/trunk/include/clang/AST/Comment.h Thu Aug  9 13:05:03 2018
@@ -215,9 +215,8 @@ public:
 
   SourceRange getSourceRange() const LLVM_READONLY { return Range; }
 
-  SourceLocation getLocStart() const LLVM_READONLY {
-return Range.getBegin();
-  }
+  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
+  SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
 
   SourceLocation getLocEnd() const LLVM_READONLY {
 return Range.getEnd();

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=339372&r1=339371&r2=339372&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Aug  9 13:05:03 2018
@@ -614,7 +614,8 @@ public:
 return SourceRange(LocStart, RBraceLoc);
   }
 
-  SourceLocation getLocStart() const LLVM_READONLY { return LocStart; }
+  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
+  SourceLocation getBeginLoc() const LLVM_READONLY { return LocStart; }
   SourceLocation getRBraceLoc() const { return RBraceLoc; }
   void setLocStart(SourceLocation L) { LocStart = L; }
   void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
@@ -735,7 +736,8 @@ public:
 
   SourceRange getSourceRange() const override LLVM_READONLY;
 
-  SourceLocation getLocStart() const LLVM_READONLY {
+  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
+  SourceLocation getBeginLoc() const LLVM_READONLY {
 return getOuterLocStart();
   }
 
@@ -2865,7 +2867,8 @@ public:
   const Type *getTypeForDecl() const { return TypeForDecl; }
   void setTypeForDecl(const Type *TD) { TypeForDecl = TD; }
 
-  SourceLocation getLocStart() const LLVM_READONLY { return LocStart; }
+  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
+  SourceLocation getBeginLoc() const LLVM_READONLY { return LocStart; }
   void setLocStart(SourceLocation L) { LocStart = L; }
   SourceRange getSourceRange() const override LLVM_READONLY {
 if (LocStart.isValid())

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=339372&r1=339371&r2=339372&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Thu Aug  9 13:05:03 2018
@@ -406,7 +406,8 @@ public:
 return SourceRange(getLocation(), getLocation());
   }
 
-  SourceLocation getLocStart() const LLVM_READONLY {
+  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
+  SourceLocation getBeginLoc() const LLVM_READONLY {
 return getSourceRange().getBegin();
   }
 

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=339372&r1=339371&r2=339372&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Aug  9 13:05:03 2018
@@ -233,7 +233,8 @@ public:
 
   /// Retrieves the source range that contains the entire base specifier.
   SourceRange getSourceRange() const LLVM_READONLY { return Range; }
-  SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
+  SourceLocation getLocStart() const LLVM_READO

r339373 - Add getBeginLoc API to replace getStartLoc

2018-08-09 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Aug  9 13:05:18 2018
New Revision: 339373

URL: http://llvm.org/viewvc/llvm-project?rev=339373&view=rev
Log:
Add getBeginLoc API to replace getStartLoc

Reviewers: teemperor!

Subscribers: cfe-commits

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

Modified:
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

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=339373&r1=339372&r2=339373&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Thu Aug  9 13:05:18 2018
@@ -2094,7 +2094,8 @@ public:
 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 @@ public:
   }
 
   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) {

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=339373&r1=339372&r2=339373&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Aug  9 13:05:18 2018
@@ -523,7 +523,7 @@ public:
   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; }

Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CloneDetection.h?rev=339373&r1=339372&r2=339373&view=diff
==
--- cfe/trunk/include/clang/Analysis/CloneDetection.h (original)
+++ cfe/trunk/include/clang/Analysis/CloneDetection.h Thu Aug  9 13:05:18 2018
@@ -122,7 +122,8 @@ public:
   /// 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.
   ///

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=339373&r1=339372&r2=339373&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Thu Aug  9 13:05:18 2018
@@ -67,7 +67,8 @@ public:
 
   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;
   }


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


r339374 - Add getEndLoc API to replace getLocEnd

2018-08-09 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Aug  9 13:05:47 2018
New Revision: 339374

URL: http://llvm.org/viewvc/llvm-project?rev=339374&view=rev
Log:
Add getEndLoc API to replace getLocEnd

Subscribers: cfe-commits

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

Modified:
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

Modified: cfe/trunk/include/clang/AST/Comment.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=339374&r1=339373&r2=339374&view=diff
==
--- cfe/trunk/include/clang/AST/Comment.h (original)
+++ cfe/trunk/include/clang/AST/Comment.h Thu Aug  9 13:05:47 2018
@@ -218,9 +218,8 @@ public:
   SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
   SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
 
-  SourceLocation getLocEnd() const LLVM_READONLY {
-return Range.getEnd();
-  }
+  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
+  SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
 
   SourceLocation getLocation() const LLVM_READONLY { return Loc; }
 

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=339374&r1=339373&r2=339374&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Aug  9 13:05:47 2018
@@ -4195,7 +4195,8 @@ public:
   SourceLocation getRBraceLoc() const { return RBraceLoc; }
   void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
 
-  SourceLocation getLocEnd() const LLVM_READONLY {
+  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
+  SourceLocation getEndLoc() const LLVM_READONLY {
 if (RBraceLoc.isValid())
   return RBraceLoc;
 // No braces: get the end location of the (only) declaration in context

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=339374&r1=339373&r2=339374&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Thu Aug  9 13:05:47 2018
@@ -411,7 +411,8 @@ public:
 return getSourceRange().getBegin();
   }
 
-  SourceLocation getLocEnd() const LLVM_READONLY {
+  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
+  SourceLocation getEndLoc() const LLVM_READONLY {
 return getSourceRange().getEnd();
   }
 

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=339374&r1=339373&r2=339374&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Aug  9 13:05:47 2018
@@ -235,7 +235,8 @@ public:
   SourceRange getSourceRange() const LLVM_READONLY { return Range; }
   SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
   SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
-  SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
+  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
+  SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
 
   /// Get the location at which the base class type was written.
   SourceLocation getBaseTypeLoc() const LLVM_READONLY {
@@ -2871,7 +2872,8 @@ public:
 LinkageSpecDeclBits.HasBraces = RBraceLoc.isValid();
   }
 
-  SourceLocation getLocEnd() const LLVM_READONLY {
+  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
+  SourceLocation getEndLoc() const LLVM_READONLY {
 if (hasBraces())
   return getRBraceLoc();
 // No braces: get the end location of the (only) declaration in context

Modified: cfe/trunk/include/clang/AST/DeclObjC.h

r339379 - Fix build

2018-08-09 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Aug  9 13:21:09 2018
New Revision: 339379

URL: http://llvm.org/viewvc/llvm-project?rev=339379&view=rev
Log:
Fix build

Modified:
cfe/trunk/lib/Analysis/CloneDetection.cpp

Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CloneDetection.cpp?rev=339379&r1=339378&r2=339379&view=diff
==
--- cfe/trunk/lib/Analysis/CloneDetection.cpp (original)
+++ cfe/trunk/lib/Analysis/CloneDetection.cpp Thu Aug  9 13:21:09 2018
@@ -77,7 +77,7 @@ ASTContext &StmtSequence::getASTContext(
   return D->getASTContext();
 }
 
-SourceLocation StmtSequence::getStartLoc() const {
+SourceLocation StmtSequence::getBeginLoc() const {
   return front()->getLocStart();
 }
 


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


r339384 - Port getStartLoc -> getBeginLoc

2018-08-09 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Aug  9 14:05:56 2018
New Revision: 339384

URL: http://llvm.org/viewvc/llvm-project?rev=339384&view=rev
Log:
Port getStartLoc -> getBeginLoc

Reviewers: teemperor!

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=339384&r1=339383&r2=339384&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Aug  9 14:05:56 2018
@@ -81,7 +81,7 @@ class VarTemplateDecl;
 /// 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,

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=339384&r1=339383&r2=339384&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Aug  9 14:05:56 2018
@@ -5011,7 +5011,7 @@ Stmt *ASTNodeImporter::VisitDeclStmt(Dec
 if (!ToD)
   return nullptr;
   }
-  SourceLocation ToStartLoc = Importer.Import(S->getStartLoc());
+  SourceLocation ToStartLoc = Importer.Import(S->getBeginLoc());
   SourceLocation ToEndLoc = Importer.Import(S->getEndLoc());
   return new (Importer.getToContext()) DeclStmt(ToDG, ToStartLoc, ToEndLoc);
 }

Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CloneDetection.cpp?rev=339384&r1=339383&r2=339384&view=diff
==
--- cfe/trunk/lib/Analysis/CloneDetection.cpp (original)
+++ cfe/trunk/lib/Analysis/CloneDetection.cpp Thu Aug  9 14:05:56 2018
@@ -45,8 +45,8 @@ bool StmtSequence::contains(const StmtSe
   // 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::getBeginLoc
 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 @@ size_t MinComplexityConstraint::calculat
 
   // 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.

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=339384&r1=339383&r2=339384&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Thu Aug  9 14:05:56 2018
@@ -117,7 +117,7 @@ struct SpellingRegion {
   }
 
   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 @@ public:
 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 @@ public:
 for (const auto &Region : SourceRegions) {
   assert(Region.hasEndLoc() && "incomplete region");
 
-  Sour

[clang-tools-extra] r339401 - Port getLocEnd -> getEndLoc

2018-08-09 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Aug  9 15:43:02 2018
New Revision: 339401

URL: http://llvm.org/viewvc/llvm-project?rev=339401&view=rev
Log:
Port getLocEnd -> getEndLoc

Subscribers: nemanjai, ioeric, kbarton, cfe-commits

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

Modified:
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

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=339401&r1=339400&r2=339401&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Thu Aug  9 
15:43:02 2018
@@ -710,7 +710,7 @@ void ChangeNamespaceTool::moveClassForwa
 const ast_matchers::MatchFinder::MatchResult &Result,
 const NamedDecl *FwdDecl) {
   SourceLocation Start = FwdDecl->getBeginLoc();
-  SourceLocation End = FwdDecl->getLocEnd();
+  SourceLocation End = FwdDecl->getEndLoc();
   const SourceManager &SM = *Result.SourceManager;
   SourceLocation AfterSemi = Lexer::findLocationAfterToken(
   End, tok::semi, SM, Result.Context->getLangOpts(),
@@ -911,7 +911,7 @@ void ChangeNamespaceTool::fixUsingShadow
 const ast_matchers::MatchFinder::MatchResult &Result,
 const UsingDecl *UsingDeclaration) {
   SourceLocation Start = UsingDeclaration->getBeginLoc();
-  SourceLocation End = UsingDeclaration->getLocEnd();
+  SourceLocation End = UsingDeclaration->getEndLoc();
   if (Start.isInvalid() || End.isInvalid())
 return;
 

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=339401&r1=339400&r2=33940

r339402 - Remove obsolete set call

2018-08-09 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Aug  9 15:44:03 2018
New Revision: 339402

URL: http://llvm.org/viewvc/llvm-project?rev=339402&view=rev
Log:
Remove obsolete set call

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

Reviewers: rsmith, dblaikie

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=339402&r1=339401&r2=339402&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Aug  9 15:44:03 2018
@@ -4949,7 +4949,6 @@ Sema::GetNameFromUnqualifiedId(const Unq
   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 @@ Sema::GetNameFromUnqualifiedId(const Unq
 
 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 @@ Sema::GetNameFromUnqualifiedId(const Unq
   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 @@ Sema::GetNameFromUnqualifiedId(const Unq
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXConversionFunctionName(
Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }
@@ -5016,7 +5011,6 @@ Sema::GetNameFromUnqualifiedId(const Unq
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXConstructorName(
   Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }
@@ -5038,7 +5032,6 @@ Sema::GetNameFromUnqualifiedId(const Unq
 
 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 @@ Sema::GetNameFromUnqualifiedId(const Unq
   return DeclarationNameInfo();
 NameInfo.setName(Context.DeclarationNames.getCXXDestructorName(
   Context.getCanonicalType(Ty)));
-NameInfo.setLoc(Name.StartLocation);
 NameInfo.setNamedTypeInfo(TInfo);
 return NameInfo;
   }


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


r339730 - Fix Stmt::ignoreImplicit

2018-08-14 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Aug 14 14:33:28 2018
New Revision: 339730

URL: http://llvm.org/viewvc/llvm-project?rev=339730&view=rev
Log:
Fix Stmt::ignoreImplicit

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

Fixes the case reported in PR37327.

Reviewers: rsmith, dblaikie, klimek

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=339730&r1=339729&r2=339730&view=diff
==
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Tue Aug 14 14:33:28 2018
@@ -113,17 +113,23 @@ void Stmt::EnableStatistics() {
 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;
 }

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=339730&r1=339729&r2=339730&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Tue Aug 14 
14:33:28 2018
@@ -1321,6 +1321,45 @@ TEST(IgnoringImplicit, MatchesImplicit)
   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();


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


r339731 - Remove obsolete comment

2018-08-14 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Aug 14 14:34:29 2018
New Revision: 339731

URL: http://llvm.org/viewvc/llvm-project?rev=339731&view=rev
Log:
Remove obsolete comment

This related to the code as first checked in in r266292 ([ASTImporter]
Implement some expression-related AST node import., 2016-04-14).

Modified:
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=339731&r1=339730&r2=339731&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Tue Aug 14 14:34:29 2018
@@ -653,7 +653,6 @@ TEST_P(ImportExpr, ImportSwitch) {
 
 TEST_P(ImportExpr, ImportStmtExpr) {
   MatchVerifier Verifier;
-  // NOTE: has() ignores implicit casts, using hasDescendant() to match it
   testImport(
 "void declToImport() { int b; int a = b ?: 1; int C = ({int X=4; X;}); }",
 Lang_C, "", Lang_C, Verifier,


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


r339810 - Add a newline to SourceLocation dump output

2018-08-15 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Aug 15 13:32:06 2018
New Revision: 339810

URL: http://llvm.org/viewvc/llvm-project?rev=339810&view=rev
Log:
Add a newline to SourceLocation dump output

Summary:
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.

Subscribers: cfe-commits

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

Modified:
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

Modified: cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp?rev=339810&r1=339809&r2=339810&view=diff
==
--- cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp Wed Aug 15 13:32:06 2018
@@ -340,7 +340,7 @@ void MigrationContext::dumpGCAttrs() {
 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) {

Modified: cfe/trunk/lib/AST/CommentLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentLexer.cpp?rev=339810&r1=339809&r2=339810&view=diff
==
--- cfe/trunk/lib/AST/CommentLexer.cpp (original)
+++ cfe/trunk/lib/AST/CommentLexer.cpp Wed Aug 15 13:32:06 2018
@@ -21,7 +21,7 @@ namespace comments {
 
 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";
 }
 

Modified: cfe/trunk/lib/Analysis/LiveVariables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/LiveVariables.cpp?rev=339810&r1=339809&r2=339810&view=diff
==
--- cfe/trunk/lib/Analysis/LiveVariables.cpp (original)
+++ cfe/trunk/lib/Analysis/LiveVariables.cpp Wed Aug 15 13:32:06 2018
@@ -626,7 +626,7 @@ void LiveVariablesImpl::dumpBlockLivenes
  de = declVec.end(); di != de; ++di) {
   llvm::errs() << " " << (*di)->getDeclName().getAsString()
<< " <";
-  (*di)->getLocation().dump(M);
+  (*di)->getLocation().print(llvm::errs(), M);
   llvm::errs() << ">\n";
 }
   }

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=339810&r1=339809&r2=339810&view=diff
==
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Wed Aug 15 13:32:06 2018
@@ -239,7 +239,7 @@ DiagnosticsEngine::DiagStateMap::getFile
 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 @@ void DiagnosticsEngine::DiagStateMap::du
  << 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 @@ void DiagnosticsEngine::DiagStateMap::du
 llvm::errs() << "  ";
 SrcMgr.getLocForStartOfFile(ID)
   .getLocWithOffset(Transition.Offset)
-  .dump(SrcMgr);
+  .print(llvm::errs(), SrcMgr);
 llvm::errs() << ": state " << Transition.State << ":\n";
   };
 

Modified: cfe/trunk/lib/Basic/SourceLocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceLocation.cpp?rev=339810&r1=339809&r2=339810&view=diff
==
--- cfe/trunk/lib/Basic/SourceLocation.cpp (original)
+++ cfe/trunk/lib/Basic/SourceLocation.cpp Wed Aug 15 13:32:06 2018
@@ -77,6 +77,7 @@ SourceLocation::printToString(const Sour
 
 LLVM_DUMP_METHOD void SourceLocation::dump(const SourceManager &SM) const {
   print(llvm::errs(), SM);
+  llvm::errs() << '\n';
 }
 
 
//===--===//

Modifie

r340376 - Update the docs for using LLVM toolset in Visual Studio

2018-08-21 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Aug 21 18:11:18 2018
New Revision: 340376

URL: http://llvm.org/viewvc/llvm-project?rev=340376&view=rev
Log:
Update the docs for using LLVM toolset in Visual Studio

Reviewers: hans

Subscribers: cfe-commits

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

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=340376&r1=340375&r2=340376&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Tue Aug 21 18:11:18 2018
@@ -2711,16 +2711,17 @@ Command Prompt or a regular Command Prom
 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``.
@@ -2729,7 +2730,7 @@ When using CMake and the Visual Studio g
 
   ::
 
-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


r340586 - Fix typo

2018-08-23 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Aug 23 15:41:52 2018
New Revision: 340586

URL: http://llvm.org/viewvc/llvm-project?rev=340586&view=rev
Log:
Fix typo

Modified:
cfe/trunk/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp

Modified: 
cfe/trunk/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp?rev=340586&r1=340585&r2=340586&view=diff
==
--- cfe/trunk/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp 
(original)
+++ cfe/trunk/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp 
Thu Aug 23 15:41:52 2018
@@ -7,7 +7,7 @@
 //
 
//===--===//
 //
-// This tablegen backend emits an fficient function to translate HTML named
+// This tablegen backend emits an efficient function to translate HTML named
 // character references to UTF-8 sequences.
 //
 
//===--===//


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


r341140 - Add dump() method for SourceRange

2018-08-30 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Aug 30 16:10:52 2018
New Revision: 341140

URL: http://llvm.org/viewvc/llvm-project?rev=341140&view=rev
Log:
Add dump() method for SourceRange

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=341140&r1=341139&r2=341140&view=diff
==
--- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
+++ cfe/trunk/include/clang/Basic/SourceLocation.h Thu Aug 30 16:10:52 2018
@@ -220,6 +220,10 @@ public:
   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.

Modified: cfe/trunk/lib/Basic/SourceLocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceLocation.cpp?rev=341140&r1=341139&r2=341140&view=diff
==
--- cfe/trunk/lib/Basic/SourceLocation.cpp (original)
+++ cfe/trunk/lib/Basic/SourceLocation.cpp Thu Aug 30 16:10:52 2018
@@ -80,6 +80,60 @@ LLVM_DUMP_METHOD void SourceLocation::du
   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
 
//===--===//

Modified: cfe/trunk/unittests/Basic/SourceManagerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/SourceManagerTest.cpp?rev=341140&r1=341139&r2=341140&view=diff
==
--- cfe/trunk/unittests/Basic/SourceManagerTest.cpp (original)
+++ cfe/trunk/unittests/Basic/SourceManagerTest.cpp Thu Aug 30 16:10:52 2018
@@ -155,6 +155,54 @@ TEST_F(SourceManagerTest, getColumnNumbe
   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 = Sou

r341141 - Extract parseBindID method

2018-08-30 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Aug 30 16:11:01 2018
New Revision: 341141

URL: http://llvm.org/viewvc/llvm-project?rev=341141&view=rev
Log:
Extract parseBindID method

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h?rev=341141&r1=341140&r2=341141&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h Thu Aug 30 16:11:01 
2018
@@ -234,6 +234,7 @@ private:
  const NamedValueMap *NamedValues,
  Diagnostics *Error);
 
+  bool parseBindID(std::string &BindID);
   bool parseExpressionImpl(VariantValue *Value);
   bool parseMatcherExpressionImpl(const TokenInfo &NameToken,
   VariantValue *Value);

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp?rev=341141&r1=341140&r2=341141&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp Thu Aug 30 16:11:01 2018
@@ -359,6 +359,43 @@ bool Parser::parseIdentifierPrefixImpl(V
   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 @@ bool Parser::parseMatcherExpressionImpl(
 
   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)


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

r341142 - Allow binding to NamedValue resulting from let expression

2018-08-30 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Aug 30 16:11:09 2018
New Revision: 341142

URL: http://llvm.org/viewvc/llvm-project?rev=341142&view=rev
Log:
Allow binding to NamedValue resulting from let expression

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp?rev=341142&r1=341141&r2=341142&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp Thu Aug 30 16:11:09 2018
@@ -339,8 +339,27 @@ bool Parser::parseIdentifierPrefixImpl(V
 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.

Modified: cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp?rev=341142&r1=341141&r2=341142&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp Thu Aug 30 16:11:09 
2018
@@ -359,6 +359,44 @@ TEST(ParserTest, CompletionNamedValues)
   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


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


[clang-tools-extra] r341145 - Add preload option to clang-query

2018-08-30 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Aug 30 16:25:44 2018
New Revision: 341145

URL: http://llvm.org/viewvc/llvm-project?rev=341145&view=rev
Log:
Add preload option to clang-query

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

Subscribers: cfe-commits

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

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

Modified: clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp?rev=341145&r1=341144&r2=341145&view=diff
==
--- clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp (original)
+++ clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp Thu Aug 30 16:25:44 
2018
@@ -58,6 +58,11 @@ static cl::list CommandFile
   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 @@ int main(int argc, const char **argv) {
 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 @@ int main(int argc, const char **argv) {
 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


[clang-tools-extra] r341144 - Extract runCommandsInFile method

2018-08-30 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Aug 30 16:25:38 2018
New Revision: 341144

URL: http://llvm.org/viewvc/llvm-project?rev=341144&view=rev
Log:
Extract runCommandsInFile method

Subscribers: cfe-commits

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

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

Modified: clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp?rev=341144&r1=341143&r2=341144&view=diff
==
--- clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp (original)
+++ clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp Thu Aug 30 16:25:38 
2018
@@ -58,6 +58,24 @@ static cl::list CommandFile
   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 @@ int main(int argc, const char **argv) {
 }
   } 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


r341146 - Remove vestiges of configure buildsystem

2018-08-30 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Aug 30 16:41:03 2018
New Revision: 341146

URL: http://llvm.org/viewvc/llvm-project?rev=341146&view=rev
Log:
Remove vestiges of configure buildsystem

Summary:

Subscribers: mgorny, cfe-commits

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

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=341146&r1=341145&r2=341146&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Thu Aug 30 16:41:03 2018
@@ -289,25 +289,13 @@ set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOU
 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


Re: r341141 - Extract parseBindID method

2018-09-06 Thread Stephen Kelly via cfe-commits


Yes, this was a prerequisite to https://reviews.llvm.org/D51259. For 
some reason the reviewer accepted that one, but not this one. I simply 
assumed that was a mistake and committed this one.


Perhaps part of the problem is that I do one thing per commit, and that 
confuses reviewers. Maybe I should squash things for review? I don't know.


Thanks for any post-commit review!

Stephen.

On 31/08/18 07:06, Roman Lebedev via cfe-commits wrote:

I don't think this was reviewed. The differential is not in 'accepted' state.

Roman.

On Fri, Aug 31, 2018 at 2:11 AM, Stephen Kelly via cfe-commits
 wrote:

Author: steveire
Date: Thu Aug 30 16:11:01 2018
New Revision: 341141

URL: http://llvm.org/viewvc/llvm-project?rev=341141&view=rev
Log:
Extract parseBindID method

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h?rev=341141&r1=341140&r2=341141&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h Thu Aug 30 16:11:01 
2018
@@ -234,6 +234,7 @@ private:
   const NamedValueMap *NamedValues,
   Diagnostics *Error);

+  bool parseBindID(std::string &BindID);
bool parseExpressionImpl(VariantValue *Value);
bool parseMatcherExpressionImpl(const TokenInfo &NameToken,
VariantValue *Value);

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp?rev=341141&r1=341140&r2=341141&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp Thu Aug 30 16:11:01 2018
@@ -359,6 +359,43 @@ bool Parser::parseIdentifierPrefixImpl(V
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 @@ bool Parser::parseMatcherExpressionImpl(

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::I

Re: r341141 - Extract parseBindID method

2018-09-06 Thread Stephen Kelly via cfe-commits



On 06/09/18 20:42, Roman Lebedev wrote:

You can specify the dependencies between the differentials in phabricator.



I didn't know that, thanks!
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r341583 - Fix reported range of partial token replacement

2018-09-06 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Sep  6 13:16:34 2018
New Revision: 341583

URL: http://llvm.org/viewvc/llvm-project?rev=341583&view=rev
Log:
Fix reported range of partial token replacement

Summary: Fixes bug: 38678

Reviewers: klimek, rsmith

Subscribers: cfe-commits

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

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

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=341583&r1=341582&r2=341583&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Sep  6 13:16:34 2018
@@ -122,10 +122,6 @@ public:
   << 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 @@ public:
 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


r338301 - Avoid returning an invalid end source loc

2018-07-30 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Mon Jul 30 13:39:14 2018
New Revision: 338301

URL: http://llvm.org/viewvc/llvm-project?rev=338301&view=rev
Log:
Avoid returning an invalid end source loc

Modified:
cfe/trunk/include/clang/AST/DeclarationName.h
cfe/trunk/lib/AST/DeclarationName.cpp

Modified: cfe/trunk/include/clang/AST/DeclarationName.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclarationName.h?rev=338301&r1=338300&r2=338301&view=diff
==
--- cfe/trunk/include/clang/AST/DeclarationName.h (original)
+++ cfe/trunk/include/clang/AST/DeclarationName.h Mon Jul 30 13:39:14 2018
@@ -558,7 +558,7 @@ public:
   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 @@ public:
   }
 
   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

Modified: cfe/trunk/lib/AST/DeclarationName.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclarationName.cpp?rev=338301&r1=338300&r2=338301&view=diff
==
--- cfe/trunk/lib/AST/DeclarationName.cpp (original)
+++ cfe/trunk/lib/AST/DeclarationName.cpp Mon Jul 30 13:39:14 2018
@@ -689,7 +689,7 @@ void DeclarationNameInfo::printName(raw_
   llvm_unreachable("Unexpected declaration name kind");
 }
 
-SourceLocation DeclarationNameInfo::getEndLoc() const {
+SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
   switch (Name.getNameKind()) {
   case DeclarationName::Identifier:
   case DeclarationName::CXXDeductionGuideName:


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


[clang-tools-extra] r344840 - [clang-query] Add option to print matcher expression

2018-10-20 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sat Oct 20 02:13:59 2018
New Revision: 344840

URL: http://llvm.org/viewvc/llvm-project?rev=344840&view=rev
Log:
[clang-query] Add option to print matcher expression

Summary:
This is useful if using clang-query -f with a file containing multiple
matchers.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
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

Modified: clang-tools-extra/trunk/clang-query/Query.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.cpp?rev=344840&r1=344839&r2=344840&view=diff
==
--- clang-tools-extra/trunk/clang-query/Query.cpp (original)
+++ clang-tools-extra/trunk/clang-query/Query.cpp Sat Oct 20 02:13:59 2018
@@ -41,6 +41,8 @@ bool HelpQuery::run(llvm::raw_ostream &O
 "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 @@ bool MatchQuery::run(llvm::raw_ostream &
 }
 Finder.matchAST(AST->getASTContext());
 
+if (QS.PrintMatcher) {
+  std::string prefixText = "Matcher: ";
+  OS << "\n  " << prefixText << Source << "\n";
+  OS << "  " << std::string(prefixText.size() + Source.size(), '=') << 
'\n';
+}
+
 for (auto MI = Matches.begin(), ME = Matches.end(); MI != ME; ++MI) {
   OS << "\nMatch #" << ++MatchCount << ":\n\n";
 

Modified: clang-tools-extra/trunk/clang-query/Query.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.h?rev=344840&r1=344839&r2=344840&view=diff
==
--- clang-tools-extra/trunk/clang-query/Query.h (original)
+++ clang-tools-extra/trunk/clang-query/Query.h Sat Oct 20 02:13:59 2018
@@ -83,12 +83,15 @@ struct QuitQuery : Query {
 
 /// 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; }
 };
 

Modified: clang-tools-extra/trunk/clang-query/QueryParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QueryParser.cpp?rev=344840&r1=344839&r2=344840&view=diff
==
--- clang-tools-extra/trunk/clang-query/QueryParser.cpp (original)
+++ clang-tools-extra/trunk/clang-query/QueryParser.cpp Sat Oct 20 02:13:59 2018
@@ -142,7 +142,12 @@ enum ParsedQueryKind {
   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 @@ QueryRef QueryParser::doParse() {
   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

[clang-tools-extra] r345192 - [clang-query] Re-word command help

2018-10-24 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Oct 24 13:33:14 2018
New Revision: 345192

URL: http://llvm.org/viewvc/llvm-project?rev=345192&view=rev
Log:
[clang-query] Re-word command help

Summary:
This will make it possible to easily

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

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-query/Query.cpp

Modified: clang-tools-extra/trunk/clang-query/Query.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.cpp?rev=345192&r1=345191&r2=345192&view=diff
==
--- clang-tools-extra/trunk/clang-query/Query.cpp (original)
+++ clang-tools-extra/trunk/clang-query/Query.cpp Wed Oct 24 13:33:14 2018
@@ -43,12 +43,18 @@ bool HelpQuery::run(llvm::raw_ostream &O
 "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


[clang-tools-extra] r345193 - [clang-query] Add 'detailed-ast' output as an alias for 'dump'

2018-10-24 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Oct 24 13:33:45 2018
New Revision: 345193

URL: http://llvm.org/viewvc/llvm-project?rev=345193&view=rev
Log:
[clang-query] Add 'detailed-ast' output as an alias for 'dump'

Summary: Future development can then dump other content than AST.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
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/unittests/clang-query/QueryEngineTest.cpp
clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp

Modified: clang-tools-extra/trunk/clang-query/Query.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.cpp?rev=345193&r1=345192&r2=345193&view=diff
==
--- clang-tools-extra/trunk/clang-query/Query.cpp (original)
+++ clang-tools-extra/trunk/clang-query/Query.cpp Wed Oct 24 13:33:45 2018
@@ -53,8 +53,10 @@ bool HelpQuery::run(llvm::raw_ostream &O
 "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 @@ bool MatchQuery::run(llvm::raw_ostream &
   OS << "\n";
   break;
 }
-case OK_Dump: {
+case OK_DetailedAST: {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.dump(OS, AST->getSourceManager());
   OS << "\n";

Modified: clang-tools-extra/trunk/clang-query/Query.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.h?rev=345193&r1=345192&r2=345193&view=diff
==
--- clang-tools-extra/trunk/clang-query/Query.h (original)
+++ clang-tools-extra/trunk/clang-query/Query.h Wed Oct 24 13:33:45 2018
@@ -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,

Modified: clang-tools-extra/trunk/clang-query/QueryParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QueryParser.cpp?rev=345193&r1=345192&r2=345193&view=diff
==
--- clang-tools-extra/trunk/clang-query/QueryParser.cpp (original)
+++ clang-tools-extra/trunk/clang-query/QueryParser.cpp Wed Oct 24 13:33:45 2018
@@ -111,11 +111,13 @@ QueryRef QueryParser::parseSetOutputKind
   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));
 }

Modified: clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp?rev=345193&r1=345192&r2=345193&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp Wed Oct 
24 13:33:45 2018
@@ -103,7 +103,8 @@ TEST_F(QueryEngineTest, Basic) {
 
   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);

Modified: clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp?rev=345193&r1=345192&r2=345193&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp Wed Oct 
24 13:33:45 

[clang-tools-extra] r345194 - [clang-query] Refactor Output settings to booleans

2018-10-24 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Oct 24 13:33:55 2018
New Revision: 345194

URL: http://llvm.org/viewvc/llvm-project?rev=345194&view=rev
Log:
[clang-query] Refactor Output settings to booleans

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

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
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
clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp

Modified: clang-tools-extra/trunk/clang-query/Query.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.cpp?rev=345194&r1=345193&r2=345194&view=diff
==
--- clang-tools-extra/trunk/clang-query/Query.cpp (original)
+++ clang-tools-extra/trunk/clang-query/Query.cpp Wed Oct 24 13:33:55 2018
@@ -107,8 +107,7 @@ bool MatchQuery::run(llvm::raw_ostream &
 
   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(),
@@ -118,20 +117,16 @@ bool MatchQuery::run(llvm::raw_ostream &
 DiagnosticsEngine::Note, "\"" + BI->first + "\" binds here",
 CharSourceRange::getTokenRange(R), None);
   }
-  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;
-}
 }
   }
 

Modified: clang-tools-extra/trunk/clang-query/Query.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.h?rev=345194&r1=345193&r2=345194&view=diff
==
--- clang-tools-extra/trunk/clang-query/Query.h (original)
+++ clang-tools-extra/trunk/clang-query/Query.h Wed Oct 24 13:33:55 2018
@@ -10,6 +10,7 @@
 #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"
@@ -133,6 +134,23 @@ template  struct SetQuery :
   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
 

Modified: clang-tools-extra/trunk/clang-query/QueryParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QueryParser.cpp?rev=345194&r1=345193&r2=345194&view=diff
==
--- clang-tools-extra/trunk/clang-query/QueryParser.cpp (original)
+++ clang-tools-extra/trunk/clang-query/QueryParser.cpp Wed Oct 24 13:33:55 2018
@@ -119,7 +119,17 @@ QueryRef QueryParser::parseSetOutputKind
 "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) {

Modified: clang-tools-extra/trunk/clang-query/QuerySession.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QuerySession.h?rev=345194&r1=345193&r2=345194&view=diff
==
--- clang-tools-extra/trunk/clang-query/QuerySession.h (original)
+++ clan

[clang-tools-extra] r345522 - [clang-query] Add non-exclusive output API

2018-10-29 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Mon Oct 29 11:59:56 2018
New Revision: 345522

URL: http://llvm.org/viewvc/llvm-project?rev=345522&view=rev
Log:
[clang-query] Add non-exclusive output API

Summary:
Add granular options for AST dumping, text printing and diagnostics.

This makes it possible to

* Have both diag and dump active at once
* Extend the output with other queryable content in the future.

Reviewers: aaron.ballman, pcc, ioeric, ilya-biryukov, klimek, sammccall

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

Modified:
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/QueryParser.h
clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp
clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp

Modified: clang-tools-extra/trunk/clang-query/Query.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.cpp?rev=345522&r1=345521&r2=345522&view=diff
==
--- clang-tools-extra/trunk/clang-query/Query.cpp (original)
+++ clang-tools-extra/trunk/clang-query/Query.cpp Mon Oct 29 11:59:56 2018
@@ -45,6 +45,10 @@ bool HelpQuery::run(llvm::raw_ostream &O
 "Set whether to print the current matcher,\n"
 "  set output   "
 "Set whether to output only  content.\n"
+"  enable output"
+"Enable  content non-exclusively.\n"
+"  disable output   "
+"Disable  content non-exclusively.\n"
 "  quit, q   "
 "Terminates the query session.\n\n"
 "Several commands accept a  parameter. The available features 
"

Modified: clang-tools-extra/trunk/clang-query/Query.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.h?rev=345522&r1=345521&r2=345522&view=diff
==
--- clang-tools-extra/trunk/clang-query/Query.h (original)
+++ clang-tools-extra/trunk/clang-query/Query.h Mon Oct 29 11:59:56 2018
@@ -29,6 +29,8 @@ enum QueryKind {
   QK_Match,
   QK_SetBool,
   QK_SetOutputKind,
+  QK_EnableOutputKind,
+  QK_DisableOutputKind,
   QK_Quit
 };
 
@@ -151,6 +153,36 @@ struct SetExclusiveOutputQuery : Query {
   bool QuerySession::*Var;
 };
 
+// Implements the non-exclusive 'set output dump|diag|print' options.
+struct SetNonExclusiveOutputQuery : Query {
+  SetNonExclusiveOutputQuery(QueryKind Kind, bool QuerySession::*Var,
+ bool Value)
+  : Query(Kind), Var(Var), Value(Value) {}
+  bool run(llvm::raw_ostream &OS, QuerySession &QS) const override {
+QS.*Var = Value;
+return true;
+  }
+
+  bool QuerySession::*Var;
+  bool Value;
+};
+
+struct EnableOutputQuery : SetNonExclusiveOutputQuery {
+  EnableOutputQuery(bool QuerySession::*Var)
+  : SetNonExclusiveOutputQuery(QK_EnableOutputKind, Var, true) {}
+
+  static bool classof(const Query *Q) { return Q->Kind == QK_EnableOutputKind; 
}
+};
+
+struct DisableOutputQuery : SetNonExclusiveOutputQuery {
+  DisableOutputQuery(bool QuerySession::*Var)
+  : SetNonExclusiveOutputQuery(QK_DisableOutputKind, Var, false) {}
+
+  static bool classof(const Query *Q) {
+return Q->Kind == QK_DisableOutputKind;
+  }
+};
+
 } // namespace query
 } // namespace clang
 

Modified: clang-tools-extra/trunk/clang-query/QueryParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QueryParser.cpp?rev=345522&r1=345521&r2=345522&view=diff
==
--- clang-tools-extra/trunk/clang-query/QueryParser.cpp (original)
+++ clang-tools-extra/trunk/clang-query/QueryParser.cpp Mon Oct 29 11:59:56 2018
@@ -106,7 +106,7 @@ QueryRef QueryParser::parseSetBool(bool
   return new SetQuery(Var, Value);
 }
 
-QueryRef QueryParser::parseSetOutputKind() {
+template  QueryRef QueryParser::parseSetOutputKind() {
   StringRef ValStr;
   unsigned OutKind = LexOrCompleteWord(this, ValStr)
  .Case("diag", OK_Diag)
@@ -122,11 +122,11 @@ QueryRef QueryParser::parseSetOutputKind
 
   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");
@@ -151,7 +151,9 @@ enum ParsedQueryKind {
   PQK_Match,
   PQK_Set,
   PQK_Unlet,
-  PQK_Quit
+  PQK_Quit,
+  PQK_Enable,

r350957 - [ASTDump] Add utility for dumping a label with child nodes

2019-01-11 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Fri Jan 11 11:11:17 2019
New Revision: 350957

URL: http://llvm.org/viewvc/llvm-project?rev=350957&view=rev
Log:
[ASTDump] Add utility for dumping a label with child nodes

Summary:
Use it to add optional label nodes to Stmt dumps.  This preserves
behavior of InitExprList dump:

// CHECK-NEXT: `-InitListExpr {{.+}}  'U [3]'
// CHECK-NEXT:   |-array_filler: InitListExpr {{.+}}  'U' field Field 
{{.+}} 'i' 'int'
// CHECK-NEXT:   `-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 'int'
// CHECK-NEXT: `-IntegerLiteral {{.+}}  'int' 1

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/test/AST/ast-dump-stmt.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=350957&r1=350956&r2=350957&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Fri Jan 11 11:11:17 2019
@@ -41,6 +41,12 @@ class TextTreeStructure {
 public:
   /// Add a child of the current node.  Calls DoAddChild without arguments
   template  void AddChild(Fn DoAddChild) {
+return AddChild("", DoAddChild);
+  }
+
+  /// Add a child of the current node with an optional label.
+  /// Calls DoAddChild without arguments.
+  template  void AddChild(StringRef Label, Fn DoAddChild) {
 // If we're at the top level, there's nothing interesting to do; just
 // run the dumper.
 if (TopLevel) {
@@ -56,7 +62,10 @@ public:
   return;
 }
 
-auto DumpWithIndent = [this, DoAddChild](bool IsLastChild) {
+// We need to capture an owning-string in the lambda because the lambda
+// is invoked in a deferred manner.
+std::string LabelStr = Label;
+auto DumpWithIndent = [this, DoAddChild, LabelStr](bool IsLastChild) {
   // Print out the appropriate tree structure and work out the prefix for
   // children of this node. For instance:
   //
@@ -73,6 +82,9 @@ public:
 OS << '\n';
 ColorScope Color(OS, ShowColors, IndentColor);
 OS << Prefix << (IsLastChild ? '`' : '|') << '-';
+if (!LabelStr.empty())
+  OS << LabelStr << ": ";
+
 this->Prefix.push_back(IsLastChild ? ' ' : '|');
 this->Prefix.push_back(' ');
   }

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=350957&r1=350956&r2=350957&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Fri Jan 11 11:11:17 2019
@@ -61,6 +61,9 @@ namespace  {
 template void dumpChild(Fn DoDumpChild) {
   NodeDumper.AddChild(DoDumpChild);
 }
+template  void dumpChild(StringRef Label, Fn DoDumpChild) {
+  NodeDumper.AddChild(Label, DoDumpChild);
+}
 
   public:
 ASTDumper(raw_ostream &OS, const CommandTraits *Traits,
@@ -80,7 +83,7 @@ namespace  {
 void setDeserialize(bool D) { Deserialize = D; }
 
 void dumpDecl(const Decl *D);
-void dumpStmt(const Stmt *S);
+void dumpStmt(const Stmt *S, StringRef Label = {});
 
 // Utilities
 void dumpType(QualType T) { NodeDumper.dumpType(T); }
@@ -1685,8 +1688,8 @@ void ASTDumper::VisitBlockDecl(const Blo
 //  Stmt dumping methods.
 
//===--===//
 
-void ASTDumper::dumpStmt(const Stmt *S) {
-  dumpChild([=] {
+void ASTDumper::dumpStmt(const Stmt *S, StringRef Label) {
+  dumpChild(Label, [=] {
 if (!S) {
   ColorScope Color(OS, ShowColors, NullColor);
   OS << "<<>>";
@@ -1957,10 +1960,7 @@ void ASTDumper::VisitInitListExpr(const
 NodeDumper.dumpBareDeclRef(Field);
   }
   if (auto *Filler = ILE->getArrayFiller()) {
-dumpChild([=] {
-  OS << "array filler";
-  dumpStmt(Filler);
-});
+dumpStmt(Filler, "array_filler");
   }
 }
 

Modified: cfe/trunk/test/AST/ast-dump-stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-stmt.cpp?rev=350957&r1=350956&r2=350957&view=diff
==
--- cfe/trunk/test/AST/ast-dump-stmt.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-stmt.cpp Fri Jan 11 11:11:17 2019
@@ -91,8 +91,7 @@ void TestUnionInitList()
   U us[3] = {1};
 // CHECK: VarDecl {{.+}}  col:5 us 'U [3]' cinit
 // CHECK-NEXT: `-InitListExpr {{.+}}  'U [3]'
-// CHECK-NEXT:   |-array filler
-// CHECK-NEXT:   | `-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 
'int'
+// CHECK-NEXT:   |-array_filler: InitListExpr {{.+}}  'U' field Field 
{{.+}} 'i' 'int'
 // CHECK-NEXT:   `-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 
'int'
 // CHECK-NEXT:  

r350958 - Implement Attr dumping in terms of visitors

2019-01-11 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Fri Jan 11 11:16:01 2019
New Revision: 350958

URL: http://llvm.org/viewvc/llvm-project?rev=350958&view=rev
Log:
Implement Attr dumping in terms of visitors

Remove now-vestigial dumpType and dumpBareDeclRef methods. The old
tablegen generated code used to expect them to be present, but the new
generated code has no such requirement.

Reviewers: aaron.ballman

Subscribers: mgorny, cfe-commits

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

Added:
cfe/trunk/include/clang/AST/AttrVisitor.h
Modified:
cfe/trunk/include/clang/AST/CMakeLists.txt
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
cfe/trunk/utils/TableGen/TableGen.cpp
cfe/trunk/utils/TableGen/TableGenBackends.h

Added: cfe/trunk/include/clang/AST/AttrVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/AttrVisitor.h?rev=350958&view=auto
==
--- cfe/trunk/include/clang/AST/AttrVisitor.h (added)
+++ cfe/trunk/include/clang/AST/AttrVisitor.h Fri Jan 11 11:16:01 2019
@@ -0,0 +1,76 @@
+//===- AttrVisitor.h - Visitor for Attr subclasses --*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines the AttrVisitor interface.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_ATTRVISITOR_H
+#define LLVM_CLANG_AST_ATTRVISITOR_H
+
+#include "clang/AST/Attr.h"
+
+namespace clang {
+
+namespace attrvisitor {
+
+/// A simple visitor class that helps create attribute visitors.
+template  class Ptr, typename ImplClass,
+  typename RetTy = void, class... ParamTys>
+class Base {
+public:
+#define PTR(CLASS) typename Ptr::type
+#define DISPATCH(NAME) 
\
+  return static_cast(this)->Visit##NAME(static_cast(A))
+
+  RetTy Visit(PTR(Attr) A) {
+switch (A->getKind()) {
+
+#define ATTR(NAME) 
\
+  case attr::NAME: 
\
+DISPATCH(NAME##Attr);
+#include "clang/Basic/AttrList.inc"
+}
+llvm_unreachable("Attr that isn't part of AttrList.inc!");
+  }
+
+  // If the implementation chooses not to implement a certain visit
+  // method, fall back to the parent.
+#define ATTR(NAME) 
\
+  RetTy Visit##NAME##Attr(PTR(NAME##Attr) A) { DISPATCH(Attr); }
+#include "clang/Basic/AttrList.inc"
+
+  RetTy VisitAttr(PTR(Attr)) { return RetTy(); }
+
+#undef PTR
+#undef DISPATCH
+};
+
+} // namespace attrvisitor
+
+/// A simple visitor class that helps create attribute visitors.
+///
+/// This class does not preserve constness of Attr pointers (see
+/// also ConstAttrVisitor).
+template 
+class AttrVisitor : public attrvisitor::Base {};
+
+/// A simple visitor class that helps create attribute visitors.
+///
+/// This class preserves constness of Attr pointers (see also
+/// AttrVisitor).
+template 
+class ConstAttrVisitor
+: public attrvisitor::Base {};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_AST_ATTRVISITOR_H

Modified: cfe/trunk/include/clang/AST/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CMakeLists.txt?rev=350958&r1=350957&r2=350958&view=diff
==
--- cfe/trunk/include/clang/AST/CMakeLists.txt (original)
+++ cfe/trunk/include/clang/AST/CMakeLists.txt Fri Jan 11 11:16:01 2019
@@ -8,10 +8,15 @@ clang_tablegen(AttrImpl.inc -gen-clang-a
   SOURCE ../Basic/Attr.td
   TARGET ClangAttrImpl)
 
-clang_tablegen(AttrDump.inc -gen-clang-attr-dump
+clang_tablegen(AttrTextNodeDump.inc -gen-clang-attr-text-node-dump
   -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
   SOURCE ../Basic/Attr.td
-  TARGET ClangAttrDump)
+  TARGET ClangAttrTextDump)
+
+clang_tablegen(AttrNodeTraverse.inc -gen-clang-attr-node-traverse
+  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
+  SOURCE ../Basic/Attr.td
+  TARGET ClangAttrTraverse)
 
 clang_tablegen(AttrVisitor.inc -gen-clang-attr-ast-visitor
   -I ${CMAKE_CURRENT_SOURCE_DIR}/../../

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=350958&r1=350957&r2=350958&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Fri Jan 11 11:16:01 2019
@@ -16,6 +16,7 @@
 
 #include "clang/AST/ASTCont

r350984 - NFC: Port loop to cxx_range_for

2019-01-11 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Fri Jan 11 16:42:59 2019
New Revision: 350984

URL: http://llvm.org/viewvc/llvm-project?rev=350984&view=rev
Log:
NFC: Port loop to cxx_range_for

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=350984&r1=350983&r2=350984&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Fri Jan 11 16:42:59 2019
@@ -709,9 +709,8 @@ void ASTDumper::dumpTemplateArgument(con
   break;
 case TemplateArgument::Pack:
   OS << " pack";
-  for (TemplateArgument::pack_iterator I = A.pack_begin(), E = 
A.pack_end();
-   I != E; ++I)
-dumpTemplateArgument(*I);
+  for (const auto& TArg : A.pack_elements())
+dumpTemplateArgument(TArg);
   break;
 }
   });


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


r351011 - [ASTDump] Change parameter to StringRef

2019-01-12 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sat Jan 12 07:45:05 2019
New Revision: 351011

URL: http://llvm.org/viewvc/llvm-project?rev=351011&view=rev
Log:
[ASTDump] Change parameter to StringRef

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351011&r1=351010&r2=351011&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Sat Jan 12 07:45:05 2019
@@ -160,7 +160,7 @@ public:
   void dumpAccessSpecifier(AccessSpecifier AS);
   void dumpCXXTemporary(const CXXTemporary *Temporary);
 
-  void dumpDeclRef(const Decl *D, const char *Label = nullptr);
+  void dumpDeclRef(const Decl *D, StringRef Label = {});
 
   void visitTextComment(const comments::TextComment *C,
 const comments::FullComment *);

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=351011&r1=351010&r2=351011&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Sat Jan 12 07:45:05 2019
@@ -184,12 +184,12 @@ void TextNodeDumper::dumpCXXTemporary(co
   OS << ")";
 }
 
-void TextNodeDumper::dumpDeclRef(const Decl *D, const char *Label) {
+void TextNodeDumper::dumpDeclRef(const Decl *D, StringRef Label) {
   if (!D)
 return;
 
   AddChild([=] {
-if (Label)
+if (!Label.empty())
   OS << Label << ' ';
 dumpBareDeclRef(D);
   });


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


r351012 - Implement TemplateArgument dumping in terms of Visitor

2019-01-12 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sat Jan 12 08:35:37 2019
New Revision: 351012

URL: http://llvm.org/viewvc/llvm-project?rev=351012&view=rev
Log:
Implement TemplateArgument dumping in terms of Visitor

Summary: Split the output streaming from the traversal to other AST nodes.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Added:
cfe/trunk/include/clang/AST/TemplateArgumentVisitor.h
Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Added: cfe/trunk/include/clang/AST/TemplateArgumentVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateArgumentVisitor.h?rev=351012&view=auto
==
--- cfe/trunk/include/clang/AST/TemplateArgumentVisitor.h (added)
+++ cfe/trunk/include/clang/AST/TemplateArgumentVisitor.h Sat Jan 12 08:35:37 
2019
@@ -0,0 +1,99 @@
+//===- TemplateArgumentVisitor.h - Visitor for TArg subclasses --*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines the TemplateArgumentVisitor interface.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_TEMPLATEARGUMENTVISITOR_H
+#define LLVM_CLANG_AST_TEMPLATEARGUMENTVISITOR_H
+
+#include "clang/AST/TemplateBase.h"
+
+namespace clang {
+
+namespace templateargumentvisitor {
+
+/// A simple visitor class that helps create template argument visitors.
+template  class Ref, typename ImplClass,
+  typename RetTy = void, typename... ParamTys>
+class Base {
+public:
+#define REF(CLASS) typename Ref::type
+#define DISPATCH(NAME) 
\
+  case TemplateArgument::NAME: 
\
+return static_cast(this)->Visit##NAME##TemplateArgument(  
\
+TA, std::forward(P)...)
+
+  RetTy Visit(REF(TemplateArgument) TA, ParamTys... P) {
+switch (TA.getKind()) {
+  DISPATCH(Null);
+  DISPATCH(Type);
+  DISPATCH(Declaration);
+  DISPATCH(NullPtr);
+  DISPATCH(Integral);
+  DISPATCH(Template);
+  DISPATCH(TemplateExpansion);
+  DISPATCH(Expression);
+  DISPATCH(Pack);
+}
+llvm_unreachable("TemplateArgument is not covered in switch!");
+  }
+
+  // If the implementation chooses not to implement a certain visit
+  // method, fall back to the parent.
+
+#define VISIT_METHOD(CATEGORY) 
\
+  RetTy Visit##CATEGORY##TemplateArgument(REF(TemplateArgument) TA,
\
+  ParamTys... P) { 
\
+return VisitTemplateArgument(TA, std::forward(P)...);
\
+  }
+
+  VISIT_METHOD(Null);
+  VISIT_METHOD(Type);
+  VISIT_METHOD(Declaration);
+  VISIT_METHOD(NullPtr);
+  VISIT_METHOD(Integral);
+  VISIT_METHOD(Template);
+  VISIT_METHOD(TemplateExpansion);
+  VISIT_METHOD(Expression);
+  VISIT_METHOD(Pack);
+
+  RetTy VisitTemplateArgument(REF(TemplateArgument), ParamTys...) {
+return RetTy();
+  }
+
+#undef REF
+#undef DISPATCH
+#undef VISIT_METHOD
+};
+
+} // namespace templateargumentvisitor
+
+/// A simple visitor class that helps create template argument visitors.
+///
+/// This class does not preserve constness of TemplateArgument references (see
+/// also ConstTemplateArgumentVisitor).
+template 
+class TemplateArgumentVisitor
+: public templateargumentvisitor::Base {};
+
+/// A simple visitor class that helps create template argument visitors.
+///
+/// This class preserves constness of TemplateArgument references (see also
+/// TemplateArgumentVisitor).
+template 
+class ConstTemplateArgumentVisitor
+: public templateargumentvisitor::Base {};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_AST_TEMPLATEARGUMENTVISITOR_H

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351012&r1=351011&r2=351012&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Sat Jan 12 08:35:37 2019
@@ -20,6 +20,7 @@
 #include "clang/AST/CommentCommandTraits.h"
 #include "clang/AST/CommentVisitor.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/TemplateArgumentVisitor.h"
 
 namespace clang {
 
@@ -123,7 +124,8 @@ class TextNodeDumper
 : public TextTreeStructure,
   public comments::ConstCommentVisitor,
-  public ConstAttrVisitor {
+  public ConstAttrVisitor,
+  public ConstTemplateArgumentVisitor {
   raw_ost

r351014 - [ASTDump] NFC: Move dump of individual Stmts to TextNodeDumper

2019-01-12 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sat Jan 12 08:53:27 2019
New Revision: 351014

URL: http://llvm.org/viewvc/llvm-project?rev=351014&view=rev
Log:
[ASTDump] NFC: Move dump of individual Stmts to TextNodeDumper

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351014&r1=351013&r2=351014&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Sat Jan 12 08:53:27 2019
@@ -20,6 +20,7 @@
 #include "clang/AST/CommentCommandTraits.h"
 #include "clang/AST/CommentVisitor.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/StmtVisitor.h"
 #include "clang/AST/TemplateArgumentVisitor.h"
 
 namespace clang {
@@ -125,7 +126,8 @@ class TextNodeDumper
   public comments::ConstCommentVisitor,
   public ConstAttrVisitor,
-  public ConstTemplateArgumentVisitor {
+  public ConstTemplateArgumentVisitor,
+  public ConstStmtVisitor {
   raw_ostream &OS;
   const bool ShowColors;
 
@@ -155,6 +157,8 @@ public:
   void Visit(const TemplateArgument &TA, SourceRange R,
  const Decl *From = nullptr, StringRef Label = {});
 
+  void Visit(const Stmt *Node);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);
@@ -201,6 +205,56 @@ public:
   void VisitTemplateExpansionTemplateArgument(const TemplateArgument &TA);
   void VisitExpressionTemplateArgument(const TemplateArgument &TA);
   void VisitPackTemplateArgument(const TemplateArgument &TA);
+
+  void VisitIfStmt(const IfStmt *Node);
+  void VisitSwitchStmt(const SwitchStmt *Node);
+  void VisitWhileStmt(const WhileStmt *Node);
+  void VisitLabelStmt(const LabelStmt *Node);
+  void VisitGotoStmt(const GotoStmt *Node);
+  void VisitCaseStmt(const CaseStmt *Node);
+  void VisitCallExpr(const CallExpr *Node);
+  void VisitCastExpr(const CastExpr *Node);
+  void VisitImplicitCastExpr(const ImplicitCastExpr *Node);
+  void VisitDeclRefExpr(const DeclRefExpr *Node);
+  void VisitPredefinedExpr(const PredefinedExpr *Node);
+  void VisitCharacterLiteral(const CharacterLiteral *Node);
+  void VisitIntegerLiteral(const IntegerLiteral *Node);
+  void VisitFixedPointLiteral(const FixedPointLiteral *Node);
+  void VisitFloatingLiteral(const FloatingLiteral *Node);
+  void VisitStringLiteral(const StringLiteral *Str);
+  void VisitInitListExpr(const InitListExpr *ILE);
+  void VisitUnaryOperator(const UnaryOperator *Node);
+  void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Node);
+  void VisitMemberExpr(const MemberExpr *Node);
+  void VisitExtVectorElementExpr(const ExtVectorElementExpr *Node);
+  void VisitBinaryOperator(const BinaryOperator *Node);
+  void VisitCompoundAssignOperator(const CompoundAssignOperator *Node);
+  void VisitAddrLabelExpr(const AddrLabelExpr *Node);
+  void VisitCXXNamedCastExpr(const CXXNamedCastExpr *Node);
+  void VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *Node);
+  void VisitCXXThisExpr(const CXXThisExpr *Node);
+  void VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *Node);
+  void VisitCXXUnresolvedConstructExpr(const CXXUnresolvedConstructExpr *Node);
+  void VisitCXXConstructExpr(const CXXConstructExpr *Node);
+  void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *Node);
+  void VisitCXXNewExpr(const CXXNewExpr *Node);
+  void VisitCXXDeleteExpr(const CXXDeleteExpr *Node);
+  void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *Node);
+  void VisitExprWithCleanups(const ExprWithCleanups *Node);
+  void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node);
+  void VisitSizeOfPackExpr(const SizeOfPackExpr *Node);
+  void
+  VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *Node);
+  void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node);
+  void VisitObjCEncodeExpr(const ObjCEncodeExpr *Node);
+  void VisitObjCMessageExpr(const ObjCMessageExpr *Node);
+  void VisitObjCBoxedExpr(const ObjCBoxedExpr *Node);
+  void VisitObjCSelectorExpr(const ObjCSelectorExpr *Node);
+  void VisitObjCProtocolExpr(const ObjCProtocolExpr *Node);
+  void VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *Node);
+  void VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *Node);
+  void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node);
+  void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node);
 };
 
 } // namespace clang

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351014&r1=351013&r2=351014&view=diff
==

r351015 - NFC: Make utility private

2019-01-12 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sat Jan 12 09:07:05 2019
New Revision: 351015

URL: http://llvm.org/viewvc/llvm-project?rev=351015&view=rev
Log:
NFC: Make utility private

No callers are external to the class anymore.

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351015&r1=351014&r2=351015&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Sat Jan 12 09:07:05 2019
@@ -167,7 +167,6 @@ public:
   void dumpBareDeclRef(const Decl *D);
   void dumpName(const NamedDecl *ND);
   void dumpAccessSpecifier(AccessSpecifier AS);
-  void dumpCXXTemporary(const CXXTemporary *Temporary);
 
   void dumpDeclRef(const Decl *D, StringRef Label = {});
 
@@ -255,6 +254,9 @@ public:
   void VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *Node);
   void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node);
   void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node);
+
+private:
+  void dumpCXXTemporary(const CXXTemporary *Temporary);
 };
 
 } // namespace clang


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


r351112 - NFC: Fix nits I missed before

2019-01-14 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Mon Jan 14 11:50:34 2019
New Revision: 351112

URL: http://llvm.org/viewvc/llvm-project?rev=351112&view=rev
Log:
NFC: Fix nits I missed before

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351112&r1=35&r2=351112&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Mon Jan 14 11:50:34 2019
@@ -400,7 +400,7 @@ namespace  {
   dumpStmt(TA.getAsExpr());
 }
 void VisitPackTemplateArgument(const TemplateArgument &TA) {
-  for (const auto& TArg : TA.pack_elements())
+  for (const auto &TArg : TA.pack_elements())
 dumpTemplateArgument(TArg);
 }
 

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=351112&r1=35&r2=351112&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Mon Jan 14 11:50:34 2019
@@ -70,9 +70,8 @@ void TextNodeDumper::Visit(const Templat
   if (R.isValid())
 dumpSourceRange(R);
 
-  if (From) {
+  if (From)
 dumpDeclRef(From, Label);
-  }
 
   ConstTemplateArgumentVisitor::Visit(TA);
 }


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


r351114 - [ASTDump] NFC: Move Type Visit implementation to TextNodeDumper

2019-01-14 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Mon Jan 14 12:11:02 2019
New Revision: 351114

URL: http://llvm.org/viewvc/llvm-project?rev=351114&view=rev
Log:
[ASTDump] NFC: Move Type Visit implementation to TextNodeDumper

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351114&r1=351113&r2=351114&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Mon Jan 14 12:11:02 2019
@@ -159,6 +159,8 @@ public:
 
   void Visit(const Stmt *Node);
 
+  void Visit(const Type *T);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351114&r1=351113&r2=351114&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Mon Jan 14 12:11:02 2019
@@ -430,47 +430,18 @@ void ASTDumper::dumpTypeAsChild(QualType
 
 void ASTDumper::dumpTypeAsChild(const Type *T) {
   dumpChild([=] {
-if (!T) {
-  ColorScope Color(OS, ShowColors, NullColor);
-  OS << "<<>>";
+NodeDumper.Visit(T);
+if (!T)
   return;
-}
 if (const LocInfoType *LIT = llvm::dyn_cast(T)) {
-  {
-ColorScope Color(OS, ShowColors, TypeColor);
-OS << "LocInfo Type";
-  }
-  NodeDumper.dumpPointer(T);
   dumpTypeAsChild(LIT->getTypeSourceInfo()->getType());
   return;
 }
-
-{
-  ColorScope Color(OS, ShowColors, TypeColor);
-  OS << T->getTypeClassName() << "Type";
-}
-NodeDumper.dumpPointer(T);
-OS << " ";
-NodeDumper.dumpBareType(QualType(T, 0), false);
+TypeVisitor::Visit(T);
 
 QualType SingleStepDesugar =
 T->getLocallyUnqualifiedSingleStepDesugaredType();
 if (SingleStepDesugar != QualType(T, 0))
-  OS << " sugar";
-if (T->isDependentType())
-  OS << " dependent";
-else if (T->isInstantiationDependentType())
-  OS << " instantiation_dependent";
-if (T->isVariablyModifiedType())
-  OS << " variably_modified";
-if (T->containsUnexpandedParameterPack())
-  OS << " contains_unexpanded_pack";
-if (T->isFromAST())
-  OS << " imported";
-
-TypeVisitor::Visit(T);
-
-if (SingleStepDesugar != QualType(T, 0))
   dumpTypeAsChild(SingleStepDesugar);
   });
 }

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=351114&r1=351113&r2=351114&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Mon Jan 14 12:11:02 2019
@@ -12,6 +12,7 @@
 
//===--===//
 
 #include "clang/AST/TextNodeDumper.h"
+#include "clang/AST/LocInfoType.h"
 
 using namespace clang;
 
@@ -130,6 +131,47 @@ void TextNodeDumper::Visit(const Stmt *N
   ConstStmtVisitor::Visit(Node);
 }
 
+void TextNodeDumper::Visit(const Type *T) {
+  if (!T) {
+ColorScope Color(OS, ShowColors, NullColor);
+OS << "<<>>";
+return;
+  }
+  if (isa(T)) {
+{
+  ColorScope Color(OS, ShowColors, TypeColor);
+  OS << "LocInfo Type";
+}
+dumpPointer(T);
+return;
+  }
+
+  {
+ColorScope Color(OS, ShowColors, TypeColor);
+OS << T->getTypeClassName() << "Type";
+  }
+  dumpPointer(T);
+  OS << " ";
+  dumpBareType(QualType(T, 0), false);
+
+  QualType SingleStepDesugar =
+  T->getLocallyUnqualifiedSingleStepDesugaredType();
+  if (SingleStepDesugar != QualType(T, 0))
+OS << " sugar";
+
+  if (T->isDependentType())
+OS << " dependent";
+  else if (T->isInstantiationDependentType())
+OS << " instantiation_dependent";
+
+  if (T->isVariablyModifiedType())
+OS << " variably_modified";
+  if (T->containsUnexpandedParameterPack())
+OS << " contains_unexpanded_pack";
+  if (T->isFromAST())
+OS << " imported";
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;


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


r351115 - [ASTDump] NFC: Canonicalize handling of TypeLocInfo

2019-01-14 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Mon Jan 14 12:13:09 2019
New Revision: 351115

URL: http://llvm.org/viewvc/llvm-project?rev=351115&view=rev
Log:
[ASTDump] NFC: Canonicalize handling of TypeLocInfo

Summary: No need to avoid the Visit method.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351115&r1=351114&r2=351115&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Mon Jan 14 12:13:09 2019
@@ -122,6 +122,9 @@ namespace  {
 void VisitComplexType(const ComplexType *T) {
   dumpTypeAsChild(T->getElementType());
 }
+void VisitLocInfoType(const LocInfoType *T) {
+  dumpTypeAsChild(T->getTypeSourceInfo()->getType());
+}
 void VisitPointerType(const PointerType *T) {
   dumpTypeAsChild(T->getPointeeType());
 }
@@ -433,10 +436,6 @@ void ASTDumper::dumpTypeAsChild(const Ty
 NodeDumper.Visit(T);
 if (!T)
   return;
-if (const LocInfoType *LIT = llvm::dyn_cast(T)) {
-  dumpTypeAsChild(LIT->getTypeSourceInfo()->getType());
-  return;
-}
 TypeVisitor::Visit(T);
 
 QualType SingleStepDesugar =


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


r351116 - [ASTDump] NFC: Move dumping of QualType node to TextNodeDumper

2019-01-14 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Mon Jan 14 12:15:29 2019
New Revision: 351116

URL: http://llvm.org/viewvc/llvm-project?rev=351116&view=rev
Log:
[ASTDump] NFC: Move dumping of QualType node to TextNodeDumper

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351116&r1=351115&r2=351116&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Mon Jan 14 12:15:29 2019
@@ -161,6 +161,8 @@ public:
 
   void Visit(const Type *T);
 
+  void Visit(QualType T);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351116&r1=351115&r2=351116&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Mon Jan 14 12:15:29 2019
@@ -422,11 +422,7 @@ void ASTDumper::dumpTypeAsChild(QualType
 return dumpTypeAsChild(SQT.Ty);
 
   dumpChild([=] {
-OS << "QualType";
-NodeDumper.dumpPointer(T.getAsOpaquePtr());
-OS << " ";
-NodeDumper.dumpBareType(T, false);
-OS << " " << T.split().Quals.getAsString();
+NodeDumper.Visit(T);
 dumpTypeAsChild(T.split().Ty);
   });
 }

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=351116&r1=351115&r2=351116&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Mon Jan 14 12:15:29 2019
@@ -172,6 +172,14 @@ void TextNodeDumper::Visit(const Type *T
 OS << " imported";
 }
 
+void TextNodeDumper::Visit(QualType T) {
+  OS << "QualType";
+  dumpPointer(T.getAsOpaquePtr());
+  OS << " ";
+  dumpBareType(T, false);
+  OS << " " << T.split().Quals.getAsString();
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;


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


r351172 - [ASTDump] NFC: Move dump of type nodes to NodeDumper

2019-01-15 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan 15 01:30:00 2019
New Revision: 351172

URL: http://llvm.org/viewvc/llvm-project?rev=351172&view=rev
Log:
[ASTDump] NFC: Move dump of type nodes to NodeDumper

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351172&r1=351171&r2=351172&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Tue Jan 15 01:30:00 2019
@@ -22,6 +22,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/AST/TemplateArgumentVisitor.h"
+#include "clang/AST/TypeVisitor.h"
 
 namespace clang {
 
@@ -127,7 +128,8 @@ class TextNodeDumper
const comments::FullComment *>,
   public ConstAttrVisitor,
   public ConstTemplateArgumentVisitor,
-  public ConstStmtVisitor {
+  public ConstStmtVisitor,
+  public TypeVisitor {
   raw_ostream &OS;
   const bool ShowColors;
 
@@ -259,6 +261,26 @@ public:
   void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node);
   void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node);
 
+  void VisitRValueReferenceType(const ReferenceType *T);
+  void VisitArrayType(const ArrayType *T);
+  void VisitConstantArrayType(const ConstantArrayType *T);
+  void VisitVariableArrayType(const VariableArrayType *T);
+  void VisitDependentSizedArrayType(const DependentSizedArrayType *T);
+  void VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *T);
+  void VisitVectorType(const VectorType *T);
+  void VisitFunctionType(const FunctionType *T);
+  void VisitFunctionProtoType(const FunctionProtoType *T);
+  void VisitUnresolvedUsingType(const UnresolvedUsingType *T);
+  void VisitTypedefType(const TypedefType *T);
+  void VisitUnaryTransformType(const UnaryTransformType *T);
+  void VisitTagType(const TagType *T);
+  void VisitTemplateTypeParmType(const TemplateTypeParmType *T);
+  void VisitAutoType(const AutoType *T);
+  void VisitTemplateSpecializationType(const TemplateSpecializationType *T);
+  void VisitInjectedClassNameType(const InjectedClassNameType *T);
+  void VisitObjCInterfaceType(const ObjCInterfaceType *T);
+  void VisitPackExpansionType(const PackExpansionType *T);
+
 private:
   void dumpCXXTemporary(const CXXTemporary *Temporary);
 };

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351172&r1=351171&r2=351172&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 15 01:30:00 2019
@@ -134,99 +134,39 @@ namespace  {
 void VisitReferenceType(const ReferenceType *T) {
   dumpTypeAsChild(T->getPointeeType());
 }
-void VisitRValueReferenceType(const ReferenceType *T) {
-  if (T->isSpelledAsLValue())
-OS << " written as lvalue reference";
-  VisitReferenceType(T);
-}
 void VisitMemberPointerType(const MemberPointerType *T) {
   dumpTypeAsChild(T->getClass());
   dumpTypeAsChild(T->getPointeeType());
 }
 void VisitArrayType(const ArrayType *T) {
-  switch (T->getSizeModifier()) {
-case ArrayType::Normal: break;
-case ArrayType::Static: OS << " static"; break;
-case ArrayType::Star: OS << " *"; break;
-  }
-  OS << " " << T->getIndexTypeQualifiers().getAsString();
   dumpTypeAsChild(T->getElementType());
 }
-void VisitConstantArrayType(const ConstantArrayType *T) {
-  OS << " " << T->getSize();
-  VisitArrayType(T);
-}
 void VisitVariableArrayType(const VariableArrayType *T) {
-  OS << " ";
-  NodeDumper.dumpSourceRange(T->getBracketsRange());
   VisitArrayType(T);
   dumpStmt(T->getSizeExpr());
 }
 void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
-  switch (T->getSizeModifier()) {
-case ArrayType::Normal: break;
-case ArrayType::Static: OS << " static"; break;
-case ArrayType::Star: OS << " *"; break;
-  }
-  OS << " " << T->getIndexTypeQualifiers().getAsString();
-  OS << " ";
-  NodeDumper.dumpSourceRange(T->getBracketsRange());
   dumpTypeAsChild(T->getElementType());
   dumpStmt(T->getSizeExpr());
 }
 void VisitDependentSizedExtVectorType(
 const DependentSizedExtVectorType *T) {
-  OS << " ";
-  NodeDumper.dumpLocation(T->getAttributeLoc());
   dumpTypeAsChild(T->getElementType());
   dumpStmt(T->getSizeExpr());
 }
 void VisitVectorType(cons

r351175 - NFC: Move Decl node handling to TextNodeDumper

2019-01-15 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan 15 01:35:52 2019
New Revision: 351175

URL: http://llvm.org/viewvc/llvm-project?rev=351175&view=rev
Log:
NFC: Move Decl node handling to TextNodeDumper

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351175&r1=351174&r2=351175&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Tue Jan 15 01:35:52 2019
@@ -165,6 +165,8 @@ public:
 
   void Visit(QualType T);
 
+  void Visit(const Decl *D);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351175&r1=351174&r2=351175&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 15 01:35:52 2019
@@ -435,35 +435,6 @@ void ASTDumper::dumpAttr(const Attr *A)
   });
 }
 
-static void dumpPreviousDeclImpl(raw_ostream &OS, ...) {}
-
-template
-static void dumpPreviousDeclImpl(raw_ostream &OS, const Mergeable *D) {
-  const T *First = D->getFirstDecl();
-  if (First != D)
-OS << " first " << First;
-}
-
-template
-static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable *D) {
-  const T *Prev = D->getPreviousDecl();
-  if (Prev)
-OS << " prev " << Prev;
-}
-
-/// Dump the previous declaration in the redeclaration chain for a declaration,
-/// if any.
-static void dumpPreviousDecl(raw_ostream &OS, const Decl *D) {
-  switch (D->getKind()) {
-#define DECL(DERIVED, BASE) \
-  case Decl::DERIVED: \
-return dumpPreviousDeclImpl(OS, cast(D));
-#define ABSTRACT_DECL(DECL)
-#include "clang/AST/DeclNodes.inc"
-  }
-  llvm_unreachable("Decl that isn't part of DeclNodes.inc!");
-}
-
 
//===--===//
 //  C++ Utilities
 
//===--===//
@@ -536,46 +507,9 @@ void ASTDumper::dumpObjCTypeParamList(co
 
 void ASTDumper::dumpDecl(const Decl *D) {
   dumpChild([=] {
-if (!D) {
-  ColorScope Color(OS, ShowColors, NullColor);
-  OS << "<<>>";
+NodeDumper.Visit(D);
+if (!D)
   return;
-}
-
-{
-  ColorScope Color(OS, ShowColors, DeclKindNameColor);
-  OS << D->getDeclKindName() << "Decl";
-}
-NodeDumper.dumpPointer(D);
-if (D->getLexicalDeclContext() != D->getDeclContext())
-  OS << " parent " << cast(D->getDeclContext());
-dumpPreviousDecl(OS, D);
-NodeDumper.dumpSourceRange(D->getSourceRange());
-OS << ' ';
-NodeDumper.dumpLocation(D->getLocation());
-if (D->isFromASTFile())
-  OS << " imported";
-if (Module *M = D->getOwningModule())
-  OS << " in " << M->getFullModuleName();
-if (auto *ND = dyn_cast(D))
-  for (Module *M : D->getASTContext().getModulesWithMergedDefinition(
-   const_cast(ND)))
-dumpChild([=] { OS << "also in " << M->getFullModuleName(); });
-if (const NamedDecl *ND = dyn_cast(D))
-  if (ND->isHidden())
-OS << " hidden";
-if (D->isImplicit())
-  OS << " implicit";
-if (D->isUsed())
-  OS << " used";
-else if (D->isThisDeclarationReferenced())
-  OS << " referenced";
-if (D->isInvalidDecl())
-  OS << " invalid";
-if (const FunctionDecl *FD = dyn_cast(D))
-  if (FD->isConstexpr())
-OS << " constexpr";
-
 
 ConstDeclVisitor::Visit(D);
 

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=351175&r1=351174&r2=351175&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Tue Jan 15 01:35:52 2019
@@ -12,11 +12,42 @@
 
//===--===//
 
 #include "clang/AST/TextNodeDumper.h"
+#include "clang/AST/DeclFriend.h"
+#include "clang/AST/DeclOpenMP.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/LocInfoType.h"
 
 using namespace clang;
 
+static void dumpPreviousDeclImpl(raw_ostream &OS, ...) {}
+
+template 
+static void dumpPreviousDeclImpl(raw_ostream &OS, const Mergeable *D) {
+  const T *First = D->getFirstDecl();
+  if (First != D)
+OS << " first " << First;
+}
+
+template 
+static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable *D) {

r351235 - Implement CXXCtorInitializer dump in terms of Visitor

2019-01-15 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan 15 12:17:33 2019
New Revision: 351235

URL: http://llvm.org/viewvc/llvm-project?rev=351235&view=rev
Log:
Implement CXXCtorInitializer dump in terms of Visitor

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351235&r1=351234&r2=351235&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Tue Jan 15 12:17:33 2019
@@ -167,6 +167,8 @@ public:
 
   void Visit(const Decl *D);
 
+  void Visit(const CXXCtorInitializer *Init);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351235&r1=351234&r2=351235&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 15 12:17:33 2019
@@ -441,17 +441,7 @@ void ASTDumper::dumpAttr(const Attr *A)
 
 void ASTDumper::dumpCXXCtorInitializer(const CXXCtorInitializer *Init) {
   dumpChild([=] {
-OS << "CXXCtorInitializer";
-if (Init->isAnyMemberInitializer()) {
-  OS << ' ';
-  NodeDumper.dumpBareDeclRef(Init->getAnyMember());
-} else if (Init->isBaseInitializer()) {
-  NodeDumper.dumpType(QualType(Init->getBaseClass(), 0));
-} else if (Init->isDelegatingInitializer()) {
-  NodeDumper.dumpType(Init->getTypeSourceInfo()->getType());
-} else {
-  llvm_unreachable("Unknown initializer type");
-}
+NodeDumper.Visit(Init);
 dumpStmt(Init->getInit());
   });
 }

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=351235&r1=351234&r2=351235&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Tue Jan 15 12:17:33 2019
@@ -258,6 +258,20 @@ void TextNodeDumper::Visit(const Decl *D
   OS << " constexpr";
 }
 
+void TextNodeDumper::Visit(const CXXCtorInitializer *Init) {
+  OS << "CXXCtorInitializer";
+  if (Init->isAnyMemberInitializer()) {
+OS << ' ';
+dumpBareDeclRef(Init->getAnyMember());
+  } else if (Init->isBaseInitializer()) {
+dumpType(QualType(Init->getBaseClass(), 0));
+  } else if (Init->isDelegatingInitializer()) {
+dumpType(Init->getTypeSourceInfo()->getType());
+  } else {
+llvm_unreachable("Unknown initializer type");
+  }
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;


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


r351236 - NFC: Implement OMPClause dump in terms of visitors

2019-01-15 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan 15 12:31:31 2019
New Revision: 351236

URL: http://llvm.org/viewvc/llvm-project?rev=351236&view=rev
Log:
NFC: Implement OMPClause dump in terms of visitors

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351236&r1=351235&r2=351236&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Tue Jan 15 12:31:31 2019
@@ -169,6 +169,8 @@ public:
 
   void Visit(const CXXCtorInitializer *Init);
 
+  void Visit(const OMPClause *C);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351236&r1=351235&r2=351236&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 15 12:31:31 2019
@@ -292,6 +292,7 @@ namespace  {
 void VisitCapturedStmt(const CapturedStmt *Node);
 
 // OpenMP
+void Visit(const OMPClause *C);
 void VisitOMPExecutableDirective(const OMPExecutableDirective *Node);
 
 // Exprs
@@ -1448,29 +1449,18 @@ void ASTDumper::VisitCapturedStmt(const
 //  OpenMP dumping methods.
 
//===--===//
 
+void ASTDumper::Visit(const OMPClause *C) {
+  dumpChild([=] {
+NodeDumper.Visit(C);
+for (auto *S : C->children())
+  dumpStmt(S);
+  });
+}
+
 void ASTDumper::VisitOMPExecutableDirective(
 const OMPExecutableDirective *Node) {
-  for (auto *C : Node->clauses()) {
-dumpChild([=] {
-  if (!C) {
-ColorScope Color(OS, ShowColors, NullColor);
-OS << "<<>> OMPClause";
-return;
-  }
-  {
-ColorScope Color(OS, ShowColors, AttrColor);
-StringRef ClauseName(getOpenMPClauseName(C->getClauseKind()));
-OS << "OMP" << ClauseName.substr(/*Start=*/0, /*N=*/1).upper()
-   << ClauseName.drop_front() << "Clause";
-  }
-  NodeDumper.dumpPointer(C);
-  NodeDumper.dumpSourceRange(SourceRange(C->getBeginLoc(), 
C->getEndLoc()));
-  if (C->isImplicit())
-OS << " ";
-  for (auto *S : C->children())
-dumpStmt(S);
-});
-  }
+  for (const auto *C : Node->clauses())
+Visit(C);
 }
 
 
//===--===//

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=351236&r1=351235&r2=351236&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Tue Jan 15 12:31:31 2019
@@ -272,6 +272,24 @@ void TextNodeDumper::Visit(const CXXCtor
   }
 }
 
+void TextNodeDumper::Visit(const OMPClause *C) {
+  if (!C) {
+ColorScope Color(OS, ShowColors, NullColor);
+OS << "<<>> OMPClause";
+return;
+  }
+  {
+ColorScope Color(OS, ShowColors, AttrColor);
+StringRef ClauseName(getOpenMPClauseName(C->getClauseKind()));
+OS << "OMP" << ClauseName.substr(/*Start=*/0, /*N=*/1).upper()
+   << ClauseName.drop_front() << "Clause";
+  }
+  dumpPointer(C);
+  dumpSourceRange(SourceRange(C->getBeginLoc(), C->getEndLoc()));
+  if (C->isImplicit())
+OS << " ";
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;


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


r351239 - Implement BlockDecl::Capture dump in terms of visitors

2019-01-15 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan 15 12:41:37 2019
New Revision: 351239

URL: http://llvm.org/viewvc/llvm-project?rev=351239&view=rev
Log:
Implement BlockDecl::Capture dump in terms of visitors

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351239&r1=351238&r2=351239&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Tue Jan 15 12:41:37 2019
@@ -171,6 +171,8 @@ public:
 
   void Visit(const OMPClause *C);
 
+  void Visit(const BlockDecl::Capture &C);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351239&r1=351238&r2=351239&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 15 12:41:37 2019
@@ -283,6 +283,7 @@ namespace  {
 void VisitObjCCompatibleAliasDecl(const ObjCCompatibleAliasDecl *D);
 void VisitObjCPropertyDecl(const ObjCPropertyDecl *D);
 void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
+void Visit(const BlockDecl::Capture &C);
 void VisitBlockDecl(const BlockDecl *D);
 
 // Stmts.
@@ -1371,6 +1372,14 @@ void ASTDumper::VisitObjCPropertyImplDec
   NodeDumper.dumpDeclRef(D->getPropertyIvarDecl());
 }
 
+void ASTDumper::Visit(const BlockDecl::Capture &C) {
+  dumpChild([=] {
+NodeDumper.Visit(C);
+if (C.hasCopyExpr())
+  dumpStmt(C.getCopyExpr());
+  });
+}
+
 void ASTDumper::VisitBlockDecl(const BlockDecl *D) {
   for (auto I : D->parameters())
 dumpDecl(I);
@@ -1381,21 +1390,8 @@ void ASTDumper::VisitBlockDecl(const Blo
   if (D->capturesCXXThis())
 dumpChild([=]{ OS << "capture this"; });
 
-  for (const auto &I : D->captures()) {
-dumpChild([=] {
-  OS << "capture";
-  if (I.isByRef())
-OS << " byref";
-  if (I.isNested())
-OS << " nested";
-  if (I.getVariable()) {
-OS << ' ';
-NodeDumper.dumpBareDeclRef(I.getVariable());
-  }
-  if (I.hasCopyExpr())
-dumpStmt(I.getCopyExpr());
-});
-  }
+  for (const auto &I : D->captures())
+Visit(I);
   dumpStmt(D->getBody());
 }
 

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=351239&r1=351238&r2=351239&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Tue Jan 15 12:41:37 2019
@@ -272,6 +272,18 @@ void TextNodeDumper::Visit(const CXXCtor
   }
 }
 
+void TextNodeDumper::Visit(const BlockDecl::Capture &C) {
+  OS << "capture";
+  if (C.isByRef())
+OS << " byref";
+  if (C.isNested())
+OS << " nested";
+  if (C.getVariable()) {
+OS << ' ';
+dumpBareDeclRef(C.getVariable());
+  }
+}
+
 void TextNodeDumper::Visit(const OMPClause *C) {
   if (!C) {
 ColorScope Color(OS, ShowColors, NullColor);


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


r351268 - NFC: Replace iterator loop with cxx_range_for

2019-01-15 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan 15 14:45:46 2019
New Revision: 351268

URL: http://llvm.org/viewvc/llvm-project?rev=351268&view=rev
Log:
NFC: Replace iterator loop with cxx_range_for

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351268&r1=351267&r2=351268&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 15 14:45:46 2019
@@ -623,10 +623,8 @@ void ASTDumper::VisitFunctionDecl(const
   dumpDecl(Parameter);
 
   if (const CXXConstructorDecl *C = dyn_cast(D))
-for (CXXConstructorDecl::init_const_iterator I = C->init_begin(),
- E = C->init_end();
- I != E; ++I)
-  dumpCXXCtorInitializer(*I);
+for (const auto *I : C->inits())
+  dumpCXXCtorInitializer(I);
 
   if (const CXXMethodDecl *MD = dyn_cast(D)) {
 if (MD->size_overridden_methods() != 0) {


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


r351269 - Re-order overrides in FunctionDecl dump

2019-01-15 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan 15 14:50:37 2019
New Revision: 351269

URL: http://llvm.org/viewvc/llvm-project?rev=351269&view=rev
Log:
Re-order overrides in FunctionDecl dump

Output all content which is local to the FunctionDecl before traversing
to child AST nodes.

This is necessary so that all of the part which is local to the
FunctionDecl can be split into a different method.

Reviewers: aaron.ballman

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

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/test/AST/ast-dump-funcs.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351269&r1=351268&r2=351269&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 15 14:50:37 2019
@@ -612,20 +612,6 @@ void ASTDumper::VisitFunctionDecl(const
 }
   }
 
-  if (const FunctionTemplateSpecializationInfo *FTSI =
-  D->getTemplateSpecializationInfo())
-dumpTemplateArgumentList(*FTSI->TemplateArguments);
-
-  if (!D->param_begin() && D->getNumParams())
-dumpChild([=] { OS << ">"; });
-  else
-for (const ParmVarDecl *Parameter : D->parameters())
-  dumpDecl(Parameter);
-
-  if (const CXXConstructorDecl *C = dyn_cast(D))
-for (const auto *I : C->inits())
-  dumpCXXCtorInitializer(I);
-
   if (const CXXMethodDecl *MD = dyn_cast(D)) {
 if (MD->size_overridden_methods() != 0) {
   auto dumpOverride = [=](const CXXMethodDecl *D) {
@@ -649,6 +635,22 @@ void ASTDumper::VisitFunctionDecl(const
 }
   }
 
+  if (const FunctionTemplateSpecializationInfo *FTSI =
+  D->getTemplateSpecializationInfo())
+dumpTemplateArgumentList(*FTSI->TemplateArguments);
+
+  if (!D->param_begin() && D->getNumParams())
+dumpChild([=] { OS << ">"; });
+  else
+for (const ParmVarDecl *Parameter : D->parameters())
+  dumpDecl(Parameter);
+
+  if (const CXXConstructorDecl *C = dyn_cast(D))
+for (CXXConstructorDecl::init_const_iterator I = C->init_begin(),
+ E = C->init_end();
+ I != E; ++I)
+  dumpCXXCtorInitializer(*I);
+
   if (D->doesThisDeclarationHaveABody())
 dumpStmt(D->getBody());
 }

Modified: cfe/trunk/test/AST/ast-dump-funcs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-funcs.cpp?rev=351269&r1=351268&r2=351269&view=diff
==
--- cfe/trunk/test/AST/ast-dump-funcs.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-funcs.cpp Tue Jan 15 14:50:37 2019
@@ -56,10 +56,10 @@ struct S {
 struct T : S { // T is not referenced, but S is
   void f(float, int = 100) override;
   // CHECK: CXXMethodDecl 0x{{[^ ]*}}  col:8 f 
'void (float, int)'
+  // CHECK-NEXT: Overrides: [ 0x{{[^ ]*}} S::f 'void (float, int)' ]
   // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:15 'float'
   // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:21 'int' cinit
   // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 100
-  // CHECK-NEXT: Overrides: [ 0x{{[^ ]*}} S::f 'void (float, int)' ]
   // CHECK-NEXT: OverrideAttr
 
   // CHECK: CXXConstructorDecl 0x{{[^ ]*}}  col:8 implicit 
T 'void (const T &)' inline default_delete noexcept-unevaluated


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


Re: r351269 - Re-order overrides in FunctionDecl dump

2019-01-15 Thread Stephen Kelly via cfe-commits


On 15/01/2019 23:00, Aaron Ballman wrote:

On Tue, Jan 15, 2019 at 5:54 PM Stephen Kelly via cfe-commits
 wrote:

Author: steveire
Date: Tue Jan 15 14:50:37 2019
New Revision: 351269

URL: http://llvm.org/viewvc/llvm-project?rev=351269&view=rev
Log:
Re-order overrides in FunctionDecl dump

Output all content which is local to the FunctionDecl before traversing
to child AST nodes.

This is necessary so that all of the part which is local to the
FunctionDecl can be split into a different method.

Reviewers: aaron.ballman

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

Modified:
 cfe/trunk/lib/AST/ASTDumper.cpp
 cfe/trunk/test/AST/ast-dump-funcs.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351269&r1=351268&r2=351269&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 15 14:50:37 2019
@@ -612,20 +612,6 @@ void ASTDumper::VisitFunctionDecl(const
  }
}

-  if (const FunctionTemplateSpecializationInfo *FTSI =
-  D->getTemplateSpecializationInfo())
-dumpTemplateArgumentList(*FTSI->TemplateArguments);
-
-  if (!D->param_begin() && D->getNumParams())
-dumpChild([=] { OS << "<getNumParams() << ">>"; });
-  else
-for (const ParmVarDecl *Parameter : D->parameters())
-  dumpDecl(Parameter);
-
-  if (const CXXConstructorDecl *C = dyn_cast(D))
-for (const auto *I : C->inits())
-  dumpCXXCtorInitializer(I);
-
if (const CXXMethodDecl *MD = dyn_cast(D)) {
  if (MD->size_overridden_methods() != 0) {
auto dumpOverride = [=](const CXXMethodDecl *D) {
@@ -649,6 +635,22 @@ void ASTDumper::VisitFunctionDecl(const
  }
}

+  if (const FunctionTemplateSpecializationInfo *FTSI =
+  D->getTemplateSpecializationInfo())
+dumpTemplateArgumentList(*FTSI->TemplateArguments);
+
+  if (!D->param_begin() && D->getNumParams())
+dumpChild([=] { OS << "<getNumParams() << ">>"; });
+  else
+for (const ParmVarDecl *Parameter : D->parameters())
+  dumpDecl(Parameter);
+
+  if (const CXXConstructorDecl *C = dyn_cast(D))

Missed this nit from the review.


+for (CXXConstructorDecl::init_const_iterator I = C->init_begin(),
+ E = C->init_end();
+ I != E; ++I)
+  dumpCXXCtorInitializer(*I);

This accidentally reverts what you did in r351268.



Lol, thanks! Fixing now

Stephen.


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


r351271 - NFC: Some cleanups that I missed in the previous commit

2019-01-15 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan 15 15:05:11 2019
New Revision: 351271

URL: http://llvm.org/viewvc/llvm-project?rev=351271&view=rev
Log:
NFC: Some cleanups that I missed in the previous commit

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351271&r1=351270&r2=351271&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 15 15:05:11 2019
@@ -599,7 +599,7 @@ void ASTDumper::VisitFunctionDecl(const
   if (D->isTrivial())
 OS << " trivial";
 
-  if (const FunctionProtoType *FPT = D->getType()->getAs()) 
{
+  if (const auto *FPT = D->getType()->getAs()) {
 FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
 switch (EPI.ExceptionSpec.Type) {
 default: break;
@@ -612,7 +612,7 @@ void ASTDumper::VisitFunctionDecl(const
 }
   }
 
-  if (const CXXMethodDecl *MD = dyn_cast(D)) {
+  if (const auto *MD = dyn_cast(D)) {
 if (MD->size_overridden_methods() != 0) {
   auto dumpOverride = [=](const CXXMethodDecl *D) {
 SplitQualType T_split = D->getType().split();
@@ -635,8 +635,7 @@ void ASTDumper::VisitFunctionDecl(const
 }
   }
 
-  if (const FunctionTemplateSpecializationInfo *FTSI =
-  D->getTemplateSpecializationInfo())
+  if (const auto *FTSI = D->getTemplateSpecializationInfo())
 dumpTemplateArgumentList(*FTSI->TemplateArguments);
 
   if (!D->param_begin() && D->getNumParams())
@@ -645,11 +644,9 @@ void ASTDumper::VisitFunctionDecl(const
 for (const ParmVarDecl *Parameter : D->parameters())
   dumpDecl(Parameter);
 
-  if (const CXXConstructorDecl *C = dyn_cast(D))
-for (CXXConstructorDecl::init_const_iterator I = C->init_begin(),
- E = C->init_end();
- I != E; ++I)
-  dumpCXXCtorInitializer(*I);
+  if (const auto *C = dyn_cast(D))
+for (const auto *I : C->inits())
+  dumpCXXCtorInitializer(I);
 
   if (D->doesThisDeclarationHaveABody())
 dumpStmt(D->getBody());


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


r351272 - Re-order type param children of ObjC nodes

2019-01-15 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan 15 15:07:30 2019
New Revision: 351272

URL: http://llvm.org/viewvc/llvm-project?rev=351272&view=rev
Log:
Re-order type param children of ObjC nodes

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/test/AST/ast-dump-decl.m

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351272&r1=351271&r2=351272&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 15 15:07:30 2019
@@ -1273,12 +1273,12 @@ void ASTDumper::VisitObjCTypeParamDecl(c
 void ASTDumper::VisitObjCCategoryDecl(const ObjCCategoryDecl *D) {
   NodeDumper.dumpName(D);
   NodeDumper.dumpDeclRef(D->getClassInterface());
-  dumpObjCTypeParamList(D->getTypeParamList());
   NodeDumper.dumpDeclRef(D->getImplementation());
   for (ObjCCategoryDecl::protocol_iterator I = D->protocol_begin(),
E = D->protocol_end();
I != E; ++I)
 NodeDumper.dumpDeclRef(*I);
+  dumpObjCTypeParamList(D->getTypeParamList());
 }
 
 void ASTDumper::VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *D) {
@@ -1296,12 +1296,12 @@ void ASTDumper::VisitObjCProtocolDecl(co
 
 void ASTDumper::VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D) {
   NodeDumper.dumpName(D);
-  dumpObjCTypeParamList(D->getTypeParamListAsWritten());
   NodeDumper.dumpDeclRef(D->getSuperClass(), "super");
 
   NodeDumper.dumpDeclRef(D->getImplementation());
   for (auto *Child : D->protocols())
 NodeDumper.dumpDeclRef(Child);
+  dumpObjCTypeParamList(D->getTypeParamListAsWritten());
 }
 
 void ASTDumper::VisitObjCImplementationDecl(const ObjCImplementationDecl *D) {

Modified: cfe/trunk/test/AST/ast-dump-decl.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.m?rev=351272&r1=351271&r2=351272&view=diff
==
--- cfe/trunk/test/AST/ast-dump-decl.m (original)
+++ cfe/trunk/test/AST/ast-dump-decl.m Tue Jan 15 15:07:30 2019
@@ -85,9 +85,9 @@
 }
 @end
 // CHECK:  ObjCInterfaceDecl{{.*}} TestGenericInterface
-// CHECK-NEXT:   -ObjCTypeParamDecl {{.+}}  col:33 T 'id':'id'
 // CHECK-NEXT:   -super ObjCInterface {{.+}} 'A'
 // CHECK-NEXT:   -ObjCProtocol {{.+}} 'P'
+// CHECK-NEXT:   -ObjCTypeParamDecl {{.+}}  col:33 T 'id':'id'
 
 @implementation TestObjCClass (TestObjCCategoryDecl)
 - (void) bar {


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


r351597 - [ASTDump] Mark variadic declarations with a tag instead of child node

2019-01-18 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Fri Jan 18 13:38:30 2019
New Revision: 351597

URL: http://llvm.org/viewvc/llvm-project?rev=351597&view=rev
Log:
[ASTDump] Mark variadic declarations with a tag instead of child node

Summary:
This makes it easier to separate traversal of the AST from output
generation.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp
cfe/trunk/test/AST/ast-dump-decl.m

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351597&r1=351596&r2=351597&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Fri Jan 18 13:38:30 2019
@@ -164,8 +164,6 @@ namespace  {
   VisitFunctionType(T);
   for (QualType PT : T->getParamTypes())
 dumpTypeAsChild(PT);
-  if (T->getExtProtoInfo().Variadic)
-dumpChild([=] { OS << "..."; });
 }
 void VisitTypeOfExprType(const TypeOfExprType *T) {
   dumpStmt(T->getUnderlyingExpr());
@@ -1236,6 +1234,9 @@ void ASTDumper::VisitObjCMethodDecl(cons
   NodeDumper.dumpName(D);
   NodeDumper.dumpType(D->getReturnType());
 
+  if (D->isVariadic())
+OS << " variadic";
+
   if (D->isThisDeclarationADefinition()) {
 dumpDeclContext(D);
   } else {
@@ -1243,9 +1244,6 @@ void ASTDumper::VisitObjCMethodDecl(cons
   dumpDecl(Parameter);
   }
 
-  if (D->isVariadic())
-dumpChild([=] { OS << "..."; });
-
   if (D->hasBody())
 dumpStmt(D->getBody());
 }
@@ -1378,12 +1376,12 @@ void ASTDumper::Visit(const BlockDecl::C
 }
 
 void ASTDumper::VisitBlockDecl(const BlockDecl *D) {
+  if (D->isVariadic())
+OS << " variadic";
+
   for (auto I : D->parameters())
 dumpDecl(I);
 
-  if (D->isVariadic())
-dumpChild([=]{ OS << "..."; });
-
   if (D->capturesCXXThis())
 dumpChild([=]{ OS << "capture this"; });
 

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=351597&r1=351596&r2=351597&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Fri Jan 18 13:38:30 2019
@@ -1096,6 +1096,8 @@ void TextNodeDumper::VisitFunctionProtoT
 OS << " volatile";
   if (T->isRestrict())
 OS << " restrict";
+  if (T->getExtProtoInfo().Variadic)
+OS << " variadic";
   switch (EPI.RefQualifier) {
   case RQ_None:
 break;

Modified: cfe/trunk/test/AST/ast-dump-decl.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.m?rev=351597&r1=351596&r2=351597&view=diff
==
--- cfe/trunk/test/AST/ast-dump-decl.m (original)
+++ cfe/trunk/test/AST/ast-dump-decl.m Fri Jan 18 13:38:30 2019
@@ -28,20 +28,18 @@
 @interface testObjCMethodDecl : A {
 }
 - (int) TestObjCMethodDecl: (int)i, ...;
-// CHECK:  ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int'
+// CHECK:  ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int' variadic
 // CHECK-NEXT:   ParmVarDecl{{.*}} i 'int'
-// CHECK-NEXT:   ...
 @end
 
 @implementation testObjCMethodDecl
 - (int) TestObjCMethodDecl: (int)i, ... {
   return 0;
 }
-// CHECK:  ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int'
+// CHECK:  ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int' variadic
 // CHECK-NEXT:   ImplicitParamDecl{{.*}} self
 // CHECK-NEXT:   ImplicitParamDecl{{.*}} _cmd
 // CHECK-NEXT:   ParmVarDecl{{.*}} i 'int'
-// CHECK-NEXT:   ...
 // CHECK-NEXT:   CompoundStmt
 @end
 
@@ -137,9 +135,8 @@ void TestBlockDecl(int x) {
   ^(int y, ...){ x; };
 }
 // CHECK:  FunctionDecl{{.*}}TestBlockDecl
-// CHECK:  BlockDecl
+// CHECK:  BlockDecl {{.+}}  col:3 variadic
 // CHECK-NEXT:   ParmVarDecl{{.*}} y 'int'
-// CHECK-NEXT:   ...
 // CHECK-NEXT:   capture ParmVar{{.*}} 'x' 'int'
 // CHECK-NEXT:   CompoundStmt
 


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


r351600 - [ASTDump] Mark BlockDecls which capture this with a tag

2019-01-18 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Fri Jan 18 13:55:24 2019
New Revision: 351600

URL: http://llvm.org/viewvc/llvm-project?rev=351600&view=rev
Log:
[ASTDump] Mark BlockDecls which capture this with a tag

Summary:
Removal of the child node makes it easier to separate traversal from
output generation.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/test/AST/ast-dump-decl.mm

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351600&r1=351599&r2=351600&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Fri Jan 18 13:55:24 2019
@@ -1379,12 +1379,12 @@ void ASTDumper::VisitBlockDecl(const Blo
   if (D->isVariadic())
 OS << " variadic";
 
+  if (D->capturesCXXThis())
+OS << " captures_this";
+
   for (auto I : D->parameters())
 dumpDecl(I);
 
-  if (D->capturesCXXThis())
-dumpChild([=]{ OS << "capture this"; });
-
   for (const auto &I : D->captures())
 Visit(I);
   dumpStmt(D->getBody());

Modified: cfe/trunk/test/AST/ast-dump-decl.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.mm?rev=351600&r1=351599&r2=351600&view=diff
==
--- cfe/trunk/test/AST/ast-dump-decl.mm (original)
+++ cfe/trunk/test/AST/ast-dump-decl.mm Fri Jan 18 13:55:24 2019
@@ -39,8 +39,7 @@ struct Test {
 // CHECK-NEXT:   cleanup Block
 // CHECK-NEXT:   CallExpr {{.*}}  'void'
 // CHECK-NEXT: BlockExpr {{.*}}  'void (^)()'
-// CHECK-NEXT:   BlockDecl {{.*}}  col:5
-// CHECK-NEXT: capture this
+// CHECK-NEXT:   BlockDecl {{.*}}  col:5 captures_this
 // CHECK-NEXT: CompoundStmt {{.*}} 
 // CHECK-NEXT:   CXXMemberCallExpr {{.*}}  'void'
 // CHECK-NEXT: MemberExpr {{.*}}  '' ->yada


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


r351601 - [ASTDump] Mark null params with a tag rather than a child node

2019-01-18 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Fri Jan 18 14:00:16 2019
New Revision: 351601

URL: http://llvm.org/viewvc/llvm-project?rev=351601&view=rev
Log:
[ASTDump] Mark null params with a tag rather than a child node

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351601&r1=351600&r2=351601&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Fri Jan 18 14:00:16 2019
@@ -633,13 +633,18 @@ void ASTDumper::VisitFunctionDecl(const
 }
   }
 
+  // Since NumParams comes from the FunctionProtoType of the FunctionDecl and
+  // the Params are set later, it is possible for a dump during debugging to
+  // encounter a FunctionDecl that has been created but hasn't been assigned
+  // ParmVarDecls yet.
+  if (!D->param_empty() && !D->param_begin())
+OS << " <>>";
+
   if (const auto *FTSI = D->getTemplateSpecializationInfo())
 dumpTemplateArgumentList(*FTSI->TemplateArguments);
 
-  if (!D->param_begin() && D->getNumParams())
-dumpChild([=] { OS << ">"; });
-  else
-for (const ParmVarDecl *Parameter : D->parameters())
+  if (D->param_begin())
+for (const auto *Parameter : D->parameters())
   dumpDecl(Parameter);
 
   if (const auto *C = dyn_cast(D))


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


r351606 - [ASTDump] Add test for current AST dump behavior

2019-01-18 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Fri Jan 18 14:15:13 2019
New Revision: 351606

URL: http://llvm.org/viewvc/llvm-project?rev=351606&view=rev
Log:
[ASTDump] Add test for current AST dump behavior

Added:
cfe/trunk/test/AST/ast-dump-undeserialized.cpp

Added: cfe/trunk/test/AST/ast-dump-undeserialized.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-undeserialized.cpp?rev=351606&view=auto
==
--- cfe/trunk/test/AST/ast-dump-undeserialized.cpp (added)
+++ cfe/trunk/test/AST/ast-dump-undeserialized.cpp Fri Jan 18 14:15:13 2019
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -chain-include %s -ast-dump | FileCheck 
-strict-whitespace %s
+
+// CHECK: TranslationUnitDecl 0x{{.+}} <> 
+// CHECK: `-


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


r351604 - [ASTDump] NFC: Remove redundant condition

2019-01-18 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Fri Jan 18 14:15:05 2019
New Revision: 351604

URL: http://llvm.org/viewvc/llvm-project?rev=351604&view=rev
Log:
[ASTDump] NFC: Remove redundant condition

These conditions are duplicated from the dumpDeclContext function called
within the if(). This is presumably an attempt to avoid calling the
function in the case it will do nothing.

That may have made sense in the past if the code was different, but it
doesn't make sense now.

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351604&r1=351603&r2=351604&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Fri Jan 18 14:15:05 2019
@@ -514,10 +514,7 @@ void ASTDumper::dumpDecl(const Decl *D)
 // Decls within functions are visited by the body.
 if (!isa(*D) && !isa(*D)) {
   auto DC = dyn_cast(D);
-  if (DC &&
-  (DC->hasExternalLexicalStorage() ||
-   (Deserialize ? DC->decls_begin() != DC->decls_end()
-: DC->noload_decls_begin() != DC->noload_decls_end(
+  if (DC)
 dumpDeclContext(DC);
 }
   });


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


r351603 - [ASTDump] NFC: Remove non-needed braces

2019-01-18 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Fri Jan 18 14:14:59 2019
New Revision: 351603

URL: http://llvm.org/viewvc/llvm-project?rev=351603&view=rev
Log:
[ASTDump] NFC: Remove non-needed braces

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351603&r1=351602&r2=351603&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Fri Jan 18 14:14:59 2019
@@ -1242,12 +1242,11 @@ void ASTDumper::VisitObjCMethodDecl(cons
   if (D->isVariadic())
 OS << " variadic";
 
-  if (D->isThisDeclarationADefinition()) {
+  if (D->isThisDeclarationADefinition())
 dumpDeclContext(D);
-  } else {
+  else
 for (const ParmVarDecl *Parameter : D->parameters())
   dumpDecl(Parameter);
-  }
 
   if (D->hasBody())
 dumpStmt(D->getBody());


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


r351605 - [ASTDump] NFC: Move variable into if() statement

2019-01-18 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Fri Jan 18 14:15:09 2019
New Revision: 351605

URL: http://llvm.org/viewvc/llvm-project?rev=351605&view=rev
Log:
[ASTDump] NFC: Move variable into if() statement

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351605&r1=351604&r2=351605&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Fri Jan 18 14:15:09 2019
@@ -513,8 +513,7 @@ void ASTDumper::dumpDecl(const Decl *D)
 
 // Decls within functions are visited by the body.
 if (!isa(*D) && !isa(*D)) {
-  auto DC = dyn_cast(D);
-  if (DC)
+  if (const auto *DC = dyn_cast(D))
 dumpDeclContext(DC);
 }
   });


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


r351637 - Move decl context dumping to TextNodeDumper

2019-01-19 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sat Jan 19 01:05:55 2019
New Revision: 351637

URL: http://llvm.org/viewvc/llvm-project?rev=351637&view=rev
Log:
Move decl context dumping to TextNodeDumper

Summary: Only an obscure case is moved.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp
cfe/trunk/test/AST/ast-dump-undeserialized.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351637&r1=351636&r2=351637&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Sat Jan 19 01:05:55 2019
@@ -359,13 +359,6 @@ void ASTDumper::dumpDeclContext(const De
 
   for (auto *D : (Deserialize ? DC->decls() : DC->noload_decls()))
 dumpDecl(D);
-
-  if (DC->hasExternalLexicalStorage()) {
-dumpChild([=] {
-  ColorScope Color(OS, ShowColors, UndeserializedColor);
-  OS << "";
-});
-  }
 }
 
 void ASTDumper::dumpLookups(const DeclContext *DC, bool DumpDecls) {

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=351637&r1=351636&r2=351637&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Sat Jan 19 01:05:55 2019
@@ -255,6 +255,17 @@ void TextNodeDumper::Visit(const Decl *D
   if (const FunctionDecl *FD = dyn_cast(D))
 if (FD->isConstexpr())
   OS << " constexpr";
+
+  if (!isa(*D)) {
+const auto *MD = dyn_cast(D);
+if (!MD || !MD->isThisDeclarationADefinition()) {
+  const auto *DC = dyn_cast(D);
+  if (DC && DC->hasExternalLexicalStorage()) {
+ColorScope Color(OS, ShowColors, UndeserializedColor);
+OS << " ";
+  }
+}
+  }
 }
 
 void TextNodeDumper::Visit(const CXXCtorInitializer *Init) {

Modified: cfe/trunk/test/AST/ast-dump-undeserialized.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-undeserialized.cpp?rev=351637&r1=351636&r2=351637&view=diff
==
--- cfe/trunk/test/AST/ast-dump-undeserialized.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-undeserialized.cpp Sat Jan 19 01:05:55 2019
@@ -1,4 +1,3 @@
 // RUN: %clang_cc1 %s -chain-include %s -ast-dump | FileCheck 
-strict-whitespace %s
 
-// CHECK: TranslationUnitDecl 0x{{.+}} <> 
-// CHECK: `-
+// CHECK: TranslationUnitDecl 0x{{.+}} <>  



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


r351646 - [ASTDump] NFC: Use `const auto` in cxx_range_for loops

2019-01-19 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sat Jan 19 01:57:51 2019
New Revision: 351646

URL: http://llvm.org/viewvc/llvm-project?rev=351646&view=rev
Log:
[ASTDump] NFC: Use `const auto` in cxx_range_for loops

This is coming up a lot in reviews. Better just to do them all at once.

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351646&r1=351645&r2=351646&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Sat Jan 19 01:57:51 2019
@@ -161,7 +161,7 @@ namespace  {
 }
 void VisitFunctionProtoType(const FunctionProtoType *T) {
   VisitFunctionType(T);
-  for (QualType PT : T->getParamTypes())
+  for (const QualType &PT : T->getParamTypes())
 dumpTypeAsChild(PT);
 }
 void VisitTypeOfExprType(const TypeOfExprType *T) {
@@ -186,7 +186,7 @@ namespace  {
   dumpTemplateArgument(T->getArgumentPack());
 }
 void VisitTemplateSpecializationType(const TemplateSpecializationType *T) {
-  for (auto &Arg : *T)
+  for (const auto &Arg : *T)
 dumpTemplateArgument(Arg);
   if (T->isTypeAlias())
 dumpTypeAsChild(T->getAliasedType());
@@ -357,7 +357,7 @@ void ASTDumper::dumpDeclContext(const De
   if (!DC)
 return;
 
-  for (auto *D : (Deserialize ? DC->decls() : DC->noload_decls()))
+  for (const auto *D : (Deserialize ? DC->decls() : DC->noload_decls()))
 dumpDecl(D);
 }
 
@@ -478,7 +478,7 @@ void ASTDumper::dumpObjCTypeParamList(co
   if (!typeParams)
 return;
 
-  for (auto typeParam : *typeParams) {
+  for (const auto &typeParam : *typeParams) {
 dumpDecl(typeParam);
   }
 }
@@ -555,7 +555,7 @@ void ASTDumper::VisitIndirectFieldDecl(c
   NodeDumper.dumpName(D);
   NodeDumper.dumpType(D->getType());
 
-  for (auto *Child : D->chain())
+  for (const auto *Child : D->chain())
 NodeDumper.dumpDeclRef(Child);
 }
 
@@ -688,14 +688,14 @@ void ASTDumper::VisitVarDecl(const VarDe
 
 void ASTDumper::VisitDecompositionDecl(const DecompositionDecl *D) {
   VisitVarDecl(D);
-  for (auto *B : D->bindings())
+  for (const auto *B : D->bindings())
 dumpDecl(B);
 }
 
 void ASTDumper::VisitBindingDecl(const BindingDecl *D) {
   NodeDumper.dumpName(D);
   NodeDumper.dumpType(D->getType());
-  if (auto *E = D->getBinding())
+  if (const auto *E = D->getBinding())
 dumpStmt(E);
 }
 
@@ -736,7 +736,7 @@ void ASTDumper::VisitCapturedDecl(const
 
//===--===//
 
 void ASTDumper::VisitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D) {
-  for (auto *E : D->varlists())
+  for (const auto *E : D->varlists())
 dumpStmt(E);
 }
 
@@ -766,7 +766,7 @@ void ASTDumper::VisitOMPDeclareReduction
 }
 
 void ASTDumper::VisitOMPRequiresDecl(const OMPRequiresDecl *D) {
-  for (auto *C : D->clauselists()) {
+  for (const auto *C : D->clauselists()) {
 dumpChild([=] {
   if (!C) {
 ColorScope Color(OS, ShowColors, NullColor);
@@ -974,7 +974,7 @@ void ASTDumper::dumpTemplateDeclSpeciali
bool DumpExplicitInst,
bool DumpRefOnly) {
   bool DumpedAny = false;
-  for (auto *RedeclWithBadType : D->redecls()) {
+  for (const auto *RedeclWithBadType : D->redecls()) {
 // FIXME: The redecls() range sometimes has elements of a less-specific
 // type. (In particular, ClassTemplateSpecializationDecl::redecls() gives
 // us TagDecls, and should give CXXRecordDecls).
@@ -1018,7 +1018,7 @@ void ASTDumper::dumpTemplateDecl(const T
 
   dumpDecl(D->getTemplatedDecl());
 
-  for (auto *Child : D->specializations())
+  for (const auto *Child : D->specializations())
 dumpTemplateDeclSpecialization(Child, DumpExplicitInst,
!D->isCanonicalDecl());
 }
@@ -1280,7 +1280,7 @@ void ASTDumper::VisitObjCCategoryImplDec
 void ASTDumper::VisitObjCProtocolDecl(const ObjCProtocolDecl *D) {
   NodeDumper.dumpName(D);
 
-  for (auto *Child : D->protocols())
+  for (const auto *Child : D->protocols())
 NodeDumper.dumpDeclRef(Child);
 }
 
@@ -1289,7 +1289,7 @@ void ASTDumper::VisitObjCInterfaceDecl(c
   NodeDumper.dumpDeclRef(D->getSuperClass(), "super");
 
   NodeDumper.dumpDeclRef(D->getImplementation());
-  for (auto *Child : D->protocols())
+  for (const auto *Child : D->protocols())
 NodeDumper.dumpDeclRef(Child);
   dumpObjCTypeParamList(D->getTypeParamListAsWritten());
 }
@@ -1374,7 +1374,7 @@ void ASTDumper::VisitBlockDecl(const Blo
   if (D->capturesCXXThis())
 OS << " captures_this";
 
-  for (auto I : D->parameters())
+  for (const auto &I : D->parameters())
 dumpDecl(I);
 
   for (const auto &I : D->captures())
@@ -1435,7 +1435,7 @@ void ASTDumper::VisitCapturedStmt(const
 void ASTDumper::Visit(const OMPClause *C) {
   du

r351647 - [ASTDump] NFC: Convert iterative loops to cxx_range_for

2019-01-19 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sat Jan 19 01:57:59 2019
New Revision: 351647

URL: http://llvm.org/viewvc/llvm-project?rev=351647&view=rev
Log:
[ASTDump] NFC: Convert iterative loops to cxx_range_for

This is coming up a lot in reviews. Better just to change them all at
once.

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351647&r1=351646&r2=351647&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Sat Jan 19 01:57:59 2019
@@ -442,15 +442,14 @@ void ASTDumper::dumpTemplateParameters(c
   if (!TPL)
 return;
 
-  for (TemplateParameterList::const_iterator I = TPL->begin(), E = TPL->end();
-   I != E; ++I)
-dumpDecl(*I);
+  for (const auto &TP : *TPL)
+dumpDecl(TP);
 }
 
 void ASTDumper::dumpTemplateArgumentListInfo(
 const TemplateArgumentListInfo &TALI) {
-  for (unsigned i = 0, e = TALI.size(); i < e; ++i)
-dumpTemplateArgumentLoc(TALI[i]);
+  for (const auto &TA : TALI.arguments())
+dumpTemplateArgumentLoc(TA);
 }
 
 void ASTDumper::dumpTemplateArgumentLoc(const TemplateArgumentLoc &A,
@@ -495,9 +494,8 @@ void ASTDumper::dumpDecl(const Decl *D)
 
 ConstDeclVisitor::Visit(D);
 
-for (Decl::attr_iterator I = D->attr_begin(), E = D->attr_end(); I != E;
- ++I)
-  dumpAttr(*I);
+for (const auto &A : D->attrs())
+  dumpAttr(A);
 
 if (const FullComment *Comment =
 D->getASTContext().getLocalCommentForDeclUncached(D))
@@ -1264,10 +1262,8 @@ void ASTDumper::VisitObjCCategoryDecl(co
   NodeDumper.dumpName(D);
   NodeDumper.dumpDeclRef(D->getClassInterface());
   NodeDumper.dumpDeclRef(D->getImplementation());
-  for (ObjCCategoryDecl::protocol_iterator I = D->protocol_begin(),
-   E = D->protocol_end();
-   I != E; ++I)
-NodeDumper.dumpDeclRef(*I);
+  for (const auto *P : D->protocols())
+NodeDumper.dumpDeclRef(P);
   dumpObjCTypeParamList(D->getTypeParamList());
 }
 
@@ -1298,10 +1294,8 @@ void ASTDumper::VisitObjCImplementationD
   NodeDumper.dumpName(D);
   NodeDumper.dumpDeclRef(D->getSuperClass(), "super");
   NodeDumper.dumpDeclRef(D->getClassInterface());
-  for (ObjCImplementationDecl::init_const_iterator I = D->init_begin(),
-   E = D->init_end();
-   I != E; ++I)
-dumpCXXCtorInitializer(*I);
+  for (const auto &I : D->inits())
+dumpCXXCtorInitializer(I);
 }
 
 void ASTDumper::VisitObjCCompatibleAliasDecl(const ObjCCompatibleAliasDecl *D) 
{
@@ -1407,17 +1401,13 @@ void ASTDumper::dumpStmt(const Stmt *S,
 }
 
 void ASTDumper::VisitDeclStmt(const DeclStmt *Node) {
-  for (DeclStmt::const_decl_iterator I = Node->decl_begin(),
- E = Node->decl_end();
-   I != E; ++I)
-dumpDecl(*I);
+  for (const auto &D : Node->decls())
+dumpDecl(D);
 }
 
 void ASTDumper::VisitAttributedStmt(const AttributedStmt *Node) {
-  for (ArrayRef::iterator I = Node->getAttrs().begin(),
-E = Node->getAttrs().end();
-   I != E; ++I)
-dumpAttr(*I);
+  for (const auto *A : Node->getAttrs())
+dumpAttr(A);
 }
 
 void ASTDumper::VisitCXXCatchStmt(const CXXCatchStmt *Node) {


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


Re: [PATCH] D56829: Move decl context dumping to TextNodeDumper

2019-01-20 Thread Stephen Kelly via cfe-commits

On 20/01/2019 16:57, Stella Stamenova via Phabricator via cfe-commits wrote:

stella.stamenova added a comment.

It looks like this change broke a number of the LLDB tests:

lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/781

Could you look into this or revert the change, so that the bot can go back to 
green?


Thanks for the heads up!

It looks like lldb tests are testing the output of AST dumps.

I made a clone of lldb and tried to fix the tests with r351703.

Thanks,

Stephen.

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


r352552 - NFC: Implement GenericSelectionExpr::Association dump with Visitor

2019-01-29 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan 29 14:22:55 2019
New Revision: 352552

URL: http://llvm.org/viewvc/llvm-project?rev=352552&view=rev
Log:
NFC: Implement GenericSelectionExpr::Association dump with Visitor

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=352552&r1=352551&r2=352552&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Tue Jan 29 14:22:55 2019
@@ -172,6 +172,8 @@ public:
 
   void Visit(const BlockDecl::Capture &C);
 
+  void Visit(const GenericSelectionExpr::ConstAssociation &A);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=352552&r1=352551&r2=352552&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 29 14:22:55 2019
@@ -297,6 +297,7 @@ namespace  {
 void VisitInitListExpr(const InitListExpr *ILE);
 void VisitBlockExpr(const BlockExpr *Node);
 void VisitOpaqueValueExpr(const OpaqueValueExpr *Node);
+void Visit(const GenericSelectionExpr::ConstAssociation &A);
 void VisitGenericSelectionExpr(const GenericSelectionExpr *E);
 
 // C++
@@ -1456,6 +1457,15 @@ void ASTDumper::VisitOpaqueValueExpr(con
 dumpStmt(Source);
 }
 
+void ASTDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
+  dumpChild([=] {
+NodeDumper.Visit(A);
+if (const TypeSourceInfo *TSI = A.getTypeSourceInfo())
+  dumpTypeAsChild(TSI->getType());
+dumpStmt(A.getAssociationExpr());
+  });
+}
+
 void ASTDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
   if (E->isResultDependent())
 OS << " result_dependent";
@@ -1463,21 +1473,7 @@ void ASTDumper::VisitGenericSelectionExp
   dumpTypeAsChild(E->getControllingExpr()->getType()); // FIXME: remove
 
   for (const auto &Assoc : E->associations()) {
-dumpChild([=] {
-  if (const TypeSourceInfo *TSI = Assoc.getTypeSourceInfo()) {
-OS << "case ";
-NodeDumper.dumpType(TSI->getType());
-  } else {
-OS << "default";
-  }
-
-  if (Assoc.isSelected())
-OS << " selected";
-
-  if (const TypeSourceInfo *TSI = Assoc.getTypeSourceInfo())
-dumpTypeAsChild(TSI->getType());
-  dumpStmt(Assoc.getAssociationExpr());
-});
+Visit(Assoc);
   }
 }
 

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=352552&r1=352551&r2=352552&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Tue Jan 29 14:22:55 2019
@@ -312,6 +312,19 @@ void TextNodeDumper::Visit(const OMPClau
 OS << " ";
 }
 
+void TextNodeDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
+  const TypeSourceInfo *TSI = A.getTypeSourceInfo();
+  if (TSI) {
+OS << "case ";
+dumpType(TSI->getType());
+  } else {
+OS << "default";
+  }
+
+  if (A.isSelected())
+OS << " selected";
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;


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


r352558 - NFC: Move GenericSelectionExpr dump to NodeDumper

2019-01-29 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan 29 14:58:28 2019
New Revision: 352558

URL: http://llvm.org/viewvc/llvm-project?rev=352558&view=rev
Log:
NFC: Move GenericSelectionExpr dump to NodeDumper

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=352558&r1=352557&r2=352558&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Tue Jan 29 14:58:28 2019
@@ -237,6 +237,7 @@ public:
   void VisitFloatingLiteral(const FloatingLiteral *Node);
   void VisitStringLiteral(const StringLiteral *Str);
   void VisitInitListExpr(const InitListExpr *ILE);
+  void VisitGenericSelectionExpr(const GenericSelectionExpr *E);
   void VisitUnaryOperator(const UnaryOperator *Node);
   void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Node);
   void VisitMemberExpr(const MemberExpr *Node);

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=352558&r1=352557&r2=352558&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 29 14:58:28 2019
@@ -1467,8 +1467,6 @@ void ASTDumper::Visit(const GenericSelec
 }
 
 void ASTDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
-  if (E->isResultDependent())
-OS << " result_dependent";
   dumpStmt(E->getControllingExpr());
   dumpTypeAsChild(E->getControllingExpr()->getType()); // FIXME: remove
 

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=352558&r1=352557&r2=352558&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Tue Jan 29 14:58:28 2019
@@ -776,6 +776,11 @@ void TextNodeDumper::VisitInitListExpr(c
   }
 }
 
+void TextNodeDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
+  if (E->isResultDependent())
+OS << " result_dependent";
+}
+
 void TextNodeDumper::VisitUnaryOperator(const UnaryOperator *Node) {
   OS << " " << (Node->isPostfix() ? "postfix" : "prefix") << " '"
  << UnaryOperator::getOpcodeStr(Node->getOpcode()) << "'";


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


r352655 - [ASTDump] Move Decl node dumping to TextNodeDumper

2019-01-30 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Jan 30 11:32:48 2019
New Revision: 352655

URL: http://llvm.org/viewvc/llvm-project?rev=352655&view=rev
Log:
[ASTDump] Move Decl node dumping to TextNodeDumper

Reviewers: aaron.ballman

Subscribers: jfb, cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=352655&r1=352654&r2=352655&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Wed Jan 30 11:32:48 2019
@@ -18,6 +18,7 @@
 #include "clang/AST/AttrVisitor.h"
 #include "clang/AST/CommentCommandTraits.h"
 #include "clang/AST/CommentVisitor.h"
+#include "clang/AST/DeclVisitor.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/AST/TemplateArgumentVisitor.h"
@@ -128,7 +129,8 @@ class TextNodeDumper
   public ConstAttrVisitor,
   public ConstTemplateArgumentVisitor,
   public ConstStmtVisitor,
-  public TypeVisitor {
+  public TypeVisitor,
+  public ConstDeclVisitor {
   raw_ostream &OS;
   const bool ShowColors;
 
@@ -291,6 +293,57 @@ public:
   void VisitObjCInterfaceType(const ObjCInterfaceType *T);
   void VisitPackExpansionType(const PackExpansionType *T);
 
+  void VisitLabelDecl(const LabelDecl *D);
+  void VisitTypedefDecl(const TypedefDecl *D);
+  void VisitEnumDecl(const EnumDecl *D);
+  void VisitRecordDecl(const RecordDecl *D);
+  void VisitEnumConstantDecl(const EnumConstantDecl *D);
+  void VisitIndirectFieldDecl(const IndirectFieldDecl *D);
+  void VisitFunctionDecl(const FunctionDecl *D);
+  void VisitFieldDecl(const FieldDecl *D);
+  void VisitVarDecl(const VarDecl *D);
+  void VisitBindingDecl(const BindingDecl *D);
+  void VisitCapturedDecl(const CapturedDecl *D);
+  void VisitImportDecl(const ImportDecl *D);
+  void VisitPragmaCommentDecl(const PragmaCommentDecl *D);
+  void VisitPragmaDetectMismatchDecl(const PragmaDetectMismatchDecl *D);
+  void VisitOMPDeclareReductionDecl(const OMPDeclareReductionDecl *D);
+  void VisitOMPRequiresDecl(const OMPRequiresDecl *D);
+  void VisitOMPCapturedExprDecl(const OMPCapturedExprDecl *D);
+  void VisitNamespaceDecl(const NamespaceDecl *D);
+  void VisitUsingDirectiveDecl(const UsingDirectiveDecl *D);
+  void VisitNamespaceAliasDecl(const NamespaceAliasDecl *D);
+  void VisitTypeAliasDecl(const TypeAliasDecl *D);
+  void VisitTypeAliasTemplateDecl(const TypeAliasTemplateDecl *D);
+  void VisitCXXRecordDecl(const CXXRecordDecl *D);
+  void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D);
+  void VisitClassTemplateDecl(const ClassTemplateDecl *D);
+  void VisitBuiltinTemplateDecl(const BuiltinTemplateDecl *D);
+  void VisitVarTemplateDecl(const VarTemplateDecl *D);
+  void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D);
+  void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D);
+  void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D);
+  void VisitUsingDecl(const UsingDecl *D);
+  void VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D);
+  void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D);
+  void VisitUsingShadowDecl(const UsingShadowDecl *D);
+  void VisitConstructorUsingShadowDecl(const ConstructorUsingShadowDecl *D);
+  void VisitLinkageSpecDecl(const LinkageSpecDecl *D);
+  void VisitAccessSpecDecl(const AccessSpecDecl *D);
+  void VisitFriendDecl(const FriendDecl *D);
+  void VisitObjCIvarDecl(const ObjCIvarDecl *D);
+  void VisitObjCMethodDecl(const ObjCMethodDecl *D);
+  void VisitObjCTypeParamDecl(const ObjCTypeParamDecl *D);
+  void VisitObjCCategoryDecl(const ObjCCategoryDecl *D);
+  void VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *D);
+  void VisitObjCProtocolDecl(const ObjCProtocolDecl *D);
+  void VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D);
+  void VisitObjCImplementationDecl(const ObjCImplementationDecl *D);
+  void VisitObjCCompatibleAliasDecl(const ObjCCompatibleAliasDecl *D);
+  void VisitObjCPropertyDecl(const ObjCPropertyDecl *D);
+  void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
+  void VisitBlockDecl(const BlockDecl *D);
+
 private:
   void dumpCXXTemporary(const CXXTemporary *Temporary);
 };

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=352655&r1=352654&r2=352655&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Wed Jan 30 11:32:48 2019
@@ -51,9 +51,6 @@ namespace  {
 
 raw_ostream &OS;
 
-/// The policy to use for printing; can be defa

r352656 - [ASTDump] NFC: Inline vestigial methods

2019-01-30 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Jan 30 11:41:04 2019
New Revision: 352656

URL: http://llvm.org/viewvc/llvm-project?rev=352656&view=rev
Log:
[ASTDump] NFC: Inline vestigial methods

This was a porting aid.

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=352656&r1=352655&r2=352656&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Wed Jan 30 11:41:04 2019
@@ -57,14 +57,6 @@ namespace  {
 
 const bool ShowColors;
 
-/// Dump a child of the current node.
-template void dumpChild(Fn DoDumpChild) {
-  NodeDumper.AddChild(DoDumpChild);
-}
-template  void dumpChild(StringRef Label, Fn DoDumpChild) {
-  NodeDumper.AddChild(Label, DoDumpChild);
-}
-
   public:
 ASTDumper(raw_ostream &OS, const CommandTraits *Traits,
   const SourceManager *SM)
@@ -306,14 +298,14 @@ void ASTDumper::dumpTypeAsChild(QualType
   if (!SQT.Quals.hasQualifiers())
 return dumpTypeAsChild(SQT.Ty);
 
-  dumpChild([=] {
+  NodeDumper.AddChild([=] {
 NodeDumper.Visit(T);
 dumpTypeAsChild(T.split().Ty);
   });
 }
 
 void ASTDumper::dumpTypeAsChild(const Type *T) {
-  dumpChild([=] {
+  NodeDumper.AddChild([=] {
 NodeDumper.Visit(T);
 if (!T)
   return;
@@ -335,7 +327,7 @@ void ASTDumper::dumpDeclContext(const De
 }
 
 void ASTDumper::dumpLookups(const DeclContext *DC, bool DumpDecls) {
-  dumpChild([=] {
+  NodeDumper.AddChild([=] {
 OS << "StoredDeclsMap ";
 NodeDumper.dumpBareDeclRef(cast(DC));
 
@@ -354,7 +346,7 @@ void ASTDumper::dumpLookups(const DeclCo
   DeclarationName Name = I.getLookupName();
   DeclContextLookupResult R = *I;
 
-  dumpChild([=] {
+  NodeDumper.AddChild([=] {
 OS << "DeclarationName ";
 {
   ColorScope Color(OS, ShowColors, DeclNameColor);
@@ -363,7 +355,7 @@ void ASTDumper::dumpLookups(const DeclCo
 
 for (DeclContextLookupResult::iterator RI = R.begin(), RE = R.end();
  RI != RE; ++RI) {
-  dumpChild([=] {
+  NodeDumper.AddChild([=] {
 NodeDumper.dumpBareDeclRef(*RI);
 
 if ((*RI)->isHidden())
@@ -385,7 +377,7 @@ void ASTDumper::dumpLookups(const DeclCo
 }
 
 if (HasUndeserializedLookups) {
-  dumpChild([=] {
+  NodeDumper.AddChild([=] {
 ColorScope Color(OS, ShowColors, UndeserializedColor);
 OS << "";
   });
@@ -394,7 +386,7 @@ void ASTDumper::dumpLookups(const DeclCo
 }
 
 void ASTDumper::dumpAttr(const Attr *A) {
-  dumpChild([=] {
+  NodeDumper.AddChild([=] {
 NodeDumper.Visit(A);
 ConstAttrVisitor::Visit(A);
   });
@@ -405,7 +397,7 @@ void ASTDumper::dumpAttr(const Attr *A)
 
//===--===//
 
 void ASTDumper::dumpCXXCtorInitializer(const CXXCtorInitializer *Init) {
-  dumpChild([=] {
+  NodeDumper.AddChild([=] {
 NodeDumper.Visit(Init);
 dumpStmt(Init->getInit());
   });
@@ -437,7 +429,7 @@ void ASTDumper::dumpTemplateArgumentList
 
 void ASTDumper::dumpTemplateArgument(const TemplateArgument &A, SourceRange R,
  const Decl *From, const char *Label) {
-  dumpChild([=] {
+  NodeDumper.AddChild([=] {
 NodeDumper.Visit(A, R, From, Label);
 ConstTemplateArgumentVisitor::Visit(A);
   });
@@ -460,7 +452,7 @@ void ASTDumper::dumpObjCTypeParamList(co
 
//===--===//
 
 void ASTDumper::dumpDecl(const Decl *D) {
-  dumpChild([=] {
+  NodeDumper.AddChild([=] {
 NodeDumper.Visit(D);
 if (!D)
   return;
@@ -741,7 +733,7 @@ void ASTDumper::VisitObjCImplementationD
 }
 
 void ASTDumper::Visit(const BlockDecl::Capture &C) {
-  dumpChild([=] {
+  NodeDumper.AddChild([=] {
 NodeDumper.Visit(C);
 if (C.hasCopyExpr())
   dumpStmt(C.getCopyExpr());
@@ -762,7 +754,7 @@ void ASTDumper::VisitBlockDecl(const Blo
 
//===--===//
 
 void ASTDumper::dumpStmt(const Stmt *S, StringRef Label) {
-  dumpChild(Label, [=] {
+  NodeDumper.AddChild(Label, [=] {
 NodeDumper.Visit(S);
 
 if (!S) {
@@ -804,7 +796,7 @@ void ASTDumper::VisitCapturedStmt(const
 
//===--===//
 
 void ASTDumper::Visit(const OMPClause *C) {
-  dumpChild([=] {
+  NodeDumper.AddChild([=] {
 NodeDumper.Visit(C);
 for (const auto *S : C->children())
   dumpStmt(S);
@@ -838,7 +830,7 @@ void ASTDumper::VisitOpaqueValueExpr(con
 }
 
 void ASTDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
-  dumpChild([=] {
+  NodeDumper.AddChild([=] {
 NodeDumper.Visit(A);
 if (const TypeSourceInfo *TSI = A.getTypeSourceInfo())
   dumpTypeAsChild(TSI->getTyp

r352657 - [ASTDump] Rename methods which are conceptually Visits

2019-01-30 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Jan 30 11:49:49 2019
New Revision: 352657

URL: http://llvm.org/viewvc/llvm-project?rev=352657&view=rev
Log:
[ASTDump] Rename methods which are conceptually Visits

This is consistent with the TextNodeDumper, and is the appropriate name
for the traverser class which will be extracted.

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=352657&r1=352656&r2=352657&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Wed Jan 30 11:49:49 2019
@@ -74,28 +74,26 @@ namespace  {
 
 void setDeserialize(bool D) { Deserialize = D; }
 
-void dumpDecl(const Decl *D);
-void dumpStmt(const Stmt *S, StringRef Label = {});
+void Visit(const Decl *D);
+void Visit(const Stmt *S, StringRef Label = {});
 
 // Utilities
-void dumpTypeAsChild(QualType T);
-void dumpTypeAsChild(const Type *T);
+void Visit(QualType T);
+void Visit(const Type *T);
 void dumpDeclContext(const DeclContext *DC);
 void dumpLookups(const DeclContext *DC, bool DumpDecls);
-void dumpAttr(const Attr *A);
+void Visit(const Attr *A);
 
 // C++ Utilities
-void dumpCXXCtorInitializer(const CXXCtorInitializer *Init);
+void Visit(const CXXCtorInitializer *Init);
 void dumpTemplateParameters(const TemplateParameterList *TPL);
 void dumpTemplateArgumentListInfo(const TemplateArgumentListInfo &TALI);
 void dumpTemplateArgumentLoc(const TemplateArgumentLoc &A,
  const Decl *From = nullptr,
  const char *Label = nullptr);
 void dumpTemplateArgumentList(const TemplateArgumentList &TAL);
-void dumpTemplateArgument(const TemplateArgument &A,
-  SourceRange R = SourceRange(),
-  const Decl *From = nullptr,
-  const char *Label = nullptr);
+void Visit(const TemplateArgument &A, SourceRange R = SourceRange(),
+   const Decl *From = nullptr, const char *Label = nullptr);
 template 
 void dumpTemplateDeclSpecialization(const SpecializationDecl *D,
 bool DumpExplicitInst,
@@ -108,93 +106,93 @@ namespace  {
 
 // Types
 void VisitComplexType(const ComplexType *T) {
-  dumpTypeAsChild(T->getElementType());
+  Visit(T->getElementType());
 }
 void VisitLocInfoType(const LocInfoType *T) {
-  dumpTypeAsChild(T->getTypeSourceInfo()->getType());
+  Visit(T->getTypeSourceInfo()->getType());
 }
 void VisitPointerType(const PointerType *T) {
-  dumpTypeAsChild(T->getPointeeType());
+  Visit(T->getPointeeType());
 }
 void VisitBlockPointerType(const BlockPointerType *T) {
-  dumpTypeAsChild(T->getPointeeType());
+  Visit(T->getPointeeType());
 }
 void VisitReferenceType(const ReferenceType *T) {
-  dumpTypeAsChild(T->getPointeeType());
+  Visit(T->getPointeeType());
 }
 void VisitMemberPointerType(const MemberPointerType *T) {
-  dumpTypeAsChild(T->getClass());
-  dumpTypeAsChild(T->getPointeeType());
+  Visit(T->getClass());
+  Visit(T->getPointeeType());
 }
 void VisitArrayType(const ArrayType *T) {
-  dumpTypeAsChild(T->getElementType());
+  Visit(T->getElementType());
 }
 void VisitVariableArrayType(const VariableArrayType *T) {
   VisitArrayType(T);
-  dumpStmt(T->getSizeExpr());
+  Visit(T->getSizeExpr());
 }
 void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
-  dumpTypeAsChild(T->getElementType());
-  dumpStmt(T->getSizeExpr());
+  Visit(T->getElementType());
+  Visit(T->getSizeExpr());
 }
 void VisitDependentSizedExtVectorType(
 const DependentSizedExtVectorType *T) {
-  dumpTypeAsChild(T->getElementType());
-  dumpStmt(T->getSizeExpr());
+  Visit(T->getElementType());
+  Visit(T->getSizeExpr());
 }
 void VisitVectorType(const VectorType *T) {
-  dumpTypeAsChild(T->getElementType());
+  Visit(T->getElementType());
 }
 void VisitFunctionType(const FunctionType *T) {
-  dumpTypeAsChild(T->getReturnType());
+  Visit(T->getReturnType());
 }
 void VisitFunctionProtoType(const FunctionProtoType *T) {
   VisitFunctionType(T);
   for (const QualType &PT : T->getParamTypes())
-dumpTypeAsChild(PT);
+Visit(PT);
 }
 void VisitTypeOfExprType(const TypeOfExprType *T) {
-  dumpStmt(T->getUnderlyingExpr());
+  Visit(T->getUnderlyingExpr());
 }
 void VisitDecltypeType(const DecltypeType *T) {
-  dumpStmt(T->getUnderlyingExpr());
+  Visit(T->getUnderlyingExpr());
 }
 void VisitUnaryT

r352661 - [ASTDump] Re-arrange method declarations to group Visit together

2019-01-30 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Jan 30 12:03:47 2019
New Revision: 352661

URL: http://llvm.org/viewvc/llvm-project?rev=352661&view=rev
Log:
[ASTDump] Re-arrange method declarations to group Visit together

This will make follow-up commits easier to review.

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=352661&r1=352660&r2=352661&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Wed Jan 30 12:03:47 2019
@@ -76,24 +76,26 @@ namespace  {
 
 void Visit(const Decl *D);
 void Visit(const Stmt *S, StringRef Label = {});
-
-// Utilities
 void Visit(QualType T);
 void Visit(const Type *T);
-void dumpDeclContext(const DeclContext *DC);
-void dumpLookups(const DeclContext *DC, bool DumpDecls);
 void Visit(const Attr *A);
+void Visit(const CXXCtorInitializer *Init);
+void Visit(const TemplateArgument &A, SourceRange R = SourceRange(),
+   const Decl *From = nullptr, const char *Label = nullptr);
+void Visit(const BlockDecl::Capture &C);
+void Visit(const OMPClause *C);
+void Visit(const GenericSelectionExpr::ConstAssociation &A);
+void Visit(const Comment *C, const FullComment *FC);
 
 // C++ Utilities
-void Visit(const CXXCtorInitializer *Init);
+void dumpDeclContext(const DeclContext *DC);
+void dumpLookups(const DeclContext *DC, bool DumpDecls);
 void dumpTemplateParameters(const TemplateParameterList *TPL);
 void dumpTemplateArgumentListInfo(const TemplateArgumentListInfo &TALI);
 void dumpTemplateArgumentLoc(const TemplateArgumentLoc &A,
  const Decl *From = nullptr,
  const char *Label = nullptr);
 void dumpTemplateArgumentList(const TemplateArgumentList &TAL);
-void Visit(const TemplateArgument &A, SourceRange R = SourceRange(),
-   const Decl *From = nullptr, const char *Label = nullptr);
 template 
 void dumpTemplateDeclSpecialization(const SpecializationDecl *D,
 bool DumpExplicitInst,
@@ -242,7 +244,6 @@ namespace  {
 void VisitObjCCategoryDecl(const ObjCCategoryDecl *D);
 void VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D);
 void VisitObjCImplementationDecl(const ObjCImplementationDecl *D);
-void Visit(const BlockDecl::Capture &C);
 void VisitBlockDecl(const BlockDecl *D);
 
 // Stmts.
@@ -252,14 +253,12 @@ namespace  {
 void VisitCapturedStmt(const CapturedStmt *Node);
 
 // OpenMP
-void Visit(const OMPClause *C);
 void VisitOMPExecutableDirective(const OMPExecutableDirective *Node);
 
 // Exprs
 void VisitInitListExpr(const InitListExpr *ILE);
 void VisitBlockExpr(const BlockExpr *Node);
 void VisitOpaqueValueExpr(const OpaqueValueExpr *Node);
-void Visit(const GenericSelectionExpr::ConstAssociation &A);
 void VisitGenericSelectionExpr(const GenericSelectionExpr *E);
 
 // C++
@@ -271,9 +270,6 @@ namespace  {
 // ObjC
 void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node);
 
-// Comments.
-void Visit(const Comment *C, const FullComment *FC);
-
 void VisitExpressionTemplateArgument(const TemplateArgument &TA) {
   Visit(TA.getAsExpr());
 }
@@ -291,6 +287,49 @@ namespace  {
 //  Utilities
 
//===--===//
 
+void ASTDumper::Visit(const Decl *D) {
+  NodeDumper.AddChild([=] {
+NodeDumper.Visit(D);
+if (!D)
+  return;
+
+ConstDeclVisitor::Visit(D);
+
+for (const auto &A : D->attrs())
+  Visit(A);
+
+if (const FullComment *Comment =
+D->getASTContext().getLocalCommentForDeclUncached(D))
+  Visit(Comment, Comment);
+
+// Decls within functions are visited by the body.
+if (!isa(*D) && !isa(*D)) {
+  if (const auto *DC = dyn_cast(D))
+dumpDeclContext(DC);
+}
+  });
+}
+
+void ASTDumper::Visit(const Stmt *S, StringRef Label) {
+  NodeDumper.AddChild(Label, [=] {
+NodeDumper.Visit(S);
+
+if (!S) {
+  return;
+}
+
+ConstStmtVisitor::Visit(S);
+
+// Some statements have custom mechanisms for dumping their children.
+if (isa(S) || isa(S)) {
+  return;
+}
+
+for (const Stmt *SubStmt : S->children())
+  Visit(SubStmt);
+  });
+}
+
 void ASTDumper::Visit(QualType T) {
   SplitQualType SQT = T.split();
   if (!SQT.Quals.hasQualifiers())
@@ -316,6 +355,66 @@ void ASTDumper::Visit(const Type *T) {
   });
 }
 
+void ASTDumper::Visit(const Attr *A) {
+  NodeDumper.AddChild([=] {
+NodeDumper.Visit(A);
+ConstAttrVisitor::Visit(A);
+  });
+}
+
+void ASTDumper::Visit(const CXXCtorInitializer *Init) {
+  NodeDumper.AddChild([=] {
+NodeDumper.Visit(Init);
+Visit(Init->getInit());
+ 

r352663 - [ASTDump] Make method definition order matches declaration order

2019-01-30 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Jan 30 12:06:52 2019
New Revision: 352663

URL: http://llvm.org/viewvc/llvm-project?rev=352663&view=rev
Log:
[ASTDump] Make method definition order matches declaration order

This will make follow-up changes easier to review.

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=352663&r1=352662&r2=352663&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Wed Jan 30 12:06:52 2019
@@ -96,12 +96,6 @@ namespace  {
  const Decl *From = nullptr,
  const char *Label = nullptr);
 void dumpTemplateArgumentList(const TemplateArgumentList &TAL);
-template 
-void dumpTemplateDeclSpecialization(const SpecializationDecl *D,
-bool DumpExplicitInst,
-bool DumpRefOnly);
-template 
-void dumpTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst);
 
 // Objective-C utilities.
 void dumpObjCTypeParamList(const ObjCTypeParamList *typeParams);
@@ -215,6 +209,13 @@ namespace  {
 void VisitOMPDeclareReductionDecl(const OMPDeclareReductionDecl *D);
 void VisitOMPCapturedExprDecl(const OMPCapturedExprDecl *D);
 
+template 
+void dumpTemplateDeclSpecialization(const SpecializationDecl *D,
+bool DumpExplicitInst,
+bool DumpRefOnly);
+template 
+void dumpTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst);
+
 // C++ Decls
 void VisitTypeAliasDecl(const TypeAliasDecl *D);
 void VisitTypeAliasTemplateDecl(const TypeAliasTemplateDecl *D);
@@ -227,8 +228,8 @@ namespace  {
 const ClassTemplatePartialSpecializationDecl *D);
 void VisitClassScopeFunctionSpecializationDecl(
 const ClassScopeFunctionSpecializationDecl *D);
-void VisitBuiltinTemplateDecl(const BuiltinTemplateDecl *D);
 void VisitVarTemplateDecl(const VarTemplateDecl *D);
+void VisitBuiltinTemplateDecl(const BuiltinTemplateDecl *D);
 void VisitVarTemplateSpecializationDecl(
 const VarTemplateSpecializationDecl *D);
 void VisitVarTemplatePartialSpecializationDecl(
@@ -605,20 +606,6 @@ void ASTDumper::VisitOMPCapturedExprDecl
 // C++ Declarations
 
//===--===//
 
-void ASTDumper::VisitTypeAliasDecl(const TypeAliasDecl *D) {
-  Visit(D->getUnderlyingType());
-}
-
-void ASTDumper::VisitTypeAliasTemplateDecl(const TypeAliasTemplateDecl *D) {
-  dumpTemplateParameters(D->getTemplateParameters());
-  Visit(D->getTemplatedDecl());
-}
-
-void ASTDumper::VisitStaticAssertDecl(const StaticAssertDecl *D) {
-  Visit(D->getAssertExpr());
-  Visit(D->getMessage());
-}
-
 template 
 void ASTDumper::dumpTemplateDeclSpecialization(const SpecializationDecl *D,
bool DumpExplicitInst,
@@ -672,6 +659,20 @@ void ASTDumper::dumpTemplateDecl(const T
!D->isCanonicalDecl());
 }
 
+void ASTDumper::VisitTypeAliasDecl(const TypeAliasDecl *D) {
+  Visit(D->getUnderlyingType());
+}
+
+void ASTDumper::VisitTypeAliasTemplateDecl(const TypeAliasTemplateDecl *D) {
+  dumpTemplateParameters(D->getTemplateParameters());
+  Visit(D->getTemplatedDecl());
+}
+
+void ASTDumper::VisitStaticAssertDecl(const StaticAssertDecl *D) {
+  Visit(D->getAssertExpr());
+  Visit(D->getMessage());
+}
+
 void ASTDumper::VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
   // FIXME: We don't add a declaration of a function template specialization
   // to its context when it's explicitly instantiated, so dump explicit


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


r352676 - [ASTDump] Inline traverse methods into class

2019-01-30 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Jan 30 13:48:32 2019
New Revision: 352676

URL: http://llvm.org/viewvc/llvm-project?rev=352676&view=rev
Log:
[ASTDump] Inline traverse methods into class

This API will be extracted into a new template class.  This change will
make the follow-up commit easier to review.

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=352676&r1=352675&r2=352676&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Wed Jan 30 13:48:32 2019
@@ -74,42 +74,175 @@ namespace  {
 
 void setDeserialize(bool D) { Deserialize = D; }
 
-void Visit(const Decl *D);
-void Visit(const Stmt *S, StringRef Label = {});
-void Visit(QualType T);
-void Visit(const Type *T);
-void Visit(const Attr *A);
-void Visit(const CXXCtorInitializer *Init);
-void Visit(const TemplateArgument &A, SourceRange R = SourceRange(),
-   const Decl *From = nullptr, const char *Label = nullptr);
-void Visit(const BlockDecl::Capture &C);
-void Visit(const OMPClause *C);
-void Visit(const GenericSelectionExpr::ConstAssociation &A);
-void Visit(const Comment *C, const FullComment *FC);
+void Visit(const Decl *D) {
+  NodeDumper.AddChild([=] {
+NodeDumper.Visit(D);
+if (!D)
+  return;
+
+ConstDeclVisitor::Visit(D);
+
+for (const auto &A : D->attrs())
+  Visit(A);
+
+if (const FullComment *Comment =
+D->getASTContext().getLocalCommentForDeclUncached(D))
+  Visit(Comment, Comment);
+
+// Decls within functions are visited by the body.
+if (!isa(*D) && !isa(*D)) {
+  if (const auto *DC = dyn_cast(D))
+dumpDeclContext(DC);
+}
+  });
+}
+
+void Visit(const Stmt *S, StringRef Label = {}) {
+  NodeDumper.AddChild(Label, [=] {
+NodeDumper.Visit(S);
+
+if (!S) {
+  return;
+}
+
+ConstStmtVisitor::Visit(S);
+
+// Some statements have custom mechanisms for dumping their children.
+if (isa(S) || isa(S)) {
+  return;
+}
+
+for (const Stmt *SubStmt : S->children())
+  Visit(SubStmt);
+  });
+}
+
+void Visit(QualType T) {
+  SplitQualType SQT = T.split();
+  if (!SQT.Quals.hasQualifiers())
+return Visit(SQT.Ty);
+
+  NodeDumper.AddChild([=] {
+NodeDumper.Visit(T);
+Visit(T.split().Ty);
+  });
+}
+
+void Visit(const Type *T) {
+  NodeDumper.AddChild([=] {
+NodeDumper.Visit(T);
+if (!T)
+  return;
+TypeVisitor::Visit(T);
+
+QualType SingleStepDesugar =
+T->getLocallyUnqualifiedSingleStepDesugaredType();
+if (SingleStepDesugar != QualType(T, 0))
+  Visit(SingleStepDesugar);
+  });
+}
+
+void Visit(const Attr *A) {
+  NodeDumper.AddChild([=] {
+NodeDumper.Visit(A);
+ConstAttrVisitor::Visit(A);
+  });
+}
+
+void Visit(const CXXCtorInitializer *Init) {
+  NodeDumper.AddChild([=] {
+NodeDumper.Visit(Init);
+Visit(Init->getInit());
+  });
+}
+
+void Visit(const TemplateArgument &A, SourceRange R = {},
+   const Decl *From = nullptr, const char *Label = nullptr) {
+  NodeDumper.AddChild([=] {
+NodeDumper.Visit(A, R, From, Label);
+ConstTemplateArgumentVisitor::Visit(A);
+  });
+}
+
+void Visit(const BlockDecl::Capture &C) {
+  NodeDumper.AddChild([=] {
+NodeDumper.Visit(C);
+if (C.hasCopyExpr())
+  Visit(C.getCopyExpr());
+  });
+}
+
+void Visit(const OMPClause *C) {
+  NodeDumper.AddChild([=] {
+NodeDumper.Visit(C);
+for (const auto *S : C->children())
+  Visit(S);
+  });
+}
+
+void Visit(const GenericSelectionExpr::ConstAssociation &A) {
+  NodeDumper.AddChild([=] {
+NodeDumper.Visit(A);
+if (const TypeSourceInfo *TSI = A.getTypeSourceInfo())
+  Visit(TSI->getType());
+Visit(A.getAssociationExpr());
+  });
+}
+
+void Visit(const Comment *C, const FullComment *FC) {
+  NodeDumper.AddChild([=] {
+NodeDumper.Visit(C, FC);
+if (!C) {
+  return;
+}
+ConstCommentVisitor::visit(C, 
FC);
+for (Comment::child_iterator I = C->child_begin(), E = C->child_end();
+ I != E; ++I)
+  Visit(*I, FC);
+  });
+}
 
-// C++ Utilities
 void dumpDeclContext(const DeclContext *DC);
 void dumpLookups(const DeclContext *DC, bool DumpDecls);
-void dumpTemplateParameters(const TemplateParameterList *TPL);
-void dumpTemplateArgumentListInfo(const TemplateArgumentListInfo &TALI);
+
+void dumpTemp

Re: Dumping AST information to other formats

2018-11-27 Thread Stephen Kelly via cfe-commits

On 26/11/2018 19:20, Aaron Ballman via cfe-commits wrote:

Once upon a time, there was -ast-print-xml. This -cc1 option was
dropped because it was frequently out of sync with the AST data. It is
right to ask: why would JSON, etc be any different? This is still an
open question, but a goal of this implementation will be to ensure
it's easier to maintain as the AST evolves. However, this feature is
intended to output a safe subset of AST information, so I don't think
this feature will require any more burden to support than -ast-dump
already requires (which is extremely limited). 



I wanted to see if there were concerns or implementation ideas the
community wanted to share before beginning the implementation phase of
this feature.


Hi Aaron,

As you know, I've already done some work in this area.

I split the ASTDumper.cpp into multiple classes so that the traversal of 
the AST is separate to the printing of it to the output stream. You can 
see the proof of concept here:


 https://github.com/steveire/clang/commits/extract-AST-dumping

though it is not ready for a real review. I just extracted it to a 
branch for the purpose of this mailing list reply.


In my branch there are two implementations of outputter - one detailed 
and one 'simplified' AST. You can see the difference here:


 http://ec2-52-14-16-249.us-east-2.compute.amazonaws.com:10240/z/JuAvs8

Because the traversal is in a separate class, it should be possible to 
port ASTMatchFinder.cpp to use it, which will eliminate the class of 
bugs that arise due to ASTMatchFinder.cpp currently using RAV. Here is 
one such bug:


 https://bugs.llvm.org/show_bug.cgi?id=37629

but there are others for example relating to getting to a 
CXXConstructorDecl from a CXXCtorInitializer, so it is a class of bug 
rather than a single bug.


Because the traversal is in a separate class, you should be able to also 
implement it for different output formats without a significant 
maintenance burden.


Using this approach, the output formats will not get out of sync and 
fall to the same fate as the XML output feature.


Let me know if you're interested.

Thanks,

Stephen.


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


Re: Dumping AST information to other formats

2018-11-28 Thread Stephen Kelly via cfe-commits

On 27/11/2018 09:49, Stephen Kelly via cfe-commits wrote:

On 26/11/2018 19:20, Aaron Ballman via cfe-commits wrote:

Once upon a time, there was -ast-print-xml. This -cc1 option was
dropped because it was frequently out of sync with the AST data. It is
right to ask: why would JSON, etc be any different? This is still an
open question, but a goal of this implementation will be to ensure
it's easier to maintain as the AST evolves. However, this feature is
intended to output a safe subset of AST information, so I don't think
this feature will require any more burden to support than -ast-dump
already requires (which is extremely limited). 



I wanted to see if there were concerns or implementation ideas the
community wanted to share before beginning the implementation phase of
this feature.


Hi Aaron,

As you know, I've already done some work in this area.

I split the ASTDumper.cpp into multiple classes so that the traversal of 
the AST is separate to the printing of it to the output stream. You can 
see the proof of concept here:


  https://github.com/steveire/clang/commits/extract-AST-dumping



For those following along at home, I implemented a Proof of Concept JSON 
dumper on that github branch in order to show the benefit of splitting 
the traversal logic which is central to my design.


You can play with it here:

 http://ec2-52-14-16-249.us-east-2.compute.amazonaws.com:10240/z/JGBcRH

 http://ec2-52-14-16-249.us-east-2.compute.amazonaws.com:10240/z/fIJjV1

This shows how simple it would be to maintain alternative output formats 
such as JSON and CBOR, which may interest clangd folks and others who 
want a binary AST dump.


Thanks,

Steve.

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


r347899 - NFC: Constify ShowColors

2018-11-29 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Nov 29 11:30:08 2018
New Revision: 347899

URL: http://llvm.org/viewvc/llvm-project?rev=347899&view=rev
Log:
NFC: Constify ShowColors

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=347899&r1=347898&r2=347899&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Thu Nov 29 11:30:08 2018
@@ -126,7 +126,7 @@ namespace  {
 /// The \c FullComment parent of the comment being dumped.
 const FullComment *FC = nullptr;
 
-bool ShowColors;
+const bool ShowColors;
 
 /// Dump a child of the current node.
 template void dumpChild(Fn doDumpChild) {


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


r347900 - NFC: Move ColorScope to global scope

2018-11-29 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Nov 29 11:30:37 2018
New Revision: 347900

URL: http://llvm.org/viewvc/llvm-project?rev=347900&view=rev
Log:
NFC: Move ColorScope to global scope

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=347900&r1=347899&r2=347900&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Thu Nov 29 11:30:37 2018
@@ -92,6 +92,22 @@ namespace  {
   // Indents ( `, -. | )
   static const TerminalColor IndentColor = { raw_ostream::BLUE, false };
 
+  class ColorScope {
+raw_ostream &OS;
+const bool ShowColors;
+
+  public:
+ColorScope(raw_ostream &OS, bool ShowColors, TerminalColor Color)
+: OS(OS), ShowColors(ShowColors) {
+  if (ShowColors)
+OS.changeColor(Color.Color, Color.Bold);
+}
+~ColorScope() {
+  if (ShowColors)
+OS.resetColor();
+}
+  };
+
   class ASTDumper
   : public ConstDeclVisitor, public ConstStmtVisitor,
 public ConstCommentVisitor, public TypeVisitor {
@@ -161,7 +177,7 @@ namespace  {
 // Note that the first level gets no prefix.
 {
   OS << '\n';
-  ColorScope Color(*this, IndentColor);
+  ColorScope Color(OS, ShowColors, IndentColor);
   OS << Prefix << (isLastChild ? '`' : '|') << '-';
   this->Prefix.push_back(isLastChild ? ' ' : '|');
   this->Prefix.push_back(' ');
@@ -193,20 +209,6 @@ namespace  {
   FirstChild = false;
 }
 
-class ColorScope {
-  ASTDumper &Dumper;
-public:
-  ColorScope(ASTDumper &Dumper, TerminalColor Color)
-: Dumper(Dumper) {
-if (Dumper.ShowColors)
-  Dumper.OS.changeColor(Color.Color, Color.Bold);
-  }
-  ~ColorScope() {
-if (Dumper.ShowColors)
-  Dumper.OS.resetColor();
-  }
-};
-
   public:
 ASTDumper(raw_ostream &OS, const CommandTraits *Traits,
   const SourceManager *SM)
@@ -607,7 +609,7 @@ namespace  {
 
//===--===//
 
 void ASTDumper::dumpPointer(const void *Ptr) {
-  ColorScope Color(*this, AddressColor);
+  ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;
 }
 
@@ -615,7 +617,7 @@ void ASTDumper::dumpLocation(SourceLocat
   if (!SM)
 return;
 
-  ColorScope Color(*this, LocationColor);
+  ColorScope Color(OS, ShowColors, LocationColor);
   SourceLocation SpellingLoc = SM->getSpellingLoc(Loc);
 
   // The general format we print out is filename:line:col, but we drop pieces
@@ -659,7 +661,7 @@ void ASTDumper::dumpSourceRange(SourceRa
 }
 
 void ASTDumper::dumpBareType(QualType T, bool Desugar) {
-  ColorScope Color(*this, TypeColor);
+  ColorScope Color(OS, ShowColors, TypeColor);
 
   SplitQualType T_split = T.split();
   OS << "'" << QualType::getAsString(T_split, PrintPolicy) << "'";
@@ -695,13 +697,13 @@ void ASTDumper::dumpTypeAsChild(QualType
 void ASTDumper::dumpTypeAsChild(const Type *T) {
   dumpChild([=] {
 if (!T) {
-  ColorScope Color(*this, NullColor);
+  ColorScope Color(OS, ShowColors, NullColor);
   OS << "<<>>";
   return;
 }
 if (const LocInfoType *LIT = llvm::dyn_cast(T)) {
   {
-ColorScope Color(*this, TypeColor);
+ColorScope Color(OS, ShowColors, TypeColor);
 OS << "LocInfo Type";
   }
   dumpPointer(T);
@@ -710,7 +712,7 @@ void ASTDumper::dumpTypeAsChild(const Ty
 }
 
 {
-  ColorScope Color(*this, TypeColor);
+  ColorScope Color(OS, ShowColors, TypeColor);
   OS << T->getTypeClassName() << "Type";
 }
 dumpPointer(T);
@@ -741,19 +743,19 @@ void ASTDumper::dumpTypeAsChild(const Ty
 
 void ASTDumper::dumpBareDeclRef(const Decl *D) {
   if (!D) {
-ColorScope Color(*this, NullColor);
+ColorScope Color(OS, ShowColors, NullColor);
 OS << "<<>>";
 return;
   }
 
   {
-ColorScope Color(*this, DeclKindNameColor);
+ColorScope Color(OS, ShowColors, DeclKindNameColor);
 OS << D->getDeclKindName();
   }
   dumpPointer(D);
 
   if (const NamedDecl *ND = dyn_cast(D)) {
-ColorScope Color(*this, DeclNameColor);
+ColorScope Color(OS, ShowColors, DeclNameColor);
 OS << " '" << ND->getDeclName() << '\'';
   }
 
@@ -774,7 +776,7 @@ void ASTDumper::dumpDeclRef(const Decl *
 
 void ASTDumper::dumpName(const NamedDecl *ND) {
   if (ND->getDeclName()) {
-ColorScope Color(*this, DeclNameColor);
+ColorScope Color(OS, ShowColors, DeclNameColor);
 OS << ' ' << ND->getNameAsString();
   }
 }
@@ -796,8 +798,8 @@ void ASTDumper::dumpDeclContext(const De
 dumpDecl(D);
 
   if (DC->hasExternalLexicalStorage()) {
-dumpChild([=]{
-  ColorScope Color(*this, UndeserializedColor);
+dumpChild([=] {
+  ColorScope Color(OS, ShowColors, UndeserializedColo

r347901 - NFC: Fix case of CommentVisitor::Visit methods

2018-11-29 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Nov 29 11:31:32 2018
New Revision: 347901

URL: http://llvm.org/viewvc/llvm-project?rev=347901&view=rev
Log:
NFC: Fix case of CommentVisitor::Visit methods

This difference is very visible because it is used with other Visitor
classes together.

Modified:
cfe/trunk/include/clang/AST/CommentVisitor.h
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/include/clang/AST/CommentVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentVisitor.h?rev=347901&r1=347900&r2=347901&view=diff
==
--- cfe/trunk/include/clang/AST/CommentVisitor.h (original)
+++ cfe/trunk/include/clang/AST/CommentVisitor.h Thu Nov 29 11:31:32 2018
@@ -23,10 +23,10 @@ template class Ptr,
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr::type
-#define DISPATCH(NAME, CLASS) \
- return static_cast(this)->visit ## 
NAME(static_cast(C))
+#define DISPATCH(NAME, CLASS)  
\
+  return static_cast(this)->Visit##NAME(static_cast(C))
 
-  RetTy visit(PTR(Comment) C) {
+  RetTy Visit(PTR(Comment) C) {
 if (!C)
   return RetTy();
 
@@ -44,13 +44,13 @@ public:
   // If the derived class does not implement a certain Visit* method, fall back
   // on Visit* method for the superclass.
 #define ABSTRACT_COMMENT(COMMENT) COMMENT
-#define COMMENT(CLASS, PARENT) \
-  RetTy visit ## CLASS(PTR(CLASS) C) { DISPATCH(PARENT, PARENT); }
+#define COMMENT(CLASS, PARENT) 
\
+  RetTy Visit##CLASS(PTR(CLASS) C) { DISPATCH(PARENT, PARENT); }
 #include "clang/AST/CommentNodes.inc"
 #undef ABSTRACT_COMMENT
 #undef COMMENT
 
-  RetTy visitComment(PTR(Comment) C) { return RetTy(); }
+  RetTy VisitComment(PTR(Comment) C) { return RetTy(); }
 
 #undef PTR
 #undef DISPATCH

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=347901&r1=347900&r2=347901&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Thu Nov 29 11:31:32 2018
@@ -589,18 +589,18 @@ namespace  {
 void dumpComment(const Comment *C);
 
 // Inline comments.
-void visitTextComment(const TextComment *C);
-void visitInlineCommandComment(const InlineCommandComment *C);
-void visitHTMLStartTagComment(const HTMLStartTagComment *C);
-void visitHTMLEndTagComment(const HTMLEndTagComment *C);
+void VisitTextComment(const TextComment *C);
+void VisitInlineCommandComment(const InlineCommandComment *C);
+void VisitHTMLStartTagComment(const HTMLStartTagComment *C);
+void VisitHTMLEndTagComment(const HTMLEndTagComment *C);
 
 // Block comments.
-void visitBlockCommandComment(const BlockCommandComment *C);
-void visitParamCommandComment(const ParamCommandComment *C);
-void visitTParamCommandComment(const TParamCommandComment *C);
-void visitVerbatimBlockComment(const VerbatimBlockComment *C);
-void visitVerbatimBlockLineComment(const VerbatimBlockLineComment *C);
-void visitVerbatimLineComment(const VerbatimLineComment *C);
+void VisitBlockCommandComment(const BlockCommandComment *C);
+void VisitParamCommandComment(const ParamCommandComment *C);
+void VisitTParamCommandComment(const TParamCommandComment *C);
+void VisitVerbatimBlockComment(const VerbatimBlockComment *C);
+void VisitVerbatimBlockLineComment(const VerbatimBlockLineComment *C);
+void VisitVerbatimLineComment(const VerbatimLineComment *C);
   };
 }
 
@@ -2670,18 +2670,18 @@ void ASTDumper::dumpComment(const Commen
 }
 dumpPointer(C);
 dumpSourceRange(C->getSourceRange());
-ConstCommentVisitor::visit(C);
+ConstCommentVisitor::Visit(C);
 for (Comment::child_iterator I = C->child_begin(), E = C->child_end();
  I != E; ++I)
   dumpComment(*I);
   });
 }
 
-void ASTDumper::visitTextComment(const TextComment *C) {
+void ASTDumper::VisitTextComment(const TextComment *C) {
   OS << " Text=\"" << C->getText() << "\"";
 }
 
-void ASTDumper::visitInlineCommandComment(const InlineCommandComment *C) {
+void ASTDumper::VisitInlineCommandComment(const InlineCommandComment *C) {
   OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
   switch (C->getRenderKind()) {
   case InlineCommandComment::RenderNormal:
@@ -2702,7 +2702,7 @@ void ASTDumper::visitInlineCommandCommen
 OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
 }
 
-void ASTDumper::visitHTMLStartTagComment(const HTMLStartTagComment *C) {
+void ASTDumper::VisitHTMLStartTagComment(const HTMLStartTagComment *C) {
   OS << " Name=\"" << C->getTagName() << "\"";
   if (C->getNumAttrs() != 0) {
 OS << " Attrs: ";
@@ -2715,17 +2715,17 @@ void ASTDumper::visitHTMLStartTagComment
 OS << " SelfClosing";
 }
 
-void ASTDumper::visitHTM

r347905 - Revert "NFC: Fix case of CommentVisitor::Visit methods"

2018-11-29 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Nov 29 11:50:10 2018
New Revision: 347905

URL: http://llvm.org/viewvc/llvm-project?rev=347905&view=rev
Log:
Revert "NFC: Fix case of CommentVisitor::Visit methods"

This reverts commit 0859c80137ac5fb3c86e7802cb8c5ef56f921cce.

Modified:
cfe/trunk/include/clang/AST/CommentVisitor.h
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/include/clang/AST/CommentVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentVisitor.h?rev=347905&r1=347904&r2=347905&view=diff
==
--- cfe/trunk/include/clang/AST/CommentVisitor.h (original)
+++ cfe/trunk/include/clang/AST/CommentVisitor.h Thu Nov 29 11:50:10 2018
@@ -23,10 +23,10 @@ template class Ptr,
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr::type
-#define DISPATCH(NAME, CLASS)  
\
-  return static_cast(this)->Visit##NAME(static_cast(C))
+#define DISPATCH(NAME, CLASS) \
+ return static_cast(this)->visit ## 
NAME(static_cast(C))
 
-  RetTy Visit(PTR(Comment) C) {
+  RetTy visit(PTR(Comment) C) {
 if (!C)
   return RetTy();
 
@@ -44,13 +44,13 @@ public:
   // If the derived class does not implement a certain Visit* method, fall back
   // on Visit* method for the superclass.
 #define ABSTRACT_COMMENT(COMMENT) COMMENT
-#define COMMENT(CLASS, PARENT) 
\
-  RetTy Visit##CLASS(PTR(CLASS) C) { DISPATCH(PARENT, PARENT); }
+#define COMMENT(CLASS, PARENT) \
+  RetTy visit ## CLASS(PTR(CLASS) C) { DISPATCH(PARENT, PARENT); }
 #include "clang/AST/CommentNodes.inc"
 #undef ABSTRACT_COMMENT
 #undef COMMENT
 
-  RetTy VisitComment(PTR(Comment) C) { return RetTy(); }
+  RetTy visitComment(PTR(Comment) C) { return RetTy(); }
 
 #undef PTR
 #undef DISPATCH

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=347905&r1=347904&r2=347905&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Thu Nov 29 11:50:10 2018
@@ -589,18 +589,18 @@ namespace  {
 void dumpComment(const Comment *C);
 
 // Inline comments.
-void VisitTextComment(const TextComment *C);
-void VisitInlineCommandComment(const InlineCommandComment *C);
-void VisitHTMLStartTagComment(const HTMLStartTagComment *C);
-void VisitHTMLEndTagComment(const HTMLEndTagComment *C);
+void visitTextComment(const TextComment *C);
+void visitInlineCommandComment(const InlineCommandComment *C);
+void visitHTMLStartTagComment(const HTMLStartTagComment *C);
+void visitHTMLEndTagComment(const HTMLEndTagComment *C);
 
 // Block comments.
-void VisitBlockCommandComment(const BlockCommandComment *C);
-void VisitParamCommandComment(const ParamCommandComment *C);
-void VisitTParamCommandComment(const TParamCommandComment *C);
-void VisitVerbatimBlockComment(const VerbatimBlockComment *C);
-void VisitVerbatimBlockLineComment(const VerbatimBlockLineComment *C);
-void VisitVerbatimLineComment(const VerbatimLineComment *C);
+void visitBlockCommandComment(const BlockCommandComment *C);
+void visitParamCommandComment(const ParamCommandComment *C);
+void visitTParamCommandComment(const TParamCommandComment *C);
+void visitVerbatimBlockComment(const VerbatimBlockComment *C);
+void visitVerbatimBlockLineComment(const VerbatimBlockLineComment *C);
+void visitVerbatimLineComment(const VerbatimLineComment *C);
   };
 }
 
@@ -2670,18 +2670,18 @@ void ASTDumper::dumpComment(const Commen
 }
 dumpPointer(C);
 dumpSourceRange(C->getSourceRange());
-ConstCommentVisitor::Visit(C);
+ConstCommentVisitor::visit(C);
 for (Comment::child_iterator I = C->child_begin(), E = C->child_end();
  I != E; ++I)
   dumpComment(*I);
   });
 }
 
-void ASTDumper::VisitTextComment(const TextComment *C) {
+void ASTDumper::visitTextComment(const TextComment *C) {
   OS << " Text=\"" << C->getText() << "\"";
 }
 
-void ASTDumper::VisitInlineCommandComment(const InlineCommandComment *C) {
+void ASTDumper::visitInlineCommandComment(const InlineCommandComment *C) {
   OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
   switch (C->getRenderKind()) {
   case InlineCommandComment::RenderNormal:
@@ -2702,7 +2702,7 @@ void ASTDumper::VisitInlineCommandCommen
 OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
 }
 
-void ASTDumper::VisitHTMLStartTagComment(const HTMLStartTagComment *C) {
+void ASTDumper::visitHTMLStartTagComment(const HTMLStartTagComment *C) {
   OS << " Name=\"" << C->getTagName() << "\"";
   if (C->getNumAttrs() != 0) {
 OS << " Attrs: ";
@@ -2715,17 +2715,17 @@ void ASTDumper::VisitHTMLStartTagComment
 OS << " SelfClosing";
 }
 
-void ASTDumper::VisitHTMLEndTagComment(co

r348093 - Add dump tests for ArrayInitLoopExpr and ArrayInitIndexExpr

2018-12-02 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sun Dec  2 08:36:23 2018
New Revision: 348093

URL: http://llvm.org/viewvc/llvm-project?rev=348093&view=rev
Log:
Add dump tests for ArrayInitLoopExpr and ArrayInitIndexExpr

Added:
cfe/trunk/test/AST/ast-dump-array.cpp

Added: cfe/trunk/test/AST/ast-dump-array.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-array.cpp?rev=348093&view=auto
==
--- cfe/trunk/test/AST/ast-dump-array.cpp (added)
+++ cfe/trunk/test/AST/ast-dump-array.cpp Sun Dec  2 08:36:23 2018
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck 
-strict-whitespace %s
+
+void testArrayInitExpr()
+{
+int a[10];
+auto l = [a]{
+};
+// CHECK: |-ArrayInitLoopExpr 0x{{[^ ]*}}  'int [10]'
+// CHECK: | `-ArrayInitIndexExpr 0x{{[^ ]*}} <> 'unsigned 
long'
+}


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


r348094 - Fix whitespace

2018-12-02 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sun Dec  2 08:42:34 2018
New Revision: 348094

URL: http://llvm.org/viewvc/llvm-project?rev=348094&view=rev
Log:
Fix whitespace

Modified:
cfe/trunk/test/AST/ast-dump-array.cpp

Modified: cfe/trunk/test/AST/ast-dump-array.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-array.cpp?rev=348094&r1=348093&r2=348094&view=diff
==
--- cfe/trunk/test/AST/ast-dump-array.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-array.cpp Sun Dec  2 08:42:34 2018
@@ -6,5 +6,5 @@ void testArrayInitExpr()
 auto l = [a]{
 };
 // CHECK: |-ArrayInitLoopExpr 0x{{[^ ]*}}  'int [10]'
-// CHECK: | `-ArrayInitIndexExpr 0x{{[^ ]*}} <> 'unsigned 
long'
+// CHECK: | `-ArrayInitIndexExpr 0x{{[^ ]*}} <> 
'unsigned long'
 }


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


r348101 - Replace FullComment member being visited with parameter

2018-12-02 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sun Dec  2 09:30:40 2018
New Revision: 348101

URL: http://llvm.org/viewvc/llvm-project?rev=348101&view=rev
Log:
Replace FullComment member being visited with parameter

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=348101&r1=348100&r2=348101&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Sun Dec  2 09:30:40 2018
@@ -109,8 +109,11 @@ namespace  {
   };
 
   class ASTDumper
-  : public ConstDeclVisitor, public ConstStmtVisitor,
-public ConstCommentVisitor, public TypeVisitor {
+  : public ConstDeclVisitor,
+public ConstStmtVisitor,
+public ConstCommentVisitor,
+public TypeVisitor {
+
 raw_ostream &OS;
 const CommandTraits *Traits;
 const SourceManager *SM;
@@ -139,9 +142,6 @@ namespace  {
 const char *LastLocFilename = "";
 unsigned LastLocLine = ~0U;
 
-/// The \c FullComment parent of the comment being dumped.
-const FullComment *FC = nullptr;
-
 const bool ShowColors;
 
 /// Dump a child of the current node.
@@ -161,8 +161,7 @@ namespace  {
 return;
   }
 
-  const FullComment *OrigFC = FC;
-  auto dumpWithIndent = [this, doDumpChild, OrigFC](bool isLastChild) {
+  auto dumpWithIndent = [this, doDumpChild](bool isLastChild) {
 // Print out the appropriate tree structure and work out the prefix for
 // children of this node. For instance:
 //
@@ -186,7 +185,6 @@ namespace  {
 FirstChild = true;
 unsigned Depth = Pending.size();
 
-FC = OrigFC;
 doDumpChild();
 
 // If any children are left, they're the last at their nesting level.
@@ -584,21 +582,30 @@ namespace  {
 
 // Comments.
 const char *getCommandName(unsigned CommandID);
-void dumpComment(const Comment *C);
+void dumpComment(const Comment *C, const FullComment *FC);
 
 // Inline comments.
-void visitTextComment(const TextComment *C);
-void visitInlineCommandComment(const InlineCommandComment *C);
-void visitHTMLStartTagComment(const HTMLStartTagComment *C);
-void visitHTMLEndTagComment(const HTMLEndTagComment *C);
+void visitTextComment(const TextComment *C, const FullComment *FC);
+void visitInlineCommandComment(const InlineCommandComment *C,
+   const FullComment *FC);
+void visitHTMLStartTagComment(const HTMLStartTagComment *C,
+  const FullComment *FC);
+void visitHTMLEndTagComment(const HTMLEndTagComment *C,
+const FullComment *FC);
 
 // Block comments.
-void visitBlockCommandComment(const BlockCommandComment *C);
-void visitParamCommandComment(const ParamCommandComment *C);
-void visitTParamCommandComment(const TParamCommandComment *C);
-void visitVerbatimBlockComment(const VerbatimBlockComment *C);
-void visitVerbatimBlockLineComment(const VerbatimBlockLineComment *C);
-void visitVerbatimLineComment(const VerbatimLineComment *C);
+void visitBlockCommandComment(const BlockCommandComment *C,
+  const FullComment *FC);
+void visitParamCommandComment(const ParamCommandComment *C,
+  const FullComment *FC);
+void visitTParamCommandComment(const TParamCommandComment *C,
+   const FullComment *FC);
+void visitVerbatimBlockComment(const VerbatimBlockComment *C,
+   const FullComment *FC);
+void visitVerbatimBlockLineComment(const VerbatimBlockLineComment *C,
+   const FullComment *FC);
+void visitVerbatimLineComment(const VerbatimLineComment *C,
+  const FullComment *FC);
   };
 }
 
@@ -2640,13 +2647,10 @@ const char *ASTDumper::getCommandName(un
 void ASTDumper::dumpFullComment(const FullComment *C) {
   if (!C)
 return;
-
-  FC = C;
-  dumpComment(C);
-  FC = nullptr;
+  dumpComment(C, C);
 }
 
-void ASTDumper::dumpComment(const Comment *C) {
+void ASTDumper::dumpComment(const Comment *C, const FullComment *FC) {
   dumpChild([=] {
 if (!C) {
   ColorScope Color(OS, ShowColors, NullColor);
@@ -2660,18 +2664,19 @@ void ASTDumper::dumpComment(const Commen
 }
 dumpPointer(C);
 dumpSourceRange(C->getSourceRange());
-ConstCommentVisitor::visit(C);
+ConstCommentVisitor::visit(C, FC);
 for (Comment::child_iterator I = C->child_begin(), E = C->child_end();
  I != E; ++I)
-  dumpComment(*I);
+  dumpComment(*I, FC);
   });
 }
 
-void ASTDumper::visitTextComment(const TextComment *C) {

r348099 - Remove unecessary methods

2018-12-02 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sun Dec  2 09:30:26 2018
New Revision: 348099

URL: http://llvm.org/viewvc/llvm-project?rev=348099&view=rev
Log:
Remove unecessary methods

The base class calls VisitExpr

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=348099&r1=348098&r2=348099&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Sun Dec  2 09:30:26 2018
@@ -537,8 +537,6 @@ namespace  {
 void VisitFloatingLiteral(const FloatingLiteral *Node);
 void VisitStringLiteral(const StringLiteral *Str);
 void VisitInitListExpr(const InitListExpr *ILE);
-void VisitArrayInitLoopExpr(const ArrayInitLoopExpr *ILE);
-void VisitArrayInitIndexExpr(const ArrayInitIndexExpr *ILE);
 void VisitUnaryOperator(const UnaryOperator *Node);
 void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Node);
 void VisitMemberExpr(const MemberExpr *Node);
@@ -2285,14 +2283,6 @@ void ASTDumper::VisitInitListExpr(const
   }
 }
 
-void ASTDumper::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E) {
-  VisitExpr(E);
-}
-
-void ASTDumper::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E) {
-  VisitExpr(E);
-}
-
 void ASTDumper::VisitUnaryOperator(const UnaryOperator *Node) {
   VisitExpr(Node);
   OS << " " << (Node->isPostfix() ? "postfix" : "prefix")


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


r348100 - Extend the CommentVisitor with parameter types

2018-12-02 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sun Dec  2 09:30:34 2018
New Revision: 348100

URL: http://llvm.org/viewvc/llvm-project?rev=348100&view=rev
Log:
Extend the CommentVisitor with parameter types

Summary:
This has precedent in the StmtVisitor.  This change will make it
possible to clean up the comment handling in ASTDumper.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/CommentVisitor.h

Modified: cfe/trunk/include/clang/AST/CommentVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentVisitor.h?rev=348100&r1=348099&r2=348100&view=diff
==
--- cfe/trunk/include/clang/AST/CommentVisitor.h (original)
+++ cfe/trunk/include/clang/AST/CommentVisitor.h Sun Dec  2 09:30:34 2018
@@ -19,14 +19,16 @@ namespace comments {
 template  struct make_ptr { using type = T *; };
 template  struct make_const_ptr { using type = const T *; };
 
-template class Ptr, typename ImplClass, typename 
RetTy=void>
+template  class Ptr, typename ImplClass,
+  typename RetTy = void, class... ParamTys>
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr::type
-#define DISPATCH(NAME, CLASS) \
- return static_cast(this)->visit ## 
NAME(static_cast(C))
+#define DISPATCH(NAME, CLASS)  
\
+  return static_cast(this)->visit##NAME(  
\
+  static_cast(C), std::forward(P)...)
 
-  RetTy visit(PTR(Comment) C) {
+  RetTy visit(PTR(Comment) C, ParamTys... P) {
 if (!C)
   return RetTy();
 
@@ -44,25 +46,26 @@ public:
   // If the derived class does not implement a certain Visit* method, fall back
   // on Visit* method for the superclass.
 #define ABSTRACT_COMMENT(COMMENT) COMMENT
-#define COMMENT(CLASS, PARENT) \
-  RetTy visit ## CLASS(PTR(CLASS) C) { DISPATCH(PARENT, PARENT); }
+#define COMMENT(CLASS, PARENT) 
\
+  RetTy visit##CLASS(PTR(CLASS) C, ParamTys... P) { DISPATCH(PARENT, PARENT); }
 #include "clang/AST/CommentNodes.inc"
 #undef ABSTRACT_COMMENT
 #undef COMMENT
 
-  RetTy visitComment(PTR(Comment) C) { return RetTy(); }
+  RetTy visitComment(PTR(Comment) C, ParamTys... P) { return RetTy(); }
 
 #undef PTR
 #undef DISPATCH
 };
 
-template
-class CommentVisitor :
-public CommentVisitorBase {};
-
-template
-class ConstCommentVisitor :
-public CommentVisitorBase {};
+template 
+class CommentVisitor
+: public CommentVisitorBase {};
+
+template 
+class ConstCommentVisitor
+: public CommentVisitorBase 
{
+};
 
 } // namespace comments
 } // namespace clang


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


r348189 - NFC: Simplify dumpStmt child handling

2018-12-03 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Mon Dec  3 13:05:52 2018
New Revision: 348189

URL: http://llvm.org/viewvc/llvm-project?rev=348189&view=rev
Log:
NFC: Simplify dumpStmt child handling

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=348189&r1=348188&r2=348189&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Mon Dec  3 13:05:52 2018
@@ -1989,18 +1989,13 @@ void ASTDumper::dumpStmt(const Stmt *S)
   return;
 }
 
+ConstStmtVisitor::Visit(S);
+
 // Some statements have custom mechanisms for dumping their children.
-if (const DeclStmt *DS = dyn_cast(S)) {
-  VisitDeclStmt(DS);
-  return;
-}
-if (const GenericSelectionExpr *GSE = dyn_cast(S)) {
-  VisitGenericSelectionExpr(GSE);
+if (isa(S) || isa(S)) {
   return;
 }
 
-ConstStmtVisitor::Visit(S);
-
 for (const Stmt *SubStmt : S->children())
   dumpStmt(SubStmt);
   });


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


r348241 - Extend test for DependentSizedArrayType

2018-12-04 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Dec  4 01:53:36 2018
New Revision: 348241

URL: http://llvm.org/viewvc/llvm-project?rev=348241&view=rev
Log:
Extend test for DependentSizedArrayType

Use a using declaration to force the type to appear in the -ast-dump
output.

Modified:
cfe/trunk/test/AST/ast-dump-array.cpp

Modified: cfe/trunk/test/AST/ast-dump-array.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-array.cpp?rev=348241&r1=348240&r2=348241&view=diff
==
--- cfe/trunk/test/AST/ast-dump-array.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-array.cpp Tue Dec  4 01:53:36 2018
@@ -8,3 +8,12 @@ void testArrayInitExpr()
 // CHECK: |-ArrayInitLoopExpr 0x{{[^ ]*}}  'int [10]'
 // CHECK: | `-ArrayInitIndexExpr 0x{{[^ ]*}} <> 
'unsigned long'
 }
+
+template
+class array {
+  T data[Size];
+
+  using array_T_size = T[Size];
+  // CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'T [Size]' dependent   

+};
+


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


r348408 - Add dump tests for inherited default template parameters

2018-12-05 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Dec  5 12:21:13 2018
New Revision: 348408

URL: http://llvm.org/viewvc/llvm-project?rev=348408&view=rev
Log:
Add dump tests for inherited default template parameters

Modified:
cfe/trunk/test/AST/ast-dump-decl.cpp

Modified: cfe/trunk/test/AST/ast-dump-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.cpp?rev=348408&r1=348407&r2=348408&view=diff
==
--- cfe/trunk/test/AST/ast-dump-decl.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-decl.cpp Wed Dec  5 12:21:13 2018
@@ -263,6 +263,15 @@ namespace testClassTemplateDecl {
   template class TestClassTemplatePartial {
 int j;
   };
+
+  template struct TestTemplateDefaultType;
+  template struct TestTemplateDefaultType { };
+
+  template struct TestTemplateDefaultNonType;
+  template struct TestTemplateDefaultNonType { };
+
+  template class TT = TestClassTemplate> struct 
TestTemplateTemplateDefaultType;
+  template class TT> struct TestTemplateTemplateDefaultType 
{ };
 }
 // CHECK:  ClassTemplateDecl{{.*}} TestClassTemplate
 // CHECK-NEXT:   TemplateTypeParmDecl
@@ -316,6 +325,24 @@ namespace testClassTemplateDecl {
 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplatePartial
 // CHECK-NEXT:   FieldDecl{{.*}} j
 
+// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
TestTemplateDefaultType
+// CHECK-NEXT:   TemplateTypeParmDecl
+// CHECK-NEXT: TemplateArgument type 'int'
+// CHECK-NEXT: inherited from TemplateTypeParm 0x{{[^ ]*}} 'T'
+
+// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
TestTemplateDefaultNonType
+// CHECK-NEXT:   NonTypeTemplateParmDecl
+// CHECK-NEXT: TemplateArgument expr
+// CHECK-NEXT:   ConstantExpr
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: inherited from NonTypeTemplateParm 0x{{[^ ]*}} 'I' 'int'
+
+// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
TestTemplateTemplateDefaultType
+// CHECK-NEXT:   TemplateTemplateParmDecl
+// CHECK-NEXT: TemplateTypeParmDecl
+// CHECK-NEXT: TemplateArgument
+// CHECK-NEXT: inherited from TemplateTemplateParm 0x{{[^ ]*}} 'TT'
+
 // PR15220 dump instantiation only once
 namespace testCanonicalTemplate {
   class A {};


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


r348409 - NFC: Inline handling of DependentSizedArrayType

2018-12-05 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Dec  5 12:34:07 2018
New Revision: 348409

URL: http://llvm.org/viewvc/llvm-project?rev=348409&view=rev
Log:
NFC: Inline handling of DependentSizedArrayType

Summary:
Re-order handling of getElementType and getBracketsRange. It is
necessary to perform all printing before any traversal to child nodes.

This causes no change in the output of ast-dump-array.cpp due to the way
child nodes are printed with a delay.  This new order of the code is
also the order that produces the expected output anyway.

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=348409&r1=348408&r2=348409&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Wed Dec  5 12:34:07 2018
@@ -299,9 +299,15 @@ namespace  {
   dumpStmt(T->getSizeExpr());
 }
 void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
-  VisitArrayType(T);
+  switch (T->getSizeModifier()) {
+case ArrayType::Normal: break;
+case ArrayType::Static: OS << " static"; break;
+case ArrayType::Star: OS << " *"; break;
+  }
+  OS << " " << T->getIndexTypeQualifiers().getAsString();
   OS << " ";
   dumpSourceRange(T->getBracketsRange());
+  dumpTypeAsChild(T->getElementType());
   dumpStmt(T->getSizeExpr());
 }
 void VisitDependentSizedExtVectorType(


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


r348410 - NFC: Extract TextTreeStructure class

2018-12-05 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Dec  5 12:53:14 2018
New Revision: 348410

URL: http://llvm.org/viewvc/llvm-project?rev=348410&view=rev
Log:
NFC: Extract TextTreeStructure class

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Added:
cfe/trunk/include/clang/AST/ASTDumperUtils.h
Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Added: cfe/trunk/include/clang/AST/ASTDumperUtils.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTDumperUtils.h?rev=348410&view=auto
==
--- cfe/trunk/include/clang/AST/ASTDumperUtils.h (added)
+++ cfe/trunk/include/clang/AST/ASTDumperUtils.h Wed Dec  5 12:53:14 2018
@@ -0,0 +1,181 @@
+//===--- ASTDumperUtils.h - Printing of AST nodes 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file implements AST utilities for traversal down the tree.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_ASTDUMPERUTILS_H
+#define LLVM_CLANG_AST_ASTDUMPERUTILS_H
+
+#include "clang/AST/ASTContext.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+
+// Colors used for various parts of the AST dump
+// Do not use bold yellow for any text.  It is hard to read on white screens.
+
+struct TerminalColor {
+  raw_ostream::Colors Color;
+  bool Bold;
+};
+
+// Red   - CastColor
+// Green - TypeColor
+// Bold Green- DeclKindNameColor, UndeserializedColor
+// Yellow- AddressColor, LocationColor
+// Blue  - CommentColor, NullColor, IndentColor
+// Bold Blue - AttrColor
+// Bold Magenta  - StmtColor
+// Cyan  - ValueKindColor, ObjectKindColor
+// Bold Cyan - ValueColor, DeclNameColor
+
+// Decl kind names (VarDecl, FunctionDecl, etc)
+static const TerminalColor DeclKindNameColor = {raw_ostream::GREEN, true};
+// Attr names (CleanupAttr, GuardedByAttr, etc)
+static const TerminalColor AttrColor = {raw_ostream::BLUE, true};
+// Statement names (DeclStmt, ImplicitCastExpr, etc)
+static const TerminalColor StmtColor = {raw_ostream::MAGENTA, true};
+// Comment names (FullComment, ParagraphComment, TextComment, etc)
+static const TerminalColor CommentColor = {raw_ostream::BLUE, false};
+
+// Type names (int, float, etc, plus user defined types)
+static const TerminalColor TypeColor = {raw_ostream::GREEN, false};
+
+// Pointer address
+static const TerminalColor AddressColor = {raw_ostream::YELLOW, false};
+// Source locations
+static const TerminalColor LocationColor = {raw_ostream::YELLOW, false};
+
+// lvalue/xvalue
+static const TerminalColor ValueKindColor = {raw_ostream::CYAN, false};
+// bitfield/objcproperty/objcsubscript/vectorcomponent
+static const TerminalColor ObjectKindColor = {raw_ostream::CYAN, false};
+
+// Null statements
+static const TerminalColor NullColor = {raw_ostream::BLUE, false};
+
+// Undeserialized entities
+static const TerminalColor UndeserializedColor = {raw_ostream::GREEN, true};
+
+// CastKind from CastExpr's
+static const TerminalColor CastColor = {raw_ostream::RED, false};
+
+// Value of the statement
+static const TerminalColor ValueColor = {raw_ostream::CYAN, true};
+// Decl names
+static const TerminalColor DeclNameColor = {raw_ostream::CYAN, true};
+
+// Indents ( `, -. | )
+static const TerminalColor IndentColor = {raw_ostream::BLUE, false};
+
+class ColorScope {
+  raw_ostream &OS;
+  const bool ShowColors;
+
+public:
+  ColorScope(raw_ostream &OS, bool ShowColors, TerminalColor Color)
+  : OS(OS), ShowColors(ShowColors) {
+if (ShowColors)
+  OS.changeColor(Color.Color, Color.Bold);
+  }
+  ~ColorScope() {
+if (ShowColors)
+  OS.resetColor();
+  }
+};
+
+class TextTreeStructure {
+  raw_ostream &OS;
+  const bool ShowColors;
+
+  /// Pending[i] is an action to dump an entity at level i.
+  llvm::SmallVector, 32> Pending;
+
+  /// Indicates whether we're at the top level.
+  bool TopLevel = true;
+
+  /// Indicates if we're handling the first child after entering a new depth.
+  bool FirstChild = true;
+
+  /// Prefix for currently-being-dumped entity.
+  std::string Prefix;
+
+public:
+  /// Add a child of the current node.  Calls doAddChild without arguments
+  template  void addChild(Fn doAddChild) {
+// If we're at the top level, there's nothing interesting to do; just
+// run the dumper.
+if (TopLevel) {
+  TopLevel = false;
+  doAddChild();
+  while (!Pending.empty()) {
+Pending.back()(true);
+Pending.pop_back();
+  }
+  Prefix.clear();
+  OS << "\n";
+  TopLevel = true;
+  return;
+}
+
+auto dumpWithIndent = [this, doAddChild](bool isLastChild) {
+

Re: r348408 - Add dump tests for inherited default template parameters

2018-12-05 Thread Stephen Kelly via cfe-commits

Surely all of the tests specifically about template decls should be moved?

On 05/12/2018 20:31, Aaron Ballman wrote:

On Wed, Dec 5, 2018 at 3:24 PM Stephen Kelly via cfe-commits
 wrote:

Author: steveire
Date: Wed Dec  5 12:21:13 2018
New Revision: 348408

URL: http://llvm.org/viewvc/llvm-project?rev=348408&view=rev
Log:
Add dump tests for inherited default template parameters

Modified:
 cfe/trunk/test/AST/ast-dump-decl.cpp

Can you move these tests into ast-dump-template-decls.cpp?

~Aaron


Modified: cfe/trunk/test/AST/ast-dump-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.cpp?rev=348408&r1=348407&r2=348408&view=diff
==
--- cfe/trunk/test/AST/ast-dump-decl.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-decl.cpp Wed Dec  5 12:21:13 2018
@@ -263,6 +263,15 @@ namespace testClassTemplateDecl {
template class TestClassTemplatePartial {
  int j;
};
+
+  template struct TestTemplateDefaultType;
+  template struct TestTemplateDefaultType { };
+
+  template struct TestTemplateDefaultNonType;
+  template struct TestTemplateDefaultNonType { };
+
+  template class TT = TestClassTemplate> struct 
TestTemplateTemplateDefaultType;
+  template class TT> struct TestTemplateTemplateDefaultType 
{ };
  }
  // CHECK:  ClassTemplateDecl{{.*}} TestClassTemplate
  // CHECK-NEXT:   TemplateTypeParmDecl
@@ -316,6 +325,24 @@ namespace testClassTemplateDecl {
  // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplatePartial
  // CHECK-NEXT:   FieldDecl{{.*}} j

+// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
TestTemplateDefaultType
+// CHECK-NEXT:   TemplateTypeParmDecl
+// CHECK-NEXT: TemplateArgument type 'int'
+// CHECK-NEXT: inherited from TemplateTypeParm 0x{{[^ ]*}} 'T'
+
+// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
TestTemplateDefaultNonType
+// CHECK-NEXT:   NonTypeTemplateParmDecl
+// CHECK-NEXT: TemplateArgument expr
+// CHECK-NEXT:   ConstantExpr
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: inherited from NonTypeTemplateParm 0x{{[^ ]*}} 'I' 'int'
+
+// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
TestTemplateTemplateDefaultType
+// CHECK-NEXT:   TemplateTemplateParmDecl
+// CHECK-NEXT: TemplateTypeParmDecl
+// CHECK-NEXT: TemplateArgument
+// CHECK-NEXT: inherited from TemplateTemplateParm 0x{{[^ ]*}} 'TT'
+
  // PR15220 dump instantiation only once
  namespace testCanonicalTemplate {
class A {};


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

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


r348412 - NFC: Extract TextNodeDumper class

2018-12-05 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Dec  5 13:12:39 2018
New Revision: 348412

URL: http://llvm.org/viewvc/llvm-project?rev=348412&view=rev
Log:
NFC: Extract TextNodeDumper class

Summary:
Start by moving some utilities to it. It will eventually house dumping
of individual nodes (after indentation etc has already been accounted
for).

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Added:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/TextNodeDumper.cpp
Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/CMakeLists.txt

Added: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=348412&view=auto
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (added)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Wed Dec  5 13:12:39 2018
@@ -0,0 +1,54 @@
+//===--- TextNodeDumper.h - Printing of AST nodes 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file implements AST dumping of components of individual AST nodes.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_TEXTNODEDUMPER_H
+#define LLVM_CLANG_AST_TEXTNODEDUMPER_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTDumperUtils.h"
+#include "clang/AST/ExprCXX.h"
+
+namespace clang {
+
+class TextNodeDumper {
+  raw_ostream &OS;
+  const bool ShowColors;
+
+  /// Keep track of the last location we print out so that we can
+  /// print out deltas from then on out.
+  const char *LastLocFilename = "";
+  unsigned LastLocLine = ~0U;
+
+  const SourceManager *SM;
+
+  /// The policy to use for printing; can be defaulted.
+  PrintingPolicy PrintPolicy;
+
+public:
+  TextNodeDumper(raw_ostream &OS, bool ShowColors, const SourceManager *SM,
+ const PrintingPolicy &PrintPolicy);
+
+  void dumpPointer(const void *Ptr);
+  void dumpLocation(SourceLocation Loc);
+  void dumpSourceRange(SourceRange R);
+  void dumpBareType(QualType T, bool Desugar = true);
+  void dumpType(QualType T);
+  void dumpBareDeclRef(const Decl *D);
+  void dumpName(const NamedDecl *ND);
+  void dumpAccessSpecifier(AccessSpecifier AS);
+  void dumpCXXTemporary(const CXXTemporary *Temporary);
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_AST_TEXTNODEDUMPER_H

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=348412&r1=348411&r2=348412&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Wed Dec  5 13:12:39 2018
@@ -23,6 +23,7 @@
 #include "clang/AST/DeclVisitor.h"
 #include "clang/AST/LocInfoType.h"
 #include "clang/AST/StmtVisitor.h"
+#include "clang/AST/TextNodeDumper.h"
 #include "clang/AST/TypeVisitor.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/Module.h"
@@ -44,10 +45,10 @@ namespace  {
 public TypeVisitor {
 
 TextTreeStructure TreeStructure;
+TextNodeDumper NodeDumper;
 
 raw_ostream &OS;
 const CommandTraits *Traits;
-const SourceManager *SM;
 
 /// The policy to use for printing; can be defaulted.
 PrintingPolicy PrintPolicy;
@@ -56,11 +57,6 @@ namespace  {
 /// not already been loaded.
 bool Deserialize = false;
 
-/// Keep track of the last location we print out so that we can
-/// print out deltas from then on out.
-const char *LastLocFilename = "";
-unsigned LastLocLine = ~0U;
-
 const bool ShowColors;
 
 /// Dump a child of the current node.
@@ -80,7 +76,8 @@ namespace  {
 ASTDumper(raw_ostream &OS, const CommandTraits *Traits,
   const SourceManager *SM, bool ShowColors,
   const PrintingPolicy &PrintPolicy)
-: TreeStructure(OS, ShowColors), OS(OS), Traits(Traits), SM(SM),
+: TreeStructure(OS, ShowColors),
+  NodeDumper(OS, ShowColors, SM, PrintPolicy), OS(OS), Traits(Traits),
   PrintPolicy(PrintPolicy), ShowColors(ShowColors) {}
 
 void setDeserialize(bool D) { Deserialize = D; }
@@ -90,23 +87,17 @@ namespace  {
 void dumpFullComment(const FullComment *C);
 
 // Utilities
-void dumpPointer(const void *Ptr);
-void dumpSourceRange(SourceRange R);
-void dumpLocation(SourceLocation Loc);
-void dumpBareType(QualType T, bool Desugar = true);
-void dumpType(QualType T);
+void dumpType(QualType T) { NodeDumper.dumpType(T); }
 void dumpTypeAsChild(QualType T);
 void dumpTypeAsChild(const Type *T);
-void dumpBareDeclRef(c

r348469 - Make test resistant to line numbers changing

2018-12-06 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Dec  6 01:22:12 2018
New Revision: 348469

URL: http://llvm.org/viewvc/llvm-project?rev=348469&view=rev
Log:
Make test resistant to line numbers changing

Modified:
cfe/trunk/test/AST/dump.cpp

Modified: cfe/trunk/test/AST/dump.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/dump.cpp?rev=348469&r1=348468&r2=348469&view=diff
==
--- cfe/trunk/test/AST/dump.cpp (original)
+++ cfe/trunk/test/AST/dump.cpp Thu Dec  6 01:22:12 2018
@@ -43,7 +43,7 @@ struct S {
   }
 };
 
-// CHECK:  | `-OMPParallelForDirective {{.+}} {{|}}
+// CHECK:  | `-OMPParallelForDirective {{.+}} {{|}}
 // CHECK-NEXT: |   |-OMPDefaultClause {{.+}} 
 // CHECK-NEXT: |   |-OMPPrivateClause {{.+}} 
 // CHECK-NEXT: |   | `-DeclRefExpr {{.+}}  'int' lvalue 
OMPCapturedExpr {{.+}} 'a' 'int &'
@@ -53,19 +53,19 @@ struct S {
 // CHECK-NEXT: |   |-OMPScheduleClause {{.+}} 
 // CHECK-NEXT: |   | `-ImplicitCastExpr {{.+}}  'int' 

 // CHECK-NEXT: |   |   `-DeclRefExpr {{.+}}  'int' lvalue 
OMPCapturedExpr {{.+}} '.capture_expr.' 'int'
-// CHECK-NEXT: |   `-CapturedStmt {{.+}} 
+// CHECK-NEXT: |   `-CapturedStmt {{.+}} 
 // CHECK-NEXT: | |-CapturedDecl {{.+}} <> 
-// CHECK-NEXT: | | |-ForStmt {{.+}} 
-// CHECK:  | | | `-UnaryOperator {{.+}}  'int' 
lvalue prefix '++'
+// CHECK-NEXT: | | |-ForStmt {{.+}} 
+// CHECK:  | | | `-UnaryOperator {{.+}}  
'int' lvalue prefix '++'
 // CHECK-NEXT: | | |   `-DeclRefExpr {{.+}}  'int' lvalue 
OMPCapturedExpr {{.+}} 'a' 'int &'
 
 #pragma omp declare simd
 #pragma omp declare simd inbranch
 void foo();
 
-// CHECK:|-FunctionDecl {{.+}}  col:6 foo 'void ()'
-// CHECK-NEXT:   |-OMPDeclareSimdDeclAttr {{.+}}  Implicit 
BS_Inbranch
-// CHECK:`-OMPDeclareSimdDeclAttr {{.+}}  Implicit 
BS_Undefined
+// CHECK:|-FunctionDecl {{.+}}  col:6 foo 'void 
()'
+// CHECK-NEXT:   |-OMPDeclareSimdDeclAttr {{.+}}  
Implicit BS_Inbranch
+// CHECK:`-OMPDeclareSimdDeclAttr {{.+}}  
Implicit BS_Undefined
 
 #pragma omp declare target
 int bar() {
@@ -74,11 +74,11 @@ int bar() {
 }
 #pragma omp end declare target
 
-// CHECK:   `-FunctionDecl {{.+}}  line:71:5 bar 
'int ()'
-// CHECK-NEXT:  |-CompoundStmt {{.+}} 
-// CHECK-NEXT:  | |-DeclStmt {{.+}} 
+// CHECK:   `-FunctionDecl {{.+}}  
line:{{.+}}:5 bar 'int ()'
+// CHECK-NEXT:  |-CompoundStmt {{.+}} 
+// CHECK-NEXT:  | |-DeclStmt {{.+}} 
 // CHECK-NEXT:  | | `-VarDecl {{.+}}  col:7 used f 'int'
-// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
+// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
 // CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
 // CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'f' 'int'
 // CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}} <> Implicit 
MT_To


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


r348471 - Add test for ObjC generics

2018-12-06 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Dec  6 01:23:59 2018
New Revision: 348471

URL: http://llvm.org/viewvc/llvm-project?rev=348471&view=rev
Log:
Add test for ObjC generics

Modified:
cfe/trunk/test/AST/ast-dump-decl.m

Modified: cfe/trunk/test/AST/ast-dump-decl.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.m?rev=348471&r1=348470&r2=348471&view=diff
==
--- cfe/trunk/test/AST/ast-dump-decl.m (original)
+++ cfe/trunk/test/AST/ast-dump-decl.m Thu Dec  6 01:23:59 2018
@@ -81,6 +81,14 @@
 // CHECK-NEXT:   ObjCProtocol{{.*}} 'P'
 // CHECK-NEXT:   ObjCMethodDecl{{.*}} bar
 
+@interface TestGenericInterface : A {
+}
+@end
+// CHECK:  ObjCInterfaceDecl{{.*}} TestGenericInterface
+// CHECK-NEXT:   -ObjCTypeParamDecl
+// CHECK-NEXT:   -super ObjCInterface
+// CHECK-NEXT:   -ObjCProtocol
+
 @implementation TestObjCClass (TestObjCCategoryDecl)
 - (void) bar {
 }


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


r348470 - Extend OMP test

2018-12-06 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Dec  6 01:23:53 2018
New Revision: 348470

URL: http://llvm.org/viewvc/llvm-project?rev=348470&view=rev
Log:
Extend OMP test

Modified:
cfe/trunk/test/AST/dump.cpp

Modified: cfe/trunk/test/AST/dump.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/dump.cpp?rev=348470&r1=348469&r2=348470&view=diff
==
--- cfe/trunk/test/AST/dump.cpp (original)
+++ cfe/trunk/test/AST/dump.cpp Thu Dec  6 01:23:53 2018
@@ -33,6 +33,13 @@ int ga, gb;
 // CHECK-NEXT: | | |-DeclRefExpr {{.+}}  'float' lvalue Var {{.+}} 
'omp_out' 'float'
 // CHECK-NEXT: | | `-ImplicitCastExpr {{.+}}  'float' 
 // CHECK-NEXT: | |   `-DeclRefExpr {{.+}}  'float' lvalue Var {{.+}} 
'omp_in' 'float'
+// CHECK-NEXT: | |-BinaryOperator {{.+}}  'float' lvalue '='
+// CHECK-NEXT: | | |-DeclRefExpr {{.+}}  'float' lvalue Var {{.+}} 
'omp_priv' 'float'
+// CHECK-NEXT: | | `-BinaryOperator {{.+}}  'float' '+'
+// CHECK-NEXT: | |   |-ImplicitCastExpr {{.+}}  'float' 

+// CHECK-NEXT: | |   | `-DeclRefExpr {{.+}}  'float' lvalue Var {{.+}} 
'omp_orig' 'float'
+// CHECK-NEXT: | |   `-ImplicitCastExpr {{.+}}  'float' 

+// CHECK-NEXT: | | `-IntegerLiteral {{.+}}  'int' 15
 
 struct S {
   int a, b;


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


r348541 - Use relative line offsets in test

2018-12-06 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Dec  6 14:51:51 2018
New Revision: 348541

URL: http://llvm.org/viewvc/llvm-project?rev=348541&view=rev
Log:
Use relative line offsets in test

Modified:
cfe/trunk/test/AST/dump.cpp

Modified: cfe/trunk/test/AST/dump.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/dump.cpp?rev=348541&r1=348540&r2=348541&view=diff
==
--- cfe/trunk/test/AST/dump.cpp (original)
+++ cfe/trunk/test/AST/dump.cpp Thu Dec  6 14:51:51 2018
@@ -13,7 +13,7 @@ int ga, gb;
 
 #pragma omp declare reduction(fun : float : omp_out += omp_in) 
initializer(omp_priv = omp_orig + 15)
 
-// CHECK:  |-OMPDeclareReductionDecl {{.+}}  col:35 operator+ 
'int' combiner
+// CHECK:  |-OMPDeclareReductionDecl {{.+}}  col:35 
operator+ 'int' combiner
 // CHECK-NEXT: | |-CompoundAssignOperator {{.+}}  'int' lvalue 
'*=' ComputeLHSTy='int' ComputeResultTy='int'
 // CHECK-NEXT: | | |-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'omp_out' 'int'
 // CHECK-NEXT: | | `-ImplicitCastExpr {{.+}}  'int' 
@@ -28,7 +28,7 @@ int ga, gb;
 // CHECK-NEXT: | | `-DeclRefExpr {{.+}}  'char' lvalue Var {{.+}} 
'omp_in' 'char'
 // CHECK-NEXT: | |-VarDecl {{.+}}  col:40 implicit used omp_in 'char'
 // CHECK-NEXT: | `-VarDecl {{.+}}  col:40 implicit used omp_out 'char'
-// CHECK-NEXT: |-OMPDeclareReductionDecl {{.+}}  col:37 fun 
'float' combiner initializer
+// CHECK-NEXT: |-OMPDeclareReductionDecl {{.+}}  col:37 
fun 'float' combiner initializer
 // CHECK-NEXT: | |-CompoundAssignOperator {{.+}}  'float' 
lvalue '+=' ComputeLHSTy='float' ComputeResultTy='float'
 // CHECK-NEXT: | | |-DeclRefExpr {{.+}}  'float' lvalue Var {{.+}} 
'omp_out' 'float'
 // CHECK-NEXT: | | `-ImplicitCastExpr {{.+}}  'float' 
@@ -60,19 +60,19 @@ struct S {
 // CHECK-NEXT: |   |-OMPScheduleClause {{.+}} 
 // CHECK-NEXT: |   | `-ImplicitCastExpr {{.+}}  'int' 

 // CHECK-NEXT: |   |   `-DeclRefExpr {{.+}}  'int' lvalue 
OMPCapturedExpr {{.+}} '.capture_expr.' 'int'
-// CHECK-NEXT: |   `-CapturedStmt {{.+}} 
+// CHECK-NEXT: |   `-CapturedStmt {{.+}} 
 // CHECK-NEXT: | |-CapturedDecl {{.+}} <> 
-// CHECK-NEXT: | | |-ForStmt {{.+}} 
-// CHECK:  | | | `-UnaryOperator {{.+}}  
'int' lvalue prefix '++'
+// CHECK-NEXT: | | |-ForStmt {{.+}} 
+// CHECK:  | | | `-UnaryOperator {{.+}}  'int' lvalue prefix '++'
 // CHECK-NEXT: | | |   `-DeclRefExpr {{.+}}  'int' lvalue 
OMPCapturedExpr {{.+}} 'a' 'int &'
 
 #pragma omp declare simd
 #pragma omp declare simd inbranch
 void foo();
 
-// CHECK:|-FunctionDecl {{.+}}  col:6 foo 'void 
()'
-// CHECK-NEXT:   |-OMPDeclareSimdDeclAttr {{.+}}  
Implicit BS_Inbranch
-// CHECK:`-OMPDeclareSimdDeclAttr {{.+}}  
Implicit BS_Undefined
+// CHECK:|-FunctionDecl {{.+}}  col:6 foo 
'void ()'
+// CHECK-NEXT:   |-OMPDeclareSimdDeclAttr {{.+}}  
Implicit BS_Inbranch
+// CHECK:`-OMPDeclareSimdDeclAttr {{.+}}  
Implicit BS_Undefined
 
 #pragma omp declare target
 int bar() {
@@ -81,11 +81,11 @@ int bar() {
 }
 #pragma omp end declare target
 
-// CHECK:   `-FunctionDecl {{.+}}  
line:{{.+}}:5 bar 'int ()'
-// CHECK-NEXT:  |-CompoundStmt {{.+}} 
-// CHECK-NEXT:  | |-DeclStmt {{.+}} 
+// CHECK:   `-FunctionDecl {{.+}}  
line:[[@LINE-6]]:5 bar 'int ()'
+// CHECK-NEXT:  |-CompoundStmt {{.+}} 
+// CHECK-NEXT:  | |-DeclStmt {{.+}} 
 // CHECK-NEXT:  | | `-VarDecl {{.+}}  col:7 used f 'int'
-// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
+// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
 // CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
 // CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'f' 'int'
 // CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}} <> Implicit 
MT_To


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


Re: r348469 - Make test resistant to line numbers changing

2018-12-06 Thread Stephen Kelly via cfe-commits


On 06/12/2018 12:45, Aaron Ballman wrote:

On Thu, Dec 6, 2018 at 4:25 AM Stephen Kelly via cfe-commits
 wrote:

Author: steveire
Date: Thu Dec  6 01:22:12 2018
New Revision: 348469

URL: http://llvm.org/viewvc/llvm-project?rev=348469&view=rev
Log:
Make test resistant to line numbers changing

I would prefer to see the line numbers be tested rather than entirely
ignored (it's still important information we want to make sure is
correct). Can you use [[@LINE + N]] to instead make the line numbers
relative?



Done with r348541.

Thanks!

Stephen.


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


r348543 - Add more expected content to match in test

2018-12-06 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Dec  6 15:23:10 2018
New Revision: 348543

URL: http://llvm.org/viewvc/llvm-project?rev=348543&view=rev
Log:
Add more expected content to match in test

Modified:
cfe/trunk/test/AST/ast-dump-decl.m

Modified: cfe/trunk/test/AST/ast-dump-decl.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.m?rev=348543&r1=348542&r2=348543&view=diff
==
--- cfe/trunk/test/AST/ast-dump-decl.m (original)
+++ cfe/trunk/test/AST/ast-dump-decl.m Thu Dec  6 15:23:10 2018
@@ -85,9 +85,9 @@
 }
 @end
 // CHECK:  ObjCInterfaceDecl{{.*}} TestGenericInterface
-// CHECK-NEXT:   -ObjCTypeParamDecl
-// CHECK-NEXT:   -super ObjCInterface
-// CHECK-NEXT:   -ObjCProtocol
+// CHECK-NEXT:   -ObjCTypeParamDecl {{.+}}  col:33 T 'id':'id'
+// CHECK-NEXT:   -super ObjCInterface {{.+}} 'A'
+// CHECK-NEXT:   -ObjCProtocol {{.+}} 'P'
 
 @implementation TestObjCClass (TestObjCCategoryDecl)
 - (void) bar {


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


Re: r348471 - Add test for ObjC generics

2018-12-06 Thread Stephen Kelly via cfe-commits


On 06/12/2018 12:48, Aaron Ballman wrote:

On Thu, Dec 6, 2018 at 4:26 AM Stephen Kelly via cfe-commits
 wrote:

Author: steveire
Date: Thu Dec  6 01:23:59 2018
New Revision: 348471

URL: http://llvm.org/viewvc/llvm-project?rev=348471&view=rev
Log:
Add test for ObjC generics

Modified:
 cfe/trunk/test/AST/ast-dump-decl.m

Modified: cfe/trunk/test/AST/ast-dump-decl.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.m?rev=348471&r1=348470&r2=348471&view=diff
==
--- cfe/trunk/test/AST/ast-dump-decl.m (original)
+++ cfe/trunk/test/AST/ast-dump-decl.m Thu Dec  6 01:23:59 2018
@@ -81,6 +81,14 @@
  // CHECK-NEXT:   ObjCProtocol{{.*}} 'P'
  // CHECK-NEXT:   ObjCMethodDecl{{.*}} bar

+@interface TestGenericInterface : A {
+}
+@end
+// CHECK:  ObjCInterfaceDecl{{.*}} TestGenericInterface
+// CHECK-NEXT:   -ObjCTypeParamDecl
+// CHECK-NEXT:   -super ObjCInterface
+// CHECK-NEXT:   -ObjCProtocol

It would be useful to test the line and column, identifier, and type
information as well as the basic AST nodes.


Done in r348543.

Thanks!

Stephen.



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


r348545 - NFC: Move VisitStmt code to dumpStmt

2018-12-06 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Dec  6 15:33:27 2018
New Revision: 348545

URL: http://llvm.org/viewvc/llvm-project?rev=348545&view=rev
Log:
NFC: Move VisitStmt code to dumpStmt

Summary: This call is duplicated in Visits of all direct subclasses of Stmt.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=348545&r1=348544&r2=348545&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Thu Dec  6 15:33:27 2018
@@ -366,7 +366,6 @@ namespace  {
 void VisitBlockDecl(const BlockDecl *D);
 
 // Stmts.
-void VisitStmt(const Stmt *Node);
 void VisitDeclStmt(const DeclStmt *Node);
 void VisitAttributedStmt(const AttributedStmt *Node);
 void VisitIfStmt(const IfStmt *Node);
@@ -1727,6 +1726,12 @@ void ASTDumper::dumpStmt(const Stmt *S)
   OS << "<<>>";
   return;
 }
+{
+  ColorScope Color(OS, ShowColors, StmtColor);
+  OS << S->getStmtClassName();
+}
+NodeDumper.dumpPointer(S);
+NodeDumper.dumpSourceRange(S->getSourceRange());
 
 ConstStmtVisitor::Visit(S);
 
@@ -1740,17 +1745,7 @@ void ASTDumper::dumpStmt(const Stmt *S)
   });
 }
 
-void ASTDumper::VisitStmt(const Stmt *Node) {
-  {
-ColorScope Color(OS, ShowColors, StmtColor);
-OS << Node->getStmtClassName();
-  }
-  NodeDumper.dumpPointer(Node);
-  NodeDumper.dumpSourceRange(Node->getSourceRange());
-}
-
 void ASTDumper::VisitDeclStmt(const DeclStmt *Node) {
-  VisitStmt(Node);
   for (DeclStmt::const_decl_iterator I = Node->decl_begin(),
  E = Node->decl_end();
I != E; ++I)
@@ -1758,7 +1753,6 @@ void ASTDumper::VisitDeclStmt(const Decl
 }
 
 void ASTDumper::VisitAttributedStmt(const AttributedStmt *Node) {
-  VisitStmt(Node);
   for (ArrayRef::iterator I = Node->getAttrs().begin(),
 E = Node->getAttrs().end();
I != E; ++I)
@@ -1766,7 +1760,6 @@ void ASTDumper::VisitAttributedStmt(cons
 }
 
 void ASTDumper::VisitIfStmt(const IfStmt *Node) {
-  VisitStmt(Node);
   if (Node->hasInitStorage())
 OS << " has_init";
   if (Node->hasVarStorage())
@@ -1776,7 +1769,6 @@ void ASTDumper::VisitIfStmt(const IfStmt
 }
 
 void ASTDumper::VisitSwitchStmt(const SwitchStmt *Node) {
-  VisitStmt(Node);
   if (Node->hasInitStorage())
 OS << " has_init";
   if (Node->hasVarStorage())
@@ -1784,35 +1776,29 @@ void ASTDumper::VisitSwitchStmt(const Sw
 }
 
 void ASTDumper::VisitWhileStmt(const WhileStmt *Node) {
-  VisitStmt(Node);
   if (Node->hasVarStorage())
 OS << " has_var";
 }
 
 void ASTDumper::VisitLabelStmt(const LabelStmt *Node) {
-  VisitStmt(Node);
   OS << " '" << Node->getName() << "'";
 }
 
 void ASTDumper::VisitGotoStmt(const GotoStmt *Node) {
-  VisitStmt(Node);
   OS << " '" << Node->getLabel()->getName() << "'";
   NodeDumper.dumpPointer(Node->getLabel());
 }
 
 void ASTDumper::VisitCXXCatchStmt(const CXXCatchStmt *Node) {
-  VisitStmt(Node);
   dumpDecl(Node->getExceptionDecl());
 }
 
 void ASTDumper::VisitCaseStmt(const CaseStmt *Node) {
-  VisitStmt(Node);
   if (Node->caseStmtIsGNURange())
 OS << " gnu_range";
 }
 
 void ASTDumper::VisitCapturedStmt(const CapturedStmt *Node) {
-  VisitStmt(Node);
   dumpDecl(Node->getCapturedDecl());
 }
 
@@ -1822,7 +1808,6 @@ void ASTDumper::VisitCapturedStmt(const
 
 void ASTDumper::VisitOMPExecutableDirective(
 const OMPExecutableDirective *Node) {
-  VisitStmt(Node);
   for (auto *C : Node->clauses()) {
 dumpChild([=] {
   if (!C) {
@@ -1851,7 +1836,6 @@ void ASTDumper::VisitOMPExecutableDirect
 
//===--===//
 
 void ASTDumper::VisitExpr(const Expr *Node) {
-  VisitStmt(Node);
   NodeDumper.dumpType(Node->getType());
 
   {
@@ -2277,7 +2261,6 @@ void ASTDumper::VisitObjCBoxedExpr(const
 }
 
 void ASTDumper::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node) {
-  VisitStmt(Node);
   if (const VarDecl *CatchParam = Node->getCatchParamDecl())
 dumpDecl(CatchParam);
   else


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


r348546 - NFC: Move VisitExpr code to dumpStmt

2018-12-06 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Dec  6 15:33:33 2018
New Revision: 348546

URL: http://llvm.org/viewvc/llvm-project?rev=348546&view=rev
Log:
NFC: Move VisitExpr code to dumpStmt

Summary:
The call is duplicated in the handlers of all Expr subclasses.

This change makes it easy to split statement handling out to
TextNodeDumper.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=348546&r1=348545&r2=348546&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Thu Dec  6 15:33:33 2018
@@ -381,7 +381,6 @@ namespace  {
 void VisitOMPExecutableDirective(const OMPExecutableDirective *Node);
 
 // Exprs
-void VisitExpr(const Expr *Node);
 void VisitCastExpr(const CastExpr *Node);
 void VisitImplicitCastExpr(const ImplicitCastExpr *Node);
 void VisitDeclRefExpr(const DeclRefExpr *Node);
@@ -417,7 +416,6 @@ namespace  {
 void VisitExprWithCleanups(const ExprWithCleanups *Node);
 void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node);
 void VisitLambdaExpr(const LambdaExpr *Node) {
-  VisitExpr(Node);
   dumpDecl(Node->getLambdaClass());
 }
 void VisitSizeOfPackExpr(const SizeOfPackExpr *Node);
@@ -1733,6 +1731,44 @@ void ASTDumper::dumpStmt(const Stmt *S)
 NodeDumper.dumpPointer(S);
 NodeDumper.dumpSourceRange(S->getSourceRange());
 
+if (const auto *E = dyn_cast(S)) {
+  NodeDumper.dumpType(E->getType());
+
+  {
+ColorScope Color(OS, ShowColors, ValueKindColor);
+switch (E->getValueKind()) {
+case VK_RValue:
+  break;
+case VK_LValue:
+  OS << " lvalue";
+  break;
+case VK_XValue:
+  OS << " xvalue";
+  break;
+}
+  }
+
+  {
+ColorScope Color(OS, ShowColors, ObjectKindColor);
+switch (E->getObjectKind()) {
+case OK_Ordinary:
+  break;
+case OK_BitField:
+  OS << " bitfield";
+  break;
+case OK_ObjCProperty:
+  OS << " objcproperty";
+  break;
+case OK_ObjCSubscript:
+  OS << " objcsubscript";
+  break;
+case OK_VectorComponent:
+  OS << " vectorcomponent";
+  break;
+}
+  }
+}
+
 ConstStmtVisitor::Visit(S);
 
 // Some statements have custom mechanisms for dumping their children.
@@ -1835,44 +1871,6 @@ void ASTDumper::VisitOMPExecutableDirect
 //  Expr dumping methods.
 
//===--===//
 
-void ASTDumper::VisitExpr(const Expr *Node) {
-  NodeDumper.dumpType(Node->getType());
-
-  {
-ColorScope Color(OS, ShowColors, ValueKindColor);
-switch (Node->getValueKind()) {
-case VK_RValue:
-  break;
-case VK_LValue:
-  OS << " lvalue";
-  break;
-case VK_XValue:
-  OS << " xvalue";
-  break;
-}
-  }
-
-  {
-ColorScope Color(OS, ShowColors, ObjectKindColor);
-switch (Node->getObjectKind()) {
-case OK_Ordinary:
-  break;
-case OK_BitField:
-  OS << " bitfield";
-  break;
-case OK_ObjCProperty:
-  OS << " objcproperty";
-  break;
-case OK_ObjCSubscript:
-  OS << " objcsubscript";
-  break;
-case OK_VectorComponent:
-  OS << " vectorcomponent";
-  break;
-}
-  }
-}
-
 static void dumpBasePath(raw_ostream &OS, const CastExpr *Node) {
   if (Node->path_empty())
 return;
@@ -1899,7 +1897,6 @@ static void dumpBasePath(raw_ostream &OS
 }
 
 void ASTDumper::VisitCastExpr(const CastExpr *Node) {
-  VisitExpr(Node);
   OS << " <";
   {
 ColorScope Color(OS, ShowColors, CastColor);
@@ -1916,8 +1913,6 @@ void ASTDumper::VisitImplicitCastExpr(co
 }
 
 void ASTDumper::VisitDeclRefExpr(const DeclRefExpr *Node) {
-  VisitExpr(Node);
-
   OS << " ";
   NodeDumper.dumpBareDeclRef(Node->getDecl());
   if (Node->getDecl() != Node->getFoundDecl()) {
@@ -1928,7 +1923,6 @@ void ASTDumper::VisitDeclRefExpr(const D
 }
 
 void ASTDumper::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node) {
-  VisitExpr(Node);
   OS << " (";
   if (!Node->requiresADL())
 OS << "no ";
@@ -1943,8 +1937,6 @@ void ASTDumper::VisitUnresolvedLookupExp
 }
 
 void ASTDumper::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node) {
-  VisitExpr(Node);
-
   {
 ColorScope Color(OS, ShowColors, DeclKindNameColor);
 OS << " " << Node->getDecl()->getDeclKindName() << "Decl";
@@ -1956,46 +1948,37 @@ void ASTDumper::VisitObjCIvarRefExpr(con
 }
 
 void ASTDumper::VisitPredefinedExpr(const PredefinedExpr *Node) {
-  VisitExpr(Node);
   OS << " " << PredefinedExpr::getIdentKindName(Node->getIdentKind());
 }
 
 void ASTDumper::VisitCharac

r348553 - Add test for InitListExpr

2018-12-06 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Dec  6 16:08:14 2018
New Revision: 348553

URL: http://llvm.org/viewvc/llvm-project?rev=348553&view=rev
Log:
Add test for InitListExpr

Modified:
cfe/trunk/test/AST/ast-dump-stmt.cpp

Modified: cfe/trunk/test/AST/ast-dump-stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-stmt.cpp?rev=348553&r1=348552&r2=348553&view=diff
==
--- cfe/trunk/test/AST/ast-dump-stmt.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-stmt.cpp Thu Dec  6 16:08:14 2018
@@ -81,3 +81,21 @@ void TestDependentScopeMemberExpr() {
 // CHECK: FunctionTemplateDecl {{.*}} TestDependentScopeMemberExpr
 // CHECK: CXXDependentScopeMemberExpr {{.*}} lvalue .member
 // CHECK: CXXDependentScopeMemberExpr {{.*}} lvalue ->member
+
+union U {
+  int i;
+  long l;
+};
+
+void TestUnionInitList()
+{
+  U us[3] = {1};
+// Check: VarDecl {{.+}}  col:5 us 'U [3]' cinit
+// Check-NEXT: `-InitListExpr {{.+}}  'U [3]'
+// Check-NEXT:   |-array filler
+// Check-NEXT:   | `-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 
'int'
+// Check-NEXT:   |-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 
'int'
+// Check-NEXT:   | `-IntegerLiteral {{.+}}  'int' 1
+
+
+}


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


r348713 - Fix InitListExpr test

2018-12-09 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sun Dec  9 05:13:41 2018
New Revision: 348713

URL: http://llvm.org/viewvc/llvm-project?rev=348713&view=rev
Log:
Fix InitListExpr test

Wrong case of Check meant this has no effect.

Modified:
cfe/trunk/test/AST/ast-dump-stmt.cpp

Modified: cfe/trunk/test/AST/ast-dump-stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-stmt.cpp?rev=348713&r1=348712&r2=348713&view=diff
==
--- cfe/trunk/test/AST/ast-dump-stmt.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-stmt.cpp Sun Dec  9 05:13:41 2018
@@ -89,12 +89,12 @@ union U {
 void TestUnionInitList()
 {
   U us[3] = {1};
-// Check: VarDecl {{.+}}  col:5 us 'U [3]' cinit
-// Check-NEXT: `-InitListExpr {{.+}}  'U [3]'
-// Check-NEXT:   |-array filler
-// Check-NEXT:   | `-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 
'int'
-// Check-NEXT:   |-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 
'int'
-// Check-NEXT:   | `-IntegerLiteral {{.+}}  'int' 1
+// CHECK: VarDecl {{.+}}  col:5 us 'U [3]' cinit
+// CHECK-NEXT: `-InitListExpr {{.+}}  'U [3]'
+// CHECK-NEXT:   |-array filler
+// CHECK-NEXT:   | `-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 
'int'
+// CHECK-NEXT:   `-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 
'int'
+// CHECK-NEXT: `-IntegerLiteral {{.+}}  'int' 1
 }
 
 void TestSwitch(int i) {


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


r348714 - Re-order content from InitListExpr

2018-12-09 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sun Dec  9 05:15:18 2018
New Revision: 348714

URL: http://llvm.org/viewvc/llvm-project?rev=348714&view=rev
Log:
Re-order content from InitListExpr

Summary:
This causes no change in the output of ast-dump-stmt.cpp due to the way
child nodes are printed with a delay.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=348714&r1=348713&r2=348714&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Sun Dec  9 05:15:18 2018
@@ -1979,16 +1979,16 @@ void ASTDumper::VisitStringLiteral(const
 }
 
 void ASTDumper::VisitInitListExpr(const InitListExpr *ILE) {
+  if (auto *Field = ILE->getInitializedFieldInUnion()) {
+OS << " field ";
+NodeDumper.dumpBareDeclRef(Field);
+  }
   if (auto *Filler = ILE->getArrayFiller()) {
 dumpChild([=] {
   OS << "array filler";
   dumpStmt(Filler);
 });
   }
-  if (auto *Field = ILE->getInitializedFieldInUnion()) {
-OS << " field ";
-NodeDumper.dumpBareDeclRef(Field);
-  }
 }
 
 void ASTDumper::VisitUnaryOperator(const UnaryOperator *Node) {


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


r348715 - Inline dumpFullComment into callers

2018-12-09 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sun Dec  9 05:18:55 2018
New Revision: 348715

URL: http://llvm.org/viewvc/llvm-project?rev=348715&view=rev
Log:
Inline dumpFullComment into callers

It causes confusion over whether it or dumpComment is the more
important. It is easier to refactor with fewer utility methods.

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=348715&r1=348714&r2=348715&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Sun Dec  9 05:18:55 2018
@@ -84,7 +84,6 @@ namespace  {
 
 void dumpDecl(const Decl *D);
 void dumpStmt(const Stmt *S);
-void dumpFullComment(const FullComment *C);
 
 // Utilities
 void dumpType(QualType T) { NodeDumper.dumpType(T); }
@@ -831,7 +830,7 @@ void ASTDumper::dumpDecl(const Decl *D)
 
 if (const FullComment *Comment =
 D->getASTContext().getLocalCommentForDeclUncached(D))
-  dumpFullComment(Comment);
+  dumpComment(Comment, Comment);
 
 // Decls within functions are visited by the body.
 if (!isa(*D) && !isa(*D) &&
@@ -2304,12 +2303,6 @@ const char *ASTDumper::getCommandName(un
   return "";
 }
 
-void ASTDumper::dumpFullComment(const FullComment *C) {
-  if (!C)
-return;
-  dumpComment(C, C);
-}
-
 void ASTDumper::dumpComment(const Comment *C, const FullComment *FC) {
   dumpChild([=] {
 if (!C) {
@@ -2547,12 +2540,16 @@ LLVM_DUMP_METHOD void Comment::dump(cons
 void Comment::dump(raw_ostream &OS, const CommandTraits *Traits,
const SourceManager *SM) const {
   const FullComment *FC = dyn_cast(this);
+  if (!FC)
+return;
   ASTDumper D(OS, Traits, SM);
-  D.dumpFullComment(FC);
+  D.dumpComment(FC, FC);
 }
 
 LLVM_DUMP_METHOD void Comment::dumpColor() const {
   const FullComment *FC = dyn_cast(this);
+  if (!FC)
+return;
   ASTDumper D(llvm::errs(), nullptr, nullptr, /*ShowColors*/true);
-  D.dumpFullComment(FC);
+  D.dumpComment(FC, FC);
 }


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


  1   2   3   4   >