Example #1
0
static bool by_source(const BlockScopePtr &b1, const BlockScopePtr &b2) {
  if (auto d = b1->getStmt()->getRange().compare(b2->getStmt()->getRange())) {
    return d < 0;
  }
  return b1->getContainingFile()->getName() <
    b2->getContainingFile()->getName();
}
Example #2
0
int CodeGenerator::checkLiteralString(const std::string &str, int &index,
                                      AnalysisResultPtr ar, BlockScopePtr bs,
                                      bool scalarVariant /* = false */) {
  always_assert(getContext() != CodeGenerator::CppConstantsDecl &&
         getContext() != CodeGenerator::CppClassConstantsImpl);
  int stringId = ar->getLiteralStringId(str, index);
  if (m_literalScope) {
    bs = m_literalScope;
  }
  if (bs && bs != ar) {
    FileScopePtr fs = bs->getContainingFile();
    if (fs) {
      fs->addUsedLiteralString(str);
      if (scalarVariant) fs->addUsedLitVarString(str);
      if (isFileOrClassHeader()) {
        ClassScopePtr cs = bs->getContainingClass();
        if (cs) {
          cs->addUsedLiteralStringHeader(str);
          if (scalarVariant) cs->addUsedLitVarStringHeader(str);
        } else {
          fs->addUsedLiteralStringHeader(str);
          if (scalarVariant) fs->addUsedLitVarStringHeader(str);
        }
      }
    }
  }

  return stringId;
}