Files
compiler-explorer/test/ast/bug-5889.cpp
Ofek a62c5a84b5 Fix #5889: add block-lookahead logic to processAST (#5903)
The code here assumes a top-level AST subtree can be in 3 states:
1. The header line indicates it's system code (e.g. includes `/usr`
etc.)
 2. The header line indicates it's user code (includes `<source>`)
3. The header contains no such info (typically it includes `<invalid
sloc>`)

For the 3rd case this PR looks-ahead inside the current subtree and
decides based on its contents.
This is enough to filter out `<vector>` or `<string>` contents, as
demonstrated in issue #5889 (added a test). This solution holds also for
the case from issue #3849.
2023-12-28 16:10:09 +02:00

6 lines
89 B
C++

#include <string>
std::string square(int& num) {
num *= num;
return "success";
}