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
Cannot find references for enum class member, but typedef'ed enum member is OK #1197
Comments
Works for me! Can you provide a step by step instruction how you did it, inclusive the source code. Thanks! The test file. #include <iostream>
typedef enum { Type1, Type2, Type3 } Type;
enum class Format {
FormatInvalid = -1,
Format1,
Format2,
Format3,
};
int main()
{
Format format = Format::Format3;
if (format == Format::Format3)
std::cout << "Format3" << std::endl;
else if (format == Format::Format2)
std::cout << "Format2" << std::endl;
else if (format == Format::Format1)
std::cout << "Format1" << std::endl;
else
std::cout << "Error " << static_cast<std::underlying_type<Format>::type>(Format::FormatInvalid) << std::endl;
std::cout << "Value of enum class: " << static_cast<std::underlying_type<Format>::type>(Format::Format1) << std::endl;
std::cout << "Value of enum: " << Type1 << std::endl;;
return 0;
} Parse the test file. rc -c g++ -std=c++11 -Wall -Wextra main.cpp -o main Christian |
Hi Christian, Regarding step by step instruction, I did submit a issue #1194. To be short, I'm working on a C++/C project which is inside Android. Android build is hard to manipulate, so I use Bear to generate compile_commands.json file, I use Bear's -a option to consolidate several folder's compile commands into one single json file. Then I use rc -J to pass the compile command to rdm. So far, finding symbols and references are pretty good with RTags. Only I suddenly found some enum class variables are not referenced well. Anyway, I tried your test.cpp file, I used your rc -c line, but I didn't find any outputs from rdm logging.
Then I use rc to find references:
So I still cannot fine all references for enum class variables, and typedef'ed enum still working OK. |
I suspect it's because of your Clang/LLVM version you built RTags against. I need to verify this inside a VM. I report back.
|
I neither couldn't reproduce this in CentOS 7. rc -w
/home/osboxes/Downloads/ <=
[osboxes@osboxes Downloads]$ rc -e -R Format3
main.cpp:14:27: Format format = Format::Format3;
main.cpp:15:25: if (format == Format::Format3)
main.cpp:9:3: Format3, Clang/LLVm 3.4.2 Your output of RDM looks differnt though, are you sure, you used the same rc command. My: I::parse loading unit: clang "-std=c++11" "-Wall" "-Wextra" "-ferror-limit=50" "-Wall" "-fspell-checking" "-Wno-unknown-warning-option" "-DRTAGS=" "-isystem" "/usr/lib/clang/3.4.2/include/" /home/osboxes/Downloads/main.cpp true Your: CI::parse loading unit: clang "-Wall" "-Wextra" "-ferror-limit=50" "-Wall" "-fspell-checking" "-Wno-unknown-warning-option" "-DRTAGS=" "-isystem" "/usr/lib/llvm-3.4/lib/clang/3.4/include/" /home/shuaiy/proj/temp/test.cpp true
Fixit for /home/shuaiy/proj/temp/test.cpp:27:66: Insert ">"
Fixit for /home/shuaiy/proj/temp/test.cpp:29:77: Insert ">" cd ~/Downloads
rc --project-root . -c g++ -std=c++11 -Wall -Wextra main.cpp -o main |
Hi Christian, I just run the rc command again, this time the rdm logging is:
The previous "Fixit" print didn't come out this time, and I'm able to find reference now:
This is peculiar because I didn't modify the test.cpp nor change anything else. Since the test source code is working well, I will close this issue for now. But in my Android project, similar enum class variable still cannot find reference for now. I guess I need re-index the project and try to nail down my issue. Thank you very much, Christian! |
Not sure if this only happens to me or a common "issue".
Example:
typedef enum
{
Type1,
Type2,
Type3
}Type;
If use rc to find reference for Type1, Type2, Type3, it's working pretty well.
However, for enum class member, like:
enum class Format
{
FormatInvalid = -1,
Format1,
Format2,
Format3,
};
For this situation, rc cannot find reference for above Formats.
Could someone confirm this is only on my side or commonly happens.
Thanks
The text was updated successfully, but these errors were encountered: