Skip to content

misc-include-cleaner breaks code #104585

Open
@ben-freist

Description

@ben-freist

I hope this is the right channel, I'm getting incorrect behaviour from clang-tidy on code that uses ICU.

I'm using ubuntu 22.04, I've tried clang-tidy-17, clang-tidy-18 and I built one myself based on (22bc9db), the results are the same for all three.

CMakeLists.txt:

cmake_minimum_required(VERSION 3.12)

project(tidy_bug)

find_package(ICU 50 COMPONENTS uc REQUIRED)
add_library(my_lib file.cpp)
target_link_libraries(my_lib ICU::uc)

file.cpp

#include <utility>
#include <unicode/uchar.h>
#include <string_view>

bool function(std::string_view input)
{
    size_t res = 0;
    char const * const s = input.data();
    auto const length = static_cast<int32_t>(input.size());
    int32_t pos = 0;
    UChar32 c;
    U8_NEXT(s, pos, length, c);
    return u_isWhitespace(c);
}

I'm using ICU version 70.1.

I'm building the project like this:
cmake -DCMAKE_CXX_COMPILER=clang++-18 -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_STANDARD=20 ..

And I'm applying clang-tidy like this:
clang-tidy -p build/ --config='{"Checks": "misc-include-cleaner"}' --fix file.cpp.

The result has the includes unicode/umachine.h, unicode/utf8.h and unicode/urename.h none of which contain u_isWhitespace.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions