Skip to content

Commit 43e8430

Browse files
committed
Fixed #10149 (compile database; incomplete handling of directory and file)
1 parent 9e9bb9f commit 43e8430

2 files changed

Lines changed: 2 additions & 10 deletions

File tree

lib/importproject.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,15 +424,7 @@ void ImportProject::importCompileCommands(std::istream &istr)
424424
continue;
425425

426426
struct FileSettings fs;
427-
if (Path::isAbsolute(file) || Path::fileExists(file))
428-
fs.filename = file;
429-
else {
430-
std::string path = directory;
431-
if (!path.empty() && !endsWith(path,'/'))
432-
path += '/';
433-
path += file;
434-
fs.filename = Path::simplifyPath(path);
435-
}
427+
fs.filename = Path::simplifyPath(directory + file);
436428
fs.parseCommand(command); // read settings; -D, -I, -U, -std, -m*, -f*
437429
std::map<std::string, std::string, cppcheck::stricmp> variables;
438430
fs.setIncludePaths(directory, fs.includePaths, variables);

test/cli/test-proj2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def realpath(s):
1919

2020
def create_compile_commands():
2121
j = [{'directory': realpath('proj2/a'), 'command': 'gcc -c a.c', 'file': 'a.c'},
22-
{'directory': realpath('proj2/b'), 'command': 'gcc -c b.c', 'file': 'b.c'}]
22+
{'directory': realpath('proj2'), 'command': 'gcc -c b/b.c', 'file': 'b/b.c'}]
2323
f = open('proj2/' + COMPILE_COMMANDS_JSON, 'wt')
2424
f.write(json.dumps(j))
2525

0 commit comments

Comments
 (0)