1 //===-- CGBuilder.h - Choose IRBuilder implementation ----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef CLANG_CODEGEN_CGBUILDER_H
11 #define CLANG_CODEGEN_CGBUILDER_H
13 #include "llvm/IR/IRBuilder.h"
18 class CodeGenFunction;
20 /// \brief This is an IRBuilder insertion helper that forwards to
21 /// CodeGenFunction::InsertHelper, which adds nesessary metadata to
23 template <bool PreserveNames>
24 class CGBuilderInserter
25 : protected llvm::IRBuilderDefaultInserter<PreserveNames> {
27 CGBuilderInserter() : CGF(nullptr) {}
28 explicit CGBuilderInserter(CodeGenFunction *CGF) : CGF(CGF) {}
31 /// \brief This forwards to CodeGenFunction::InsertHelper.
32 void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name,
34 llvm::BasicBlock::iterator InsertPt) const;
36 void operator=(const CGBuilderInserter &) LLVM_DELETED_FUNCTION;
41 // Don't preserve names on values in an optimized build.
43 #define PreserveNames false
45 #define PreserveNames true
47 typedef CGBuilderInserter<PreserveNames> CGBuilderInserterTy;
48 typedef llvm::IRBuilder<PreserveNames, llvm::ConstantFolder,
49 CGBuilderInserterTy> CGBuilderTy;
52 } // end namespace CodeGen
53 } // end namespace clang