Coverage Report

Created: 2018-09-21 05:35

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/AST/CommentVisitor.h
Line
Count
Source (jump to first uncovered line)
1
//===- CommentVisitor.h - Visitor for Comment subclasses --------*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLVM_CLANG_AST_COMMENTVISITOR_H
11
#define LLVM_CLANG_AST_COMMENTVISITOR_H
12
13
#include "clang/AST/Comment.h"
14
#include "llvm/Support/ErrorHandling.h"
15
16
namespace clang {
17
namespace comments {
18
19
template <typename T> struct make_ptr { using type = T *; };
20
template <typename T> struct make_const_ptr { using type = const T *; };
21
22
template<template <typename> class Ptr, typename ImplClass, typename RetTy=void>
23
class CommentVisitorBase {
24
public:
25
#define PTR(CLASS) typename Ptr<CLASS>::type
26
#define DISPATCH(NAME, CLASS) \
27
606
 return static_cast<ImplClass*>(this)->visit ## NAME(static_cast<PTR(CLASS)>(C))
28
29
513
  RetTy visit(PTR(Comment) C) {
30
513
    if (!C)
31
0
      return RetTy();
32
513
33
513
    switch (C->getCommentKind()) {
34
513
    
default: 0
llvm_unreachable0
("Unknown comment kind!");
35
513
#define ABSTRACT_COMMENT(COMMENT)
36
513
#define COMMENT(CLASS, PARENT) \
37
513
    case Comment::CLASS##Kind: 
DISPATCH356
(CLASS, CLASS);
38
513
#include 
"clang/AST/CommentNodes.inc"10
39
513
#undef ABSTRACT_COMMENT
40
513
#undef COMMENT
41
513
    }
42
513
  }
43
44
  // If the derived class does not implement a certain Visit* method, fall back
45
  // on Visit* method for the superclass.
46
146
#define ABSTRACT_COMMENT(COMMENT) COMMENT
47
#define COMMENT(CLASS, PARENT) \
48
250
  RetTy visit ## CLASS(PTR(CLASS) C) { DISPATCH(PARENT, PARENT); }
ASTDumper.cpp:clang::comments::CommentVisitorBase<clang::comments::make_const_ptr, (anonymous namespace)::ASTDumper, void>::visitParagraphComment(clang::comments::ParagraphComment const*)
Line
Count
Source
48
146
  RetTy visit ## CLASS(PTR(CLASS) C) { DISPATCH(PARENT, PARENT); }
ASTDumper.cpp:clang::comments::CommentVisitorBase<clang::comments::make_const_ptr, (anonymous namespace)::ASTDumper, void>::visitFullComment(clang::comments::FullComment const*)
Line
Count
Source
48
104
  RetTy visit ## CLASS(PTR(CLASS) C) { DISPATCH(PARENT, PARENT); }
49
#include "clang/AST/CommentNodes.inc"
50
#undef ABSTRACT_COMMENT
51
#undef COMMENT
52
53
250
  RetTy visitComment(PTR(Comment) C) { return RetTy(); }
54
55
#undef PTR
56
#undef DISPATCH
57
};
58
59
template<typename ImplClass, typename RetTy=void>
60
class CommentVisitor :
61
    public CommentVisitorBase<make_ptr, ImplClass, RetTy> {};
62
63
template<typename ImplClass, typename RetTy=void>
64
class ConstCommentVisitor :
65
    public CommentVisitorBase<make_const_ptr, ImplClass, RetTy> {};
66
67
} // namespace comments
68
} // namespace clang
69
70
#endif // LLVM_CLANG_AST_COMMENTVISITOR_H