[cfe-dev] Assert in SourceManager::getFileIDSlow()

Alexei Svitkine alexei.svitkine at gmail.com
Tue Aug 25 11:00:35 PDT 2009


Hi,

My code is triggering the assert:

  assert(SLocOffset && "Invalid FileID");

In SourceManager::getFileIDSlow().

It happens as a result of calling SM->isFromMainFile(Loc) in some
ASTConsumer code that looks like:

void HandleTopLevelDecl(clang::DeclGroupRef D) {
  for (clang::DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) {
    if (clang::FunctionDecl *FD = dyn_cast<clang::FunctionDecl>(*I)) {
      clang::SourceLocation Loc = FD->getTypeSpecStartLoc();
      if (SM->isFromMainFile(Loc)) {
        // ...
      }
    }
  }
}

(The input that is being parsed begins with a function declaration.)

I am not sure how old this issue is, but it makes ccons unusable
(which is quite a shame, since I hoped ccons could work fine with the
clang 1.0 release). Any advice would be appreciated.

-Alexei



More information about the cfe-dev mailing list