Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions clang/utils/TableGen/ClangSACheckersEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ static std::string getPackageFullName(const Record *R, StringRef Sep = ".");

static std::string getParentPackageFullName(const Record *R,
StringRef Sep = ".") {
std::string name;
if (const DefInit *DI = dyn_cast<DefInit>(R->getValueInit("ParentPackage")))
name = getPackageFullName(DI->getDef(), Sep);
return name;
return getPackageFullName(DI->getDef(), Sep);
return "";
}

static std::string getPackageFullName(const Record *R, StringRef Sep) {
Expand All @@ -52,10 +51,10 @@ static std::string getCheckerFullName(const Record *R, StringRef Sep = ".") {
return name;
}

static std::string getStringValue(const Record &R, StringRef field) {
static StringRef getStringValue(const Record &R, StringRef field) {
if (const StringInit *SI = dyn_cast<StringInit>(R.getValueInit(field)))
return std::string(SI->getValue());
return std::string();
return SI->getValue();
return "";
}

// Calculates the integer value representing the BitsInit object
Expand Down Expand Up @@ -93,7 +92,7 @@ static std::string getCheckerDocs(const Record &R) {
/// Retrieves the type from a CmdOptionTypeEnum typed Record object. Note that
/// the class itself has to be modified for adding a new option type in
/// CheckerBase.td.
static std::string getCheckerOptionType(const Record &R) {
static StringRef getCheckerOptionType(const Record &R) {
if (const BitsInit *BI = R.getValueAsBitsInit("Type")) {
switch(getValueFromBitsInit(BI, R)) {
case 0:
Expand All @@ -110,7 +109,7 @@ static std::string getCheckerOptionType(const Record &R) {
return "";
}

static std::string getDevelopmentStage(const Record &R) {
static StringRef getDevelopmentStage(const Record &R) {
if (const BitsInit *BI = R.getValueAsBitsInit("DevelopmentStage")) {
switch(getValueFromBitsInit(BI, R)) {
case 0:
Expand Down Expand Up @@ -179,8 +178,6 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
ArrayRef<const Record *> packages =
Records.getAllDerivedDefinitions("Package");

using SortedRecords = StringMap<const Record *>;

OS << "// This file is automatically generated. Do not edit this file by "
"hand.\n";

Expand All @@ -191,16 +188,13 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
OS << "\n"
"#ifdef GET_PACKAGES\n";
{
SortedRecords sortedPackages;
for (unsigned i = 0, e = packages.size(); i != e; ++i)
sortedPackages[getPackageFullName(packages[i])] = packages[i];

for (SortedRecords::iterator
I = sortedPackages.begin(), E = sortedPackages.end(); I != E; ++I) {
const Record &R = *I->second;

StringMap<const Record *> sortedPackages;
for (const Record *Package : packages)
sortedPackages[getPackageFullName(Package)] = Package;

for (const auto &[_, R] : sortedPackages) {
OS << "PACKAGE(" << "\"";
OS.write_escaped(getPackageFullName(&R)) << '\"';
OS.write_escaped(getPackageFullName(R)) << '\"';
OS << ")\n";
}
}
Expand All @@ -225,7 +219,6 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
OS << "\n"
"#ifdef GET_PACKAGE_OPTIONS\n";
for (const Record *Package : packages) {

if (Package->isValueUnset("PackageOptions"))
continue;

Expand All @@ -250,9 +243,9 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
OS << "\n"
"#ifdef GET_CHECKERS\n"
"\n";
for (const Record *checker : checkers) {
for (const Record *checker : checkers)
printChecker(OS, *checker);
}

OS << "\n"
"#endif // GET_CHECKERS\n"
"\n";
Expand Down
4 changes: 2 additions & 2 deletions clang/utils/TableGen/ClangSyntaxEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ struct SyntaxConstraint {
} else if (R.isSubClassOf("AnyToken")) {
NodeType = "Leaf";
} else if (R.isSubClassOf("NodeType")) {
NodeType = R.getName().str();
NodeType = R.getName();
} else {
assert(false && "Unhandled Syntax kind");
}
}

std::string NodeType;
StringRef NodeType;
// optional and leaf types also go here, once we want to use them.
};

Expand Down
Loading