================ @@ -0,0 +1,99 @@ +//===--- SemaAPINotesInternal.h - API Notes Sema Internals ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_LIB_SEMA_SEMAAPINOTESINTERNAL_H +#define LLVM_CLANG_LIB_SEMA_SEMAAPINOTESINTERNAL_H + +#include "clang/APINotes/Types.h" +#include "clang/Basic/SourceLocation.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/STLFunctionalExtras.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include <string> +#include <utility> + +namespace clang { +class Sema; +struct APINotesParameterSelectorCandidates; +namespace api_notes { +class APINotesReader; +} // namespace api_notes + +/// Source name and location for a declaration seen by Sema. +struct APINotesSelectorDiagnosticName { + SourceLocation Loc; + std::string Name; +}; + +/// Tracks exact Where.Parameters selectors from one API notes reader. +/// +/// Sema marks selectors as used when a visible declaration matches them. It +/// also records broad/name-only declarations seen in the translation unit, so +/// end-of-TU diagnostics can warn about exact selectors for known names that +/// were never matched. +struct APINotesSelectorDiagnosticReaderState { + /// Exact Where.Parameters selector keys stored by API notes. The bool is + /// true once Sema sees a declaration matching the exact selector. + llvm::DenseMap<api_notes::APINotesFunctionSelectorKey, bool> SelectorUsed; + + /// Maps broad/name-only keys to a declaration location/name used for + /// diagnostics. + llvm::DenseMap<api_notes::APINotesFunctionSelectorKey, + APINotesSelectorDiagnosticName> + SeenNames; + + void addSelector(const api_notes::APINotesFunctionSelectorKey &Key) { + SelectorUsed.try_emplace(Key, false); + } + + void + addSelectors(llvm::SmallVectorImpl<api_notes::APINotesFunctionSelectorKey> ---------------- Xazax-hun wrote:
This only reads the vector, could take an `ArrayRef` by value instead. https://github.com/llvm/llvm-project/pull/209408 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
