[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen
Csaba Dabis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 29 10:42:42 PDT 2018
Charusso updated this revision to Diff 140288.
Charusso added a comment.
Fixed the unseen diff issues, removed redundant parentheses, the class got a private part.
https://reviews.llvm.org/D45050
Files:
clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
clang-tidy/bugprone/NotNullTerminatedResultCheck.h
docs/ReleaseNotes.rst
Index: docs/ReleaseNotes.rst
===================================================================
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -65,9 +65,6 @@
Finds function calls where ``strlen`` or ``wcslen`` passed as argument and
cause a not null-terminated result.
-- The 'misc-incorrect-roundings' check was renamed to `bugprone-incorrect-roundings
- <http://clang.llvm.org/extra/clang-tidy/checks/bugprone-incorrect-roundings.html>`_
-
- New module ``zircon`` for checks related to Fuchsia's Zircon kernel.
- New `bugprone-throw-keyword-missing
Index: clang-tidy/bugprone/NotNullTerminatedResultCheck.h
===================================================================
--- clang-tidy/bugprone/NotNullTerminatedResultCheck.h
+++ clang-tidy/bugprone/NotNullTerminatedResultCheck.h
@@ -27,6 +27,7 @@
: ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+private:
void memAllocFuncFix(StringRef Name,
const ast_matchers::MatchFinder::MatchResult &Result);
void memHandlerFuncFix(StringRef Name,
Index: clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
===================================================================
--- clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
+++ clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
@@ -1,3 +1,12 @@
+//===------------- NotNullTerminatedResultCheck.cpp - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
#include "NotNullTerminatedResultCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -49,7 +58,7 @@
const auto StrLenArgStr = exprToStr(
Result.Nodes.getNodeAs<CallExpr>("length-call")->getArg(0), Result);
- return (StrLenArgStr == LHSStr || StrLenArgStr == RHSStr);
+ return StrLenArgStr == LHSStr || StrLenArgStr == RHSStr;
}
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45050.140288.patch
Type: text/x-patch
Size: 2214 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180329/78bc3ba3/attachment-0001.bin>
More information about the cfe-commits
mailing list