Do not use (non-0-term) data(); factor out the tag.

This commit is contained in:
Axel Naumann 2014-09-22 15:52:38 +02:00 committed by sftnight
parent 1027dd6e90
commit 7cb4bbbaf7

View File

@ -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,