http://llvm.org/bugs/show_bug.cgi?id=10882

           Summary: FileManager::getVirtualFile() fails due to bug in
                    FileManager::addAncestorsAsVirtualDirs()
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


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 =
    SeenDirEntries.GetOrCreateValue(DirName);

  // 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())
    return;

  // 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 *)
        SeenDirEntries.getTombstoneVal())
    return;

all is seemingly well.

See:

https://github.com/vsajip/clang/commit/6958016e54862b1f5bc17a44bffeba8d4df7cb97

-- 
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to