Change linkInModule to take a std::unique_ptr. Passing in a std::unique_ptr should help find errors when the module is used after being linked into another module. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255842 91177308-0d34-0410-b5e6-96231b3b80d8
Use diagnostic handler in the LLVMContext This patch converts code that has access to a LLVMContext to not take a diagnostic handler. This has a few advantages * It is easier to use a consistent diagnostic handler in a single program. * Less clutter since we are not passing a handler around. It does make it a bit awkward to implement some C APIs that return a diagnostic string. I will propose new versions of these APIs and deprecate the current ones. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255571 91177308-0d34-0410-b5e6-96231b3b80d8
Simplify testMergedProgram. It now receives and returns std::unique_ptr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255087 91177308-0d34-0410-b5e6-96231b3b80d8
Simplify memory management. NFC. This passes std::unique_ptr to predicates that are expected to delete their argument. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255086 91177308-0d34-0410-b5e6-96231b3b80d8
Return std::unique_ptr from SplitFunctionsOutOfModule. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255084 91177308-0d34-0410-b5e6-96231b3b80d8
Simplify memory management. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255082 91177308-0d34-0410-b5e6-96231b3b80d8
Simplify memory management a bit. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255079 91177308-0d34-0410-b5e6-96231b3b80d8
Return a std::unique_ptr from CloneModule. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255078 91177308-0d34-0410-b5e6-96231b3b80d8
Always pass a diagnostic handler to the linker. Before this patch the diagnostic handler was optional. If it was not passed, the one in the LLVMContext was used. That is probably not a pattern we want to follow. If each area has an optional callback, there is a sea of callbacks and it is hard to follow which one is called. Doing this also found cases where the callback is a nice addition, like testing that no errors or warnings are reported. The other option is to always use the diagnostic handler in the LLVMContext. That has a few problems * To implement the C API we would have to set the diag handler and then set it back to the original value. * Code that creates the context might be far away from code that wants the diagnostics. I do have a patch that implements the second option and will send that as an RFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254777 91177308-0d34-0410-b5e6-96231b3b80d8
Use references now that it is natural to do so. The linker never takes ownership of a module or changes which module it is refering to, making it natural to use references. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254449 91177308-0d34-0410-b5e6-96231b3b80d8
bugpoint: Remove implicit ilist iterator conversions, NFC This is the last of the implicit ilist iterator conversions in LLVM. Still up for debate whether we let these bitrot back: http://lists.llvm.org/pipermail/llvm-dev/2015-October/091617.html git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250852 91177308-0d34-0410-b5e6-96231b3b80d8
[Bugpoint] Use 'CC' instead of 'GCC' for variable naming. We now use clang by default and fallback to gcc when requested. With this commit, names reflect reality. No functional change intended. Discussed with: Rafael Espindola. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250321 91177308-0d34-0410-b5e6-96231b3b80d8
Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial types If the type isn't trivially moveable emplace can skip a potentially expensive move. It also saves a couple of characters. Call sites were found with the ASTMatcher + some semi-automated cleanup. memberCallExpr( argumentCountIs(1), callee(methodDecl(hasName("push_back"))), on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))), hasArgument(0, bindTemporaryExpr( hasType(recordDecl(hasNonTrivialDestructor())), has(constructExpr()))), unless(isInTemplateInstantiation())) No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238602 91177308-0d34-0410-b5e6-96231b3b80d8
[opaque pointer type] API migration for GEP constant factories Require the pointee type to be passed explicitly and assert that it is correct. For now it's possible to pass nullptr here (and I've done so in a few places in this patch) but eventually that will be disallowed once all clients have been updated or removed. It'll be a long road to get all the way there... but if you have the cahnce to update your callers to pass the type explicitly without depending on a pointer's element type, that would be a good thing to do soon and a necessary thing to do eventually. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233938 91177308-0d34-0410-b5e6-96231b3b80d8
Teach raw_ostream to accept SmallString. Saves adding .str() call to any raw_ostream << SmallString usage and a small step towards making .str() consistent in the ADTs by removing one of the SmallString::str() use cases, discussion at http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20141013/240026.html I'll update the Phabricator patch http://reviews.llvm.org/D6372 for review of the Twine SmallString support, it's more complex than this one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231763 91177308-0d34-0410-b5e6-96231b3b80d8
Remove the PreserveSource linker mode. I noticed that it was untested, and forcing it on caused some tests to fail: LLVM :: Linker/metadata-a.ll LLVM :: Linker/prefixdata.ll LLVM :: Linker/type-unique-odr-a.ll LLVM :: Linker/type-unique-simple-a.ll LLVM :: Linker/type-unique-simple2-a.ll LLVM :: Linker/type-unique-simple2.ll LLVM :: Linker/type-unique-type-array-a.ll LLVM :: Linker/unnamed-addr1-a.ll LLVM :: Linker/visibility1.ll If it is to be resurrected, it has to be fixed and we should probably have a -preserve-source command line option in llvm-mc and run tests with and without it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220741 91177308-0d34-0410-b5e6-96231b3b80d8
Update the error handling of lib/Linker. Instead of passing a std::string&, use the new diagnostic infrastructure. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220608 91177308-0d34-0410-b5e6-96231b3b80d8
Return a std::unique_ptr from parseInputFile and propagate. NFC. The memory management in BugPoint is fairly convoluted, so this just unwraps one layer by changing the return type of functions that always return owned Modules. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216464 91177308-0d34-0410-b5e6-96231b3b80d8
Remove 'using std::error_code' from tools. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210876 91177308-0d34-0410-b5e6-96231b3b80d8
Don't use 'using std::error_code' in include/llvm. This should make sure that most new uses use the std prefix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210835 91177308-0d34-0410-b5e6-96231b3b80d8