本文整理汇总了C++中cl::list::end方法的典型用法代码示例。如果您正苦于以下问题:C++ list::end方法的具体用法?C++ list::end怎么用?C++ list::end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cl::list
的用法示例。
在下文中一共展示了list::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildLinkItems
// BuildLinkItems -- This function generates a LinkItemList for the LinkItems
// linker function by combining the Files and Libraries in the order they were
// declared on the command line.
static void BuildLinkItems(
Linker::ItemList& Items,
const cl::list<std::string>& Files,
const cl::list<std::string>& Libraries) {
// Build the list of linkage items for LinkItems.
cl::list<std::string>::const_iterator fileIt = Files.begin();
cl::list<std::string>::const_iterator libIt = Libraries.begin();
int libPos = -1, filePos = -1;
while ( libIt != Libraries.end() || fileIt != Files.end() ) {
if (libIt != Libraries.end())
libPos = Libraries.getPosition(libIt - Libraries.begin());
else
libPos = -1;
if (fileIt != Files.end())
filePos = Files.getPosition(fileIt - Files.begin());
else
filePos = -1;
if (filePos != -1 && (libPos == -1 || filePos < libPos)) {
// Add a source file
Items.push_back(std::make_pair(*fileIt++, false));
} else if (libPos != -1 && (filePos == -1 || libPos < filePos)) {
// Add a library
Items.push_back(std::make_pair(*libIt++, true));
}
}
}
示例2: main
int main(int argc, const char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
CommonOptionsParser OptionsParser(argc, argv, ClangQueryCategory);
if (!Commands.empty() && !CommandFiles.empty()) {
llvm::errs() << argv[0] << ": cannot specify both -c and -f\n";
return 1;
}
ClangTool Tool(OptionsParser.getCompilations(),
OptionsParser.getSourcePathList());
std::vector<std::unique_ptr<ASTUnit>> ASTs;
if (Tool.buildASTs(ASTs) != 0)
return 1;
QuerySession QS(ASTs);
if (!Commands.empty()) {
for (cl::list<std::string>::iterator I = Commands.begin(),
E = Commands.end();
I != E; ++I) {
QueryRef Q = QueryParser::parse(*I, QS);
if (!Q->run(llvm::outs(), QS))
return 1;
}
} else if (!CommandFiles.empty()) {
for (cl::list<std::string>::iterator I = CommandFiles.begin(),
E = CommandFiles.end();
I != E; ++I) {
std::ifstream Input(I->c_str());
if (!Input.is_open()) {
llvm::errs() << argv[0] << ": cannot open " << *I << "\n";
return 1;
}
while (Input.good()) {
std::string Line;
std::getline(Input, Line);
QueryRef Q = QueryParser::parse(Line, QS);
if (!Q->run(llvm::outs(), QS))
return 1;
}
}
} else {
LineEditor LE("clang-query");
LE.setListCompleter([&QS](StringRef Line, size_t Pos) {
return QueryParser::complete(Line, Pos, QS);
});
while (llvm::Optional<std::string> Line = LE.readLine()) {
QueryRef Q = QueryParser::parse(*Line, QS);
Q->run(llvm::outs(), QS);
llvm::outs().flush();
if (QS.Terminate)
break;
}
}
return 0;
}
示例3: ModulePass
InternalizePass::InternalizePass()
: ModulePass(ID) {
initializeInternalizePassPass(*PassRegistry::getPassRegistry());
if (!APIFile.empty()) // If a filename is specified, use it.
LoadFile(APIFile.c_str());
ExternalNames.insert(APIList.begin(), APIList.end());
DSONames.insert(DSOList.begin(), DSOList.end());
}
示例4: BuildInitial
// Helper function used by Build().
// Traverses initial portions of the toolchains (up to the first Join node).
// This function is also responsible for handling the -x option.
void CompilationGraph::BuildInitial (InputLanguagesSet& InLangs,
const sys::Path& TempDir) {
// This is related to -x option handling.
cl::list<std::string>::const_iterator xIter = Languages.begin(),
xBegin = xIter, xEnd = Languages.end();
bool xEmpty = true;
const std::string* xLanguage = 0;
unsigned xPos = 0, xPosNext = 0, filePos = 0;
if (xIter != xEnd) {
xEmpty = false;
xPos = Languages.getPosition(xIter - xBegin);
cl::list<std::string>::const_iterator xNext = llvm::next(xIter);
xPosNext = (xNext == xEnd) ? std::numeric_limits<unsigned>::max()
: Languages.getPosition(xNext - xBegin);
xLanguage = (*xIter == "none") ? 0 : &(*xIter);
}
// For each input file:
for (cl::list<std::string>::const_iterator B = InputFilenames.begin(),
CB = B, E = InputFilenames.end(); B != E; ++B) {
sys::Path In = sys::Path(*B);
// Code for handling the -x option.
// Output: std::string* xLanguage (can be NULL).
if (!xEmpty) {
filePos = InputFilenames.getPosition(B - CB);
if (xPos < filePos) {
if (filePos < xPosNext) {
xLanguage = (*xIter == "none") ? 0 : &(*xIter);
}
else { // filePos >= xPosNext
// Skip xIters while filePos > xPosNext
while (filePos > xPosNext) {
++xIter;
xPos = xPosNext;
cl::list<std::string>::const_iterator xNext = llvm::next(xIter);
if (xNext == xEnd)
xPosNext = std::numeric_limits<unsigned>::max();
else
xPosNext = Languages.getPosition(xNext - xBegin);
xLanguage = (*xIter == "none") ? 0 : &(*xIter);
}
}
}
}
// Find the toolchain corresponding to this file.
const Node* N = FindToolChain(In, xLanguage, InLangs);
// Pass file through the chain starting at head.
PassThroughGraph(In, N, InLangs, TempDir);
}
}
示例5: main
int main(int argc, char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal();
llvm::PrettyStackTraceProgram X(argc, argv);
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
cl::ParseCommandLineOptions(argc, argv,
"LLVM automatic testcase reducer. See\nhttp://"
"llvm.org/cmds/bugpoint.html"
" for more information.\n");
sys::SetInterruptFunction(BugpointInterruptFunction);
BugDriver D(argv[0], AsChild, FindBugs, TimeoutValue, MemoryLimit);
if (D.addSources(InputFilenames)) return 1;
D.addPasses(PassList.begin(), PassList.end());
// Bugpoint has the ability of generating a plethora of core files, so to
// avoid filling up the disk, we prevent it
sys::Process::PreventCoreFiles();
try {
return D.run();
} catch (ToolExecutionError &TEE) {
std::cerr << "Tool execution error: " << TEE.what() << '\n';
} catch (const std::string& msg) {
std::cerr << argv[0] << ": " << msg << "\n";
} catch (...) {
std::cerr << "Whoops, an exception leaked out of bugpoint. "
<< "This is a bug in bugpoint!\n";
}
return 1;
}
示例6: runOnModule
bool Preparer::runOnModule(Module &M) {
IdentifyThreadFuncs &ITF = getAnalysis<IdentifyThreadFuncs>();
for (cl::list<string>::const_iterator itr = OtherThreadFunctions.begin();
itr != OtherThreadFunctions.end(); ++itr) {
DEBUG(dbgs() << "Other thread functions: " << *itr << "\n";);
}
示例7: main
int main(int argc, char **argv) {
// Print a stack trace if we signal out.
sys::PrintStackTraceOnErrorSignal();
PrettyStackTraceProgram X(argc, argv);
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
cl::ParseCommandLineOptions(argc, argv, "llvm object size dumper\n");
ToolName = argv[0];
if (OutputFormatShort.getNumOccurrences())
OutputFormat = OutputFormatShort;
if (RadixShort.getNumOccurrences())
Radix = RadixShort;
if (InputFilenames.size() == 0)
InputFilenames.push_back("a.out");
if (OutputFormat == berkeley)
outs() << " text data bss "
<< (Radix == octal ? "oct" : "dec")
<< " hex filename\n";
std::for_each(InputFilenames.begin(), InputFilenames.end(),
PrintFileSectionSizes);
return 0;
}
示例8: main
int main(int argc, char **argv) {
// Print a stack trace if we signal out.
sys::PrintStackTraceOnErrorSignal();
PrettyStackTraceProgram X(argc, argv);
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
cl::ParseCommandLineOptions(argc, argv, "llvm object size dumper\n");
ToolName = argv[0];
if (OutputFormatShort.getNumOccurrences())
OutputFormat = OutputFormatShort;
if (RadixShort.getNumOccurrences())
Radix = RadixShort;
for (unsigned i = 0; i < ArchFlags.size(); ++i) {
if (ArchFlags[i] == "all") {
ArchAll = true;
} else {
if (!MachOObjectFile::isValidArch(ArchFlags[i])) {
outs() << ToolName << ": for the -arch option: Unknown architecture "
<< "named '" << ArchFlags[i] << "'";
return 1;
}
}
}
if (InputFilenames.size() == 0)
InputFilenames.push_back("a.out");
moreThanOneFile = InputFilenames.size() > 1;
std::for_each(InputFilenames.begin(), InputFilenames.end(),
PrintFileSectionSizes);
return 0;
}
示例9: runOnModule
bool DefineExtsPass::runOnModule(Module& M) {
bool modified = false;
for(cl::list<std::string>::iterator it = NullSymbols.begin(), it2 = NullSymbols.end(); it != it2; ++it) {
GlobalValue* GV = M.getNamedValue(*it);
if(!GV) {
errs() << "Warning: skipped value " << *it << " (symbol not found)\n";
continue;
}
if(Function* F = dyn_cast<Function>(GV)) {
if(!F->isDeclaration()) {
errs() << "Warning: skipped function " << *it << " because it has a definition\n";
continue;
}
}
GV->replaceAllUsesWith(Constant::getNullValue(GV->getType()));
modified = true;
}
return modified;
}
示例10: EmitShellScript
/// EmitShellScript - Output the wrapper file that invokes the JIT on the LLVM
/// bytecode file for the program.
static void EmitShellScript(char **argv) {
if (Verbose)
cout << "Emitting Shell Script\n";
#if defined(_WIN32) || defined(__CYGWIN__)
// Windows doesn't support #!/bin/sh style shell scripts in .exe files. To
// support windows systems, we copy the llvm-stub.exe executable from the
// build tree to the destination file.
std::string ErrMsg;
sys::Path llvmstub = FindExecutable("llvm-stub.exe", argv[0]);
if (llvmstub.isEmpty())
PrintAndExit("Could not find llvm-stub.exe executable!");
if (0 != sys::CopyFile(sys::Path(OutputFilename), llvmstub, &ErrMsg))
PrintAndExit(ErrMsg);
return;
#endif
// Output the script to start the program...
std::ofstream Out2(OutputFilename.c_str());
if (!Out2.good())
PrintAndExit("error opening '" + OutputFilename + "' for writing!");
Out2 << "#!/bin/sh\n";
// Allow user to setenv LLVMINTERP if lli is not in their PATH.
Out2 << "lli=${LLVMINTERP-lli}\n";
Out2 << "exec $lli \\\n";
// gcc accepts -l<lib> and implicitly searches /lib and /usr/lib.
LibPaths.push_back("/lib");
LibPaths.push_back("/usr/lib");
LibPaths.push_back("/usr/X11R6/lib");
// We don't need to link in libc! In fact, /usr/lib/libc.so may not be a
// shared object at all! See RH 8: plain text.
std::vector<std::string>::iterator libc =
std::find(Libraries.begin(), Libraries.end(), "c");
if (libc != Libraries.end()) Libraries.erase(libc);
// List all the shared object (native) libraries this executable will need
// on the command line, so that we don't have to do this manually!
for (std::vector<std::string>::iterator i = Libraries.begin(),
e = Libraries.end(); i != e; ++i) {
sys::Path FullLibraryPath = sys::Path::FindLibrary(*i);
if (!FullLibraryPath.isEmpty() && FullLibraryPath.isDynamicLibrary())
Out2 << " -load=" << FullLibraryPath.toString() << " \\\n";
}
Out2 << " $0.bc ${1+\"[email protected]\"}\n";
Out2.close();
}
示例11: is_specified_thread_function
bool Preparer::is_specified_thread_function(const Function *f) const {
for (cl::list<string>::const_iterator itr = OtherThreadFunctions.begin();
itr != OtherThreadFunctions.end(); ++itr) {
if (f->getName() == *itr)
return true;
}
return false;
}
示例12: ModulePass
InternalizePass::InternalizePass(bool AllButMain)
: ModulePass(ID), AllButMain(AllButMain){
initializeInternalizePassPass(*PassRegistry::getPassRegistry());
if (!APIFile.empty()) // If a filename is specified, use it.
LoadFile(APIFile.c_str());
if (!APIList.empty()) // If a list is specified, use it as well.
ExternalNames.insert(APIList.begin(), APIList.end());
}
示例13: FindFirstCandidateMatch
// Try to find the first match in buffer for any prefix. If a valid match is
// found, return that prefix and set its type and location. If there are almost
// matches (e.g. the actual prefix string is found, but is not an actual check
// string), but no valid match, return an empty string and set the position to
// resume searching from. If no partial matches are found, return an empty
// string and the location will be StringRef::npos. If one prefix is a substring
// of another, the maximal match should be found. e.g. if "A" and "AA" are
// prefixes then AA-CHECK: should match the second one.
static StringRef FindFirstCandidateMatch(StringRef &Buffer,
Check::CheckType &CheckTy,
size_t &CheckLoc) {
StringRef FirstPrefix;
size_t FirstLoc = StringRef::npos;
size_t SearchLoc = StringRef::npos;
Check::CheckType FirstTy = Check::CheckNone;
CheckTy = Check::CheckNone;
CheckLoc = StringRef::npos;
for (prefix_iterator I = CheckPrefixes.begin(), E = CheckPrefixes.end();
I != E; ++I) {
StringRef Prefix(*I);
size_t PrefixLoc = Buffer.find(Prefix);
if (PrefixLoc == StringRef::npos)
continue;
// Track where we are searching for invalid prefixes that look almost right.
// We need to only advance to the first partial match on the next attempt
// since a partial match could be a substring of a later, valid prefix.
// Need to skip to the end of the word, otherwise we could end up
// matching a prefix in a substring later.
if (PrefixLoc < SearchLoc)
SearchLoc = SkipWord(Buffer, PrefixLoc);
// We only want to find the first match to avoid skipping some.
if (PrefixLoc > FirstLoc)
continue;
// If one matching check-prefix is a prefix of another, choose the
// longer one.
if (PrefixLoc == FirstLoc && Prefix.size() < FirstPrefix.size())
continue;
StringRef Rest = Buffer.drop_front(PrefixLoc);
// Make sure we have actually found the prefix, and not a word containing
// it. This should also prevent matching the wrong prefix when one is a
// substring of another.
if (PrefixLoc != 0 && IsPartOfWord(Buffer[PrefixLoc - 1]))
FirstTy = Check::CheckNone;
else
FirstTy = FindCheckType(Rest, Prefix);
FirstLoc = PrefixLoc;
FirstPrefix = Prefix;
}
// If the first prefix is invalid, we should continue the search after it.
if (FirstTy == Check::CheckNone) {
CheckLoc = SearchLoc;
return "";
}
CheckTy = FirstTy;
CheckLoc = FirstLoc;
return FirstPrefix;
}
示例14: main
int main(int argc, const char **argv) {
CommonOptionsParser OptionsParser(argc, argv, NoGlobalStyleCategory);
ClangTool Tool(OptionsParser.getCompilations(),
OptionsParser.getSourcePathList());
MatchFinder finder;
// Snarf abstract-only namespaces from the environment.
std::vector<std::string> abstract_namespaces_v, banned_namespaces_v;
std::copy(abstract_namespaces.begin(), abstract_namespaces.end(), std::back_inserter(abstract_namespaces_v));
std::copy(banned_namespaces.begin(), banned_namespaces.end(), std::back_inserter(banned_namespaces_v));
std::unique_ptr<RuleCheckerBase> rules[] = {
make_unique<DisallowNew>(),
make_unique<DisallowDelete>(),
make_unique<DisallowGlobals>(),
make_unique<DisallowNonAbstract>(abstract_namespaces_v),
make_unique<DisallowCoupling>(banned_namespaces_v)
};
size_t rules_size = sizeof(rules) / sizeof(rules[0]);
auto rules_begin = &rules[0];
auto rules_end = &rules[rules_size];
std::vector<std::string> analyze_paths_v;
std::copy(analyze_paths.begin(), analyze_paths.end(), std::back_inserter(analyze_paths_v));
for (size_t i = 0; i < sizeof(rules) / sizeof(rules[0]); ++i) {
auto &rule = rules[i];
rule->setAnalyzePaths(analyze_paths_v);
rule->SetupMatches(finder);
rule->getPrinter().setDebug(Debug.getValue());
}
#ifndef NDEBUG
llvm::DebugFlag = Debug.getValue();
#endif
return Tool.run(newFrontendActionFactory(&finder).get()) ||
(Werror.getValue() &&
std::any_of
(rules_begin, rules_end,
[] (const std::unique_ptr<RuleCheckerBase> &rule) {
return rule->getPrinter().getWarnings();
}));
}
示例15: runOnModule
bool Mutator::runOnModule(Module &M) {
unsigned siteId = 0;
OperatorManager *OMgr = OperatorManager::getInstance();
OperatorInfoList oplst;
// Loop through all functions within module
for (Module::iterator F = M.begin(), ME = M.end(); F != ME; ++F) {
// Loop through all basic blocks within function
for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) {
// Loop through all instructions within basic block
for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE; I++) {
// Consider only mutable instructions
OMgr->getCompatibleOperators(I, oplst);
bool mutated = false;
for (OperatorInfoList::iterator opi = oplst.begin(); opi != oplst.end(); opi++) {
cl::list<unsigned>::iterator sid = find (MutationIDS.begin(), MutationIDS.end(), siteId++);
if (sid != MutationIDS.end()) {
// One of the specified mutations was found
if (!mutated) {
MutationOperator *op = (*opi)->build();
Value *newv = op->apply(I);
//cerr << *I << " --> " << *newv << "\n";
if (newv != NULL) {
ReplaceInstWithValue(B->getInstList(), I, newv);
} else {
}
mutated = true;
} else {
throw std::string("An instruction is being mutated twice! Aborting...");
}
}
}
}
}
}
// notify change of program
return true;
}