summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2016-03-19 00:51:43 +0000
committerSean Callanan <scallanan@apple.com>2016-03-19 00:51:43 +0000
commitb3a36df39e60f1f5833930190b29a0a41336c24d (patch)
tree46ae5b97cbb17dd85d340aa80921369e0f366c8e /lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
parent8d05185a26ecbd1079b43651c427508a6156f1ea (diff)
downloadbcm5719-llvm-b3a36df39e60f1f5833930190b29a0a41336c24d.tar.gz
bcm5719-llvm-b3a36df39e60f1f5833930190b29a0a41336c24d.zip
Handle any persistent Decl in the Clang expression parser, not just types.
Persistent decls have traditionally only been types. However, we want to be able to persist more things, like functions and global variables. This changes some of the nomenclature and the lookup rules to make this possible. <rdar://problem/22864976> llvm-svn: 263864
Diffstat (limited to 'lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp')
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
index 9bf9d435d7e..d1478e49bff 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
@@ -14,6 +14,8 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Value.h"
+#include "clang/AST/Decl.h"
+
#include "llvm/ADT/StringMap.h"
using namespace lldb;
@@ -66,18 +68,26 @@ ClangPersistentVariables::GetNextPersistentVariableName ()
}
void
-ClangPersistentVariables::RegisterPersistentType (const ConstString &name,
- clang::TypeDecl *type_decl)
+ClangPersistentVariables::RegisterPersistentDecl (const ConstString &name,
+ clang::NamedDecl *decl)
{
- m_persistent_types.insert(std::pair<const char*, clang::TypeDecl*>(name.GetCString(), type_decl));
+ m_persistent_decls.insert(std::pair<const char*, clang::NamedDecl*>(name.GetCString(), decl));
+
+ if (clang::EnumDecl *enum_decl = llvm::dyn_cast<clang::EnumDecl>(decl))
+ {
+ for (clang::EnumConstantDecl *enumerator_decl : enum_decl->enumerators())
+ {
+ m_persistent_decls.insert(std::pair<const char*, clang::NamedDecl*>(ConstString(enumerator_decl->getNameAsString()).GetCString(), enumerator_decl));
+ }
+ }
}
-clang::TypeDecl *
-ClangPersistentVariables::GetPersistentType (const ConstString &name)
+clang::NamedDecl *
+ClangPersistentVariables::GetPersistentDecl (const ConstString &name)
{
- PersistentTypeMap::const_iterator i = m_persistent_types.find(name.GetCString());
+ PersistentDeclMap::const_iterator i = m_persistent_decls.find(name.GetCString());
- if (i == m_persistent_types.end())
+ if (i == m_persistent_decls.end())
return NULL;
else
return i->second;
OpenPOWER on IntegriCloud