This is an archive of the discontinued LLVM Phabricator instance.

Fix segmentation fault when mixing -Rpass with #line.
ClosedPublic

Authored by dnovillo on May 6 2014, 11:48 AM.

Details

Summary

When using #line directives, FileManager::getFile() will return a nil
entry. This triggers an assert in translateFileLineCol().

This patch handles nil FileEntry instances by emitting a not that the
location could not be translated back to a SourceLocation. I don't
really like this solution, but I could not find a way of handling it
any other way.

Diff Detail

Event Timeline

dnovillo updated this revision to Diff 9117.May 6 2014, 11:48 AM
dnovillo retitled this revision from to Fix segmentation fault when mixing -Rpass with #line..
dnovillo updated this object.
dnovillo edited the test plan for this revision. (Show Details)
dnovillo added a reviewer: rsmith.
dnovillo added a subscriber: Unknown Object (MLST).
dnovillo updated this revision to Diff 9176.May 7 2014, 9:13 AM
  • Check for positive line numbers.

The translation to SourceLocation does not understand line number 0.
That means that the associated instruction did not really have location
information attached to it.

rsmith accepted this revision.May 7 2014, 2:32 PM
rsmith edited edge metadata.

LGTM, although this makes the "do this properly" FIXME seem somewhat more of a pressing concern :)

lib/CodeGen/CodeGenAction.cpp
405

How does SourceMgr respond if the file/line you give it is out of range for the file?

This revision is now accepted and ready to land.May 7 2014, 2:32 PM
dnovillo closed this revision.May 8 2014, 3:13 PM