Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to use the compilation database with clang-expand #5

Open
razeh opened this issue Mar 28, 2017 · 4 comments
Open

Is there a way to use the compilation database with clang-expand #5

razeh opened this issue Mar 28, 2017 · 4 comments
Assignees

Comments

@razeh
Copy link

razeh commented Mar 28, 2017

My list of source files is larger than can be passed on the command line; is there a way to use a LLVM compilation database?

@goldsborough
Copy link
Owner

It should be possible because the compilation database was really made for this, but when I tried it I ran into some difficulties. Have you tried passing the db to the -p flag? All clang tools have a -p option for a build path containing the db.
If not and you really want it to work with the compilation database, I'd be glad if you can help looking into it. I'm also interested in the lookup times you will experience with more source files than can be passed on the command line.
Let me know.

@razeh
Copy link
Author

razeh commented Mar 29, 2017

If you run clang-expand with just -p, clang-expand complains about not enough positional parameters --- and it looks like this is coming from within clang.

How does adding an option that tells clang expand to use all of the entries in the build database for the source files sound?

@goldsborough
Copy link
Owner

You still have to pass the source file of the code you have to expand, so I think you're just missing that positional location? Try something like:
clang-expand file_containing_expansion.cpp -p path_containing_compile_commands --line <l> --column <c>
Either way, we'll still need something to read the compilation database as you suggest. In clang-expand.cpp, it should be as simple as merging the database compilations with the source list somehow:

  const auto& sources = options.getSourcePathList();
  auto& db = options.getCompilations();

Will look into it.

@razeh
Copy link
Author

razeh commented Mar 29, 2017

If you add the positional argument, you do get further:
run /scratch/razeh/src/clang-expand/source/search.cpp:54
source: Escape.C
run /scratch/razeh/src/clang-expand/source/search.cpp:61
run /scratch/razeh/src/clang-expand/source/search.cpp:87
allCompileCommands.size()!
error: no input files
error: unable to handle compilation, expected exactly one compiler job in ''

It is reading in the compilation database --- as you can see by the debug output I've added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants