diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-07-31 17:55:53 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-07-31 17:55:53 +0000 |
commit | 1e40dc42cd1bff905323186bc0184f260902f6dd (patch) | |
tree | a9edccf44043fa3f00b4749d6d818f0db364f556 /llvm/lib | |
parent | 600aee98057e8657140713cd2a0dd6e5ff0247b8 (diff) | |
download | bcm5719-llvm-1e40dc42cd1bff905323186bc0184f260902f6dd.tar.gz bcm5719-llvm-1e40dc42cd1bff905323186bc0184f260902f6dd.zip |
DI: Rewrite the DIBuilder local variable API
Replace the general `createLocalVariable()` with two more specific
functions: `createParameterVariable()` and `createAutoVariable()`, and
rewrite the documentation.
Besides cleaning up the API, this avoids exposing the fake DWARF tags
`DW_TAG_arg_variable` and `DW_TAG_auto_variable` to frontends, and is
preparation for removing them completely.
llvm-svn: 243764
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/IR/DIBuilder.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index 28a8d567c22..7a4c5203965 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -602,15 +602,18 @@ DIGlobalVariable *DIBuilder::createTempGlobalVariableFwdDecl( .release(); } -DILocalVariable *DIBuilder::createLocalVariable( - unsigned Tag, DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, - DIType *Ty, bool AlwaysPreserve, unsigned Flags, unsigned ArgNo) { +static DILocalVariable *createLocalVariable( + LLVMContext &VMContext, + DenseMap<MDNode *, std::vector<TrackingMDNodeRef>> &PreservedVariables, + DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File, + unsigned LineNo, DIType *Ty, bool AlwaysPreserve, unsigned Flags) { // FIXME: Why getNonCompileUnitScope()? // FIXME: Why is "!Context" okay here? // FIXME: Why doesn't this check for a subprogram or lexical block (AFAICT // the only valid scopes)? DIScope *Context = getNonCompileUnitScope(Scope); + dwarf::Tag Tag = ArgNo ? dwarf::DW_TAG_arg_variable : dwarf::DW_TAG_auto_variable; auto *Node = DILocalVariable::get( VMContext, Tag, cast_or_null<DILocalScope>(Context), Name, File, LineNo, DITypeRef::get(Ty), ArgNo, Flags); @@ -625,6 +628,23 @@ DILocalVariable *DIBuilder::createLocalVariable( return Node; } +DILocalVariable *DIBuilder::createAutoVariable(DIScope *Scope, StringRef Name, + DIFile *File, unsigned LineNo, + DIType *Ty, bool AlwaysPreserve, + unsigned Flags) { + return createLocalVariable(VMContext, PreservedVariables, Scope, Name, + /* ArgNo */ 0, File, LineNo, Ty, AlwaysPreserve, + Flags); +} + +DILocalVariable *DIBuilder::createParameterVariable( + DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File, + unsigned LineNo, DIType *Ty, bool AlwaysPreserve, unsigned Flags) { + assert(ArgNo && "Expected non-zero argument number for parameter"); + return createLocalVariable(VMContext, PreservedVariables, Scope, Name, ArgNo, + File, LineNo, Ty, AlwaysPreserve, Flags); +} + DIExpression *DIBuilder::createExpression(ArrayRef<uint64_t> Addr) { return DIExpression::get(VMContext, Addr); } |