[PATCH] D21036: Misplaced const-qualification with typedef types
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 6 12:45:57 PDT 2016
aaron.ballman created this revision.
aaron.ballman added reviewers: alexfh, sbenza, hokein.
aaron.ballman added a subscriber: cfe-commits.
Sometimes it's easy for developers to not notice that the type they are working with is a typedef type to a pointer and add a const-qualifier that applies to the typedef type rather than the underlying pointer type. e.g.,
typedef int *int_ptr;
void func(const int_ptr ip);
This results in ip having the type int * const rather than const int *.
This patch adds a new clang-tidy check to diagnose such constructs to alert the developer of the difference in types. It does not diagnose if the underlying pointer type points to a const type or is a function type because the const-qualifier on the typedef is more likely to be intentional.
http://reviews.llvm.org/D21036
Files:
clang-tidy/misc/CMakeLists.txt
clang-tidy/misc/MiscTidyModule.cpp
clang-tidy/misc/MisplacedConstCheck.cpp
clang-tidy/misc/MisplacedConstCheck.h
docs/clang-tidy/checks/list.rst
docs/clang-tidy/checks/misc-misplaced-const.rst
test/clang-tidy/misc-misplaced-const.c
test/clang-tidy/misc-misplaced-const.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21036.59764.patch
Type: text/x-patch
Size: 9587 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160606/8fcd4621/attachment.bin>
More information about the cfe-commits
mailing list