[clang-tools-extra] [NFC] Fix uninitialized pointer field. (PR #117173)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 21 07:44:51 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tools-extra
Author: Zahira Ammarguellat (zahiraam)
<details>
<summary>Changes</summary>
Non-static class member `PP` is not initialized in this constructor nor in any functions that it calls.
---
Full diff: https://github.com/llvm/llvm-project/pull/117173.diff
1 Files Affected:
- (modified) clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp (+2-1)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
index 9161c0e702a28c..4f240982250741 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
@@ -23,7 +23,7 @@ AST_MATCHER(StringLiteral, isOrdinary) { return Node.isOrdinary(); }
} // namespace
UseStdPrintCheck::UseStdPrintCheck(StringRef Name, ClangTidyContext *Context)
- : ClangTidyCheck(Name, Context),
+ : ClangTidyCheck(Name, Context), PP(nullptr),
StrictMode(Options.getLocalOrGlobal("StrictMode", false)),
PrintfLikeFunctions(utils::options::parseStringList(
Options.get("PrintfLikeFunctions", ""))),
@@ -131,6 +131,7 @@ void UseStdPrintCheck::check(const MatchFinder::MatchResult &Result) {
utils::FormatStringConverter::Configuration ConverterConfig;
ConverterConfig.StrictMode = StrictMode;
ConverterConfig.AllowTrailingNewlineRemoval = true;
+ assert(PP && "Preprocessor should be set by registerPPCallbacks");
utils::FormatStringConverter Converter(
Result.Context, Printf, FormatArgOffset, ConverterConfig, getLangOpts(),
*Result.SourceManager, *PP);
``````````
</details>
https://github.com/llvm/llvm-project/pull/117173
More information about the cfe-commits
mailing list