diff options
| author | Raphael Isemann <teemperor@gmail.com> | 2019-12-23 20:42:25 +0100 |
|---|---|---|
| committer | Raphael Isemann <teemperor@gmail.com> | 2019-12-24 13:17:27 +0100 |
| commit | 4657a397c22a27775823b8f731abdc6477badfea (patch) | |
| tree | 824de1197bc46ce022a3edd850654f8d7a93fbaf /lldb/include | |
| parent | 8131c04836829e7f37f2feaa1d85b4ef62ad092f (diff) | |
| download | bcm5719-llvm-4657a397c22a27775823b8f731abdc6477badfea.tar.gz bcm5719-llvm-4657a397c22a27775823b8f731abdc6477badfea.zip | |
[lldb][NFC] Remove ClangExternalASTSourceCommon
ClangExternalASTSourceCommon's purpose is to store a map from
Decl*/Type* to ClangASTMetadata. Usually this data is accessed
via the ClangASTContext interface which then grabs the
current ExternalASTSource of its ASTContext, tries to cast it
to ClangExternalASTSourceCommon and then accesses the metadata
map. If the casting fails the setter does nothing and the getter
returns a nullptr as if there was no known metadata for a type/decl.
This system breaks as soon as any non-LLDB ExternalASTSource is added via
a multiplexer to our existing ExternalASTSource (in which case we suddenly
loose all out metadata as the casting always fails with an ExternalASTSource
that is not inheriting from ClangExternalASTSourceCommon).
This patch moves the metadata map to the ClangASTContext. This gets
rid of all the fragile casting, the requirement that every ExternalASTSource in
LLDB has to inherit from ClangExternalASTSourceCommon and simplifies
the metadata implementation to a simple map lookup. As ClangExternalASTSourceCommon
had no other purpose than storing metadata, this patch deletes this class
and replaces all uses with clang::ExternalASTSource.
No other code changes in this commit beside the AppleObjCDeclVendor which
was the only code that did not use the ClangASTContext interface but directly
accessed the ClangExternalASTSourceCommon.
Diffstat (limited to 'lldb/include')
| -rw-r--r-- | lldb/include/lldb/Symbol/ClangASTContext.h | 9 | ||||
| -rw-r--r-- | lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h | 5 | ||||
| -rw-r--r-- | lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h | 82 |
3 files changed, 12 insertions, 84 deletions
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index cc8be845157..59abe19eba1 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -966,6 +966,15 @@ protected: std::unique_ptr<clang::MangleContext> m_mangle_ctx_up; uint32_t m_pointer_byte_size = 0; bool m_ast_owned = false; + + typedef llvm::DenseMap<const clang::Decl *, ClangASTMetadata> DeclMetadataMap; + /// Maps Decls to their associated ClangASTMetadata. + DeclMetadataMap m_decl_metadata; + + typedef llvm::DenseMap<const clang::Type *, ClangASTMetadata> TypeMetadataMap; + /// Maps Types to their associated ClangASTMetadata. + TypeMetadataMap m_type_metadata; + /// The sema associated that is currently used to build this ASTContext. /// May be null if we are already done parsing this ASTContext or the /// ASTContext wasn't created by parsing source code. diff --git a/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h b/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h index ed7e3b8ece7..290ecc9b901 100644 --- a/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h +++ b/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h @@ -9,13 +9,14 @@ #ifndef liblldb_ClangExternalASTSourceCallbacks_h_ #define liblldb_ClangExternalASTSourceCallbacks_h_ -#include "lldb/Symbol/ClangExternalASTSourceCommon.h" +#include "lldb/Symbol/ClangASTContext.h" +#include "clang/AST/ExternalASTSource.h" namespace lldb_private { class ClangASTContext; -class ClangExternalASTSourceCallbacks : public ClangExternalASTSourceCommon { +class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource { public: ClangExternalASTSourceCallbacks(ClangASTContext &ast) : m_ast(ast) {} diff --git a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h b/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h deleted file mode 100644 index dada61d7d02..00000000000 --- a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h +++ /dev/null @@ -1,82 +0,0 @@ -//===-- ClangExternalASTSourceCommon.h --------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_ClangExternalASTSourceCommon_h -#define liblldb_ClangExternalASTSourceCommon_h - -// Clang headers like to use NDEBUG inside of them to enable/disable debug -// related 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 - -#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 - -#include "clang/AST/ExternalASTSource.h" - -#include "lldb/Core/dwarf.h" -#include "lldb/Symbol/ClangASTMetadata.h" -#include "lldb/lldb-defines.h" -#include "lldb/lldb-enumerations.h" - -namespace lldb_private { - -class ClangExternalASTSourceCommon : public clang::ExternalASTSource { - - /// LLVM-style RTTI. - static char ID; - -public: - ~ClangExternalASTSourceCommon() override; - - ClangASTMetadata *GetMetadata(const clang::Decl *object); - void SetMetadata(const clang::Decl *object, - const ClangASTMetadata &metadata) { - m_decl_metadata[object] = metadata; - } - - ClangASTMetadata *GetMetadata(const clang::Type *object); - void SetMetadata(const clang::Type *object, - const ClangASTMetadata &metadata) { - m_type_metadata[object] = metadata; - } - - /// LLVM-style RTTI. - /// \{ - bool isA(const void *ClassID) const override { - return ClassID == &ID || ExternalASTSource::isA(ClassID); - } - static bool classof(const ExternalASTSource *S) { return S->isA(&ID); } - /// \} -private: - typedef llvm::DenseMap<const clang::Decl *, ClangASTMetadata> DeclMetadataMap; - typedef llvm::DenseMap<const clang::Type *, ClangASTMetadata> TypeMetadataMap; - - DeclMetadataMap m_decl_metadata; - TypeMetadataMap m_type_metadata; -}; - -} // namespace lldb_private - -#endif // liblldb_ClangExternalASTSourceCommon_h |

