0

I have this c file

#include "pointer.h"
int switcher(int * i) {
 int a = *i;
    switch (a) {
        case 1: 
            return 0;
        default: 
            return 1;
    }
}  

and the associated header contains only one line

int switcher(int * i);

This compiles using clang.

If I now use clang-tidy (clang-tidy -fix pointer.c -checks=* -header-filter=.* ) I get the following result

#include "pointer.h"
int switcher(const int * i) {
    int a = *i;
    switch (a) {
        case 1: 
            return 0;
        default: 
            return 1;
    }
}

and the header

#ifndef _HOME_GWE_PROJEKTE_CLANG_TIDY_POINTER_H
#define _HOME_GWE_PROJEKTE_CLANG_TIDY_POINTER_H

int switcher(int * i);

#endif

The signature of the function has been changed form (int i) to (const inti) which is nice. The header file has also been altered (guards), but the signature stays the very same. Thus. the code does not compile any more.

My compile_commands.json looks like this

[
{
  "directory": "/home/gwe/projekte/clang/tidy",
  "command": "clang -c pointer.c -I.",
  "file": "pointer.c"
}
]

Is this a clang-tidy bug or am I doing it wrong? Thanks for your help?

Best regards, Georg

valiano
  • 16,433
  • 7
  • 64
  • 79
schorsch312
  • 5,553
  • 5
  • 28
  • 57

1 Answers1

1

This bug is reported to llvm.org.

bugs.llvm.org//show_bug.cgi?id=33219

schorsch312
  • 5,553
  • 5
  • 28
  • 57