Skip to content

Commit db491fb

Browse files
author
Sriya Pratipati
committed
Fixed merge conflicts
2 parents b63141a + 572b89a commit db491fb

File tree

62 files changed

+1664
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1664
-150
lines changed

clang-tools-extra/clang-doc/Serialize.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ getFunctionPrototype(const FunctionDecl *FuncDecl) {
113113
Stream << " " << ParamDecl->getNameAsString();
114114

115115
// Print default argument if it exists
116-
if (ParamDecl->hasDefaultArg()) {
117-
const Expr *DefaultArg = ParamDecl->getDefaultArg();
118-
if (DefaultArg) {
116+
if (ParamDecl->hasDefaultArg() &&
117+
!ParamDecl->hasUninstantiatedDefaultArg()) {
118+
if (const Expr *DefaultArg = ParamDecl->getDefaultArg()) {
119119
Stream << " = ";
120120
DefaultArg->printPretty(Stream, nullptr, Ctx.getPrintingPolicy());
121121
}

clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ KEYWORD(offset)
102102

103103
// StaticSampler Keywords:
104104
KEYWORD(mipLODBias)
105+
KEYWORD(maxAnisotropy)
106+
KEYWORD(minLOD)
107+
KEYWORD(maxLOD)
105108

106109
// Unbounded Enum:
107110
UNBOUNDED_ENUM(unbounded, "unbounded")

clang/include/clang/Parse/ParseHLSLRootSignature.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ class RootSignatureParser {
112112
struct ParsedStaticSamplerParams {
113113
std::optional<llvm::hlsl::rootsig::Register> Reg;
114114
std::optional<float> MipLODBias;
115+
std::optional<uint32_t> MaxAnisotropy;
116+
std::optional<float> MinLOD;
117+
std::optional<float> MaxLOD;
115118
};
116119
std::optional<ParsedStaticSamplerParams> parseStaticSamplerParams();
117120

clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,6 @@ class ModuleDepCollector final : public DependencyCollector {
311311
const ArrayRef<StringRef> StableDirs;
312312
/// Path to the main source file.
313313
std::string MainFile;
314-
/// Hash identifying the compilation conditions of the current TU.
315-
std::string ContextHash;
316314
/// Non-modular file dependencies. This includes the main source file and
317315
/// textually included header files.
318316
std::vector<std::string> FileDeps;

clang/lib/Frontend/VerifyDiagnosticConsumer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ bool VerifyDiagnosticConsumer::HandleComment(Preprocessor &PP,
812812
C2 += C.substr(last, loc-last);
813813
last = loc + 1;
814814

815-
if (C[last] == '\n' || C[last] == '\r') {
815+
if (last < C.size() && (C[last] == '\n' || C[last] == '\r')) {
816816
++last;
817817

818818
// Escape \r\n or \n\r, but not \n\n.

clang/lib/Parse/ParseHLSLRootSignature.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,15 @@ std::optional<StaticSampler> RootSignatureParser::parseStaticSampler() {
380380
if (Params->MipLODBias.has_value())
381381
Sampler.MipLODBias = Params->MipLODBias.value();
382382

383+
if (Params->MaxAnisotropy.has_value())
384+
Sampler.MaxAnisotropy = Params->MaxAnisotropy.value();
385+
386+
if (Params->MinLOD.has_value())
387+
Sampler.MinLOD = Params->MinLOD.value();
388+
389+
if (Params->MaxLOD.has_value())
390+
Sampler.MaxLOD = Params->MaxLOD.value();
391+
383392
if (consumeExpectedToken(TokenKind::pu_r_paren,
384393
diag::err_hlsl_unexpected_end_of_params,
385394
/*param of=*/TokenKind::kw_StaticSampler))
@@ -682,6 +691,57 @@ RootSignatureParser::parseStaticSamplerParams() {
682691
return std::nullopt;
683692
Params.MipLODBias = MipLODBias;
684693
}
694+
695+
// `maxAnisotropy` `=` POS_INT
696+
if (tryConsumeExpectedToken(TokenKind::kw_maxAnisotropy)) {
697+
if (Params.MaxAnisotropy.has_value()) {
698+
getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
699+
<< CurToken.TokKind;
700+
return std::nullopt;
701+
}
702+
703+
if (consumeExpectedToken(TokenKind::pu_equal))
704+
return std::nullopt;
705+
706+
auto MaxAnisotropy = parseUIntParam();
707+
if (!MaxAnisotropy.has_value())
708+
return std::nullopt;
709+
Params.MaxAnisotropy = MaxAnisotropy;
710+
}
711+
712+
// `minLOD` `=` NUMBER
713+
if (tryConsumeExpectedToken(TokenKind::kw_minLOD)) {
714+
if (Params.MinLOD.has_value()) {
715+
getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
716+
<< CurToken.TokKind;
717+
return std::nullopt;
718+
}
719+
720+
if (consumeExpectedToken(TokenKind::pu_equal))
721+
return std::nullopt;
722+
723+
auto MinLOD = parseFloatParam();
724+
if (!MinLOD.has_value())
725+
return std::nullopt;
726+
Params.MinLOD = MinLOD;
727+
}
728+
729+
// `maxLOD` `=` NUMBER
730+
if (tryConsumeExpectedToken(TokenKind::kw_maxLOD)) {
731+
if (Params.MaxLOD.has_value()) {
732+
getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
733+
<< CurToken.TokKind;
734+
return std::nullopt;
735+
}
736+
737+
if (consumeExpectedToken(TokenKind::pu_equal))
738+
return std::nullopt;
739+
740+
auto MaxLOD = parseFloatParam();
741+
if (!MaxLOD.has_value())
742+
return std::nullopt;
743+
Params.MaxLOD = MaxLOD;
744+
}
685745
} while (tryConsumeExpectedToken(TokenKind::pu_comma));
686746

687747
return Params;

clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -629,13 +629,6 @@ void ModuleDepCollectorPP::LexedFileChanged(FileID FID,
629629
if (Reason != LexedFileChangeReason::EnterFile)
630630
return;
631631

632-
// This has to be delayed as the context hash can change at the start of
633-
// `CompilerInstance::ExecuteAction`.
634-
if (MDC.ContextHash.empty()) {
635-
MDC.ContextHash = MDC.ScanInstance.getInvocation().getModuleHash();
636-
MDC.Consumer.handleContextHash(MDC.ContextHash);
637-
}
638-
639632
SourceManager &SM = MDC.ScanInstance.getSourceManager();
640633

641634
// Dependency generation really does want to go all the way to the
@@ -717,6 +710,9 @@ void ModuleDepCollectorPP::EndOfMainFile() {
717710
for (const Module *M : MDC.DirectModularDeps)
718711
handleTopLevelModule(M);
719712

713+
MDC.Consumer.handleContextHash(
714+
MDC.ScanInstance.getInvocation().getModuleHash());
715+
720716
MDC.Consumer.handleDependencyOutputOpts(*MDC.Opts);
721717

722718
if (MDC.Service.getFormat() == ScanningOutputFormat::P1689)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %clang_cc1 -verify %s
2+
3+
// Check that we don't crash if the file ends in a splice
4+
// This file should *NOT* end with a new line
5+
a;
6+
// expected-error@-1 {{}} \

clang/unittests/Lex/LexHLSLRootSignatureTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ TEST_F(LexHLSLRootSignatureTest, ValidLexAllTokensTest) {
136136
space visibility flags
137137
numDescriptors offset
138138
139-
mipLODBias
139+
mipLODBias maxAnisotropy minLOD maxLOD
140140
141141
unbounded
142142
DESCRIPTOR_RANGE_OFFSET_APPEND

clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) {
225225

226226
TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) {
227227
const llvm::StringLiteral Source = R"cc(
228-
StaticSampler(s0, mipLODBias = 0)
228+
StaticSampler(s0),
229+
StaticSampler(s0, maxAnisotropy = 3,
230+
minLOD = 4.2f, mipLODBias = 0.23e+3,
231+
maxLOD = 9000,
232+
)
229233
)cc";
230234

231235
TrivialModuleLoader ModLoader;
@@ -241,13 +245,27 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) {
241245

242246
ASSERT_FALSE(Parser.parse());
243247

244-
ASSERT_EQ(Elements.size(), 1u);
248+
ASSERT_EQ(Elements.size(), 2u);
245249

250+
// Check default values are as expected
246251
RootElement Elem = Elements[0];
247252
ASSERT_TRUE(std::holds_alternative<StaticSampler>(Elem));
248253
ASSERT_EQ(std::get<StaticSampler>(Elem).Reg.ViewType, RegisterType::SReg);
249254
ASSERT_EQ(std::get<StaticSampler>(Elem).Reg.Number, 0u);
250255
ASSERT_FLOAT_EQ(std::get<StaticSampler>(Elem).MipLODBias, 0.f);
256+
ASSERT_EQ(std::get<StaticSampler>(Elem).MaxAnisotropy, 16u);
257+
ASSERT_FLOAT_EQ(std::get<StaticSampler>(Elem).MinLOD, 0.f);
258+
ASSERT_FLOAT_EQ(std::get<StaticSampler>(Elem).MaxLOD, 3.402823466e+38f);
259+
260+
// Check values can be set as expected
261+
Elem = Elements[1];
262+
ASSERT_TRUE(std::holds_alternative<StaticSampler>(Elem));
263+
ASSERT_EQ(std::get<StaticSampler>(Elem).Reg.ViewType, RegisterType::SReg);
264+
ASSERT_EQ(std::get<StaticSampler>(Elem).Reg.Number, 0u);
265+
ASSERT_FLOAT_EQ(std::get<StaticSampler>(Elem).MipLODBias, 230.f);
266+
ASSERT_EQ(std::get<StaticSampler>(Elem).MaxAnisotropy, 3u);
267+
ASSERT_FLOAT_EQ(std::get<StaticSampler>(Elem).MinLOD, 4.2f);
268+
ASSERT_FLOAT_EQ(std::get<StaticSampler>(Elem).MaxLOD, 9000.f);
251269

252270
ASSERT_TRUE(Consumer->isSatisfied());
253271
}

0 commit comments

Comments
 (0)