forked from qt-creator/qt-creator
Clang: Pass on file paths with native separators
libclang 3.8 seems to be sensitive to file paths separators [1]. On Windows, this led to not updated document annotations and/or crashes after reparsing. When passing file paths to libclang, convert to native separators. When getting file paths from libclang, convert back. This handles: * main file path * file paths of the unsaved files * -I<DIR> arguments, the resource path (for builtins) and the paths to the wrapped qt headers * included header files from libclang * source locations from libclang Also, minimize the conversion in SourceLocation to a minimum by making filePath() lazy. [1] https://llvm.org/bugs/show_bug.cgi?id=28381 Change-Id: If5866f34a6fdc6b34b16c022d3988e8e6eae2a0a Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -98,7 +98,7 @@ public:
|
||||
|
||||
optionsBuilder.addPredefinedMacrosAndHeaderPathsOptions();
|
||||
optionsBuilder.addWrappedQtHeadersIncludePath();
|
||||
optionsBuilder.addHeaderPathOptions();
|
||||
optionsBuilder.addHeaderPathOptions(/*addAsNativePath*/ true);
|
||||
optionsBuilder.addProjectConfigFileInclude();
|
||||
|
||||
optionsBuilder.addMsvcCompatibilityVersion();
|
||||
@@ -149,19 +149,20 @@ private:
|
||||
static const QString resourceDir = getResourceDir();
|
||||
if (!resourceDir.isEmpty()) {
|
||||
add(QLatin1String("-nostdlibinc"));
|
||||
add(QLatin1String("-I") + resourceDir);
|
||||
add(QLatin1String("-I") + QDir::toNativeSeparators(resourceDir));
|
||||
add(QLatin1String("-undef"));
|
||||
}
|
||||
}
|
||||
|
||||
void addWrappedQtHeadersIncludePath()
|
||||
{
|
||||
static const QString wrappedQtHeaders = ICore::instance()->resourcePath()
|
||||
static const QString wrappedQtHeadersPath = ICore::instance()->resourcePath()
|
||||
+ QLatin1String("/cplusplus/wrappedQtHeaders");
|
||||
|
||||
if (m_projectPart.qtVersion != ProjectPart::NoQt) {
|
||||
add(QLatin1String("-I") + wrappedQtHeaders);
|
||||
add(QLatin1String("-I") + wrappedQtHeaders + QLatin1String("/QtCore"));
|
||||
const QString wrappedQtCoreHeaderPath = wrappedQtHeadersPath + QLatin1String("/QtCore");
|
||||
add(QLatin1String("-I") + QDir::toNativeSeparators(wrappedQtHeadersPath));
|
||||
add(QLatin1String("-I") + QDir::toNativeSeparators(wrappedQtCoreHeaderPath));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +170,7 @@ private:
|
||||
{
|
||||
if (!m_projectPart.projectConfigFile.isEmpty()) {
|
||||
add(QLatin1String("-include"));
|
||||
add(m_projectPart.projectConfigFile);
|
||||
add(QDir::toNativeSeparators(m_projectPart.projectConfigFile));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user