diff --git a/.gitignore b/.gitignore index 3ff328851..ffb7aded0 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ cmake-build-*/ prefix/ CMakeLists.txt.user CMakeUserPresets.json +.ccls diff --git a/include/slang/parsing/ParserMetadata.h b/include/slang/parsing/ParserMetadata.h index 8e1164766..7e82267da 100644 --- a/include/slang/parsing/ParserMetadata.h +++ b/include/slang/parsing/ParserMetadata.h @@ -44,6 +44,9 @@ struct SLANG_EXPORT ParserMetadata { /// A list of all class declarations parsed. std::vector classDecls; + /// A list of all interface port headers parsed. + std::vector interfacePorts; + /// The EOF token, if one has already been consumed by the parser. /// Otherwise an empty token. Token eofToken; diff --git a/source/driver/Driver.cpp b/source/driver/Driver.cpp index 135bc3e69..cf11b3046 100644 --- a/source/driver/Driver.cpp +++ b/source/driver/Driver.cpp @@ -612,6 +612,12 @@ bool Driver::parseAllSources() { missing.emplace(name); } } + + for (auto intf : meta.interfacePorts) { + std::string_view name = intf->nameOrKeyword.valueText(); + if (knownNames.find(name) == knownNames.end()) + missing.emplace(name); + } }; for (auto& tree : syntaxTrees) diff --git a/source/parsing/Parser.cpp b/source/parsing/Parser.cpp index f5ba9ea31..e943c960b 100644 --- a/source/parsing/Parser.cpp +++ b/source/parsing/Parser.cpp @@ -234,7 +234,10 @@ PortHeaderSyntax& Parser::parsePortHeader(Token constKeyword, Token direction) { if (!constKeyword && peek(1).kind == TokenKind::Dot && peek(2).kind == TokenKind::Identifier && peek(3).kind == TokenKind::Identifier) { auto name = consume(); - return factory.interfacePortHeader(name, parseDotMemberClause()); + InterfacePortHeaderSyntax* header = + &factory.interfacePortHeader(name, parseDotMemberClause()); + meta.interfacePorts.push_back(header); + return *header; } DataTypeSyntax* type; diff --git a/source/parsing/ParserMetadata.cpp b/source/parsing/ParserMetadata.cpp index 4921a10f9..e6b9eb644 100644 --- a/source/parsing/ParserMetadata.cpp +++ b/source/parsing/ParserMetadata.cpp @@ -45,6 +45,13 @@ class MetadataVisitor : public SyntaxVisitor { visitDefault(syntax); } + void handle(const InterfacePortHeaderSyntax& syntax) { + std::string_view name = syntax.nameOrKeyword.valueText(); + if (name != "" && name != "interface") + meta.interfacePorts.push_back(&syntax); + visitDefault(syntax); + } + void handle(const DefParamSyntax& syntax) { meta.hasDefparams = true; visitDefault(syntax);