From b8d7292b46bc5d0fb45ac5d43b40da144bfe52d8 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Wed, 17 Oct 2018 14:59:30 +0100 Subject: [PATCH] CPP: Speed up startsWithIfndef. --- cpp/ql/src/semmle/code/cpp/headers/MultipleInclusion.qll | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cpp/ql/src/semmle/code/cpp/headers/MultipleInclusion.qll b/cpp/ql/src/semmle/code/cpp/headers/MultipleInclusion.qll index d259d1ef8059..299998647c19 100644 --- a/cpp/ql/src/semmle/code/cpp/headers/MultipleInclusion.qll +++ b/cpp/ql/src/semmle/code/cpp/headers/MultipleInclusion.qll @@ -114,8 +114,11 @@ pragma[noopt] predicate correctIncludeGuard(HeaderFile hf, PreprocessorDirective */ predicate startsWithIfndef(HeaderFile hf, PreprocessorDirective ifndef, string macroName) { ifndefDirective(ifndef, macroName) and - ifndef.getFile() = hf and - ifndef.getLocation().getStartLine() = min(int l | includeGuardRelevantLine(hf, l)) + exists(Location loc | + loc = ifndef.getLocation() and + loc.getFile() = hf and + loc.getStartLine() = min(int l | includeGuardRelevantLine(hf, l)) + ) } private predicate endifLocation(PreprocessorEndif endif, File f, int line) {