Commit Graph

19 Commits

Author SHA1 Message Date
Douglas Gregor cfa46a82b8 Track which particular submodule #undef's a macro, so that the actual
#undef only occurs if that submodule is imported.

llvm-svn: 165773
2012-10-12 00:16:50 +00:00
Douglas Gregor 5968b1b71f Diagnose the expansion of ambiguous macro definitions. This can happen
only with modules, when two disjoint modules #define the same
identifier to different token sequences.

llvm-svn: 165746
2012-10-11 21:07:39 +00:00
Douglas Gregor 5a4649b034 Deserialize macro history when we deserialize an identifier that has
macro history.

When deserializing macro history, we arrange history such that the
macros that have definitions (that haven't been #undef'd) and are
visible come at the beginning of the list, which is what the
preprocessor and other clients of Preprocessor::getMacroInfo()
expect. If additional macro definitions become visible later, they'll
be moved toward the front of the list. Note that it's possible to have
ambiguities, but we don't diagnose them yet.

There is a partially-implemented design decision here that, if a
particular identifier has been defined or #undef'd within the
translation unit, that definition (or #undef) hides any macro
definitions that come from imported modules. There's still a little
work to do to ensure that the right #undef'ing happens.

Additionally, we'll need to scope the update records for #undefs, so
they only kick in when the submodule containing that update record
becomes visible.

llvm-svn: 165682
2012-10-11 00:46:49 +00:00
Douglas Gregor c83de30add Introduce builtin macros to determine whether we're building a
specific module (__building_module(modulename)) and to get the name of
the current module as an identifier (__MODULE__). 

Used to help headers behave differently when they're being included as
part of building a module. Oh, the irony.

llvm-svn: 164605
2012-09-25 15:44:52 +00:00
Ted Kremenek c1e4dd0e8e Change @import to @__experimental_modules_import. We are not ready to commit to a particular syntax for modules,
and don't have time to push it forward in the near future.

llvm-svn: 151841
2012-03-01 22:07:04 +00:00
Douglas Gregor 663b48f13b Re-uglify #public and #private to #__public_macro and #__private_macro.
llvm-svn: 147469
2012-01-03 19:48:16 +00:00
Douglas Gregor da82e703d1 Eliminate the uglified keyword __import_module__ for importing
modules. This leaves us without an explicit syntax for importing
modules in C/C++, because such a syntax needs to be discussed
first. In Objective-C/Objective-C++, the @import syntax is used to
import modules.

Note that, under -fmodules, C/C++ programs can import modules via the
#include mechanism when a module map is in place for that header. This
allows us to work with modules in C/C++ without committing to a syntax.

llvm-svn: 147467
2012-01-03 19:32:59 +00:00
Douglas Gregor 0bf886d41a Under -fmodules, accept #public <macroname> and #private <macroname>
to make a macro public (the default for headers) or private,
respectively.

llvm-svn: 147455
2012-01-03 18:24:14 +00:00
Richard Trieu 553b2b2e5d Modify how the -verify flag works. Currently, the verification string and
diagnostic message are compared.  If either is a substring of the other, then
no error is given.  This gives rise to an unexpected case:

  // expect-error{{candidate function has different number of parameters}}

will match the following error messages from Clang:

  candidate function has different number of parameters (expected 1 but has 2)
  candidate function has different number of parameters

It will also match these other error messages:

  candidate function
  function has different number of parameters
  number of parameters

This patch will change so that the verification string must be a substring of
the diagnostic message before accepting.  Also, all the failing tests from this
change have been corrected.  Some stats from this cleanup:

87 - removed extra spaces around verification strings
70 - wording updates to diagnostics
40 - extra leading or trailing characters (typos, unmatched parens or quotes)
35 - diagnostic level was included (error:, warning:, or note:)
18 - flag name put in the warning (-Wprotocol)

llvm-svn: 146619
2011-12-15 00:38:15 +00:00
Douglas Gregor 70db54f18d Eliminate the -emit-module option, which emitted a module by parsing a
source file (e.g., a header). Immediately steal this useful option
name for building modules from a module map file.

llvm-svn: 145444
2011-11-29 22:42:06 +00:00
Douglas Gregor 84febf4a4d Migrate a few more modules tests over to -emit-module-from-map.
llvm-svn: 144779
2011-11-16 05:16:30 +00:00
Douglas Gregor ebf0049901 For modules, all macros that aren't include guards are implicitly
public. Add a __private_macro__ directive to hide a macro, similar to
the __module_private__ declaration specifier.

llvm-svn: 142188
2011-10-17 15:32:29 +00:00
Douglas Gregor 21931efc4d Make -E work with module imports
llvm-svn: 139750
2011-09-14 23:13:09 +00:00
Douglas Gregor d7910e95bd Don't try to write a macro offset for an identifier that names a non-exported macro, for real this time
llvm-svn: 139745
2011-09-14 22:14:14 +00:00
Douglas Gregor 4fe9b18182 Revert my exported-macro hackery. Something is amiss
llvm-svn: 139734
2011-09-14 20:57:14 +00:00
Douglas Gregor 4184ab0b26 Don't try to write a macro offset for an identifier that names a non-exported macro
llvm-svn: 139728
2011-09-14 20:36:30 +00:00
Douglas Gregor 1735f4e752 For modules, use a hash of the compiler version, language options, and
target triple to separate modules built under different
conditions. The hash is used to create a subdirectory in the module
cache path where other invocations of the compiler (with the same
version, language options, etc.) can find the precompiled modules.

llvm-svn: 139662
2011-09-13 23:15:45 +00:00
Douglas Gregor 1e44e02292 Introduce a cc1-level option to provide the path to the module cache,
where the compiler will look for module files. Eliminates the
egregious hack where we looked into the header search paths for
modules.

llvm-svn: 139538
2011-09-12 20:41:59 +00:00
Douglas Gregor 4a69c2e6c5 Modules hide macro definitions by default, so that silly things like
include guards don't show up as macro definitions in every translation
unit that imports a module. Macro definitions can, however, be
exported with the intentionally-ugly #__export_macro__
directive. Implement this feature by not even bothering to serialize
non-exported macros to a module, because clients of that module need
not (should not) know that these macros even exist.

llvm-svn: 138943
2011-09-01 17:04:32 +00:00