r200380 - Short-circuit a couple of queries (and avoid corrupting
David Blaikie
dblaikie at gmail.com
Wed Jan 29 09:31:16 PST 2014
On Wed, Jan 29, 2014 at 8:46 AM, David Blaikie <dblaikie at gmail.com> wrote:
>
>
>
> On Wed, Jan 29, 2014 at 12:33 AM, John McCall <rjmccall at apple.com> wrote:
>
>> Author: rjmccall
>> Date: Wed Jan 29 02:33:09 2014
>> New Revision: 200380
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=200380&view=rev
>> Log:
>> Short-circuit a couple of queries (and avoid corrupting
>> the linkage cache) when type-checking static local
>> variables.
>>
>
>
Any chance of a test case or two?
>
Clearly not my day... carry on.
>
>
>>
>> There's a very deep problem here where the linkage of
>> a declaration can suddenly massively change as soon as
>> it's given a typedef name; these fixes, while optimizations
>> in their own right, are really just targeted workarounds.
>>
>> rdar://15928125
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/test/SemaCXX/linkage.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=200380&r1=200379&r2=200380&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jan 29 02:33:09 2014
>> @@ -8773,7 +8773,13 @@ void Sema::CheckCompleteVariableDeclarat
>> }
>> }
>>
>> + // Warn about externally-visible variables being defined without a
>> + // prior declaration. We only want to do this for global
>> + // declarations, but we also specifically need to avoid doing it for
>> + // class members because the linkage of an anonymous class can
>> + // change if it's later given a typedef name.
>> if (var->isThisDeclarationADefinition() &&
>> + var->getDeclContext()->getRedeclContext()->isFileContext() &&
>> var->isExternallyVisible() && var->hasLinkage() &&
>> getDiagnostics().getDiagnosticLevel(
>> diag::warn_missing_variable_declarations,
>> @@ -8910,7 +8916,7 @@ Sema::FinalizeDeclaration(Decl *ThisDecl
>> const DeclContext *DC = VD->getDeclContext();
>> // If there's a #pragma GCC visibility in scope, and this isn't a class
>> // member, set the visibility of this variable.
>> - if (!DC->isRecord() && VD->isExternallyVisible())
>> + if (DC->getRedeclContext()->isFileContext() &&
>> VD->isExternallyVisible())
>> AddPushedVisibilityAttribute(VD);
>>
>> if (VD->isFileVarDecl())
>>
>> Modified: cfe/trunk/test/SemaCXX/linkage.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/linkage.cpp?rev=200380&r1=200379&r2=200380&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/SemaCXX/linkage.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/linkage.cpp Wed Jan 29 02:33:09 2014
>> @@ -103,3 +103,13 @@ namespace test5 {
>> };
>> }
>> }
>> +
>> +// Test that we don't compute linkage too hastily before we're done
>> +// processing a record decl. rdar://15928125
>> +namespace test6 {
>> + typedef struct {
>> + void foo() {
>> + static int bar = 0;
>> + }
>> + } A;
>> +}
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140129/806c85f7/attachment.html>
More information about the cfe-commits
mailing list