llvm-project/clang/test/Modules/fatal-module-loader-error.m
Dmitri Gribenko ea4d1c32fb libclang: report error code for bad PCH files
This commit improves libclang to report the error condition when
CXTranslationUnit can not be created because of a stale PCH file.  This allows
the caller, for example, to rebuild the PCH file and retry the request.

There two are APIs in libclang that return a CXTranslationUnit and don't
support reporting detailed errors (the only error condition is a NULL result).
For these APIs, a second, superior, version is introduced --
clang_createTranslationUnit2 and clang_parseTranslationUnit2.  These functions
return a CXTranslationUnit indirectly and also return an error code.  Old
functions are still supported and are nothing more than convenience wrappers
that ignore extended error codes.

As a cleanup, this commit also categorizes some libclang errors in the
functions I had to modify anyway.

llvm-svn: 201249
2014-02-12 19:12:37 +00:00

27 lines
869 B
Objective-C

// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: touch %t/Module.pcm
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t %s -fdisable-module-hash -F %S/Inputs -verify
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t %s -fdisable-module-hash -F %S/Inputs -DIMPLICIT -verify
// This tests that after a fatal module loader error, we do not continue parsing.
#ifdef IMPLICIT
// expected-error@+1{{does not appear to be}}
#import <Module/Module.h>
#pragma clang __debug crash;
#else
// expected-error@+1{{does not appear to be}}
@import Module;
#pragma clang __debug crash;
#endif
// Also check that libclang does not create a PCH with such an error.
// RUN: not c-index-test -write-pch %t.pch -fmodules -fmodules-cache-path=%t \
// RUN: %s -Xclang -fdisable-module-hash -F %S/Inputs 2>&1 | FileCheck %s
// CHECK: {{^}}Failure: AST deserialization error occurred{{$}}