[Lldb-commits] [lldb] r263544 - Fix expression evaluation for resolving anonymous aggregrate types with a typedefed name

Ewan Crawford via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 15 02:50:16 PDT 2016


Author: ewancrawford
Date: Tue Mar 15 04:50:16 2016
New Revision: 263544

URL: http://llvm.org/viewvc/llvm-project?rev=263544&view=rev
Log:
Fix expression evaluation for resolving anonymous aggregrate types with a typedefed name

This fixes a recently reported a bug(https://llvm.org/bugs/show_bug.cgi?id=26790) relating to the clang expression evaluator no longer being able to resolve calls to
functions with arguments to typedefed anonymous structs, unions, or enums after a cleanup to the expression parsing code in r260768

This fixes the issue by attaching the tagged name to the original clang::TagDecl object when generating the typedef in lldb::ClangAstContext::CreateTypeDef.

This also fixes the issue for anonymous typedefs for non-struct types (unions and enums) where we have a tag name.


Author: Luke Drummond <luke.drummond at codeplay.com>
Differential Revision: http://reviews.llvm.org/D18099

Modified:
    lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=263544&r1=263543&r2=263544&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Mar 15 04:50:16 2016
@@ -4640,6 +4640,20 @@ ClangASTContext::CreateTypedef (lldb::op
                                                                &clang_ast->Idents.get(typedef_name),
                                                                clang_ast->getTrivialTypeSourceInfo(qual_type));
 
+        clang::TagDecl *tdecl = nullptr;
+        if (!qual_type.isNull())
+        {
+            if (const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
+                tdecl = rt->getDecl();
+            if (const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
+                tdecl = et->getDecl();
+        }
+
+        // Check whether this declaration is an anonymous struct, union, or enum, hidden behind a typedef. If so, we
+        // try to check whether we have a typedef tag to attach to the original record declaration
+        if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl())
+            tdecl->setTypedefNameForAnonDecl(decl);
+
         decl->setAccess(clang::AS_public); // TODO respect proper access specifier
 
         // Get a uniqued clang::QualType for the typedef decl type




More information about the lldb-commits mailing list