Commit Graph

982 Commits

Author SHA1 Message Date
Douglas Gregor 4dc71835f5 Set umbrella directory correctly when we infer a framework module
llvm-svn: 146451
2011-12-12 23:55:05 +00:00
Douglas Gregor a95387786d Don't mark include guard macros as implicitly private. This isn't
actually a terribly good heuristic, and the world is too horrible for
it to work.

llvm-svn: 146393
2011-12-12 18:47:39 +00:00
Douglas Gregor 5ca04bd4e7 When performing subframework header lookup, don't search for
".framework/" in the path name, because it could be ".framework\" on
Windows. This whole function needs to be rewritten with PathV2.

llvm-svn: 146261
2011-12-09 16:48:01 +00:00
Douglas Gregor 7033127b4e Implement the notion of umbrella directories, which implicity cover
all of the headers below that particular directory. Use umbrella
directories as a clean way to deal with (1) directories/frameworks
that don't have an umbrella header, but don't want to enumerate all of
their headers, and (2) PrivateHeaders, which we never want to
enumerate and want to keep separate from the main umbrella header. 

This also eliminates a little more of the "magic" for private headers,
and frameworks in general.

llvm-svn: 146235
2011-12-09 02:04:43 +00:00
Chandler Carruth b0ffe50da8 Move a free function from the Frontend library into the Lex library as
part of HeaderSearch. This function just normalizes filenames for use
inside of a synthetic include directive, but it is used in both the
Frontend and Serialization libraries so it needs a common home.

llvm-svn: 146227
2011-12-09 01:33:57 +00:00
Douglas Gregor 524e33e1f8 Implement umbrella directories for modules, which are similar to
umbrella headers in the sense that all of the headers within that
directory (and eventually its subdirectories) are considered to be
part of the module with that umbrella directory. However, unlike
umbrella headers, which are expected to include all of the headers
within their subdirectories, Clang will automatically include all of
the headers it finds in the named subdirectory.

The intent here is to allow a module map to trivially turn a
subdirectory into a module, where the module's structure can mimic the
directory structure.

llvm-svn: 146165
2011-12-08 19:11:24 +00:00
Douglas Gregor 322f633c1c Tweak the syntax of umbrella headers, so that "umbrella" is treated as
a modifier for a header declarartion, e.g.,

  umbrella header "headername"

Collapse the umbrella-handling code in the parser into the
header-handling code, so we don't duplicate the header-search logic.

llvm-svn: 146159
2011-12-08 18:00:48 +00:00
Douglas Gregor 73141fa98d Within the module representation, generalize the notion of an umbrella
header to also support umbrella directories. The umbrella directory
for an umbrella header is the directory in which the umbrella header
resides.

No functionality change yet, but it's coming.

llvm-svn: 146158
2011-12-08 17:39:04 +00:00
Douglas Gregor 2537a36483 Keep track of import dependencies between submodules within the module
that's currently being built. This is important for supporting
transitive dependencies ("export *" in the module map) completely.

llvm-svn: 146156
2011-12-08 17:01:29 +00:00
Douglas Gregor ddaa69cb28 Convert paths to native format before constructing a
directory_iterator for them.

llvm-svn: 146154
2011-12-08 16:13:24 +00:00
Douglas Gregor 9458f82df7 Implement inference for the "Private" submodule corresponding to
private headers in a framework.

llvm-svn: 146082
2011-12-07 22:05:21 +00:00
Douglas Gregor 8030677b70 Make sure we pick up module_private.map when loading a module.map file.
llvm-svn: 146074
2011-12-07 21:25:07 +00:00
Douglas Gregor e7ab36693b Implement basic support for private headers in frameworks. In essence,
when we load a module map (module.map) from a directory, also load a
private module map (module_private.map) for that directory, if
present. That private module map can inject a new submodule that
captures private headers.

llvm-svn: 146012
2011-12-07 02:23:45 +00:00
Douglas Gregor d6343c99d6 Remove misleading error message
llvm-svn: 145958
2011-12-06 19:57:48 +00:00
Douglas Gregor e89dbc1d98 When inferring a module map for a framework, infer subframework
modules for each of its subframeworks.

llvm-svn: 145957
2011-12-06 19:39:29 +00:00
Douglas Gregor dd005f69f0 Allow inferred submodules for any (sub)module that has an umbrella header
llvm-svn: 145945
2011-12-06 17:34:58 +00:00
Douglas Gregor 356f3d4b53 When suggesting a module import for a #include or #import, suggest the
most specific (sub)module based on the actual file we find, rather
than always importing the top-level module. This means
that #include'ing <Foo/Blah.h> should give us the submodule Foo.Blah.

llvm-svn: 145942
2011-12-06 17:31:28 +00:00
Douglas Gregor f2161a70aa Implement modules support for subframeworks (aka embedded
frameworks). A submodule can now be labeled as a "framework", and
header search will look into the appropriate Headers/PrivateHeaders
subdirectories for named headers.

llvm-svn: 145941
2011-12-06 17:16:41 +00:00
Douglas Gregor 930a85cc2d Minor tweak to prepare for submodules with umbrella headers. No actual
functionality change yet.

llvm-svn: 145938
2011-12-06 16:17:15 +00:00
Douglas Gregor a89c5ac4a6 Implement inferred submodules support, which (when requested)
implicitly generates submodules corresponding to the headers that fall
within a module.

llvm-svn: 145887
2011-12-06 01:10:29 +00:00
Douglas Gregor 734410916a Parse inferred submodules in module maps, track their contents in
Module, and (de-)serialize this information. Semantics of inferred
submodules to follow.

llvm-svn: 145864
2011-12-05 22:27:44 +00:00
Douglas Gregor d8bd7537ec Inferred framework modules automatically export anything they import
(i.e., 'export *'), to better match the semantics of headers.

llvm-svn: 145813
2011-12-05 17:40:25 +00:00
Douglas Gregor f5eedd05db Implement support for wildcard exports in modules, allowing a module
to re-export anything that it imports. This opt-in feature makes a
module behave more like a header, because it can be used to re-export
the transitive closure of a (sub)module's dependencies.

llvm-svn: 145811
2011-12-05 17:28:06 +00:00
Douglas Gregor 0093b3c7bf When writing a module file, keep track of the set of (sub)modules that
it imports, establishing dependencies at the (sub)module
granularity. This is not a user-visible change (yet).

llvm-svn: 145808
2011-12-05 16:33:54 +00:00
Douglas Gregor dca70af22f Implement support for the __is_final type trait, to determine whether
a class is marked 'final', from Alberto Ganesh Barbati! Fixes
PR11462.

llvm-svn: 145775
2011-12-03 18:14:24 +00:00
Douglas Gregor bcfc7d0229 When we treat an #include or #import as a module import, create an
implicit ImportDecl in the translation unit to record the presence of
the import.

llvm-svn: 145727
2011-12-02 23:42:12 +00:00
Douglas Gregor 2b82c2a59e Implementing parsing and resolution of module export declarations
within module maps, which will (eventually) be used to re-export a
module from another module. There are still some pieces missing,
however.

llvm-svn: 145665
2011-12-02 01:47:07 +00:00
Douglas Gregor ff2be53f8f Introduce the notion of name visibility into modules. For a given
(sub)module, all of the names may be hidden, just the macro names may
be exposed (for example, after the preprocessor has seen the import of
the module but the parser has not), or all of the names may be
exposed. Importing a module makes its names, and the names in any of
its non-explicit submodules, visible to name lookup (transitively).

This commit only introduces the notion of name visible and marks
modules and submodules as visible when they are imported. The actual
name-hiding logic in the AST reader will follow (along with test cases).

llvm-svn: 145586
2011-12-01 17:11:21 +00:00
Douglas Gregor ef42154c17 Unbreak build with GCC. Clang is too lame to diagnose this particular ill-formedness
llvm-svn: 145539
2011-11-30 23:29:56 +00:00
Douglas Gregor de3ef502a9 Promote ModuleMap::Module to a namespace-scope class in the Basic
library, since modules cut across all of the libraries. Rename
serialization::Module to serialization::ModuleFile to side-step the
annoying naming conflict. Prune a bunch of ModuleMap.h includes that
are no longer needed (most files only needed the Module type).

llvm-svn: 145538
2011-11-30 23:21:26 +00:00
Douglas Gregor c3312fab71 Note that we'll need to handle __include_macros specially in the module loader
llvm-svn: 145514
2011-11-30 19:39:08 +00:00
Douglas Gregor 11729f01f9 Move the module auto-import logic after the logic that allows a
callback client to suggest an alternative search path and after we
complain when the included file can't be found. The former can't be
tested in isolation, the latter doesn't actually matter (because we
won't make a module suggestion if no header is available). However,
the flow is better this way.

llvm-svn: 145502
2011-11-30 18:12:06 +00:00
Douglas Gregor 4401fbee56 Trivial indentation fix for the code I just committed
llvm-svn: 145501
2011-11-30 18:03:26 +00:00
Douglas Gregor 41e115a81a Introduce an opt-in warning indicating when the compiler is treating
an #include/#import as a module import.

llvm-svn: 145500
2011-11-30 18:02:36 +00:00
Douglas Gregor 6902197407 Implement (de-)serialization of the description of a module and its
submodules. This information will eventually be used for name hiding
when dealing with submodules. For now, we only use it to ensure that
the module "key" returned when loading a module will always be a
module (rather than occasionally being a FileEntry).

llvm-svn: 145497
2011-11-30 17:33:56 +00:00
Benjamin Kramer 382eaadaa5 Use raw_ostream::indent.
llvm-svn: 145492
2011-11-30 15:07:30 +00:00
Douglas Gregor 4f3fa713bf Switch the module map printer over to
raw_ostream::write_escaped. Thanks, Benjamin!

llvm-svn: 145491
2011-11-30 15:00:49 +00:00
Douglas Gregor 1805b8a42f Teach the preprocessor how to handle module import declarations that
involve submodules (e.g., importing std.vector), rather than always
importing the top-level module.

llvm-svn: 145478
2011-11-30 04:26:53 +00:00
Douglas Gregor 71944203de Switch the module-loading interfaces and parser from a simple
top-level module name to a module path (e.g., std.vector). We're still
missing a number of pieces for this actually to do something.

llvm-svn: 145462
2011-11-30 00:36:36 +00:00
Douglas Gregor fe96ee0307 Escape strings when printing module maps, for silly operating systems
that use \ as a separator.

llvm-svn: 145439
2011-11-29 22:27:12 +00:00
Douglas Gregor f545f67de3 Switch on-demand module building over to use module maps, always. When
we infer the module map, we'll just print the module map to a
temporary file and generate the module using that.

llvm-svn: 145436
2011-11-29 21:59:16 +00:00
Douglas Gregor 514b636ada Teach the module import mechanism how to rebuild modules expressed via
module map, rather than assuming that there is an umbrella
header. This allows us to automatically build umbrella-less modules. 

llvm-svn: 145415
2011-11-29 19:06:37 +00:00
Douglas Gregor d28d1b8dc0 Expose the printing of module maps as part of the ModuleMap::Module
interface. No functionality change.

llvm-svn: 145411
2011-11-29 18:17:59 +00:00
Douglas Gregor ca295457e5 When attempting to load a module that is not in the module cache,
return the module itself (in the module map) rather than returning the
umbrella header used to build the module. While doing this, make sure
that we're inferring modules for frameworks to build that module.

llvm-svn: 145310
2011-11-28 23:16:06 +00:00
Argyrios Kyrtzidis e4d082827d Remove an assertion that is not valid if we cancel parsing.
llvm-svn: 145108
2011-11-23 20:27:29 +00:00
Benjamin Kramer 900f1defdd Remove assert from hot code path and add a clarifying comment.
The assert wasn't adding much value but slowed down Release+Asserts builds.

llvm-svn: 145082
2011-11-22 20:39:31 +00:00
Benjamin Kramer 3885737a1b Lexer: Don't throw away the hard work SSE did to find a slash.
We can reuse the information and avoid looping over all the bytes again.

llvm-svn: 145070
2011-11-22 18:56:46 +00:00
Kostya Serebryany c3333e879f implement __has_feature(address_sanitizer); also use LangOpts.AddressSanitizer instead of CodeGenOpts.AddressSanitizer
llvm-svn: 145054
2011-11-22 01:28:36 +00:00
Douglas Gregor 8ad31c2e36 Allow preprocessor callbacks to recover from a "file not found" error,
from Jason Haslam!

llvm-svn: 145012
2011-11-20 17:46:46 +00:00
Douglas Gregor c04f644311 When making a suggestion regarding which module to load rather than
preprocess/parse a header, report back with an actual module (which
may be a submodule) rather than just the name of the module.

llvm-svn: 144925
2011-11-17 22:44:56 +00:00