Issue 56478
Summary Add warning or diagnostic if a header file has unbalanced braces
Labels
Assignees
Reporter davidben
    If someone writes in a header file:
```
namespace foo {
...lots....
...of...
...code...
```
and forgets or miscounts the closing `}`s, the resulting compile errors can be very confusing. Particularly if the source file does `#include "buggy.h"` followed by `#include "other_header.h"`. Random name references deep in that other header will get interpreted from the wrong namespace. In the example I saw, the error manifested inside the STL, which is extra confusing.

Perhaps there should have a warning when a header file contains unbalanced braces, parens, etc. Alternatively, if worried about false positives from intentional mismatches (I don't think I've ever seen it...), it could just be a diagnostic/suggestion Clang shows if this happened and the compile failed in some other way. If there's an unbalanced header but it built anyway, it was probably intentional, though quite rude.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to