@@ -203,7 +203,7 @@ bool Indexer::TraverseCallExpr(CallExpr* CE) {
203203}
204204
205205bool Indexer::VisitDeclRefExpr (const DeclRefExpr* DeclRef) {
206- if (const auto * Func = dyn_cast <FunctionDecl>(DeclRef->getDecl ()))
206+ if (const auto * Func = dyn_cast_if_present <FunctionDecl>(DeclRef->getDecl ()))
207207 EmitReference (DeclRef->getBeginLoc (), DeclRef->getDecl (), EntityKindFunction,
208208 InCallee ? RefKindCall : RefKindTakesAddr);
209209 return true ;
@@ -246,25 +246,25 @@ bool Indexer::VisitTypedefType(const TypedefType* T) {
246246 return true ;
247247 EmitReference (TypeRefingLocation, T->getDecl (), EntityKindTypedef, RefKindUses);
248248 // If it's a struct typedef, also note the struct use.
249- if (const auto * Tag = dyn_cast <TagType>(T->getCanonicalTypeInternal ().getTypePtr ()))
249+ if (const auto * Tag = dyn_cast_if_present <TagType>(T->getCanonicalTypeInternal ().getTypePtr ()))
250250 VisitTagType (Tag);
251251 return true ;
252252}
253253
254254bool Indexer::VisitMemberExpr (const MemberExpr* E) {
255255 auto * Record = E->getBase ()->getType ()->getAsRecordDecl ();
256- if (auto * Ptr = dyn_cast <PointerType>(E->getBase ()->getType ()))
256+ if (auto * Ptr = dyn_cast_if_present <PointerType>(E->getBase ()->getType ()))
257257 Record = Ptr->getPointeeType ()->getAsRecordDecl ();
258258 if (!Record)
259259 return true ;
260260 const std::string Field = Record->getNameAsString () + " ::" + E->getMemberDecl ()->getNameAsString ();
261261 const char * RefKind = RefKindRead;
262262 const Stmt* P = GetParent (E);
263- if (auto * BO = dyn_cast <BinaryOperator>(P)) {
263+ if (auto * BO = dyn_cast_if_present <BinaryOperator>(P)) {
264264 if (E == BO->getLHS () && (BO->isAssignmentOp () || BO->isCompoundAssignmentOp () || BO->isShiftAssignOp ()))
265265 RefKind = RefKindWrite;
266266 }
267- if (auto * UO = dyn_cast <UnaryOperator>(P))
267+ if (auto * UO = dyn_cast_if_present <UnaryOperator>(P))
268268 RefKind = RefKindTakesAddr;
269269 EmitReference (E->getMemberLoc (), Field, EntityKindField, RefKind);
270270 return true ;
0 commit comments