@@ -151,8 +151,22 @@ void DeclInfo::fill() {
151
151
TemplateParameters = NULL ;
152
152
153
153
if (!ThisDecl) {
154
- // Defaults are OK.
155
- } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ThisDecl)) {
154
+ // If there is no declaration, the defaults is our only guess.
155
+ IsFilled = true ;
156
+ return ;
157
+ }
158
+
159
+ Decl::Kind K = ThisDecl->getKind ();
160
+ switch (K) {
161
+ default :
162
+ // Defaults are should be good for declarations we don't handle explicitly.
163
+ break ;
164
+ case Decl::Function:
165
+ case Decl::CXXMethod:
166
+ case Decl::CXXConstructor:
167
+ case Decl::CXXDestructor:
168
+ case Decl::CXXConversion: {
169
+ const FunctionDecl *FD = cast<FunctionDecl>(ThisDecl);
156
170
Kind = FunctionKind;
157
171
ParamVars = ArrayRef<const ParmVarDecl *>(FD->param_begin (),
158
172
FD->getNumParams ());
@@ -164,53 +178,78 @@ void DeclInfo::fill() {
164
178
FD->getTemplateParameterList (NumLists - 1 );
165
179
}
166
180
167
- if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
181
+ if (K == Decl::CXXMethod) {
182
+ const CXXMethodDecl *MD = cast<CXXMethodDecl>(ThisDecl);
168
183
IsInstanceMethod = MD->isInstance ();
169
184
IsClassMethod = !IsInstanceMethod;
170
185
}
171
- } else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(ThisDecl)) {
186
+ break ;
187
+ }
188
+ case Decl::ObjCMethod: {
189
+ const ObjCMethodDecl *MD = cast<ObjCMethodDecl>(ThisDecl);
172
190
Kind = FunctionKind;
173
191
ParamVars = ArrayRef<const ParmVarDecl *>(MD->param_begin (),
174
192
MD->param_size ());
175
193
IsInstanceMethod = MD->isInstanceMethod ();
176
194
IsClassMethod = !IsInstanceMethod;
177
- } else if (const FunctionTemplateDecl *FTD =
178
- dyn_cast<FunctionTemplateDecl>(ThisDecl)) {
195
+ break ;
196
+ }
197
+ case Decl::FunctionTemplate: {
198
+ const FunctionTemplateDecl *FTD = cast<FunctionTemplateDecl>(ThisDecl);
179
199
Kind = FunctionKind;
180
200
IsTemplateDecl = true ;
181
201
const FunctionDecl *FD = FTD->getTemplatedDecl ();
182
202
ParamVars = ArrayRef<const ParmVarDecl *>(FD->param_begin (),
183
203
FD->getNumParams ());
184
204
TemplateParameters = FTD->getTemplateParameters ();
185
- } else if (const ClassTemplateDecl *CTD =
186
- dyn_cast<ClassTemplateDecl>(ThisDecl)) {
205
+ break ;
206
+ }
207
+ case Decl::ClassTemplate: {
208
+ const ClassTemplateDecl *CTD = cast<ClassTemplateDecl>(ThisDecl);
187
209
Kind = ClassKind;
188
210
IsTemplateDecl = true ;
189
211
TemplateParameters = CTD->getTemplateParameters ();
190
- } else if (const ClassTemplatePartialSpecializationDecl *CTPSD =
191
- dyn_cast<ClassTemplatePartialSpecializationDecl>(ThisDecl)) {
212
+ break ;
213
+ }
214
+ case Decl::ClassTemplatePartialSpecialization: {
215
+ const ClassTemplatePartialSpecializationDecl *CTPSD =
216
+ cast<ClassTemplatePartialSpecializationDecl>(ThisDecl);
192
217
Kind = ClassKind;
193
218
IsTemplateDecl = true ;
194
219
IsTemplatePartialSpecialization = true ;
195
220
TemplateParameters = CTPSD->getTemplateParameters ();
196
- } else if (isa<ClassTemplateSpecializationDecl>(ThisDecl)) {
221
+ break ;
222
+ }
223
+ case Decl::ClassTemplateSpecialization:
197
224
Kind = ClassKind;
198
225
IsTemplateDecl = true ;
199
226
IsTemplateSpecialization = true ;
200
- } else if (isa<RecordDecl>(ThisDecl)) {
227
+ break ;
228
+ case Decl::Record:
201
229
Kind = ClassKind;
202
- } else if (isa<VarDecl>(ThisDecl) || isa<FieldDecl>(ThisDecl)) {
230
+ break ;
231
+ case Decl::Var:
232
+ case Decl::Field:
233
+ case Decl::ObjCIvar:
234
+ case Decl::ObjCAtDefsField:
203
235
Kind = VariableKind;
204
- } else if (isa<NamespaceDecl>(ThisDecl)) {
236
+ break ;
237
+ case Decl::Namespace:
205
238
Kind = NamespaceKind;
206
- } else if (isa<TypedefNameDecl>(ThisDecl)) {
239
+ break ;
240
+ case Decl::Typedef:
241
+ case Decl::TypeAlias:
207
242
Kind = TypedefKind;
208
- } else if (const TypeAliasTemplateDecl *TAT =
209
- dyn_cast<TypeAliasTemplateDecl>(ThisDecl)) {
243
+ break ;
244
+ case Decl::TypeAliasTemplate: {
245
+ const TypeAliasTemplateDecl *TAT = cast<TypeAliasTemplateDecl>(ThisDecl);
210
246
Kind = TypedefKind;
211
247
IsTemplateDecl = true ;
212
248
TemplateParameters = TAT->getTemplateParameters ();
249
+ break ;
213
250
}
251
+ }
252
+
214
253
IsFilled = true ;
215
254
}
216
255
0 commit comments