11
11
12
12
#include " Commands.hpp"
13
13
#include " utility.hpp"
14
- #include " ast/ Serialize.hpp"
15
- #include " ast/ FrontendAction.hpp"
14
+ #include " Serialize.hpp"
15
+ #include " FrontendAction.hpp"
16
16
#include < mrdox/Corpus.hpp>
17
17
#include < clang/Index/USRGeneration.h>
18
18
#include < clang/AST/RecursiveASTVisitor.h>
19
19
#include < llvm/ADT/StringExtras.h>
20
20
#include < llvm/Support/Error.h>
21
21
#include < llvm/Support/Path.h>
22
22
23
- //
24
- // This file implements the Mapper piece of the clang-doc tool. It implements
25
- // a RecursiveASTVisitor to look at each declaration and populate the info
26
- // into the internal representation. Each seen declaration is serialized to
27
- // to bitcode and written out to the ExecutionContext as a KV pair where the
28
- // key is the declaration's USR and the value is the serialized bitcode.
29
- //
30
-
31
23
namespace clang {
32
24
namespace mrdox {
33
25
34
26
// ------------------------------------------------
35
27
36
- /* An instance of Visitor runs on one translation unit.
37
- */
28
+ // An instance of Visitor runs on one translation unit.
38
29
void
39
30
Visitor::
40
31
HandleTranslationUnit (
@@ -45,13 +36,15 @@ HandleTranslationUnit(
45
36
llvm::Optional<llvm::StringRef> filePath =
46
37
Context.getSourceManager ().getNonBuiltinFilenameForID (
47
38
Context.getSourceManager ().getMainFileID ());
48
- if (filePath)
49
- {
50
- llvm::SmallString<0 > s (*filePath);
51
- convert_to_slash (s);
52
- if (config_.shouldVisitTU (s))
53
- TraverseDecl (Context.getTranslationUnitDecl ());
54
- }
39
+ if (! filePath)
40
+ return ;
41
+
42
+ llvm::SmallString<0 > s (*filePath);
43
+ convert_to_slash (s);
44
+ if (! config_.shouldVisitTU (s))
45
+ return ;
46
+
47
+ TraverseDecl (Context.getTranslationUnitDecl ());
55
48
}
56
49
57
50
template <typename T>
@@ -123,21 +116,21 @@ mapDecl(T const* D)
123
116
// VFALCO is this right?
124
117
bool const IsFileInRootDir = true ;
125
118
126
- auto I = buildInfoPair (
127
- D,
119
+ Serializer sr (
128
120
getLine (D, D->getASTContext ()),
129
121
filePath,
130
122
IsFileInRootDir,
131
- ! config_. includePrivate () ,
123
+ config_,
132
124
R_);
125
+ auto I = sr.buildInfoPair (D);
133
126
134
127
// A null in place of I indicates that the
135
128
// serializer is skipping this decl for some
136
129
// reason (e.g. we're only reporting public decls).
137
130
if (I.first )
138
- Corpus::reportResult (ex_, *I.first );
131
+ Corpus::reportResult (ex_, I. first -> USR , serialize ( *I.first ) );
139
132
if (I.second )
140
- Corpus::reportResult (ex_, *I.second );
133
+ Corpus::reportResult (ex_, I. second -> USR , serialize ( *I.second ) );
141
134
142
135
return true ;
143
136
}
0 commit comments