summaryrefslogtreecommitdiffstats
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-11-19 16:05:35 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-11-19 16:05:35 +0100
commitb0339005b820149f86e691f88f0540c07a306d69 (patch)
tree6c1e83563c7c937dbe1b49982c1a877f20877b4b /compilerplugins
parenttdf#90904 Sorry, mixed Characters and CharactersWithSpaces at a first time (diff)
downloadcore-b0339005b820149f86e691f88f0540c07a306d69.tar.gz
core-b0339005b820149f86e691f88f0540c07a306d69.zip
loplugin:sallogareas
Change-Id: I2220ab194384fb397716bf3227d38716ba54f537
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/store/sallogareas.cxx36
-rw-r--r--compilerplugins/clang/store/sallogareas.hxx1
2 files changed, 35 insertions, 2 deletions
diff --git a/compilerplugins/clang/store/sallogareas.cxx b/compilerplugins/clang/store/sallogareas.cxx
index f427e6567d35..a9f6e350f364 100644
--- a/compilerplugins/clang/store/sallogareas.cxx
+++ b/compilerplugins/clang/store/sallogareas.cxx
@@ -107,9 +107,38 @@ void SalLogAreas::checkArea( StringRef area, SourceLocation location )
{
report( DiagnosticsEngine::Warning, "unknown log area '%0' (check or extend include/sal/log-areas.dox)",
location ) << area;
+ checkAreaSyntax(area, location);
}
}
+void SalLogAreas::checkAreaSyntax(StringRef area, SourceLocation location) {
+ for (std::size_t i = 0;;) {
+ std::size_t j = area.find('.', i);
+ if (j == StringRef::npos) {
+ j = area.size();
+ }
+ if (j == i) {
+ goto bad;
+ }
+ for (; i != j; ++i) {
+ auto c = area[i];
+ if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z'))) {
+ goto bad;
+ }
+ }
+ if (j == area.size()) {
+ return;
+ }
+ i = j + 1;
+ }
+bad:
+ report(
+ DiagnosticsEngine::Warning,
+ "invalid log area syntax '%0'%1 (see include/sal/log.hxx for details)",
+ location)
+ << area << (location.isValid() ? "" : " in include/sal/log-areas.dox");
+}
+
void SalLogAreas::readLogAreas()
{
ifstream is( SRCDIR "/include/sal/log-areas.dox" );
@@ -122,10 +151,13 @@ void SalLogAreas::readLogAreas()
{
pos += strlen( "@li @c " );
size_t end = line.find( ' ', pos );
+ std::string area;
if( end == string::npos )
- logAreas.insert( line.substr( pos ));
+ area = line.substr( pos );
else if( pos != end )
- logAreas.insert( line.substr( pos, end - pos ));
+ area = line.substr( pos, end - pos );
+ checkAreaSyntax(area, SourceLocation());
+ logAreas.insert(area);
}
}
// If you get this error message, you possibly have too old icecream (ICECC_EXTRAFILES is needed).
diff --git a/compilerplugins/clang/store/sallogareas.hxx b/compilerplugins/clang/store/sallogareas.hxx
index d18df946a428..d665c38099f2 100644
--- a/compilerplugins/clang/store/sallogareas.hxx
+++ b/compilerplugins/clang/store/sallogareas.hxx
@@ -30,6 +30,7 @@ class SalLogAreas
bool VisitCallExpr( const CallExpr* call );
private:
void checkArea( StringRef area, SourceLocation location );
+ void checkAreaSyntax(StringRef area, SourceLocation location);
void readLogAreas();
const FunctionDecl* inFunction;
SourceLocation lastSalDetailLogStreamMacro;