-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350958 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
8 changed files
with
195 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <template <typename> class Ptr, typename ImplClass, | ||
typename RetTy = void, class... ParamTys> | ||
class Base { | ||
public: | ||
#define PTR(CLASS) typename Ptr<CLASS>::type | ||
#define DISPATCH(NAME) \ | ||
return static_cast<ImplClass *>(this)->Visit##NAME(static_cast<PTR(NAME)>(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 <typename ImplClass, typename RetTy = void, typename... ParamTys> | ||
class AttrVisitor : public attrvisitor::Base<std::add_pointer, ImplClass, RetTy, | ||
ParamTys...> {}; | ||
|
||
/// A simple visitor class that helps create attribute visitors. | ||
/// | ||
/// This class preserves constness of Attr pointers (see also | ||
/// AttrVisitor). | ||
template <typename ImplClass, typename RetTy = void, typename... ParamTys> | ||
class ConstAttrVisitor | ||
: public attrvisitor::Base<llvm::make_const_ptr, ImplClass, RetTy, | ||
ParamTys...> {}; | ||
|
||
} // namespace clang | ||
|
||
#endif // LLVM_CLANG_AST_ATTRVISITOR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.