[cfe-commits] r43023 - in /cfe/trunk: Sema/SemaDecl.cpp Sema/SemaExpr.cpp clang.xcodeproj/project.pbxproj
Steve Naroff
snaroff at apple.com
Wed Oct 17 20:55:18 PDT 2007
On Oct 17, 2007, at 5:37 PM, Chris Lattner wrote:
>> Bad cast...need to use dyn_cast_or_null. Also changed
>> Sema::InitBuiltinVaListType (which had the same bug).
>
> Hi Steve,
>
> Why are these dyn_cast_or_null? It seems like none of those cases
> allow null pointers?
>
The second case you forwarded currently needs it (you may be right
about the first).
If I don't use dyn_cast_or_null(), the following case will bus error.
With dyn_cast_or_null(), we assert (missing '@interface
NSConstantString').
[dylan:~/llvm/tools/clang] admin% cat trivial.m
@class NSString;
NSString *s = @"123";
This is because NSConstantString isn't really built-in - we rely on
seeing NSString.h to get the @interface for NSConstantString. This
dividing line between the language and library/platform is a little
murky (unfortunately, given the adhoc language evolution:-).
So...until we have a better solution for how to integrate
NSConstantString, I have the conservative dyn_cast_or_null. In
practice (with MacOS X/Cocoa), this isn't a problem. It's unlikely
developers will bump into this assert.
snaroff
> -Chris
>
>>
>> Modified:
>> cfe/trunk/Sema/SemaDecl.cpp
>> cfe/trunk/Sema/SemaExpr.cpp
>> cfe/trunk/clang.xcodeproj/project.pbxproj
>>
>> Modified: cfe/trunk/Sema/SemaDecl.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/
>> SemaDecl.cpp?rev=43023&r1=43022&r2=43023&view=diff
>>
>> =====================================================================
>> =========
>> --- cfe/trunk/Sema/SemaDecl.cpp (original)
>> +++ cfe/trunk/Sema/SemaDecl.cpp Mon Oct 15 19:00:18 2007
>> @@ -154,7 +154,7 @@
>> IdentifierInfo *VaIdent = &Context.Idents.get
>> ("__builtin_va_list");
>> ScopedDecl *VaDecl = LookupScopedDecl(VaIdent,
>> Decl::IDNS_Ordinary,
>> SourceLocation(),
>> TUScope);
>> - TypedefDecl *VaTypedef = cast<TypedefDecl>(VaDecl);
>> + TypedefDecl *VaTypedef = dyn_cast_or_null<TypedefDecl>(VaDecl);
>> Context.setBuiltinVaListType(Context.getTypedefType(VaTypedef));
>> }
>>
>>
>> Modified: cfe/trunk/Sema/SemaExpr.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/
>> SemaExpr.cpp?rev=43023&r1=43022&r2=43023&view=diff
>>
>> =====================================================================
>> =========
>> --- cfe/trunk/Sema/SemaExpr.cpp (original)
>> +++ cfe/trunk/Sema/SemaExpr.cpp Mon Oct 15 19:00:18 2007
>> @@ -1896,9 +1896,9 @@
>> IdentifierInfo *NSIdent = &Context.Idents.get
>> ("NSConstantString");
>> ScopedDecl *IFace = LookupScopedDecl(NSIdent,
>> Decl::IDNS_Ordinary,
>> SourceLocation(), TUScope);
>> - ObjcInterfaceDecl *stringInterface = cast<ObjcInterfaceDecl>
>> (IFace);
>> - assert(stringInterface && "missing '@interface
>> NSConstantString'");
>> - Context.setObjcConstantStringInterface(stringInterface);
>> + ObjcInterfaceDecl *strIFace =
>> dyn_cast_or_null<ObjcInterfaceDecl>(IFace);
>> + assert(strIFace && "missing '@interface NSConstantString'");
>> + Context.setObjcConstantStringInterface(strIFace);
>> }
>> QualType t = Context.getObjcConstantStringInterface();
>> t = Context.getPointerType(t);
>>
>> Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/
>> project.pbxproj?rev=43023&r1=43022&r2=43023&view=diff
>>
>> =====================================================================
>> =========
>> --- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
>> +++ cfe/trunk/clang.xcodeproj/project.pbxproj Mon Oct 15 19:00:18
>> 2007
>> @@ -742,7 +742,6 @@
>> 08FB7793FE84155DC02AAC07 /* Project object */ = {
>> isa = PBXProject;
>> buildConfigurationList = 1DEB923508733DC60010E9CD /* Build
>> configuration list for PBXProject "clang" */;
>> - compatibilityVersion = "Xcode 2.4";
>> hasScannedForEncodings = 1;
>> mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
>> projectDirPath = "";
>>
>>
>> _______________________________________________
>> 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/20071017/bb559ad2/attachment.html>
More information about the cfe-commits
mailing list