aboutsummaryrefslogtreecommitdiff
path: root/Driver/PrintPreprocessedOutput.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Driver/PrintPreprocessedOutput.cpp')
-rw-r--r--Driver/PrintPreprocessedOutput.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/Driver/PrintPreprocessedOutput.cpp b/Driver/PrintPreprocessedOutput.cpp
index d5c5b9a08b..a8bc4e40d2 100644
--- a/Driver/PrintPreprocessedOutput.cpp
+++ b/Driver/PrintPreprocessedOutput.cpp
@@ -18,6 +18,7 @@
#include "clang/Lex/Pragma.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Config/config.h"
#include <cstdio>
@@ -123,13 +124,13 @@ namespace {
class PrintPPOutputPPCallbacks : public PPCallbacks {
Preprocessor &PP;
unsigned CurLine;
- std::string CurFilename;
bool EmittedTokensOnThisLine;
DirectoryLookup::DirType FileType;
+ llvm::SmallString<512> CurFilename;
public:
PrintPPOutputPPCallbacks(Preprocessor &pp) : PP(pp) {
CurLine = 0;
- CurFilename = "<uninit>";
+ CurFilename += "<uninit>";
EmittedTokensOnThisLine = false;
FileType = DirectoryLookup::NormalHeaderDir;
}
@@ -237,7 +238,9 @@ void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc,
Loc = SourceMgr.getLogicalLoc(Loc);
CurLine = SourceMgr.getLineNumber(Loc);
- CurFilename = Lexer::Stringify(SourceMgr.getSourceName(Loc));
+ CurFilename.clear();
+ CurFilename += SourceMgr.getSourceName(Loc);
+ Lexer::Stringify(CurFilename);
FileType = FileType;
if (EmittedTokensOnThisLine) {