From ef780c15fb99b8f9b40aba5872540d2011d0c561 Mon Sep 17 00:00:00 2001 From: Jeroen Ketema Date: Wed, 25 Mar 2026 16:34:02 +0100 Subject: [PATCH] C++: NSDMI fixes * Do not generate IR for field initializers from uninstantiated templates. * Add forgotten case to `TranslatedDeclarationEntry` --- .../code/cpp/ir/implementation/raw/internal/IRConstruction.qll | 1 + .../implementation/raw/internal/TranslatedDeclarationEntry.qll | 2 ++ 2 files changed, 3 insertions(+) diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll index f3d88908cd6..da8c394c845 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll @@ -47,6 +47,7 @@ module Raw { not var.isFromUninstantiatedTemplate(_) and var instanceof StaticInitializedStaticLocalVariable or + not var.isFromUninstantiatedTemplate(_) and var instanceof Field ) and var.hasInitializer() and diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedDeclarationEntry.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedDeclarationEntry.qll index b10bba90536..6de5c1ba21f 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedDeclarationEntry.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedDeclarationEntry.qll @@ -34,6 +34,8 @@ abstract class TranslatedDeclarationEntry extends TranslatedElement, TTranslated or result = entry.getDeclaration().(GlobalOrNamespaceVariable) or + result = entry.getDeclaration().(Field) + or not entry.getDeclaration() instanceof StaticInitializedStaticLocalVariable and not entry.getDeclaration() instanceof GlobalOrNamespaceVariable and not entry.getDeclaration() instanceof Field and