Kaydet (Commit) e50ef195 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

New loplugin:stringconcat

Change-Id: Id7c517fb37bc28797c45fc0dde83e866f2aa4aac
üst 363e39d6
......@@ -221,7 +221,7 @@ void SAL_CALL DummyXShape::setPropertyValue( const OUString& rName, const uno::A
lang::IllegalArgumentException, lang::WrappedTargetException,
uno::RuntimeException, std::exception)
{
SAL_INFO("chart2", "DummyXShape::setProperty: " << rName << " " << "Any");
SAL_INFO("chart2", "DummyXShape::setProperty: " << rName << " Any");
maProperties[rName] = rValue;
if(rName == "Transformation")
{
......
......@@ -43,9 +43,9 @@ int static checkGLError(const char *file, int line)
{
const char* sError = OpenGLHelper::GLErrorString(glErr);
if (sError)
SAL_WARN("chart2.opengl", "GL Error #" << glErr << "(" << sError << ") " << " in File " << file << " at line: " << line);
SAL_WARN("chart2.opengl", "GL Error #" << glErr << "(" << sError << ") in File " << file << " at line: " << line);
else
SAL_WARN("chart2.opengl", "GL Error #" << glErr << " (no message available)" << " in File " << file << " at line: " << line);
SAL_WARN("chart2.opengl", "GL Error #" << glErr << " (no message available) in File " << file << " at line: " << line);
retCode = -1;
return retCode;
}
......
......@@ -84,9 +84,9 @@ int static checkGLError(const char *file, int line)
const char* sError = OpenGLHelper::GLErrorString(glErr);
if (sError)
SAL_WARN("chart2.opengl", "GL Error #" << glErr << "(" << sError << ") " << " in File " << file << " at line: " << line);
SAL_WARN("chart2.opengl", "GL Error #" << glErr << "(" << sError << ") in File " << file << " at line: " << line);
else
SAL_WARN("chart2.opengl", "GL Error #" << glErr << " (no message available)" << " in File " << file << " at line: " << line);
SAL_WARN("chart2.opengl", "GL Error #" << glErr << " (no message available) in File " << file << " at line: " << line);
retCode = -1;
return retCode;
......
......@@ -2562,7 +2562,7 @@ void PolyStructType::dumpComprehensiveGetCppuType(FileStream & out) {
dec();
out << indent() << "}\n";
dec();
out << indent() << "};\n" << " }" << " }\n\n";
out << indent() << "};\n } }\n\n";
dumpGetCppuTypePreamble(out);
out << indent() << "return *detail::" << staticTypeClass;
dumpTemplateParameters(out);
......@@ -3785,8 +3785,7 @@ void SingletonType::dumpHxxFile(
inc();
o << indent() << "assert(the_context.is());\n" << indent()
<< "::css::uno::Reference< " << scopedBaseName
<< " > instance;\n"
<< ("#if defined LO_URE_CURRENT_ENV && defined "
<< (" > instance;\n#if defined LO_URE_CURRENT_ENV && defined "
"LO_URE_CTOR_ENV_")
<< name_.replaceAll(".", "_dot_")
<< " && (LO_URE_CURRENT_ENV) == (LO_URE_CTOR_ENV_"
......@@ -3803,7 +3802,7 @@ void SingletonType::dumpHxxFile(
" ::css::uno::UNO_QUERY);\n#else\n")
<< indent() << ("the_context->getValueByName("
"::rtl::OUString( \"/singletons/")
<< name_ << "\" )) >>= instance;\n" << "#endif\n"
<< name_ << "\" )) >>= instance;\n#endif\n"
<< indent() << "if (!instance.is()) {\n";
inc();
o << indent()
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "plugin.hxx"
namespace {
class StringConcat:
public RecursiveASTVisitor<StringConcat>, public loplugin::Plugin
{
public:
explicit StringConcat(InstantiationData const & data): Plugin(data) {}
void run() override
{ TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
bool VisitCallExpr(CallExpr const * expr);
};
bool StringConcat::VisitCallExpr(CallExpr const * expr) {
if (ignoreLocation(expr)) {
return true;
}
FunctionDecl const * fdecl = expr->getDirectCallee();
if (fdecl == nullptr) {
return true;
}
OverloadedOperatorKind oo = fdecl->getOverloadedOperator();
if ((oo != OverloadedOperatorKind::OO_Plus
&& oo != OverloadedOperatorKind::OO_LessLess)
|| fdecl->getNumParams() != 2 || expr->getNumArgs() != 2
|| !isa<StringLiteral>(expr->getArg(1)->IgnoreParenImpCasts()))
{
return true;
}
CallExpr const * left = dyn_cast<CallExpr>(
expr->getArg(0)->IgnoreParenImpCasts());
if (left == nullptr) {
return true;
}
FunctionDecl const * ldecl = left->getDirectCallee();
if (ldecl == nullptr) {
return true;
}
OverloadedOperatorKind loo = ldecl->getOverloadedOperator();
if ((loo != OverloadedOperatorKind::OO_Plus
&& loo != OverloadedOperatorKind::OO_LessLess)
|| ldecl->getNumParams() != 2 || left->getNumArgs() != 2
|| !isa<StringLiteral>(left->getArg(1)->IgnoreParenImpCasts()))
{
return true;
}
StringRef name {
compiler.getSourceManager().getFilename(
compiler.getSourceManager().getSpellingLoc(expr->getLocStart())) };
if (name == SRCDIR "/sal/qa/rtl/strings/test_ostring_concat.cxx"
|| name == SRCDIR "/sal/qa/rtl/strings/test_oustring_concat.cxx")
{
return true;
}
CXXOperatorCallExpr const * op = dyn_cast<CXXOperatorCallExpr>(expr);
report(
DiagnosticsEngine::Warning,
"replace '%0' between string literals with juxtaposition",
op == nullptr ? expr->getExprLoc() : op->getOperatorLoc())
<< (oo == OverloadedOperatorKind::OO_Plus ? "+" : "<<")
<< SourceRange(
left->getArg(1)->getLocStart(), expr->getArg(1)->getLocEnd());
return true;
}
loplugin::Plugin::Registration<StringConcat> X("stringconcat");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -404,7 +404,7 @@ Any OPoolCollection::getNodeValue(const OUString& _rPath,const Reference<XInterf
}
catch(NoSuchElementException& e)
{
SAL_WARN("connectivity.cpool", "::getNodeValue: caught a " <<
SAL_WARN("connectivity.cpool", "::getNodeValue: caught a "
"NoSuchElementException while trying to open " <<
e.Message << "!" );
}
......
......@@ -951,7 +951,7 @@ void OFlatTable::setRowPos(const vector<TRowPositionInFile>::size_type rowNum, c
{
SAL_WARN_IF(m_aRowPosToFilePos[rowNum] != rowPos,
"connectivity.flat",
"Setting position for row " << rowNum << " to (" << rowPos.first << ", " << rowPos.second << "), " <<
"Setting position for row " << rowNum << " to (" << rowPos.first << ", " << rowPos.second << "), "
"but already had different position (" << m_aRowPosToFilePos[rowNum].first << ", " << m_aRowPosToFilePos[rowNum].second << ")");
m_aRowPosToFilePos[rowNum] = rowPos;
}
......
......@@ -1053,8 +1053,7 @@ namespace cppcanvas
OSL_ASSERT( ( header >> 12 ) == 0xdbc01 );
SAL_INFO("cppcanvas.emf", "EMF+\tfont\n"
<< "EMF+\theader: 0x" << std::hex << (header >> 12) << " version: 0x" << (header & 0x1fff) << " size: " << std::dec << emSize << " unit: 0x" << std::hex << sizeUnit << std::dec);
SAL_INFO("cppcanvas.emf", "EMF+\tfont\nEMF+\theader: 0x" << std::hex << (header >> 12) << " version: 0x" << (header & 0x1fff) << " size: " << std::dec << emSize << " unit: 0x" << std::hex << sizeUnit << std::dec);
SAL_INFO("cppcanvas.emf", "EMF+\tflags: 0x" << std::hex << fontFlags << " reserved: 0x" << reserved << " length: 0x" << std::hex << length << std::dec);
if( length > 0 && length < 0x4000 ) {
......@@ -1804,7 +1803,7 @@ namespace cppcanvas
polygon.append (Map (x + width, y + height));
polygon.append (Map (x, y + height));
SAL_INFO("cppcanvas.emf", "EMF+\trectangle: " << x << "," << " " << width << "x" << height);
SAL_INFO("cppcanvas.emf", "EMF+\trectangle: " << x << ", " << width << "x" << height);
} else {
/* Single's */