mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:20:10 +01:00
This fixes various violations of C++'s One Definition Rule, where we accidentally gave the same static data member multiple definitions in different translation units. Clang happens to emit such definitions with weak linkage, which allows us to get away with this without link errors, but it's still formally incorrect. Also switch keyword order around for a handful of instances of `constexpr inline`, per agreement in open discussion. This happens to reduce the size of a `-c dbg` toolchain binary by 7.2 MiB, presumably by making more of our symbols and especially debug info discardable.
32 lines
1.1 KiB
C++
32 lines
1.1 KiB
C++
|
|
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef CARBON_TOOLCHAIN_CHECK_SCOPE_INDEX_H_
|
|
#define CARBON_TOOLCHAIN_CHECK_SCOPE_INDEX_H_
|
|
|
|
#include "toolchain/base/index_base.h"
|
|
|
|
namespace Carbon::Check {
|
|
|
|
// An index for a pushed scope. This may correspond to a permanent scope with a
|
|
// corresponding `NameScope`, in which case a different index will be assigned
|
|
// each time the scope is entered. Alternatively, it may be a temporary scope
|
|
// such as is created for a block, and will only be entered once.
|
|
//
|
|
// `ScopeIndex` values are comparable. Lower `ScopeIndex` values correspond to
|
|
// scopes entered earlier in the file.
|
|
struct ScopeIndex : public IndexBase<ScopeIndex> {
|
|
static constexpr llvm::StringLiteral Label = "scope";
|
|
static const ScopeIndex Package;
|
|
|
|
using IndexBase::IndexBase;
|
|
};
|
|
|
|
inline constexpr ScopeIndex ScopeIndex::Package = ScopeIndex(0);
|
|
|
|
} // namespace Carbon::Check
|
|
|
|
#endif // CARBON_TOOLCHAIN_CHECK_SCOPE_INDEX_H_
|