[PATCH] D47187: [clangd] Skip .inc headers when canonicalizing header #include.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 23 07:50:43 PDT 2018
sammccall added inline comments.
================
Comment at: clangd/index/CanonicalIncludes.cpp:54
+ StringRef Header = *I;
+ if (!isLiteralInclude(Header)) {
+ // If Header is not expected be included (e.g. .cc file), we fall back to
----------------
headers are paths, not <quoted>, right?
================
Comment at: clangd/index/CanonicalIncludes.cpp:55
+ if (!isLiteralInclude(Header)) {
+ // If Header is not expected be included (e.g. .cc file), we fall back to
+ // the declaring header.
----------------
This logic could be merged with the .inc logic, right?
"Find the first header such that the extension is not '.inc', and isn't a recognized non-header file"
================
Comment at: clangd/index/CanonicalIncludes.cpp:60
+ if (!Ext.empty() && !driver::types::onlyPrecompileType(
+ driver::types::lookupTypeForExtension(Ext)))
+ return Headers[0];
----------------
lookupTypeForExtension can return TY_INVALID, which you have to check for (onlyPrecompileType will assert).
I think we should be conservative and accept TY_INVALID as possible headers - our goal here really is to exclude "obvious" non-headers like cpp.
(in this case you can probably drop the explicit empty check)
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D47187
More information about the cfe-commits
mailing list