Skip to content

[clang-tidy] Broken diagnostic for performance-avoid-endl #107859

@VReichelt

Description

@VReichelt

When I run clang-tidy -checks='-*,performance-avoid-endl' on the following code

#include <iostream>

#define COUT_ENDL std::cout << std::endl

void foo()
{
  COUT_ENDL;
}

I get the message

bug.cc:7:3: warning: do not use '' with streams; use '\n' instead [performance-avoid-endl]
   11 |   COUT_ENDL;
      |   ^
bug.cc:3:32: note: expanded from macro 'COUT_ENDL'
    7 | #define COUT_ENDL std::cout << std::endl
      |                                ^

which is slightly broken (note the empty '' in the first line).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions