[PATCH] D152589: [clang-tidy] Add readability test for not allowing relative includes
Erez Amihud via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 13 11:57:57 PDT 2023
ErezAmihud added a comment.
In D152589#4410930 <https://reviews.llvm.org/D152589#4410930>, @PiotrZSL wrote:
> Even with that for me for example, I would consider `#include "xyz"` be fine, but `#include "../xyz"` would be a red flag, so please consider adding `StrictMode` option to check so if `StrictMode` is not set then includes from same directory, or subdirectory would be allowed, but includes that contain `..` would not.
> With that settings, I could use that check, and probably many other users could.
I want to make sure I understand.
The ideal situation would be to create `misc-no-relative-includes` check that checks for `..` in paths (meaning - relative paths), and have a `StrictMode` which does the check for angled-bracket includes.
BTW The reason I initially checked for angled-bracket includes is that according to this <https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html> quote includes search in paths relative to the current file, and the angled-bracket includes check only in the defined include directories.
In this case there is no risk that the include would get a file that is not relative to the include directory the user specified in the compile flags.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152589/new/
https://reviews.llvm.org/D152589
More information about the cfe-commits
mailing list