llvm/lib
Greg Clayton c64f919f1c Add the ability to get attribute values as Optional<T>
When getting attributes it is sometimes nicer to use Optional<T> some of the time instead of magic values. I tried to cut over to only using the Optional values but it made many of the call sites very messy, so it makes sense the leave in the calls that can return a default value. Otherwise code that looks like this:

uint64_t CallColumn = Die.getAttributeValueAsAddress(DW_AT_call_line, 0);

Has to be turned into:

uint64_t CallColumn = 0;
if (auto CallColumnValue = Die.getAttributeValueAsAddress(DW_AT_call_line))
    CallColumn = *CallColumnValue;

The first snippet of code looks much better. But in cases where you want an offset that may or may not be there, the following code looks better:

if (auto StmtOffset = Die.getAttributeValueAsSectionOffset(DW_AT_stmt_list)) {
  // Use StmtOffset
}

Differential Revision: https://reviews.llvm.org/D27772



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289731 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-14 22:38:08 +00:00
..
Analysis Replace APFloatBase static fltSemantics data members with getter functions 2016-12-14 11:57:17 +00:00
AsmParser Replace APFloatBase static fltSemantics data members with getter functions 2016-12-14 11:57:17 +00:00
Bitcode Replace APFloatBase static fltSemantics data members with getter functions 2016-12-14 11:57:17 +00:00
CodeGen DebugInfo: Improve type safety and simplify some subprogram finalization code 2016-12-14 19:38:39 +00:00
DebugInfo Add the ability to get attribute values as Optional<T> 2016-12-14 22:38:08 +00:00
Demangle Demangle: remove references to allocator for default allocator 2016-11-20 00:20:27 +00:00
ExecutionEngine Replace APFloatBase static fltSemantics data members with getter functions 2016-12-14 11:57:17 +00:00
Fuzzer [libFuzzer] disable msan for one more hook that reads target's data that might be uninitialized 2016-12-14 18:13:02 +00:00
IR [DebugInfo] Changed DIBuilder::createCompileUnit() to take DIFile instead of FileName and Directory. 2016-12-14 20:24:54 +00:00
IRReader Timer: Track name and description. 2016-11-18 19:43:18 +00:00
LibDriver LibDriver: Reject inputs that are not COFF objects or bitcode files. 2016-12-14 22:19:22 +00:00
LineEditor
Linker [ThinLTO] Import only necessary DICompileUnit fields 2016-12-12 16:09:30 +00:00
LTO [LTO] Reject modules without datalayout. 2016-12-14 21:57:04 +00:00
MC Replace APFloatBase static fltSemantics data members with getter functions 2016-12-14 11:57:17 +00:00
Object Object: Make IRObjectFile own multiple modules and enumerate symbols from all modules. 2016-12-13 20:20:17 +00:00
ObjectYAML [ObjectYAML] Support for DWARF debug_aranges 2016-12-09 00:26:44 +00:00
Option
Passes [PM] Support invalidation of inner analysis managers from a pass over the outer IR unit. 2016-12-10 06:34:44 +00:00
ProfileData Make the Error class constructor protected 2016-11-11 04:28:40 +00:00
Support Include <cstdarg> in PrettyStackTrace.cpp, fixing the bots. 2016-12-14 19:19:53 +00:00
TableGen [TableGen] Centralize/Unify error handling. 2016-12-05 22:58:01 +00:00
Target [NVPTX] Support .maxnreg annotation. 2016-12-14 22:32:50 +00:00
Transforms Only sets profile summary when it was not preset. 2016-12-14 22:06:49 +00:00
CMakeLists.txt
LLVMBuild.txt