clang API Documentation

CGDebugInfo.h
Go to the documentation of this file.
00001 //===--- CGDebugInfo.h - DebugInfo for LLVM CodeGen -------------*- 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 is the source-level debug info generator for llvm translation.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
00015 #define LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
00016 
00017 #include "CGBuilder.h"
00018 #include "clang/AST/Expr.h"
00019 #include "clang/AST/Type.h"
00020 #include "clang/Basic/SourceLocation.h"
00021 #include "clang/Frontend/CodeGenOptions.h"
00022 #include "llvm/ADT/DenseMap.h"
00023 #include "llvm/IR/DIBuilder.h"
00024 #include "llvm/IR/DebugInfo.h"
00025 #include "llvm/IR/ValueHandle.h"
00026 #include "llvm/Support/Allocator.h"
00027 
00028 namespace llvm {
00029   class MDNode;
00030 }
00031 
00032 namespace clang {
00033   class CXXMethodDecl;
00034   class VarDecl;
00035   class ObjCInterfaceDecl;
00036   class ObjCIvarDecl;
00037   class ClassTemplateSpecializationDecl;
00038   class GlobalDecl;
00039   class UsingDecl;
00040 
00041 namespace CodeGen {
00042   class CodeGenModule;
00043   class CodeGenFunction;
00044   class CGBlockInfo;
00045 
00046 /// CGDebugInfo - This class gathers all debug information during compilation
00047 /// and is responsible for emitting to llvm globals or pass directly to
00048 /// the backend.
00049 class CGDebugInfo {
00050   friend class ArtificialLocation;
00051   friend class SaveAndRestoreLocation;
00052   CodeGenModule &CGM;
00053   const CodeGenOptions::DebugInfoKind DebugKind;
00054   llvm::DIBuilder DBuilder;
00055   llvm::DICompileUnit TheCU;
00056   SourceLocation CurLoc, PrevLoc;
00057   llvm::DIType VTablePtrType;
00058   llvm::DIType ClassTy;
00059   llvm::DICompositeType ObjTy;
00060   llvm::DIType SelTy;
00061   llvm::DIType OCLImage1dDITy, OCLImage1dArrayDITy, OCLImage1dBufferDITy;
00062   llvm::DIType OCLImage2dDITy, OCLImage2dArrayDITy;
00063   llvm::DIType OCLImage3dDITy;
00064   llvm::DIType OCLEventDITy;
00065   llvm::DIType BlockLiteralGeneric;
00066 
00067   /// TypeCache - Cache of previously constructed Types.
00068   llvm::DenseMap<const void *, llvm::WeakVH> TypeCache;
00069 
00070   struct ObjCInterfaceCacheEntry {
00071     const ObjCInterfaceType *Type;
00072     llvm::DIType Decl;
00073     llvm::DIFile Unit;
00074     ObjCInterfaceCacheEntry(const ObjCInterfaceType *Type, llvm::DIType Decl,
00075                             llvm::DIFile Unit)
00076         : Type(Type), Decl(Decl), Unit(Unit) {}
00077   };
00078 
00079   /// ObjCInterfaceCache - Cache of previously constructed interfaces
00080   /// which may change.
00081   llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
00082 
00083   /// RetainedTypes - list of interfaces we want to keep even if orphaned.
00084   std::vector<void *> RetainedTypes;
00085 
00086   /// ReplaceMap - Cache of forward declared types to RAUW at the end of
00087   /// compilation.
00088   std::vector<std::pair<const TagType *, llvm::WeakVH>> ReplaceMap;
00089 
00090   /// \brief Cache of replaceable forward declarartions (functions and
00091   /// variables) to RAUW at the end of compilation.
00092   std::vector<std::pair<const DeclaratorDecl *, llvm::WeakVH>> FwdDeclReplaceMap;
00093 
00094   // LexicalBlockStack - Keep track of our current nested lexical block.
00095   std::vector<llvm::TrackingVH<llvm::MDNode> > LexicalBlockStack;
00096   llvm::DenseMap<const Decl *, llvm::WeakVH> RegionMap;
00097   // FnBeginRegionCount - Keep track of LexicalBlockStack counter at the
00098   // beginning of a function. This is used to pop unbalanced regions at
00099   // the end of a function.
00100   std::vector<unsigned> FnBeginRegionCount;
00101 
00102   /// DebugInfoNames - This is a storage for names that are
00103   /// constructed on demand. For example, C++ destructors, C++ operators etc..
00104   llvm::BumpPtrAllocator DebugInfoNames;
00105   StringRef CWDName;
00106 
00107   llvm::DenseMap<const char *, llvm::WeakVH> DIFileCache;
00108   llvm::DenseMap<const FunctionDecl *, llvm::WeakVH> SPCache;
00109   /// \brief Cache declarations relevant to DW_TAG_imported_declarations (C++
00110   /// using declarations) that aren't covered by other more specific caches.
00111   llvm::DenseMap<const Decl *, llvm::WeakVH> DeclCache;
00112   llvm::DenseMap<const NamespaceDecl *, llvm::WeakVH> NameSpaceCache;
00113   llvm::DenseMap<const NamespaceAliasDecl *, llvm::WeakVH> NamespaceAliasCache;
00114   llvm::DenseMap<const Decl *, llvm::WeakVH> StaticDataMemberCache;
00115 
00116   /// Helper functions for getOrCreateType.
00117   unsigned Checksum(const ObjCInterfaceDecl *InterfaceDecl);
00118   llvm::DIType CreateType(const BuiltinType *Ty);
00119   llvm::DIType CreateType(const ComplexType *Ty);
00120   llvm::DIType CreateQualifiedType(QualType Ty, llvm::DIFile Fg);
00121   llvm::DIType CreateType(const TypedefType *Ty, llvm::DIFile Fg);
00122   llvm::DIType CreateType(const TemplateSpecializationType *Ty, llvm::DIFile Fg);
00123   llvm::DIType CreateType(const ObjCObjectPointerType *Ty,
00124                           llvm::DIFile F);
00125   llvm::DIType CreateType(const PointerType *Ty, llvm::DIFile F);
00126   llvm::DIType CreateType(const BlockPointerType *Ty, llvm::DIFile F);
00127   llvm::DIType CreateType(const FunctionType *Ty, llvm::DIFile F);
00128   llvm::DIType CreateType(const RecordType *Tyg);
00129   llvm::DIType CreateTypeDefinition(const RecordType *Ty);
00130   llvm::DICompositeType CreateLimitedType(const RecordType *Ty);
00131   void CollectContainingType(const CXXRecordDecl *RD, llvm::DICompositeType CT);
00132   llvm::DIType CreateType(const ObjCInterfaceType *Ty, llvm::DIFile F);
00133   llvm::DIType CreateTypeDefinition(const ObjCInterfaceType *Ty, llvm::DIFile F);
00134   llvm::DIType CreateType(const ObjCObjectType *Ty, llvm::DIFile F);
00135   llvm::DIType CreateType(const VectorType *Ty, llvm::DIFile F);
00136   llvm::DIType CreateType(const ArrayType *Ty, llvm::DIFile F);
00137   llvm::DIType CreateType(const LValueReferenceType *Ty, llvm::DIFile F);
00138   llvm::DIType CreateType(const RValueReferenceType *Ty, llvm::DIFile Unit);
00139   llvm::DIType CreateType(const MemberPointerType *Ty, llvm::DIFile F);
00140   llvm::DIType CreateType(const AtomicType *Ty, llvm::DIFile F);
00141   llvm::DIType CreateEnumType(const EnumType *Ty);
00142   llvm::DIType CreateTypeDefinition(const EnumType *Ty);
00143   llvm::DIType CreateSelfType(const QualType &QualTy, llvm::DIType Ty);
00144   llvm::DIType getTypeOrNull(const QualType);
00145   llvm::DICompositeType getOrCreateMethodType(const CXXMethodDecl *Method,
00146                                               llvm::DIFile F);
00147   llvm::DICompositeType getOrCreateInstanceMethodType(
00148       QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile Unit);
00149   llvm::DICompositeType getOrCreateFunctionType(const Decl *D, QualType FnType,
00150                                                 llvm::DIFile F);
00151   llvm::DIType getOrCreateVTablePtrType(llvm::DIFile F);
00152   llvm::DINameSpace getOrCreateNameSpace(const NamespaceDecl *N);
00153   llvm::DIType getOrCreateTypeDeclaration(QualType PointeeTy, llvm::DIFile F);
00154   llvm::DIType CreatePointerLikeType(llvm::dwarf::Tag Tag,
00155                                      const Type *Ty, QualType PointeeTy,
00156                                      llvm::DIFile F);
00157 
00158   llvm::Value *getCachedInterfaceTypeOrNull(const QualType Ty);
00159   llvm::DIType getOrCreateStructPtrType(StringRef Name, llvm::DIType &Cache);
00160 
00161   llvm::DISubprogram CreateCXXMemberFunction(const CXXMethodDecl *Method,
00162                                              llvm::DIFile F,
00163                                              llvm::DIType RecordTy);
00164 
00165   void CollectCXXMemberFunctions(const CXXRecordDecl *Decl,
00166                                  llvm::DIFile F,
00167                                  SmallVectorImpl<llvm::Value *> &E,
00168                                  llvm::DIType T);
00169 
00170   void CollectCXXBases(const CXXRecordDecl *Decl,
00171                        llvm::DIFile F,
00172                        SmallVectorImpl<llvm::Value *> &EltTys,
00173                        llvm::DIType RecordTy);
00174 
00175   llvm::DIArray
00176   CollectTemplateParams(const TemplateParameterList *TPList,
00177                         ArrayRef<TemplateArgument> TAList,
00178                         llvm::DIFile Unit);
00179   llvm::DIArray
00180   CollectFunctionTemplateParams(const FunctionDecl *FD, llvm::DIFile Unit);
00181   llvm::DIArray
00182   CollectCXXTemplateParams(const ClassTemplateSpecializationDecl *TS,
00183                            llvm::DIFile F);
00184 
00185   llvm::DIType createFieldType(StringRef name, QualType type,
00186                                uint64_t sizeInBitsOverride, SourceLocation loc,
00187                                AccessSpecifier AS,
00188                                uint64_t offsetInBits,
00189                                llvm::DIFile tunit,
00190                                llvm::DIScope scope,
00191                                const RecordDecl* RD = nullptr);
00192 
00193   // Helpers for collecting fields of a record.
00194   void CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl,
00195                                  SmallVectorImpl<llvm::Value *> &E,
00196                                  llvm::DIType RecordTy);
00197   llvm::DIDerivedType CreateRecordStaticField(const VarDecl *Var,
00198                                               llvm::DIType RecordTy,
00199                                               const RecordDecl* RD);
00200   void CollectRecordNormalField(const FieldDecl *Field, uint64_t OffsetInBits,
00201                                 llvm::DIFile F,
00202                                 SmallVectorImpl<llvm::Value *> &E,
00203                                 llvm::DIType RecordTy,
00204                                 const RecordDecl* RD);
00205   void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile F,
00206                            SmallVectorImpl<llvm::Value *> &E,
00207                            llvm::DICompositeType RecordTy);
00208 
00209   void CollectVTableInfo(const CXXRecordDecl *Decl,
00210                          llvm::DIFile F,
00211                          SmallVectorImpl<llvm::Value *> &EltTys);
00212 
00213   // CreateLexicalBlock - Create a new lexical block node and push it on
00214   // the stack.
00215   void CreateLexicalBlock(SourceLocation Loc);
00216 
00217 public:
00218   CGDebugInfo(CodeGenModule &CGM);
00219   ~CGDebugInfo();
00220 
00221   void finalize();
00222 
00223   /// setLocation - Update the current source location. If \arg loc is
00224   /// invalid it is ignored.
00225   void setLocation(SourceLocation Loc);
00226 
00227   /// getLocation - Return the current source location.
00228   SourceLocation getLocation() const { return CurLoc; }
00229 
00230   /// EmitLocation - Emit metadata to indicate a change in line/column
00231   /// information in the source file.
00232   /// \param ForceColumnInfo  Assume DebugColumnInfo option is true.
00233   void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc,
00234                     bool ForceColumnInfo = false);
00235 
00236   /// EmitFunctionStart - Emit a call to llvm.dbg.function.start to indicate
00237   /// start of a new function.
00238   /// \param Loc       The location of the function header.
00239   /// \param ScopeLoc  The location of the function body.
00240   void EmitFunctionStart(GlobalDecl GD,
00241                          SourceLocation Loc, SourceLocation ScopeLoc,
00242                          QualType FnType, llvm::Function *Fn,
00243                          CGBuilderTy &Builder);
00244 
00245   /// EmitFunctionEnd - Constructs the debug code for exiting a function.
00246   void EmitFunctionEnd(CGBuilderTy &Builder);
00247 
00248   /// EmitLexicalBlockStart - Emit metadata to indicate the beginning of a
00249   /// new lexical block and push the block onto the stack.
00250   void EmitLexicalBlockStart(CGBuilderTy &Builder, SourceLocation Loc);
00251 
00252   /// EmitLexicalBlockEnd - Emit metadata to indicate the end of a new lexical
00253   /// block and pop the current block.
00254   void EmitLexicalBlockEnd(CGBuilderTy &Builder, SourceLocation Loc);
00255 
00256   /// EmitDeclareOfAutoVariable - Emit call to llvm.dbg.declare for an automatic
00257   /// variable declaration.
00258   void EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI,
00259                                  CGBuilderTy &Builder);
00260 
00261   /// EmitDeclareOfBlockDeclRefVariable - Emit call to llvm.dbg.declare for an
00262   /// imported variable declaration in a block.
00263   void EmitDeclareOfBlockDeclRefVariable(const VarDecl *variable,
00264                                          llvm::Value *storage,
00265                                          CGBuilderTy &Builder,
00266                                          const CGBlockInfo &blockInfo);
00267 
00268   /// EmitDeclareOfArgVariable - Emit call to llvm.dbg.declare for an argument
00269   /// variable declaration.
00270   void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI,
00271                                 unsigned ArgNo, CGBuilderTy &Builder);
00272 
00273   /// EmitDeclareOfBlockLiteralArgVariable - Emit call to
00274   /// llvm.dbg.declare for the block-literal argument to a block
00275   /// invocation function.
00276   void EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
00277                                             llvm::Value *Arg, unsigned ArgNo,
00278                                             llvm::Value *LocalAddr,
00279                                             CGBuilderTy &Builder);
00280 
00281   /// EmitGlobalVariable - Emit information about a global variable.
00282   void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
00283 
00284   /// EmitGlobalVariable - Emit global variable's debug info.
00285   void EmitGlobalVariable(const ValueDecl *VD, llvm::Constant *Init);
00286 
00287   /// \brief - Emit C++ using directive.
00288   void EmitUsingDirective(const UsingDirectiveDecl &UD);
00289 
00290   /// EmitExplicitCastType - Emit the type explicitly casted to.
00291   void EmitExplicitCastType(QualType Ty);
00292 
00293   /// \brief - Emit C++ using declaration.
00294   void EmitUsingDecl(const UsingDecl &UD);
00295 
00296   /// \brief - Emit C++ namespace alias.
00297   llvm::DIImportedEntity EmitNamespaceAlias(const NamespaceAliasDecl &NA);
00298 
00299   /// getOrCreateRecordType - Emit record type's standalone debug info.
00300   llvm::DIType getOrCreateRecordType(QualType Ty, SourceLocation L);
00301 
00302   /// getOrCreateInterfaceType - Emit an objective c interface type standalone
00303   /// debug info.
00304   llvm::DIType getOrCreateInterfaceType(QualType Ty,
00305                                         SourceLocation Loc);
00306 
00307   void completeType(const EnumDecl *ED);
00308   void completeType(const RecordDecl *RD);
00309   void completeRequiredType(const RecordDecl *RD);
00310   void completeClassData(const RecordDecl *RD);
00311 
00312   void completeTemplateDefinition(const ClassTemplateSpecializationDecl &SD);
00313 
00314 private:
00315   /// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.
00316   /// Tag accepts custom types DW_TAG_arg_variable and DW_TAG_auto_variable,
00317   /// otherwise would be of type llvm::dwarf::Tag.
00318   void EmitDeclare(const VarDecl *decl, llvm::dwarf::LLVMConstants Tag,
00319                    llvm::Value *AI, unsigned ArgNo, CGBuilderTy &Builder);
00320 
00321   // EmitTypeForVarWithBlocksAttr - Build up structure info for the byref.
00322   // See BuildByRefType.
00323   llvm::DIType EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
00324                                             uint64_t *OffSet);
00325 
00326   /// getContextDescriptor - Get context info for the decl.
00327   llvm::DIScope getContextDescriptor(const Decl *Decl);
00328 
00329   llvm::DIScope getCurrentContextDescriptor(const Decl *Decl);
00330 
00331   /// \brief Create a forward decl for a RecordType in a given context.
00332   llvm::DICompositeType getOrCreateRecordFwdDecl(const RecordType *,
00333                                                  llvm::DIDescriptor);
00334 
00335   /// createContextChain - Create a set of decls for the context chain.
00336   llvm::DIDescriptor createContextChain(const Decl *Decl);
00337 
00338   /// getCurrentDirname - Return current directory name.
00339   StringRef getCurrentDirname();
00340 
00341   /// CreateCompileUnit - Create new compile unit.
00342   void CreateCompileUnit();
00343 
00344   /// getOrCreateFile - Get the file debug info descriptor for the input
00345   /// location.
00346   llvm::DIFile getOrCreateFile(SourceLocation Loc);
00347 
00348   /// getOrCreateMainFile - Get the file info for main compile unit.
00349   llvm::DIFile getOrCreateMainFile();
00350 
00351   /// getOrCreateType - Get the type from the cache or create a new type if
00352   /// necessary.
00353   llvm::DIType getOrCreateType(QualType Ty, llvm::DIFile Fg);
00354 
00355   /// getOrCreateLimitedType - Get the type from the cache or create a new
00356   /// partial type if necessary.
00357   llvm::DIType getOrCreateLimitedType(const RecordType *Ty, llvm::DIFile F);
00358 
00359   /// CreateTypeNode - Create type metadata for a source language type.
00360   llvm::DIType CreateTypeNode(QualType Ty, llvm::DIFile Fg);
00361 
00362   /// getObjCInterfaceDecl - return the underlying ObjCInterfaceDecl
00363   /// if Ty is an ObjCInterface or a pointer to one.
00364   ObjCInterfaceDecl* getObjCInterfaceDecl(QualType Ty);
00365 
00366   /// CreateMemberType - Create new member and increase Offset by FType's size.
00367   llvm::DIType CreateMemberType(llvm::DIFile Unit, QualType FType,
00368                                 StringRef Name, uint64_t *Offset);
00369 
00370   /// \brief Retrieve the DIDescriptor, if any, for the canonical form of this
00371   /// declaration.
00372   llvm::DIDescriptor getDeclarationOrDefinition(const Decl *D);
00373 
00374   /// getFunctionDeclaration - Return debug info descriptor to describe method
00375   /// declaration for the given method definition.
00376   llvm::DISubprogram getFunctionDeclaration(const Decl *D);
00377 
00378   /// Return debug info descriptor to describe in-class static data member
00379   /// declaration for the given out-of-class definition.
00380   llvm::DIDerivedType
00381   getOrCreateStaticDataMemberDeclarationOrNull(const VarDecl *D);
00382 
00383   /// \brief Create a DISubprogram describing the forward
00384   /// decalration represented in the given FunctionDecl.
00385   llvm::DISubprogram getFunctionForwardDeclaration(const FunctionDecl *FD);
00386 
00387   /// \brief Create a DIGlobalVariable describing the forward
00388   /// decalration represented in the given VarDecl.
00389   llvm::DIGlobalVariable getGlobalVariableForwardDeclaration(const VarDecl *VD);
00390 
00391   /// Return a global variable that represents one of the collection of
00392   /// global variables created for an anonmyous union.
00393   llvm::DIGlobalVariable
00394   CollectAnonRecordDecls(const RecordDecl *RD, llvm::DIFile Unit, unsigned LineNo,
00395                          StringRef LinkageName, llvm::GlobalVariable *Var,
00396                          llvm::DIDescriptor DContext);
00397 
00398   /// getFunctionName - Get function name for the given FunctionDecl. If the
00399   /// name is constructed on demand (e.g. C++ destructor) then the name
00400   /// is stored on the side.
00401   StringRef getFunctionName(const FunctionDecl *FD);
00402 
00403   /// getObjCMethodName - Returns the unmangled name of an Objective-C method.
00404   /// This is the display name for the debugging info.
00405   StringRef getObjCMethodName(const ObjCMethodDecl *FD);
00406 
00407   /// getSelectorName - Return selector name. This is used for debugging
00408   /// info.
00409   StringRef getSelectorName(Selector S);
00410 
00411   /// getClassName - Get class name including template argument list.
00412   StringRef getClassName(const RecordDecl *RD);
00413 
00414   /// getVTableName - Get vtable name for the given Class.
00415   StringRef getVTableName(const CXXRecordDecl *Decl);
00416 
00417   /// getLineNumber - Get line number for the location. If location is invalid
00418   /// then use current location.
00419   unsigned getLineNumber(SourceLocation Loc);
00420 
00421   /// getColumnNumber - Get column number for the location. If location is
00422   /// invalid then use current location.
00423   /// \param Force  Assume DebugColumnInfo option is true.
00424   unsigned getColumnNumber(SourceLocation Loc, bool Force=false);
00425 
00426   /// \brief Collect various properties of a FunctionDecl.
00427   /// \param GD  A GlobalDecl whose getDecl() must return a FunctionDecl.
00428   void collectFunctionDeclProps(GlobalDecl GD,
00429                                 llvm::DIFile Unit,
00430                                 StringRef &Name, StringRef &LinkageName,
00431                                 llvm::DIDescriptor &FDContext,
00432                                 llvm::DIArray &TParamsArray,
00433                                 unsigned &Flags);
00434 
00435   /// \brief Collect various properties of a VarDecl.
00436   void collectVarDeclProps(const VarDecl *VD, llvm::DIFile &Unit,
00437                            unsigned &LineNo, QualType &T,
00438                            StringRef &Name, StringRef &LinkageName,
00439                            llvm::DIDescriptor &VDContext);
00440 
00441   /// internString - Allocate a copy of \p A using the DebugInfoNames allocator
00442   /// and return a reference to it. If multiple arguments are given the strings
00443   /// are concatenated.
00444   StringRef internString(StringRef A, StringRef B = StringRef()) {
00445     char *Data = DebugInfoNames.Allocate<char>(A.size() + B.size());
00446     std::memcpy(Data, A.data(), A.size());
00447     std::memcpy(Data + A.size(), B.data(), B.size());
00448     return StringRef(Data, A.size() + B.size());
00449   }
00450 };
00451 
00452 /// SaveAndRestoreLocation - An RAII object saves the current location
00453 /// and automatically restores it to the original value.
00454 class SaveAndRestoreLocation {
00455 protected:
00456   SourceLocation SavedLoc;
00457   CGDebugInfo *DI;
00458   CGBuilderTy &Builder;
00459 public:
00460   SaveAndRestoreLocation(CodeGenFunction &CGF, CGBuilderTy &B);
00461   /// Autorestore everything back to normal.
00462   ~SaveAndRestoreLocation();
00463 };
00464 
00465 /// NoLocation - An RAII object that temporarily disables debug
00466 /// locations. This is useful for emitting instructions that should be
00467 /// counted towards the function prologue.
00468 class NoLocation : public SaveAndRestoreLocation {
00469 public:
00470   NoLocation(CodeGenFunction &CGF, CGBuilderTy &B);
00471   /// Autorestore everything back to normal.
00472   ~NoLocation();
00473 };
00474 
00475 /// ArtificialLocation - An RAII object that temporarily switches to
00476 /// an artificial debug location that has a valid scope, but no line
00477 /// information. This is useful when emitting compiler-generated
00478 /// helper functions that have no source location associated with
00479 /// them. The DWARF specification allows the compiler to use the
00480 /// special line number 0 to indicate code that can not be attributed
00481 /// to any source location.
00482 ///
00483 /// This is necessary because passing an empty SourceLocation to
00484 /// CGDebugInfo::setLocation() will result in the last valid location
00485 /// being reused.
00486 class ArtificialLocation : public SaveAndRestoreLocation {
00487 public:
00488   ArtificialLocation(CodeGenFunction &CGF, CGBuilderTy &B);
00489 
00490   /// Set the current location to line 0, but within the current scope
00491   /// (= the top of the LexicalBlockStack).
00492   void Emit();
00493 
00494   /// Autorestore everything back to normal.
00495   ~ArtificialLocation();
00496 };
00497 
00498 
00499 } // namespace CodeGen
00500 } // namespace clang
00501 
00502 
00503 #endif