diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2012-07-18 16:30:42 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2012-07-18 16:30:42 +0000 |
commit | 761447cd98eb6547f815f08fb1593733c26de2a8 (patch) | |
tree | a980f6fd1702be45d966e8845f7232fbeec4fbd6 /clang/lib/AST/Comment.cpp | |
parent | ab34919413560f884fbda747b493c6d5a40c3456 (diff) | |
download | bcm5719-llvm-761447cd98eb6547f815f08fb1593733c26de2a8.tar.gz bcm5719-llvm-761447cd98eb6547f815f08fb1593733c26de2a8.zip |
On Darwin, the linker removes functions in CommentDumper.o (Comment::dump())
despite __attribute__(__used__). As explained by Argyrios,
> .a archive files do some stripping of their own and they remove .o files that
> contain functions that are not referenced by any other .o file.
The fix is to use these functions from another .o file.
Thanks, Argyrios!
llvm-svn: 160437
Diffstat (limited to 'clang/lib/AST/Comment.cpp')
-rw-r--r-- | clang/lib/AST/Comment.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp index 1520d134172..e215e63dec9 100644 --- a/clang/lib/AST/Comment.cpp +++ b/clang/lib/AST/Comment.cpp @@ -9,6 +9,7 @@ #include "clang/AST/Comment.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" namespace clang { namespace comments { @@ -27,6 +28,19 @@ const char *Comment::getCommentKindName() const { llvm_unreachable("Unknown comment kind!"); } +void Comment::dump() const { + // It is important that Comment::dump() is defined in a different TU than + // Comment::dump(raw_ostream, SourceManager). If both functions were defined + // in CommentDumper.cpp, that object file would be removed by linker because + // none of its functions are referenced by other object files, despite the + // LLVM_ATTRIBUTE_USED. + dump(llvm::errs(), NULL); +} + +void Comment::dump(SourceManager &SM) const { + dump(llvm::errs(), &SM); +} + namespace { struct good {}; struct bad {}; |