r200889 - Fix -Wunused-variable 'FD' by using it instead of ND when they're equal but FD

Nick Lewycky nicholas at mxc.ca
Wed Feb 5 21:04:42 PST 2014


Justin Bogner wrote:
> Nick Lewycky<nicholas at mxc.ca>  writes:
>> Fix -Wunused-variable 'FD' by using it instead of ND when they're equal but FD
>> has a more precise type.
>>
>> Modified:
>>      cfe/trunk/lib/AST/MicrosoftMangle.cpp
>>
>> Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=200889&r1=200888&r2=200889&view=diff==============================================================================
>> --- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
>> +++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Wed Feb  5 17:53:29 2014
>> @@ -1093,11 +1093,11 @@ void MicrosoftCXXNameMangler::mangleTemp
>>       if (const FieldDecl *FD = dyn_cast<FieldDecl>(ND)) {
>>         mangleMemberDataPointer(cast<CXXRecordDecl>(FD->getParent()), FD);
>>       } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
>> -      const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(ND);
>> +      const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD);
>
> Is this better than using isa<>  instead of dyn_cast<>  in some way? Ie,
>
>      } else if (isa<FunctionDecl>(ND)) {
>        const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(ND);
>        ...

I haven't bothered to check, but probably not. The isa<> method calls 
classof, but you can overload classof at any level. If CXXMethodDecl has 
different classof implementations for when the static type is a 
FunctionDecl vs. NamedDecl, then it could be better.

But I didn't really think about it. It's common to declare the variable 
and then use it, and I figured that it was probably intended that way. I 
don't much care, if you want to change it, or if you want me to change 
it. Whatever.

Nick

>>         if (MD&&  MD->isInstance())
>>           mangleMemberFunctionPointer(MD->getParent(), MD);
>>         else
>> -        mangle(ND, "$1?");
>> +        mangle(FD, "$1?");
>>       } else {
>>         mangle(ND, TA.isDeclForReferenceParam() ? "$E?" : "$1?");
>>       }
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list