Deleted Added
full compact
PassNameParser.h (208954) PassNameParser.h (212904)
1//===- llvm/Support/PassNameParser.h ----------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 9 unchanged lines hidden (view full) ---

18// includes passes that have a PassType that are compatible with the filter
19// (which is the template argument).
20//
21//===----------------------------------------------------------------------===//
22
23#ifndef LLVM_SUPPORT_PASS_NAME_PARSER_H
24#define LLVM_SUPPORT_PASS_NAME_PARSER_H
25
1//===- llvm/Support/PassNameParser.h ----------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 9 unchanged lines hidden (view full) ---

18// includes passes that have a PassType that are compatible with the filter
19// (which is the template argument).
20//
21//===----------------------------------------------------------------------===//
22
23#ifndef LLVM_SUPPORT_PASS_NAME_PARSER_H
24#define LLVM_SUPPORT_PASS_NAME_PARSER_H
25
26#include "llvm/Pass.h"
27#include "llvm/ADT/STLExtras.h"
26#include "llvm/Support/CommandLine.h"
27#include "llvm/Support/ErrorHandling.h"
28#include "llvm/Support/raw_ostream.h"
28#include "llvm/Support/CommandLine.h"
29#include "llvm/Support/ErrorHandling.h"
30#include "llvm/Support/raw_ostream.h"
29#include "llvm/Pass.h"
30#include <algorithm>
31#include <cstring>
32
33namespace llvm {
34
35//===----------------------------------------------------------------------===//
36// PassNameParser class - Make use of the pass registration mechanism to
37// automatically add a command line argument to opt for each pass.
38//
39class PassNameParser : public PassRegistrationListener,
40 public cl::parser<const PassInfo*> {
41 cl::Option *Opt;
42public:
43 PassNameParser() : Opt(0) {}
44 virtual ~PassNameParser();
31#include <cstring>
32
33namespace llvm {
34
35//===----------------------------------------------------------------------===//
36// PassNameParser class - Make use of the pass registration mechanism to
37// automatically add a command line argument to opt for each pass.
38//
39class PassNameParser : public PassRegistrationListener,
40 public cl::parser<const PassInfo*> {
41 cl::Option *Opt;
42public:
43 PassNameParser() : Opt(0) {}
44 virtual ~PassNameParser();
45
46
45
47 void initialize(cl::Option &O) {
48 Opt = &O;
49 cl::parser<const PassInfo*>::initialize(O);
50
51 // Add all of the passes to the map that got initialized before 'this' did.
52 enumeratePasses();
53 }
54

--- 17 unchanged lines hidden (view full) ---

72 errs() << "Two passes with the same argument (-"
73 << P->getPassArgument() << ") attempted to be registered!\n";
74 llvm_unreachable(0);
75 }
76 addLiteralOption(P->getPassArgument(), P, P->getPassName());
77 }
78 virtual void passEnumerate(const PassInfo *P) { passRegistered(P); }
79
46 void initialize(cl::Option &O) {
47 Opt = &O;
48 cl::parser<const PassInfo*>::initialize(O);
49
50 // Add all of the passes to the map that got initialized before 'this' did.
51 enumeratePasses();
52 }
53

--- 17 unchanged lines hidden (view full) ---

71 errs() << "Two passes with the same argument (-"
72 << P->getPassArgument() << ") attempted to be registered!\n";
73 llvm_unreachable(0);
74 }
75 addLiteralOption(P->getPassArgument(), P, P->getPassName());
76 }
77 virtual void passEnumerate(const PassInfo *P) { passRegistered(P); }
78
80 // ValLessThan - Provide a sorting comparator for Values elements...
81 typedef std::pair<const char*,
82 std::pair<const PassInfo*, const char*> > ValType;
83 static bool ValLessThan(const ValType &VT1, const ValType &VT2) {
84 return std::string(VT1.first) < std::string(VT2.first);
85 }
86
87 // printOptionInfo - Print out information about this option. Override the
88 // default implementation to sort the table before we print...
89 virtual void printOptionInfo(const cl::Option &O, size_t GlobalWidth) const {
90 PassNameParser *PNP = const_cast<PassNameParser*>(this);
79 // printOptionInfo - Print out information about this option. Override the
80 // default implementation to sort the table before we print...
81 virtual void printOptionInfo(const cl::Option &O, size_t GlobalWidth) const {
82 PassNameParser *PNP = const_cast<PassNameParser*>(this);
91 std::sort(PNP->Values.begin(), PNP->Values.end(), ValLessThan);
83 array_pod_sort(PNP->Values.begin(), PNP->Values.end(), ValLessThan);
92 cl::parser<const PassInfo*>::printOptionInfo(O, GlobalWidth);
93 }
84 cl::parser<const PassInfo*>::printOptionInfo(O, GlobalWidth);
85 }
86
87private:
88 // ValLessThan - Provide a sorting comparator for Values elements...
89 static int ValLessThan(const void *VT1, const void *VT2) {
90 typedef PassNameParser::OptionInfo ValType;
91 return std::strcmp(static_cast<const ValType *>(VT1)->Name,
92 static_cast<const ValType *>(VT2)->Name);
93 }
94};
95
96///===----------------------------------------------------------------------===//
97/// FilteredPassNameParser class - Make use of the pass registration
98/// mechanism to automatically add a command line argument to opt for
99/// each pass that satisfies a filter criteria. Filter should return
100/// true for passes to be registered as command-line options.
101///

--- 36 unchanged lines hidden ---
94};
95
96///===----------------------------------------------------------------------===//
97/// FilteredPassNameParser class - Make use of the pass registration
98/// mechanism to automatically add a command line argument to opt for
99/// each pass that satisfies a filter criteria. Filter should return
100/// true for passes to be registered as command-line options.
101///

--- 36 unchanged lines hidden ---