Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/libclang/libclang_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,21 @@ cppast::libclang_compile_config::libclang_compile_config(
std::string exe(clang_getCString(clang_CompileCommand_getArg(cmd, 0)));
use_c_ = (exe.find("++", 0) == std::string::npos);

if (use_c_)
{
// Try to determine the language from the compiler arguments (e.g. -std=c++11, -x c++)
auto argSize = clang_CompileCommands_getSize(cmd);
for (auto j = 0u; j <= argSize; ++j)
{
std::string arg(clang_getCString(clang_CompileCommand_getArg(cmd, j)));
if (arg.find("c++", 0) != std::string::npos)
{
use_c_ = false;
break;
}
}
}

auto dir = detail::cxstring(clang_CompileCommand_getDirectory(cmd));
parse_flags(cmd, [&](std::string flag, std::string args) {
if (flag == "-I")
Expand Down