1 //===- unittests/CodeGen/BufferSourceTest.cpp - MemoryBuffer source tests -===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "TestCompiler.h"
11 #include "clang/AST/ASTContext.h"
12 #include "clang/AST/RecursiveASTVisitor.h"
13 #include "clang/Basic/TargetInfo.h"
14 #include "clang/CodeGen/ModuleBuilder.h"
15 #include "clang/Frontend/CompilerInstance.h"
16 #include "clang/Lex/Preprocessor.h"
17 #include "clang/Parse/ParseAST.h"
18 #include "clang/Sema/Sema.h"
19 #include "llvm/IR/LLVMContext.h"
20 #include "llvm/Support/MemoryBuffer.h"
21 #include "llvm/TargetParser/Host.h"
22 #include "llvm/TargetParser/Triple.h"
23 #include "gtest/gtest.h"
26 using namespace clang
;
30 TEST(BufferSourceTest
, EmitCXXGlobalInitFunc
) {
31 // Emitting constructors for global objects involves looking
32 // at the source file name. This makes sure that we don't crash
33 // if the source file is a memory buffer.
34 const char TestProgram
[] =
35 "class EmitCXXGlobalInitFunc "
38 " EmitCXXGlobalInitFunc() {} "
40 "EmitCXXGlobalInitFunc test; ";
42 clang::LangOptions LO
;
45 TestCompiler
Compiler(LO
);
46 Compiler
.init(TestProgram
);
48 clang::ParseAST(Compiler
.compiler
.getSema(), false, false);
51 } // end anonymous namespace