Use SourceManager::translateFile() to check if file is loaded (thanks Axel)