LLVM_ATTRIBUTE_USED void dump() const;
LLVM_ATTRIBUTE_USED void dump(SourceManager &SM) const;
+ void dump(llvm::raw_ostream &OS, SourceManager *SM) const;
static bool classof(const Comment *) { return true; }
#include "clang/AST/Comment.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
namespace clang {
namespace comments {
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 {};
} // unnamed namespace
-void Comment::dump() const {
- CommentDumper D(llvm::errs(), NULL);
- D.dumpSubtree(this);
- llvm::errs() << '\n';
-}
-
-void Comment::dump(SourceManager &SM) const {
- CommentDumper D(llvm::errs(), &SM);
+void Comment::dump(llvm::raw_ostream &OS, SourceManager *SM) const {
+ CommentDumper D(llvm::errs(), SM);
D.dumpSubtree(this);
llvm::errs() << '\n';
}