Skip to content

Non-existent files are resolved as the working directory file #573

Open
@andocz

Description

@andocz

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 to cc::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 return nullptr if a relative path (which an empty string is) is passed as the argument. This means the location_file field for these nodes will be null 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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions