[cfe-commits] r95782 - in /cfe/trunk: lib/AST/ASTImporter.cpp lib/Frontend/ASTMerge.cpp test/ASTMerge/Inputs/var1.c test/ASTMerge/Inputs/var2.c test/ASTMerge/var.c
Douglas Gregor
dgregor at apple.com
Fri Feb 12 09:24:19 PST 2010
On Feb 11, 2010, at 8:35 AM, Daniel Dunbar wrote:
> Hi Doug,
>
> On Wed, Feb 10, 2010 at 9:16 AM, Douglas Gregor <dgregor at apple.com> wrote:
>> Author: dgregor
>> Date: Wed Feb 10 11:16:49 2010
>> New Revision: 95782
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=95782&view=rev
>> Log:
>> Teach AST merging that variables with incomplete array types can be
>> merged with variables of constant array types. Also, make sure that we
>> call DiagnosticClient's BeginSourceFile/EndSourceFile, so that it has
>> a LangOptions to work with.
>>
>> Modified:
>> cfe/trunk/lib/AST/ASTImporter.cpp
>> cfe/trunk/lib/Frontend/ASTMerge.cpp
>> cfe/trunk/test/ASTMerge/Inputs/var1.c
>> cfe/trunk/test/ASTMerge/Inputs/var2.c
>> cfe/trunk/test/ASTMerge/var.c
>>
>> Modified: cfe/trunk/lib/AST/ASTImporter.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=95782&r1=95781&r2=95782&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/AST/ASTImporter.cpp (original)
>> +++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Feb 10 11:16:49 2010
>> @@ -500,6 +500,33 @@
>> 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;
>> + }
>> + }
>> + }
>
> I think this would be more succinct if it just did two getAsArrayType
> calls, then checked that only one was incomplete?
Yeah, that's cleaner: r95987. Thanks!
- Doug
More information about the cfe-commits
mailing list