[clang-tools-extra] [clang-tidy] Add user-defined functions to `bugprone-unsafe-functions` check (PR #106350)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 29 09:20:50 PDT 2024
================
@@ -127,57 +139,157 @@ static bool isAnnexKAvailable(std::optional<bool> &CacheVar, Preprocessor *PP,
return CacheVar.value();
}
+static std::vector<UnsafeFunctionsCheck::CheckedFunction>
+ParseCheckedFunctions(StringRef Option, StringRef OptionName,
+ ClangTidyContext *Context) {
+ std::vector<StringRef> Functions = utils::options::parseStringList(Option);
+ std::vector<UnsafeFunctionsCheck::CheckedFunction> Result;
+ Result.reserve(Functions.size());
+
+ for (StringRef Function : Functions) {
+ if (Function.empty()) {
+ continue;
+ }
+
+ auto [Name, Rest] = Function.split(',');
+ auto [Replacement, Reason] = Rest.split(',');
+
+ if (Name.trim().empty()) {
+ Context->configurationDiag("invalid configuration value for option '%0'; "
+ "expected the name of an unsafe function")
+ << OptionName;
+ }
+
+ if (Replacement.trim().empty()) {
+ Context->configurationDiag(
+ "invalid configuration value '%0' for option '%1'; "
+ "expected a replacement function name")
+ << Name.trim() << OptionName;
+ }
----------------
5chmidti wrote:
I think in both cases, we would want to skip this iteration, right? We would add things we know are invalid to the returned vector otherwise.
https://github.com/llvm/llvm-project/pull/106350
More information about the cfe-commits
mailing list