CppTools: Allow interpreting ambiguous headers as C headers

...instead of C++ headers.

For the Clang Code Model this results in using "-x c-header" instead of
"-x c++-header".

This introduces a new option in Options > C++ > "Code Model" to
configure this.

Change-Id: I8a0ce8fa6155f5ef58743ebc7f1d0b500fbf6599
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
Nikolai Kosjar
2017-01-12 18:01:12 +01:00
parent 4416eecc02
commit e4e6572661
21 changed files with 228 additions and 72 deletions

View File

@@ -384,8 +384,17 @@ static CppTools::ProjectPart projectPartForLanguageOption(CppTools::ProjectPart
static QStringList languageOptions(const QString &filePath, CppTools::ProjectPart *projectPart)
{
const auto theProjectPart = projectPartForLanguageOption(projectPart);
// Determine file kind with respect to ambiguous headers.
CppTools::ProjectFile::Kind fileKind = CppTools::ProjectFile::classify(filePath);
if (fileKind == CppTools::ProjectFile::AmbiguousHeader) {
fileKind = theProjectPart.languageVersion <= CppTools::ProjectPart::LatestCVersion
? CppTools::ProjectFile::CHeader
: CppTools::ProjectFile::CXXHeader;
}
CppTools::CompilerOptionsBuilder builder(theProjectPart);
builder.addLanguageOption(CppTools::ProjectFile::classify(filePath));
builder.addLanguageOption(fileKind);
return builder.options();
}