llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Chen Miao (ChenMiaoi) <details> <summary>Changes</summary> `PPDirectiveParameter` stores a source range for each embed parameter, but `getParameterRange()` has no callers. Remove the base class and the unused range arguments from embed parameter construction. --- Full diff: https://github.com/llvm/llvm-project/pull/240235.diff 3 Files Affected: - (removed) clang/include/clang/Lex/PPDirectiveParameter.h (-33) - (modified) clang/include/clang/Lex/PPEmbedParameters.h (+13-16) - (modified) clang/lib/Lex/PPDirectives.cpp (+5-10) ``````````diff diff --git a/clang/include/clang/Lex/PPDirectiveParameter.h b/clang/include/clang/Lex/PPDirectiveParameter.h deleted file mode 100644 index 83f0566d739b10..00000000000000 --- a/clang/include/clang/Lex/PPDirectiveParameter.h +++ /dev/null @@ -1,33 +0,0 @@ -//===--- PPDirectiveParameter.h ---------------------------------*- 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 -// -//===----------------------------------------------------------------------===// -// -// This file defines the base class for preprocessor directive parameters, such -// as limit(1) or suffix(x) for #embed. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_LEX_PPDIRECTIVEPARAMETER_H -#define LLVM_CLANG_LEX_PPDIRECTIVEPARAMETER_H - -#include "clang/Basic/SourceLocation.h" - -namespace clang { - -/// Captures basic information about a preprocessor directive parameter. -class PPDirectiveParameter { - SourceRange R; - -public: - PPDirectiveParameter(SourceRange R) : R(R) {} - - SourceRange getParameterRange() const { return R; } -}; - -} // end namespace clang - -#endif diff --git a/clang/include/clang/Lex/PPEmbedParameters.h b/clang/include/clang/Lex/PPEmbedParameters.h index 41a69664df3667..17346742fcad77 100644 --- a/clang/include/clang/Lex/PPEmbedParameters.h +++ b/clang/include/clang/Lex/PPEmbedParameters.h @@ -13,7 +13,6 @@ #ifndef LLVM_CLANG_LEX_PPEMBEDPARAMETERS_H #define LLVM_CLANG_LEX_PPEMBEDPARAMETERS_H -#include "clang/Lex/PPDirectiveParameter.h" #include "clang/Lex/Token.h" #include "llvm/ADT/SmallVector.h" @@ -21,52 +20,50 @@ namespace clang { /// Preprocessor extension embed parameter "clang::offset" /// `clang::offset( constant-expression )` -class PPEmbedParameterOffset : public PPDirectiveParameter { +class PPEmbedParameterOffset { public: size_t Offset; - PPEmbedParameterOffset(size_t Offset, SourceRange R) - : PPDirectiveParameter(R), Offset(Offset) {} + explicit PPEmbedParameterOffset(size_t Offset) : Offset(Offset) {} }; /// Preprocessor standard embed parameter "limit" /// `limit( constant-expression )` -class PPEmbedParameterLimit : public PPDirectiveParameter { +class PPEmbedParameterLimit { public: size_t Limit; - PPEmbedParameterLimit(size_t Limit, SourceRange R) - : PPDirectiveParameter(R), Limit(Limit) {} + explicit PPEmbedParameterLimit(size_t Limit) : Limit(Limit) {} }; /// Preprocessor standard embed parameter "prefix" /// `prefix( balanced-token-seq )` -class PPEmbedParameterPrefix : public PPDirectiveParameter { +class PPEmbedParameterPrefix { public: SmallVector<Token, 2> Tokens; - PPEmbedParameterPrefix(SmallVectorImpl<Token> &&Tokens, SourceRange R) - : PPDirectiveParameter(R), Tokens(std::move(Tokens)) {} + explicit PPEmbedParameterPrefix(SmallVectorImpl<Token> &&Tokens) + : Tokens(std::move(Tokens)) {} }; /// Preprocessor standard embed parameter "suffix" /// `suffix( balanced-token-seq )` -class PPEmbedParameterSuffix : public PPDirectiveParameter { +class PPEmbedParameterSuffix { public: SmallVector<Token, 2> Tokens; - PPEmbedParameterSuffix(SmallVectorImpl<Token> &&Tokens, SourceRange R) - : PPDirectiveParameter(R), Tokens(std::move(Tokens)) {} + explicit PPEmbedParameterSuffix(SmallVectorImpl<Token> &&Tokens) + : Tokens(std::move(Tokens)) {} }; /// Preprocessor standard embed parameter "if_empty" /// `if_empty( balanced-token-seq )` -class PPEmbedParameterIfEmpty : public PPDirectiveParameter { +class PPEmbedParameterIfEmpty { public: SmallVector<Token, 2> Tokens; - PPEmbedParameterIfEmpty(SmallVectorImpl<Token> &&Tokens, SourceRange R) - : PPDirectiveParameter(R), Tokens(std::move(Tokens)) {} + explicit PPEmbedParameterIfEmpty(SmallVectorImpl<Token> &&Tokens) + : Tokens(std::move(Tokens)) {} }; struct LexEmbedParametersResult { diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 5ff165e3ddf81f..d122ca059ea5f6 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -3979,8 +3979,7 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool ForHasEmbed) { std::optional<size_t> Limit = LexParenthesizedIntegerExpr(); if (!Limit) return std::nullopt; - Result.MaybeLimitParam = - PPEmbedParameterLimit{*Limit, {ParamStartLoc, CurTok.getLocation()}}; + Result.MaybeLimitParam = PPEmbedParameterLimit{*Limit}; } else if (Parameter == "clang::offset") { if (Result.MaybeOffsetParam) Diag(CurTok, diag::err_pp_embed_dup_params) << Parameter; @@ -3988,8 +3987,7 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool ForHasEmbed) { std::optional<size_t> Offset = LexParenthesizedIntegerExpr(); if (!Offset) return std::nullopt; - Result.MaybeOffsetParam = PPEmbedParameterOffset{ - *Offset, {ParamStartLoc, CurTok.getLocation()}}; + Result.MaybeOffsetParam = PPEmbedParameterOffset{*Offset}; } else if (Parameter == "prefix") { if (Result.MaybePrefixParam) Diag(CurTok, diag::err_pp_embed_dup_params) << Parameter; @@ -3997,8 +3995,7 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool ForHasEmbed) { SmallVector<Token, 4> Soup; if (!LexParenthesizedBalancedTokenSoup(Soup)) return std::nullopt; - Result.MaybePrefixParam = PPEmbedParameterPrefix{ - std::move(Soup), {ParamStartLoc, CurTok.getLocation()}}; + Result.MaybePrefixParam = PPEmbedParameterPrefix{std::move(Soup)}; } else if (Parameter == "suffix") { if (Result.MaybeSuffixParam) Diag(CurTok, diag::err_pp_embed_dup_params) << Parameter; @@ -4006,8 +4003,7 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool ForHasEmbed) { SmallVector<Token, 4> Soup; if (!LexParenthesizedBalancedTokenSoup(Soup)) return std::nullopt; - Result.MaybeSuffixParam = PPEmbedParameterSuffix{ - std::move(Soup), {ParamStartLoc, CurTok.getLocation()}}; + Result.MaybeSuffixParam = PPEmbedParameterSuffix{std::move(Soup)}; } else if (Parameter == "if_empty") { if (Result.MaybeIfEmptyParam) Diag(CurTok, diag::err_pp_embed_dup_params) << Parameter; @@ -4015,8 +4011,7 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool ForHasEmbed) { SmallVector<Token, 4> Soup; if (!LexParenthesizedBalancedTokenSoup(Soup)) return std::nullopt; - Result.MaybeIfEmptyParam = PPEmbedParameterIfEmpty{ - std::move(Soup), {ParamStartLoc, CurTok.getLocation()}}; + Result.MaybeIfEmptyParam = PPEmbedParameterIfEmpty{std::move(Soup)}; } else { ++Result.UnrecognizedParams; `````````` </details> https://github.com/llvm/llvm-project/pull/240235 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
