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:
Nikolai Kosjar
2016-07-01 15:07:32 +02:00
parent a12184ea32
commit 36e7f4541f
18 changed files with 221 additions and 26 deletions

View File

@@ -25,8 +25,12 @@
#include "commandlinearguments.h"
#include "clangfilepath.h"
#include <utf8string.h>
#include <QByteArray>
#include <iostream>
namespace ClangBackEnd {
@@ -46,7 +50,8 @@ CommandLineArguments::CommandLineArguments(const char *filePath,
m_arguments.push_back(argument.constData());
if (addVerboseOption)
m_arguments.push_back("-v");
m_arguments.push_back(filePath);
m_nativeFilePath = FilePath::toNativeSeparators(Utf8String::fromUtf8(filePath));
m_arguments.push_back(m_nativeFilePath.constData());
}
const char * const *CommandLineArguments::data() const