|
11 | 11 | #include "indexer/FileMetadata.h"
|
12 | 12 | #include "indexer/Hash.h"
|
13 | 13 | #include "indexer/IdPathMappings.h"
|
| 14 | +#include "indexer/LlvmAdapter.h" |
14 | 15 | #include "indexer/Path.h"
|
15 | 16 |
|
16 | 17 | namespace scip_clang {
|
@@ -127,14 +128,43 @@ bool FileMetadataMap::insert(clang::FileID fileId, AbsolutePathRef absPathRef) {
|
127 | 128 | // projectRoot / relativePath exists, but is actually a symlink to
|
128 | 129 | // inside the build root, rather than an in-project file. So check that
|
129 | 130 | // that real_path is the same.
|
130 |
| - if (!error && realPath.str() == originalFileSourcePath.asStringRef()) { |
131 |
| - return insertRelPath(RootRelativePathRef(buildRootRelPath->asStringView(), |
132 |
| - RootKind::Project), |
133 |
| - /*isInProject*/ true); |
| 131 | + if (!error) { |
| 132 | + if (realPath.str() == originalFileSourcePath.asStringRef()) { |
| 133 | + return insertRelPath( |
| 134 | + RootRelativePathRef(buildRootRelPath->asStringView(), |
| 135 | + RootKind::Project), |
| 136 | + /*isInProject*/ true); |
| 137 | + } else { |
| 138 | + spdlog::trace("projectRoot.join(relativePath (= '{}'/'{}')) exists but " |
| 139 | + "the real path is '{}", |
| 140 | + this->projectRootPath.asRef().asStringView(), |
| 141 | + buildRootRelPath->asStringView(), |
| 142 | + llvm_ext::toStringView(realPath.str())); |
| 143 | + } |
| 144 | + } else if (error == std::errc::no_such_file_or_directory) { |
| 145 | + spdlog::trace( |
| 146 | + "failed to find file in project at '{}' (root: '{}', rel: '{}')", |
| 147 | + originalFileSourcePath.asStringRef(), |
| 148 | + this->projectRootPath.asRef().asStringView(), |
| 149 | + buildRootRelPath->asStringView()); |
| 150 | + } else { |
| 151 | + spdlog::trace("hit error: {} when getting real path for {}", |
| 152 | + error.message(), originalFileSourcePath.asStringRef()); |
134 | 153 | }
|
135 | 154 | } else if (auto optProjectRootRelPath =
|
136 | 155 | this->projectRootPath.tryMakeRelative(absPathRef)) {
|
137 | 156 | return insertRelPath(optProjectRootRelPath.value(), /*isInProject*/ true);
|
| 157 | + } else { |
| 158 | + if ((spdlog::default_logger_raw()->level() <= spdlog::level::trace) |
| 159 | + && (absPathRef.asStringView().find("usr/include") == std::string::npos) |
| 160 | + && (absPathRef.asStringView().find("usr/lib/clang") |
| 161 | + == std::string::npos)) { |
| 162 | + spdlog::trace( |
| 163 | + "path {} is neither inside project root {} nor inside build root {}", |
| 164 | + absPathRef.asStringView(), |
| 165 | + this->projectRootPath.asRef().asStringView(), |
| 166 | + this->buildRootPath.asRef().asStringView()); |
| 167 | + } |
138 | 168 | }
|
139 | 169 |
|
140 | 170 | auto optFileName = absPathRef.fileName();
|
|
0 commit comments