Comments (6)
Ah, this one fell through the cracks. It's important that the #define
is part of the preamble (the initial block of preprocessor directives). Add int x;
to the top of the file and everything works again.
The problem is we assumed that "in the preamble" was the same thing as "not in the main file", and so we don't index symbols in the main file. This assumption is true for decls, but not for macros.
from clangd.
Ah, this one fell through the cracks. It's important that the #define is part of the preamble (the initial block of preprocessor directives). Add int x; to the top of the file and everything works again.
Yes, add int x; to the top of the file and everything is back to normal. But the macro's document still doesn't show in codecomplete.
Document does not display for macros
from clangd.
This is a bit hairy:
- we see the macros when indexing the preamble, but we don't actually want the macros in the index: that would make them complete while in other files.
- we don't see the macros when indexing the main file, because the lexer starts after the preamble region
I see two main options:
- when building the preamble, record the macros and store them alongside the preamble
- when code completing, preprocess the preamble region in single-file mode to get the macros
In either case, we then need to overlay the result onto the index.
The first option is more correct - single-file mode doesn't follow includes and therefore isn't accurate. But the first option probably involves some layering violations or code duplication (if the preamble-building code needs to run SymbolCollector), and certainly involves more plumbing.
Macro doc I'm not sure about - I forget exactly how we extract doc comments, will have a look into that if it persists after the main issue is fixed.
from clangd.
On further reflection, clearly the preamble contains the macros, the question is whether we can get them out efficiently.
ASTReader::ReadDefinedMacros
is responsible for decoding.
The preprocessor block appears to be very small: it's 0.8%, or roughly 300kB in a 45M LLVM preamble.
As far as I can see, it contains macro identifiers (PP_MACRO_FUNCTION_LIKE
, PP_MACRO_OBJECT_LIKE
), macro definition sites (PP_MACRO_DIRECTIVE_HISTORY
), and a little bit of stuff we don't need. So far so good.
Unfortunately it looks like the path from identifier -> definition site goes through the name lookup table that's used for all identifiers, and deserializing anything that matches! I'll need to measure if this is expensive.
from clangd.
Finally have an approach here that seems okayish...
https://reviews.llvm.org/D60937
from clangd.
Fixed in r359799.
Thanks for reporting!
from clangd.
Related Issues (20)
- clangd crashes on header included within extern "C++" block HOT 6
- No completions offered after `(*this).` in template class HOT 2
- Failed to reference non-existent header file error underlining HOT 4
- The Chinese internationalization of the right-click menu is incomplete HOT 2
- conflict types for "_mm_prefetch" in xmmintrin.h HOT 1
- clangd doesn't clean up /tmp even when it exits cleanly HOT 9
- clangd in my neovim setup is showing unnecessary errors like " No member named 'cout' in namespace 'std' " HOT 1
- Formatting Issue with '<' operator parsing in template parameter list HOT 2
- Clangd treats my .cpp files as c files: Reports errors when using any c++ functions HOT 7
- Typing {} with new keyword should trigger signature help
- Partial Result Progress support
- "In included file: too few arguments provided to function-like macro invocation" when using gcc headers HOT 2
- Double click to insert argument comment HOT 2
- guides/include-cleaner inconsistent on IWYU private separator.
- Provide way to list all warnings for a project
- [Windows 10] Can't find iostream , or basic header in C++ (on Neovim) HOT 1
- clangd "--query-driver" option doesn't follow symlinks HOT 1
- `--function-arg-placeholders=0` should apply to variable template arguments as well HOT 5
- Clangd produces `type` semantic token for `auto` resolving to `int`, but not `auto` resolving to `int*` HOT 1
- --function-arg-placeholders=0 is sending an error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clangd.