ClangExternalASTSourceCommon.h revision e628a9f23e6ed8883e1a4ba9a2a563ccbcf2f93e
1//===-- ClangExternalASTSourceCommon.h --------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef liblldb_ClangExternalASTSourceCommon_h
11#define liblldb_ClangExternalASTSourceCommon_h
12
13// Clang headers like to use NDEBUG inside of them to enable/disable debug
14// releated features using "#ifndef NDEBUG" preprocessor blocks to do one thing
15// or another. This is bad because it means that if clang was built in release
16// mode, it assumes that you are building in release mode which is not always
17// the case. You can end up with functions that are defined as empty in header
18// files when NDEBUG is not defined, and this can cause link errors with the
19// clang .a files that you have since you might be missing functions in the .a
20// file. So we have to define NDEBUG when including clang headers to avoid any
21// mismatches. This is covered by rdar://problem/8691220
22
23#if !defined(NDEBUG) && !defined(LLVM_NDEBUG_OFF)
24#define LLDB_DEFINED_NDEBUG_FOR_CLANG
25#define NDEBUG
26// Need to include assert.h so it is as clang would expect it to be (disabled)
27#include <assert.h>
28#endif
29
30#include "clang/AST/ExternalASTSource.h"
31
32#ifdef LLDB_DEFINED_NDEBUG_FOR_CLANG
33#undef NDEBUG
34#undef LLDB_DEFINED_NDEBUG_FOR_CLANG
35// Need to re-include assert.h so it is as _we_ would expect it to be (enabled)
36#include <assert.h>
37#endif
38
39namespace lldb_private {
40
41class ClangExternalASTSourceCommon : public clang::ExternalASTSource
42{
43public:
44    ClangExternalASTSourceCommon();
45
46    virtual uint64_t GetMetadata(uintptr_t object);
47    virtual void SetMetadata(uintptr_t object, uint64_t metadata);
48    virtual bool HasMetadata(uintptr_t object);
49private:
50    typedef llvm::DenseMap<uintptr_t, uint64_t> MetadataMap;
51
52    MetadataMap m_metadata;
53    uint64_t    m_magic;        ///< Because we don't have RTTI, we must take it
54                                ///< on faith that any valid ExternalASTSource that
55                                ///< we try to use the *Metadata APIs on inherits
56                                ///< from ClangExternalASTSourceCommon.  This magic
57                                ///< number exists to enforce that.
58};
59
60}
61
62#endif
63