lebedev.ri added a comment. This certainly needs more tests: macros, `-x C`, ???
================ Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:26-29 + if(!MatchedDecl->isLocalVarDecl()) + return; + if(MatchedDecl->hasInit()) + return; ---------------- Can make these proper `AST_MATCHER` and do this in `registerMatchers()`. ================ Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:32-35 + if(varName.empty() || varName.front() == '_') { + // Some standard library methods such as "be64toh" are implemented + // as macros that internally use variable names + // like __v. Do not touch those. ---------------- This feels brittle. ================ Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:41-48 + replacement = "=0"; + } else if(typePtr->isFloatingType()) { + replacement = "=(0.0/0.0)"; // NaN without needing #includes + } else if(typePtr->isPointerType()) { + if(getLangOpts().CPlusPlus) { + replacement = "=nullptr"; + } else { ---------------- should be `var = <init>;` ================ Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:43 + } else if(typePtr->isFloatingType()) { + replacement = "=(0.0/0.0)"; // NaN without needing #includes + } else if(typePtr->isPointerType()) { ---------------- I'm pretty sure there's simple utility function that can insert include. Repository: rCTE Clang Tools Extra CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64671/new/ https://reviews.llvm.org/D64671 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits