]> granicus.if.org Git - clang/commit
[clang-format] Don't detect C++11 attribute specifiers as ObjC
authorBen Hamilton <benhamilton@google.com>
Mon, 12 Mar 2018 15:42:38 +0000 (15:42 +0000)
committerBen Hamilton <benhamilton@google.com>
Mon, 12 Mar 2018 15:42:38 +0000 (15:42 +0000)
commit5f93943aedc0fc3de15f1885209503f015f63b56
tree67596012a558758231c3cd4d1ded059b14d62831
parent4f1bb770ad5a800381b264e80e3fde83071d0203
[clang-format] Don't detect C++11 attribute specifiers as ObjC

Summary:
Previously, clang-format would detect C++11 and C++17 attribute
specifiers like the following as Objective-C method invocations:

  [[noreturn]];
  [[clang::fallthrough]];
  [[noreturn, deprecated("so sorry")]];
  [[using gsl: suppress("type")]];

To fix this, I ported part of the logic from
tools/clang/lib/Parse/ParseTentative.cpp into TokenAnnotator.cpp so we
can explicitly parse and identify C++11 attribute specifiers.

This allows the guessLanguage() and getStyle() APIs to correctly
guess files containing the C++11 attribute specifiers as C++,
not Objective-C.

Test Plan: New tests added. Ran tests with:
  make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: krasimir, jolesiak, djasper

Reviewed By: djasper

Subscribers: aaron.ballman, cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D43902

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327284 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/ContinuationIndenter.cpp
lib/Format/FormatToken.h
lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp