-
Notifications
You must be signed in to change notification settings - Fork 102
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
Non-existent files are resolved as the working directory file #573
Comments
@andocz Can you gives us a MWE to test and validate this issue on? (An AST node without location?) |
@andocz Thanks for the quick response, we will reproduce this first. However I don't think that the correct behaviour would be to add So the source if this faulty behaviour should be examined first. |
I've succesfully reproduced the issue brought up by @andocz . I created a directory unrelated to the project named ParseFromHere and I invoked the parser while inside this directory. As seen in the attached screenshots, there are nodes related to this directory. |
Hi. As we previously discussed on our CodeCompass meeting, I followed the approach @andocz presented and I found that this didn't solve the issue. This code snippet is really short but you can find it at the following link: ervin7mk@203f59b |
Hi @ervin7mk, However, a segmentation fault occurred during parsing, so most likely the returned |
Hi @mcserep , |
Hi All! |
AST nodes that aren't located in any file are reported in the database as being located inside the working directory file.
As a result, the directory that the parser was called from appears in the file manager in the web UI.
This happens because
cc::parser::FileLocUtil::getFilePath(const clang::SourceLocation&)
returns an empty string if no file containing the SourceLocation can be found. This "path" is directly passed tocc::parser::SourceManager::getFile(const sdt::string&)
in numerous places in the code. This function resolves it against the working directory, returning the same directory.My planned solution is to make
SourceManager::getFile
returnnullptr
if a relative path (which an empty string is) is passed as the argument. This means thelocation_file
field for these nodes will benull
in the database. Does that sound like a good format?I wanted to discuss this before implementing a fix as it requires a (small) change to the database schema.
The text was updated successfully, but these errors were encountered: