summaryrefslogtreecommitdiffstats
path: root/lib/Frontend/CacheTokens.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Frontend/CacheTokens.cpp')
-rw-r--r--lib/Frontend/CacheTokens.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/Frontend/CacheTokens.cpp b/lib/Frontend/CacheTokens.cpp
index 06a1fd2..20b5189 100644
--- a/lib/Frontend/CacheTokens.cpp
+++ b/lib/Frontend/CacheTokens.cpp
@@ -247,17 +247,16 @@ void PTHWriter::EmitToken(const Token& T) {
} else {
// We cache *un-cleaned* spellings. This gives us 100% fidelity with the
// source code.
- const char* s = T.getLiteralData();
- unsigned len = T.getLength();
+ llvm::StringRef s(T.getLiteralData(), T.getLength());
// Get the string entry.
- llvm::StringMapEntry<OffsetOpt> *E = &CachedStrs.GetOrCreateValue(s, s+len);
+ llvm::StringMapEntry<OffsetOpt> *E = &CachedStrs.GetOrCreateValue(s);
// If this is a new string entry, bump the PTH offset.
if (!E->getValue().hasOffset()) {
E->getValue().setOffset(CurStrOffset);
StrEntries.push_back(E);
- CurStrOffset += len + 1;
+ CurStrOffset += s.size() + 1;
}
// Emit the relative offset into the PTH file for the spelling string.
OpenPOWER on IntegriCloud