summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2018-03-23 00:07:18 +0000
committerJordan Rose <jordan_rose@apple.com>2018-03-23 00:07:18 +0000
commit1e879d8be6322f9f974db3dc7dc4279ea46b4645 (patch)
tree4d19017996100e775e6eda980bec9bf4101c384f /clang/lib/AST/Decl.cpp
parent37eeb32046d27f78d5ef52f02b81dfd295281fff (diff)
downloadbcm5719-llvm-1e879d8be6322f9f974db3dc7dc4279ea46b4645.tar.gz
bcm5719-llvm-1e879d8be6322f9f974db3dc7dc4279ea46b4645.zip
Sink PrettyDeclStackTrace down to the AST library
...and add some very basic stack trace entries for module building. This would have helped track down rdar://problem/38434694 sooner. llvm-svn: 328276
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r--clang/lib/AST/Decl.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 35364d6abcb..ed80dd8fca2 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -27,6 +27,7 @@
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExternalASTSource.h"
#include "clang/AST/ODRHash.h"
+#include "clang/AST/PrettyDeclStackTrace.h"
#include "clang/AST/PrettyPrinter.h"
#include "clang/AST/Redeclarable.h"
#include "clang/AST/Stmt.h"
@@ -76,6 +77,24 @@ Decl *clang::getPrimaryMergedDecl(Decl *D) {
return D->getASTContext().getPrimaryMergedDecl(D);
}
+void PrettyDeclStackTraceEntry::print(raw_ostream &OS) const {
+ SourceLocation Loc = this->Loc;
+ if (!Loc.isValid() && TheDecl) Loc = TheDecl->getLocation();
+ if (Loc.isValid()) {
+ Loc.print(OS, Context.getSourceManager());
+ OS << ": ";
+ }
+ OS << Message;
+
+ if (auto *ND = dyn_cast_or_null<NamedDecl>(TheDecl)) {
+ OS << " '";
+ ND->getNameForDiagnostic(OS, Context.getPrintingPolicy(), true);
+ OS << "'";
+ }
+
+ OS << '\n';
+}
+
// Defined here so that it can be inlined into its direct callers.
bool Decl::isOutOfLine() const {
return !getLexicalDeclContext()->Equals(getDeclContext());
OpenPOWER on IntegriCloud