[Lldb-commits] [lldb] r223433 - This is the meat of the code to add Clang modules
Sean Callanan
scallanan at apple.com
Thu Dec 4 17:21:59 PST 2014
Author: spyffe
Date: Thu Dec 4 19:21:59 2014
New Revision: 223433
URL: http://llvm.org/viewvc/llvm-project?rev=223433&view=rev
Log:
This is the meat of the code to add Clang modules
support to LLDB. It includes the following:
- Changed DeclVendor to TypeVendor.
- Made the ObjCLanguageRuntime provide a DeclVendor
rather than a TypeVendor.
- Changed the consumers of TypeVendors to use
DeclVendors instead.
- Provided a few convenience functions on
ClangASTContext to make that easier.
Added:
lldb/trunk/include/lldb/Symbol/DeclVendor.h
- copied, changed from r223076, lldb/trunk/include/lldb/Symbol/TypeVendor.h
lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ClangModules/
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
- copied, changed from r223076, lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
- copied, changed from r223076, lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h
Removed:
lldb/trunk/include/lldb/Symbol/TypeVendor.h
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h
Modified:
lldb/trunk/include/lldb/Symbol/ClangASTContext.h
lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
lldb/trunk/source/Symbol/ClangASTContext.cpp
lldb/trunk/source/Target/Target.cpp
Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=223433&r1=223432&r2=223433&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Dec 4 19:21:59 2014
@@ -212,10 +212,13 @@ public:
ClangASTType type2,
bool ignore_qualifiers = false);
- ClangASTType
+ static ClangASTType
+ GetTypeForDecl (clang::NamedDecl *decl);
+
+ static ClangASTType
GetTypeForDecl (clang::TagDecl *decl);
- ClangASTType
+ static ClangASTType
GetTypeForDecl (clang::ObjCInterfaceDecl *objc_decl);
template <typename RecordDeclType>
Copied: lldb/trunk/include/lldb/Symbol/DeclVendor.h (from r223076, lldb/trunk/include/lldb/Symbol/TypeVendor.h)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/DeclVendor.h?p2=lldb/trunk/include/lldb/Symbol/DeclVendor.h&p1=lldb/trunk/include/lldb/Symbol/TypeVendor.h&r1=223076&r2=223433&rev=223433&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TypeVendor.h (original)
+++ lldb/trunk/include/lldb/Symbol/DeclVendor.h Thu Dec 4 19:21:59 2014
@@ -1,4 +1,4 @@
-//===-- TypeVendor.h --------------------------------------------*- C++ -*-===//
+//===-- DeclVendor.h --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,52 +7,64 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_TypeVendor_h_
-#define liblldb_TypeVendor_h_
+#ifndef liblldb_DeclVendor_h_
+#define liblldb_DeclVendor_h_
#include "lldb/Core/ClangForward.h"
+#include <vector>
+
namespace lldb_private {
//----------------------------------------------------------------------
-// The type vendor class is intended as a generic interface to search
-// for Clang types that are not necessarily backed by a specific symbol
-// file.
+// The Decl vendor class is intended as a generic interface to search
+// for named declarations that are not necessarily backed by a specific
+// symbol file.
//----------------------------------------------------------------------
-class TypeVendor
+class DeclVendor
{
public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- TypeVendor()
+ DeclVendor()
{
}
virtual
- ~TypeVendor()
+ ~DeclVendor()
{
}
+ //------------------------------------------------------------------
+ /// Look up the set of Decls that the DeclVendor currently knows about
+ /// matching a given name.
+ ///
+ /// @param[in] name
+ /// The name to look for.
+ ///
+ /// @param[in] append
+ /// If true, FindDecls will clear "decls" when it starts.
+ ///
+ /// @param[in] max_matches
+ /// The maximum number of Decls to return. UINT32_MAX means "as
+ /// many as possible."
+ ///
+ /// @return
+ /// The number of Decls added to decls; will not exceed
+ /// max_matches.
+ //------------------------------------------------------------------
virtual uint32_t
- FindTypes (const ConstString &name,
+ FindDecls (const ConstString &name,
bool append,
uint32_t max_matches,
- std::vector <ClangASTType> &types) = 0;
-
- virtual clang::ASTContext *
- GetClangASTContext () = 0;
-
-protected:
- //------------------------------------------------------------------
- // Classes that inherit from TypeVendor can see and modify these
- //------------------------------------------------------------------
+ std::vector <clang::NamedDecl*> &decls) = 0;
private:
//------------------------------------------------------------------
- // For TypeVendor only
+ // For DeclVendor only
//------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (TypeVendor);
+ DISALLOW_COPY_AND_ASSIGN (DeclVendor);
};
Removed: lldb/trunk/include/lldb/Symbol/TypeVendor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeVendor.h?rev=223432&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TypeVendor.h (original)
+++ lldb/trunk/include/lldb/Symbol/TypeVendor.h (removed)
@@ -1,61 +0,0 @@
-//===-- TypeVendor.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_TypeVendor_h_
-#define liblldb_TypeVendor_h_
-
-#include "lldb/Core/ClangForward.h"
-
-namespace lldb_private {
-
-//----------------------------------------------------------------------
-// The type vendor class is intended as a generic interface to search
-// for Clang types that are not necessarily backed by a specific symbol
-// file.
-//----------------------------------------------------------------------
-class TypeVendor
-{
-public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- TypeVendor()
- {
- }
-
- virtual
- ~TypeVendor()
- {
- }
-
- virtual uint32_t
- FindTypes (const ConstString &name,
- bool append,
- uint32_t max_matches,
- std::vector <ClangASTType> &types) = 0;
-
- virtual clang::ASTContext *
- GetClangASTContext () = 0;
-
-protected:
- //------------------------------------------------------------------
- // Classes that inherit from TypeVendor can see and modify these
- //------------------------------------------------------------------
-
-private:
- //------------------------------------------------------------------
- // For TypeVendor only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (TypeVendor);
-};
-
-
-} // namespace lldb_private
-
-#endif
Modified: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=223433&r1=223432&r2=223433&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h Thu Dec 4 19:21:59 2014
@@ -21,8 +21,8 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Symbol/ClangASTType.h"
+#include "lldb/Symbol/DeclVendor.h"
#include "lldb/Symbol/Type.h"
-#include "lldb/Symbol/TypeVendor.h"
#include "lldb/Target/LanguageRuntime.h"
namespace lldb_private {
@@ -385,8 +385,8 @@ public:
virtual ObjCISA
GetParentClass(ObjCISA isa);
- virtual TypeVendor *
- GetTypeVendor()
+ virtual DeclVendor *
+ GetDeclVendor()
{
return NULL;
}
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=223433&r1=223432&r2=223433&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Thu Dec 4 19:21:59 2014
@@ -26,6 +26,7 @@
#include "lldb/Core/Event.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/UserSettingsController.h"
+#include "lldb/Expression/ClangModulesDeclVendor.h"
#include "lldb/Expression/ClangPersistentVariables.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/OptionValueBoolean.h"
@@ -1346,6 +1347,9 @@ public:
SourceManager &
GetSourceManager ();
+
+ ClangModulesDeclVendor *
+ GetClangModulesDeclVendor ();
//------------------------------------------------------------------
// Methods.
@@ -1383,6 +1387,7 @@ protected:
std::unique_ptr<ClangASTContext> m_scratch_ast_context_ap;
std::unique_ptr<ClangASTSource> m_scratch_ast_source_ap;
std::unique_ptr<ClangASTImporter> m_ast_importer_ap;
+ std::unique_ptr<ClangModulesDeclVendor> m_clang_modules_decl_vendor_ap;
ClangPersistentVariables m_persistent_variables; ///< These are the persistent variables associated with this process for the expression parser.
std::unique_ptr<SourceManager> m_source_manager_ap;
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=223433&r1=223432&r2=223433&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Dec 4 19:21:59 2014
@@ -602,12 +602,14 @@
490A36C2180F0E9300BA31F8 /* PlatformWindows.h in Headers */ = {isa = PBXBuildFile; fileRef = 490A36BE180F0E6F00BA31F8 /* PlatformWindows.h */; };
490A966B1628C3BF00F0002E /* SBDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 9452573816262CEF00325455 /* SBDeclaration.h */; settings = {ATTRIBUTES = (Public, ); }; };
494260DA14579144003C1C78 /* VerifyDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 494260D914579144003C1C78 /* VerifyDecl.cpp */; };
+ 4959511D1A1BC49500F6F8FC /* ClangModulesDeclVendor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4959511B1A1BC48100F6F8FC /* ClangModulesDeclVendor.h */; };
+ 4959511F1A1BC4BC00F6F8FC /* ClangModulesDeclVendor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4959511E1A1BC4BC00F6F8FC /* ClangModulesDeclVendor.cpp */; };
4966DCC4148978A10028481B /* ClangExternalASTSourceCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4966DCC3148978A10028481B /* ClangExternalASTSourceCommon.cpp */; };
49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A1CAC31430E8BD00306AC9 /* ExpressionSourceCode.cpp */; };
49A71FE7141FFA5C00D59478 /* IRInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 496B01581406DE8900F830D5 /* IRInterpreter.cpp */; };
49A71FE8141FFACF00D59478 /* DataEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268ED0A4140FF54200DE830F /* DataEncoder.cpp */; };
49D8FB3913B5598F00411094 /* ClangASTImporter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49D8FB3513B558DE00411094 /* ClangASTImporter.cpp */; };
- 49DA65031485C92A005FF180 /* AppleObjCTypeVendor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DA65021485C92A005FF180 /* AppleObjCTypeVendor.cpp */; };
+ 49DA65031485C92A005FF180 /* AppleObjCDeclVendor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DA65021485C92A005FF180 /* AppleObjCDeclVendor.cpp */; };
49DCF6FE170E6B4A0092F75E /* IRMemoryMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DCF6FD170E6B4A0092F75E /* IRMemoryMap.cpp */; };
49DCF702170E70120092F75E /* Materializer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DCF700170E70120092F75E /* Materializer.cpp */; };
4C3ADCD61810D88B00357218 /* BreakpointResolverFileRegex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CAA56141422D986001FFA01 /* BreakpointResolverFileRegex.cpp */; };
@@ -1867,6 +1869,8 @@
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>"; };
+ 4959511B1A1BC48100F6F8FC /* ClangModulesDeclVendor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangModulesDeclVendor.h; path = include/lldb/Expression/ClangModulesDeclVendor.h; sourceTree = "<group>"; };
+ 4959511E1A1BC4BC00F6F8FC /* ClangModulesDeclVendor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangModulesDeclVendor.cpp; path = source/Expression/ClangModulesDeclVendor.cpp; 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>"; };
@@ -1883,7 +1887,7 @@
49A1CAC31430E8BD00306AC9 /* ExpressionSourceCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExpressionSourceCode.cpp; path = source/Expression/ExpressionSourceCode.cpp; sourceTree = "<group>"; };
49A8A39F11D568A300AD3B68 /* ASTResultSynthesizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTResultSynthesizer.cpp; path = source/Expression/ASTResultSynthesizer.cpp; sourceTree = "<group>"; };
49A8A3A311D568BF00AD3B68 /* ASTResultSynthesizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASTResultSynthesizer.h; path = include/lldb/Expression/ASTResultSynthesizer.h; sourceTree = "<group>"; };
- 49B01A2D15F67B1700666829 /* TypeVendor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeVendor.h; path = include/lldb/Symbol/TypeVendor.h; sourceTree = "<group>"; };
+ 49B01A2D15F67B1700666829 /* DeclVendor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DeclVendor.h; path = include/lldb/Symbol/DeclVendor.h; sourceTree = "<group>"; };
49BB309511F79450001A4197 /* TaggedASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TaggedASTType.h; path = include/lldb/Symbol/TaggedASTType.h; sourceTree = "<group>"; };
49C66B1C17011A43004D1922 /* IRMemoryMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = IRMemoryMap.h; path = include/lldb/Expression/IRMemoryMap.h; sourceTree = "<group>"; };
49CF9829122C70BD007A0B96 /* IRDynamicChecks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IRDynamicChecks.cpp; path = source/Expression/IRDynamicChecks.cpp; sourceTree = "<group>"; };
@@ -1894,8 +1898,8 @@
49D7072811B5AD11001AD875 /* ClangASTSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangASTSource.cpp; path = source/Expression/ClangASTSource.cpp; sourceTree = "<group>"; };
49D8FB3513B558DE00411094 /* ClangASTImporter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangASTImporter.cpp; path = source/Symbol/ClangASTImporter.cpp; sourceTree = "<group>"; };
49D8FB3713B5594900411094 /* ClangASTImporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangASTImporter.h; path = include/lldb/Symbol/ClangASTImporter.h; sourceTree = "<group>"; };
- 49DA65021485C92A005FF180 /* AppleObjCTypeVendor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleObjCTypeVendor.cpp; sourceTree = "<group>"; };
- 49DA65041485C942005FF180 /* AppleObjCTypeVendor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppleObjCTypeVendor.h; sourceTree = "<group>"; };
+ 49DA65021485C92A005FF180 /* AppleObjCDeclVendor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = AppleObjCDeclVendor.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
+ 49DA65041485C942005FF180 /* AppleObjCDeclVendor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppleObjCDeclVendor.h; sourceTree = "<group>"; };
49DCF6FD170E6B4A0092F75E /* IRMemoryMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IRMemoryMap.cpp; path = source/Expression/IRMemoryMap.cpp; sourceTree = "<group>"; };
49DCF6FF170E6FD90092F75E /* Materializer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Materializer.h; path = include/lldb/Expression/Materializer.h; sourceTree = "<group>"; };
49DCF700170E70120092F75E /* Materializer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Materializer.cpp; path = source/Expression/Materializer.cpp; sourceTree = "<group>"; };
@@ -1956,10 +1960,10 @@
4CCA643E13B40B82003BDF98 /* ItaniumABILanguageRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ItaniumABILanguageRuntime.h; sourceTree = "<group>"; };
4CCA644213B40B82003BDF98 /* AppleObjCRuntime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleObjCRuntime.cpp; sourceTree = "<group>"; };
4CCA644313B40B82003BDF98 /* AppleObjCRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleObjCRuntime.h; sourceTree = "<group>"; };
- 4CCA644413B40B82003BDF98 /* AppleObjCRuntimeV1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleObjCRuntimeV1.cpp; sourceTree = "<group>"; };
- 4CCA644513B40B82003BDF98 /* AppleObjCRuntimeV1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleObjCRuntimeV1.h; sourceTree = "<group>"; };
- 4CCA644613B40B82003BDF98 /* AppleObjCRuntimeV2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleObjCRuntimeV2.cpp; sourceTree = "<group>"; };
- 4CCA644713B40B82003BDF98 /* AppleObjCRuntimeV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleObjCRuntimeV2.h; sourceTree = "<group>"; };
+ 4CCA644413B40B82003BDF98 /* AppleObjCRuntimeV1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = AppleObjCRuntimeV1.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
+ 4CCA644513B40B82003BDF98 /* AppleObjCRuntimeV1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = AppleObjCRuntimeV1.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
+ 4CCA644613B40B82003BDF98 /* AppleObjCRuntimeV2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = AppleObjCRuntimeV2.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
+ 4CCA644713B40B82003BDF98 /* AppleObjCRuntimeV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = AppleObjCRuntimeV2.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
4CCA644813B40B82003BDF98 /* AppleObjCTrampolineHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleObjCTrampolineHandler.cpp; sourceTree = "<group>"; };
4CCA644913B40B82003BDF98 /* AppleObjCTrampolineHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleObjCTrampolineHandler.h; sourceTree = "<group>"; };
4CCA644A13B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleThreadPlanStepThroughObjCTrampoline.cpp; sourceTree = "<group>"; };
@@ -2079,7 +2083,7 @@
94CD7D0719A3FB8600908B7C /* AppleObjCClassDescriptorV2.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppleObjCClassDescriptorV2.h; sourceTree = "<group>"; };
94CD7D0819A3FBA300908B7C /* AppleObjCClassDescriptorV2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleObjCClassDescriptorV2.cpp; sourceTree = "<group>"; };
94CD7D0A19A3FBC300908B7C /* AppleObjCTypeEncodingParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppleObjCTypeEncodingParser.h; sourceTree = "<group>"; };
- 94CD7D0B19A3FBCE00908B7C /* AppleObjCTypeEncodingParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleObjCTypeEncodingParser.cpp; sourceTree = "<group>"; };
+ 94CD7D0B19A3FBCE00908B7C /* AppleObjCTypeEncodingParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = AppleObjCTypeEncodingParser.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
94D0B10A16D5535900EA9C70 /* LibCxx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibCxx.cpp; path = source/DataFormatters/LibCxx.cpp; sourceTree = "<group>"; };
94D0B10B16D5535900EA9C70 /* LibStdcpp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibStdcpp.cpp; path = source/DataFormatters/LibStdcpp.cpp; sourceTree = "<group>"; };
94D6A0A716CEB55F00833B6E /* NSArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NSArray.cpp; path = source/DataFormatters/NSArray.cpp; sourceTree = "<group>"; };
@@ -2146,7 +2150,7 @@
9A9831041125FC5800A56CB0 /* SBProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBProcess.h; path = include/lldb/API/SBProcess.h; sourceTree = "<group>"; };
9A9831051125FC5800A56CB0 /* SBSourceManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBSourceManager.cpp; path = source/API/SBSourceManager.cpp; sourceTree = "<group>"; };
9A9831061125FC5800A56CB0 /* SBSourceManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBSourceManager.h; path = include/lldb/API/SBSourceManager.h; sourceTree = "<group>"; };
- 9A9831071125FC5800A56CB0 /* SBTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBTarget.cpp; path = source/API/SBTarget.cpp; sourceTree = "<group>"; };
+ 9A9831071125FC5800A56CB0 /* SBTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = SBTarget.cpp; path = source/API/SBTarget.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
9A9831081125FC5800A56CB0 /* SBTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBTarget.h; path = include/lldb/API/SBTarget.h; sourceTree = "<group>"; };
9A9831091125FC5800A56CB0 /* SBThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBThread.cpp; path = source/API/SBThread.cpp; sourceTree = "<group>"; };
9A98310A1125FC5800A56CB0 /* SBThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBThread.h; path = include/lldb/API/SBThread.h; sourceTree = "<group>"; };
@@ -3449,6 +3453,7 @@
26BC7F1510F1B8EC00F91463 /* CompileUnit.cpp */,
26BC7C5810F1B6E900F91463 /* Declaration.h */,
26BC7F1610F1B8EC00F91463 /* Declaration.cpp */,
+ 49B01A2D15F67B1700666829 /* DeclVendor.h */,
26BC7C5910F1B6E900F91463 /* DWARFCallFrameInfo.h */,
26BC7F1710F1B8EC00F91463 /* DWARFCallFrameInfo.cpp */,
26BC7C5A10F1B6E900F91463 /* Function.h */,
@@ -3478,7 +3483,6 @@
26BC7F2010F1B8EC00F91463 /* Type.cpp */,
26BC7C6610F1B6E900F91463 /* TypeList.h */,
26BC7F2110F1B8EC00F91463 /* TypeList.cpp */,
- 49B01A2D15F67B1700666829 /* TypeVendor.h */,
269FF07F12494F8E00225026 /* UnwindPlan.h */,
961FABB91235DE1600F93A47 /* UnwindPlan.cpp */,
269FF08112494FC200225026 /* UnwindTable.h */,
@@ -3619,6 +3623,8 @@
49445C2512245E3600C11A81 /* ClangExpressionParser.cpp */,
26BC7DC110F1B79500F91463 /* ClangExpressionVariable.h */,
26BC7ED610F1B86700F91463 /* ClangExpressionVariable.cpp */,
+ 4959511B1A1BC48100F6F8FC /* ClangModulesDeclVendor.h */,
+ 4959511E1A1BC4BC00F6F8FC /* ClangModulesDeclVendor.cpp */,
49D4FE821210B5FB00CDB854 /* ClangPersistentVariables.h */,
49D4FE871210B61C00CDB854 /* ClangPersistentVariables.cpp */,
49445E341225AB6A00C11A81 /* ClangUserExpression.h */,
@@ -4256,8 +4262,8 @@
4CCA644913B40B82003BDF98 /* AppleObjCTrampolineHandler.h */,
94CD7D0A19A3FBC300908B7C /* AppleObjCTypeEncodingParser.h */,
94CD7D0B19A3FBCE00908B7C /* AppleObjCTypeEncodingParser.cpp */,
- 49DA65041485C942005FF180 /* AppleObjCTypeVendor.h */,
- 49DA65021485C92A005FF180 /* AppleObjCTypeVendor.cpp */,
+ 49DA65041485C942005FF180 /* AppleObjCDeclVendor.h */,
+ 49DA65021485C92A005FF180 /* AppleObjCDeclVendor.cpp */,
4CCA644A13B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */,
4CCA644B13B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.h */,
);
@@ -4635,6 +4641,7 @@
2697A39515E404BA003E682C /* OptionValueArch.h in Headers */,
26474CBF18D0CB2D0073DEBA /* RegisterContextMach_i386.h in Headers */,
26474CC118D0CB2D0073DEBA /* RegisterContextMach_x86_64.h in Headers */,
+ 4959511D1A1BC49500F6F8FC /* ClangModulesDeclVendor.h in Headers */,
4C73152219B7D71700F865A4 /* Iterable.h in Headers */,
2698699D15E6CBD0002415FF /* OperatingSystemPython.h in Headers */,
232CB618191E00CD00EF39FC /* NativeBreakpointList.h in Headers */,
@@ -4700,6 +4707,7 @@
26680205115FD0ED008E1FE4 /* Frameworks */,
261B5A7511C3FA6F00AABD0A /* Fixup Framework Headers */,
9A19ACE2116563A700E0D453 /* Finish swig wrapper classes (lldb) */,
+ 4959511A1A1ACE9500F6F8FC /* Install Clang compiler headers */,
ED4AFF44199C2207004FFDC6 /* CopyFiles */,
);
buildRules = (
@@ -4944,6 +4952,21 @@
shellPath = /bin/sh;
shellScript = "$SRCROOT/scripts/build-swig-wrapper-classes.sh $SRCROOT $TARGET_BUILD_DIR $CONFIGURATION_BUILD_DIR \"\"\n";
};
+ 4959511A1A1ACE9500F6F8FC /* Install Clang compiler headers */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "$(BUILT_PRODUCTS_DIR)/LLDB.framework/Resources/Clang",
+ );
+ name = "Install Clang compiler headers";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "/usr/bin/python $SRCROOT/scripts/package-clang-headers.py $TARGET_BUILD_DIR $LLVM_BUILD_DIR/$CURRENT_ARCH/$LLVM_CONFIGURATION";
+ };
4C3326CA18B2A2B800EB5DD7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -5113,6 +5136,7 @@
2689002413353DDE00698AC0 /* CommandObjectSettings.cpp in Sources */,
2689002513353DDE00698AC0 /* CommandObjectSource.cpp in Sources */,
2689002613353DDE00698AC0 /* CommandObjectSyntax.cpp in Sources */,
+ 4959511F1A1BC4BC00F6F8FC /* ClangModulesDeclVendor.cpp in Sources */,
26BC179918C7F2B300D2196D /* JITLoader.cpp in Sources */,
2689002713353DDE00698AC0 /* CommandObjectTarget.cpp in Sources */,
2689002813353DDE00698AC0 /* CommandObjectThread.cpp in Sources */,
@@ -5475,7 +5499,7 @@
26EFC4CD18CFAF0D00865D87 /* ObjectFileJIT.cpp in Sources */,
49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */,
494260DA14579144003C1C78 /* VerifyDecl.cpp in Sources */,
- 49DA65031485C92A005FF180 /* AppleObjCTypeVendor.cpp in Sources */,
+ 49DA65031485C92A005FF180 /* AppleObjCDeclVendor.cpp in Sources */,
4966DCC4148978A10028481B /* ClangExternalASTSourceCommon.cpp in Sources */,
26A527C114E24F5F00F3A14A /* ProcessMachCore.cpp in Sources */,
26A527C314E24F5F00F3A14A /* ThreadMachCore.cpp in Sources */,
Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=223433&r1=223432&r2=223433&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Thu Dec 4 19:21:59 2014
@@ -2315,14 +2315,19 @@ SBTarget::FindFirstType (const char* typ
if (objc_language_runtime)
{
- TypeVendor *objc_type_vendor = objc_language_runtime->GetTypeVendor();
+ DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
- if (objc_type_vendor)
+ if (objc_decl_vendor)
{
- std::vector <ClangASTType> types;
+ std::vector <clang::NamedDecl *> decls;
- if (objc_type_vendor->FindTypes(const_typename, true, 1, types) > 0)
- return SBType(types[0]);
+ if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0)
+ {
+ if (ClangASTType type = ClangASTContext::GetTypeForDecl(decls[0]))
+ {
+ return SBType(type);
+ }
+ }
}
}
}
@@ -2388,17 +2393,20 @@ SBTarget::FindTypes (const char* typenam
if (objc_language_runtime)
{
- TypeVendor *objc_type_vendor = objc_language_runtime->GetTypeVendor();
+ DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
- if (objc_type_vendor)
+ if (objc_decl_vendor)
{
- std::vector <ClangASTType> types;
+ std::vector <clang::NamedDecl *> decls;
- if (objc_type_vendor->FindTypes(const_typename, true, UINT32_MAX, types))
+ if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0)
{
- for (ClangASTType &type : types)
+ for (clang::NamedDecl *decl : decls)
{
- sb_type_list.Append(SBType(type));
+ if (ClangASTType type = ClangASTContext::GetTypeForDecl(decl))
+ {
+ sb_type_list.Append(SBType(type));
+ }
}
}
}
Added: lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp?rev=223433&view=auto
==============================================================================
--- lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp (added)
+++ lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp Thu Dec 4 19:21:59 2014
@@ -0,0 +1,370 @@
+//===-- ClangModulesDeclVendor.cpp ------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ClangModulesDeclVendor.h"
+
+#include "lldb/Core/StreamString.h"
+#include "lldb/Host/FileSpec.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/Target.h"
+
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Parse/Parser.h"
+#include "clang/Sema/Lookup.h"
+#include "clang/Serialization/ASTReader.h"
+
+using namespace lldb_private;
+
+namespace {
+ // Any Clang compiler requires a consumer for diagnostics. This one stores them as strings
+ // so we can provide them to the user in case a module failed to load.
+ class StoringDiagnosticConsumer : public clang::DiagnosticConsumer
+ {
+ public:
+ StoringDiagnosticConsumer ();
+ void
+ HandleDiagnostic (clang::DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &info);
+
+ void
+ ClearDiagnostics ();
+
+ void
+ DumpDiagnostics (Stream &error_stream);
+ private:
+ typedef std::pair<clang::DiagnosticsEngine::Level, std::string> IDAndDiagnostic;
+ std::vector<IDAndDiagnostic> m_diagnostics;
+ Log * m_log;
+ };
+
+ // The private implementation of our ClangModulesDeclVendor. Contains all the Clang state required
+ // to load modules.
+ class ClangModulesDeclVendorImpl : public ClangModulesDeclVendor
+ {
+ public:
+ ClangModulesDeclVendorImpl(llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine> &diagnostics_engine,
+ llvm::IntrusiveRefCntPtr<clang::CompilerInvocation> &compiler_invocation,
+ std::unique_ptr<clang::CompilerInstance> &&compiler_instance,
+ std::unique_ptr<clang::Parser> &&parser);
+
+ virtual bool
+ AddModule(std::vector<llvm::StringRef> &path,
+ Stream &error_stream);
+
+ virtual uint32_t
+ FindDecls (const ConstString &name,
+ bool append,
+ uint32_t max_matches,
+ std::vector <clang::NamedDecl*> &decls);
+
+ ~ClangModulesDeclVendorImpl();
+
+ private:
+ clang::ModuleLoadResult
+ DoGetModule(clang::ModuleIdPath path, bool make_visible);
+
+ llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine> m_diagnostics_engine;
+ llvm::IntrusiveRefCntPtr<clang::CompilerInvocation> m_compiler_invocation;
+ std::unique_ptr<clang::CompilerInstance> m_compiler_instance;
+ std::unique_ptr<clang::Parser> m_parser;
+ };
+}
+
+StoringDiagnosticConsumer::StoringDiagnosticConsumer ()
+{
+ m_log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
+}
+
+void
+StoringDiagnosticConsumer::HandleDiagnostic (clang::DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &info)
+{
+ llvm::SmallVector<char, 256> diagnostic_string;
+
+ info.FormatDiagnostic(diagnostic_string);
+
+ m_diagnostics.push_back(IDAndDiagnostic(DiagLevel, std::string(diagnostic_string.data(), diagnostic_string.size())));
+}
+
+void
+StoringDiagnosticConsumer::ClearDiagnostics ()
+{
+ m_diagnostics.clear();
+}
+
+void
+StoringDiagnosticConsumer::DumpDiagnostics (Stream &error_stream)
+{
+ for (IDAndDiagnostic &diag : m_diagnostics)
+ {
+ switch (diag.first)
+ {
+ default:
+ error_stream.PutCString(diag.second.c_str());
+ break;
+ case clang::DiagnosticsEngine::Level::Ignored:
+ break;
+ }
+ }
+}
+
+static FileSpec
+GetResourceDir ()
+{
+ static FileSpec g_cached_resource_dir;
+
+ static std::once_flag g_once_flag;
+
+ std::call_once(g_once_flag, [](){
+ HostInfo::GetLLDBPath (lldb::ePathTypeClangDir, g_cached_resource_dir);
+ });
+
+ return g_cached_resource_dir;
+}
+
+
+ClangModulesDeclVendor::ClangModulesDeclVendor()
+{
+}
+
+ClangModulesDeclVendor::~ClangModulesDeclVendor()
+{
+}
+
+ClangModulesDeclVendorImpl::ClangModulesDeclVendorImpl(llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine> &diagnostics_engine,
+ llvm::IntrusiveRefCntPtr<clang::CompilerInvocation> &compiler_invocation,
+ std::unique_ptr<clang::CompilerInstance> &&compiler_instance,
+ std::unique_ptr<clang::Parser> &&parser) :
+ ClangModulesDeclVendor(),
+ m_diagnostics_engine(diagnostics_engine),
+ m_compiler_invocation(compiler_invocation),
+ m_compiler_instance(std::move(compiler_instance)),
+ m_parser(std::move(parser))
+{
+}
+
+bool
+ClangModulesDeclVendorImpl::AddModule(std::vector<llvm::StringRef> &path,
+ Stream &error_stream)
+{
+ // Fail early.
+
+ if (m_compiler_instance->hadModuleLoaderFatalFailure())
+ {
+ error_stream.PutCString("error: Couldn't load a module because the module loader is in a fatal state.\n");
+ return false;
+ }
+
+ if (!m_compiler_instance->getPreprocessor().getHeaderSearchInfo().lookupModule(path[0]))
+ {
+ error_stream.Printf("error: Header search couldn't locate module %s\n", path[0].str().c_str());
+ return false;
+ }
+
+ llvm::SmallVector<std::pair<clang::IdentifierInfo *, clang::SourceLocation>, 4> clang_path;
+
+ {
+ size_t source_loc_counter = 0;
+ clang::SourceManager &source_manager = m_compiler_instance->getASTContext().getSourceManager();
+
+ for (llvm::StringRef &component : path)
+ {
+ clang_path.push_back(std::make_pair(&m_compiler_instance->getASTContext().Idents.get(component),
+ source_manager.getLocForStartOfFile(source_manager.getMainFileID()).getLocWithOffset(source_loc_counter++)));
+ }
+ }
+
+ StoringDiagnosticConsumer *diagnostic_consumer = static_cast<StoringDiagnosticConsumer *>(m_compiler_instance->getDiagnostics().getClient());
+
+ diagnostic_consumer->ClearDiagnostics();
+
+ clang::Module *top_level_module = DoGetModule(clang_path.front(), false);
+
+ if (!top_level_module)
+ {
+ diagnostic_consumer->DumpDiagnostics(error_stream);
+ error_stream.Printf("error: Couldn't load top-level module %s\n", path[0].str().c_str());
+ return false;
+ }
+
+ clang::Module *submodule = top_level_module;
+
+ for (size_t ci = 1; ci < path.size(); ++ci)
+ {
+ llvm::StringRef &component = path[ci];
+ submodule = submodule->findSubmodule(component.str());
+ if (!submodule)
+ {
+ diagnostic_consumer->DumpDiagnostics(error_stream);
+ error_stream.Printf("error: Couldn't load submodule %s\n", component.str().c_str());
+ return false;
+ }
+ }
+
+ clang::Module *requested_module = DoGetModule(clang_path, true);
+
+ return (requested_module != nullptr);
+}
+
+// ClangImporter::lookupValue
+
+uint32_t
+ClangModulesDeclVendorImpl::FindDecls (const ConstString &name,
+ bool append,
+ uint32_t max_matches,
+ std::vector <clang::NamedDecl*> &decls)
+{
+ if (!append)
+ decls.clear();
+
+ clang::IdentifierInfo &ident = m_compiler_instance->getASTContext().Idents.get(name.GetStringRef());
+
+ clang::LookupResult lookup_result(m_compiler_instance->getSema(),
+ clang::DeclarationName(&ident),
+ clang::SourceLocation(),
+ clang::Sema::LookupOrdinaryName);
+
+ m_compiler_instance->getSema().LookupName(lookup_result, m_compiler_instance->getSema().getScopeForContext(m_compiler_instance->getASTContext().getTranslationUnitDecl()));
+
+ uint32_t num_matches = 0;
+
+ for (clang::NamedDecl *named_decl : lookup_result)
+ {
+ if (num_matches >= max_matches)
+ return num_matches;
+
+ decls.push_back(named_decl);
+ ++num_matches;
+ }
+
+ return num_matches;
+}
+
+ClangModulesDeclVendorImpl::~ClangModulesDeclVendorImpl()
+{
+}
+
+clang::ModuleLoadResult
+ClangModulesDeclVendorImpl::DoGetModule(clang::ModuleIdPath path,
+ bool make_visible)
+{
+ clang::Module::NameVisibilityKind visibility = make_visible ? clang::Module::AllVisible : clang::Module::Hidden;
+
+ const bool is_inclusion_directive = false;
+
+ return m_compiler_instance->loadModule(path.front().second, path, visibility, is_inclusion_directive);
+}
+
+static const char *ModuleImportBufferName = "LLDBModulesMemoryBuffer";
+
+lldb_private::ClangModulesDeclVendor *
+ClangModulesDeclVendor::Create(Target &target)
+{
+ // FIXME we should insure programmatically that the expression parser's compiler and the modules runtime's
+ // compiler are both initialized in the same way â preferably by the same code.
+
+ if (!target.GetPlatform()->SupportsModules())
+ return nullptr;
+
+ const ArchSpec &arch = target.GetArchitecture();
+
+ std::vector<std::string> compiler_invocation_arguments =
+ {
+ "-fmodules",
+ "-fcxx-modules",
+ "-fsyntax-only",
+ "-femit-all-decls",
+ "-target", arch.GetTriple().str(),
+ "-fmodules-validate-system-headers",
+ "-Werror=non-modular-include-in-framework-module"
+ };
+
+ target.GetPlatform()->AddClangModuleCompilationOptions(compiler_invocation_arguments);
+
+ compiler_invocation_arguments.push_back(ModuleImportBufferName);
+
+ // Add additional search paths with { "-I", path } or { "-F", path } here.
+
+ {
+ llvm::SmallString<128> DefaultModuleCache;
+ const bool erased_on_reboot = false;
+ llvm::sys::path::system_temp_directory(erased_on_reboot, DefaultModuleCache);
+ llvm::sys::path::append(DefaultModuleCache, "org.llvm.clang");
+ llvm::sys::path::append(DefaultModuleCache, "ModuleCache");
+ std::string module_cache_argument("-fmodules-cache-path=");
+ module_cache_argument.append(DefaultModuleCache.str().str());
+ compiler_invocation_arguments.push_back(module_cache_argument);
+ }
+
+ {
+ FileSpec clang_resource_dir = GetResourceDir();
+
+ if (clang_resource_dir.IsDirectory())
+ {
+ compiler_invocation_arguments.push_back("-resource-dir");
+ compiler_invocation_arguments.push_back(clang_resource_dir.GetPath());
+ }
+ }
+
+ llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine> diagnostics_engine = clang::CompilerInstance::createDiagnostics(new clang::DiagnosticOptions,
+ new StoringDiagnosticConsumer);
+
+ std::vector<const char *> compiler_invocation_argument_cstrs;
+
+ for (const std::string &arg : compiler_invocation_arguments) {
+ compiler_invocation_argument_cstrs.push_back(arg.c_str());
+ }
+
+ llvm::IntrusiveRefCntPtr<clang::CompilerInvocation> invocation(clang::createInvocationFromCommandLine(compiler_invocation_argument_cstrs, diagnostics_engine));
+
+ if (!invocation)
+ return nullptr;
+
+ std::unique_ptr<llvm::MemoryBuffer> source_buffer = llvm::MemoryBuffer::getMemBuffer("extern int __lldb __attribute__((unavailable));",
+ ModuleImportBufferName);
+
+ invocation->getPreprocessorOpts().addRemappedFile(ModuleImportBufferName, source_buffer.release());
+
+ std::unique_ptr<clang::CompilerInstance> instance(new clang::CompilerInstance);
+
+ instance->setDiagnostics(diagnostics_engine.get());
+ instance->setInvocation(invocation.get());
+
+ std::unique_ptr<clang::FrontendAction> action(new clang::SyntaxOnlyAction);
+
+ instance->setTarget(clang::TargetInfo::CreateTargetInfo(*diagnostics_engine, instance->getInvocation().TargetOpts));
+
+ if (!instance->hasTarget())
+ return nullptr;
+
+ instance->getTarget().adjust(instance->getLangOpts());
+
+ if (!action->BeginSourceFile(*instance, instance->getFrontendOpts().Inputs[0]))
+ return nullptr;
+
+ instance->getPreprocessor().enableIncrementalProcessing();
+
+ instance->createModuleManager();
+
+ instance->createSema(action->getTranslationUnitKind(), nullptr);
+
+ const bool skipFunctionBodies = false;
+ std::unique_ptr<clang::Parser> parser(new clang::Parser(instance->getPreprocessor(), instance->getSema(), skipFunctionBodies));
+
+ instance->getPreprocessor().EnterMainSourceFile();
+ parser->Initialize();
+
+ clang::Parser::DeclGroupPtrTy parsed;
+
+ while (!parser->ParseTopLevelDecl(parsed));
+
+ return new ClangModulesDeclVendorImpl (diagnostics_engine, invocation, std::move(instance), std::move(parser));
+}
Copied: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp (from r223076, lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp?p2=lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp&p1=lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp&r1=223076&r2=223433&rev=223433&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp Thu Dec 4 19:21:59 2014
@@ -1,4 +1,4 @@
-//===-- AppleObjCSymbolVendor.cpp -------------------------------*- C++ -*-===//
+//===-- AppleObjCDeclVendor.cpp ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "AppleObjCTypeVendor.h"
+#include "AppleObjCDeclVendor.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
@@ -25,8 +25,8 @@ using namespace lldb_private;
class lldb_private::AppleObjCExternalASTSource : public ClangExternalASTSourceCommon
{
public:
- AppleObjCExternalASTSource (AppleObjCTypeVendor &type_vendor) :
- m_type_vendor(type_vendor)
+ AppleObjCExternalASTSource (AppleObjCDeclVendor &decl_vendor) :
+ m_decl_vendor(decl_vendor)
{
}
@@ -57,7 +57,7 @@ public:
clang::ObjCInterfaceDecl *non_const_interface_decl = const_cast<clang::ObjCInterfaceDecl*>(interface_decl);
- if (!m_type_vendor.FinishDecl(non_const_interface_decl))
+ if (!m_decl_vendor.FinishDecl(non_const_interface_decl))
break;
clang::DeclContext::lookup_const_result result = non_const_interface_decl->lookup(name);
@@ -129,7 +129,7 @@ public:
dumper.ToLog(log, " [CT] ");
}
- m_type_vendor.FinishDecl(interface_decl);
+ m_decl_vendor.FinishDecl(interface_decl);
if (log)
{
@@ -153,16 +153,16 @@ public:
void StartTranslationUnit (clang::ASTConsumer *Consumer)
{
- clang::TranslationUnitDecl *translation_unit_decl = m_type_vendor.m_ast_ctx.getASTContext()->getTranslationUnitDecl();
+ clang::TranslationUnitDecl *translation_unit_decl = m_decl_vendor.m_ast_ctx.getASTContext()->getTranslationUnitDecl();
translation_unit_decl->setHasExternalVisibleStorage();
translation_unit_decl->setHasExternalLexicalStorage();
}
private:
- AppleObjCTypeVendor &m_type_vendor;
+ AppleObjCDeclVendor &m_decl_vendor;
};
-AppleObjCTypeVendor::AppleObjCTypeVendor(ObjCLanguageRuntime &runtime) :
- TypeVendor(),
+AppleObjCDeclVendor::AppleObjCDeclVendor(ObjCLanguageRuntime &runtime) :
+ DeclVendor(),
m_runtime(runtime),
m_ast_ctx(runtime.GetProcess()->GetTarget().GetArchitecture().GetTriple().getTriple().c_str()),
m_type_realizer_sp(m_runtime.GetEncodingToType())
@@ -173,7 +173,7 @@ AppleObjCTypeVendor::AppleObjCTypeVendor
}
clang::ObjCInterfaceDecl*
-AppleObjCTypeVendor::GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa)
+AppleObjCDeclVendor::GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa)
{
ISAToInterfaceMap::const_iterator iter = m_isa_to_interface.find(isa);
@@ -421,7 +421,7 @@ private:
};
bool
-AppleObjCTypeVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl)
+AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl)
{
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
@@ -534,7 +534,7 @@ AppleObjCTypeVendor::FinishDecl(clang::O
{
ASTDumper method_dumper ((clang::Decl*)interface_decl);
- log->Printf("[AppleObjCTypeVendor::FinishDecl] Finishing Objective-C interface for %s", descriptor->GetClassName().AsCString());
+ log->Printf("[AppleObjCDeclVendor::FinishDecl] Finishing Objective-C interface for %s", descriptor->GetClassName().AsCString());
}
@@ -548,7 +548,7 @@ AppleObjCTypeVendor::FinishDecl(clang::O
{
ASTDumper method_dumper ((clang::Decl*)interface_decl);
- log->Printf("[AppleObjCTypeVendor::FinishDecl] Finished Objective-C interface");
+ log->Printf("[AppleObjCDeclVendor::FinishDecl] Finished Objective-C interface");
method_dumper.ToLog(log, " [AOTV::FD] ");
}
@@ -557,10 +557,10 @@ AppleObjCTypeVendor::FinishDecl(clang::O
}
uint32_t
-AppleObjCTypeVendor::FindTypes (const ConstString &name,
+AppleObjCDeclVendor::FindDecls (const ConstString &name,
bool append,
uint32_t max_matches,
- std::vector <ClangASTType> &types)
+ std::vector <clang::NamedDecl *> &decls)
{
static unsigned int invocation_id = 0;
unsigned int current_id = invocation_id++;
@@ -568,14 +568,14 @@ AppleObjCTypeVendor::FindTypes (const Co
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
if (log)
- log->Printf("AppleObjCTypeVendor::FindTypes [%u] ('%s', %s, %u, )",
+ log->Printf("AppleObjCDeclVendor::FindTypes [%u] ('%s', %s, %u, )",
current_id,
(const char*)name.AsCString(),
append ? "true" : "false",
max_matches);
if (!append)
- types.clear();
+ decls.clear();
uint32_t ret = 0;
@@ -592,12 +592,11 @@ AppleObjCTypeVendor::FindTypes (const Co
if (!lookup_result.empty())
{
- if (const clang::ObjCInterfaceDecl *result_iface_decl = llvm::dyn_cast<clang::ObjCInterfaceDecl>(lookup_result[0]))
+ if (clang::ObjCInterfaceDecl *result_iface_decl = llvm::dyn_cast<clang::ObjCInterfaceDecl>(lookup_result[0]))
{
- clang::QualType result_iface_type = ast_ctx->getObjCInterfaceType(result_iface_decl);
-
if (log)
{
+ clang::QualType result_iface_type = ast_ctx->getObjCInterfaceType(result_iface_decl);
ASTDumper dumper(result_iface_type);
uint64_t isa_value = LLDB_INVALID_ADDRESS;
@@ -611,7 +610,7 @@ AppleObjCTypeVendor::FindTypes (const Co
isa_value);
}
- types.push_back(ClangASTType(ast_ctx, result_iface_type.getAsOpaquePtr()));
+ decls.push_back(result_iface_decl);
ret++;
break;
}
@@ -655,10 +654,9 @@ AppleObjCTypeVendor::FindTypes (const Co
break;
}
- clang::QualType new_iface_type = ast_ctx->getObjCInterfaceType(iface_decl);
-
if (log)
{
+ clang::QualType new_iface_type = ast_ctx->getObjCInterfaceType(iface_decl);
ASTDumper dumper(new_iface_type);
log->Printf("AOCTV::FT [%u] Created %s (isa 0x%" PRIx64 ")",
current_id,
@@ -666,7 +664,7 @@ AppleObjCTypeVendor::FindTypes (const Co
(uint64_t)isa);
}
- types.push_back(ClangASTType(ast_ctx, new_iface_type.getAsOpaquePtr()));
+ decls.push_back(iface_decl);
ret++;
break;
} while (0);
Copied: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h (from r223076, lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h?p2=lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h&p1=lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h&r1=223076&r2=223433&rev=223433&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h Thu Dec 4 19:21:59 2014
@@ -1,4 +1,4 @@
-//===-- AppleObjCSymbolVendor.h ---------------------------------*- C++ -*-===//
+//===-- AppleObjCDeclVendor.h -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_AppleObjCSymbolVendor_h_
-#define liblldb_AppleObjCSymbolVendor_h_
+#ifndef liblldb_AppleObjCDeclVendor_h_
+#define liblldb_AppleObjCDeclVendor_h_
// C Includes
// C++ Includes
@@ -20,30 +20,24 @@
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/TypeVendor.h"
+#include "lldb/Symbol/DeclVendor.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
namespace lldb_private {
class AppleObjCExternalASTSource;
-class AppleObjCTypeVendor : public TypeVendor
+class AppleObjCDeclVendor : public DeclVendor
{
public:
- AppleObjCTypeVendor(ObjCLanguageRuntime &runtime);
+ AppleObjCDeclVendor(ObjCLanguageRuntime &runtime);
virtual uint32_t
- FindTypes (const ConstString &name,
+ FindDecls (const ConstString &name,
bool append,
uint32_t max_matches,
- std::vector <ClangASTType> &types);
-
- virtual clang::ASTContext *
- GetClangASTContext ()
- {
- return m_ast_ctx.getASTContext();
- }
-
+ std::vector <clang::NamedDecl *> &decls);
+
friend class AppleObjCExternalASTSource;
private:
clang::ObjCInterfaceDecl *GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa);
@@ -61,4 +55,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_AppleObjCSymbolVendor_h_
+#endif // liblldb_AppleObjCDeclVendor_h_
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp?rev=223433&r1=223432&r2=223433&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Thu Dec 4 19:21:59 2014
@@ -9,7 +9,7 @@
#include "AppleObjCRuntimeV1.h"
#include "AppleObjCTrampolineHandler.h"
-#include "AppleObjCTypeVendor.h"
+#include "AppleObjCDeclVendor.h"
#include "clang/AST/Type.h"
@@ -445,11 +445,11 @@ AppleObjCRuntimeV1::UpdateISAToDescripto
}
}
-TypeVendor *
-AppleObjCRuntimeV1::GetTypeVendor()
+DeclVendor *
+AppleObjCRuntimeV1::GetDeclVendor()
{
- if (!m_type_vendor_ap.get())
- m_type_vendor_ap.reset(new AppleObjCTypeVendor(*this));
+ if (!m_decl_vendor_ap.get())
+ m_decl_vendor_ap.reset(new AppleObjCDeclVendor(*this));
- return m_type_vendor_ap.get();
+ return m_decl_vendor_ap.get();
}
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h?rev=223433&r1=223432&r2=223433&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h Thu Dec 4 19:21:59 2014
@@ -138,8 +138,8 @@ public:
virtual void
UpdateISAToDescriptorMapIfNeeded();
- virtual TypeVendor *
- GetTypeVendor();
+ virtual DeclVendor *
+ GetDeclVendor();
protected:
virtual lldb::BreakpointResolverSP
@@ -188,7 +188,7 @@ protected:
HashTableSignature m_hash_signature;
lldb::addr_t m_isa_hash_table_ptr;
- std::unique_ptr<TypeVendor> m_type_vendor_ap;
+ std::unique_ptr<DeclVendor> m_decl_vendor_ap;
private:
AppleObjCRuntimeV1(Process *process);
};
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=223433&r1=223432&r2=223433&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Thu Dec 4 19:21:59 2014
@@ -44,10 +44,11 @@
#include "AppleObjCRuntimeV2.h"
#include "AppleObjCClassDescriptorV2.h"
#include "AppleObjCTypeEncodingParser.h"
-#include "AppleObjCTypeVendor.h"
+#include "AppleObjCDeclVendor.h"
#include "AppleObjCTrampolineHandler.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclObjC.h"
#include <vector>
@@ -346,7 +347,7 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2 (
m_get_shared_cache_class_info_code(),
m_get_shared_cache_class_info_args (LLDB_INVALID_ADDRESS),
m_get_shared_cache_class_info_args_mutex (Mutex::eMutexTypeNormal),
- m_type_vendor_ap (),
+ m_decl_vendor_ap (),
m_isa_hash_table_ptr (LLDB_INVALID_ADDRESS),
m_hash_signature (),
m_has_object_getClass (false),
@@ -401,12 +402,12 @@ AppleObjCRuntimeV2::GetDynamicTypeAndAdd
else
{
// try to go for a ClangASTType at least
- TypeVendor* vendor = GetTypeVendor();
+ DeclVendor* vendor = GetDeclVendor();
if (vendor)
{
- std::vector<ClangASTType> types;
- if (vendor->FindTypes(class_name, false, 1, types) && types.size() && types.at(0).IsValid())
- class_type_or_name.SetClangASTType(types.at(0));
+ std::vector<clang::NamedDecl*> decls;
+ if (vendor->FindDecls(class_name, false, 1, decls) && decls.size())
+ class_type_or_name.SetClangASTType(ClangASTContext::GetTypeForDecl(decls[0]));
}
}
}
@@ -1576,13 +1577,13 @@ AppleObjCRuntimeV2::GetActualTypeName(Ob
return ObjCLanguageRuntime::GetActualTypeName(isa);
}
-TypeVendor *
-AppleObjCRuntimeV2::GetTypeVendor()
+DeclVendor *
+AppleObjCRuntimeV2::GetDeclVendor()
{
- if (!m_type_vendor_ap.get())
- m_type_vendor_ap.reset(new AppleObjCTypeVendor(*this));
+ if (!m_decl_vendor_ap.get())
+ m_decl_vendor_ap.reset(new AppleObjCDeclVendor(*this));
- return m_type_vendor_ap.get();
+ return m_decl_vendor_ap.get();
}
lldb::addr_t
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h?rev=223433&r1=223432&r2=223433&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h Thu Dec 4 19:21:59 2014
@@ -99,8 +99,8 @@ public:
virtual ClassDescriptorSP
GetClassDescriptorFromISA (ObjCISA isa);
- virtual TypeVendor *
- GetTypeVendor();
+ virtual DeclVendor *
+ GetDeclVendor();
virtual lldb::addr_t
LookupRuntimeSymbol (const ConstString &name);
@@ -280,7 +280,7 @@ private:
lldb::addr_t m_get_shared_cache_class_info_args;
Mutex m_get_shared_cache_class_info_args_mutex;
- std::unique_ptr<TypeVendor> m_type_vendor_ap;
+ std::unique_ptr<DeclVendor> m_decl_vendor_ap;
lldb::addr_t m_isa_hash_table_ptr;
HashTableSignature m_hash_signature;
bool m_has_object_getClass;
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp?rev=223433&r1=223432&r2=223433&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp Thu Dec 4 19:21:59 2014
@@ -240,23 +240,22 @@ AppleObjCTypeEncodingParser::BuildObjCOb
name.erase(less_than_pos);
}
- TypeVendor *type_vendor = m_runtime.GetTypeVendor();
+ DeclVendor *decl_vendor = m_runtime.GetDeclVendor();
- assert (type_vendor); // how are we parsing type encodings for expressions if a type vendor isn't in play?
- assert (type_vendor->GetClangASTContext() == &ast_ctx); // it doesn't make sense for us to be looking in other places
+ assert (decl_vendor); // how are we parsing type encodings for expressions if a type vendor isn't in play?
const bool append = false;
const uint32_t max_matches = 1;
- std::vector<ClangASTType> types;
+ std::vector<clang::NamedDecl *> decls;
- uint32_t num_types = type_vendor->FindTypes(ConstString(name),
+ uint32_t num_types = decl_vendor->FindDecls(ConstString(name),
append,
max_matches,
- types);
+ decls);
assert(num_types); // how can a type be mentioned in runtime type signatures and not be in the runtime?
-
- return types[0].GetPointerType().GetQualType();
+
+ return ClangASTContext::GetTypeForDecl(decls[0]).GetPointerType().GetQualType();
}
else
{
Removed: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp?rev=223432&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp (removed)
@@ -1,675 +0,0 @@
-//===-- AppleObjCSymbolVendor.cpp -------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "AppleObjCTypeVendor.h"
-
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Expression/ASTDumper.h"
-#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/Target.h"
-
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/DeclObjC.h"
-
-using namespace lldb_private;
-
-class lldb_private::AppleObjCExternalASTSource : public ClangExternalASTSourceCommon
-{
-public:
- AppleObjCExternalASTSource (AppleObjCTypeVendor &type_vendor) :
- m_type_vendor(type_vendor)
- {
- }
-
- bool
- FindExternalVisibleDeclsByName (const clang::DeclContext *decl_ctx,
- clang::DeclarationName name)
- {
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
-
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
-
- if (log)
- {
- log->Printf("AppleObjCExternalASTSource::FindExternalVisibleDeclsByName[%u] on (ASTContext*)%p Looking for %s in (%sDecl*)%p",
- current_id,
- static_cast<void*>(&decl_ctx->getParentASTContext()),
- name.getAsString().c_str(), decl_ctx->getDeclKindName(),
- static_cast<const void*>(decl_ctx));
- }
-
- do
- {
- const clang::ObjCInterfaceDecl *interface_decl = llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
-
- if (!interface_decl)
- break;
-
- clang::ObjCInterfaceDecl *non_const_interface_decl = const_cast<clang::ObjCInterfaceDecl*>(interface_decl);
-
- if (!m_type_vendor.FinishDecl(non_const_interface_decl))
- break;
-
- clang::DeclContext::lookup_const_result result = non_const_interface_decl->lookup(name);
-
- return (result.size() != 0);
- }
- while(0);
-
- SetNoExternalVisibleDeclsForName(decl_ctx, name);
- return false;
- }
-
- clang::ExternalLoadResult
- FindExternalLexicalDecls (const clang::DeclContext *DC,
- bool (*isKindWeWant)(clang::Decl::Kind),
- llvm::SmallVectorImpl<clang::Decl*> &Decls)
- {
- return clang::ELR_Success;
- }
-
- void
- CompleteType (clang::TagDecl *tag_decl)
- {
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
-
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
-
- if (log)
- {
- log->Printf("AppleObjCExternalASTSource::CompleteType[%u] on (ASTContext*)%p Completing (TagDecl*)%p named %s",
- current_id,
- static_cast<void*>(&tag_decl->getASTContext()),
- static_cast<void*>(tag_decl),
- tag_decl->getName().str().c_str());
-
- log->Printf(" AOEAS::CT[%u] Before:", current_id);
- ASTDumper dumper((clang::Decl*)tag_decl);
- dumper.ToLog(log, " [CT] ");
- }
-
- if (log)
- {
- log->Printf(" AOEAS::CT[%u] After:", current_id);
- ASTDumper dumper((clang::Decl*)tag_decl);
- dumper.ToLog(log, " [CT] ");
- }
- return;
- }
-
- void
- CompleteType (clang::ObjCInterfaceDecl *interface_decl)
- {
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
-
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
-
- if (log)
- {
- log->Printf("AppleObjCExternalASTSource::CompleteType[%u] on (ASTContext*)%p Completing (ObjCInterfaceDecl*)%p named %s",
- current_id,
- static_cast<void*>(&interface_decl->getASTContext()),
- static_cast<void*>(interface_decl),
- interface_decl->getName().str().c_str());
-
- log->Printf(" AOEAS::CT[%u] Before:", current_id);
- ASTDumper dumper((clang::Decl*)interface_decl);
- dumper.ToLog(log, " [CT] ");
- }
-
- m_type_vendor.FinishDecl(interface_decl);
-
- if (log)
- {
- log->Printf(" [CT] After:");
- ASTDumper dumper((clang::Decl*)interface_decl);
- dumper.ToLog(log, " [CT] ");
- }
- return;
- }
-
- bool
- layoutRecordType(const clang::RecordDecl *Record,
- uint64_t &Size,
- uint64_t &Alignment,
- llvm::DenseMap <const clang::FieldDecl *, uint64_t> &FieldOffsets,
- llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets,
- llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &VirtualBaseOffsets)
- {
- return false;
- }
-
- void StartTranslationUnit (clang::ASTConsumer *Consumer)
- {
- clang::TranslationUnitDecl *translation_unit_decl = m_type_vendor.m_ast_ctx.getASTContext()->getTranslationUnitDecl();
- translation_unit_decl->setHasExternalVisibleStorage();
- translation_unit_decl->setHasExternalLexicalStorage();
- }
-private:
- AppleObjCTypeVendor &m_type_vendor;
-};
-
-AppleObjCTypeVendor::AppleObjCTypeVendor(ObjCLanguageRuntime &runtime) :
- TypeVendor(),
- m_runtime(runtime),
- m_ast_ctx(runtime.GetProcess()->GetTarget().GetArchitecture().GetTriple().getTriple().c_str()),
- m_type_realizer_sp(m_runtime.GetEncodingToType())
-{
- m_external_source = new AppleObjCExternalASTSource (*this);
- llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> external_source_owning_ptr (m_external_source);
- m_ast_ctx.getASTContext()->setExternalSource(external_source_owning_ptr);
-}
-
-clang::ObjCInterfaceDecl*
-AppleObjCTypeVendor::GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa)
-{
- ISAToInterfaceMap::const_iterator iter = m_isa_to_interface.find(isa);
-
- if (iter != m_isa_to_interface.end())
- return iter->second;
-
- clang::ASTContext *ast_ctx = m_ast_ctx.getASTContext();
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor = m_runtime.GetClassDescriptorFromISA(isa);
-
- if (!descriptor)
- return NULL;
-
- const ConstString &name(descriptor->GetClassName());
-
- clang::IdentifierInfo &identifier_info = ast_ctx->Idents.get(name.GetStringRef());
-
- clang::ObjCInterfaceDecl *new_iface_decl = clang::ObjCInterfaceDecl::Create(*ast_ctx,
- ast_ctx->getTranslationUnitDecl(),
- clang::SourceLocation(),
- &identifier_info,
- NULL);
-
- ClangASTMetadata meta_data;
- meta_data.SetISAPtr(isa);
- m_external_source->SetMetadata(new_iface_decl, meta_data);
-
- new_iface_decl->setHasExternalVisibleStorage();
- new_iface_decl->setHasExternalLexicalStorage();
-
- ast_ctx->getTranslationUnitDecl()->addDecl(new_iface_decl);
-
- m_isa_to_interface[isa] = new_iface_decl;
-
- return new_iface_decl;
-}
-
-class ObjCRuntimeMethodType
-{
-public:
- ObjCRuntimeMethodType (const char *types) : m_is_valid(false)
- {
- const char *cursor = types;
- enum ParserState {
- Start = 0,
- InType,
- InPos
- } state = Start;
- const char *type = NULL;
- int brace_depth = 0;
-
- uint32_t stepsLeft = 256;
-
- while (1)
- {
- if (--stepsLeft == 0)
- {
- m_is_valid = false;
- return;
- }
-
- switch (state)
- {
- case Start:
- {
- switch (*cursor)
- {
- default:
- state = InType;
- type = cursor;
- break;
- case '\0':
- m_is_valid = true;
- return;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- m_is_valid = false;
- return;
- }
- }
- break;
- case InType:
- {
- switch (*cursor)
- {
- default:
- ++cursor;
- break;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- if (!brace_depth)
- {
- state = InPos;
- if (type)
- {
- m_type_vector.push_back(std::string(type, (cursor - type)));
- }
- else
- {
- m_is_valid = false;
- return;
- }
- type = NULL;
- }
- else
- {
- ++cursor;
- }
- break;
- case '[': case '{': case '(':
- ++brace_depth;
- ++cursor;
- break;
- case ']': case '}': case ')':
- if (!brace_depth)
- {
- m_is_valid = false;
- return;
- }
- --brace_depth;
- ++cursor;
- break;
- case '\0':
- m_is_valid = false;
- return;
- }
- }
- break;
- case InPos:
- {
- switch (*cursor)
- {
- default:
- state = InType;
- type = cursor;
- break;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- ++cursor;
- break;
- case '\0':
- m_is_valid = true;
- return;
- }
- }
- break;
- }
- }
- }
-
- clang::ObjCMethodDecl *BuildMethod (clang::ObjCInterfaceDecl *interface_decl, const char *name, bool instance, ObjCLanguageRuntime::EncodingToTypeSP type_realizer_sp)
- {
- if (!m_is_valid || m_type_vector.size() < 3)
- return NULL;
-
- clang::ASTContext &ast_ctx(interface_decl->getASTContext());
-
- clang::QualType return_qual_type;
-
- const bool isInstance = instance;
- const bool isVariadic = false;
- const bool isSynthesized = false;
- const bool isImplicitlyDeclared = true;
- const bool isDefined = false;
- const clang::ObjCMethodDecl::ImplementationControl impControl = clang::ObjCMethodDecl::None;
- const bool HasRelatedResultType = false;
- const bool for_expression = true;
-
- std::vector <clang::IdentifierInfo *> selector_components;
-
- const char *name_cursor = name;
- bool is_zero_argument = true;
-
-
- while (*name_cursor != '\0')
- {
- const char *colon_loc = strchr(name_cursor, ':');
- if (!colon_loc)
- {
- selector_components.push_back(&ast_ctx.Idents.get(llvm::StringRef(name_cursor)));
- break;
- }
- else
- {
- is_zero_argument = false;
- selector_components.push_back(&ast_ctx.Idents.get(llvm::StringRef(name_cursor, colon_loc - name_cursor)));
- name_cursor = colon_loc + 1;
- }
- }
-
- clang::Selector sel = ast_ctx.Selectors.getSelector(is_zero_argument ? 0 : selector_components.size(), selector_components.data());
-
- clang::QualType ret_type = type_realizer_sp->RealizeType(interface_decl->getASTContext(), m_type_vector[0].c_str(), for_expression).GetQualType();
-
- if (ret_type.isNull())
- return NULL;
-
- clang::ObjCMethodDecl *ret = clang::ObjCMethodDecl::Create(ast_ctx,
- clang::SourceLocation(),
- clang::SourceLocation(),
- sel,
- ret_type,
- NULL,
- interface_decl,
- isInstance,
- isVariadic,
- isSynthesized,
- isImplicitlyDeclared,
- isDefined,
- impControl,
- HasRelatedResultType);
-
- std::vector <clang::ParmVarDecl*> parm_vars;
-
- for (size_t ai = 3, ae = m_type_vector.size();
- ai != ae;
- ++ai)
- {
- const bool for_expression = true;
- clang::QualType arg_type = type_realizer_sp->RealizeType(ast_ctx, m_type_vector[ai].c_str(), for_expression).GetQualType();
-
- if (arg_type.isNull())
- return NULL; // well, we just wasted a bunch of time. Wish we could delete the stuff we'd just made!
-
- parm_vars.push_back(clang::ParmVarDecl::Create(ast_ctx,
- ret,
- clang::SourceLocation(),
- clang::SourceLocation(),
- NULL,
- arg_type,
- NULL,
- clang::SC_None,
- NULL));
- }
-
- ret->setMethodParams(ast_ctx, llvm::ArrayRef<clang::ParmVarDecl*>(parm_vars), llvm::ArrayRef<clang::SourceLocation>());
-
- return ret;
- }
-private:
- typedef std::vector <std::string> TypeVector;
-
- TypeVector m_type_vector;
- bool m_is_valid;
-};
-
-bool
-AppleObjCTypeVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl)
-{
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
-
- ClangASTMetadata *metadata = m_external_source->GetMetadata(interface_decl);
- ObjCLanguageRuntime::ObjCISA objc_isa = 0;
- if (metadata)
- objc_isa = metadata->GetISAPtr();
-
- if (!objc_isa)
- return false;
-
- if (!interface_decl->hasExternalVisibleStorage())
- return true;
-
- interface_decl->startDefinition();
-
- interface_decl->setHasExternalVisibleStorage(false);
- interface_decl->setHasExternalLexicalStorage(false);
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor = m_runtime.GetClassDescriptorFromISA(objc_isa);
-
- if (!descriptor)
- return false;
-
- auto superclass_func = [interface_decl, this](ObjCLanguageRuntime::ObjCISA isa)
- {
- clang::ObjCInterfaceDecl *superclass_decl = GetDeclForISA(isa);
-
- if (!superclass_decl)
- return;
-
- FinishDecl(superclass_decl);
-
- interface_decl->setSuperClass(superclass_decl);
- };
-
- auto instance_method_func = [log, interface_decl, this](const char *name, const char *types) -> bool
- {
- if (!name || !types)
- return false; // skip this one
-
- ObjCRuntimeMethodType method_type(types);
-
- clang::ObjCMethodDecl *method_decl = method_type.BuildMethod (interface_decl, name, true, m_type_realizer_sp);
-
- if (log)
- log->Printf("[ AOTV::FD] Instance method [%s] [%s]", name, types);
-
- if (method_decl)
- interface_decl->addDecl(method_decl);
-
- return false;
- };
-
- auto class_method_func = [log, interface_decl, this](const char *name, const char *types) -> bool
- {
- if (!name || !types)
- return false; // skip this one
-
- ObjCRuntimeMethodType method_type(types);
-
- clang::ObjCMethodDecl *method_decl = method_type.BuildMethod (interface_decl, name, false, m_type_realizer_sp);
-
- if (log)
- log->Printf("[ AOTV::FD] Class method [%s] [%s]", name, types);
-
- if (method_decl)
- interface_decl->addDecl(method_decl);
-
- return false;
- };
-
- auto ivar_func = [log, interface_decl, this](const char *name, const char *type, lldb::addr_t offset_ptr, uint64_t size) -> bool
- {
- if (!name || !type)
- return false;
-
- const bool for_expression = true;
-
- if (log)
- log->Printf("[ AOTV::FD] Instance variable [%s] [%s], offset at %" PRIx64, name, type, offset_ptr);
-
- ClangASTType ivar_type = m_runtime.GetEncodingToType()->RealizeType(m_ast_ctx, type, for_expression);
-
- if (ivar_type.IsValid())
- {
- clang::TypeSourceInfo * const type_source_info = nullptr;
- const bool is_synthesized = false;
- clang::ObjCIvarDecl *ivar_decl = clang::ObjCIvarDecl::Create (*m_ast_ctx.getASTContext(),
- interface_decl,
- clang::SourceLocation(),
- clang::SourceLocation(),
- &m_ast_ctx.getASTContext()->Idents.get(name),
- ivar_type.GetQualType(),
- type_source_info, // TypeSourceInfo *
- clang::ObjCIvarDecl::Public,
- 0,
- is_synthesized);
-
- if (ivar_decl)
- {
- interface_decl->addDecl(ivar_decl);
- }
- }
-
- return false;
- };
-
- if (log)
- {
- ASTDumper method_dumper ((clang::Decl*)interface_decl);
-
- log->Printf("[AppleObjCTypeVendor::FinishDecl] Finishing Objective-C interface for %s", descriptor->GetClassName().AsCString());
- }
-
-
- if (!descriptor->Describe(superclass_func,
- instance_method_func,
- class_method_func,
- ivar_func))
- return false;
-
- if (log)
- {
- ASTDumper method_dumper ((clang::Decl*)interface_decl);
-
- log->Printf("[AppleObjCTypeVendor::FinishDecl] Finished Objective-C interface");
-
- method_dumper.ToLog(log, " [AOTV::FD] ");
- }
-
- return true;
-}
-
-uint32_t
-AppleObjCTypeVendor::FindTypes (const ConstString &name,
- bool append,
- uint32_t max_matches,
- std::vector <ClangASTType> &types)
-{
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
-
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
-
- if (log)
- log->Printf("AppleObjCTypeVendor::FindTypes [%u] ('%s', %s, %u, )",
- current_id,
- (const char*)name.AsCString(),
- append ? "true" : "false",
- max_matches);
-
- if (!append)
- types.clear();
-
- uint32_t ret = 0;
-
- do
- {
- // See if the type is already in our ASTContext.
-
- clang::ASTContext *ast_ctx = m_ast_ctx.getASTContext();
-
- clang::IdentifierInfo &identifier_info = ast_ctx->Idents.get(name.GetStringRef());
- clang::DeclarationName decl_name = ast_ctx->DeclarationNames.getIdentifier(&identifier_info);
-
- clang::DeclContext::lookup_const_result lookup_result = ast_ctx->getTranslationUnitDecl()->lookup(decl_name);
-
- if (!lookup_result.empty())
- {
- if (const clang::ObjCInterfaceDecl *result_iface_decl = llvm::dyn_cast<clang::ObjCInterfaceDecl>(lookup_result[0]))
- {
- clang::QualType result_iface_type = ast_ctx->getObjCInterfaceType(result_iface_decl);
-
- if (log)
- {
- ASTDumper dumper(result_iface_type);
-
- uint64_t isa_value = LLDB_INVALID_ADDRESS;
- ClangASTMetadata *metadata = m_external_source->GetMetadata(result_iface_decl);
- if (metadata)
- isa_value = metadata->GetISAPtr();
-
- log->Printf("AOCTV::FT [%u] Found %s (isa 0x%" PRIx64 ") in the ASTContext",
- current_id,
- dumper.GetCString(),
- isa_value);
- }
-
- types.push_back(ClangASTType(ast_ctx, result_iface_type.getAsOpaquePtr()));
- ret++;
- break;
- }
- else
- {
- if (log)
- log->Printf("AOCTV::FT [%u] There's something in the ASTContext, but it's not something we know about",
- current_id);
- break;
- }
- }
- else if(log)
- {
- log->Printf("AOCTV::FT [%u] Couldn't find %s in the ASTContext",
- current_id,
- name.AsCString());
- }
-
- // It's not. If it exists, we have to put it into our ASTContext.
-
- ObjCLanguageRuntime::ObjCISA isa = m_runtime.GetISA(name);
-
- if (!isa)
- {
- if (log)
- log->Printf("AOCTV::FT [%u] Couldn't find the isa",
- current_id);
-
- break;
- }
-
- clang::ObjCInterfaceDecl *iface_decl = GetDeclForISA(isa);
-
- if (!iface_decl)
- {
- if (log)
- log->Printf("AOCTV::FT [%u] Couldn't get the Objective-C interface for isa 0x%" PRIx64,
- current_id,
- (uint64_t)isa);
-
- break;
- }
-
- clang::QualType new_iface_type = ast_ctx->getObjCInterfaceType(iface_decl);
-
- if (log)
- {
- ASTDumper dumper(new_iface_type);
- log->Printf("AOCTV::FT [%u] Created %s (isa 0x%" PRIx64 ")",
- current_id,
- dumper.GetCString(),
- (uint64_t)isa);
- }
-
- types.push_back(ClangASTType(ast_ctx, new_iface_type.getAsOpaquePtr()));
- ret++;
- break;
- } while (0);
-
- return ret;
-}
Removed: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h?rev=223432&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.h (removed)
@@ -1,64 +0,0 @@
-//===-- AppleObjCSymbolVendor.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_AppleObjCSymbolVendor_h_
-#define liblldb_AppleObjCSymbolVendor_h_
-
-// C Includes
-// C++ Includes
-
-#include <map>
-
-// Other libraries and framework includes
-
-// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/TypeVendor.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
-
-namespace lldb_private {
-
-class AppleObjCExternalASTSource;
-
-class AppleObjCTypeVendor : public TypeVendor
-{
-public:
- AppleObjCTypeVendor(ObjCLanguageRuntime &runtime);
-
- virtual uint32_t
- FindTypes (const ConstString &name,
- bool append,
- uint32_t max_matches,
- std::vector <ClangASTType> &types);
-
- virtual clang::ASTContext *
- GetClangASTContext ()
- {
- return m_ast_ctx.getASTContext();
- }
-
- friend class AppleObjCExternalASTSource;
-private:
- clang::ObjCInterfaceDecl *GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa);
- bool FinishDecl(clang::ObjCInterfaceDecl *decl);
-
- ObjCLanguageRuntime &m_runtime;
- ClangASTContext m_ast_ctx;
- ObjCLanguageRuntime::EncodingToTypeSP m_type_realizer_sp;
- AppleObjCExternalASTSource *m_external_source;
-
- typedef llvm::DenseMap<ObjCLanguageRuntime::ObjCISA, clang::ObjCInterfaceDecl *> ISAToInterfaceMap;
-
- ISAToInterfaceMap m_isa_to_interface;
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_AppleObjCSymbolVendor_h_
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=223433&r1=223432&r2=223433&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Dec 4 19:21:59 2014
@@ -1132,6 +1132,16 @@ ClangASTContext::AreTypesSame (ClangASTT
return ast->hasSameType (type1_qual, type2_qual);
}
+ClangASTType
+ClangASTContext::GetTypeForDecl (clang::NamedDecl *decl)
+{
+ if (clang::ObjCInterfaceDecl *interface_decl = llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
+ return GetTypeForDecl(interface_decl);
+ if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
+ return GetTypeForDecl(tag_decl);
+ return ClangASTType();
+}
+
ClangASTType
ClangASTContext::GetTypeForDecl (TagDecl *decl)
@@ -1139,7 +1149,7 @@ ClangASTContext::GetTypeForDecl (TagDecl
// No need to call the getASTContext() accessor (which can create the AST
// if it isn't created yet, because we can't have created a decl in this
// AST if our AST didn't already exist...
- ASTContext *ast = m_ast_ap.get();
+ ASTContext *ast = &decl->getASTContext();
if (ast)
return ClangASTType (ast, ast->getTagDeclType(decl).getAsOpaquePtr());
return ClangASTType();
@@ -1151,7 +1161,7 @@ ClangASTContext::GetTypeForDecl (ObjCInt
// No need to call the getASTContext() accessor (which can create the AST
// if it isn't created yet, because we can't have created a decl in this
// AST if our AST didn't already exist...
- ASTContext *ast = m_ast_ap.get();
+ ASTContext *ast = &decl->getASTContext();
if (ast)
return ClangASTType (ast, ast->getObjCInterfaceType(decl).getAsOpaquePtr());
return ClangASTType();
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=223433&r1=223432&r2=223433&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Dec 4 19:21:59 2014
@@ -2028,6 +2028,22 @@ Target::GetSourceManager ()
return *m_source_manager_ap;
}
+ClangModulesDeclVendor *
+Target::GetClangModulesDeclVendor ()
+{
+ static Mutex s_clang_modules_decl_vendor_mutex; // If this is contended we can make it per-target
+
+ {
+ Mutex::Locker clang_modules_decl_vendor_locker(s_clang_modules_decl_vendor_mutex);
+
+ if (!m_clang_modules_decl_vendor_ap)
+ {
+ m_clang_modules_decl_vendor_ap.reset(ClangModulesDeclVendor::Create(*this));
+ }
+ }
+
+ return m_clang_modules_decl_vendor_ap.get();
+}
Target::StopHookSP
Target::CreateStopHook ()
More information about the lldb-commits
mailing list