forked from OSchip/llvm-project
CIndex: Fix a crash in clang_createTranslationUnitFromSourceFile when using
external ASTs, and the ASTUnit fails to load. Also, move getLocationFromExpr outside extern "C" block. llvm-svn: 95065
This commit is contained in:
parent
057c642486
commit
a4a2e5dd5b
|
@ -1094,9 +1094,11 @@ clang_createTranslationUnitFromSourceFile(CXIndex CIdx,
|
|||
if (ATU)
|
||||
ATU->unlinkTemporaryFile();
|
||||
|
||||
ReportSerializedDiagnostics(DiagnosticsFile, *Diags,
|
||||
num_unsaved_files, unsaved_files,
|
||||
ATU->getASTContext().getLangOptions());
|
||||
// FIXME: Currently we don't report diagnostics on invalid ASTs.
|
||||
if (ATU)
|
||||
ReportSerializedDiagnostics(DiagnosticsFile, *Diags,
|
||||
num_unsaved_files, unsaved_files,
|
||||
ATU->getASTContext().getLangOptions());
|
||||
|
||||
for (unsigned i = 0, e = TemporaryFiles.size(); i != e; ++i)
|
||||
TemporaryFiles[i].eraseFromDisk();
|
||||
|
@ -1306,6 +1308,18 @@ static Decl *getDeclFromExpr(Stmt *E) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static SourceLocation getLocationFromExpr(Expr *E) {
|
||||
if (ObjCMessageExpr *Msg = dyn_cast<ObjCMessageExpr>(E))
|
||||
return /*FIXME:*/Msg->getLeftLoc();
|
||||
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
|
||||
return DRE->getLocation();
|
||||
if (MemberExpr *Member = dyn_cast<MemberExpr>(E))
|
||||
return Member->getMemberLoc();
|
||||
if (ObjCIvarRefExpr *Ivar = dyn_cast<ObjCIvarRefExpr>(E))
|
||||
return Ivar->getLocation();
|
||||
return E->getLocStart();
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
unsigned clang_visitChildren(CXCursor parent,
|
||||
|
@ -1504,18 +1518,6 @@ CXCursorKind clang_getCursorKind(CXCursor C) {
|
|||
return C.kind;
|
||||
}
|
||||
|
||||
static SourceLocation getLocationFromExpr(Expr *E) {
|
||||
if (ObjCMessageExpr *Msg = dyn_cast<ObjCMessageExpr>(E))
|
||||
return /*FIXME:*/Msg->getLeftLoc();
|
||||
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
|
||||
return DRE->getLocation();
|
||||
if (MemberExpr *Member = dyn_cast<MemberExpr>(E))
|
||||
return Member->getMemberLoc();
|
||||
if (ObjCIvarRefExpr *Ivar = dyn_cast<ObjCIvarRefExpr>(E))
|
||||
return Ivar->getLocation();
|
||||
return E->getLocStart();
|
||||
}
|
||||
|
||||
CXSourceLocation clang_getCursorLocation(CXCursor C) {
|
||||
if (clang_isReference(C.kind)) {
|
||||
switch (C.kind) {
|
||||
|
|
Loading…
Reference in New Issue