[LLVMbugs] [Bug 10882] New: FileManager::getVirtualFile() fails due to bug in FileManager::addAncestorsAsVirtualDirs()

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Sep 7 07:49:01 PDT 2011


           Summary: FileManager::getVirtualFile() fails due to bug in
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: vinay_sajip at yahoo.co.uk
                CC: llvmbugs at cs.uiuc.edu

A call to FileManager::getVirtualFile() with a filename such as
"/usr/include/i386._types.h" fails with an assertion error: "The directory of a
virtual file should already be in the cache."

This is because code in the FileManager::addAncestorsAsVirtualDirs() method -
called from FileManager::getVirtualFile() - looks like this:

  llvm::StringMapEntry<DirectoryEntry *> &NamedDirEnt =

  // When caching a virtual directory, we always cache its ancestors
  // at the same time.  Therefore, if DirName is already in the cache,
  // we don't need to recurse as its ancestors must also already be in
  // the cache.

  if (NamedDirEnt.getValue())

  // continue to set the value and add the directory's ancestors

However, the GetOrCreateValue() call creates an entry with a bogus "tombstone"
value of -1. So, the if test always returns true and causes a premature return.
If the test is changed to

  if (NamedDirEnt.getValue() != (DirectoryEntry *)

all is seemingly well.



Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list