From eab6cd474c478942949942d844da0ed51f31e394 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 1 Mar 2017 10:47:52 +0000 Subject: clang-format: Ignore contents of #ifdef SWIG .. #endif blocks. Those blocks are used if C++ code is SWIG-wrapped (see swig.org) and usually do not contain C++ code. Also cleanup the implementation of for #if 0 and #if false a bit. llvm-svn: 296605 --- clang/lib/Format/UnwrappedLineParser.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'clang/lib/Format/UnwrappedLineParser.cpp') diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 9a536ad6019..bd049ef668b 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -590,12 +590,12 @@ void UnwrappedLineParser::conditionalCompilationEnd() { void UnwrappedLineParser::parsePPIf(bool IfDef) { nextToken(); - bool IsLiteralFalse = (FormatTok->Tok.isLiteral() && - FormatTok->Tok.getLiteralData() != nullptr && - StringRef(FormatTok->Tok.getLiteralData(), - FormatTok->Tok.getLength()) == "0") || - FormatTok->Tok.is(tok::kw_false); - conditionalCompilationStart(!IfDef && IsLiteralFalse); + bool Unreachable = false; + if (!IfDef && (FormatTok->is(tok::kw_false) || FormatTok->TokenText == "0")) + Unreachable = true; + if (IfDef && FormatTok->TokenText == "SWIG") + Unreachable = true; + conditionalCompilationStart(Unreachable); parsePPUnknown(); } -- cgit v1.2.3