Commit Graph

20 Commits

Author SHA1 Message Date
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Jordan Rose
77f6228542 [ClangImporter] Warn on and ignore invalid swift_name attributes.
...that Clang didn't catch for us. The Clang side of things is now looser so
that we don't have to mirror our import logic over there, but that means
invalid cases can slip through.

Part of rdar://problem/21091469

Swift SVN r29535
2015-06-20 18:55:13 +00:00
Jordan Rose
bc9e1fb1ce [ClangImporter] Handle Clang diagnostics purportedly on line 0.
We don't handle a line 0 in Swift, and this led to LLDB crashing. I'm not
actually sure why Clang was emitting an error on line 0, either; the full
location was "<built-in>:0:4" and the error was

  module 'CoreFoundation' found in both '.../CoreFoundation-17XE9QM744UO5.pcm'
  and '.../CoreFoundation-2BVMOFFOYI8X.pcm'

which turned out to be another manifestation of rdar://problem/19817341
(this was an older LLDB build). No test cases because I'm not sure how to
trigger this, especially not since the previous Radar was fixed, but I'll
clone it to track down why Clang is using such an unusual location.

rdar://problem/19951280

Swift SVN r25766
2015-03-04 21:25:11 +00:00
Jordan Rose
2cd2fe3418 [ClangImporter] Don't assume all memory buffers have unique identifiers.
In particular, the fake "<module-includes>" buffers all have that same name.
Use the buffer itself to provide identity. (We are already deliberately
keeping the buffers alive via their source managers.)

rdar://problem/19716081

Swift SVN r25200
2015-02-11 23:07:37 +00:00
Jordan Rose
5ad871ecd6 Adopt llvm::function_ref for callbacks that aren't persisted.
...removing a few other constructs that were doing the same thing
(mostly from me).

No functionality change.

Swift SVN r23294
2014-11-13 00:19:03 +00:00
Jordan Rose
5aa60308a6 [ClangImporter] Don't mistake a module being built for our dummy buffer.
The ClangDiagnosticConsumer forwards diagnostics from Clang's diagnostic machinery
to Swift's. It deliberately filters out things that happen in our top-level dummy
buffer (usually trivial things like "module imported here"). Unfortunately, it was
doing so by checking against the current SourceManager's "main file". When building
Clang modules (compiling PCM files), we're dealing with a new SourceManager, whose
main file is the module map file.

Instead, just check against the (very unlikely) name of our dummy input file,
like we do for imported headers.

rdar://problem/18867749

Swift SVN r23121
2014-11-05 23:10:19 +00:00
Argyrios Kyrtzidis
b74feafdfd [ClangImporter] Make sure to use the right clang::SourceManager when resolving a diagnostic-related source location during clang module building.
Fixes crash in rdar://18464633

Swift SVN r22721
2014-10-14 03:37:00 +00:00
Jordan Rose
3d3c6fa730 [ClangImporter] Fix crash when a diagnostic is reported during module building.
This rare crash happens when
1. A diagnostic is reported when building a Clang module.
2. The diagnostic is mapped to a Swift diagnostic by mirroring the Clang
   source buffer as a Swift source buffer (via non-owning reference).
3. The Clang CompilerInstance used specifically to build the module is
   destroyed.
4. Some /new/ buffer is allocated in the same memory spot as the old buffer.
5. Some new Clang diagnostic occurs in the new buffer.
6. The Swift source manager asserts when trying to set up a virtual name
   for the diagnostic in the second imported buffer, because there's already
   a name for that region.

The fix, because we don't expect diagnostics from modules to appear very
often, is to keep any clang::SourceManagers alive if diagnostics are emitted
in their buffers. We can revisit this if/when Swift's source manager
(currently built on llvm::SourceMgr) has the ability to remove buffers.

Many thanks to Greg for noticing the problem, tracking it down, and providing
a diff to make it fail reproducibly under GuardMalloc. I've tried to preserve
the spirit of that diff in the new logic in ~SourceManager, which will also
fail reliably with GuardMalloc (and probably ASan).

rdar://problem/18285805

Swift SVN r21958
2014-09-15 22:26:48 +00:00
Argyrios Kyrtzidis
da95aadb4b [ClangImporter] Make sure we don't crash if clang emits diagnostics because of the provided clang compiler arguments.
rdar://18068354

Swift SVN r21823
2014-09-10 01:18:32 +00:00
Jordan Rose
b682e0cf3d [ClangImporter] Don't try to recover if an Objective-C module can't be loaded.
This is already a fatal error, so it doesn't matter how many diagnostics we
dump after that. It's better not to lie to the rest of the compiler about
whether the load succeeds.

No immediate Radar, but this fixes a crash in the test case I'm about to
commit, and possibly some other mystery "dependency missing" crashes in
XREF resolution.

Swift SVN r20919
2014-08-01 21:44:36 +00:00
Jordan Rose
aae4a3d731 [ClangImporter] Pass through diagnostic locations for imports.
If importing a Clang module fails, we should report that at the location of
the import statement. This doesn't do that fully because it isn't transitive
(if Swift module Foo imports Swift module Bar, which fails to import Clang
module Baz, we don't get an error in user source), but it's a step forward
for the simple cases.

Swift SVN r20575
2014-07-25 23:01:51 +00:00
Jordan Rose
d8077fc540 [ClangImporter] Print notes for macro expansions and include locations.
(for errors in the bridging header or in modules)

<rdar://problem/17573187>

Swift SVN r20573
2014-07-25 23:01:47 +00:00
Jordan Rose
0b933acfda [ClangImporter] Use #line when reporting module build errors.
...or at least the same machinery as #line. We add a (referential) mirror
of the Clang buffer to Swift's source manager, then remap that particular
line to whatever Clang currently thinks is the presumed location for that
line. (This means we respect Clang line directives too.)

This also modifies Swift's source manager to be more forgiving about adding
the same virtual file range twice; it will tell you when you try to do it.

<rdar://problem/16596800>

Swift SVN r20572
2014-07-25 23:01:45 +00:00
Jordan Rose
904d1b21c6 [ClangImporter] Drop the "current import" tracking for bridging headers.
Now that bridging headers from ASTs are always present and bridging headers
from the command line are checked in advance, we no longer need to worry
about the Clang instance failing to find the bridging header. That's good,
because this wasn't implemented correctly anyway: if a bridging header
imported a module, we could get an error.

Swift SVN r20129
2014-07-18 00:22:55 +00:00
Jordan Rose
0e8021b7f3 [ClangImporter] Add frontend option -dump-clang-diagnostics for debugging.
This option dumps Clang diagnostics to stderr as well as passing them along
to Swift's diagnostic machinery.

Swift SVN r19841
2014-07-11 00:36:55 +00:00
Jordan Rose
d3cdebc84e [ClangImporter] Add missing early exit after emitting a fatal error.
This doesn't really matter, since the error that follows will just be
ignored, but it's more correct.

Swift SVN r18463
2014-05-20 19:50:26 +00:00
Jordan Rose
6d376f9627 [ClangImporter] Make a missing bridging header a fatal error.
<rdar://problem/16920163>

Swift SVN r18442
2014-05-20 02:13:32 +00:00
Jordan Rose
2981cd3579 [ClangImporter] Note that Clang's getPresumedLoc handles invalid source locs.
Per feedback from Ted. Comment change only.

Swift SVN r18366
2014-05-18 22:51:26 +00:00
Jordan Rose
b581365785 [ClangImporter] If a Clang module fails to build, it's not missing.
...so don't report a second "module missing" error from Swift itself.

We do still treat the Clang module failing to build as a fatal error.

<rdar://problem/16175035>

Swift SVN r18231
2014-05-17 00:23:46 +00:00
Jordan Rose
a012602f62 [ClangImporter] Pass diagnostics through to Swift's diagnostic consumer.
We're not mapping source locations over correctly yet, so the file name
where an error occurs gets shoved into the diagnostic text, but that's
fine for now.

This also silences the "module 'Blah' not found" error coming from the
importer whenever Swift itself can be responsible for importing the module.

Still to do: if we can't build a Clang module, we shouldn't report that
error and then say it can't be found.

<rdar://problem/14509389>

Swift SVN r18230
2014-05-17 00:23:44 +00:00