Ejemplo n.º 1
0
static void setModuleName(CompilerInvocation &Invocation) {
  if (!Invocation.getModuleName().empty())
    return;

  StringRef Filename = Invocation.getOutputFilename();
  if (Filename.empty()) {
    if (Invocation.getInputFilenames().empty()) {
      Invocation.setModuleName("__main__");
      return;
    }
    Filename = Invocation.getInputFilenames()[0];
  }
  Filename = llvm::sys::path::filename(Filename);
  StringRef ModuleName = llvm::sys::path::stem(Filename);
  if (ModuleName.empty() || !Lexer::isIdentifier(ModuleName)) {
    Invocation.setModuleName("__main__");
    return;
  }
  Invocation.setModuleName(ModuleName);
}