diff options
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/store/sallogareas.cxx | 36 | ||||
-rw-r--r-- | compilerplugins/clang/store/sallogareas.hxx | 1 |
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; |