Пример #1
0
  string name(const char* baseName)
  {
    Names::iterator p = names_number_.find(string(baseName));
    int id = (p == names_number_.end()) ? 0 : names_number_[baseName] + 1;
    names_number_[baseName] = id;

    enum { BufferSize = 14 };
    char buffer[BufferSize];
    snprintf(buffer, BufferSize, "_%d", id);

    return (string(baseName) + buffer + ".log").c_str();
  }
Пример #2
0
void C2Sema::analyseStructNames(const StructTypeDecl* S, Names& names) {
    typedef Names::iterator NamesIter;
    for (unsigned i=0; i<S->numMembers(); i++) {
        const Decl* member = S->getMember(i);
        const std::string& name = member->getName();
        if (name == "") {
            assert(isa<StructTypeDecl>(member));
            analyseStructNames(cast<StructTypeDecl>(member), names);
        } else {
            NamesIter iter = names.find(name);
            if (iter != names.end()) {
                const Decl* existing = iter->second;
                Diag(member->getLocation(), diag::err_duplicate_member) << name;
                Diag(existing->getLocation(), diag::note_previous_declaration);
            } else {
                names[name] = member;
            }
        }
    }
}