Conversation
| if (output && output->type == simplecpp::Output::ERROR && startsWith(output->msg, "#error") && | ||
| (mSettings.userDefines.empty() || mSettings.force)) { |
There was a problem hiding this comment.
This is an AI review. Take it with a grain of salt and feel free to reject it by resolving the comment.
The behavior looks right to me. I tried the test case from the PR via the CLI: --check-config now reports invalidConfiguration for FEATURE=FEATURE, -DFEATURE without --force still gives only the existing preprocessorErrorDirective, and normal analysis is unchanged.
One maintainability concern: (mSettings.userDefines.empty() || mSettings.force) is the negation of showerror in Preprocessor::handleErrors(), and startsWith(output->msg, "#error") repeats the check in Preprocessor::reportOutput(). If one of those is changed later, this will silently start producing duplicates or missing messages. Maybe let the preprocessor tell whether it already reported the #error (for example, a small helper that returns showerror, or a flag/out-parameter from handleErrors()) instead of re-deriving the condition here?
Minor: the location building in invalidConfigurationMessage() (fromNativeSeparators + relativePaths) duplicates Preprocessor::error().
When configuration discovery considers an optional macro without a required platform macro, an active
#errorcan skip that configuration.--check-configcurrently gives no explanation, making the resulting unused-function warning difficult to diagnose. This addresses the requested diagnostic in Trac #6672 comment 5.Report a suppressible
invalidConfigurationinformation message in--check-configfor the#errorfailures otherwise hidden by existing error handling. Include the configuration's user/automatic defines, the original error text, and source/header location. Preserve the existing error for explicit defines without--force, avoiding a duplicate message. Normal analysis and configuration enumeration remain unchanged; this does not automatically infer the required macro or remove the ordinary unused-function diagnostic.Validation on Windows with Clang 22.1.8 and CMake/Ninja:
redundantCopyLocalConstin upstream self-check. That diagnostic was reproduced with the original analyzer and is now absent on the changed test file; all 24TestCppchecktests pass after rebuilding, and Uncrustify 0.80.1 matches. The full-suite/CLI results above cover the unchanged production implementation; upstream checks for the updated head are pending.git diff --checkpasses. Local build used Debug with PCH disabled and serial compilation after Clang crashed on unchanged code in Release/parallel builds. GUI and non-Windows CI were not run locally.Please assign this work to KiritoYG if needed. I would like this diagnostic fix considered under the published $10 bounty schedule, subject to acceptance and the required ticket closure. Please confirm its eligibility and the supported settlement route; GitHub Sponsors is available if accepted. No award or payment is being claimed.