summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2016-03-17 21:28:49 +0000
committerLang Hames <lhames@gmail.com>2016-03-17 21:28:49 +0000
commit6935c2d3227661bda111bdecae976a091b8307d8 (patch)
tree936675c00ce2c608a996488e45ba4bda358108f2 /clang/lib/Frontend/CompilerInvocation.cpp
parent016b2d0ddc4855a2e07161abd9ba6cdcebadd0c4 (diff)
downloadbcm5719-llvm-6935c2d3227661bda111bdecae976a091b8307d8.tar.gz
bcm5719-llvm-6935c2d3227661bda111bdecae976a091b8307d8.zip
[Support] Add ExitOnError utility to support tools that use the exit-on-error
idiom. Most LLVM tool code exits immediately when an error is encountered and prints an error message to stderr. The ExitOnError class supports this by providing two call operators - one for Errors, and one for Expected<T>s. Calls to code that can return Errors (or Expected<T>s) can use these calls to bail out on error, and otherwise continue as if the operation had succeeded. E.g. Error foo(); Expected<int> bar(); int main(int argc, char *argv[]) { ExitOnError ExitOnErr; ExitOnErr.setBanner(std::string("Error in ") + argv[0] + ":"); // Exit if foo returns an error. No need to manually check error return. ExitOnErr(foo()); // Exit if bar returns an error, otherwise unwrap the contained int and // continue. int X = ExitOnErr(bar()); // ... return 0; } llvm-svn: 263749
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud