This is an archive of the discontinued LLVM Phabricator instance.

Fixes bug 20559 - SBPO_Always does not work for sizeof
ClosedPublic

Authored by lifted on Aug 6 2014, 7:03 AM.

Details

Reviewers
djasper
Summary

http://llvm.org/bugs/show_bug.cgi?id=20559

clang-format: interpret some keywords as function calls and apply
the SBPO_Always option accordingly.

Before:

auto f (int x) -> decltype(x) { return sizeof(x); }

int g () noexcept(someCall ());

static_assert(sizeof(char) == 1, "Your compiler is broken");

After:

auto f (int x) -> decltype (x) { return sizeof (x); }

int g () noexcept (someCall ());

static_assert (sizeof (char) == 1, "Your compiler is broken");

Diff Detail

Event Timeline

lifted updated this revision to Diff 12234.Aug 6 2014, 7:03 AM
lifted retitled this revision from to Fixes bug 20559 - SBPO_Always does not work for sizeof.
lifted updated this object.
lifted added a reviewer: djasper.
lifted added subscribers: klimek, Unknown Object (MLST).
djasper accepted this revision.Aug 6 2014, 7:09 AM
djasper edited edge metadata.

Two minor comments, otherwise looks good.

lib/Format/FormatToken.h
356

How about:

/// \brief Returns \c true if this is a keyword that can be used
/// like a function call (e.g. sizeof, typeid, ...).
lib/Format/TokenAnnotator.cpp
1552

What do you think about moving kw___attribute into isFunctionLikeKeyword as well?

This revision is now accepted and ready to land.Aug 6 2014, 7:09 AM
lifted updated this revision to Diff 12235.Aug 6 2014, 7:18 AM
lifted edited edge metadata.

Mark kw___attribute as function-like keyword.

lifted added a comment.Aug 6 2014, 7:19 AM

Commit this patch please, I have no commit access yet.

lib/Format/FormatToken.h
356

Ok.

lib/Format/TokenAnnotator.cpp
1552

Good idea, thanks.

djasper closed this revision.Aug 6 2014, 7:25 AM

Submitted as r214969.