summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Expression/ClangASTSource.h27
-rw-r--r--lldb/include/lldb/Symbol/ClangASTContext.h9
-rw-r--r--lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h29
-rw-r--r--lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h62
-rw-r--r--lldb/lldb.xcodeproj/project.pbxproj6
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp31
-rw-r--r--lldb/source/Symbol/ClangExternalASTSourceCommon.cpp40
7 files changed, 171 insertions, 33 deletions
diff --git a/lldb/include/lldb/Expression/ClangASTSource.h b/lldb/include/lldb/Expression/ClangASTSource.h
index f376c4b1394..542e926251b 100644
--- a/lldb/include/lldb/Expression/ClangASTSource.h
+++ b/lldb/include/lldb/Expression/ClangASTSource.h
@@ -13,7 +13,7 @@
#include <set>
#include "clang/Basic/IdentifierTable.h"
-#include "clang/AST/ExternalASTSource.h"
+#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
#include "lldb/Symbol/ClangASTImporter.h"
#include "lldb/Target/Target.h"
@@ -31,7 +31,7 @@ namespace lldb_private {
/// the actual lookups.
//----------------------------------------------------------------------
class ClangASTSource :
- public clang::ExternalASTSource,
+ public ClangExternalASTSourceCommon,
public ClangASTImporter::NamespaceMapCompleter
{
public:
@@ -198,7 +198,7 @@ public:
/// Clang AST contexts like to own their AST sources, so this is a
/// state-free proxy object.
//----------------------------------------------------------------------
- class ClangASTSourceProxy : public clang::ExternalASTSource
+ class ClangASTSourceProxy : public ClangExternalASTSourceCommon
{
public:
ClangASTSourceProxy (ClangASTSource &original) :
@@ -213,7 +213,7 @@ public:
return m_original.FindExternalVisibleDeclsByName(DC, Name);
}
- virtual clang::ExternalLoadResult
+ clang::ExternalLoadResult
FindExternalLexicalDecls (const clang::DeclContext *DC,
bool (*isKindWeWant)(clang::Decl::Kind),
llvm::SmallVectorImpl<clang::Decl*> &Decls)
@@ -221,13 +221,13 @@ public:
return m_original.FindExternalLexicalDecls(DC, isKindWeWant, Decls);
}
- virtual void
+ void
CompleteType (clang::TagDecl *Tag)
{
return m_original.CompleteType(Tag);
}
- virtual void
+ void
CompleteType (clang::ObjCInterfaceDecl *Class)
{
return m_original.CompleteType(Class);
@@ -237,6 +237,21 @@ public:
{
return m_original.StartTranslationUnit(Consumer);
}
+
+ uint64_t GetMetadata(uintptr_t object)
+ {
+ return m_original.GetMetadata(object);
+ }
+
+ void SetMetadata(uintptr_t object, uint64_t metadata)
+ {
+ return m_original.SetMetadata(object, metadata);
+ }
+
+ bool HasMetadata(uintptr_t object)
+ {
+ return m_original.HasMetadata(object);
+ }
private:
ClangASTSource &m_original;
};
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index 095d1d34717..3c9fd0987f3 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -849,6 +849,15 @@ public:
//------------------------------------------------------------------
static unsigned
GetTypeQualifiers(lldb::clang_type_t clang_type);
+
+ //------------------------------------------------------------------
+ // Flags
+ //------------------------------------------------------------------
+ static uint64_t
+ GetTypeFlags(clang::ASTContext *ast, lldb::clang_type_t clang_type);
+
+ static void
+ SetTypeFlags(clang::ASTContext *ast, lldb::clang_type_t clang_type, uint64_t flags);
protected:
//------------------------------------------------------------------
// Classes that inherit from ClangASTContext can see and modify these
diff --git a/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h b/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
index 2ab6dc27864..99ff12a8623 100644
--- a/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
+++ b/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
@@ -19,40 +19,15 @@
// Other libraries and framework includes
-// Clang headers like to use NDEBUG inside of them to enable/disable debug
-// releated features using "#ifndef NDEBUG" preprocessor blocks to do one thing
-// or another. This is bad because it means that if clang was built in release
-// mode, it assumes that you are building in release mode which is not always
-// the case. You can end up with functions that are defined as empty in header
-// files when NDEBUG is not defined, and this can cause link errors with the
-// clang .a files that you have since you might be missing functions in the .a
-// file. So we have to define NDEBUG when including clang headers to avoid any
-// mismatches. This is covered by rdar://problem/8691220
-
-#if !defined(NDEBUG) && !defined(LLVM_NDEBUG_OFF)
-#define LLDB_DEFINED_NDEBUG_FOR_CLANG
-#define NDEBUG
-// Need to include assert.h so it is as clang would expect it to be (disabled)
-#include <assert.h>
-#endif
-
-#include "clang/AST/ExternalASTSource.h"
-
-#ifdef LLDB_DEFINED_NDEBUG_FOR_CLANG
-#undef NDEBUG
-#undef LLDB_DEFINED_NDEBUG_FOR_CLANG
-// Need to re-include assert.h so it is as _we_ would expect it to be (enabled)
-#include <assert.h>
-#endif
-
// Project includes
#include "lldb/lldb-enumerations.h"
#include "lldb/Core/ClangForward.h"
#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
namespace lldb_private {
-class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource
+class ClangExternalASTSourceCallbacks : public ClangExternalASTSourceCommon
{
public:
diff --git a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h b/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h
new file mode 100644
index 00000000000..40a55508a88
--- /dev/null
+++ b/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h
@@ -0,0 +1,62 @@
+//===-- ClangExternalASTSourceCommon.h --------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ClangExternalASTSourceCommon_h
+#define liblldb_ClangExternalASTSourceCommon_h
+
+// Clang headers like to use NDEBUG inside of them to enable/disable debug
+// releated features using "#ifndef NDEBUG" preprocessor blocks to do one thing
+// or another. This is bad because it means that if clang was built in release
+// mode, it assumes that you are building in release mode which is not always
+// the case. You can end up with functions that are defined as empty in header
+// files when NDEBUG is not defined, and this can cause link errors with the
+// clang .a files that you have since you might be missing functions in the .a
+// file. So we have to define NDEBUG when including clang headers to avoid any
+// mismatches. This is covered by rdar://problem/8691220
+
+#if !defined(NDEBUG) && !defined(LLVM_NDEBUG_OFF)
+#define LLDB_DEFINED_NDEBUG_FOR_CLANG
+#define NDEBUG
+// Need to include assert.h so it is as clang would expect it to be (disabled)
+#include <assert.h>
+#endif
+
+#include "clang/AST/ExternalASTSource.h"
+
+#ifdef LLDB_DEFINED_NDEBUG_FOR_CLANG
+#undef NDEBUG
+#undef LLDB_DEFINED_NDEBUG_FOR_CLANG
+// Need to re-include assert.h so it is as _we_ would expect it to be (enabled)
+#include <assert.h>
+#endif
+
+namespace lldb_private {
+
+class ClangExternalASTSourceCommon : public clang::ExternalASTSource
+{
+public:
+ ClangExternalASTSourceCommon();
+
+ virtual uint64_t GetMetadata(uintptr_t object);
+ virtual void SetMetadata(uintptr_t object, uint64_t metadata);
+ virtual bool HasMetadata(uintptr_t object);
+private:
+ typedef llvm::DenseMap<uintptr_t, uint64_t> MetadataMap;
+
+ MetadataMap m_metadata;
+ uint64_t m_magic; ///< Because we don't have RTTI, we must take it
+ ///< on faith that any valid ExternalASTSource that
+ ///< we try to use the *Metadata APIs on inherits
+ ///< from ClangExternalASTSourceCommon. This magic
+ ///< number exists to enforce that.
+};
+
+};
+
+#endif
diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj
index afe6e8e242c..4ff953e67ad 100644
--- a/lldb/lldb.xcodeproj/project.pbxproj
+++ b/lldb/lldb.xcodeproj/project.pbxproj
@@ -387,6 +387,7 @@
26F5C32D10F3DFDD009D5894 /* libtermcap.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */; };
26F73062139D8FDB00FD51C7 /* History.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F73061139D8FDB00FD51C7 /* History.cpp */; };
494260DA14579144003C1C78 /* VerifyDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 494260D914579144003C1C78 /* VerifyDecl.cpp */; };
+ 4966DCC4148978A10028481B /* ClangExternalASTSourceCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4966DCC3148978A10028481B /* ClangExternalASTSourceCommon.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 */; };
@@ -1147,8 +1148,10 @@
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>"; };
+ 495B38431489714C002708C5 /* ClangExternalASTSourceCommon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ClangExternalASTSourceCommon.h; path = include/lldb/Symbol/ClangExternalASTSourceCommon.h; sourceTree = "<group>"; };
495BBACB119A0DBE00418BEA /* PathMappingList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PathMappingList.cpp; path = source/Target/PathMappingList.cpp; sourceTree = "<group>"; };
495BBACF119A0DE700418BEA /* PathMappingList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PathMappingList.h; path = include/lldb/Target/PathMappingList.h; sourceTree = "<group>"; };
+ 4966DCC3148978A10028481B /* ClangExternalASTSourceCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExternalASTSourceCommon.cpp; path = source/Symbol/ClangExternalASTSourceCommon.cpp; sourceTree = "<group>"; };
496B01581406DE8900F830D5 /* IRInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IRInterpreter.cpp; path = source/Expression/IRInterpreter.cpp; sourceTree = "<group>"; };
496B015A1406DEB100F830D5 /* IRInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IRInterpreter.h; path = include/lldb/Expression/IRInterpreter.h; sourceTree = "<group>"; };
497C86BD122823D800B54702 /* ClangUtilityFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangUtilityFunction.cpp; path = source/Expression/ClangUtilityFunction.cpp; sourceTree = "<group>"; };
@@ -2199,6 +2202,8 @@
49D8FB3513B558DE00411094 /* ClangASTImporter.cpp */,
49E45FA911F660DC008F7B28 /* ClangASTType.h */,
49E45FAD11F660FE008F7B28 /* ClangASTType.cpp */,
+ 495B38431489714C002708C5 /* ClangExternalASTSourceCommon.h */,
+ 4966DCC3148978A10028481B /* ClangExternalASTSourceCommon.cpp */,
26E6902E129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h */,
26E69030129C6BEF00DDECD9 /* ClangExternalASTSourceCallbacks.cpp */,
266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */,
@@ -3521,6 +3526,7 @@
49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */,
494260DA14579144003C1C78 /* VerifyDecl.cpp in Sources */,
49DA65031485C92A005FF180 /* AppleObjCSymbolVendor.cpp in Sources */,
+ 4966DCC4148978A10028481B /* ClangExternalASTSourceCommon.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
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)
{
diff --git a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp
new file mode 100644
index 00000000000..d5b7d57ae1c
--- /dev/null
+++ b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp
@@ -0,0 +1,40 @@
+//===-- ClangExternalASTSourceCommon.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/ClangExternalASTSourceCommon.h"
+
+using namespace lldb_private;
+
+#define ClangExternalASTSourceCommon_MAGIC (0x00112233aabbccddull)
+
+ClangExternalASTSourceCommon::ClangExternalASTSourceCommon() : clang::ExternalASTSource()
+{
+ m_magic = ClangExternalASTSourceCommon_MAGIC;
+}
+
+uint64_t ClangExternalASTSourceCommon::GetMetadata (uintptr_t object)
+{
+ assert (m_magic == ClangExternalASTSourceCommon_MAGIC);
+
+ return m_metadata[object];
+}
+
+void ClangExternalASTSourceCommon::SetMetadata (uintptr_t object, uint64_t metadata)
+{
+ assert (m_magic == ClangExternalASTSourceCommon_MAGIC);
+
+ m_metadata[object] = metadata;
+}
+
+bool ClangExternalASTSourceCommon::HasMetadata (uintptr_t object)
+{
+ assert (m_magic == ClangExternalASTSourceCommon_MAGIC);
+
+ return m_metadata.find(object) != m_metadata.end();
+} \ No newline at end of file
OpenPOWER on IntegriCloud