Added VerifyDecl, a function that, when LLDB is

linked against a debug LLVM, runs a variety of
functions -- currently just one -- that verify
that the Decls we create are valid.

ClangASTContext now calls this verifier whenever
it adds a Decl to a DeclContext, and the verifier
checks that the AccessSpecifier is sane.

llvm-svn: 143000
This commit is contained in:
Sean Callanan 2011-10-26 01:06:27 +00:00
parent 86edbf41d1
commit 5e9e1991e9
4 changed files with 82 additions and 0 deletions

View File

@ -0,0 +1,23 @@
//===-- VerifyDecl.h --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_VariableList_h_
#define lldb_VariableList_h_
namespace clang
{
class Decl;
}
namespace lldb_private
{
void VerifyDecl (clang::Decl *decl);
}
#endif

View File

@ -398,6 +398,7 @@
26F5C37510F3F61B009D5894 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C37410F3F61B009D5894 /* libobjc.dylib */; };
26F5C39110F3FA26009D5894 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; };
26F73062139D8FDB00FD51C7 /* History.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F73061139D8FDB00FD51C7 /* History.cpp */; };
494260DA14579144003C1C78 /* VerifyDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 494260D914579144003C1C78 /* VerifyDecl.cpp */; };
496B015B1406DEB100F830D5 /* IRInterpreter.h in Headers */ = {isa = PBXBuildFile; fileRef = 496B015A1406DEB100F830D5 /* IRInterpreter.h */; };
49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A1CAC31430E8BD00306AC9 /* ExpressionSourceCode.cpp */; };
49A71FE7141FFA5C00D59478 /* IRInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 496B01581406DE8900F830D5 /* IRInterpreter.cpp */; };
@ -1153,6 +1154,8 @@
491193501226386000578B7F /* ASTStructExtractor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTStructExtractor.cpp; path = source/Expression/ASTStructExtractor.cpp; sourceTree = "<group>"; };
49307AAD11DEA4D90081F992 /* IRForTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IRForTarget.cpp; path = source/Expression/IRForTarget.cpp; sourceTree = "<group>"; };
49307AB111DEA4F20081F992 /* IRForTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IRForTarget.h; path = include/lldb/Expression/IRForTarget.h; sourceTree = "<group>"; };
494260D7145790D5003C1C78 /* VerifyDecl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VerifyDecl.h; path = include/lldb/Symbol/VerifyDecl.h; sourceTree = "<group>"; };
494260D914579144003C1C78 /* VerifyDecl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VerifyDecl.cpp; path = source/Symbol/VerifyDecl.cpp; sourceTree = "<group>"; };
49445C2512245E3600C11A81 /* ClangExpressionParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExpressionParser.cpp; path = source/Expression/ClangExpressionParser.cpp; sourceTree = "<group>"; };
49445C2912245E5500C11A81 /* ClangExpressionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangExpressionParser.h; path = include/lldb/Expression/ClangExpressionParser.h; sourceTree = "<group>"; };
49445E341225AB6A00C11A81 /* ClangUserExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangUserExpression.h; path = include/lldb/Expression/ClangUserExpression.h; sourceTree = "<group>"; };
@ -2266,6 +2269,8 @@
26BC7F2210F1B8EC00F91463 /* Variable.cpp */,
26BC7C6810F1B6E900F91463 /* VariableList.h */,
26BC7F2310F1B8EC00F91463 /* VariableList.cpp */,
494260D7145790D5003C1C78 /* VerifyDecl.h */,
494260D914579144003C1C78 /* VerifyDecl.cpp */,
);
name = Symbol;
sourceTree = "<group>";
@ -3505,6 +3510,7 @@
49A71FE8141FFACF00D59478 /* DataEncoder.cpp in Sources */,
B207C4931429607D00F36E4E /* CommandObjectWatchpoint.cpp in Sources */,
49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */,
494260DA14579144003C1C78 /* VerifyDecl.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -61,6 +61,7 @@
#include "lldb/Core/Log.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Expression/ASTDumper.h"
#include "lldb/Symbol/VerifyDecl.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
@ -1182,7 +1183,13 @@ ClangASTContext::CreateClassTemplateDecl (DeclContext *decl_ctx,
NULL);
if (class_template_decl)
{
decl_ctx->addDecl (class_template_decl);
#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(class_template_decl);
#endif
}
return class_template_decl;
}
@ -1691,6 +1698,10 @@ ClangASTContext::AddMethodToCXXRecordType
cxx_method_decl->setParams (ArrayRef<ParmVarDecl*>(params));
cxx_record_decl->addDecl (cxx_method_decl);
#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(cxx_method_decl);
#endif
// printf ("decl->isPolymorphic() = %i\n", cxx_record_decl->isPolymorphic());
// printf ("decl->isAggregate() = %i\n", cxx_record_decl->isAggregate());
@ -1756,6 +1767,10 @@ ClangASTContext::AddFieldToRecordType
if (field)
{
record_decl->addDecl(field);
#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(field);
#endif
}
}
else
@ -2019,6 +2034,11 @@ ClangASTContext::AddObjCClassIVar
if (field)
{
class_interface_decl->addDecl(field);
#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(field);
#endif
return true;
}
}
@ -2191,6 +2211,9 @@ ClangASTContext::AddMethodToObjCObjectType
class_interface_decl->addDecl (objc_method_decl);
#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(objc_method_decl);
#endif
return objc_method_decl;
}
@ -4269,6 +4292,10 @@ ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, DeclContext *d
namespace_decl = NamespaceDecl::Create(*ast, decl_ctx, SourceLocation(), SourceLocation(), &identifier_info);
decl_ctx->addDecl (namespace_decl);
#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(namespace_decl);
#endif
}
return namespace_decl;
}
@ -4312,6 +4339,11 @@ ClangASTContext::CreateFunctionDeclaration (DeclContext *decl_ctx, const char *n
}
if (func_decl)
decl_ctx->addDecl (func_decl);
#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(func_decl);
#endif
return func_decl;
}
@ -4579,6 +4611,11 @@ ClangASTContext::AddEnumerationValueToEnumerationType
if (enumerator_decl)
{
enum_type->getDecl()->addDecl(enumerator_decl);
#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(enumerator_decl);
#endif
return true;
}
}

View File

@ -0,0 +1,16 @@
//===-- VerifyDecl.cpp ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Symbol/VerifyDecl.h"
#include "clang/AST/DeclBase.h"
void lldb_private::VerifyDecl (clang::Decl *decl)
{
decl->getAccess();
}