[clang-tools-extra] [clang-tidy] add depercation warning for non-whitelisted global options (PR #121057)
Carlos Galvez via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 26 13:50:22 PST 2024
================
@@ -62,16 +62,29 @@ ClangTidyCheck::OptionsView::get(StringRef LocalName) const {
return std::nullopt;
}
+static const llvm::StringSet<> DeprecatedGlobalOptions{
+ "StrictMode",
+ "IgnoreMacros",
+};
+
static ClangTidyOptions::OptionMap::const_iterator
findPriorityOption(const ClangTidyOptions::OptionMap &Options,
StringRef NamePrefix, StringRef LocalName,
- llvm::StringSet<> *Collector) {
+ ClangTidyContext *Context) {
+ llvm::StringSet<> *Collector = Context->getOptionsCollector();
if (Collector) {
Collector->insert((NamePrefix + LocalName).str());
Collector->insert(LocalName);
}
auto IterLocal = Options.find((NamePrefix + LocalName).str());
auto IterGlobal = Options.find(LocalName);
+ // FIXME: temporary solution for deprecation warnings, should be removed
+ // after 22.x.
+ if (IterGlobal != Options.end() &&
+ DeprecatedGlobalOptions.contains(LocalName))
+ Context->configurationDiag(
+ "deprecation global option '%0', please use '%1%0'.")
----------------
carlosgalvezp wrote:
I believe this would be clearer:
```
"global option '%0' is deprecated, please use '%1%0' instead."
```
https://github.com/llvm/llvm-project/pull/121057
More information about the cfe-commits
mailing list