r200380 - Short-circuit a couple of queries (and avoid corrupting
David Blaikie
dblaikie at gmail.com
Wed Jan 29 11:29:12 PST 2014
On Wed, Jan 29, 2014 at 11:26 AM, John McCall <rjmccall at apple.com> wrote:
> On 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?
>
>
> In addition to the test case I committed in this patch?
>
As others pointed out - it was clearly too early & I didn't notice the test
you already included.
> What do you have in mind?
> The test case used to crash.
>
Now that you mention that and I look at the test case - I'm usually a bit
concerned about test cases that are simply "do not crash" - could you test
that as well as not crashing, we actually do whatever right thing we
weren't doing before? (like codegen with the correct linkage?)
>
> John.
>
>
>
>>
>> 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/a8573711/attachment.html>
More information about the cfe-commits
mailing list