//===--- DebugInfo.cpp - Debug Information Helper Classes -----------------===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////// This file implements the helper classes used to build and interpret debug// information in LLVM IR form.////===----------------------------------------------------------------------===//#include"llvm/Analysis/DebugInfo.h"#include"llvm/Constants.h"#include"llvm/DerivedTypes.h"#include"llvm/Intrinsics.h"#include"llvm/IntrinsicInst.h"#include"llvm/Instructions.h"#include"llvm/LLVMContext.h"#include"llvm/Module.h"#include"llvm/Analysis/ValueTracking.h"#include"llvm/ADT/SmallPtrSet.h"#include"llvm/Support/Dwarf.h"#include"llvm/Support/DebugLoc.h"#include"llvm/Support/raw_ostream.h"usingnamespacellvm;usingnamespacellvm::dwarf;//===----------------------------------------------------------------------===//// DIDescriptor//===----------------------------------------------------------------------===///// ValidDebugInfo - Return true if V represents valid debug info value./// FIXME : Add DIDescriptor.isValid()boolDIDescriptor::ValidDebugInfo(MDNode*N,CodeGenOpt::LevelOptLevel){if(!N)returnfalse;DIDescriptorDI(N);// Check current version. Allow Version6 for now.unsignedVersion=DI.getVersion();if(Version!=LLVMDebugVersion&&Version!=LLVMDebugVersion6)returnfalse;unsignedTag=DI.getTag();switch(Tag){caseDW_TAG_variable:assert(DIVariable(N).Verify()&&"Invalid DebugInfo value");break;caseDW_TAG_compile_unit:assert(DICompileUnit(N).Verify()&&"Invalid DebugInfo value");break;caseDW_TAG_subprogram:assert(DISubprogram(N).Verify()&&"Invalid DebugInfo value");break;caseDW_TAG_lexical_block:// FIXME: This interfers with the quality of generated code during// optimization.if(OptLevel!=CodeGenOpt::None)returnfalse;// FALLTHROUGHdefault:break;}returntrue;}DIDescriptor::DIDescriptor(MDNode*N,unsignedRequiredTag){DbgNode=N;// If this is non-null, check to see if the Tag matches. If not, set to null.if(N&&getTag()!=RequiredTag){DbgNode=0;}}conststd::string&DIDescriptor::getStringField(unsignedElt,std::string&Result)const{Result.clear();if(DbgNode==0)returnResult;if(Elt<