llvm/clang/unittests/CodeGen/CodeGenExternalTest.cpp

//===- unittests/CodeGen/CodeGenExternalTest.cpp - test external CodeGen -===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "TestCompiler.h"

#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/GlobalDecl.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/CodeGen/CodeGenABITypes.h"
#include "clang/CodeGen/ModuleBuilder.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Parse/ParseAST.h"
#include "clang/Sema/Sema.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/Triple.h"
#include "gtest/gtest.h"

usingnamespacellvm;
usingnamespaceclang;

namespace {

// Mocks up a language using Clang code generation as a library and
// tests some basic functionality there.
//   - CodeGen->GetAddrOfGlobal
//   - CodeGen::convertTypeForMemory
//   - CodeGen::getLLVMFieldNumber

static const bool DebugThisTest =;

// forward declarations
struct MyASTConsumer;
static void test_codegen_fns(MyASTConsumer *my);
static bool test_codegen_fns_ran;

// This forwards the calls to the Clang CodeGenerator
// so that we can test CodeGen functions while it is open.
// It accumulates toplevel decls in HandleTopLevelDecl and
// calls test_codegen_fns() in HandleTranslationUnit
// before forwarding that function to the CodeGenerator.

struct MyASTConsumer : public ASTConsumer {};

void MyASTConsumer::Initialize(ASTContext &Context) {}

bool MyASTConsumer::HandleTopLevelDecl(DeclGroupRef DG) {}

void MyASTConsumer::HandleInlineFunctionDefinition(FunctionDecl *D) {}

void MyASTConsumer::HandleInterestingDecl(DeclGroupRef D) {}

void MyASTConsumer::HandleTranslationUnit(ASTContext &Context) {}

void MyASTConsumer::HandleTagDeclDefinition(TagDecl *D) {}

void MyASTConsumer::HandleTagDeclRequiredDefinition(const TagDecl *D) {}

void MyASTConsumer::HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {}

void MyASTConsumer::HandleTopLevelDeclInObjCContainer(DeclGroupRef D) {}

void MyASTConsumer::HandleImplicitImportDecl(ImportDecl *D) {}

void MyASTConsumer::CompleteTentativeDefinition(VarDecl *D) {}

void MyASTConsumer::AssignInheritanceModel(CXXRecordDecl *RD) {}

void MyASTConsumer::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {}

void MyASTConsumer::HandleVTable(CXXRecordDecl *RD) {}

ASTMutationListener *MyASTConsumer::GetASTMutationListener() {}

ASTDeserializationListener *MyASTConsumer::GetASTDeserializationListener() {}

void MyASTConsumer::PrintStats() {}

bool MyASTConsumer::shouldSkipFunctionBody(Decl *D) {}

const char TestProgram[] =;

// This function has the real test code here
static void test_codegen_fns(MyASTConsumer *my) {}

TEST(CodeGenExternalTest, CodeGenExternalTest) {}

} // end anonymous namespace