@@ -6,7 +6,7 @@ NOTICE: Adobe permits you to use, modify, and distribute this file in
6
6
accordance with the terms of the Adobe license agreement accompanying
7
7
it. If you have received this file from a source other than Adobe,
8
8
then your use, modification, or distribution of it requires the prior
9
- written permission of Adobe.
9
+ written permission of Adobe.
10
10
*/
11
11
12
12
// identity
@@ -62,8 +62,11 @@ class FindConstructor : public RecursiveASTVisitor<FindConstructor> {
62
62
63
63
class FindStaticMembers : public RecursiveASTVisitor <FindStaticMembers> {
64
64
public:
65
- FindStaticMembers (ASTContext* context) : context(context), static_members(hyde::json::object()) {}
65
+ FindStaticMembers (ASTContext* context, hyde::ToolAccessFilter access_filter)
66
+ : context(context), _access_filter(access_filter), static_members(hyde::json::object()) {}
66
67
bool VisitVarDecl (const VarDecl* d) {
68
+ if (!AccessCheck (_access_filter, d->getAccess ())) return true ;
69
+
67
70
auto storage = d->getStorageClass ();
68
71
// TODO(Wyles): Do we want to worry about other kinds of storage?
69
72
if (storage == SC_Static) {
@@ -80,6 +83,7 @@ class FindStaticMembers : public RecursiveASTVisitor<FindStaticMembers> {
80
83
81
84
private:
82
85
ASTContext* context = nullptr ;
86
+ hyde::ToolAccessFilter _access_filter;
83
87
hyde::json static_members;
84
88
};
85
89
@@ -92,6 +96,8 @@ void ClassInfo::run(const MatchFinder::MatchResult& Result) {
92
96
93
97
if (!PathCheck (_paths, clas, Result.Context )) return ;
94
98
99
+ if (!AccessCheck (_access_filter, clas->getAccess ())) return ;
100
+
95
101
if (!clas->isCompleteDefinition ()) return ; // e.g., a forward declaration.
96
102
97
103
if (clas->isLambda ()) return ;
@@ -100,8 +106,7 @@ void ClassInfo::run(const MatchFinder::MatchResult& Result) {
100
106
101
107
// e.g., compiler-injected class specializations not caught by the above
102
108
if (auto s = llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(clas)) {
103
- if (!s->getTypeAsWritten ())
104
- return ;
109
+ if (!s->getTypeAsWritten ()) return ;
105
110
}
106
111
107
112
json info = DetailCXXRecordDecl (Result.Context , clas);
@@ -116,20 +121,24 @@ void ClassInfo::run(const MatchFinder::MatchResult& Result) {
116
121
dtor_finder.TraverseDecl (const_cast <Decl*>(static_cast <const Decl*>(clas)));
117
122
if (!dtor_finder) info[" dtor" ] = " unspecified" ;
118
123
119
- FindStaticMembers static_finder (Result.Context );
124
+ FindStaticMembers static_finder (Result.Context , _access_filter );
120
125
static_finder.TraverseDecl (const_cast <Decl*>(static_cast <const Decl*>(clas)));
121
126
122
127
if (const auto & template_decl = clas->getDescribedClassTemplate ()) {
123
128
info[" template_parameters" ] = GetTemplateParameters (Result.Context , template_decl);
124
129
}
125
130
126
131
for (const auto & method : clas->methods ()) {
132
+ if (!AccessCheck (_access_filter, method->getAccess ())) continue ;
133
+
127
134
json methodInfo = DetailFunctionDecl (Result.Context , method);
128
135
info[" methods" ][static_cast <const std::string&>(methodInfo[" short_name" ])].push_back (
129
136
std::move (methodInfo));
130
137
}
131
138
132
139
for (const auto & decl : clas->decls ()) {
140
+ if (!AccessCheck (_access_filter, decl->getAccess ())) continue ;
141
+
133
142
auto * function_template_decl = dyn_cast<FunctionTemplateDecl>(decl);
134
143
if (!function_template_decl) continue ;
135
144
json methodInfo =
@@ -139,12 +148,16 @@ void ClassInfo::run(const MatchFinder::MatchResult& Result) {
139
148
}
140
149
141
150
for (const auto & field : clas->fields ()) {
151
+ if (!AccessCheck (_access_filter, field->getAccess ())) continue ;
152
+
142
153
json fieldInfo = StandardDeclInfo (Result.Context , field);
143
154
fieldInfo[" type" ] = hyde::to_string (Result.Context , field->getType ());
144
155
info[" fields" ][static_cast <const std::string&>(fieldInfo[" qualified_name" ])] =
145
156
fieldInfo; // can't move this into place for some reason.
146
157
}
158
+
147
159
hyde::json static_members = static_finder.get_results ();
160
+
148
161
if (static_members.size () > 0 ) {
149
162
if (info[" fields" ].size () == 0 ) {
150
163
info[" fields" ] = hyde::json::object ();
@@ -158,6 +171,8 @@ void ClassInfo::run(const MatchFinder::MatchResult& Result) {
158
171
typedef_iterator (CXXRecordDecl::decl_iterator ()));
159
172
for (const auto & type_def : typedefs) {
160
173
// REVISIT (fbrereto) : Refactor this block and TypedefInfo::run's.
174
+ if (!AccessCheck (_access_filter, type_def->getAccess ())) continue ;
175
+
161
176
json typedefInfo = StandardDeclInfo (Result.Context , type_def);
162
177
typedefInfo[" type" ] = hyde::to_string (Result.Context , type_def->getUnderlyingType ());
163
178
@@ -170,10 +185,13 @@ void ClassInfo::run(const MatchFinder::MatchResult& Result) {
170
185
typealias_iterator (CXXRecordDecl::decl_iterator ()));
171
186
for (const auto & type_alias : typealiases) {
172
187
// REVISIT (fbrereto) : Refactor this block and TypeAliasInfo::run's.
188
+ if (!AccessCheck (_access_filter, type_alias->getAccess ())) continue ;
189
+
173
190
json typealiasInfo = StandardDeclInfo (Result.Context , type_alias);
174
191
typealiasInfo[" type" ] = hyde::to_string (Result.Context , type_alias->getUnderlyingType ());
175
192
if (auto template_decl = type_alias->getDescribedAliasTemplate ()) {
176
- typealiasInfo[" template_parameters" ] = GetTemplateParameters (Result.Context , template_decl);
193
+ typealiasInfo[" template_parameters" ] =
194
+ GetTemplateParameters (Result.Context , template_decl);
177
195
}
178
196
179
197
info[" typealiases" ].push_back (std::move (typealiasInfo));
0 commit comments