| 246 | } |
| 247 | |
| 248 | bool PreprocessorCallback::FileNotFound(llvm::StringRef FileName, llvm::SmallVectorImpl<char> &RecoveryPath) |
| 249 | { |
| 250 | if (!recoverIncludePath) |
| 251 | return false; |
| 252 | clang::SourceLocation currentLoc = static_cast<clang::Lexer *>(PP.getCurrentLexer())->getSourceLocation(); |
| 253 | auto &SM = annotator.getSourceMgr(); |
| 254 | const clang::FileEntry* entry = SM.getFileEntryForID(SM.getFileID(currentLoc)); |
| 255 | if (!entry || llvm::StringRef(entry->getName()).empty()) |
| 256 | return false; |
| 257 | std::string recovery = annotator.projectManager.includeRecovery(FileName, entry->getName()); |
| 258 | if (recovery.empty() || !llvm::StringRef(recovery).endswith(FileName)) |
| 259 | return false; |
| 260 | RecoveryPath.clear(); |
| 261 | RecoveryPath.append(recovery.begin(), recovery.begin() + recovery.size() - FileName.size()); |
| 262 | currentLoc.dump(SM); |
| 263 | llvm::errs() << " WARNING: File not found '" << FileName << "'. Recovering using " |
| 264 | << llvm::StringRef(RecoveryPath.data(), RecoveryPath.size()) << "\n"; |
| 265 | |
| 266 | return true; |
| 267 | } |
| 268 | |
| 269 | |
| 270 | void PreprocessorCallback::InclusionDirective(clang::SourceLocation HashLoc, const clang::Token& IncludeTok, |
nothing calls this directly
no test coverage detected