[sema] Check the result of getAsCXXRecordDecl() to fix the build

I'm not 100% sure what should happen here to find the real
CXXRecordDecl.