From 9f8742c05adb604cbd7a8300a74ccd3f3831e5ed Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Fri, 12 Sep 2014 13:57:48 +0200 Subject: [PATCH] Use filename spelling as #included. --- .../cling/lib/Interpreter/ForwardDeclPrinter.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.cpp b/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.cpp index b88c53b..a3d70a1 100644 --- a/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.cpp +++ b/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.cpp @@ -160,7 +160,22 @@ namespace cling { PLocs.push_back(PLoc); PLoc = m_SMgr.getPresumedLoc(PLoc.getIncludeLoc()); } - std::string file = PLocs[PLocs.size() -1].getFilename(); + + clang::SourceLocation includeLoc = m_SMgr.getSpellingLoc(PLocs[PLocs.size() - 1].getIncludeLoc()); + bool invalid = true; + const char* includeText = m_SMgr.getCharacterData(includeLoc, &invalid); + assert(!invalid && "Invalid source data"); + assert(includeText && "Cannot find #include location"); + assert((includeText[0] == '<' || includeText[0] == '"') + && "Unexpected #include delimiter"); + char endMarker = includeText[0] == '<' ? '>' : '"'; + ++includeText; + const char* includeEnd = includeText; + while (*includeEnd != endMarker && *includeEnd) { + ++includeEnd; + } + assert(includeEnd && "Cannot find end of #include file name"); + // assert ( file.length() != 0 && "Filename Should not be blank"); Out() << " __attribute__((annotate(\"$clingAutoload$" << llvm::StringRef(includeText, includeEnd - includeText); -- 1.8.2