From 44028263c6ce3b509726f1e9b24faefdcc283696 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Mon, 22 Sep 2014 15:52:38 +0200 Subject: [PATCH] Do not use (non-0-term) data(); factor out the tag. --- interpreter/cling/lib/Interpreter/AutoloadCallback.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/interpreter/cling/lib/Interpreter/AutoloadCallback.cpp b/interpreter/cling/lib/Interpreter/AutoloadCallback.cpp index 524c4a0..6e64cf5 100644 --- a/interpreter/cling/lib/Interpreter/AutoloadCallback.cpp +++ b/interpreter/cling/lib/Interpreter/AutoloadCallback.cpp @@ -24,6 +24,10 @@ #include "cling/Interpreter/AutoloadCallback.h" #include "cling/Interpreter/Transaction.h" +namespace { + constexpr const char annoTag[] = "$clingAutoload$"; + constexpr const size_t lenAnnoTag = sizeof(annoTag) - 1; +} using namespace clang; @@ -40,8 +44,8 @@ namespace cling { = sema.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Level::Note, "Type : %0 , Full Path: %1")*/; - if (header.startswith(llvm::StringRef("$clingAutoload$", 15))) - sema.Diags.Report(l, id) << name << header.drop_front(15); + if (header.startswith(llvm::StringRef(annoTag, lenAnnoTag))) + sema.Diags.Report(l, id) << name << header.drop_front(lenAnnoTag); } @@ -60,7 +64,7 @@ namespace cling { void InsertIntoAutoloadingState (Decl* decl, llvm::StringRef annotation) { assert(!annotation.empty() && "Empty annotation!"); - if (!annotation.startswith(llvm::StringRef("$clingAutoload$", 15))) { + if (!annotation.startswith(llvm::StringRef(annoTag, lenAnnoTag))) { // not an autoload annotation. return; } @@ -73,7 +77,8 @@ namespace cling { const DirectoryLookup* LookupFrom = 0; const DirectoryLookup* CurDir = 0; - FE = m_PP->LookupFile(fileNameLoc, annotation.data() + 15, isAngled, + FE = m_PP->LookupFile(fileNameLoc, + annotation.drop_front(lenAnnoTag), isAngled, LookupFrom, CurDir, /*SearchPath*/0, /*RelativePath*/ 0, /*suggestedModule*/0, /*SkipCache*/false, /*OpenFile*/ false, -- 1.8.2