DebugInfo: Gut DIType and subclasses
[oota-llvm.git] / include / llvm / IR / DebugInfo.h
1 //===- DebugInfo.h - Debug Information Helpers ------------------*- 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 // This file defines a bunch of datatypes that are useful for creating and
11 // walking debug info in LLVM IR form. They essentially provide wrappers around
12 // the information in the global variables that's needed when constructing the
13 // DWARF information.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_IR_DEBUGINFO_H
18 #define LLVM_IR_DEBUGINFO_H
19
20 #include "llvm/ADT/DenseMap.h"
21 #include "llvm/ADT/SmallPtrSet.h"
22 #include "llvm/ADT/SmallVector.h"
23 #include "llvm/ADT/StringRef.h"
24 #include "llvm/ADT/iterator_range.h"
25 #include "llvm/IR/DebugInfoMetadata.h"
26 #include "llvm/Support/Casting.h"
27 #include "llvm/Support/Dwarf.h"
28 #include "llvm/Support/ErrorHandling.h"
29 #include <iterator>
30
31 namespace llvm {
32 class BasicBlock;
33 class Constant;
34 class Function;
35 class GlobalVariable;
36 class Module;
37 class Type;
38 class Value;
39 class DbgDeclareInst;
40 class DbgValueInst;
41 class Instruction;
42 class Metadata;
43 class MDNode;
44 class MDString;
45 class NamedMDNode;
46 class LLVMContext;
47 class raw_ostream;
48
49 class DIFile;
50 class DISubprogram;
51 class DILexicalBlock;
52 class DILexicalBlockFile;
53 class DIVariable;
54 class DIType;
55 class DIScope;
56 class DIObjCProperty;
57
58 /// \brief Maps from type identifier to the actual MDNode.
59 typedef DenseMap<const MDString *, MDNode *> DITypeIdentifierMap;
60
61 /// \brief A thin wraper around MDNode to access encoded debug info.
62 ///
63 /// This should not be stored in a container, because the underlying MDNode may
64 /// change in certain situations.
65 class DIDescriptor {
66 public:
67   /// \brief Duplicated debug info flags.
68   ///
69   /// \see DebugNode::DIFlags.
70   enum {
71 #define HANDLE_DI_FLAG(ID, NAME) Flag##NAME = DebugNode::Flag##NAME,
72 #include "llvm/IR/DebugInfoFlags.def"
73     FlagAccessibility = DebugNode::FlagAccessibility
74   };
75
76 protected:
77   const MDNode *DbgNode;
78
79 public:
80   explicit DIDescriptor(const MDNode *N = nullptr) : DbgNode(N) {}
81   DIDescriptor(const DebugNode *N) : DbgNode(N) {}
82
83   MDNode *get() const { return const_cast<MDNode *>(DbgNode); }
84   operator MDNode *() const { return get(); }
85   MDNode *operator->() const { return get(); }
86   MDNode &operator*() const { return *get(); }
87
88   // An explicit operator bool so that we can do testing of DI values
89   // easily.
90   // FIXME: This operator bool isn't actually protecting anything at the
91   // moment due to the conversion operator above making DIDescriptor nodes
92   // implicitly convertable to bool.
93   explicit operator bool() const { return DbgNode != nullptr; }
94
95   bool operator==(DIDescriptor Other) const { return DbgNode == Other.DbgNode; }
96   bool operator!=(DIDescriptor Other) const { return !operator==(Other); }
97
98   uint16_t getTag() const {
99     if (auto *N = dyn_cast_or_null<DebugNode>(get()))
100       return N->getTag();
101     return 0;
102   }
103
104   void print(raw_ostream &OS) const;
105   void dump() const;
106 };
107
108 #define DECLARE_SIMPLIFY_DESCRIPTOR(DESC)                                      \
109   class DESC;                                                                  \
110   template <> struct simplify_type<const DESC>;                                \
111   template <> struct simplify_type<DESC>;
112 DECLARE_SIMPLIFY_DESCRIPTOR(DIDescriptor)
113 DECLARE_SIMPLIFY_DESCRIPTOR(DISubrange)
114 DECLARE_SIMPLIFY_DESCRIPTOR(DIEnumerator)
115 DECLARE_SIMPLIFY_DESCRIPTOR(DIScope)
116 DECLARE_SIMPLIFY_DESCRIPTOR(DIType)
117 DECLARE_SIMPLIFY_DESCRIPTOR(DIBasicType)
118 DECLARE_SIMPLIFY_DESCRIPTOR(DIDerivedType)
119 DECLARE_SIMPLIFY_DESCRIPTOR(DICompositeType)
120 DECLARE_SIMPLIFY_DESCRIPTOR(DISubroutineType)
121 DECLARE_SIMPLIFY_DESCRIPTOR(DIFile)
122 DECLARE_SIMPLIFY_DESCRIPTOR(DICompileUnit)
123 DECLARE_SIMPLIFY_DESCRIPTOR(DISubprogram)
124 DECLARE_SIMPLIFY_DESCRIPTOR(DILexicalBlock)
125 DECLARE_SIMPLIFY_DESCRIPTOR(DILexicalBlockFile)
126 DECLARE_SIMPLIFY_DESCRIPTOR(DINameSpace)
127 DECLARE_SIMPLIFY_DESCRIPTOR(DITemplateTypeParameter)
128 DECLARE_SIMPLIFY_DESCRIPTOR(DITemplateValueParameter)
129 DECLARE_SIMPLIFY_DESCRIPTOR(DIGlobalVariable)
130 DECLARE_SIMPLIFY_DESCRIPTOR(DIVariable)
131 DECLARE_SIMPLIFY_DESCRIPTOR(DIExpression)
132 DECLARE_SIMPLIFY_DESCRIPTOR(DILocation)
133 DECLARE_SIMPLIFY_DESCRIPTOR(DIObjCProperty)
134 DECLARE_SIMPLIFY_DESCRIPTOR(DIImportedEntity)
135 #undef DECLARE_SIMPLIFY_DESCRIPTOR
136
137 typedef DebugNodeArray DIArray;
138 typedef MDTypeRefArray DITypeArray;
139
140 /// \brief This is used to represent ranges, for array bounds.
141 class DISubrange : public DIDescriptor {
142 public:
143   DISubrange() = default;
144   DISubrange(const MDSubrange *N) : DIDescriptor(N) {}
145
146   MDSubrange *get() const {
147     return cast_or_null<MDSubrange>(DIDescriptor::get());
148   }
149   operator MDSubrange *() const { return get(); }
150   MDSubrange *operator->() const { return get(); }
151   MDSubrange &operator*() const { return *get(); }
152
153   int64_t getLo() const { return get()->getLowerBound(); }
154   int64_t getCount() const { return get()->getCount(); }
155 };
156
157 /// \brief A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
158 ///
159 /// FIXME: it seems strange that this doesn't have either a reference to the
160 /// type/precision or a file/line pair for location info.
161 class DIEnumerator : public DIDescriptor {
162 public:
163   DIEnumerator() = default;
164   DIEnumerator(const MDEnumerator *N) : DIDescriptor(N) {}
165
166   MDEnumerator *get() const {
167     return cast_or_null<MDEnumerator>(DIDescriptor::get());
168   }
169   operator MDEnumerator *() const { return get(); }
170   MDEnumerator *operator->() const { return get(); }
171   MDEnumerator &operator*() const { return *get(); }
172
173   StringRef getName() const { return get()->getName(); }
174   int64_t getEnumValue() const { return get()->getValue(); }
175 };
176
177 template <typename T> class DIRef;
178 typedef DIRef<DIDescriptor> DIDescriptorRef;
179 typedef DIRef<DIScope> DIScopeRef;
180 typedef DIRef<DIType> DITypeRef;
181
182 /// \brief A base class for various scopes.
183 ///
184 /// Although, implementation-wise, DIScope is the parent class of most
185 /// other DIxxx classes, including DIType and its descendants, most of
186 /// DIScope's descendants are not a substitutable subtype of
187 /// DIScope. The DIDescriptor::isScope() method only is true for
188 /// DIScopes that are scopes in the strict lexical scope sense
189 /// (DICompileUnit, DISubprogram, etc.), but not for, e.g., a DIType.
190 class DIScope : public DIDescriptor {
191 public:
192   DIScope() = default;
193   DIScope(const MDScope *N) : DIDescriptor(N) {}
194
195   MDScope *get() const { return cast_or_null<MDScope>(DIDescriptor::get()); }
196   operator MDScope *() const { return get(); }
197   MDScope *operator->() const { return get(); }
198   MDScope &operator*() const { return *get(); }
199
200   inline DIScopeRef getContext() const;
201   StringRef getName() const { return get()->getName(); }
202   StringRef getFilename() const { return get()->getFilename(); }
203   StringRef getDirectory() const { return get()->getDirectory(); }
204
205   /// \brief Generate a reference to this DIScope.
206   ///
207   /// Uses the type identifier instead of the actual MDNode if possible, to
208   /// help type uniquing.
209   DIScopeRef getRef() const;
210 };
211
212 /// \brief Represents reference to a DIDescriptor.
213 ///
214 /// Abstracts over direct and identifier-based metadata references.
215 template <typename T> class DIRef {
216   /// \brief Val can be either a MDNode or a MDString.
217   ///
218   /// In the latter, MDString specifies the type identifier.
219   const Metadata *Val;
220
221 public:
222   template <class U>
223   DIRef(const TypedDebugNodeRef<U> &Ref,
224         typename std::enable_if<std::is_convertible<U *, T>::value>::type * =
225             nullptr)
226       : Val(Ref) {}
227
228   T resolve(const DITypeIdentifierMap &Map) const;
229   operator Metadata *() const { return const_cast<Metadata *>(Val); }
230 };
231
232 template <>
233 DIDescriptor DIRef<DIDescriptor>::resolve(const DITypeIdentifierMap &Map) const;
234 template <>
235 DIScope DIRef<DIScope>::resolve(const DITypeIdentifierMap &Map) const;
236 template <> DIType DIRef<DIType>::resolve(const DITypeIdentifierMap &Map) const;
237
238 DIScopeRef DIScope::getContext() const { return get()->getScope(); }
239
240 class DIType {
241   MDType *N;
242
243 public:
244   DIType(const MDType *N = nullptr) : N(const_cast<MDType *>(N)) {}
245
246   operator DIDescriptor() const { return N; }
247   operator DIScope() const { return N; }
248   operator MDType *() const { return N; }
249   MDType *operator->() const { return N; }
250   MDType &operator*() const { return *N; }
251 };
252
253 class DIBasicType {
254   MDBasicType *N;
255
256 public:
257   DIBasicType(const MDBasicType *N = nullptr)
258       : N(const_cast<MDBasicType *>(N)) {}
259
260   operator DIDescriptor() const { return N; }
261   operator DIType() const { return N; }
262   operator MDBasicType *() const { return N; }
263   MDBasicType *operator->() const { return N; }
264   MDBasicType &operator*() const { return *N; }
265 };
266
267 class DIDerivedType {
268   MDDerivedTypeBase *N;
269
270 public:
271   DIDerivedType(const MDDerivedTypeBase *N = nullptr)
272       : N(const_cast<MDDerivedTypeBase *>(N)) {}
273
274   operator DIDescriptor() const { return N; }
275   operator DIType() const { return N; }
276   operator MDDerivedTypeBase *() const { return N; }
277   MDDerivedTypeBase *operator->() const { return N; }
278   MDDerivedTypeBase &operator*() const { return *N; }
279 };
280
281 class DICompositeType {
282   MDCompositeTypeBase *N;
283
284 public:
285   DICompositeType(const MDCompositeTypeBase *N = nullptr)
286       : N(const_cast<MDCompositeTypeBase *>(N)) {}
287
288   operator DIDescriptor() const { return N; }
289   operator DIType() const { return N; }
290   operator MDCompositeTypeBase *() const { return N; }
291   MDCompositeTypeBase *operator->() const { return N; }
292   MDCompositeTypeBase &operator*() const { return *N; }
293 };
294
295 class DISubroutineType {
296   MDSubroutineType *N;
297
298 public:
299   DISubroutineType(const MDSubroutineType *N = nullptr)
300       : N(const_cast<MDSubroutineType *>(N)) {}
301
302   operator DIDescriptor() const { return N; }
303   operator DIType() const { return N; }
304   operator DICompositeType() const { return N; }
305   operator MDSubroutineType *() const { return N; }
306   MDSubroutineType *operator->() const { return N; }
307   MDSubroutineType &operator*() const { return *N; }
308 };
309
310 class DIFile {
311   MDFile *N;
312
313 public:
314   DIFile(const MDFile *N = nullptr) : N(const_cast<MDFile *>(N)) {}
315
316   operator DIDescriptor() const { return N; }
317   operator DIScope() const { return N; }
318   operator MDFile *() const { return N; }
319   MDFile *operator->() const { return N; }
320   MDFile &operator*() const { return *N; }
321 };
322
323 class DICompileUnit {
324   MDCompileUnit *N;
325
326 public:
327   DICompileUnit(const MDCompileUnit *N = nullptr)
328       : N(const_cast<MDCompileUnit *>(N)) {}
329
330   operator DIDescriptor() const { return N; }
331   operator DIScope() const { return N; }
332   operator MDCompileUnit *() const { return N; }
333   MDCompileUnit *operator->() const { return N; }
334   MDCompileUnit &operator*() const { return *N; }
335 };
336
337 class DISubprogram {
338   MDSubprogram *N;
339
340 public:
341   DISubprogram(const MDSubprogram *N = nullptr)
342       : N(const_cast<MDSubprogram *>(N)) {}
343
344   operator DIDescriptor() const { return N; }
345   operator DIScope() const { return N; }
346   operator MDSubprogram *() const { return N; }
347   MDSubprogram *operator->() const { return N; }
348   MDSubprogram &operator*() const { return *N; }
349 };
350
351 class DILexicalBlock {
352   MDLexicalBlockBase *N;
353
354 public:
355   DILexicalBlock(const MDLexicalBlockBase *N = nullptr)
356       : N(const_cast<MDLexicalBlockBase *>(N)) {}
357
358   operator DIDescriptor() const { return N; }
359   operator MDLexicalBlockBase *() const { return N; }
360   MDLexicalBlockBase *operator->() const { return N; }
361   MDLexicalBlockBase &operator*() const { return *N; }
362 };
363
364 class DILexicalBlockFile {
365   MDLexicalBlockFile *N;
366
367 public:
368   DILexicalBlockFile(const MDLexicalBlockFile *N = nullptr)
369       : N(const_cast<MDLexicalBlockFile *>(N)) {}
370
371   operator DIDescriptor() const { return N; }
372   operator MDLexicalBlockFile *() const { return N; }
373   MDLexicalBlockFile *operator->() const { return N; }
374   MDLexicalBlockFile &operator*() const { return *N; }
375 };
376
377 class DINameSpace {
378   MDNamespace *N;
379
380 public:
381   DINameSpace(const MDNamespace *N = nullptr)
382       : N(const_cast<MDNamespace *>(N)) {}
383
384   operator DIDescriptor() const { return N; }
385   operator DIScope() const { return N; }
386   operator MDNamespace *() const { return N; }
387   MDNamespace *operator->() const { return N; }
388   MDNamespace &operator*() const { return *N; }
389 };
390
391 class DITemplateTypeParameter {
392   MDTemplateTypeParameter *N;
393
394 public:
395   DITemplateTypeParameter(const MDTemplateTypeParameter *N = nullptr)
396       : N(const_cast<MDTemplateTypeParameter *>(N)) {}
397
398   operator MDTemplateTypeParameter *() const { return N; }
399   MDTemplateTypeParameter *operator->() const { return N; }
400   MDTemplateTypeParameter &operator*() const { return *N; }
401 };
402
403 class DITemplateValueParameter {
404   MDTemplateValueParameter *N;
405
406 public:
407   DITemplateValueParameter(const MDTemplateValueParameter *N = nullptr)
408       : N(const_cast<MDTemplateValueParameter *>(N)) {}
409
410   operator MDTemplateValueParameter *() const { return N; }
411   MDTemplateValueParameter *operator->() const { return N; }
412   MDTemplateValueParameter &operator*() const { return *N; }
413 };
414
415 class DIGlobalVariable {
416   MDGlobalVariable *N;
417
418 public:
419   DIGlobalVariable(const MDGlobalVariable *N = nullptr)
420       : N(const_cast<MDGlobalVariable *>(N)) {}
421
422   operator DIDescriptor() const { return N; }
423   operator MDGlobalVariable *() const { return N; }
424   MDGlobalVariable *operator->() const { return N; }
425   MDGlobalVariable &operator*() const { return *N; }
426 };
427
428 class DIVariable {
429   MDLocalVariable *N;
430
431 public:
432   DIVariable(const MDLocalVariable *N = nullptr)
433       : N(const_cast<MDLocalVariable *>(N)) {}
434
435   operator MDLocalVariable *() const { return N; }
436   MDLocalVariable *operator->() const { return N; }
437   MDLocalVariable &operator*() const { return *N; }
438 };
439
440 class DIExpression {
441   MDExpression *N;
442
443 public:
444   DIExpression(const MDExpression *N = nullptr)
445       : N(const_cast<MDExpression *>(N)) {}
446
447   operator MDExpression *() const { return N; }
448   MDExpression *operator->() const { return N; }
449   MDExpression &operator*() const { return *N; }
450 };
451
452 class DILocation {
453   MDLocation *N;
454
455 public:
456   DILocation(const MDLocation *N = nullptr) : N(const_cast<MDLocation *>(N)) {}
457
458   operator MDLocation *() const { return N; }
459   MDLocation *operator->() const { return N; }
460   MDLocation &operator*() const { return *N; }
461 };
462
463 class DIObjCProperty {
464   MDObjCProperty *N;
465
466 public:
467   DIObjCProperty(const MDObjCProperty *N = nullptr)
468       : N(const_cast<MDObjCProperty *>(N)) {}
469
470   operator MDObjCProperty *() const { return N; }
471   MDObjCProperty *operator->() const { return N; }
472   MDObjCProperty &operator*() const { return *N; }
473 };
474
475 class DIImportedEntity {
476   MDImportedEntity *N;
477
478 public:
479   DIImportedEntity(const MDImportedEntity *N = nullptr)
480       : N(const_cast<MDImportedEntity *>(N)) {}
481
482   operator DIDescriptor() const { return N; }
483   operator MDImportedEntity *() const { return N; }
484   MDImportedEntity *operator->() const { return N; }
485   MDImportedEntity &operator*() const { return *N; }
486 };
487
488 #define SIMPLIFY_DESCRIPTOR(DESC)                                              \
489   template <> struct simplify_type<const DESC> {                               \
490     typedef Metadata *SimpleType;                                              \
491     static SimpleType getSimplifiedValue(const DESC &DI) { return DI; }        \
492   };                                                                           \
493   template <> struct simplify_type<DESC> : simplify_type<const DESC> {};
494 SIMPLIFY_DESCRIPTOR(DIDescriptor)
495 SIMPLIFY_DESCRIPTOR(DISubrange)
496 SIMPLIFY_DESCRIPTOR(DIEnumerator)
497 SIMPLIFY_DESCRIPTOR(DIScope)
498 SIMPLIFY_DESCRIPTOR(DIType)
499 SIMPLIFY_DESCRIPTOR(DIBasicType)
500 SIMPLIFY_DESCRIPTOR(DIDerivedType)
501 SIMPLIFY_DESCRIPTOR(DICompositeType)
502 SIMPLIFY_DESCRIPTOR(DISubroutineType)
503 SIMPLIFY_DESCRIPTOR(DIFile)
504 SIMPLIFY_DESCRIPTOR(DICompileUnit)
505 SIMPLIFY_DESCRIPTOR(DISubprogram)
506 SIMPLIFY_DESCRIPTOR(DILexicalBlock)
507 SIMPLIFY_DESCRIPTOR(DILexicalBlockFile)
508 SIMPLIFY_DESCRIPTOR(DINameSpace)
509 SIMPLIFY_DESCRIPTOR(DITemplateTypeParameter)
510 SIMPLIFY_DESCRIPTOR(DITemplateValueParameter)
511 SIMPLIFY_DESCRIPTOR(DIGlobalVariable)
512 SIMPLIFY_DESCRIPTOR(DIVariable)
513 SIMPLIFY_DESCRIPTOR(DIExpression)
514 SIMPLIFY_DESCRIPTOR(DILocation)
515 SIMPLIFY_DESCRIPTOR(DIObjCProperty)
516 SIMPLIFY_DESCRIPTOR(DIImportedEntity)
517 #undef SIMPLIFY_DESCRIPTOR
518
519 /// \brief Find subprogram that is enclosing this scope.
520 DISubprogram getDISubprogram(const MDNode *Scope);
521
522 /// \brief Find debug info for a given function.
523 /// \returns a valid DISubprogram, if found. Otherwise, it returns an empty
524 /// DISubprogram.
525 DISubprogram getDISubprogram(const Function *F);
526
527 /// \brief Find underlying composite type.
528 DICompositeType getDICompositeType(DIType T);
529
530 /// \brief Generate map by visiting all retained types.
531 DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes);
532
533 /// \brief Strip debug info in the module if it exists.
534 ///
535 /// To do this, we remove all calls to the debugger intrinsics and any named
536 /// metadata for debugging. We also remove debug locations for instructions.
537 /// Return true if module is modified.
538 bool StripDebugInfo(Module &M);
539 bool stripDebugInfo(Function &F);
540
541 /// \brief Return Debug Info Metadata Version by checking module flags.
542 unsigned getDebugMetadataVersionFromModule(const Module &M);
543
544 /// \brief Utility to find all debug info in a module.
545 ///
546 /// DebugInfoFinder tries to list all debug info MDNodes used in a module. To
547 /// list debug info MDNodes used by an instruction, DebugInfoFinder uses
548 /// processDeclare, processValue and processLocation to handle DbgDeclareInst,
549 /// DbgValueInst and DbgLoc attached to instructions. processModule will go
550 /// through all DICompileUnits in llvm.dbg.cu and list debug info MDNodes
551 /// used by the CUs.
552 class DebugInfoFinder {
553 public:
554   DebugInfoFinder() : TypeMapInitialized(false) {}
555
556   /// \brief Process entire module and collect debug info anchors.
557   void processModule(const Module &M);
558
559   /// \brief Process DbgDeclareInst.
560   void processDeclare(const Module &M, const DbgDeclareInst *DDI);
561   /// \brief Process DbgValueInst.
562   void processValue(const Module &M, const DbgValueInst *DVI);
563   /// \brief Process DILocation.
564   void processLocation(const Module &M, DILocation Loc);
565
566   /// \brief Clear all lists.
567   void reset();
568
569 private:
570   void InitializeTypeMap(const Module &M);
571
572   void processType(DIType DT);
573   void processSubprogram(DISubprogram SP);
574   void processScope(DIScope Scope);
575   bool addCompileUnit(DICompileUnit CU);
576   bool addGlobalVariable(DIGlobalVariable DIG);
577   bool addSubprogram(DISubprogram SP);
578   bool addType(DIType DT);
579   bool addScope(DIScope Scope);
580
581 public:
582   typedef SmallVectorImpl<DICompileUnit>::const_iterator compile_unit_iterator;
583   typedef SmallVectorImpl<DISubprogram>::const_iterator subprogram_iterator;
584   typedef SmallVectorImpl<DIGlobalVariable>::const_iterator
585       global_variable_iterator;
586   typedef SmallVectorImpl<DIType>::const_iterator type_iterator;
587   typedef SmallVectorImpl<DIScope>::const_iterator scope_iterator;
588
589   iterator_range<compile_unit_iterator> compile_units() const {
590     return iterator_range<compile_unit_iterator>(CUs.begin(), CUs.end());
591   }
592
593   iterator_range<subprogram_iterator> subprograms() const {
594     return iterator_range<subprogram_iterator>(SPs.begin(), SPs.end());
595   }
596
597   iterator_range<global_variable_iterator> global_variables() const {
598     return iterator_range<global_variable_iterator>(GVs.begin(), GVs.end());
599   }
600
601   iterator_range<type_iterator> types() const {
602     return iterator_range<type_iterator>(TYs.begin(), TYs.end());
603   }
604
605   iterator_range<scope_iterator> scopes() const {
606     return iterator_range<scope_iterator>(Scopes.begin(), Scopes.end());
607   }
608
609   unsigned compile_unit_count() const { return CUs.size(); }
610   unsigned global_variable_count() const { return GVs.size(); }
611   unsigned subprogram_count() const { return SPs.size(); }
612   unsigned type_count() const { return TYs.size(); }
613   unsigned scope_count() const { return Scopes.size(); }
614
615 private:
616   SmallVector<DICompileUnit, 8> CUs;
617   SmallVector<DISubprogram, 8> SPs;
618   SmallVector<DIGlobalVariable, 8> GVs;
619   SmallVector<DIType, 8> TYs;
620   SmallVector<DIScope, 8> Scopes;
621   SmallPtrSet<MDNode *, 64> NodesSeen;
622   DITypeIdentifierMap TypeIdentifierMap;
623
624   /// \brief Specify if TypeIdentifierMap is initialized.
625   bool TypeMapInitialized;
626 };
627
628 DenseMap<const Function *, DISubprogram> makeSubprogramMap(const Module &M);
629
630 } // end namespace llvm
631
632 #endif