Improve verbosity when clang_parseTranslationUnit fails
This commit is contained in:
committed by
SvyatoslavScherbina
parent
d734303ddf
commit
8a1d8a29b1
+17
-4
@@ -82,15 +82,28 @@ internal fun parseTranslationUnit(
|
|||||||
): CXTranslationUnit {
|
): CXTranslationUnit {
|
||||||
|
|
||||||
memScoped {
|
memScoped {
|
||||||
val result = clang_parseTranslationUnit(
|
val resultVar = alloc<CXTranslationUnitVar>()
|
||||||
|
|
||||||
|
val errorCode = clang_parseTranslationUnit2(
|
||||||
index,
|
index,
|
||||||
sourceFile.absolutePath,
|
sourceFile.absolutePath,
|
||||||
compilerArgs.toNativeStringArray(memScope), compilerArgs.size,
|
compilerArgs.toNativeStringArray(memScope), compilerArgs.size,
|
||||||
null, 0,
|
null, 0,
|
||||||
options
|
options,
|
||||||
)!!
|
resultVar.ptr
|
||||||
|
)
|
||||||
|
|
||||||
return result
|
if (errorCode != CXErrorCode.CXError_Success) {
|
||||||
|
val copiedSourceFile = sourceFile.copyTo(createTempFile(suffix = sourceFile.name), overwrite = true)
|
||||||
|
|
||||||
|
error("""
|
||||||
|
clang_parseTranslationUnit2 failed with $errorCode;
|
||||||
|
sourceFile = ${copiedSourceFile.absolutePath}
|
||||||
|
arguments = ${compilerArgs.joinToString(" ")}
|
||||||
|
""".trimIndent())
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultVar.value!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user