Commit df0fd1c3 authored by Simon Pilgrim's avatar Simon Pilgrim
Browse files

[clangd] Use castAs<> instead of getAs<> to avoid dereference of nullptr

The pointer is dereferenced immediately, so assert the cast is correct instead of returning nullptr
parent 86497026
......@@ -59,9 +59,8 @@ const Type *HeuristicResolver::getPointeeType(const Type *T) const {
if (!T)
return nullptr;
if (T->isPointerType()) {
return T->getAs<PointerType>()->getPointeeType().getTypePtrOrNull();
}
if (T->isPointerType())
return T->castAs<PointerType>()->getPointeeType().getTypePtrOrNull();
// Try to handle smart pointer types.
......
......@@ -147,7 +147,7 @@ HoverInfo::PrintedType printType(QualType QT, ASTContext &ASTCtx,
// FIXME: This doesn't handle composite types that contain a decltype in them.
// We should rather have a printing policy for that.
while (!QT.isNull() && QT->isDecltypeType())
QT = QT->getAs<DecltypeType>()->getUnderlyingType();
QT = QT->castAs<DecltypeType>()->getUnderlyingType();
HoverInfo::PrintedType Result;
llvm::raw_string_ostream OS(Result.Type);
// Special case: if the outer type is a tag type without qualifiers, then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment