<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_unnamed_class(decls):
 """ Adds name to class_t declarations. If CastXML is being used, the type definitions with an unnamed class/struct are split across two nodes in the XML tree. For example, typedef struct {} cls; produces For each typedef, we look at which class it refers to, and update the name accordingly. This helps the matcher classes finding these declarations. This was the behaviour with gccxml too, so this is important for backward compatibility. If the castxml epic version 1 is used, there is even an elaborated type declaration between the typedef and the struct/class, that also needs to be taken care of. Args: decls (list[declaration_t]):
 a list of declarations to be patched. Returns: None """


    for decl in decls:
        if isinstance(decl, declarations.typedef_t):
            referent = decl.decl_type
            if isinstance(referent, declarations.elaborated_t):
                referent = referent.base
            if not isinstance(referent, declarations.declarated_t):
                continue
            referent = referent.declaration
            if referent.name or not isinstance(referent, declarations.class_t):
                continue
            referent.name = decl.name