//===--- CGDebugInfo.cpp - Emit Debug Information for a Module ------------===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////// This coordinates the debug information generation while generating code.////===----------------------------------------------------------------------===//#include"CGDebugInfo.h"#include"CodeGenFunction.h"#include"CodeGenModule.h"#include"clang/AST/ASTContext.h"#include"clang/AST/DeclObjC.h"#include"clang/AST/Expr.h"#include"clang/AST/RecordLayout.h"#include"clang/Basic/SourceManager.h"#include"clang/Basic/FileManager.h"#include"clang/Basic/Version.h"#include"clang/Frontend/CompileOptions.h"#include"llvm/Constants.h"#include"llvm/DerivedTypes.h"#include"llvm/Instructions.h"#include"llvm/Intrinsics.h"#include"llvm/Module.h"#include"llvm/ADT/StringExtras.h"#include"llvm/ADT/SmallVector.h"#include"llvm/Support/Dwarf.h"#include"llvm/System/Path.h"#include"llvm/Target/TargetMachine.h"usingnamespaceclang;usingnamespaceclang::CodeGen;CGDebugInfo::CGDebugInfo(CodeGenModule*m):M(m),isMainCompileUnitCreated(false),DebugFactory(M->getModule()),BlockLiteralGenericSet(false){}CGDebugInfo::~CGDebugInfo(){assert(RegionStack.empty()&&"Region stack mismatch, stack not empty!");}voidCGDebugInfo::setLocation(SourceLocationLoc){if(Loc.isValid())CurLoc=M->getContext().getSourceManager().getInstantiationLoc(Loc);}/// getOrCreateCompileUnit - Get the compile unit from the cache or create a new/// one if necessary. This returns null for invalid source locations.llvm::DICompileUnitCGDebugInfo::getOrCreateCompileUnit(SourceLocationLoc){// Get source file information.constchar*FileName="<unknown>";SourceManager&SM=M->getContext().getSourceManager();unsignedFID=0;if(Loc.isValid()){PresumedLocPLoc=SM.getPresumedLoc(Loc);FileName=PLoc.getFilename();FID=PLoc.getIncludeLoc().getRawEncoding();}// See if this compile unit has been used before.llvm::DICompileUnit&Unit=CompileUnitCache[FID];if(!Unit.isNull())return