LLVM API Documentation
00001 //===--- DebugInfo.cpp - Debug Information Helper Classes -----------------===// 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 implements the helper classes used to build and interpret debug 00011 // information in LLVM IR form. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #include "llvm/DebugInfo.h" 00016 #include "llvm/ADT/STLExtras.h" 00017 #include "llvm/ADT/SmallPtrSet.h" 00018 #include "llvm/ADT/SmallString.h" 00019 #include "llvm/Analysis/ValueTracking.h" 00020 #include "llvm/IR/Constants.h" 00021 #include "llvm/IR/DerivedTypes.h" 00022 #include "llvm/IR/Instructions.h" 00023 #include "llvm/IR/IntrinsicInst.h" 00024 #include "llvm/IR/Intrinsics.h" 00025 #include "llvm/IR/Module.h" 00026 #include "llvm/Support/Debug.h" 00027 #include "llvm/Support/Dwarf.h" 00028 #include "llvm/Support/ValueHandle.h" 00029 #include "llvm/Support/raw_ostream.h" 00030 using namespace llvm; 00031 using namespace llvm::dwarf; 00032 00033 //===----------------------------------------------------------------------===// 00034 // DIDescriptor 00035 //===----------------------------------------------------------------------===// 00036 00037 DIDescriptor::DIDescriptor(const DIFile F) : DbgNode(F.DbgNode) { 00038 } 00039 00040 DIDescriptor::DIDescriptor(const DISubprogram F) : DbgNode(F.DbgNode) { 00041 } 00042 00043 DIDescriptor::DIDescriptor(const DILexicalBlockFile F) : DbgNode(F.DbgNode) { 00044 } 00045 00046 DIDescriptor::DIDescriptor(const DILexicalBlock F) : DbgNode(F.DbgNode) { 00047 } 00048 00049 DIDescriptor::DIDescriptor(const DIVariable F) : DbgNode(F.DbgNode) { 00050 } 00051 00052 DIDescriptor::DIDescriptor(const DIType F) : DbgNode(F.DbgNode) { 00053 } 00054 00055 bool DIDescriptor::Verify() const { 00056 return DbgNode && 00057 (DIDerivedType(DbgNode).Verify() || 00058 DICompositeType(DbgNode).Verify() || DIBasicType(DbgNode).Verify() || 00059 DIVariable(DbgNode).Verify() || DISubprogram(DbgNode).Verify() || 00060 DIGlobalVariable(DbgNode).Verify() || DIFile(DbgNode).Verify() || 00061 DICompileUnit(DbgNode).Verify() || DINameSpace(DbgNode).Verify() || 00062 DILexicalBlock(DbgNode).Verify() || 00063 DILexicalBlockFile(DbgNode).Verify() || 00064 DISubrange(DbgNode).Verify() || DIEnumerator(DbgNode).Verify() || 00065 DIObjCProperty(DbgNode).Verify() || 00066 DITemplateTypeParameter(DbgNode).Verify() || 00067 DITemplateValueParameter(DbgNode).Verify() || 00068 DIImportedEntity(DbgNode).Verify()); 00069 } 00070 00071 static Value *getField(const MDNode *DbgNode, unsigned Elt) { 00072 if (DbgNode == 0 || Elt >= DbgNode->getNumOperands()) 00073 return 0; 00074 return DbgNode->getOperand(Elt); 00075 } 00076 00077 static const MDNode *getNodeField(const MDNode *DbgNode, unsigned Elt) { 00078 if (const MDNode *R = dyn_cast_or_null<MDNode>(getField(DbgNode, Elt))) 00079 return R; 00080 return 0; 00081 } 00082 00083 static StringRef getStringField(const MDNode *DbgNode, unsigned Elt) { 00084 if (MDString *MDS = dyn_cast_or_null<MDString>(getField(DbgNode, Elt))) 00085 return MDS->getString(); 00086 return StringRef(); 00087 } 00088 00089 StringRef DIDescriptor::getStringField(unsigned Elt) const { 00090 return ::getStringField(DbgNode, Elt); 00091 } 00092 00093 uint64_t DIDescriptor::getUInt64Field(unsigned Elt) const { 00094 if (DbgNode == 0) 00095 return 0; 00096 00097 if (Elt < DbgNode->getNumOperands()) 00098 if (ConstantInt *CI 00099 = dyn_cast_or_null<ConstantInt>(DbgNode->getOperand(Elt))) 00100 return CI->getZExtValue(); 00101 00102 return 0; 00103 } 00104 00105 int64_t DIDescriptor::getInt64Field(unsigned Elt) const { 00106 if (DbgNode == 0) 00107 return 0; 00108 00109 if (Elt < DbgNode->getNumOperands()) 00110 if (ConstantInt *CI 00111 = dyn_cast_or_null<ConstantInt>(DbgNode->getOperand(Elt))) 00112 return CI->getSExtValue(); 00113 00114 return 0; 00115 } 00116 00117 DIDescriptor DIDescriptor::getDescriptorField(unsigned Elt) const { 00118 if (DbgNode == 0) 00119 return DIDescriptor(); 00120 00121 if (Elt < DbgNode->getNumOperands()) 00122 return 00123 DIDescriptor(dyn_cast_or_null<const MDNode>(DbgNode->getOperand(Elt))); 00124 return DIDescriptor(); 00125 } 00126 00127 GlobalVariable *DIDescriptor::getGlobalVariableField(unsigned Elt) const { 00128 if (DbgNode == 0) 00129 return 0; 00130 00131 if (Elt < DbgNode->getNumOperands()) 00132 return dyn_cast_or_null<GlobalVariable>(DbgNode->getOperand(Elt)); 00133 return 0; 00134 } 00135 00136 Constant *DIDescriptor::getConstantField(unsigned Elt) const { 00137 if (DbgNode == 0) 00138 return 0; 00139 00140 if (Elt < DbgNode->getNumOperands()) 00141 return dyn_cast_or_null<Constant>(DbgNode->getOperand(Elt)); 00142 return 0; 00143 } 00144 00145 Function *DIDescriptor::getFunctionField(unsigned Elt) const { 00146 if (DbgNode == 0) 00147 return 0; 00148 00149 if (Elt < DbgNode->getNumOperands()) 00150 return dyn_cast_or_null<Function>(DbgNode->getOperand(Elt)); 00151 return 0; 00152 } 00153 00154 void DIDescriptor::replaceFunctionField(unsigned Elt, Function *F) { 00155 if (DbgNode == 0) 00156 return; 00157 00158 if (Elt < DbgNode->getNumOperands()) { 00159 MDNode *Node = const_cast<MDNode*>(DbgNode); 00160 Node->replaceOperandWith(Elt, F); 00161 } 00162 } 00163 00164 unsigned DIVariable::getNumAddrElements() const { 00165 return DbgNode->getNumOperands()-8; 00166 } 00167 00168 /// getInlinedAt - If this variable is inlined then return inline location. 00169 MDNode *DIVariable::getInlinedAt() const { 00170 return dyn_cast_or_null<MDNode>(DbgNode->getOperand(7)); 00171 } 00172 00173 //===----------------------------------------------------------------------===// 00174 // Predicates 00175 //===----------------------------------------------------------------------===// 00176 00177 /// isBasicType - Return true if the specified tag is legal for 00178 /// DIBasicType. 00179 bool DIDescriptor::isBasicType() const { 00180 if (!DbgNode) return false; 00181 switch (getTag()) { 00182 case dwarf::DW_TAG_base_type: 00183 case dwarf::DW_TAG_unspecified_type: 00184 return true; 00185 default: 00186 return false; 00187 } 00188 } 00189 00190 /// isDerivedType - Return true if the specified tag is legal for DIDerivedType. 00191 bool DIDescriptor::isDerivedType() const { 00192 if (!DbgNode) return false; 00193 switch (getTag()) { 00194 case dwarf::DW_TAG_typedef: 00195 case dwarf::DW_TAG_pointer_type: 00196 case dwarf::DW_TAG_ptr_to_member_type: 00197 case dwarf::DW_TAG_reference_type: 00198 case dwarf::DW_TAG_rvalue_reference_type: 00199 case dwarf::DW_TAG_const_type: 00200 case dwarf::DW_TAG_volatile_type: 00201 case dwarf::DW_TAG_restrict_type: 00202 case dwarf::DW_TAG_member: 00203 case dwarf::DW_TAG_inheritance: 00204 case dwarf::DW_TAG_friend: 00205 return true; 00206 default: 00207 // CompositeTypes are currently modelled as DerivedTypes. 00208 return isCompositeType(); 00209 } 00210 } 00211 00212 /// isCompositeType - Return true if the specified tag is legal for 00213 /// DICompositeType. 00214 bool DIDescriptor::isCompositeType() const { 00215 if (!DbgNode) return false; 00216 switch (getTag()) { 00217 case dwarf::DW_TAG_array_type: 00218 case dwarf::DW_TAG_structure_type: 00219 case dwarf::DW_TAG_union_type: 00220 case dwarf::DW_TAG_enumeration_type: 00221 case dwarf::DW_TAG_subroutine_type: 00222 case dwarf::DW_TAG_class_type: 00223 return true; 00224 default: 00225 return false; 00226 } 00227 } 00228 00229 /// isVariable - Return true if the specified tag is legal for DIVariable. 00230 bool DIDescriptor::isVariable() const { 00231 if (!DbgNode) return false; 00232 switch (getTag()) { 00233 case dwarf::DW_TAG_auto_variable: 00234 case dwarf::DW_TAG_arg_variable: 00235 return true; 00236 default: 00237 return false; 00238 } 00239 } 00240 00241 /// isType - Return true if the specified tag is legal for DIType. 00242 bool DIDescriptor::isType() const { 00243 return isBasicType() || isCompositeType() || isDerivedType(); 00244 } 00245 00246 /// isSubprogram - Return true if the specified tag is legal for 00247 /// DISubprogram. 00248 bool DIDescriptor::isSubprogram() const { 00249 return DbgNode && getTag() == dwarf::DW_TAG_subprogram; 00250 } 00251 00252 /// isGlobalVariable - Return true if the specified tag is legal for 00253 /// DIGlobalVariable. 00254 bool DIDescriptor::isGlobalVariable() const { 00255 return DbgNode && (getTag() == dwarf::DW_TAG_variable || 00256 getTag() == dwarf::DW_TAG_constant); 00257 } 00258 00259 /// isGlobal - Return true if the specified tag is legal for DIGlobal. 00260 bool DIDescriptor::isGlobal() const { 00261 return isGlobalVariable(); 00262 } 00263 00264 /// isUnspecifiedParmeter - Return true if the specified tag is 00265 /// DW_TAG_unspecified_parameters. 00266 bool DIDescriptor::isUnspecifiedParameter() const { 00267 return DbgNode && getTag() == dwarf::DW_TAG_unspecified_parameters; 00268 } 00269 00270 /// isScope - Return true if the specified tag is one of the scope 00271 /// related tag. 00272 bool DIDescriptor::isScope() const { 00273 if (!DbgNode) return false; 00274 switch (getTag()) { 00275 case dwarf::DW_TAG_compile_unit: 00276 case dwarf::DW_TAG_lexical_block: 00277 case dwarf::DW_TAG_subprogram: 00278 case dwarf::DW_TAG_namespace: 00279 return true; 00280 default: 00281 break; 00282 } 00283 return false; 00284 } 00285 00286 /// isTemplateTypeParameter - Return true if the specified tag is 00287 /// DW_TAG_template_type_parameter. 00288 bool DIDescriptor::isTemplateTypeParameter() const { 00289 return DbgNode && getTag() == dwarf::DW_TAG_template_type_parameter; 00290 } 00291 00292 /// isTemplateValueParameter - Return true if the specified tag is 00293 /// DW_TAG_template_value_parameter. 00294 bool DIDescriptor::isTemplateValueParameter() const { 00295 return DbgNode && getTag() == dwarf::DW_TAG_template_value_parameter; 00296 } 00297 00298 /// isCompileUnit - Return true if the specified tag is DW_TAG_compile_unit. 00299 bool DIDescriptor::isCompileUnit() const { 00300 return DbgNode && getTag() == dwarf::DW_TAG_compile_unit; 00301 } 00302 00303 /// isFile - Return true if the specified tag is DW_TAG_file_type. 00304 bool DIDescriptor::isFile() const { 00305 return DbgNode && getTag() == dwarf::DW_TAG_file_type; 00306 } 00307 00308 /// isNameSpace - Return true if the specified tag is DW_TAG_namespace. 00309 bool DIDescriptor::isNameSpace() const { 00310 return DbgNode && getTag() == dwarf::DW_TAG_namespace; 00311 } 00312 00313 /// isLexicalBlockFile - Return true if the specified descriptor is a 00314 /// lexical block with an extra file. 00315 bool DIDescriptor::isLexicalBlockFile() const { 00316 return DbgNode && getTag() == dwarf::DW_TAG_lexical_block && 00317 (DbgNode->getNumOperands() == 3); 00318 } 00319 00320 /// isLexicalBlock - Return true if the specified tag is DW_TAG_lexical_block. 00321 bool DIDescriptor::isLexicalBlock() const { 00322 return DbgNode && getTag() == dwarf::DW_TAG_lexical_block && 00323 (DbgNode->getNumOperands() > 3); 00324 } 00325 00326 /// isSubrange - Return true if the specified tag is DW_TAG_subrange_type. 00327 bool DIDescriptor::isSubrange() const { 00328 return DbgNode && getTag() == dwarf::DW_TAG_subrange_type; 00329 } 00330 00331 /// isEnumerator - Return true if the specified tag is DW_TAG_enumerator. 00332 bool DIDescriptor::isEnumerator() const { 00333 return DbgNode && getTag() == dwarf::DW_TAG_enumerator; 00334 } 00335 00336 /// isObjCProperty - Return true if the specified tag is DW_TAG_APPLE_property. 00337 bool DIDescriptor::isObjCProperty() const { 00338 return DbgNode && getTag() == dwarf::DW_TAG_APPLE_property; 00339 } 00340 00341 /// \brief Return true if the specified tag is DW_TAG_imported_module or 00342 /// DW_TAG_imported_declaration. 00343 bool DIDescriptor::isImportedEntity() const { 00344 return DbgNode && (getTag() == dwarf::DW_TAG_imported_module || 00345 getTag() == dwarf::DW_TAG_imported_declaration); 00346 } 00347 00348 //===----------------------------------------------------------------------===// 00349 // Simple Descriptor Constructors and other Methods 00350 //===----------------------------------------------------------------------===// 00351 00352 DIType::DIType(const MDNode *N) : DIScope(N) { 00353 if (!N) return; 00354 if (!isBasicType() && !isDerivedType() && !isCompositeType()) { 00355 DbgNode = 0; 00356 } 00357 } 00358 00359 unsigned DIArray::getNumElements() const { 00360 if (!DbgNode) 00361 return 0; 00362 return DbgNode->getNumOperands(); 00363 } 00364 00365 /// replaceAllUsesWith - Replace all uses of debug info referenced by 00366 /// this descriptor. 00367 void DIType::replaceAllUsesWith(DIDescriptor &D) { 00368 if (!DbgNode) 00369 return; 00370 00371 // Since we use a TrackingVH for the node, its easy for clients to manufacture 00372 // legitimate situations where they want to replaceAllUsesWith() on something 00373 // which, due to uniquing, has merged with the source. We shield clients from 00374 // this detail by allowing a value to be replaced with replaceAllUsesWith() 00375 // itself. 00376 if (DbgNode != D) { 00377 MDNode *Node = const_cast<MDNode*>(DbgNode); 00378 const MDNode *DN = D; 00379 const Value *V = cast_or_null<Value>(DN); 00380 Node->replaceAllUsesWith(const_cast<Value*>(V)); 00381 MDNode::deleteTemporary(Node); 00382 } 00383 } 00384 00385 /// replaceAllUsesWith - Replace all uses of debug info referenced by 00386 /// this descriptor. 00387 void DIType::replaceAllUsesWith(MDNode *D) { 00388 if (!DbgNode) 00389 return; 00390 00391 // Since we use a TrackingVH for the node, its easy for clients to manufacture 00392 // legitimate situations where they want to replaceAllUsesWith() on something 00393 // which, due to uniquing, has merged with the source. We shield clients from 00394 // this detail by allowing a value to be replaced with replaceAllUsesWith() 00395 // itself. 00396 if (DbgNode != D) { 00397 MDNode *Node = const_cast<MDNode*>(DbgNode); 00398 const MDNode *DN = D; 00399 const Value *V = cast_or_null<Value>(DN); 00400 Node->replaceAllUsesWith(const_cast<Value*>(V)); 00401 MDNode::deleteTemporary(Node); 00402 } 00403 } 00404 00405 /// isUnsignedDIType - Return true if type encoding is unsigned. 00406 bool DIType::isUnsignedDIType() { 00407 DIDerivedType DTy(DbgNode); 00408 if (DTy.Verify()) 00409 return DTy.getTypeDerivedFrom().isUnsignedDIType(); 00410 00411 DIBasicType BTy(DbgNode); 00412 if (BTy.Verify()) { 00413 unsigned Encoding = BTy.getEncoding(); 00414 if (Encoding == dwarf::DW_ATE_unsigned || 00415 Encoding == dwarf::DW_ATE_unsigned_char || 00416 Encoding == dwarf::DW_ATE_boolean) 00417 return true; 00418 } 00419 return false; 00420 } 00421 00422 /// Verify - Verify that a compile unit is well formed. 00423 bool DICompileUnit::Verify() const { 00424 if (!isCompileUnit()) 00425 return false; 00426 StringRef N = getFilename(); 00427 if (N.empty()) 00428 return false; 00429 // It is possible that directory and produce string is empty. 00430 return DbgNode->getNumOperands() == 13; 00431 } 00432 00433 /// Verify - Verify that an ObjC property is well formed. 00434 bool DIObjCProperty::Verify() const { 00435 if (!isObjCProperty()) 00436 return false; 00437 00438 DIType Ty = getType(); 00439 if (!Ty.Verify()) return false; 00440 00441 // Don't worry about the rest of the strings for now. 00442 return DbgNode->getNumOperands() == 8; 00443 } 00444 00445 /// Verify - Verify that a type descriptor is well formed. 00446 bool DIType::Verify() const { 00447 if (!isType()) 00448 return false; 00449 if (getContext() && !getContext().Verify()) 00450 return false; 00451 unsigned Tag = getTag(); 00452 if (!isBasicType() && Tag != dwarf::DW_TAG_const_type && 00453 Tag != dwarf::DW_TAG_volatile_type && Tag != dwarf::DW_TAG_pointer_type && 00454 Tag != dwarf::DW_TAG_ptr_to_member_type && 00455 Tag != dwarf::DW_TAG_reference_type && 00456 Tag != dwarf::DW_TAG_rvalue_reference_type && 00457 Tag != dwarf::DW_TAG_restrict_type && 00458 Tag != dwarf::DW_TAG_array_type && 00459 Tag != dwarf::DW_TAG_enumeration_type && 00460 Tag != dwarf::DW_TAG_subroutine_type && 00461 getFilename().empty()) 00462 return false; 00463 return true; 00464 } 00465 00466 /// Verify - Verify that a basic type descriptor is well formed. 00467 bool DIBasicType::Verify() const { 00468 return isBasicType() && DbgNode->getNumOperands() == 10; 00469 } 00470 00471 /// Verify - Verify that a derived type descriptor is well formed. 00472 bool DIDerivedType::Verify() const { 00473 return isDerivedType() && DbgNode->getNumOperands() >= 10 && 00474 DbgNode->getNumOperands() <= 14; 00475 } 00476 00477 /// Verify - Verify that a composite type descriptor is well formed. 00478 bool DICompositeType::Verify() const { 00479 if (!isCompositeType()) 00480 return false; 00481 if (getContext() && !getContext().Verify()) 00482 return false; 00483 00484 return DbgNode->getNumOperands() >= 10 && DbgNode->getNumOperands() <= 14; 00485 } 00486 00487 /// Verify - Verify that a subprogram descriptor is well formed. 00488 bool DISubprogram::Verify() const { 00489 if (!isSubprogram()) 00490 return false; 00491 00492 if (getContext() && !getContext().Verify()) 00493 return false; 00494 00495 DICompositeType Ty = getType(); 00496 if (!Ty.Verify()) 00497 return false; 00498 return DbgNode->getNumOperands() == 20; 00499 } 00500 00501 /// Verify - Verify that a global variable descriptor is well formed. 00502 bool DIGlobalVariable::Verify() const { 00503 if (!isGlobalVariable()) 00504 return false; 00505 00506 if (getDisplayName().empty()) 00507 return false; 00508 00509 if (getContext() && !getContext().Verify()) 00510 return false; 00511 00512 DIType Ty = getType(); 00513 if (!Ty.Verify()) 00514 return false; 00515 00516 if (!getGlobal() && !getConstant()) 00517 return false; 00518 00519 return DbgNode->getNumOperands() == 13; 00520 } 00521 00522 /// Verify - Verify that a variable descriptor is well formed. 00523 bool DIVariable::Verify() const { 00524 if (!isVariable()) 00525 return false; 00526 00527 if (getContext() && !getContext().Verify()) 00528 return false; 00529 00530 DIType Ty = getType(); 00531 if (!Ty.Verify()) 00532 return false; 00533 00534 return DbgNode->getNumOperands() >= 8; 00535 } 00536 00537 /// Verify - Verify that a location descriptor is well formed. 00538 bool DILocation::Verify() const { 00539 if (!DbgNode) 00540 return false; 00541 00542 return DbgNode->getNumOperands() == 4; 00543 } 00544 00545 /// Verify - Verify that a namespace descriptor is well formed. 00546 bool DINameSpace::Verify() const { 00547 if (!isNameSpace()) 00548 return false; 00549 return DbgNode->getNumOperands() == 5; 00550 } 00551 00552 /// \brief Retrieve the MDNode for the directory/file pair. 00553 MDNode *DIFile::getFileNode() const { 00554 return const_cast<MDNode*>(getNodeField(DbgNode, 1)); 00555 } 00556 00557 /// \brief Verify that the file descriptor is well formed. 00558 bool DIFile::Verify() const { 00559 return isFile() && DbgNode->getNumOperands() == 2; 00560 } 00561 00562 /// \brief Verify that the enumerator descriptor is well formed. 00563 bool DIEnumerator::Verify() const { 00564 return isEnumerator() && DbgNode->getNumOperands() == 3; 00565 } 00566 00567 /// \brief Verify that the subrange descriptor is well formed. 00568 bool DISubrange::Verify() const { 00569 return isSubrange() && DbgNode->getNumOperands() == 3; 00570 } 00571 00572 /// \brief Verify that the lexical block descriptor is well formed. 00573 bool DILexicalBlock::Verify() const { 00574 return isLexicalBlock() && DbgNode->getNumOperands() == 6; 00575 } 00576 00577 /// \brief Verify that the file-scoped lexical block descriptor is well formed. 00578 bool DILexicalBlockFile::Verify() const { 00579 return isLexicalBlockFile() && DbgNode->getNumOperands() == 3; 00580 } 00581 00582 /// \brief Verify that the template type parameter descriptor is well formed. 00583 bool DITemplateTypeParameter::Verify() const { 00584 return isTemplateTypeParameter() && DbgNode->getNumOperands() == 7; 00585 } 00586 00587 /// \brief Verify that the template value parameter descriptor is well formed. 00588 bool DITemplateValueParameter::Verify() const { 00589 return isTemplateValueParameter() && DbgNode->getNumOperands() == 8; 00590 } 00591 00592 /// \brief Verify that the imported module descriptor is well formed. 00593 bool DIImportedEntity::Verify() const { 00594 return isImportedEntity() && 00595 (DbgNode->getNumOperands() == 4 || DbgNode->getNumOperands() == 5); 00596 } 00597 00598 /// getOriginalTypeSize - If this type is derived from a base type then 00599 /// return base type size. 00600 uint64_t DIDerivedType::getOriginalTypeSize() const { 00601 unsigned Tag = getTag(); 00602 00603 if (Tag != dwarf::DW_TAG_member && Tag != dwarf::DW_TAG_typedef && 00604 Tag != dwarf::DW_TAG_const_type && Tag != dwarf::DW_TAG_volatile_type && 00605 Tag != dwarf::DW_TAG_restrict_type) 00606 return getSizeInBits(); 00607 00608 DIType BaseType = getTypeDerivedFrom(); 00609 00610 // If this type is not derived from any type then take conservative approach. 00611 if (!BaseType.isValid()) 00612 return getSizeInBits(); 00613 00614 // If this is a derived type, go ahead and get the base type, unless it's a 00615 // reference then it's just the size of the field. Pointer types have no need 00616 // of this since they're a different type of qualification on the type. 00617 if (BaseType.getTag() == dwarf::DW_TAG_reference_type || 00618 BaseType.getTag() == dwarf::DW_TAG_rvalue_reference_type) 00619 return getSizeInBits(); 00620 00621 if (BaseType.isDerivedType()) 00622 return DIDerivedType(BaseType).getOriginalTypeSize(); 00623 00624 return BaseType.getSizeInBits(); 00625 } 00626 00627 /// getObjCProperty - Return property node, if this ivar is associated with one. 00628 MDNode *DIDerivedType::getObjCProperty() const { 00629 if (DbgNode->getNumOperands() <= 10) 00630 return NULL; 00631 return dyn_cast_or_null<MDNode>(DbgNode->getOperand(10)); 00632 } 00633 00634 /// \brief Set the array of member DITypes. 00635 void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) { 00636 assert((!TParams || DbgNode->getNumOperands() == 14) && 00637 "If you're setting the template parameters this should include a slot " 00638 "for that!"); 00639 TrackingVH<MDNode> N(*this); 00640 N->replaceOperandWith(10, Elements); 00641 if (TParams) 00642 N->replaceOperandWith(13, TParams); 00643 DbgNode = N; 00644 } 00645 00646 /// \brief Set the containing type. 00647 void DICompositeType::setContainingType(DICompositeType ContainingType) { 00648 TrackingVH<MDNode> N(*this); 00649 N->replaceOperandWith(12, ContainingType); 00650 DbgNode = N; 00651 } 00652 00653 /// isInlinedFnArgument - Return true if this variable provides debugging 00654 /// information for an inlined function arguments. 00655 bool DIVariable::isInlinedFnArgument(const Function *CurFn) { 00656 assert(CurFn && "Invalid function"); 00657 if (!getContext().isSubprogram()) 00658 return false; 00659 // This variable is not inlined function argument if its scope 00660 // does not describe current function. 00661 return !DISubprogram(getContext()).describes(CurFn); 00662 } 00663 00664 /// describes - Return true if this subprogram provides debugging 00665 /// information for the function F. 00666 bool DISubprogram::describes(const Function *F) { 00667 assert(F && "Invalid function"); 00668 if (F == getFunction()) 00669 return true; 00670 StringRef Name = getLinkageName(); 00671 if (Name.empty()) 00672 Name = getName(); 00673 if (F->getName() == Name) 00674 return true; 00675 return false; 00676 } 00677 00678 unsigned DISubprogram::isOptimized() const { 00679 assert (DbgNode && "Invalid subprogram descriptor!"); 00680 if (DbgNode->getNumOperands() == 15) 00681 return getUnsignedField(14); 00682 return 0; 00683 } 00684 00685 MDNode *DISubprogram::getVariablesNodes() const { 00686 if (!DbgNode || DbgNode->getNumOperands() <= 18) 00687 return NULL; 00688 return dyn_cast_or_null<MDNode>(DbgNode->getOperand(18)); 00689 } 00690 00691 DIArray DISubprogram::getVariables() const { 00692 if (!DbgNode || DbgNode->getNumOperands() <= 18) 00693 return DIArray(); 00694 if (MDNode *T = dyn_cast_or_null<MDNode>(DbgNode->getOperand(18))) 00695 return DIArray(T); 00696 return DIArray(); 00697 } 00698 00699 Value *DITemplateValueParameter::getValue() const { 00700 return getField(DbgNode, 4); 00701 } 00702 00703 void DIScope::setFilename(StringRef Name, LLVMContext &Context) { 00704 if (!DbgNode) 00705 return; 00706 MDString *MDName(MDString::get(Context, Name)); 00707 const_cast<MDNode*>(getNodeField(DbgNode, 1))->replaceOperandWith(0, MDName); 00708 } 00709 00710 StringRef DIScope::getFilename() const { 00711 if (!DbgNode) 00712 return StringRef(); 00713 return ::getStringField(getNodeField(DbgNode, 1), 0); 00714 } 00715 00716 StringRef DIScope::getDirectory() const { 00717 if (!DbgNode) 00718 return StringRef(); 00719 return ::getStringField(getNodeField(DbgNode, 1), 1); 00720 } 00721 00722 DIArray DICompileUnit::getEnumTypes() const { 00723 if (!DbgNode || DbgNode->getNumOperands() < 13) 00724 return DIArray(); 00725 00726 if (MDNode *N = dyn_cast_or_null<MDNode>(DbgNode->getOperand(7))) 00727 return DIArray(N); 00728 return DIArray(); 00729 } 00730 00731 DIArray DICompileUnit::getRetainedTypes() const { 00732 if (!DbgNode || DbgNode->getNumOperands() < 13) 00733 return DIArray(); 00734 00735 if (MDNode *N = dyn_cast_or_null<MDNode>(DbgNode->getOperand(8))) 00736 return DIArray(N); 00737 return DIArray(); 00738 } 00739 00740 DIArray DICompileUnit::getSubprograms() const { 00741 if (!DbgNode || DbgNode->getNumOperands() < 13) 00742 return DIArray(); 00743 00744 if (MDNode *N = dyn_cast_or_null<MDNode>(DbgNode->getOperand(9))) 00745 return DIArray(N); 00746 return DIArray(); 00747 } 00748 00749 00750 DIArray DICompileUnit::getGlobalVariables() const { 00751 if (!DbgNode || DbgNode->getNumOperands() < 13) 00752 return DIArray(); 00753 00754 if (MDNode *N = dyn_cast_or_null<MDNode>(DbgNode->getOperand(10))) 00755 return DIArray(N); 00756 return DIArray(); 00757 } 00758 00759 DIArray DICompileUnit::getImportedEntities() const { 00760 if (!DbgNode || DbgNode->getNumOperands() < 13) 00761 return DIArray(); 00762 00763 if (MDNode *N = dyn_cast_or_null<MDNode>(DbgNode->getOperand(11))) 00764 return DIArray(N); 00765 return DIArray(); 00766 } 00767 00768 /// fixupObjcLikeName - Replace contains special characters used 00769 /// in a typical Objective-C names with '.' in a given string. 00770 static void fixupObjcLikeName(StringRef Str, SmallVectorImpl<char> &Out) { 00771 bool isObjCLike = false; 00772 for (size_t i = 0, e = Str.size(); i < e; ++i) { 00773 char C = Str[i]; 00774 if (C == '[') 00775 isObjCLike = true; 00776 00777 if (isObjCLike && (C == '[' || C == ']' || C == ' ' || C == ':' || 00778 C == '+' || C == '(' || C == ')')) 00779 Out.push_back('.'); 00780 else 00781 Out.push_back(C); 00782 } 00783 } 00784 00785 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is 00786 /// suitable to hold function specific information. 00787 NamedMDNode *llvm::getFnSpecificMDNode(const Module &M, DISubprogram Fn) { 00788 SmallString<32> Name = StringRef("llvm.dbg.lv."); 00789 StringRef FName = "fn"; 00790 if (Fn.getFunction()) 00791 FName = Fn.getFunction()->getName(); 00792 else 00793 FName = Fn.getName(); 00794 char One = '\1'; 00795 if (FName.startswith(StringRef(&One, 1))) 00796 FName = FName.substr(1); 00797 fixupObjcLikeName(FName, Name); 00798 return M.getNamedMetadata(Name.str()); 00799 } 00800 00801 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable 00802 /// to hold function specific information. 00803 NamedMDNode *llvm::getOrInsertFnSpecificMDNode(Module &M, DISubprogram Fn) { 00804 SmallString<32> Name = StringRef("llvm.dbg.lv."); 00805 StringRef FName = "fn"; 00806 if (Fn.getFunction()) 00807 FName = Fn.getFunction()->getName(); 00808 else 00809 FName = Fn.getName(); 00810 char One = '\1'; 00811 if (FName.startswith(StringRef(&One, 1))) 00812 FName = FName.substr(1); 00813 fixupObjcLikeName(FName, Name); 00814 00815 return M.getOrInsertNamedMetadata(Name.str()); 00816 } 00817 00818 /// createInlinedVariable - Create a new inlined variable based on current 00819 /// variable. 00820 /// @param DV Current Variable. 00821 /// @param InlinedScope Location at current variable is inlined. 00822 DIVariable llvm::createInlinedVariable(MDNode *DV, MDNode *InlinedScope, 00823 LLVMContext &VMContext) { 00824 SmallVector<Value *, 16> Elts; 00825 // Insert inlined scope as 7th element. 00826 for (unsigned i = 0, e = DV->getNumOperands(); i != e; ++i) 00827 i == 7 ? Elts.push_back(InlinedScope) : 00828 Elts.push_back(DV->getOperand(i)); 00829 return DIVariable(MDNode::get(VMContext, Elts)); 00830 } 00831 00832 /// cleanseInlinedVariable - Remove inlined scope from the variable. 00833 DIVariable llvm::cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext) { 00834 SmallVector<Value *, 16> Elts; 00835 // Insert inlined scope as 7th element. 00836 for (unsigned i = 0, e = DV->getNumOperands(); i != e; ++i) 00837 i == 7 ? 00838 Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext))): 00839 Elts.push_back(DV->getOperand(i)); 00840 return DIVariable(MDNode::get(VMContext, Elts)); 00841 } 00842 00843 /// getDISubprogram - Find subprogram that is enclosing this scope. 00844 DISubprogram llvm::getDISubprogram(const MDNode *Scope) { 00845 DIDescriptor D(Scope); 00846 if (D.isSubprogram()) 00847 return DISubprogram(Scope); 00848 00849 if (D.isLexicalBlockFile()) 00850 return getDISubprogram(DILexicalBlockFile(Scope).getContext()); 00851 00852 if (D.isLexicalBlock()) 00853 return getDISubprogram(DILexicalBlock(Scope).getContext()); 00854 00855 return DISubprogram(); 00856 } 00857 00858 /// getDICompositeType - Find underlying composite type. 00859 DICompositeType llvm::getDICompositeType(DIType T) { 00860 if (T.isCompositeType()) 00861 return DICompositeType(T); 00862 00863 if (T.isDerivedType()) 00864 return getDICompositeType(DIDerivedType(T).getTypeDerivedFrom()); 00865 00866 return DICompositeType(); 00867 } 00868 00869 /// isSubprogramContext - Return true if Context is either a subprogram 00870 /// or another context nested inside a subprogram. 00871 bool llvm::isSubprogramContext(const MDNode *Context) { 00872 if (!Context) 00873 return false; 00874 DIDescriptor D(Context); 00875 if (D.isSubprogram()) 00876 return true; 00877 if (D.isType()) 00878 return isSubprogramContext(DIType(Context).getContext()); 00879 return false; 00880 } 00881 00882 //===----------------------------------------------------------------------===// 00883 // DebugInfoFinder implementations. 00884 //===----------------------------------------------------------------------===// 00885 00886 /// processModule - Process entire module and collect debug info. 00887 void DebugInfoFinder::processModule(const Module &M) { 00888 if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) { 00889 for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) { 00890 DICompileUnit CU(CU_Nodes->getOperand(i)); 00891 addCompileUnit(CU); 00892 DIArray GVs = CU.getGlobalVariables(); 00893 for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) { 00894 DIGlobalVariable DIG(GVs.getElement(i)); 00895 if (addGlobalVariable(DIG)) 00896 processType(DIG.getType()); 00897 } 00898 DIArray SPs = CU.getSubprograms(); 00899 for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) 00900 processSubprogram(DISubprogram(SPs.getElement(i))); 00901 DIArray EnumTypes = CU.getEnumTypes(); 00902 for (unsigned i = 0, e = EnumTypes.getNumElements(); i != e; ++i) 00903 processType(DIType(EnumTypes.getElement(i))); 00904 DIArray RetainedTypes = CU.getRetainedTypes(); 00905 for (unsigned i = 0, e = RetainedTypes.getNumElements(); i != e; ++i) 00906 processType(DIType(RetainedTypes.getElement(i))); 00907 // FIXME: We really shouldn't be bailing out after visiting just one CU 00908 return; 00909 } 00910 } 00911 } 00912 00913 /// processLocation - Process DILocation. 00914 void DebugInfoFinder::processLocation(DILocation Loc) { 00915 if (!Loc.Verify()) return; 00916 DIDescriptor S(Loc.getScope()); 00917 if (S.isCompileUnit()) 00918 addCompileUnit(DICompileUnit(S)); 00919 else if (S.isSubprogram()) 00920 processSubprogram(DISubprogram(S)); 00921 else if (S.isLexicalBlock()) 00922 processLexicalBlock(DILexicalBlock(S)); 00923 else if (S.isLexicalBlockFile()) { 00924 DILexicalBlockFile DBF = DILexicalBlockFile(S); 00925 processLexicalBlock(DILexicalBlock(DBF.getScope())); 00926 } 00927 processLocation(Loc.getOrigLocation()); 00928 } 00929 00930 /// processType - Process DIType. 00931 void DebugInfoFinder::processType(DIType DT) { 00932 if (!addType(DT)) 00933 return; 00934 if (DT.isCompositeType()) { 00935 DICompositeType DCT(DT); 00936 processType(DCT.getTypeDerivedFrom()); 00937 DIArray DA = DCT.getTypeArray(); 00938 for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) { 00939 DIDescriptor D = DA.getElement(i); 00940 if (D.isType()) 00941 processType(DIType(D)); 00942 else if (D.isSubprogram()) 00943 processSubprogram(DISubprogram(D)); 00944 } 00945 } else if (DT.isDerivedType()) { 00946 DIDerivedType DDT(DT); 00947 processType(DDT.getTypeDerivedFrom()); 00948 } 00949 } 00950 00951 /// processLexicalBlock 00952 void DebugInfoFinder::processLexicalBlock(DILexicalBlock LB) { 00953 DIScope Context = LB.getContext(); 00954 if (Context.isLexicalBlock()) 00955 return processLexicalBlock(DILexicalBlock(Context)); 00956 else if (Context.isLexicalBlockFile()) { 00957 DILexicalBlockFile DBF = DILexicalBlockFile(Context); 00958 return processLexicalBlock(DILexicalBlock(DBF.getScope())); 00959 } 00960 else 00961 return processSubprogram(DISubprogram(Context)); 00962 } 00963 00964 /// processSubprogram - Process DISubprogram. 00965 void DebugInfoFinder::processSubprogram(DISubprogram SP) { 00966 if (!addSubprogram(SP)) 00967 return; 00968 processType(SP.getType()); 00969 } 00970 00971 /// processDeclare - Process DbgDeclareInst. 00972 void DebugInfoFinder::processDeclare(const DbgDeclareInst *DDI) { 00973 MDNode *N = dyn_cast<MDNode>(DDI->getVariable()); 00974 if (!N) return; 00975 00976 DIDescriptor DV(N); 00977 if (!DV.isVariable()) 00978 return; 00979 00980 if (!NodesSeen.insert(DV)) 00981 return; 00982 processType(DIVariable(N).getType()); 00983 } 00984 00985 /// addType - Add type into Tys. 00986 bool DebugInfoFinder::addType(DIType DT) { 00987 if (!DT.isValid()) 00988 return false; 00989 00990 if (!NodesSeen.insert(DT)) 00991 return false; 00992 00993 TYs.push_back(DT); 00994 return true; 00995 } 00996 00997 /// addCompileUnit - Add compile unit into CUs. 00998 bool DebugInfoFinder::addCompileUnit(DICompileUnit CU) { 00999 if (!CU.Verify()) 01000 return false; 01001 01002 if (!NodesSeen.insert(CU)) 01003 return false; 01004 01005 CUs.push_back(CU); 01006 return true; 01007 } 01008 01009 /// addGlobalVariable - Add global variable into GVs. 01010 bool DebugInfoFinder::addGlobalVariable(DIGlobalVariable DIG) { 01011 if (!DIDescriptor(DIG).isGlobalVariable()) 01012 return false; 01013 01014 if (!NodesSeen.insert(DIG)) 01015 return false; 01016 01017 GVs.push_back(DIG); 01018 return true; 01019 } 01020 01021 // addSubprogram - Add subprgoram into SPs. 01022 bool DebugInfoFinder::addSubprogram(DISubprogram SP) { 01023 if (!DIDescriptor(SP).isSubprogram()) 01024 return false; 01025 01026 if (!NodesSeen.insert(SP)) 01027 return false; 01028 01029 SPs.push_back(SP); 01030 return true; 01031 } 01032 01033 //===----------------------------------------------------------------------===// 01034 // DIDescriptor: dump routines for all descriptors. 01035 //===----------------------------------------------------------------------===// 01036 01037 /// dump - Print descriptor to dbgs() with a newline. 01038 void DIDescriptor::dump() const { 01039 print(dbgs()); dbgs() << '\n'; 01040 } 01041 01042 /// print - Print descriptor. 01043 void DIDescriptor::print(raw_ostream &OS) const { 01044 if (!DbgNode) return; 01045 01046 if (const char *Tag = dwarf::TagString(getTag())) 01047 OS << "[ " << Tag << " ]"; 01048 01049 if (this->isSubrange()) { 01050 DISubrange(DbgNode).printInternal(OS); 01051 } else if (this->isCompileUnit()) { 01052 DICompileUnit(DbgNode).printInternal(OS); 01053 } else if (this->isFile()) { 01054 DIFile(DbgNode).printInternal(OS); 01055 } else if (this->isEnumerator()) { 01056 DIEnumerator(DbgNode).printInternal(OS); 01057 } else if (this->isBasicType()) { 01058 DIType(DbgNode).printInternal(OS); 01059 } else if (this->isDerivedType()) { 01060 DIDerivedType(DbgNode).printInternal(OS); 01061 } else if (this->isCompositeType()) { 01062 DICompositeType(DbgNode).printInternal(OS); 01063 } else if (this->isSubprogram()) { 01064 DISubprogram(DbgNode).printInternal(OS); 01065 } else if (this->isGlobalVariable()) { 01066 DIGlobalVariable(DbgNode).printInternal(OS); 01067 } else if (this->isVariable()) { 01068 DIVariable(DbgNode).printInternal(OS); 01069 } else if (this->isObjCProperty()) { 01070 DIObjCProperty(DbgNode).printInternal(OS); 01071 } else if (this->isNameSpace()) { 01072 DINameSpace(DbgNode).printInternal(OS); 01073 } else if (this->isScope()) { 01074 DIScope(DbgNode).printInternal(OS); 01075 } 01076 } 01077 01078 void DISubrange::printInternal(raw_ostream &OS) const { 01079 int64_t Count = getCount(); 01080 if (Count != -1) 01081 OS << " [" << getLo() << ", " << Count - 1 << ']'; 01082 else 01083 OS << " [unbounded]"; 01084 } 01085 01086 void DIScope::printInternal(raw_ostream &OS) const { 01087 OS << " [" << getDirectory() << "/" << getFilename() << ']'; 01088 } 01089 01090 void DICompileUnit::printInternal(raw_ostream &OS) const { 01091 DIScope::printInternal(OS); 01092 OS << " ["; 01093 unsigned Lang = getLanguage(); 01094 if (const char *LangStr = dwarf::LanguageString(Lang)) 01095 OS << LangStr; 01096 else 01097 (OS << "lang 0x").write_hex(Lang); 01098 OS << ']'; 01099 } 01100 01101 void DIEnumerator::printInternal(raw_ostream &OS) const { 01102 OS << " [" << getName() << " :: " << getEnumValue() << ']'; 01103 } 01104 01105 void DIType::printInternal(raw_ostream &OS) const { 01106 if (!DbgNode) return; 01107 01108 StringRef Res = getName(); 01109 if (!Res.empty()) 01110 OS << " [" << Res << "]"; 01111 01112 // TODO: Print context? 01113 01114 OS << " [line " << getLineNumber() 01115 << ", size " << getSizeInBits() 01116 << ", align " << getAlignInBits() 01117 << ", offset " << getOffsetInBits(); 01118 if (isBasicType()) 01119 if (const char *Enc = 01120 dwarf::AttributeEncodingString(DIBasicType(DbgNode).getEncoding())) 01121 OS << ", enc " << Enc; 01122 OS << "]"; 01123 01124 if (isPrivate()) 01125 OS << " [private]"; 01126 else if (isProtected()) 01127 OS << " [protected]"; 01128 01129 if (isArtificial()) 01130 OS << " [artificial]"; 01131 01132 if (isForwardDecl()) 01133 OS << " [fwd]"; 01134 if (isVector()) 01135 OS << " [vector]"; 01136 if (isStaticMember()) 01137 OS << " [static]"; 01138 } 01139 01140 void DIDerivedType::printInternal(raw_ostream &OS) const { 01141 DIType::printInternal(OS); 01142 OS << " [from " << getTypeDerivedFrom().getName() << ']'; 01143 } 01144 01145 void DICompositeType::printInternal(raw_ostream &OS) const { 01146 DIType::printInternal(OS); 01147 DIArray A = getTypeArray(); 01148 OS << " [" << A.getNumElements() << " elements]"; 01149 } 01150 01151 void DINameSpace::printInternal(raw_ostream &OS) const { 01152 StringRef Name = getName(); 01153 if (!Name.empty()) 01154 OS << " [" << Name << ']'; 01155 01156 OS << " [line " << getLineNumber() << ']'; 01157 } 01158 01159 void DISubprogram::printInternal(raw_ostream &OS) const { 01160 // TODO : Print context 01161 OS << " [line " << getLineNumber() << ']'; 01162 01163 if (isLocalToUnit()) 01164 OS << " [local]"; 01165 01166 if (isDefinition()) 01167 OS << " [def]"; 01168 01169 if (getScopeLineNumber() != getLineNumber()) 01170 OS << " [scope " << getScopeLineNumber() << "]"; 01171 01172 if (isPrivate()) 01173 OS << " [private]"; 01174 else if (isProtected()) 01175 OS << " [protected]"; 01176 01177 StringRef Res = getName(); 01178 if (!Res.empty()) 01179 OS << " [" << Res << ']'; 01180 } 01181 01182 void DIGlobalVariable::printInternal(raw_ostream &OS) const { 01183 StringRef Res = getName(); 01184 if (!Res.empty()) 01185 OS << " [" << Res << ']'; 01186 01187 OS << " [line " << getLineNumber() << ']'; 01188 01189 // TODO : Print context 01190 01191 if (isLocalToUnit()) 01192 OS << " [local]"; 01193 01194 if (isDefinition()) 01195 OS << " [def]"; 01196 } 01197 01198 void DIVariable::printInternal(raw_ostream &OS) const { 01199 StringRef Res = getName(); 01200 if (!Res.empty()) 01201 OS << " [" << Res << ']'; 01202 01203 OS << " [line " << getLineNumber() << ']'; 01204 } 01205 01206 void DIObjCProperty::printInternal(raw_ostream &OS) const { 01207 StringRef Name = getObjCPropertyName(); 01208 if (!Name.empty()) 01209 OS << " [" << Name << ']'; 01210 01211 OS << " [line " << getLineNumber() 01212 << ", properties " << getUnsignedField(6) << ']'; 01213 } 01214 01215 static void printDebugLoc(DebugLoc DL, raw_ostream &CommentOS, 01216 const LLVMContext &Ctx) { 01217 if (!DL.isUnknown()) { // Print source line info. 01218 DIScope Scope(DL.getScope(Ctx)); 01219 // Omit the directory, because it's likely to be long and uninteresting. 01220 if (Scope.Verify()) 01221 CommentOS << Scope.getFilename(); 01222 else 01223 CommentOS << "<unknown>"; 01224 CommentOS << ':' << DL.getLine(); 01225 if (DL.getCol() != 0) 01226 CommentOS << ':' << DL.getCol(); 01227 DebugLoc InlinedAtDL = DebugLoc::getFromDILocation(DL.getInlinedAt(Ctx)); 01228 if (!InlinedAtDL.isUnknown()) { 01229 CommentOS << " @[ "; 01230 printDebugLoc(InlinedAtDL, CommentOS, Ctx); 01231 CommentOS << " ]"; 01232 } 01233 } 01234 } 01235 01236 void DIVariable::printExtendedName(raw_ostream &OS) const { 01237 const LLVMContext &Ctx = DbgNode->getContext(); 01238 StringRef Res = getName(); 01239 if (!Res.empty()) 01240 OS << Res << "," << getLineNumber(); 01241 if (MDNode *InlinedAt = getInlinedAt()) { 01242 DebugLoc InlinedAtDL = DebugLoc::getFromDILocation(InlinedAt); 01243 if (!InlinedAtDL.isUnknown()) { 01244 OS << " @["; 01245 printDebugLoc(InlinedAtDL, OS, Ctx); 01246 OS << "]"; 01247 } 01248 } 01249 }