[llvm-branch-commits] [cfe-branch] r322550 - Merging r321933:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jan 16 04:58:37 PST 2018
Author: hans
Date: Tue Jan 16 04:58:37 2018
New Revision: 322550
URL: http://llvm.org/viewvc/llvm-project?rev=322550&view=rev
Log:
Merging r321933:
------------------------------------------------------------------------
r321933 | xazax | 2018-01-06 02:51:00 -0800 (Sat, 06 Jan 2018) | 4 lines
[analyzer] Fix some check's output plist not containing the check name
Differential Revision: https://reviews.llvm.org/D41538
------------------------------------------------------------------------
Modified:
cfe/branches/release_60/ (props changed)
cfe/branches/release_60/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
cfe/branches/release_60/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/branches/release_60/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
cfe/branches/release_60/test/Analysis/malloc.c
Propchange: cfe/branches/release_60/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 16 04:58:37 2018
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:322518
+/cfe/trunk:321933,322518
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_60/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_60/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h?rev=322550&r1=322549&r2=322550&view=diff
==============================================================================
--- cfe/branches/release_60/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h (original)
+++ cfe/branches/release_60/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h Tue Jan 16 04:58:37 2018
@@ -32,27 +32,39 @@ private:
const CheckName Check;
const std::string Name;
const std::string Category;
- bool SuppressonSink;
+ const CheckerBase *Checker;
+ bool SuppressOnSink;
virtual void anchor();
+
public:
- BugType(class CheckName check, StringRef name, StringRef cat)
- : Check(check), Name(name), Category(cat), SuppressonSink(false) {}
- BugType(const CheckerBase *checker, StringRef name, StringRef cat)
- : Check(checker->getCheckName()), Name(name), Category(cat),
- SuppressonSink(false) {}
- virtual ~BugType() {}
+ BugType(CheckName Check, StringRef Name, StringRef Cat)
+ : Check(Check), Name(Name), Category(Cat), Checker(nullptr),
+ SuppressOnSink(false) {}
+ BugType(const CheckerBase *Checker, StringRef Name, StringRef Cat)
+ : Check(Checker->getCheckName()), Name(Name), Category(Cat),
+ Checker(Checker), SuppressOnSink(false) {}
+ virtual ~BugType() = default;
- // FIXME: Should these be made strings as well?
StringRef getName() const { return Name; }
StringRef getCategory() const { return Category; }
- StringRef getCheckName() const { return Check.getName(); }
+ StringRef getCheckName() const {
+ // FIXME: This is a workaround to ensure that the correct check name is used
+ // The check names are set after the constructors are run.
+ // In case the BugType object is initialized in the checker's ctor
+ // the Check field will be empty. To circumvent this problem we use
+ // CheckerBase whenever it is possible.
+ StringRef CheckName =
+ Checker ? Checker->getCheckName().getName() : Check.getName();
+ assert(!CheckName.empty() && "Check name is not set properly.");
+ return CheckName;
+ }
/// isSuppressOnSink - Returns true if bug reports associated with this bug
/// type should be suppressed if the end node of the report is post-dominated
/// by a sink node.
- bool isSuppressOnSink() const { return SuppressonSink; }
- void setSuppressOnSink(bool x) { SuppressonSink = x; }
+ bool isSuppressOnSink() const { return SuppressOnSink; }
+ void setSuppressOnSink(bool x) { SuppressOnSink = x; }
virtual void FlushReports(BugReporter& BR);
};
@@ -74,7 +86,7 @@ public:
StringRef getDescription() const { return desc; }
};
-} // end GR namespace
+} // end ento namespace
} // end clang namespace
#endif
Modified: cfe/branches/release_60/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_60/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=322550&r1=322549&r2=322550&view=diff
==============================================================================
--- cfe/branches/release_60/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/branches/release_60/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Tue Jan 16 04:58:37 2018
@@ -2900,8 +2900,13 @@ void ento::registerNewDeleteLeaksChecker
mgr.getCurrentCheckName();
// We currently treat NewDeleteLeaks checker as a subchecker of NewDelete
// checker.
- if (!checker->ChecksEnabled[MallocChecker::CK_NewDeleteChecker])
+ if (!checker->ChecksEnabled[MallocChecker::CK_NewDeleteChecker]) {
checker->ChecksEnabled[MallocChecker::CK_NewDeleteChecker] = true;
+ // FIXME: This does not set the correct name, but without this workaround
+ // no name will be set at all.
+ checker->CheckNames[MallocChecker::CK_NewDeleteChecker] =
+ mgr.getCurrentCheckName();
+ }
}
#define REGISTER_CHECKER(name) \
Modified: cfe/branches/release_60/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_60/lib/StaticAnalyzer/Checkers/ValistChecker.cpp?rev=322550&r1=322549&r2=322550&view=diff
==============================================================================
--- cfe/branches/release_60/lib/StaticAnalyzer/Checkers/ValistChecker.cpp (original)
+++ cfe/branches/release_60/lib/StaticAnalyzer/Checkers/ValistChecker.cpp Tue Jan 16 04:58:37 2018
@@ -64,7 +64,7 @@ private:
CheckerContext &C) const;
void reportLeakedVALists(const RegionVector &LeakedVALists, StringRef Msg1,
StringRef Msg2, CheckerContext &C, ExplodedNode *N,
- bool ForceReport = false) const;
+ bool ReportUninit = false) const;
void checkVAListStartCall(const CallEvent &Call, CheckerContext &C,
bool IsCopy) const;
@@ -267,15 +267,19 @@ void ValistChecker::reportUninitializedA
void ValistChecker::reportLeakedVALists(const RegionVector &LeakedVALists,
StringRef Msg1, StringRef Msg2,
CheckerContext &C, ExplodedNode *N,
- bool ForceReport) const {
+ bool ReportUninit) const {
if (!(ChecksEnabled[CK_Unterminated] ||
- (ChecksEnabled[CK_Uninitialized] && ForceReport)))
+ (ChecksEnabled[CK_Uninitialized] && ReportUninit)))
return;
for (auto Reg : LeakedVALists) {
if (!BT_leakedvalist) {
- BT_leakedvalist.reset(new BugType(CheckNames[CK_Unterminated],
- "Leaked va_list",
- categories::MemoryError));
+ // FIXME: maybe creating a new check name for this type of bug is a better
+ // solution.
+ BT_leakedvalist.reset(
+ new BugType(CheckNames[CK_Unterminated].getName().empty()
+ ? CheckNames[CK_Uninitialized]
+ : CheckNames[CK_Unterminated],
+ "Leaked va_list", categories::MemoryError));
BT_leakedvalist->setSuppressOnSink(true);
}
@@ -375,7 +379,7 @@ void ValistChecker::checkVAListEndCall(c
std::shared_ptr<PathDiagnosticPiece> ValistChecker::ValistBugVisitor::VisitNode(
const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC,
- BugReport &BR) {
+ BugReport &) {
ProgramStateRef State = N->getState();
ProgramStateRef StatePrev = PrevN->getState();
Modified: cfe/branches/release_60/test/Analysis/malloc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_60/test/Analysis/malloc.c?rev=322550&r1=322549&r2=322550&view=diff
==============================================================================
--- cfe/branches/release_60/test/Analysis/malloc.c (original)
+++ cfe/branches/release_60/test/Analysis/malloc.c Tue Jan 16 04:58:37 2018
@@ -1720,13 +1720,6 @@ void *smallocWarn(size_t size) {
}
}
-char *dupstrWarn(const char *s) {
- const int len = strlen(s);
- char *p = (char*) smallocWarn(len + 1);
- strcpy(p, s); // expected-warning{{String copy function overflows destination buffer}}
- return p;
-}
-
int *radar15580979() {
int *data = (int *)malloc(32);
int *p = data ?: (int*)malloc(32); // no warning
More information about the llvm-branch-commits
mailing list