Skip to content

Commit 79dc7fc

Browse files
committed
C#: Avoid using TRAP stack in buildless mode
1 parent f025430 commit 79dc7fc

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

csharp/extractor/Semmle.Extraction/Context.cs

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -274,28 +274,36 @@ private void Populate(ISymbol? optionalSymbol, CachedEntity entity)
274274

275275
bool duplicationGuard, deferred;
276276

277-
switch (entity.TrapStackBehaviour)
277+
if (Extractor.Mode is ExtractorMode.Standalone)
278278
{
279-
case TrapStackBehaviour.NeedsLabel:
280-
if (!tagStack.Any())
281-
ExtractionError("TagStack unexpectedly empty", optionalSymbol, entity);
282-
duplicationGuard = false;
283-
deferred = false;
284-
break;
285-
case TrapStackBehaviour.NoLabel:
286-
duplicationGuard = false;
287-
deferred = tagStack.Any();
288-
break;
289-
case TrapStackBehaviour.OptionalLabel:
290-
duplicationGuard = false;
291-
deferred = false;
292-
break;
293-
case TrapStackBehaviour.PushesLabel:
294-
duplicationGuard = true;
295-
deferred = duplicationGuard && tagStack.Any();
296-
break;
297-
default:
298-
throw new InternalError("Unexpected TrapStackBehaviour");
279+
duplicationGuard = false;
280+
deferred = false;
281+
}
282+
else
283+
{
284+
switch (entity.TrapStackBehaviour)
285+
{
286+
case TrapStackBehaviour.NeedsLabel:
287+
if (!tagStack.Any())
288+
ExtractionError("TagStack unexpectedly empty", optionalSymbol, entity);
289+
duplicationGuard = false;
290+
deferred = false;
291+
break;
292+
case TrapStackBehaviour.NoLabel:
293+
duplicationGuard = false;
294+
deferred = tagStack.Any();
295+
break;
296+
case TrapStackBehaviour.OptionalLabel:
297+
duplicationGuard = false;
298+
deferred = false;
299+
break;
300+
case TrapStackBehaviour.PushesLabel:
301+
duplicationGuard = true;
302+
deferred = duplicationGuard && tagStack.Any();
303+
break;
304+
default:
305+
throw new InternalError("Unexpected TrapStackBehaviour");
306+
}
299307
}
300308

301309
var a = duplicationGuard && IsEntityDuplicationGuarded(entity, out var loc)

0 commit comments

Comments
 (0)