Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up ModuleConfig initialization #70644

Merged
merged 3 commits into from
Apr 12, 2020

Commits on Apr 1, 2020

  1. Remove some dead code.

    The condition checks if `sess.opts.output_types` doesn't contain
    `OutputType::Assembly` within a match arm that is only reached if
    `sess.opts.output_types` contains `OutputType::Assembly`.
    nnethercote committed Apr 1, 2020
    Configuration menu
    Copy the full SHA
    4c8bf50 View commit details
    Browse the repository at this point in the history
  2. Improve ModuleConfig initialization.

    There are three `ModuleConfigs`, one for each `ModuleKind`. The code to
    initialized them is spaghetti imperative code that sets each field to a
    default value and then modifies many fields in complicated ways. This
    makes it very hard to tell what value ends up in each field in each
    config.
    
    For example, the `modules_config.emit_pre_lto_bc` field is set twice,
    which means it can be set to true and then incorrectly set back to
    false. (This probably hasn't been noticed because it happens in a very
    obscure case.)
    
    This commit changes the code to a declarative style in which
    `ModuleConfig::new` initializes all fields and then they are never
    changed again. This is slightly more concise and much easier to read.
    (And it fixes the abovementioned `emit_pre_lto_bc` error as well.)
    nnethercote committed Apr 1, 2020
    Configuration menu
    Copy the full SHA
    72a28e8 View commit details
    Browse the repository at this point in the history
  3. Rename modules_config as regular_config.

    That way it matches `ModuleKind::Regular`.
    nnethercote committed Apr 1, 2020
    Configuration menu
    Copy the full SHA
    5131c69 View commit details
    Browse the repository at this point in the history