llvm-project
b147019f - [clang] Preserve `externs` following broken declarations (#161641)

Commit
2 days ago
[clang] Preserve `externs` following broken declarations (#161641) Treat them as namespaces: if they are at the beginning of the line, they are likely a good recovery point. For instance, in ```cpp 1.3.0 extern "C" { extern int foo(); extern "C++" { namespace bar { void baz(); }; } } namespace {} ``` Everything until `namespace`... is gone from the AST. Headers (like libc's C++ `math.h`) can be included from an `extern "C"` context, and they do an `extern "C++"` back again before including C++ headers (like `__type_traits`). However, a malformed declaration just before the include (as the orphan `1.3.0` in the example) causes everything from these standard headers to go missing. This patch updates the heuristic to try to recover from the first `extern` keyword seen, pretty much as it is done for `namespace`. CPP-4478
Parents
Loading