static_scope.cpp 675 B

123456789101112131415161718192021
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "executable_semantics/ast/static_scope.h"
  5. #include "executable_semantics/common/error.h"
  6. namespace Carbon {
  7. NamedEntity::~NamedEntity() = default;
  8. void StaticScope::Add(std::string name, Nonnull<const NamedEntity*> entity) {
  9. if (!declared_names_.insert({name, entity}).second) {
  10. FATAL_COMPILATION_ERROR(entity->source_loc())
  11. << "Duplicate name `" << name << "` also found at "
  12. << declared_names_[name]->source_loc();
  13. }
  14. }
  15. } // namespace Carbon