[PATCH] D67865: [clang-tidy] Finds uses of OSRead* calls on macOS that may mask unexpected behavior due to unaligned reads
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 26 03:47:26 PDT 2019
gribozavr added a comment.
What is the expected contract of the functions that this checker flags? Are they supposed to perform unaligned reads correctly, and we have just an implementation bug in these functions, or is it the caller's fault if they pass an unaligned address?
================
Comment at: clang-tidy/objc/ObjCTidyModule.cpp:30
"objc-avoid-nserror-init");
+ CheckFactories.registerCheck<AvoidOSReadCheck>(
+ "objc-avoid-osread");
----------------
Maybe a better place for this checker is the new "darwin" module? It is being added in https://reviews.llvm.org/D67567.
================
Comment at: test/clang-tidy/objc-avoid-osread.m:5
+ const char *buff = "";
+ OSReadBigInt(buff, 0);
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use memcpy and OSSwap{Big|Little}ToHostInt{16|32|64} instead of OSRead* calls to avoid potential unaligned read issues [objc-avoid-osread]
----------------
Please add declarations for these functions. It is strange that this test even works without them...
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67865/new/
https://reviews.llvm.org/D67865
More information about the cfe-commits
mailing list