[PATCH] D49438: [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing
Umann Kristóf via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 17 11:15:51 PDT 2018
Szelethus created this revision.
Szelethus added reviewers: NoQ, george.karpenkov, rnkovacs, xazax.hun.
Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, szepet, whisperity.
The idea came from both @george.karpenkov (https://reviews.llvm.org/D45532#1145592) and from bugzilla (https://bugs.llvm.org/show_bug.cgi?id=37965).
Assigning an object with uninitialized value to a pointer/reference could be intentional, especially if one writes a class that just initializes values.
struct Initializer {
int *a;
void initialize(/* ... */) {
a = /* ... */;
}
Initializer(int *a) : a(a) {}
};
void f() {
int b;
Initializer init(&b);
// ...
init.initialize(/* ... */);
}
I actually have seen some examples for this in LLVM. While I absolutely agree that a flag like this would be neat, I also think that it should be disabled by default, as for example some objects are only created with `malloc`/`new`, and because I didn't find this functionality to be too noisy.
Repository:
rC Clang
https://reviews.llvm.org/D49438
Files:
lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
test/Analysis/cxx-uninitialized-no-dereference.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49438.155923.patch
Type: text/x-patch
Size: 4517 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180717/61dac497/attachment.bin>
More information about the cfe-commits
mailing list