[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEXW_YRPk6Q92MTL7Bnr9kzJT=FHTAiEwxLU=vT+VP+TqPApew@mail.gmail.com>
Date: Thu, 13 Apr 2023 21:16:01 -0400
From: Joel Fernandes <joel@...lfernandes.org>
To: rcu@...r.kernel.org, ndesaulniers@...gle.com, nathan@...nel.org,
trix@...hat.com, llvm@...ts.linux.dev,
linux-kernel@...r.kernel.org, paulmck@...nel.org
Subject: Re: clangd cannot handle tree_nocb.h
On Thu, Apr 13, 2023 at 9:11 PM Joel Fernandes <joel@...lfernandes.org> wrote:
>
> Hello,
>
> One way to fix this could be to add this to the beginning of tree_nocb.h
>
> /* Make clangd understand tree_nocb.h */
> +#ifdef CLANGD_PARSER_ACTIVE
> +#define TREE_NOCB_H_CLANGD
> +#include "tree.c"
> +#endif
>
> And then at the end of tree.c, do this to prevent recursion:
> +#ifndef TREE_NOCB_H_CLANGD
> #include "tree_nocb.h"
> -#include "tree_plugin.h"
> +#endif
> +#include "tree_plugin.h"
>
> Then in scripts/clang-tools/gen_compile_commands.py, we can just make
> it add "-DCLANGD_PARSER_ACTIVE" to all compile command entries in the
> JSON file.
>
Ah and even that will not fully work, because there is no entry for
tree_nocb.h in compile_commands.json to begin with :-(. However, that
also can be fixed. Here's how:
We can just add metadata to tree_nocb.h , something like:
/* clangd_infer_from: tree.c */
Then we make scripts/clang-tools/gen_compile_commands.py duplicate
the compile command JSON entry for tree.c but for tree_nocb.h.
Lastly, we add -DDCLANGD_PARSER_ACTIVE to all entries (including the duplicate).
- Joel
Powered by blists - more mailing lists