Commit 53721728 authored by Marco Bubke's avatar Marco Bubke

Clang: Ignore CHeader

Because we don't now if a *.h file is a C or C++ header we provide both
as project file if a C and C++ file is present. But C++ is not readable
by C compiler. So we skip that files and hope there is no non referenced
C header, which is very very unlikely.

Change-Id: I5505713e759749c8a0738e11b70bb6b309412966
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 58763aa9
......@@ -168,6 +168,11 @@ bool unsavedContentContains(const ClangBackEnd::FilePath &sourceFilePath,
return found != unsavedContent.end();
}
bool isCHeader(CppTools::ProjectFile::Kind kind)
{
return kind == CppTools::ProjectFile::CHeader;
}
void appendSource(std::vector<ClangBackEnd::V2::FileContainer> &sources,
const CppTools::ProjectPart::Ptr &projectPart,
const CppTools::ProjectFile &projectFile,
......@@ -175,7 +180,7 @@ void appendSource(std::vector<ClangBackEnd::V2::FileContainer> &sources,
{
ClangBackEnd::FilePath sourceFilePath(projectFile.path);
if (!unsavedContentContains(sourceFilePath, unsavedContent)) {
if (!unsavedContentContains(sourceFilePath, unsavedContent) && !isCHeader(projectFile.kind)) {
sources.emplace_back(ClangBackEnd::FilePath(projectFile.path),
"",
createCommandLine(projectPart.data(),
......
......@@ -165,8 +165,10 @@ std::vector<CppTools::ProjectPart::Ptr> createProjectParts()
projectPart1->files.append({"/path/to/file1.cpp", CppTools::ProjectFile::CXXSource});
auto projectPart2 = CppTools::ProjectPart::Ptr(new CppTools::ProjectPart);
projectPart1->files.append({"/path/to/file2.cpp", CppTools::ProjectFile::CXXSource});
projectPart1->files.append({"/path/to/unsaved.cpp", CppTools::ProjectFile::CXXSource});
projectPart2->files.append({"/path/to/file2.cpp", CppTools::ProjectFile::CXXSource});
projectPart2->files.append({"/path/to/unsaved.cpp", CppTools::ProjectFile::CXXSource});
projectPart2->files.append({"/path/to/cheader.h", CppTools::ProjectFile::CHeader});
return {projectPart1, projectPart2};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment