I have a working InstVisitor, thanks to the answer to my prior question. Does LLVM make these InstVisitors traverse the IR using DFS or BFS?
DFS. Check the source here (relevant lines 88 to 108):
http://llvm.org/docs/doxygen/html/InstVisitor_8h_source.html#l00088
Related
I am looking for ctwill's (literate) source code.
I did not find it in CTAN or through Knuth's page.
The links in this previous question (ftp://ftp.cs.stanford.edu/pub/ctwill/ and ftp://labrea.stanford.edu/pub/ctwill/) don't seem to work. (And the same links appear in this cweb repository, so no luck there either.)
Any help is deeply appreciated!
Actually, the repository for cweb binaries contains the source for ctwill.
The reason why this is not immediately apparent is because of how ctwill is generated. Indeed, it is a modified version of cweave, which is generated from the very source files of cweave using the changefile mechanism devised by Knuth.
I am new to gojs and trying to play with flowchart example. The current example can't differentiate the output nodes of a Condition node and i want to fix it. Is there any way to distinguish them other than simple labeling them?
Thanks for pointing out the error in the sample. We have fixed the code in the sample -- please look again at the latest code at https://gojs.net/latest/samples/flowchart.html.
I've been able to implement an ASTFrontendAction to create an ASTConsumer, which uses a RescursiveASTVisitor to traverse a translation unit decl, thereby visiting all the nodes of an AST for a given source file. I do this by implementing a ToolAction which is passed to ClangTool::run(ToolAction *action). This tool overrides the ToolAction::runInvocation member function to do some processing between each call to my ASTFrontendAction. So far so good, everything is working as expected, and my custom clang tool is helping me better explore a rather large, over 15 years old code base.
However, every time I want to run my tool, I need to do a full blown parse of the ASTs. As I mentioned, this is a rather large code base, so it takes a while to do a single run. I have gathered, by looking through the code, that it is possible to create and traverse an AST from a saved file, rather than perform the parse. Googling around confirmed that it's possible to save an AST, and by looking at the ClangTool and ASTUnit API, it seems it's pretty easy to do.
While it seems straightforward to save the AST, I have no idea how to make use of a saved AST when running my custom clang tool. Looking at the code path for running a tool, I see there is a point where the AST is created either by parsing a source file or by reading it from a file. What I would like to do is have all my ASTs available in a file(s), so that each run of my tool will create the ASTs from a file, and not need to perform a full parse (which, I assume would be much faster).
Could someone please help? Thanks in advance!
This worked for me:
clang::CompilerInstance CI;
CI.createDiagnostics();
std::shared_ptr<clang::TargetOptions> TO = std::make_shared<clang::TargetOptions>();
TO->Triple = "x86_64-pc-win32"; // see clang -v
CI.setTarget(clang::TargetInfo::CreateTargetInfo(CI.getDiagnostics(), TO));
std::unique_ptr<ASTUnit> ast = ASTUnit::LoadFromASTFile("TheAstFile.ast",
CI.getPCHContainerReader(),
ASTUnit::LoadEverything,
&CI.getDiagnostics(),
CI.getFileSystemOpts());
MyAstConsumer consumer(ast->getASTContext());
consumer.HandleTranslationUnit(ast->getASTContext());
I am currently trying out Task #2 in the 2016/2017 COCI. Although I have attempted to solve this problem, I couldn't do it.
So, I looked at the solution and it said,
In order to solve this task, we need to find any path Barry can take
from the initial position to any position in the last column. We can
do this by using BFS or DFS algorithm, after which we need to
construct the path. Finally, all that’s left is to format the path
according to the task.
So I went ahead and studied the BFS and DFS algorithm. However, I am not sure how I can implement this algorithm into my program.
Although I can find certain elements in a tree with the algorithm, I don't know how to use it to find a pathway.
So can someone tell my, briefly, how to use the BFS/DFS algorithm to solve the programming problem?
Thanks in advance.
This is the contest page:
http://hsin.hr/coci/archive/2016_2017/contest1_tasks.pdf
What you could do is convert the whole map into a tree.
Here is a diagram I made to demonstrate what I exactly mean:Click here to view the image
Hope that made sense.
Is there any open source code for extracting API call sequences and control flow graphs from assembly code?
I use a disassembler to come up with the assembly code of a PE file first. And now I need to extract the API call sequences and of course the cfg.
I'd suggest you to have a look at LLVM in combination with clang. There you are able to parse the call tree of the clang-generated bit code, which is an intermediate language and can be compiled to a target architecture afterwards. The CallGraphSCCPass should be helpful.
Edit As you are needing a disassembly first maybe x86 Disassembler with LLVM is more useful.