-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
intellisense with std::map is broken #438
Comments
Hi @seisowl Thanks for the bug report.
In the "used to work" did it stop working when you made an update, either to your C++ install or to your Eclipse CDT install? As libstdc++ evolves and takes on new features it can sometimes expose areas of the CDT parser that cause issue. Can you confirm the following:
Finally, if you haven't changed versions, the problem may be a corrupted index. You can reindex and see if there is anything in the log. See the first paragraph of https://github.com/eclipse-cdt/cdt/blob/main/FAQ/Indexer.md#diagnosing-the-index for more info. |
Hi @seisowl please check with There is at least a problem with ambiguous bindings for constructors which shows up more frequently with c++17 deduction guides. Also there is a problem with initializer list constructors where one of aggregate initialization cases is not handled in CDT parser. Ambiguous bindings from indexer do not look trivial to handle so I only have experimental fix for these in CDT parser which does not help in all cases. LSP integration should help here. |
I can confirm the bug is reproducible on my end (Eclipse version: 2023-06 (4.28.0), Build id: 20230608-1333, CDT Version: 11.2.0.202306051917, Build id: 20230605-1917). To reproduce: take the following code #include <map>
#include <string>
int main() {
std::map<std::string, std::string> testMap;
return 0;
} CDT indexer reports "invalid template arguments" on the @i-garrison, the indexer log indeed reports an ambiguous node. The log is as follows:
|
I've been running into this for a while now as well, ever since I accidentally upgraded my 2023-03. Switching to fresh install didn't work either.
I just tried with 2023-03 as well and that works just fine. g++ (SUSE Linux) 13.1.1 20230522 [revision dd36656ada05731c069ecd5b1878380294fb1f3e] |
Before support for deduction guides landed it did not fully worked anyway for >= c++17 so if you do not use that set --std=c++14 or earlier.
This is about the test case I'm using to reproduce the issue. Unfortunately the source of ambiguity is not clear to me yet: it looks like index lookup for default template argument returns extra hits (in this case, for ::std::less) and I cannot explain all of these extras yet.
This looks modern and suggests your GCC is already defaulting to c++17 or later which could explain why you see the issue. |
I have the same issue. Updated Eclipse today. Created new workspace with default settings. Created new project and test cpp file. Tried c++17 and c++2a dialects. Got "Invalid Template Arguments" error for std::map and std::unordered_map.
In properties,
Error log contains messages similar to the ones below
c++14 works OK but, unfortunately, is not feasible. |
Just wondering if there is any movement on this, if it is marked for development, or if it would be best to get a version from before 2023-03? |
The movement on this is the migration path being worked on to LSP support in CDT which will support all the latest C++ standards. That work is ongoing with the intention of a first released version in the coming weeks. |
I've found a temporary workaround for this issue. #!/bin/bash
##
# This script is used to downgrade __cpp_deduction_guides definition
# to avoid Eclipse indexer's inability to correctly work with it.
# See Project > Properties > C/C++ General > Preprocessor ... >
# Providers > CDT GCC Built-in Compiler Settings.
##
"$@" | sed -e '/__cpp_deduction_guides/c #define __cpp_deduction_guides 201600L' Locate this script somewhere inside of your project directory (for example, in
Don't forget to rebuild the index. |
@sergeniously, you're my hero. From a quick test it looks like adding it under CDT User Setting Entries works as well - no need for the sed script, it doesn't seem that selecting "treat as built-in" makes a difference. |
Minimal reproducer at the moment: header file: testcxx17-unordered-map-resolution-bug-minimal.h
source file: testcxx17-unordered-map-resolution-bug-minimal.cc
Steps to reproduce:
Strange thing is that you have to modify the header file to reproduce. Another thing is this works if you move everything to header file. It appears that deduction guide detection code is somehow causing this issue, probably somewhere in PDOM interactions but nothing concrete to point out yet. |
Add new index binding resolution test strategy SinglePDOMReindexedTestStrategy which does reindex project after adding test case sources. Clean up redundand C++17 setup helper classes from test since deduction guides are always enabled. Add test case modelling std::map resolution problem and make sure to run it with new test strategy to reproduce the issue. Bug eclipse-cdt#438
Turned out that index is missing information about template parameters of deduction guide templates, and all affected names which are only available via index could not be resolved. This happens to e.g. std::map<> which is usually looked up via index populated from <map> header file. Fix this by implementing ICPPTemplateParameterOwner and ICPPTemplateDefinition interfaces in new CPPDeductionGuideTemplate which delegates missing resolution calls to the function object which already carry required template information. Closes eclipse-cdt#438
#580 should fix this issue |
Add new index binding resolution test strategy SinglePDOMReindexedTestStrategy which does reindex project after adding test case sources. Clean up redundand C++17 setup helper classes from test since deduction guides are always enabled. Add test case modelling std::map resolution problem and make sure to run it with new test strategy to reproduce the issue. Bug eclipse-cdt#438
Turned out that index is missing information about template parameters of deduction guide templates, and all affected names which are only available via index could not be resolved. This happens to e.g. std::map<> which is usually looked up via index populated from <map> header file. Fix this by implementing ICPPTemplateParameterOwner and ICPPTemplateDefinition interfaces in new CPPDeductionGuideTemplate which delegates missing resolution calls to the function object which already carry required template information. Closes eclipse-cdt#438
Add new index binding resolution test strategy SinglePDOMReindexedTestStrategy which does reindex project after adding test case sources. Clean up redundand C++17 setup helper classes from test since deduction guides are always enabled. Add test case modelling std::map resolution problem and make sure to run it with new test strategy to reproduce the issue. Bug eclipse-cdt#438
Turned out that index is missing information about template parameters of deduction guide templates, and all affected names which are only available via index could not be resolved. This happens to e.g. std::map<> which is usually looked up via index populated from <map> header file. Fix this by implementing ICPPTemplateParameterOwner and ICPPTemplateDefinition interfaces in new CPPDeductionGuideTemplate which delegates missing resolution calls to the function object which already carry required template information. Closes eclipse-cdt#438
Add new index binding resolution test strategy SinglePDOMReindexedTestStrategy which does reindex project after adding test case sources. Clean up redundand C++17 setup helper classes from test since deduction guides are always enabled. Add test case modelling std::map resolution problem and make sure to run it with new test strategy to reproduce the issue. Bug #438
Turned out that index is missing information about template parameters of deduction guide templates, and all affected names which are only available via index could not be resolved. This happens to e.g. std::map<> which is usually looked up via index populated from <map> header file. Fix this by implementing ICPPTemplateParameterOwner and ICPPTemplateDefinition interfaces in new CPPDeductionGuideTemplate which delegates missing resolution calls to the function object which already carry required template information. Closes #438
still occurs with both |
Please open new issue and provide more details, e.g. which cdt version and c++ compiler this is still seen with and what was the source code (preferrably extract a small test case from it.) Note you probably cannot expect all cases to work with C++20 and above due to missing support for concepts and constraints, but with C++17 it should work already pretty well. |
@jonahgraham would you believe marking this issue with milestone (e.g. to see this should be fixed in upcoming 11.x release) would help navigating through issues? |
The fix didn’t make it to 11.4/2023.12 if that’s what you’re using. |
Yes - I have focused on PRs in the past, but the issues having the milestones too is a good idea. |
Describe the bug
It looks like the intellisense does not recognize std::map. It used to work.
To Reproduce
Steps to reproduce the behavior:
#include <map> #include <utility>
std::pair
works with intellisense, whilestd::map
had a red underline. Click on#include <map>
goes to the correct header file.Expected behavior
std::map
should be recognized by the intellisense.Screenshots
NA
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: