[PATCH] D70639: [IR] Take const references to LLVMContext

Brian Gesiak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 23 18:40:50 PST 2019


modocache created this revision.
modocache added reviewers: chandlerc, vsk, asbirlea.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

I tried to pass a `const LLVMContext &` to `llvm::Type::getInt32Ty` and
was surprised that it didn't work. Upon closer inspection, `llvm::Type`
defines many static functions that just access a member of `LLVMContext`
and `LLVMContextImpl`, and so -- as far as I can tell -- may as well
take a const reference, not a mutable reference.

I didn't want to change too much at once, so this patch just adds const
to one-line static functions defined on `llvm::Type`. For example, I left
`llvm::Type::getIntNTy` alone since that calls `llvm::IntegerType::get`,
which in turn calls the `llvm::Type` constructor, which sets the
`LLVMContext &Context` member of `llvm::Type` -- changing ALL of those
to use `const LLVMContext &` seemed like something I could do in a later
patch (if it would work at all, as of now I don't know that it would).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70639

Files:
  llvm/include/llvm/IR/Type.h
  llvm/lib/IR/Type.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70639.230781.patch
Type: text/x-patch
Size: 9703 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191124/05a6ec21/attachment.bin>


More information about the llvm-commits mailing list