Fix include issue on pre-clang 4.0.0
This commit is contained in:
parent
a91746c145
commit
670551faa5
1 changed files with 17 additions and 14 deletions
|
|
@ -1042,6 +1042,13 @@ detail::preprocessor_output detail::preprocess(const libclang_compile_config& co
|
||||||
|
|
||||||
auto preprocessed = clang_preprocess(config, path, logger);
|
auto preprocessed = clang_preprocess(config, path, logger);
|
||||||
|
|
||||||
|
if (detail::libclang_compile_config_access::clang_version(config) < 40000)
|
||||||
|
{
|
||||||
|
// add headers from diagnostics w/o line information
|
||||||
|
for (auto name : preprocessed.included_files)
|
||||||
|
result.includes.push_back(pp_include{name, "", cpp_include_kind::local, 1u});
|
||||||
|
}
|
||||||
|
|
||||||
position p(ts::ref(result.source), preprocessed.file.c_str());
|
position p(ts::ref(result.source), preprocessed.file.c_str());
|
||||||
ts::flag in_string(false), in_char(false), first_line(true);
|
ts::flag in_string(false), in_char(false), first_line(true);
|
||||||
while (p)
|
while (p)
|
||||||
|
|
@ -1120,13 +1127,17 @@ detail::preprocessor_output detail::preprocess(const libclang_compile_config& co
|
||||||
if (p.write_enabled())
|
if (p.write_enabled())
|
||||||
{
|
{
|
||||||
// this is a direct include, update the full path of the last include
|
// this is a direct include, update the full path of the last include
|
||||||
DEBUG_ASSERT(!result.includes.empty()
|
// note: path can be empty if pre clang 4 and not fast preprocessing
|
||||||
&& result.includes.back().full_path.empty()
|
// in this case we can't get the full path at all
|
||||||
|
if (!result.includes.empty())
|
||||||
|
{
|
||||||
|
DEBUG_ASSERT(result.includes.back().full_path.empty()
|
||||||
&& lm.value().file.find(result.includes.back().file_name)
|
&& lm.value().file.find(result.includes.back().file_name)
|
||||||
!= std::string::npos,
|
!= std::string::npos,
|
||||||
detail::assert_handler{});
|
detail::assert_handler{});
|
||||||
result.includes.back().full_path = lm.value().file;
|
result.includes.back().full_path = lm.value().file;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// this is an indirect include, remember it to get full path for indirect includes
|
// this is an indirect include, remember it to get full path for indirect includes
|
||||||
|
|
@ -1183,14 +1194,6 @@ detail::preprocessor_output detail::preprocess(const libclang_compile_config& co
|
||||||
p.bump();
|
p.bump();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.includes.empty())
|
|
||||||
{
|
|
||||||
// add headers from diagnostics w/o line information
|
|
||||||
// only needed for older clangs
|
|
||||||
for (auto name : preprocessed.included_files)
|
|
||||||
result.includes.push_back(pp_include{name, "", cpp_include_kind::local, 1u});
|
|
||||||
}
|
|
||||||
|
|
||||||
// get full path for indirect includes
|
// get full path for indirect includes
|
||||||
// doesn't work if fast preprocessing
|
// doesn't work if fast preprocessing
|
||||||
if (!detail::libclang_compile_config_access::fast_preprocessing(config))
|
if (!detail::libclang_compile_config_access::fast_preprocessing(config))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue