Simplify incomplete-array merging code in the AST importer, thanks to

Daniel's suggestion.

llvm-svn: 95987
This commit is contained in:
Douglas Gregor 2010-02-12 17:23:39 +00:00
parent 8870a49310
commit 56521c5e8c
1 changed files with 14 additions and 24 deletions

View File

@ -1038,30 +1038,20 @@ Decl *ASTNodeImporter::VisitVarDecl(VarDecl *D) {
break;
}
if (const IncompleteArrayType *FoundArray
= Importer.getToContext().getAsIncompleteArrayType(
FoundVar->getType())) {
if (const ConstantArrayType *TArray
= Importer.getToContext().getAsConstantArrayType(T)) {
if (Importer.getToContext().typesAreCompatible(
TArray->getElementType(),
FoundArray->getElementType())) {
FoundVar->setType(T);
MergeWithVar = FoundVar;
break;
}
}
} else if (const IncompleteArrayType *TArray
= Importer.getToContext().getAsIncompleteArrayType(T)) {
if (const ConstantArrayType *FoundArray
= Importer.getToContext().getAsConstantArrayType(
FoundVar->getType())) {
if (Importer.getToContext().typesAreCompatible(
TArray->getElementType(),
FoundArray->getElementType())) {
MergeWithVar = FoundVar;
break;
}
const ArrayType *FoundArray
= Importer.getToContext().getAsArrayType(FoundVar->getType());
const ArrayType *TArray
= Importer.getToContext().getAsArrayType(T);
if (FoundArray && TArray) {
if (isa<IncompleteArrayType>(FoundArray) &&
isa<ConstantArrayType>(TArray)) {
FoundVar->setType(T);
MergeWithVar = FoundVar;
break;
} else if (isa<IncompleteArrayType>(TArray) &&
isa<ConstantArrayType>(FoundArray)) {
MergeWithVar = FoundVar;
break;
}
}