forked from loarabia/Clang-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CItutorial1.cpp
37 lines (32 loc) · 1.29 KB
/
CItutorial1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*** CItutorial1.cpp *****************************************************
* This code is licensed under the New BSD license.
* See LICENSE.txt for details.
*
* The _CI tutorials remake the original tutorials but using the
* CompilerInstance object which has as one of its purpose to create commonly
* used Clang types.
*****************************************************************************/
#include "llvm/Support/Host.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Basic/TargetInfo.h"
/******************************************************************************
* This tutorial just shows off the steps needed to build up to a Preprocessor
* object. Note that the order below is important.
*****************************************************************************/
int main()
{
using clang::CompilerInstance;
using clang::TargetOptions;
using clang::TargetInfo;
CompilerInstance ci;
ci.createDiagnostics(0,NULL);
TargetOptions to;
to.Triple = llvm::sys::getDefaultTargetTriple();
TargetInfo *pti = TargetInfo::CreateTargetInfo(ci.getDiagnostics(), to);
ci.setTarget(pti);
ci.createFileManager();
ci.createSourceManager(ci.getFileManager());
ci.createPreprocessor();
return 0;
}