Skip to content
  1. Dec 13, 2013
  2. Dec 12, 2013
  3. Dec 11, 2013
  4. Dec 06, 2013
    • Daniel Jasper's avatar
      Allow string literals as module names. · 3cd34c76
      Daniel Jasper authored
      In order to make the migration to modules easier, it seems to be helpful
      to allow a 1:1 mapping between target names of a current build system
      and the corresponding C++ modules. As  such targets commonly contain
      characters like "-". ":" and "/", allowing arbitrary quote-escaped
      strings seems to be a straightforward option.
      
      After several offline discussions, the precise mechanisms for C++
      module names especially regarding submodules and import statements has
      yet to be determined. Thus, this patch only enables string literals as
      names inside the module map files which can be used by automatic module
      import (through #include).
      
      Also improve the error message on missing use-declarations.
      
      llvm-svn: 196573
      3cd34c76
  5. Dec 03, 2013
    • Daniel Jasper's avatar
      Fix corner case in module-based layering warning. · 88d8695a
      Daniel Jasper authored
      Before, there SourceManager would not return a FileEntry for a
      SourceLocation of a macro expansion (if the header name itself is
      defined in a macro). We'd then fallback to assume that the module
      currently being built is the including module. However, in this case we
      are actually interested in the spelling location of the filename loc in
      order to derive the including module.
      
      llvm-svn: 196311
      88d8695a
  6. Nov 23, 2013
  7. Nov 15, 2013
    • Richard Smith's avatar
      When we hit a #include directive that maps to a module import, emit a token · ce587f5e
      Richard Smith authored
      representing the module import rather than making the module immediately
      visible. This serves two goals:
       * It avoids making declarations in the module visible prematurely, if we
         walk past the #include during a tentative parse, for instance, and
       * It gives a diagnostic (although, admittedly, not a very nice one) if
         a header with a corresponding module is included anywhere other than
         at the top level.
      
      llvm-svn: 194782
      ce587f5e
  8. Nov 07, 2013
    • Douglas Gregor's avatar
      Modules: Teach the preprocessor to recognize 'import' only after an '@'. · 594b8c93
      Douglas Gregor authored
      The preprocessor currently recognizes module declarations to load a
      module based on seeing the 'import' keyword followed by an
      identifier. This sequence is fairly unlikely in C (one would need a
      type named 'import'), but is more common in Objective-C (where a
      variable named 'import' can cause problems). Since import declarations
      currently require a leading '@', recognize that in the preprocessor as
      well. Fixes <rdar://problem/15084587>.
      
      llvm-svn: 194225
      594b8c93
  9. Nov 04, 2013
    • Dmitri Gribenko's avatar
      Include non-explicit submodules in exported module list · e9bcf5b7
      Dmitri Gribenko authored
      This change fixes Richard's testcase for r193815.  Now we include non-explicit
      submodules into the list of exports.
      
      The test failed previously because:
      - recursive_visibility_a1.inner is not imported (only recursive_visibility_a1 is),
      - thus the 'inner' submodule is not showing up in any of the import lists,
      - and because of this getExportedModules() is not returning the
        correct module set -- it only considers modules that are imported.
      
      The fix is to make Module::getExportedModules() include non-explicit submodules
      into the list of exports.
      
      llvm-svn: 194018
      e9bcf5b7
  10. Oct 28, 2013
    • Richard Smith's avatar
      Allow a new syntax in a module requires-declaration: · a3feee2a
      Richard Smith authored
        requires ! feature
      
      The purpose of this is to allow (for instance) the module map for /usr/include
      to exclude <tgmath.h> and <complex.h> when building in C++ (these headers are
      instead provided by the C++ standard library in this case, and the glibc C
      <tgmath.h> header would otherwise try to include <complex.h>, resulting in a
      module cycle).
      
      llvm-svn: 193549
      a3feee2a
  11. Oct 24, 2013
    • Manuel Klimek's avatar
      Use the same SourceManager for ModuleMaps and compilations. · 1f76c4e8
      Manuel Klimek authored
      This allows using virtual file mappings on the original SourceManager to
      map in virtual module.map files. Without this patch, the ModuleMap
      search will find a module.map file (as the FileEntry exists in the
      FileManager), but will be unable to get the content from the
      SourceManager (as ModuleMap previously created its own SourceManager).
      
      Two problems needed to be fixed which this patch exposed:
      
      1. Storing the inferred module map
      When writing out a module, the ASTWriter stores the names of the files
      in the main source manager; when loading the AST again, the ASTReader
      errs out if such a file is found missing, unless it is overridden.
      Previously CompilerInstance's compileModule method would store the
      inferred module map to a temporary file; the problem with this approach
      is that now that the module map is handled by the main source manager,
      the ASTWriter stores the name of the temporary module map as source to
      the compilation; later, when the module is loaded, the temporary file
      has already been deleted, which leads to a compilation error. This patch
      changes the inferred module map to instead inject a virtual file into
      the source manager. This both saves some disk IO, and works with how the
      ASTWriter/ASTReader handle overridden source files.
      
      2. Changing test input in test/Modules/Inputs/*
      Now that the module map file is handled by the main source manager, the
      VerifyDiagnosticConsumer will not ignore diagnostics created while
      parsing the module map file. The module test test/Modules/renamed.m uses
      -I test/Modules/Inputs and triggers recursive loading of all module maps
      in test/Modules/Inputs, some of which had conflicting names, thus
      leading errors while parsing the module maps. Those diagnostics already
      occur on trunk, but before this patch they would not break the test, as
      they were ignored by the VerifyDiagnosticConsumer. This patch thus
      changes the module maps that have been recently introduced which broke
      the invariant of compatible modules maps in test/Modules/Inputs.
      
      llvm-svn: 193314
      1f76c4e8
  12. Oct 23, 2013
  13. Oct 22, 2013
    • Daniel Jasper's avatar
      Allow a header to be part of multiple modules. · 97da9178
      Daniel Jasper authored
      This patch changes two things:
      
      a) Allow a header to be part of multiple modules. The reasoning is that
      in existing codebases that have a module-like build system, the same
      headers might be used in several build targets. Simple reasons might be
      that they defined different classes that are declared in the same
      header. Supporting a header as a part of multiple modules will make the
      transistion easier for those cases. A later step in clang can then
      determine whether the two modules are actually compatible and can be
      merged and error out appropriately. The later check is similar to what
      needs to be done for template specializations anyway.
      
      b) Allow modules to be stored in a directory tree separate from the
      headers they describe.
      
      Review: http://llvm-reviews.chandlerc.com/D1951
      llvm-svn: 193151
      97da9178
  14. Oct 19, 2013
  15. Oct 18, 2013
    • Richard Smith's avatar
    • Richard Smith's avatar
      Basic ODR checking for C++ modules: · 2b9e3e39
      Richard Smith authored
      If we have multiple definitions of the same entity from different modules, we
      nominate the first definition which we see as being the canonical definition.
      If we load a declaration from a different definition and we can't find a
      corresponding declaration in the canonical definition, issue a diagnostic.
      
      This is insufficient to prevent things from going horribly wrong in all cases
      -- we might be in the middle of emitting IR for a function when we trigger some
      deserialization and discover that it refers to an incoherent piece of the AST,
      by which point it's probably too late to bail out -- but we'll at least produce
      a diagnostic.
      
      llvm-svn: 192950
      2b9e3e39
  16. Oct 16, 2013
  17. Oct 14, 2013
  18. Oct 07, 2013
  19. Sep 24, 2013
    • Daniel Jasper's avatar
      Add -fmodule-map-file option. · ca9f7381
      Daniel Jasper authored
      With this option, arbitrarily named module map files can be specified
      to be loaded as required for headers in the respective (sub)directories.
      
      This, together with the extern module declaration allows for specifying
      module maps in a modular fashion without the need for files called
      "module.map".
      
      Among other things, this allows a directory to contain two modules that
      are completely independent of one another.
      
      Review: http://llvm-reviews.chandlerc.com/D1697.
      llvm-svn: 191284
      ca9f7381
    • Daniel Jasper's avatar
      Module use declarations (II) · ba7f2f71
      Daniel Jasper authored
      Review: http://llvm-reviews.chandlerc.com/D1546.
      
      I have picked up this patch form Lawrence
      (http://llvm-reviews.chandlerc.com/D1063) and did a few changes.
      
      From the original change description (updated as appropriate):
      This patch adds a check that ensures that modules only use modules they
      have so declared. To this end, it adds a statement on intended module
      use to the module.map grammar:
      
        use module-id
      
      A module can then only use headers from other modules if it 'uses' them.
      This enforcement is off by default, but may be turned on with the new
      option -fmodules-decluse.
      
      When enforcing the module semantics, we also need to consider a source
      file part of a module. This is achieved with a compiler option
      
      -fmodule-name=<module-id>.
      
      The compiler at present only applies restrictions to the module directly
      being built.
      
      llvm-svn: 191283
      ba7f2f71
  20. Sep 11, 2013
    • Daniel Jasper's avatar
      Support for modular module-map-files · 97292843
      Daniel Jasper authored
      This patch is the first step to make module-map-files modular (instead
      of requiring a single "module.map"-file per include directory). This
      step adds a new "extern module" declaration that enables
      module-map-files to reference one another along with a very basic
      implementation.
      
      The next steps are:
      
      * Combine this with the use-declaration (from
        http://llvm-reviews.chandlerc.com/D1546) in order to only load module
        map files required for a specific compilation.
      * Add an additional flag to start with a specific module-map-file (instead
        of requiring there to be at least one "module.map").
      
      Review: http://llvm-reviews.chandlerc.com/D1637
      llvm-svn: 190497
      97292843
  21. Sep 09, 2013
    • Richard Smith's avatar
      C++ modules: if a class is defined in multiple modules (for instance, because · d55889a6
      Richard Smith authored
      it is an implicit instantiation of a class template specialization), pick the
      first-loaded definition to be the canonical definition, and merge all other
      definitions into it.
      
      This is still rather incomplete -- we need to extend every form of declaration
      that can appear within a CXXRecordDecl to be redeclarable if it came from an
      AST file (this includes fields, enumerators, ...).
      
      llvm-svn: 190315
      d55889a6
    • Richard Smith's avatar
      C++ modules: fix a bug where loading a declaration with some name would prevent · 4abe0a8d
      Richard Smith authored
      name lookup from lazily deserializing the other declarations with the same
      name, by tracking a bit to indicate whether a name in a DeclContext might have
      additional external results. This also allows lazier reconciling of the lookup
      table if a module import adds decls to a pre-existing DC.
      
      However, this exposes a pre-existing bug, which causes a regression in
      test/Modules/decldef.mm: if we have a reference to a declaration, and a
      later-imported module adds a redeclaration, nothing causes us to load that
      redeclaration when we use or emit the reference (which can manifest as a
      reference to an undefined inline function, a use of an incomplete type, and so
      on). decldef.mm has been extended with an additional testcase which fails with
      or without this change.
      
      llvm-svn: 190293
      4abe0a8d
  22. Sep 05, 2013
    • Eli Friedman's avatar
      Note when a decl is used in AST files. · 276dd188
      Eli Friedman authored
      When an AST file is built based on another AST file, it can use a decl from
      the fist file, and therefore mark the "isUsed" bit.  We need to note this in
      the AST file so that the bit is set correctly when the second AST file is
      loaded.
      
      This patch introduces the distinction between setIsUsed() and markUsed() so
      that we don't call into the ASTMutationListener callback when it wouldn't
      be appropriate.
      
      Fixes PR16635.
      
      llvm-svn: 190016
      276dd188
  23. Aug 30, 2013
  24. Aug 20, 2013
  25. Aug 12, 2013
    • Tim Northover's avatar
      Fix FileCheck --check-prefix lines. · 19ae1175
      Tim Northover authored
      Various tests had sprung up over the years which had --check-prefix=ABC on the
      RUN line, but "CHECK-ABC:" later on. This happened to work before, but was
      strictly incorrect. FileCheck is getting stricter soon though.
      
      Patch by Ron Ofir.
      
      llvm-svn: 188174
      19ae1175
  26. Aug 02, 2013
    • Richard Smith's avatar
      When merging redeclaration chains across modules, if a declaration is visible · 7ecc31b0
      Richard Smith authored
      in one module but is only declared as a friend in another module, keep it
      visible in the result of the merge.
      
      This is incomplete on two axes:
      
      1) Our handling of local extern declarations is basically broken (we put them
      in the wrong decl context, and don't find them in redeclaration lookup, unless
      they've previously been declared), and this results in them making friends
      visible after a merge.
      
      2) Eventually we'll need to mark that this has happened, and more carefully
      check whether a declaration should be visible if it was only visible in some
      of the modules in which it was declared. Fortunately it's rare for the
      identifier namespace of a declaration to change along its redeclaration chain.
      
      llvm-svn: 187639
      7ecc31b0
  27. Aug 01, 2013
  28. Jul 26, 2013
    • Richard Smith's avatar
      When we perform dependent name lookup during template instantiation, it's not · 0e5d7b8c
      Richard Smith authored
      sufficient to only consider names visible at the point of instantiation,
      because that may not include names that were visible when the template was
      defined. More generally, if the instantiation backtrace goes through a module
      M, then every declaration visible within M should be available to the
      instantiation. Any of those declarations might be part of the interface that M
      intended to export to a template that it instantiates.
      
      The fix here has two parts:
      
      1) If we find a non-visible declaration during name lookup during template
      instantiation, check whether the declaration was visible from the defining
      module of all entities on the active template instantiation stack. The defining
      module is not the owning module in all cases: we look at the module in which a
      template was defined, not the module in which it was first instantiated.
      
      2) Perform pending instantiations at the end of a module, not at the end of the
      translation unit. This is general goodness, since it significantly cuts down
      the amount of redundant work that is performed in every TU importing a module,
      and also implicitly adds the module containing the point of instantiation to
      the set of modules checked for declarations in a lookup within a template
      instantiation.
      
      There's a known issue here with template instantiations performed while
      building a module, if additional imports are added later on. I'll fix that
      in a subsequent commit.
      
      llvm-svn: 187167
      0e5d7b8c
  29. Jul 14, 2013
  30. Jul 04, 2013
  31. Jun 25, 2013
  32. Jun 24, 2013
    • Richard Smith's avatar
      Avoid adding entries to the DeclContext lookup table multiple times when lazily · cf4ab520
      Richard Smith authored
      constructing a lookup table.
      
      Previously, buildLookup would add lookup table entries for each item lexically
      within the DC, and adding the first entry with a given name would trigger the
      external source to add all its entries with that name. Then buildLookup would
      carry on and re-add those entries all over again.
      
      Instead, follow a simple rule: a declaration from an external source is only
      ever made visible by the external source. One exception to this: since we don't
      usually build a lookup table for the TU in C, and we never serialize one, we
      don't expect the external source to provide lookups in the TU in C, so we build
      those ones ourselves.
      
      llvm-svn: 184696
      cf4ab520
Loading