The binary tool only works on working source code, if the source code is
not compilable, don't perform any analysis and edits.
Differential Revision: https://reviews.llvm.org/D153271
}
void EndSourceFile() override {
+ const auto &SM = getCompilerInstance().getSourceManager();
+ if (SM.getDiagnostics().hasUncompilableErrorOccurred()) {
+ llvm::errs()
+ << "Skipping file " << getCurrentFile()
+ << " due to compiler errors. clang-include-cleaner expects to "
+ "work on compilable source code.\n";
+ return;
+ }
+
if (!HTMLReportPath.empty())
writeHTML();
- const auto &SM = getCompilerInstance().getSourceManager();
auto &HS = getCompilerInstance().getPreprocessor().getHeaderSearchInfo();
llvm::StringRef Path =
SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName();