[cfe-dev] Tool programming. Where can I get default platform configuration ?
Y. Orçun Gökbulut
orcun.gokbulut at zinekengine.com
Wed Sep 5 00:29:54 PDT 2012
Hello again João,
I'm using Visual Studio 2010 and I have managed to clear some of the
produced errors.
But right now I'm struggling with three errors;
* C:/Program Files (x86)/Microsoft Visual Studio
10.0/VC/include\new(49,15) : error: function declared 'cdecl' here was
previously declared without calling convention [Semantic Issue]
* C:/Program Files (x86)/Microsoft Visual Studio
10.0/VC/include\xstring(2067,21) : error: use of undeclared identifier
'char16_t' [Semantic Issue]
* C:/Program Files (x86)/Microsoft Visual Studio
10.0/VC/include\xlocale(1235,29) : error: use of undeclared identifier
'char32_t' [Semantic Issue]
In addition to these, after changing some parameters diagnostics started
acting like crazy. I didn't do anything about the diagnostics. Here is some
diagnostic outputs;
In included file:
In included file:
In included file:
In included file:
In included file:
In included file:
In included file:
In included file:
In included file:
In included file:
In included file:
In included file:
In included file:
In included file:
In included file:
In included file:
In included file:
error: function declared 'cdecl' here was previously declared without
calling convention
note: previous declaration is here
error: function declared 'cdecl' here was previously declared without
calling convention
note: previous declaration is here
error: function declared 'cdecl' here was previously declared without
calling convention
note: previous declaration is here
error: function declared 'cdecl' here was previously declared without
calling convention
note: previous declaration is here
I think I'm getting closer :D
Thank you and have a nice day,
Orçun
Here is the code so far;
int main_compiler_instance(int argc, const char** argv)
{
// Default Windows Platform Arguments
// These arguments has been taken from cmake -v
const char* Arguments[] =
{
"-cc1",
"-I", ".",
"-I", "..",
"-I", "../ZEFoundation",
"-v",
"-fmath-errno",
"-ferror-limit", "19",
"-fmessage-length", "150",
"-fms-extensions",
"-fms-compatibility",
"-fmsc-version=1300",
"-fdelayed-template-parsing",
"-fno-rtti",
"-fcolor-diagnostics",
"-x", "c++", // NOT WORKING !!! It is working in clang.exe
command line but not here. I don't know why...
"-std=c++0x",
"-fsyntax-only"
};
size_t ArgumentCount = sizeof(Arguments) / sizeof(const char*);
CompilerInstance Compiler;
Compiler.createDiagnostics(0, NULL);
// Target Options
TargetOptions TO;
TO.Triple = llvm::sys::getDefaultTargetTriple();
TargetInfo* TI =
TargetInfo::CreateTargetInfo(Compiler.getDiagnostics(), TO);
TI->setCXXABI(TargetCXXABI::CXXABI_Microsoft);
Compiler.setTarget(TI);
CompilerInvocation Invocation;
bool Result = CompilerInvocation::CreateFromArgs(Invocation,
Arguments, Arguments + ArgumentCount, Compiler.getDiagnostics());
// -x c++ not working so; (I'm not sure whether it Works or not)
CompilerInvocation::setLangDefaults(*Invocation.getLangOpts(),
InputKind::IK_CXX, LangStandard::Kind::lang_cxx11);
// Resource Directory
if (Invocation.getHeaderSearchOpts().UseBuiltinIncludes &&
Invocation.getHeaderSearchOpts().ResourceDir.empty())
{
// I'm going to distribute clang runtime include directory in
tools binary directory.
// Like if the path of tools binary is c:\tool\codegen.exe then
include files will be in c:\tool\include
llvm::sys::Path BinaryDir =
llvm::sys::Path::GetMainExecutable(argv[0], main_compiler_instance);
BinaryDir.eraseComponent();
Invocation.getHeaderSearchOpts().ResourceDir = BinaryDir.str();
}
// Include Path
// Thanks for the patch João Matos.
std::vector<std::string> SystemDirs =
clang::driver::GetWindowsSystemIncludeDirs();
for(size_t i = 0; i < SystemDirs.size(); ++i)
Invocation.getHeaderSearchOpts().AddPath(SystemDirs[i],
frontend::System, false, false, true, true);
Invocation.getHeaderSearchOpts().AddPath(Invocation.getHeaderSearchOpts().Re
sourceDir + "/include", clang::frontend::System, false, false, true, true);
// Compiler Definitions
//Invocation.getPreprocessorOpts().addMacroDef("_WCHAR_T_DEFINED");
Compiler.setInvocation(&Invocation);
Compiler.createFileManager();
Compiler.createSourceManager(Compiler.getFileManager());
Compiler.createPreprocessor();
Compiler.setASTConsumer(new ZECodeGeneratorASTConsumer());
Compiler.createASTContext();
const FileEntry *pFile = Compiler.getFileManager().getFile(argv[1]);
Compiler.getSourceManager().createMainFileID(pFile);
Compiler.getDiagnosticClient().BeginSourceFile(Compiler.getLangOpts(),
&Compiler.getPreprocessor());
ParseAST(Compiler.getPreprocessor(), &Compiler.getASTConsumer(),
Compiler.getASTContext(), false, clang::TU_Complete, NULL, true);
Compiler.getDiagnosticClient().EndSourceFile();
return 1;
}
From: cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu] On
Behalf Of Y. Orçun Gökbulut
Sent: Tuesday, September 04, 2012 1:32 PM
To: 'João Matos'
Cc: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] Tool programming. Where can I get default platform
configuration ?
Hi João,
Thank you so much for your reply and patch.
I have applied your patch and modified my driver according to your code. It
really automated things like getting system paths but I still got errors in
system headers (Visual Studio's c library).
I think problem is clang can not parse visual studio c library headers
becouse it could not found Microsoft specific type_info struct or
__CHAR_BIT__.
I just can figure out the difference between a clang driver with my own
code. They are doing the same thing. They are using compiler invocation so I
do it too. I'm really stuck.
Thank you,
Orçun
From: João Matos [mailto:ripzonetriton at gmail.com]
Sent: Saturday, September 01, 2012 4:10 PM
To: Y. Orçun Gökbulut
Cc: cfe-dev at cs.uiuc.edu <mailto:cfe-dev at cs.uiuc.edu>
Subject: Re: [cfe-dev] Tool programming. Where can I get default platform
configuration ?
Hi. I'm also using Clang for a similiar tool (generate reflection data for
C++), check out the attached source file 'ParserInit.cpp' to see how I
initialize it.
You're also gonna need the attached patch applied to Clang, it exposes the
Windows SDK headers locations.
--
João Matos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120905/631b6fd1/attachment.html>
More information about the cfe-dev
mailing list