本文整理汇总了C++中SmallVectorImpl::data方法的典型用法代码示例。如果您正苦于以下问题:C++ SmallVectorImpl::data方法的具体用法?C++ SmallVectorImpl::data怎么用?C++ SmallVectorImpl::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmallVectorImpl
的用法示例。
在下文中一共展示了SmallVectorImpl::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: appendSentenceCase
StringRef camel_case::appendSentenceCase(SmallVectorImpl<char> &buffer,
StringRef string) {
// Trivial case: empty string.
if (string.empty())
return StringRef(buffer.data(), buffer.size());
// Uppercase the first letter, append the rest.
buffer.push_back(clang::toUppercase(string[0]));
buffer.append(string.begin() + 1, string.end());
return StringRef(buffer.data(), buffer.size());
}
示例2: getline
StringRef raw_istream::getline(SmallVectorImpl<char>& buf, int maxLen) {
buf.clear();
for (int i = 0; i < maxLen; ++i) {
char c;
read(c);
if (has_error()) return StringRef{buf.data(), buf.size()};
if (c == '\r') continue;
buf.push_back(c);
if (c == '\n') break;
}
return StringRef{buf.data(), buf.size()};
}
示例3: compress
Error zlib::compress(StringRef InputBuffer,
SmallVectorImpl<char> &CompressedBuffer, int Level) {
unsigned long CompressedSize = ::compressBound(InputBuffer.size());
CompressedBuffer.reserve(CompressedSize);
int Res =
::compress2((Bytef *)CompressedBuffer.data(), &CompressedSize,
(const Bytef *)InputBuffer.data(), InputBuffer.size(), Level);
// Tell MemorySanitizer that zlib output buffer is fully initialized.
// This avoids a false report when running LLVM with uninstrumented ZLib.
__msan_unpoison(CompressedBuffer.data(), CompressedSize);
CompressedBuffer.set_size(CompressedSize);
return Res ? createError(convertZlibCodeToString(Res)) : Error::success();
}
示例4: removeDotPaths
/// Remove '.' and '..' path components from the given absolute path.
/// \return \c true if any changes were made.
// FIXME: Move this to llvm::sys::path.
bool FileManager::removeDotPaths(SmallVectorImpl<char> &Path, bool RemoveDotDot) {
using namespace llvm::sys;
SmallVector<StringRef, 16> ComponentStack;
StringRef P(Path.data(), Path.size());
// Skip the root path, then look for traversal in the components.
StringRef Rel = path::relative_path(P);
for (StringRef C : llvm::make_range(path::begin(Rel), path::end(Rel))) {
if (C == ".")
continue;
if (RemoveDotDot) {
if (C == "..") {
if (!ComponentStack.empty())
ComponentStack.pop_back();
continue;
}
}
ComponentStack.push_back(C);
}
SmallString<256> Buffer = path::root_path(P);
for (StringRef C : ComponentStack)
path::append(Buffer, C);
bool Changed = (Path != Buffer);
Path.swap(Buffer);
return Changed;
}
示例5: qsort
// Copy Options into a vector so we can sort them as we like.
static void
sortOpts(StringMap<Option*> &OptMap,
SmallVectorImpl< std::pair<const char *, Option*> > &Opts,
bool ShowHidden) {
SmallPtrSet<Option*, 128> OptionSet; // Duplicate option detection.
for (StringMap<Option*>::iterator I = OptMap.begin(), E = OptMap.end();
I != E; ++I) {
// Ignore really-hidden options.
if (I->second->getOptionHiddenFlag() == ReallyHidden)
continue;
// Unless showhidden is set, ignore hidden flags.
if (I->second->getOptionHiddenFlag() == Hidden && !ShowHidden)
continue;
// If we've already seen this option, don't add it to the list again.
if (!OptionSet.insert(I->second))
continue;
Opts.push_back(std::pair<const char *, Option*>(I->getKey().data(),
I->second));
}
// Sort the options list alphabetically.
qsort(Opts.data(), Opts.size(), sizeof(Opts[0]), OptNameCompare);
}
示例6: emit_result
static void emit_result(std::vector<NewArchiveMember> &Archive, SmallVectorImpl<char> &OS,
StringRef Name, std::vector<std::string> &outputs)
{
outputs.push_back({ OS.data(), OS.size() });
Archive.push_back(NewArchiveMember(MemoryBufferRef(outputs.back(), Name)));
OS.clear();
}
示例7: removePathTraversal
/// Remove traversal (ie, . or ..) from the given absolute path.
static void removePathTraversal(SmallVectorImpl<char> &Path) {
using namespace llvm::sys;
SmallVector<StringRef, 16> ComponentStack;
StringRef P(Path.data(), Path.size());
// Skip the root path, then look for traversal in the components.
StringRef Rel = path::relative_path(P);
for (StringRef C : llvm::make_range(path::begin(Rel), path::end(Rel))) {
if (C == ".")
continue;
if (C == "..") {
assert(ComponentStack.size() && "Path traverses out of parent");
ComponentStack.pop_back();
} else
ComponentStack.push_back(C);
}
// The stack is now the path without any directory traversal.
SmallString<256> Buffer = path::root_path(P);
for (StringRef C : ComponentStack)
path::append(Buffer, C);
// Put the result in Path.
Path.swap(Buffer);
}
示例8: removeDotPaths
/// Remove '.' path components from the given absolute path.
/// \return \c true if any changes were made.
// FIXME: Move this to llvm::sys::path.
bool FileManager::removeDotPaths(SmallVectorImpl<char> &Path) {
using namespace llvm::sys;
SmallVector<StringRef, 16> ComponentStack;
StringRef P(Path.data(), Path.size());
// Skip the root path, then look for traversal in the components.
StringRef Rel = path::relative_path(P);
bool AnyDots = false;
for (StringRef C : llvm::make_range(path::begin(Rel), path::end(Rel))) {
if (C == ".") {
AnyDots = true;
continue;
}
ComponentStack.push_back(C);
}
if (!AnyDots)
return false;
SmallString<256> Buffer = path::root_path(P);
for (StringRef C : ComponentStack)
path::append(Buffer, C);
Path.swap(Buffer);
return true;
}
示例9: ProcessDeclGroup
void DeclPrinter::ProcessDeclGroup(SmallVectorImpl<Decl*>& Decls) {
this->Indent();
Decl::printGroup(Decls.data(), Decls.size(), Out, Policy, Indentation);
Out << ";\n";
Decls.clear();
}
示例10: uncompress
Error zlib::uncompress(StringRef InputBuffer,
SmallVectorImpl<char> &UncompressedBuffer,
size_t UncompressedSize) {
UncompressedBuffer.resize(UncompressedSize);
Error E =
uncompress(InputBuffer, UncompressedBuffer.data(), UncompressedSize);
UncompressedBuffer.resize(UncompressedSize);
return E;
}
示例11: native
void native(const Twine &path, SmallVectorImpl<char> &result, Style style) {
assert((!path.isSingleStringRef() ||
path.getSingleStringRef().data() != result.data()) &&
"path and result are not allowed to overlap!");
// Clear result.
result.clear();
path.toVector(result);
native(result, style);
}
示例12: makeAbsolutePath
bool FileManager::makeAbsolutePath(SmallVectorImpl<char> &Path) const {
bool Changed = FixupRelativePath(Path);
if (!llvm::sys::path::is_absolute(StringRef(Path.data(), Path.size()))) {
llvm::sys::fs::make_absolute(Path);
Changed = true;
}
return Changed;
}
示例13: FixupRelativePath
void FileManager::FixupRelativePath(SmallVectorImpl<char> &path) const {
StringRef pathRef(path.data(), path.size());
if (FileSystemOpts.WorkingDir.empty()
|| llvm::sys::path::is_absolute(pathRef))
return;
SmallString<128> NewPath(FileSystemOpts.WorkingDir);
llvm::sys::path::append(NewPath, pathRef);
path = NewPath;
}
示例14: remove_dots
bool remove_dots(SmallVectorImpl<char> &path, bool remove_dot_dot,
Style style) {
StringRef p(path.data(), path.size());
SmallString<256> result = remove_dots(p, remove_dot_dot, style);
if (result == path)
return false;
path.swap(result);
return true;
}
示例15: toSentencecase
StringRef camel_case::toSentencecase(StringRef string,
SmallVectorImpl<char> &scratch) {
if (string.empty())
return string;
// Can't be uppercased.
if (!clang::isLowercase(string[0]))
return string;
// Uppercase the first letter, append the rest.
scratch.clear();
scratch.push_back(clang::toUppercase(string[0]));
scratch.append(string.begin() + 1, string.end());
return StringRef(scratch.data(), scratch.size());
}