================ @@ -40,11 +40,30 @@ void UncheckedOptionalAccessCheck::registerMatchers(MatchFinder *Finder) { this); } +void UncheckedOptionalAccessCheck::onStartOfTranslationUnit() { + // Reset the flag for each TU. + is_test_tu_ = false; +} + void UncheckedOptionalAccessCheck::check( const MatchFinder::MatchResult &Result) { - if (Result.SourceManager->getDiagnostics().hasUncompilableErrorOccurred()) + // The googletest assertion macros are not currently recognized, so we have + // many false positives in tests. So, do not check functions in a test TU + // if the option ignore_test_tus_ is set. + if ((ignore_test_tus_ && is_test_tu_) || + Result.SourceManager->getDiagnostics().hasUncompilableErrorOccurred()) ---------------- 5chmidti wrote:
Couldn't this be moved to onStartOfTranslationUnit? https://github.com/llvm/llvm-project/pull/115051 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits