From: Axel Naumann Date: Mon, 22 Sep 2014 13:52:38 +0000 (+0200) Subject: Do not use (non-0-term) data(); factor out the tag. X-Git-Tag: v6-02-00-rc1~35 X-Git-Url: https://root.cern.ch/gitweb?p=root.git;a=commitdiff_plain;h=44028263c6ce3b509726f1e9b24faefdcc283696 Do not use (non-0-term) data(); factor out the tag. --- 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,