diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll index 0f9bc370f7a5..8e7e46c94c62 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll @@ -196,6 +196,8 @@ private predicate isInvalidFunction(Function func) { expr.getEnclosingFunction() = func and not exists(expr.getType()) ) + or + count(func.getEntryPoint().getLocation()) > 1 } /** diff --git a/cpp/ql/test/library-tests/ir/multiple-entry-points/raw_ir.expected b/cpp/ql/test/library-tests/ir/multiple-entry-points/raw_ir.expected new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/cpp/ql/test/library-tests/ir/multiple-entry-points/raw_ir.ql b/cpp/ql/test/library-tests/ir/multiple-entry-points/raw_ir.ql new file mode 100644 index 000000000000..cfc9da598a12 --- /dev/null +++ b/cpp/ql/test/library-tests/ir/multiple-entry-points/raw_ir.ql @@ -0,0 +1,6 @@ +/** + * @kind graph + */ + +private import cpp +private import semmle.code.cpp.ir.implementation.raw.PrintIR diff --git a/cpp/ql/test/library-tests/ir/multiple-entry-points/test1.cpp b/cpp/ql/test/library-tests/ir/multiple-entry-points/test1.cpp new file mode 100644 index 000000000000..463e9d34a868 --- /dev/null +++ b/cpp/ql/test/library-tests/ir/multiple-entry-points/test1.cpp @@ -0,0 +1,7 @@ +int foo(int i); + +int foo(int i) { + return 42; +} + +int bar(); diff --git a/cpp/ql/test/library-tests/ir/multiple-entry-points/test2.cpp b/cpp/ql/test/library-tests/ir/multiple-entry-points/test2.cpp new file mode 100644 index 000000000000..b61562ce2c3e --- /dev/null +++ b/cpp/ql/test/library-tests/ir/multiple-entry-points/test2.cpp @@ -0,0 +1,3 @@ +int foo(int i) { + return i; +}