From 1e80887d6314e3d34b0f1c4aa6ffef9999fba8ec Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Fri, 28 Jun 2013 12:51:24 +0000 Subject: Use lexing mode based on FormatStyle.Standard. Summary: Some valid pre-C++11 constructs change meaning when lexed in C++11 mode, e.g. #define x(_a) printf("foo"_a); (example from http://llvm.org/bugs/show_bug.cgi?id=16342). "foo"_a is treated as a user-defined string literal when parsed in C++11 mode. In order to deal with this correctly, we need to set lexing mode according to which standard the code conforms to. We already have a configuration value for this (FormatStyle.Standard), which seems to be appropriate to use in this case as well. Reviewers: klimek CC: cfe-commits, gribozavr Differential Revision: http://llvm-reviews.chandlerc.com/D1028 llvm-svn: 185149 --- clang/include/clang/Format/Format.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'clang/include') diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index 24eeb76d068..d03b8796feb 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -218,7 +218,11 @@ tooling::Replacements reformat(const FormatStyle &Style, StringRef Code, StringRef FileName = ""); /// \brief Returns the \c LangOpts that the formatter expects you to set. -LangOptions getFormattingLangOpts(); +/// +/// \param Standard determines lexing mode: LC_Cpp11 and LS_Auto turn on C++11 +/// lexing mode, LS_Cpp03 - C++03 mode. +LangOptions getFormattingLangOpts(FormatStyle::LanguageStandard Standard = + FormatStyle::LS_Cpp11); } // end namespace format } // end namespace clang -- cgit v1.2.3