简体   繁体   中英

Clang-Tidy llvm-header-guard directory configuration

Is there a way to remove the suggested computer specific path on the suggested llvm-header-guard string when running static analysis with clang-tidy?

For example the suggested header guard for the file (cls/math/matrix.hpp) is: _USERS_NAME_DESKTOP_PROJECT_SRC_CLS_MATH_MATRIX_HPP

But to avoid making this specific to my computer it should only be: _PROJECT_SRC_CLS_MATH_MATRIX_HPP

Is there a way to configure clang-tidy such that it suggests header guards starting from the /project/ directory rather than the /users/ directory?

I am using clang 5.0.0, running from cmake.

I've also had this problem for ages and finally figured it out, at least for public includes: clang-tidy assumes that headers are within a directory called include .

So, if your headers are like /home/me/myproject/include/myproject/header.h then it will work properly and recommend MYPROJECT_HEADER_H . If it doesn't find an include directory to treat as the root, then it falls back to the absolute path.

So the solution for libraries is to use that structure (which is probably a good idea anyway). I am still not sure about headers inside a project's source though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM