This is an archive of the discontinued LLVM Phabricator instance.

[Format] Don't treat compound extension headers (foo.proto.h) as foo.cc main file.
ClosedPublic

Authored by hokein on Oct 1 2020, 2:00 AM.

Details

Reviewers
sammccall
Summary

We receive internal bugs about this false positives after D86597.

Diff Detail

Event Timeline

hokein created this revision.Oct 1 2020, 2:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 1 2020, 2:00 AM
hokein requested review of this revision.Oct 1 2020, 2:00 AM
sammccall accepted this revision.Oct 1 2020, 5:40 AM
sammccall added inline comments.
clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
237

this deserves a comment: Not matchingStem: implementation files may have compound extensions but headers may not.

This revision is now accepted and ready to land.Oct 1 2020, 5:40 AM
hokein closed this revision.Oct 1 2020, 11:38 PM
hokein marked an inline comment as done.

It looks like this fix caused a different regression in not accepting name.<x>.h as the main header for name.<x>.cc, e.g.:

$ cat /tmp/foo.bar.cc
#include "a.h"
#include "z.h"
#include "foo.bar.h"

$ clang-format /tmp/foo.bar.cc  # Before
#include "foo.bar.h"

#include "a.h"
#include "z.h"

$ clang-format /tmp/foo.bar.cc  # After
#include "a.h"
#include "foo.bar.h"
#include "z.h"

It looks like this fix caused a different regression in not accepting name.<x>.h as the main header for name.<x>.cc, e.g.:

$ cat /tmp/foo.bar.cc
#include "a.h"
#include "z.h"
#include "foo.bar.h"

$ clang-format /tmp/foo.bar.cc  # Before
#include "foo.bar.h"

#include "a.h"
#include "z.h"

$ clang-format /tmp/foo.bar.cc  # After
#include "a.h"
#include "foo.bar.h"
#include "z.h"

oh, sorry for the regression. Will try to fix that, thanks for the example!