Skip to content

Commit

Permalink
Merge branch amd-master into amd-common
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins committed Jan 12, 2019
2 parents 3a4bfca + 9931d0b commit e0d5c12
Show file tree
Hide file tree
Showing 7 changed files with 763 additions and 551 deletions.
99 changes: 99 additions & 0 deletions include/clang/AST/TemplateArgumentVisitor.h
Original file line number Diff line number Diff line change
@@ -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 <template <typename> class Ref, typename ImplClass,
typename RetTy = void, typename... ParamTys>
class Base {
public:
#define REF(CLASS) typename Ref<CLASS>::type
#define DISPATCH(NAME) \
case TemplateArgument::NAME: \
return static_cast<ImplClass *>(this)->Visit##NAME##TemplateArgument( \
TA, std::forward<ParamTys>(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<ParamTys>(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 <typename ImplClass, typename RetTy = void, typename... ParamTys>
class TemplateArgumentVisitor
: public templateargumentvisitor::Base<std::add_lvalue_reference, ImplClass,
RetTy, ParamTys...> {};

/// A simple visitor class that helps create template argument visitors.
///
/// This class preserves constness of TemplateArgument references (see also
/// TemplateArgumentVisitor).
template <typename ImplClass, typename RetTy = void, typename... ParamTys>
class ConstTemplateArgumentVisitor
: public templateargumentvisitor::Base<llvm::make_const_ref, ImplClass,
RetTy, ParamTys...> {};

} // namespace clang

#endif // LLVM_CLANG_AST_TEMPLATEARGUMENTVISITOR_H
77 changes: 74 additions & 3 deletions include/clang/AST/TextNodeDumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#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 {

Expand Down Expand Up @@ -123,7 +125,9 @@ class TextNodeDumper
: public TextTreeStructure,
public comments::ConstCommentVisitor<TextNodeDumper, void,
const comments::FullComment *>,
public ConstAttrVisitor<TextNodeDumper> {
public ConstAttrVisitor<TextNodeDumper>,
public ConstTemplateArgumentVisitor<TextNodeDumper>,
public ConstStmtVisitor<TextNodeDumper> {
raw_ostream &OS;
const bool ShowColors;

Expand All @@ -150,6 +154,11 @@ class TextNodeDumper

void Visit(const Attr *A);

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);
Expand All @@ -158,9 +167,8 @@ class TextNodeDumper
void dumpBareDeclRef(const Decl *D);
void dumpName(const NamedDecl *ND);
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 *);
Expand All @@ -186,6 +194,69 @@ class TextNodeDumper

// Implements Visit methods for Attrs.
#include "clang/AST/AttrTextNodeDump.inc"

void VisitNullTemplateArgument(const TemplateArgument &TA);
void VisitTypeTemplateArgument(const TemplateArgument &TA);
void VisitDeclarationTemplateArgument(const TemplateArgument &TA);
void VisitNullPtrTemplateArgument(const TemplateArgument &TA);
void VisitIntegralTemplateArgument(const TemplateArgument &TA);
void VisitTemplateTemplateArgument(const TemplateArgument &TA);
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);

private:
void dumpCXXTemporary(const CXXTemporary *Temporary);
};

} // namespace clang
Expand Down
Loading

0 comments on commit e0d5c12

Please sign in to comment.