LLVM API Documentation

DebugInfo.h
Go to the documentation of this file.
00001 //===- DebugInfo.h - Debug Information Helpers ------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines a bunch of datatypes that are useful for creating and
00011 // walking debug info in LLVM IR form. They essentially provide wrappers around
00012 // the information in the global variables that's needed when constructing the
00013 // DWARF information.
00014 //
00015 //===----------------------------------------------------------------------===//
00016 
00017 #ifndef LLVM_IR_DEBUGINFO_H
00018 #define LLVM_IR_DEBUGINFO_H
00019 
00020 #include "llvm/ADT/DenseMap.h"
00021 #include "llvm/ADT/SmallPtrSet.h"
00022 #include "llvm/ADT/SmallVector.h"
00023 #include "llvm/ADT/StringRef.h"
00024 #include "llvm/ADT/iterator_range.h"
00025 #include "llvm/IR/Metadata.h"
00026 #include "llvm/Support/Casting.h"
00027 #include "llvm/Support/Dwarf.h"
00028 #include "llvm/Support/ErrorHandling.h"
00029 #include <iterator>
00030 
00031 namespace llvm {
00032 class BasicBlock;
00033 class Constant;
00034 class Function;
00035 class GlobalVariable;
00036 class Module;
00037 class Type;
00038 class Value;
00039 class DbgDeclareInst;
00040 class DbgValueInst;
00041 class Instruction;
00042 class Metadata;
00043 class MDNode;
00044 class MDString;
00045 class NamedMDNode;
00046 class LLVMContext;
00047 class raw_ostream;
00048 
00049 class DIFile;
00050 class DISubprogram;
00051 class DILexicalBlock;
00052 class DILexicalBlockFile;
00053 class DIVariable;
00054 class DIType;
00055 class DIScope;
00056 class DIObjCProperty;
00057 
00058 /// \brief Maps from type identifier to the actual MDNode.
00059 typedef DenseMap<const MDString *, MDNode *> DITypeIdentifierMap;
00060 
00061 class DIHeaderFieldIterator
00062     : public std::iterator<std::input_iterator_tag, StringRef, std::ptrdiff_t,
00063                            const StringRef *, StringRef> {
00064   StringRef Header;
00065   StringRef Current;
00066 
00067 public:
00068   DIHeaderFieldIterator() {}
00069   explicit DIHeaderFieldIterator(StringRef Header)
00070       : Header(Header), Current(Header.slice(0, Header.find('\0'))) {}
00071   StringRef operator*() const { return Current; }
00072   const StringRef *operator->() const { return &Current; }
00073   DIHeaderFieldIterator &operator++() {
00074     increment();
00075     return *this;
00076   }
00077   DIHeaderFieldIterator operator++(int) {
00078     DIHeaderFieldIterator X(*this);
00079     increment();
00080     return X;
00081   }
00082   bool operator==(const DIHeaderFieldIterator &X) const {
00083     return Current.data() == X.Current.data();
00084   }
00085   bool operator!=(const DIHeaderFieldIterator &X) const {
00086     return !(*this == X);
00087   }
00088 
00089   StringRef getHeader() const { return Header; }
00090   StringRef getCurrent() const { return Current; }
00091   StringRef getPrefix() const {
00092     if (Current.begin() == Header.begin())
00093       return StringRef();
00094     return Header.slice(0, Current.begin() - Header.begin() - 1);
00095   }
00096   StringRef getSuffix() const {
00097     if (Current.end() == Header.end())
00098       return StringRef();
00099     return Header.slice(Current.end() - Header.begin() + 1, StringRef::npos);
00100   }
00101 
00102   /// \brief Get the current field as a number.
00103   ///
00104   /// Convert the current field into a number.  Return \c 0 on error.
00105   template <class T> T getNumber() const {
00106     T Int;
00107     if (getCurrent().getAsInteger(0, Int))
00108       return 0;
00109     return Int;
00110   }
00111 
00112 private:
00113   void increment() {
00114     assert(Current.data() != nullptr && "Cannot increment past the end");
00115     StringRef Suffix = getSuffix();
00116     Current = Suffix.slice(0, Suffix.find('\0'));
00117   }
00118 };
00119 
00120 /// \brief A thin wraper around MDNode to access encoded debug info.
00121 ///
00122 /// This should not be stored in a container, because the underlying MDNode may
00123 /// change in certain situations.
00124 class DIDescriptor {
00125   // Befriends DIRef so DIRef can befriend the protected member
00126   // function: getFieldAs<DIRef>.
00127   template <typename T> friend class DIRef;
00128 
00129 public:
00130   /// \brief Accessibility flags.
00131   ///
00132   /// The three accessibility flags are mutually exclusive and rolled together
00133   /// in the first two bits.
00134   enum {
00135     FlagAccessibility     = 1 << 0 | 1 << 1,
00136     FlagPrivate           = 1,
00137     FlagProtected         = 2,
00138     FlagPublic            = 3,
00139 
00140     FlagFwdDecl           = 1 << 2,
00141     FlagAppleBlock        = 1 << 3,
00142     FlagBlockByrefStruct  = 1 << 4,
00143     FlagVirtual           = 1 << 5,
00144     FlagArtificial        = 1 << 6,
00145     FlagExplicit          = 1 << 7,
00146     FlagPrototyped        = 1 << 8,
00147     FlagObjcClassComplete = 1 << 9,
00148     FlagObjectPointer     = 1 << 10,
00149     FlagVector            = 1 << 11,
00150     FlagStaticMember      = 1 << 12,
00151     FlagLValueReference   = 1 << 13,
00152     FlagRValueReference   = 1 << 14
00153   };
00154 
00155 protected:
00156   const MDNode *DbgNode;
00157 
00158   StringRef getStringField(unsigned Elt) const;
00159   unsigned getUnsignedField(unsigned Elt) const {
00160     return (unsigned)getUInt64Field(Elt);
00161   }
00162   uint64_t getUInt64Field(unsigned Elt) const;
00163   int64_t getInt64Field(unsigned Elt) const;
00164   DIDescriptor getDescriptorField(unsigned Elt) const;
00165 
00166   template <typename DescTy> DescTy getFieldAs(unsigned Elt) const {
00167     return DescTy(getDescriptorField(Elt));
00168   }
00169 
00170   GlobalVariable *getGlobalVariableField(unsigned Elt) const;
00171   Constant *getConstantField(unsigned Elt) const;
00172   Function *getFunctionField(unsigned Elt) const;
00173   void replaceFunctionField(unsigned Elt, Function *F);
00174 
00175 public:
00176   explicit DIDescriptor(const MDNode *N = nullptr) : DbgNode(N) {}
00177 
00178   bool Verify() const;
00179 
00180   MDNode *get() const { return const_cast<MDNode *>(DbgNode); }
00181   operator MDNode *() const { return get(); }
00182   MDNode *operator->() const { return get(); }
00183 
00184   // An explicit operator bool so that we can do testing of DI values
00185   // easily.
00186   // FIXME: This operator bool isn't actually protecting anything at the
00187   // moment due to the conversion operator above making DIDescriptor nodes
00188   // implicitly convertable to bool.
00189   LLVM_EXPLICIT operator bool() const { return DbgNode != nullptr; }
00190 
00191   bool operator==(DIDescriptor Other) const { return DbgNode == Other.DbgNode; }
00192   bool operator!=(DIDescriptor Other) const { return !operator==(Other); }
00193 
00194   StringRef getHeader() const { return getStringField(0); }
00195 
00196   size_t getNumHeaderFields() const {
00197     return std::distance(DIHeaderFieldIterator(getHeader()),
00198                          DIHeaderFieldIterator());
00199   }
00200 
00201   DIHeaderFieldIterator header_begin() const {
00202     return DIHeaderFieldIterator(getHeader());
00203   }
00204   DIHeaderFieldIterator header_end() const { return DIHeaderFieldIterator(); }
00205 
00206   DIHeaderFieldIterator getHeaderIterator(unsigned Index) const {
00207     // Since callers expect an empty string for out-of-range accesses, we can't
00208     // use std::advance() here.
00209     for (auto I = header_begin(), E = header_end(); I != E; ++I, --Index)
00210       if (!Index)
00211         return I;
00212     return header_end();
00213   }
00214 
00215   StringRef getHeaderField(unsigned Index) const {
00216     return *getHeaderIterator(Index);
00217   }
00218 
00219   template <class T> T getHeaderFieldAs(unsigned Index) const {
00220     return getHeaderIterator(Index).getNumber<T>();
00221   }
00222 
00223   uint16_t getTag() const { return getHeaderFieldAs<uint16_t>(0); }
00224 
00225   bool isDerivedType() const;
00226   bool isCompositeType() const;
00227   bool isSubroutineType() const;
00228   bool isBasicType() const;
00229   bool isVariable() const;
00230   bool isSubprogram() const;
00231   bool isGlobalVariable() const;
00232   bool isScope() const;
00233   bool isFile() const;
00234   bool isCompileUnit() const;
00235   bool isNameSpace() const;
00236   bool isLexicalBlockFile() const;
00237   bool isLexicalBlock() const;
00238   bool isSubrange() const;
00239   bool isEnumerator() const;
00240   bool isType() const;
00241   bool isTemplateTypeParameter() const;
00242   bool isTemplateValueParameter() const;
00243   bool isObjCProperty() const;
00244   bool isImportedEntity() const;
00245   bool isExpression() const;
00246 
00247   void print(raw_ostream &OS) const;
00248   void dump() const;
00249 
00250   /// \brief Replace all uses of debug info referenced by this descriptor.
00251   void replaceAllUsesWith(LLVMContext &VMContext, DIDescriptor D);
00252   void replaceAllUsesWith(MDNode *D);
00253 };
00254 
00255 /// \brief This is used to represent ranges, for array bounds.
00256 class DISubrange : public DIDescriptor {
00257   friend class DIDescriptor;
00258   void printInternal(raw_ostream &OS) const;
00259 
00260 public:
00261   explicit DISubrange(const MDNode *N = nullptr) : DIDescriptor(N) {}
00262 
00263   int64_t getLo() const { return getHeaderFieldAs<int64_t>(1); }
00264   int64_t getCount() const { return getHeaderFieldAs<int64_t>(2); }
00265   bool Verify() const;
00266 };
00267 
00268 /// \brief This descriptor holds an array of nodes with type T.
00269 template <typename T> class DITypedArray : public DIDescriptor {
00270 public:
00271   explicit DITypedArray(const MDNode *N = nullptr) : DIDescriptor(N) {}
00272   unsigned getNumElements() const {
00273     return DbgNode ? DbgNode->getNumOperands() : 0;
00274   }
00275   T getElement(unsigned Idx) const { return getFieldAs<T>(Idx); }
00276 };
00277 
00278 typedef DITypedArray<DIDescriptor> DIArray;
00279 
00280 /// \brief A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
00281 ///
00282 /// FIXME: it seems strange that this doesn't have either a reference to the
00283 /// type/precision or a file/line pair for location info.
00284 class DIEnumerator : public DIDescriptor {
00285   friend class DIDescriptor;
00286   void printInternal(raw_ostream &OS) const;
00287 
00288 public:
00289   explicit DIEnumerator(const MDNode *N = nullptr) : DIDescriptor(N) {}
00290 
00291   StringRef getName() const { return getHeaderField(1); }
00292   int64_t getEnumValue() const { return getHeaderFieldAs<int64_t>(2); }
00293   bool Verify() const;
00294 };
00295 
00296 template <typename T> class DIRef;
00297 typedef DIRef<DIScope> DIScopeRef;
00298 typedef DIRef<DIType> DITypeRef;
00299 typedef DITypedArray<DITypeRef> DITypeArray;
00300 
00301 /// \brief A base class for various scopes.
00302 ///
00303 /// Although, implementation-wise, DIScope is the parent class of most
00304 /// other DIxxx classes, including DIType and its descendants, most of
00305 /// DIScope's descendants are not a substitutable subtype of
00306 /// DIScope. The DIDescriptor::isScope() method only is true for
00307 /// DIScopes that are scopes in the strict lexical scope sense
00308 /// (DICompileUnit, DISubprogram, etc.), but not for, e.g., a DIType.
00309 class DIScope : public DIDescriptor {
00310 protected:
00311   friend class DIDescriptor;
00312   void printInternal(raw_ostream &OS) const;
00313 
00314 public:
00315   explicit DIScope(const MDNode *N = nullptr) : DIDescriptor(N) {}
00316 
00317   /// \brief Get the parent scope.
00318   ///
00319   /// Gets the parent scope for this scope node or returns a default
00320   /// constructed scope.
00321   DIScopeRef getContext() const;
00322   /// \brief Get the scope name.
00323   ///
00324   /// If the scope node has a name, return that, else return an empty string.
00325   StringRef getName() const;
00326   StringRef getFilename() const;
00327   StringRef getDirectory() const;
00328 
00329   /// \brief Generate a reference to this DIScope.
00330   ///
00331   /// Uses the type identifier instead of the actual MDNode if possible, to
00332   /// help type uniquing.
00333   DIScopeRef getRef() const;
00334 };
00335 
00336 /// \brief Represents reference to a DIDescriptor.
00337 ///
00338 /// Abstracts over direct and identifier-based metadata references.
00339 template <typename T> class DIRef {
00340   template <typename DescTy>
00341   friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const;
00342   friend DIScopeRef DIScope::getContext() const;
00343   friend DIScopeRef DIScope::getRef() const;
00344   friend class DIType;
00345 
00346   /// \brief Val can be either a MDNode or a MDString.
00347   ///
00348   /// In the latter, MDString specifies the type identifier.
00349   const Metadata *Val;
00350   explicit DIRef(const Metadata *V);
00351 
00352 public:
00353   T resolve(const DITypeIdentifierMap &Map) const;
00354   StringRef getName() const;
00355   operator Metadata *() const { return const_cast<Metadata *>(Val); }
00356 };
00357 
00358 template <typename T>
00359 T DIRef<T>::resolve(const DITypeIdentifierMap &Map) const {
00360   if (!Val)
00361     return T();
00362 
00363   if (const MDNode *MD = dyn_cast<MDNode>(Val))
00364     return T(MD);
00365 
00366   const MDString *MS = cast<MDString>(Val);
00367   // Find the corresponding MDNode.
00368   DITypeIdentifierMap::const_iterator Iter = Map.find(MS);
00369   assert(Iter != Map.end() && "Identifier not in the type map?");
00370   assert(DIDescriptor(Iter->second).isType() &&
00371          "MDNode in DITypeIdentifierMap should be a DIType.");
00372   return T(Iter->second);
00373 }
00374 
00375 template <typename T> StringRef DIRef<T>::getName() const {
00376   if (!Val)
00377     return StringRef();
00378 
00379   if (const MDNode *MD = dyn_cast<MDNode>(Val))
00380     return T(MD).getName();
00381 
00382   const MDString *MS = cast<MDString>(Val);
00383   return MS->getString();
00384 }
00385 
00386 /// \brief Handle fields that are references to DIScopes.
00387 template <> DIScopeRef DIDescriptor::getFieldAs<DIScopeRef>(unsigned Elt) const;
00388 /// \brief Specialize DIRef constructor for DIScopeRef.
00389 template <> DIRef<DIScope>::DIRef(const Metadata *V);
00390 
00391 /// \brief Handle fields that are references to DITypes.
00392 template <> DITypeRef DIDescriptor::getFieldAs<DITypeRef>(unsigned Elt) const;
00393 /// \brief Specialize DIRef constructor for DITypeRef.
00394 template <> DIRef<DIType>::DIRef(const Metadata *V);
00395 
00396 /// \brief This is a wrapper for a type.
00397 ///
00398 /// FIXME: Types should be factored much better so that CV qualifiers and
00399 /// others do not require a huge and empty descriptor full of zeros.
00400 class DIType : public DIScope {
00401 protected:
00402   friend class DIDescriptor;
00403   void printInternal(raw_ostream &OS) const;
00404 
00405 public:
00406   explicit DIType(const MDNode *N = nullptr) : DIScope(N) {}
00407   operator DITypeRef() const {
00408     assert(isType() &&
00409            "constructing DITypeRef from an MDNode that is not a type");
00410     return DITypeRef(&*getRef());
00411   }
00412 
00413   bool Verify() const;
00414 
00415   DIScopeRef getContext() const { return getFieldAs<DIScopeRef>(2); }
00416   StringRef getName() const { return getHeaderField(1); }
00417   unsigned getLineNumber() const { return getHeaderFieldAs<unsigned>(2); }
00418   uint64_t getSizeInBits() const { return getHeaderFieldAs<unsigned>(3); }
00419   uint64_t getAlignInBits() const { return getHeaderFieldAs<unsigned>(4); }
00420   // FIXME: Offset is only used for DW_TAG_member nodes.  Making every type
00421   // carry this is just plain insane.
00422   uint64_t getOffsetInBits() const { return getHeaderFieldAs<unsigned>(5); }
00423   unsigned getFlags() const { return getHeaderFieldAs<unsigned>(6); }
00424   bool isPrivate() const {
00425     return (getFlags() & FlagAccessibility) == FlagPrivate;
00426   }
00427   bool isProtected() const {
00428     return (getFlags() & FlagAccessibility) == FlagProtected;
00429   }
00430   bool isPublic() const {
00431     return (getFlags() & FlagAccessibility) == FlagPublic;
00432   }
00433   bool isForwardDecl() const { return (getFlags() & FlagFwdDecl) != 0; }
00434   bool isAppleBlockExtension() const {
00435     return (getFlags() & FlagAppleBlock) != 0;
00436   }
00437   bool isBlockByrefStruct() const {
00438     return (getFlags() & FlagBlockByrefStruct) != 0;
00439   }
00440   bool isVirtual() const { return (getFlags() & FlagVirtual) != 0; }
00441   bool isArtificial() const { return (getFlags() & FlagArtificial) != 0; }
00442   bool isObjectPointer() const { return (getFlags() & FlagObjectPointer) != 0; }
00443   bool isObjcClassComplete() const {
00444     return (getFlags() & FlagObjcClassComplete) != 0;
00445   }
00446   bool isVector() const { return (getFlags() & FlagVector) != 0; }
00447   bool isStaticMember() const { return (getFlags() & FlagStaticMember) != 0; }
00448   bool isLValueReference() const {
00449     return (getFlags() & FlagLValueReference) != 0;
00450   }
00451   bool isRValueReference() const {
00452     return (getFlags() & FlagRValueReference) != 0;
00453   }
00454   bool isValid() const { return DbgNode && isType(); }
00455 };
00456 
00457 /// \brief A basic type, like 'int' or 'float'.
00458 class DIBasicType : public DIType {
00459 public:
00460   explicit DIBasicType(const MDNode *N = nullptr) : DIType(N) {}
00461 
00462   unsigned getEncoding() const { return getHeaderFieldAs<unsigned>(7); }
00463 
00464   bool Verify() const;
00465 };
00466 
00467 /// \brief A simple derived type
00468 ///
00469 /// Like a const qualified type, a typedef, a pointer or reference, et cetera.
00470 /// Or, a data member of a class/struct/union.
00471 class DIDerivedType : public DIType {
00472   friend class DIDescriptor;
00473   void printInternal(raw_ostream &OS) const;
00474 
00475 public:
00476   explicit DIDerivedType(const MDNode *N = nullptr) : DIType(N) {}
00477 
00478   DITypeRef getTypeDerivedFrom() const { return getFieldAs<DITypeRef>(3); }
00479 
00480   /// \brief Return property node, if this ivar is associated with one.
00481   MDNode *getObjCProperty() const;
00482 
00483   DITypeRef getClassType() const {
00484     assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
00485     return getFieldAs<DITypeRef>(4);
00486   }
00487 
00488   Constant *getConstant() const {
00489     assert((getTag() == dwarf::DW_TAG_member) && isStaticMember());
00490     return getConstantField(4);
00491   }
00492 
00493   bool Verify() const;
00494 };
00495 
00496 /// \brief Types that refer to multiple other types.
00497 ///
00498 /// This descriptor holds a type that can refer to multiple other types, like a
00499 /// function or struct.
00500 ///
00501 /// DICompositeType is derived from DIDerivedType because some
00502 /// composite types (such as enums) can be derived from basic types
00503 // FIXME: Make this derive from DIType directly & just store the
00504 // base type in a single DIType field.
00505 class DICompositeType : public DIDerivedType {
00506   friend class DIBuilder;
00507   friend class DIDescriptor;
00508   void printInternal(raw_ostream &OS) const;
00509 
00510   /// \brief Set the array of member DITypes.
00511   void setArraysHelper(MDNode *Elements, MDNode *TParams);
00512 
00513 public:
00514   explicit DICompositeType(const MDNode *N = nullptr) : DIDerivedType(N) {}
00515 
00516   DIArray getElements() const {
00517     assert(!isSubroutineType() && "no elements for DISubroutineType");
00518     return getFieldAs<DIArray>(4);
00519   }
00520 
00521 private:
00522   template <typename T>
00523   void setArrays(DITypedArray<T> Elements, DIArray TParams = DIArray()) {
00524     assert(
00525         (!TParams || DbgNode->getNumOperands() == 8) &&
00526         "If you're setting the template parameters this should include a slot "
00527         "for that!");
00528     setArraysHelper(Elements, TParams);
00529   }
00530 
00531 public:
00532   unsigned getRunTimeLang() const { return getHeaderFieldAs<unsigned>(7); }
00533   DITypeRef getContainingType() const { return getFieldAs<DITypeRef>(5); }
00534 
00535 private:
00536   /// \brief Set the containing type.
00537   void setContainingType(DICompositeType ContainingType);
00538 
00539 public:
00540   DIArray getTemplateParams() const { return getFieldAs<DIArray>(6); }
00541   MDString *getIdentifier() const;
00542 
00543   bool Verify() const;
00544 };
00545 
00546 class DISubroutineType : public DICompositeType {
00547 public:
00548   explicit DISubroutineType(const MDNode *N = nullptr) : DICompositeType(N) {}
00549   DITypedArray<DITypeRef> getTypeArray() const {
00550     return getFieldAs<DITypedArray<DITypeRef>>(4);
00551   }
00552 };
00553 
00554 /// \brief This is a wrapper for a file.
00555 class DIFile : public DIScope {
00556   friend class DIDescriptor;
00557 
00558 public:
00559   explicit DIFile(const MDNode *N = nullptr) : DIScope(N) {}
00560 
00561   /// \brief Retrieve the MDNode for the directory/file pair.
00562   MDNode *getFileNode() const;
00563   bool Verify() const;
00564 };
00565 
00566 /// \brief A wrapper for a compile unit.
00567 class DICompileUnit : public DIScope {
00568   friend class DIDescriptor;
00569   void printInternal(raw_ostream &OS) const;
00570 
00571 public:
00572   explicit DICompileUnit(const MDNode *N = nullptr) : DIScope(N) {}
00573 
00574   dwarf::SourceLanguage getLanguage() const {
00575     return static_cast<dwarf::SourceLanguage>(getHeaderFieldAs<unsigned>(1));
00576   }
00577   StringRef getProducer() const { return getHeaderField(2); }
00578 
00579   bool isOptimized() const { return getHeaderFieldAs<bool>(3) != 0; }
00580   StringRef getFlags() const { return getHeaderField(4); }
00581   unsigned getRunTimeVersion() const { return getHeaderFieldAs<unsigned>(5); }
00582 
00583   DIArray getEnumTypes() const;
00584   DIArray getRetainedTypes() const;
00585   DIArray getSubprograms() const;
00586   DIArray getGlobalVariables() const;
00587   DIArray getImportedEntities() const;
00588 
00589   void replaceSubprograms(DIArray Subprograms);
00590   void replaceGlobalVariables(DIArray GlobalVariables);
00591 
00592   StringRef getSplitDebugFilename() const { return getHeaderField(6); }
00593   unsigned getEmissionKind() const { return getHeaderFieldAs<unsigned>(7); }
00594 
00595   bool Verify() const;
00596 };
00597 
00598 /// \brief This is a wrapper for a subprogram (e.g. a function).
00599 class DISubprogram : public DIScope {
00600   friend class DIDescriptor;
00601   void printInternal(raw_ostream &OS) const;
00602 
00603 public:
00604   explicit DISubprogram(const MDNode *N = nullptr) : DIScope(N) {}
00605 
00606   StringRef getName() const { return getHeaderField(1); }
00607   StringRef getDisplayName() const { return getHeaderField(2); }
00608   StringRef getLinkageName() const { return getHeaderField(3); }
00609   unsigned getLineNumber() const { return getHeaderFieldAs<unsigned>(4); }
00610 
00611   /// \brief Check if this is local (like 'static' in C).
00612   unsigned isLocalToUnit() const { return getHeaderFieldAs<unsigned>(5); }
00613   unsigned isDefinition() const { return getHeaderFieldAs<unsigned>(6); }
00614 
00615   unsigned getVirtuality() const { return getHeaderFieldAs<unsigned>(7); }
00616   unsigned getVirtualIndex() const { return getHeaderFieldAs<unsigned>(8); }
00617 
00618   unsigned getFlags() const { return getHeaderFieldAs<unsigned>(9); }
00619 
00620   unsigned isOptimized() const { return getHeaderFieldAs<bool>(10); }
00621 
00622   /// \brief Get the beginning of the scope of the function (not the name).
00623   unsigned getScopeLineNumber() const { return getHeaderFieldAs<unsigned>(11); }
00624 
00625   DIScopeRef getContext() const { return getFieldAs<DIScopeRef>(2); }
00626   DISubroutineType getType() const { return getFieldAs<DISubroutineType>(3); }
00627 
00628   DITypeRef getContainingType() const { return getFieldAs<DITypeRef>(4); }
00629 
00630   bool Verify() const;
00631 
00632   /// \brief Check if this provides debugging information for the function F.
00633   bool describes(const Function *F);
00634 
00635   Function *getFunction() const { return getFunctionField(5); }
00636   void replaceFunction(Function *F) { replaceFunctionField(5, F); }
00637   DIArray getTemplateParams() const { return getFieldAs<DIArray>(6); }
00638   DISubprogram getFunctionDeclaration() const {
00639     return getFieldAs<DISubprogram>(7);
00640   }
00641   MDNode *getVariablesNodes() const;
00642   DIArray getVariables() const;
00643 
00644   unsigned isArtificial() const { return (getFlags() & FlagArtificial) != 0; }
00645   /// \brief Check for the "private" access specifier.
00646   bool isPrivate() const {
00647     return (getFlags() & FlagAccessibility) == FlagPrivate;
00648   }
00649   /// \brief Check for the "protected" access specifier.
00650   bool isProtected() const {
00651     return (getFlags() & FlagAccessibility) == FlagProtected;
00652   }
00653   /// \brief Check for the "public" access specifier.
00654   bool isPublic() const {
00655     return (getFlags() & FlagAccessibility) == FlagPublic;
00656   }
00657   /// \brief Check for "explicit".
00658   bool isExplicit() const { return (getFlags() & FlagExplicit) != 0; }
00659   /// \brief Check if this is prototyped.
00660   bool isPrototyped() const { return (getFlags() & FlagPrototyped) != 0; }
00661 
00662   /// \brief Check if this is reference-qualified.
00663   ///
00664   /// Return true if this subprogram is a C++11 reference-qualified non-static
00665   /// member function (void foo() &).
00666   unsigned isLValueReference() const {
00667     return (getFlags() & FlagLValueReference) != 0;
00668   }
00669 
00670   /// \brief Check if this is rvalue-reference-qualified.
00671   ///
00672   /// Return true if this subprogram is a C++11 rvalue-reference-qualified
00673   /// non-static member function (void foo() &&).
00674   unsigned isRValueReference() const {
00675     return (getFlags() & FlagRValueReference) != 0;
00676   }
00677 };
00678 
00679 /// \brief This is a wrapper for a lexical block.
00680 class DILexicalBlock : public DIScope {
00681 public:
00682   explicit DILexicalBlock(const MDNode *N = nullptr) : DIScope(N) {}
00683   DIScope getContext() const { return getFieldAs<DIScope>(2); }
00684   unsigned getLineNumber() const { return getHeaderFieldAs<unsigned>(1); }
00685   unsigned getColumnNumber() const { return getHeaderFieldAs<unsigned>(2); }
00686   bool Verify() const;
00687 };
00688 
00689 /// \brief This is a wrapper for a lexical block with a filename change.
00690 class DILexicalBlockFile : public DIScope {
00691 public:
00692   explicit DILexicalBlockFile(const MDNode *N = nullptr) : DIScope(N) {}
00693   DIScope getContext() const {
00694     if (getScope().isSubprogram())
00695       return getScope();
00696     return getScope().getContext();
00697   }
00698   unsigned getLineNumber() const { return getScope().getLineNumber(); }
00699   unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
00700   DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(2); }
00701   unsigned getDiscriminator() const { return getHeaderFieldAs<unsigned>(1); }
00702   bool Verify() const;
00703 };
00704 
00705 /// \brief A wrapper for a C++ style name space.
00706 class DINameSpace : public DIScope {
00707   friend class DIDescriptor;
00708   void printInternal(raw_ostream &OS) const;
00709 
00710 public:
00711   explicit DINameSpace(const MDNode *N = nullptr) : DIScope(N) {}
00712   StringRef getName() const { return getHeaderField(1); }
00713   unsigned getLineNumber() const { return getHeaderFieldAs<unsigned>(2); }
00714   DIScope getContext() const { return getFieldAs<DIScope>(2); }
00715   bool Verify() const;
00716 };
00717 
00718 /// \brief This is a wrapper for template type parameter.
00719 class DITemplateTypeParameter : public DIDescriptor {
00720 public:
00721   explicit DITemplateTypeParameter(const MDNode *N = nullptr)
00722       : DIDescriptor(N) {}
00723 
00724   StringRef getName() const { return getHeaderField(1); }
00725   unsigned getLineNumber() const { return getHeaderFieldAs<unsigned>(2); }
00726   unsigned getColumnNumber() const { return getHeaderFieldAs<unsigned>(3); }
00727 
00728   DIScopeRef getContext() const { return getFieldAs<DIScopeRef>(1); }
00729   DITypeRef getType() const { return getFieldAs<DITypeRef>(2); }
00730   StringRef getFilename() const { return getFieldAs<DIFile>(3).getFilename(); }
00731   StringRef getDirectory() const {
00732     return getFieldAs<DIFile>(3).getDirectory();
00733   }
00734   bool Verify() const;
00735 };
00736 
00737 /// \brief This is a wrapper for template value parameter.
00738 class DITemplateValueParameter : public DIDescriptor {
00739 public:
00740   explicit DITemplateValueParameter(const MDNode *N = nullptr)
00741       : DIDescriptor(N) {}
00742 
00743   StringRef getName() const { return getHeaderField(1); }
00744   unsigned getLineNumber() const { return getHeaderFieldAs<unsigned>(2); }
00745   unsigned getColumnNumber() const { return getHeaderFieldAs<unsigned>(3); }
00746 
00747   DIScopeRef getContext() const { return getFieldAs<DIScopeRef>(1); }
00748   DITypeRef getType() const { return getFieldAs<DITypeRef>(2); }
00749   Metadata *getValue() const;
00750   StringRef getFilename() const { return getFieldAs<DIFile>(4).getFilename(); }
00751   StringRef getDirectory() const {
00752     return getFieldAs<DIFile>(4).getDirectory();
00753   }
00754   bool Verify() const;
00755 };
00756 
00757 /// \brief This is a wrapper for a global variable.
00758 class DIGlobalVariable : public DIDescriptor {
00759   friend class DIDescriptor;
00760   void printInternal(raw_ostream &OS) const;
00761 
00762 public:
00763   explicit DIGlobalVariable(const MDNode *N = nullptr) : DIDescriptor(N) {}
00764 
00765   StringRef getName() const { return getHeaderField(1); }
00766   StringRef getDisplayName() const { return getHeaderField(2); }
00767   StringRef getLinkageName() const { return getHeaderField(3); }
00768   unsigned getLineNumber() const { return getHeaderFieldAs<unsigned>(4); }
00769   unsigned isLocalToUnit() const { return getHeaderFieldAs<bool>(5); }
00770   unsigned isDefinition() const { return getHeaderFieldAs<bool>(6); }
00771 
00772   DIScope getContext() const { return getFieldAs<DIScope>(1); }
00773   StringRef getFilename() const { return getFieldAs<DIFile>(2).getFilename(); }
00774   StringRef getDirectory() const {
00775     return getFieldAs<DIFile>(2).getDirectory();
00776   }
00777   DITypeRef getType() const { return getFieldAs<DITypeRef>(3); }
00778 
00779   GlobalVariable *getGlobal() const { return getGlobalVariableField(4); }
00780   Constant *getConstant() const { return getConstantField(4); }
00781   DIDerivedType getStaticDataMemberDeclaration() const {
00782     return getFieldAs<DIDerivedType>(5);
00783   }
00784 
00785   bool Verify() const;
00786 };
00787 
00788 /// \brief This is a wrapper for a variable (e.g. parameter, local, global etc).
00789 class DIVariable : public DIDescriptor {
00790   friend class DIDescriptor;
00791   void printInternal(raw_ostream &OS) const;
00792 
00793 public:
00794   explicit DIVariable(const MDNode *N = nullptr) : DIDescriptor(N) {}
00795 
00796   StringRef getName() const { return getHeaderField(1); }
00797   unsigned getLineNumber() const {
00798     // FIXME: Line number and arg number shouldn't be merged together like this.
00799     return (getHeaderFieldAs<unsigned>(2) << 8) >> 8;
00800   }
00801   unsigned getArgNumber() const { return getHeaderFieldAs<unsigned>(2) >> 24; }
00802 
00803   DIScope getContext() const { return getFieldAs<DIScope>(1); }
00804   DIFile getFile() const { return getFieldAs<DIFile>(2); }
00805   DITypeRef getType() const { return getFieldAs<DITypeRef>(3); }
00806 
00807   /// \brief Return true if this variable is marked as "artificial".
00808   bool isArtificial() const {
00809     return (getHeaderFieldAs<unsigned>(3) & FlagArtificial) != 0;
00810   }
00811 
00812   bool isObjectPointer() const {
00813     return (getHeaderFieldAs<unsigned>(3) & FlagObjectPointer) != 0;
00814   }
00815 
00816   /// \brief If this variable is inlined then return inline location.
00817   MDNode *getInlinedAt() const;
00818 
00819   bool Verify() const;
00820 
00821   /// \brief Check if this is a "__block" variable (Apple Blocks).
00822   bool isBlockByrefVariable(const DITypeIdentifierMap &Map) const {
00823     return (getType().resolve(Map)).isBlockByrefStruct();
00824   }
00825 
00826   /// \brief Check if this is an inlined function argument.
00827   bool isInlinedFnArgument(const Function *CurFn);
00828 
00829   /// \brief Return the size reported by the variable's type.
00830   unsigned getSizeInBits(const DITypeIdentifierMap &Map);
00831 
00832   void printExtendedName(raw_ostream &OS) const;
00833 };
00834 
00835 /// \brief A complex location expression in postfix notation.
00836 ///
00837 /// This is (almost) a DWARF expression that modifies the location of a
00838 /// variable or (or the location of a single piece of a variable).
00839 ///
00840 /// FIXME: Instead of DW_OP_plus taking an argument, this should use DW_OP_const
00841 /// and have DW_OP_plus consume the topmost elements on the stack.
00842 class DIExpression : public DIDescriptor {
00843   friend class DIDescriptor;
00844   void printInternal(raw_ostream &OS) const;
00845 
00846 public:
00847   explicit DIExpression(const MDNode *N = nullptr) : DIDescriptor(N) {}
00848 
00849   bool Verify() const;
00850 
00851   /// \brief Return the number of elements in the complex expression.
00852   unsigned getNumElements() const {
00853     if (!DbgNode)
00854       return 0;
00855     unsigned N = getNumHeaderFields();
00856     assert(N > 0 && "missing tag");
00857     return N - 1;
00858   }
00859 
00860   /// \brief return the Idx'th complex address element.
00861   uint64_t getElement(unsigned Idx) const;
00862 
00863   /// \brief Return whether this is a piece of an aggregate variable.
00864   bool isVariablePiece() const;
00865   /// \brief Return the offset of this piece in bytes.
00866   uint64_t getPieceOffset() const;
00867   /// \brief Return the size of this piece in bytes.
00868   uint64_t getPieceSize() const;
00869 
00870   class iterator;
00871   /// \brief A lightweight wrapper around an element of a DIExpression.
00872   class Operand {
00873     friend class iterator;
00874     DIHeaderFieldIterator I;
00875     Operand() {}
00876     Operand(DIHeaderFieldIterator I) : I(I) {}
00877   public:
00878     /// \brief Operands such as DW_OP_piece have explicit (non-stack) arguments.
00879     /// Argument 0 is the operand itself.
00880     uint64_t getArg(unsigned N) const {
00881       DIHeaderFieldIterator In = I;
00882       std::advance(In, N);
00883       return In.getNumber<uint64_t>();
00884     }
00885     operator uint64_t () const { return I.getNumber<uint64_t>(); }
00886     /// \brief Returns underlying DIHeaderFieldIterator.
00887     const DIHeaderFieldIterator &getBase() const { return I; }
00888     /// \brief Returns the next operand.
00889     Operand getNext() const;
00890   };
00891 
00892   /// \brief An iterator for DIExpression elements.
00893   class iterator : public std::iterator<std::input_iterator_tag, StringRef,
00894                                         unsigned, const Operand*, Operand> {
00895     friend class Operand;
00896     DIHeaderFieldIterator I;
00897     Operand Tmp;
00898     iterator(DIHeaderFieldIterator I) : I(I) {}
00899   public:
00900     iterator() {}
00901     iterator(const DIExpression &Expr) : I(++Expr.header_begin()) {}
00902     const Operand &operator*() { return Tmp = Operand(I); }
00903     const Operand *operator->() { return &(Tmp = Operand(I)); }
00904     iterator &operator++() {
00905       increment();
00906       return *this;
00907     }
00908     iterator operator++(int) {
00909       iterator X(*this);
00910       increment();
00911       return X;
00912     }
00913     bool operator==(const iterator &X) const { return I == X.I; }
00914     bool operator!=(const iterator &X) const { return !(*this == X); }
00915 
00916   private:
00917     void increment() {
00918       switch (**this) {
00919       case dwarf::DW_OP_piece: std::advance(I, 3); break;
00920       case dwarf::DW_OP_plus:  std::advance(I, 2); break;
00921       case dwarf::DW_OP_deref: std::advance(I, 1); break;
00922       default:
00923         llvm_unreachable("unsupported operand");
00924       }
00925     }
00926   };
00927 
00928   iterator begin() const;
00929   iterator end() const;
00930 };
00931 
00932 /// \brief This object holds location information.
00933 ///
00934 /// This object is not associated with any DWARF tag.
00935 class DILocation : public DIDescriptor {
00936 public:
00937   explicit DILocation(const MDNode *N) : DIDescriptor(N) {}
00938 
00939   unsigned getLineNumber() const {
00940     if (auto *L = dyn_cast_or_null<MDLocation>(DbgNode))
00941       return L->getLine();
00942     return 0;
00943   }
00944   unsigned getColumnNumber() const {
00945     if (auto *L = dyn_cast_or_null<MDLocation>(DbgNode))
00946       return L->getColumn();
00947     return 0;
00948   }
00949   DIScope getScope() const {
00950     if (auto *L = dyn_cast_or_null<MDLocation>(DbgNode))
00951       return DIScope(dyn_cast_or_null<MDNode>(L->getScope()));
00952     return DIScope(nullptr);
00953   }
00954   DILocation getOrigLocation() const {
00955     if (auto *L = dyn_cast_or_null<MDLocation>(DbgNode))
00956       return DILocation(dyn_cast_or_null<MDNode>(L->getInlinedAt()));
00957     return DILocation(nullptr);
00958   }
00959   StringRef getFilename() const { return getScope().getFilename(); }
00960   StringRef getDirectory() const { return getScope().getDirectory(); }
00961   bool Verify() const;
00962   bool atSameLineAs(const DILocation &Other) const {
00963     return (getLineNumber() == Other.getLineNumber() &&
00964             getFilename() == Other.getFilename());
00965   }
00966   /// \brief Get the DWAF discriminator.
00967   ///
00968   /// DWARF discriminators are used to distinguish identical file locations for
00969   /// instructions that are on different basic blocks. If two instructions are
00970   /// inside the same lexical block and are in different basic blocks, we
00971   /// create a new lexical block with identical location as the original but
00972   /// with a different discriminator value
00973   /// (lib/Transforms/Util/AddDiscriminators.cpp for details).
00974   unsigned getDiscriminator() const {
00975     // Since discriminators are associated with lexical blocks, make
00976     // sure this location is a lexical block before retrieving its
00977     // value.
00978     return getScope().isLexicalBlockFile()
00979                ? DILexicalBlockFile(
00980                      cast<MDNode>(cast<MDLocation>(DbgNode)->getScope()))
00981                      .getDiscriminator()
00982                : 0;
00983   }
00984 
00985   /// \brief Generate a new discriminator value for this location.
00986   unsigned computeNewDiscriminator(LLVMContext &Ctx);
00987 
00988   /// \brief Return a copy of this location with a different scope.
00989   DILocation copyWithNewScope(LLVMContext &Ctx, DILexicalBlockFile NewScope);
00990 };
00991 
00992 class DIObjCProperty : public DIDescriptor {
00993   friend class DIDescriptor;
00994   void printInternal(raw_ostream &OS) const;
00995 
00996 public:
00997   explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) {}
00998 
00999   StringRef getObjCPropertyName() const { return getHeaderField(1); }
01000   DIFile getFile() const { return getFieldAs<DIFile>(1); }
01001   unsigned getLineNumber() const { return getHeaderFieldAs<unsigned>(2); }
01002 
01003   StringRef getObjCPropertyGetterName() const { return getHeaderField(3); }
01004   StringRef getObjCPropertySetterName() const { return getHeaderField(4); }
01005   unsigned getAttributes() const { return getHeaderFieldAs<unsigned>(5); }
01006   bool isReadOnlyObjCProperty() const {
01007     return (getAttributes() & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
01008   }
01009   bool isReadWriteObjCProperty() const {
01010     return (getAttributes() & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
01011   }
01012   bool isAssignObjCProperty() const {
01013     return (getAttributes() & dwarf::DW_APPLE_PROPERTY_assign) != 0;
01014   }
01015   bool isRetainObjCProperty() const {
01016     return (getAttributes() & dwarf::DW_APPLE_PROPERTY_retain) != 0;
01017   }
01018   bool isCopyObjCProperty() const {
01019     return (getAttributes() & dwarf::DW_APPLE_PROPERTY_copy) != 0;
01020   }
01021   bool isNonAtomicObjCProperty() const {
01022     return (getAttributes() & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
01023   }
01024 
01025   /// \brief Get the type.
01026   ///
01027   /// \note Objective-C doesn't have an ODR, so there is no benefit in storing
01028   /// the type as a DITypeRef here.
01029   DIType getType() const { return getFieldAs<DIType>(2); }
01030 
01031   bool Verify() const;
01032 };
01033 
01034 /// \brief An imported module (C++ using directive or similar).
01035 class DIImportedEntity : public DIDescriptor {
01036   friend class DIDescriptor;
01037   void printInternal(raw_ostream &OS) const;
01038 
01039 public:
01040   explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) {}
01041   DIScope getContext() const { return getFieldAs<DIScope>(1); }
01042   DIScopeRef getEntity() const { return getFieldAs<DIScopeRef>(2); }
01043   unsigned getLineNumber() const { return getHeaderFieldAs<unsigned>(1); }
01044   StringRef getName() const { return getHeaderField(2); }
01045   bool Verify() const;
01046 };
01047 
01048 /// \brief Find subprogram that is enclosing this scope.
01049 DISubprogram getDISubprogram(const MDNode *Scope);
01050 
01051 /// \brief Find debug info for a given function.
01052 /// \returns a valid DISubprogram, if found. Otherwise, it returns an empty
01053 /// DISubprogram.
01054 DISubprogram getDISubprogram(const Function *F);
01055 
01056 /// \brief Find underlying composite type.
01057 DICompositeType getDICompositeType(DIType T);
01058 
01059 /// \brief Create a new inlined variable based on current variable.
01060 ///
01061 /// @param DV            Current Variable.
01062 /// @param InlinedScope  Location at current variable is inlined.
01063 DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
01064                                  LLVMContext &VMContext);
01065 
01066 /// \brief Remove inlined scope from the variable.
01067 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
01068 
01069 /// \brief Generate map by visiting all retained types.
01070 DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes);
01071 
01072 /// \brief Strip debug info in the module if it exists.
01073 ///
01074 /// To do this, we remove all calls to the debugger intrinsics and any named
01075 /// metadata for debugging. We also remove debug locations for instructions.
01076 /// Return true if module is modified.
01077 bool StripDebugInfo(Module &M);
01078 
01079 /// \brief Return Debug Info Metadata Version by checking module flags.
01080 unsigned getDebugMetadataVersionFromModule(const Module &M);
01081 
01082 /// \brief Utility to find all debug info in a module.
01083 ///
01084 /// DebugInfoFinder tries to list all debug info MDNodes used in a module. To
01085 /// list debug info MDNodes used by an instruction, DebugInfoFinder uses
01086 /// processDeclare, processValue and processLocation to handle DbgDeclareInst,
01087 /// DbgValueInst and DbgLoc attached to instructions. processModule will go
01088 /// through all DICompileUnits in llvm.dbg.cu and list debug info MDNodes
01089 /// used by the CUs.
01090 class DebugInfoFinder {
01091 public:
01092   DebugInfoFinder() : TypeMapInitialized(false) {}
01093 
01094   /// \brief Process entire module and collect debug info anchors.
01095   void processModule(const Module &M);
01096 
01097   /// \brief Process DbgDeclareInst.
01098   void processDeclare(const Module &M, const DbgDeclareInst *DDI);
01099   /// \brief Process DbgValueInst.
01100   void processValue(const Module &M, const DbgValueInst *DVI);
01101   /// \brief Process DILocation.
01102   void processLocation(const Module &M, DILocation Loc);
01103 
01104   /// \brief Process DIExpression.
01105   void processExpression(DIExpression Expr);
01106 
01107   /// \brief Clear all lists.
01108   void reset();
01109 
01110 private:
01111   void InitializeTypeMap(const Module &M);
01112 
01113   void processType(DIType DT);
01114   void processSubprogram(DISubprogram SP);
01115   void processScope(DIScope Scope);
01116   bool addCompileUnit(DICompileUnit CU);
01117   bool addGlobalVariable(DIGlobalVariable DIG);
01118   bool addSubprogram(DISubprogram SP);
01119   bool addType(DIType DT);
01120   bool addScope(DIScope Scope);
01121 
01122 public:
01123   typedef SmallVectorImpl<DICompileUnit>::const_iterator compile_unit_iterator;
01124   typedef SmallVectorImpl<DISubprogram>::const_iterator subprogram_iterator;
01125   typedef SmallVectorImpl<DIGlobalVariable>::const_iterator
01126       global_variable_iterator;
01127   typedef SmallVectorImpl<DIType>::const_iterator type_iterator;
01128   typedef SmallVectorImpl<DIScope>::const_iterator scope_iterator;
01129 
01130   iterator_range<compile_unit_iterator> compile_units() const {
01131     return iterator_range<compile_unit_iterator>(CUs.begin(), CUs.end());
01132   }
01133 
01134   iterator_range<subprogram_iterator> subprograms() const {
01135     return iterator_range<subprogram_iterator>(SPs.begin(), SPs.end());
01136   }
01137 
01138   iterator_range<global_variable_iterator> global_variables() const {
01139     return iterator_range<global_variable_iterator>(GVs.begin(), GVs.end());
01140   }
01141 
01142   iterator_range<type_iterator> types() const {
01143     return iterator_range<type_iterator>(TYs.begin(), TYs.end());
01144   }
01145 
01146   iterator_range<scope_iterator> scopes() const {
01147     return iterator_range<scope_iterator>(Scopes.begin(), Scopes.end());
01148   }
01149 
01150   unsigned compile_unit_count() const { return CUs.size(); }
01151   unsigned global_variable_count() const { return GVs.size(); }
01152   unsigned subprogram_count() const { return SPs.size(); }
01153   unsigned type_count() const { return TYs.size(); }
01154   unsigned scope_count() const { return Scopes.size(); }
01155 
01156 private:
01157   SmallVector<DICompileUnit, 8> CUs;
01158   SmallVector<DISubprogram, 8> SPs;
01159   SmallVector<DIGlobalVariable, 8> GVs;
01160   SmallVector<DIType, 8> TYs;
01161   SmallVector<DIScope, 8> Scopes;
01162   SmallPtrSet<MDNode *, 64> NodesSeen;
01163   DITypeIdentifierMap TypeIdentifierMap;
01164 
01165   /// \brief Specify if TypeIdentifierMap is initialized.
01166   bool TypeMapInitialized;
01167 };
01168 
01169 DenseMap<const Function *, DISubprogram> makeSubprogramMap(const Module &M);
01170 
01171 } // end namespace llvm
01172 
01173 #endif