Caphyon / clang-power-tools

Bringing clang-tidy magic to Visual Studio C++ developers.
http://www.clangpowertools.com
Apache License 2.0
472 stars 57 forks source link

clang-tidy: llvm-header-guard adds absolute path to header guard #1334

Closed vadymchan closed 7 months ago

vadymchan commented 7 months ago

I encountered an issue with the llvm-header-guard check when running extension. It refactors header guards using absolute paths:

#ifndef C:_USERS_VADYM_SOURCE_REPOS_PET_PROJECT_MATH_LIBRARY_SRC_LIB_OPTIONS_OPTIONS_H
#define C:_USERS_VADYM_SOURCE_REPOS_PET_PROJECT_MATH_LIBRARY_SRC_LIB_OPTIONS_OPTIONS_H

This behavior isn't ideal. I'm looking for a guard style that reflects the project structure, such as:

#ifndef MATH_LIBRARY_OPTIONS_H
#define MATH_LIBRARY_OPTIONS_H

, where MATHLIBRARY is project name and OPTIONS_H is file name (it's in ideal case, but at least the header guard should be file name - OPTIONS_H). Is there a way to customize llvm-header-guard to generate project-based, rather than absolute path-based, guards?

mariru27 commented 7 months ago

Hi @vadymchan,

Thanks for reaching out

Unfortunately, we're not aware of a way to customize llvm-header-guard to generate project-based guards using relative paths

It seems like the tool might be designed for absolute paths

Kind regards, Marina