diff options
author | Sean Callanan <scallanan@apple.com> | 2011-12-03 03:15:28 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2011-12-03 03:15:28 +0000 |
commit | 3b107b172d51a80429dc6a7e2abb419eff3992fa (patch) | |
tree | c603f7d6e60223333a129814aeeefa8c025295c3 /lldb/source/Symbol/ClangASTContext.cpp | |
parent | 2869b5afe3cc962cfe33f17d44b0615deeeb7a38 (diff) | |
download | bcm5719-llvm-3b107b172d51a80429dc6a7e2abb419eff3992fa.tar.gz bcm5719-llvm-3b107b172d51a80429dc6a7e2abb419eff3992fa.zip |
Added ClangExternalASTSourceCommon, a local superclass
for all our external AST sources that lets us associate
arbitrary flags with the types we put into the AST
contexts. Also added an API on ClangASTContext that
allows access to these flags given only an ASTContext
and a type.
Because we don't have access to RTTI, and because at
some point in the future we might encounter external
AST sources that we didn't make (so they don't subclass
ClangExternalASTSourceCommon) I added a magic number
that we check before doing anything else, so that we
can catch that problem as soon as it appears.
llvm-svn: 145748
Diffstat (limited to 'lldb/source/Symbol/ClangASTContext.cpp')
-rw-r--r-- | lldb/source/Symbol/ClangASTContext.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 8ad8c836816..d156dae7124 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -61,6 +61,7 @@ #include "lldb/Core/Log.h" #include "lldb/Core/RegularExpression.h" #include "lldb/Expression/ASTDumper.h" +#include "lldb/Symbol/ClangExternalASTSourceCommon.h" #include "lldb/Symbol/VerifyDecl.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" @@ -5767,6 +5768,36 @@ ClangASTContext::GetTypeQualifiers(clang_type_t clang_type) return qual_type.getQualifiers().getCVRQualifiers(); } +uint64_t +GetTypeFlags(clang::ASTContext *ast, lldb::clang_type_t clang_type) +{ + assert (clang_type); + + clang::ExternalASTSource *external_ast_source = ast->getExternalSource(); + + if (!external_ast_source) + return 0; + + ClangExternalASTSourceCommon *common_ast_source = static_cast<ClangExternalASTSourceCommon*>(external_ast_source); + + return common_ast_source->GetMetadata((uintptr_t)clang_type); +} + +void +SetTypeFlags(clang::ASTContext *ast, lldb::clang_type_t clang_type, uint64_t flags) +{ + assert (clang_type); + + clang::ExternalASTSource *external_ast_source = ast->getExternalSource(); + + if (!external_ast_source) + return; + + ClangExternalASTSourceCommon *common_ast_source = static_cast<ClangExternalASTSourceCommon*>(external_ast_source); + + return common_ast_source->SetMetadata((uintptr_t)clang_type, flags); +} + bool ClangASTContext::GetCompleteType (clang::ASTContext *ast, lldb::clang_type_t clang_type) { |