[cfe-dev] How clang works, whant to learn compiler internals
Aleksei Sidorin via cfe-dev
cfe-dev at lists.llvm.org
Tue Oct 18 02:08:46 PDT 2016
Ivan,
-Xclang option is for passing arguments to clang directly (like for
'-cc1'-style call). With "-cc1" specified you don't need -Xclang, just
-cc1 -std=c++1z -ast-dump -fsyntax-only test_deb.cpp.
18.10.2016 11:58, Ivan Kush via cfe-dev пишет:
> thanks a lot!
> with "-cc1" the compiler doesn't understand "-Xclang" parameter.
>
> -cc1 -std=c++1z -Xclang -ast-dump -fsyntax-only test_deb.cpp
>
> So deleted "-Xclang", but in that case AST doesn't output to console.
>
> -cc1 -std=c++1z -ast-dump -fsyntax-only test_deb.cpp
>
> Does someone know what parameters should pass in that case, in order
> to output AST to console?
> --
> Best wishes,
> Ivan Kush
> 18.10.2016, 11:12, "Serge Pavlov" <sepavloff at gmail.com>:
>> You need to pass argument "-cc1" to the compiler in debug session. In
>> your case parameters must be:
>> -cc1 -std=c++1z -Xclang -ast-dump -fsyntax-only test_deb.cpp
>> Without "-cc1" clang works as driver executing other tools to make
>> job, with "-cc1" it works as compiler.
>> Thanks,
>> --Serge
>> 2016-10-18 14:54 GMT+07:00 Ivan Kush via cfe-dev
>> <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>>:
>>
>> I want to learn clang internals and how it works. But
>> llvm::sys::ExecuteAndWait executes in the debugger and that's
>> all, finish, console output with my AST (I passes to clang
>> "-ast-dump"). It didn't jump in the Lexer.cpp, Sema.cpp, etc.
>> What should I do in the debugger, in order to see how Lexer, Sema
>> work?
>> My steps in the debugger:
>> 1) compiled debug version of llvm and clang
>> 2) created a source file "test_deb.cpp" with the following code
>> enum class Enum : int
>> {
>> kOne,
>> kTwo
>> };
>> int f(int x) {
>> int result = (x / 42);
>> return result;
>> }
>> int main()
>> {
>> return f(4);
>> }
>> 3) launch clang-4.0 in in the debugger with the following parameters:
>> -std=c++1z -Xclang -ast-dump -fsyntax-only test_deb.cpp
>> 4) and begin to learn how all work:
>> the "int main" in driver.cpp
>> in driver.cpp is called "ExecuteCompilation" of "Driver"
>> TheDriver.ExecuteCompilation(*C, FailingCommands);
>> where called "ExecuteJobs" of "Compilation" (the file
>> Compilation.cpp):
>> C.ExecuteJobs(C.getJobs(), FailingCommands);
>> in the func ExecuteJobs called ExecuteCommand
>> if (int Res = ExecuteCommand(Job, FailingCommand)) {
>> that calls "Execute" of "Command" (the file Jobs.cpp):
>> where called a func "ExecuteAnddWait" of "llvm::sys"
>> return llvm::sys::ExecuteAndWait(Executable, Argv.data(),
>> /*env*/ nullptr,
>> Redirects, /*secondsToWait*/ 0,
>> /*memoryLimit*/ 0, ErrMsg,
>> ExecutionFailed);
>> but the "Executable" is "...path/clang-4.0" - the file, that I
>> launched in the debugger o__O
>> 5) so llvm::sys::ExecuteAndWait(Executable,...) is called and
>> that's all, finish, console output with my AST. It didn't jump in
>> the Lexer.cpp, Sema.cpp, etc.
>> What should I do in the debugger, in order to see how Lexer, Sema
>> work?
>> --
>> Best wishes,
>> Ivan Kush
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
--
Best regards,
Aleksei Sidorin
Software Engineer,
IMSWL-IMCG, SRR, Samsung Electronics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161018/7b36d0d5/attachment.html>
More information about the cfe-dev
mailing list