Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ void ConstCorrectnessCheck::check(const MatchFinder::MatchResult &Result) {
CheckValue();
if (WarnPointersAsPointers) {
if (const auto *PT = dyn_cast<PointerType>(VT)) {
if (!PT->getPointeeType().isConstQualified())
if (!PT->getPointeeType().isConstQualified() &&
!PT->getPointeeType()->isFunctionType())
CheckPointee();
}
if (const auto *AT = dyn_cast<ArrayType>(VT)) {
Expand Down
3 changes: 2 additions & 1 deletion clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ Changes in existing checks

- Improved :doc:`misc-const-correctness
<clang-tidy/checks/misc/const-correctness>` check to avoid false
positives when pointers is tranferred to non-const references.
positives when pointers is tranferred to non-const references
and check by fixing false positives of function pointer.

- Improved :doc:`misc-header-include-cycle
<clang-tidy/checks/misc/header-include-cycle>` check performance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ void ignore_const_alias() {
p_local0 = &a[1];
}

void function_pointer_basic() {
void (*const fp)() = nullptr;
fp();
}

void takeNonConstRef(int *&r);

void ignoreNonConstRefOps() {
Expand Down