clang  3.7.0
CGBuilder.h
Go to the documentation of this file.
1 //===-- CGBuilder.h - Choose IRBuilder implementation ----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_LIB_CODEGEN_CGBUILDER_H
11 #define LLVM_CLANG_LIB_CODEGEN_CGBUILDER_H
12 
13 #include "llvm/IR/IRBuilder.h"
14 
15 namespace clang {
16 namespace CodeGen {
17 
18 class CodeGenFunction;
19 
20 /// \brief This is an IRBuilder insertion helper that forwards to
21 /// CodeGenFunction::InsertHelper, which adds necessary metadata to
22 /// instructions.
23 template <bool PreserveNames>
25  : protected llvm::IRBuilderDefaultInserter<PreserveNames> {
26 public:
27  CGBuilderInserter() : CGF(nullptr) {}
28  explicit CGBuilderInserter(CodeGenFunction *CGF) : CGF(CGF) {}
29 
30 protected:
31  /// \brief This forwards to CodeGenFunction::InsertHelper.
32  void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name,
33  llvm::BasicBlock *BB,
34  llvm::BasicBlock::iterator InsertPt) const;
35 private:
36  void operator=(const CGBuilderInserter &) = delete;
37 
38  CodeGenFunction *CGF;
39 };
40 
41 // Don't preserve names on values in an optimized build.
42 #ifdef NDEBUG
43 #define PreserveNames false
44 #else
45 #define PreserveNames true
46 #endif
48 typedef llvm::IRBuilder<PreserveNames, llvm::ConstantFolder,
50 #undef PreserveNames
51 
52 } // end namespace CodeGen
53 } // end namespace clang
54 
55 #endif
CGBuilderInserter(CodeGenFunction *CGF)
Definition: CGBuilder.h:28
CGBuilderInserter< PreserveNames > CGBuilderInserterTy
Definition: CGBuilder.h:47
#define PreserveNames
Definition: CGBuilder.h:45
llvm::IRBuilder< PreserveNames, llvm::ConstantFolder, CGBuilderInserterTy > CGBuilderTy
Definition: CGBuilder.h:49
void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock *BB, llvm::BasicBlock::iterator InsertPt) const
This forwards to CodeGenFunction::InsertHelper.
This is an IRBuilder insertion helper that forwards to CodeGenFunction::InsertHelper, which adds necessary metadata to instructions.
Definition: CGBuilder.h:24