[PATCH] D75158: [analyzer][StreamChecker] Using function description objects - NFC.
Balázs Kéri via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 2 03:54:21 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb293a7217bae: [analyzer][StreamChecker] Using function description objects - NFC. (authored by balazske).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75158/new/
https://reviews.llvm.org/D75158
Files:
clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -49,6 +49,15 @@
}
};
+class StreamChecker;
+
+using FnCheck = std::function<void(const StreamChecker *, const CallEvent &,
+ CheckerContext &)>;
+
+struct FnDescription {
+ FnCheck EvalFn;
+};
+
class StreamChecker : public Checker<eval::Call,
check::DeadSymbols > {
mutable std::unique_ptr<BuiltinBug> BT_nullfp, BT_illegalwhence,
@@ -59,35 +68,33 @@
void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
private:
- using FnCheck = std::function<void(const StreamChecker *, const CallEvent &,
- CheckerContext &)>;
-
- CallDescriptionMap<FnCheck> Callbacks = {
- {{"fopen"}, &StreamChecker::evalFopen},
- {{"freopen", 3}, &StreamChecker::evalFreopen},
- {{"tmpfile"}, &StreamChecker::evalFopen},
- {{"fclose", 1}, &StreamChecker::evalFclose},
+
+ CallDescriptionMap<FnDescription> FnDescriptions = {
+ {{"fopen"}, {&StreamChecker::evalFopen}},
+ {{"freopen", 3}, {&StreamChecker::evalFreopen}},
+ {{"tmpfile"}, {&StreamChecker::evalFopen}},
+ {{"fclose", 1}, {&StreamChecker::evalFclose}},
{{"fread", 4},
- std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 3)},
+ {std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 3)}},
{{"fwrite", 4},
- std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 3)},
- {{"fseek", 3}, &StreamChecker::evalFseek},
+ {std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 3)}},
+ {{"fseek", 3}, {&StreamChecker::evalFseek}},
{{"ftell", 1},
- std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)},
+ {std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)}},
{{"rewind", 1},
- std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)},
+ {std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)}},
{{"fgetpos", 2},
- std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)},
+ {std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)}},
{{"fsetpos", 2},
- std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)},
+ {std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)}},
{{"clearerr", 1},
- std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)},
+ {std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)}},
{{"feof", 1},
- std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)},
+ {std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)}},
{{"ferror", 1},
- std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)},
+ {std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)}},
{{"fileno", 1},
- std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)},
+ {std::bind(&StreamChecker::checkArgNullStream, _1, _2, _3, 0)}},
};
void evalFopen(const CallEvent &Call, CheckerContext &C) const;
@@ -125,11 +132,11 @@
return false;
}
- const FnCheck *Callback = Callbacks.lookup(Call);
- if (!Callback)
+ const FnDescription *Description = FnDescriptions.lookup(Call);
+ if (!Description)
return false;
- (*Callback)(this, Call, C);
+ (Description->EvalFn)(this, Call, C);
return C.isDifferent();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75158.247591.patch
Type: text/x-patch
Size: 3601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200302/713d0e65/attachment.bin>
More information about the cfe-commits
mailing list