From b727e36afc44d9b4eeae35d96bc0d3fd64a2c7f5 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Fri, 1 Dec 2017 09:59:28 -0800 Subject: [PATCH] Move cleanup_maybe_relative_path to top of func in project.cc --- src/project.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/project.cc b/src/project.cc index cc590b99..5502ba67 100644 --- a/src/project.cc +++ b/src/project.cc @@ -86,6 +86,15 @@ bool IsCFile(const std::string& path) { Project::Entry GetCompilationEntryFromCompileCommandEntry( ProjectConfig* config, const CompileCommandsEntry& entry) { + auto cleanup_maybe_relative_path = [&](const std::string& path) { + // TODO/FIXME: Normalization will fail for paths that do not exist. Should + // it return an optional? + assert(!path.empty()); + if (path[0] == '/' || entry.directory.empty()) + return NormalizePathWithTestOptOut(path); + return NormalizePathWithTestOptOut(entry.directory + "/" + path); + }; + Project::Entry result; result.filename = NormalizePathWithTestOptOut(entry.file); @@ -108,15 +117,6 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry( for (; i < entry.args.size(); ++i) { std::string arg = entry.args[i]; - auto cleanup_maybe_relative_path = [&](const std::string& path) { - // TODO/FIXME: Normalization will fail for paths that do not exist. Should - // it return an optional? - assert(!path.empty()); - if (path[0] == '/' || entry.directory.empty()) - return NormalizePathWithTestOptOut(path); - return NormalizePathWithTestOptOut(entry.directory + "/" + path); - }; - // Do not include path. if (result.filename == cleanup_maybe_relative_path(arg)) continue;