slycelote / caide-cpp-inliner

Transform a C++ program consisting of multiple source files and headers into a single self-contained source file without any external dependencies (except for standard system headers). Unused code is not included in the resulting file.
Other
32 stars 12 forks source link

Some comments aren't removed #2

Open AlCash07 opened 7 years ago

AlCash07 commented 7 years ago

Comments in global namespace aren't removed, and I didn't find an option to change this behavior. Comments inside classes that are at least partially inlined are also affected.

slycelote commented 7 years ago

You should probably clarify exact scenarios when it happens. Doxygen or, with -fparse-all-comments, 'almost Doxygen' comments attached to unused declarations definitely get removed. I know that trailing comments don't. Anything else?

AlCash07 commented 7 years ago

In the following example both comments aren't removed without -fparse-all-comments, and with this option the one inside class is removed: http://ideone.com/BSoOtw. Looks like, standalone comments are always ignored.

slycelote commented 7 years ago

The first comment is removed with -fparse-all-comments or if it is changed to doxygen style, as expected. The second comment is not removed because it is attached to a used function.

AlCash07 commented 7 years ago

I think it would make sense to attach a comment to a function only if there are no empty lines between them.

slycelote commented 7 years ago

I believe that's how Doxygen and, by extension, clang parser works. Could probably be hacked around but I don't think it's worth it.