summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2019-04-29 22:39:00 +0200
committerLuboš Luňák <l.lunak@collabora.com>2019-05-05 17:44:48 +0200
commitacd8ee107f336d629782956350ed3981ca302024 (patch)
tree90e4f9dbe41ca1973e22ef1548cf68dff145b1d8 /compilerplugins
parent1334c2bf93a4ea7168718a3a2678fbf9848ec469 (diff)
avoid false warnings from oslendian clang plugin if PCH is used
Change-Id: I3ab8371b14068601995616dc9979a3297313d761 Reviewed-on: https://gerrit.libreoffice.org/71563 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/oslendian.cxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/compilerplugins/clang/oslendian.cxx b/compilerplugins/clang/oslendian.cxx
index 3cb1adbe3da0..13296330baf6 100644
--- a/compilerplugins/clang/oslendian.cxx
+++ b/compilerplugins/clang/oslendian.cxx
@@ -25,6 +25,22 @@ public:
private:
void run() override {}
+ virtual void FileChanged(SourceLocation, FileChangeReason, SrcMgr::CharacteristicKind, FileID) override {
+ if(!startChecked) {
+ // With precompiled headers MacroDefined() would not be called, so check already at the very
+ // start whether the macros exist.
+ startChecked = true;
+ if(const MacroInfo* macroBig = compiler.getPreprocessor().getMacroInfo(
+ &compiler.getPreprocessor().getIdentifierTable().get("OSL_BIGENDIAN"))) {
+ definedBig_ = macroBig->getDefinitionLoc();
+ }
+ if(const MacroInfo* macroLit = compiler.getPreprocessor().getMacroInfo(
+ &compiler.getPreprocessor().getIdentifierTable().get("OSL_LITENDIAN"))) {
+ definedLit_ = macroLit->getDefinitionLoc();
+ }
+ }
+ }
+
void MacroDefined(Token const & MacroNameTok, MacroDirective const *)
override
{
@@ -107,6 +123,7 @@ private:
SourceLocation definedBig_;
SourceLocation definedLit_;
+ bool startChecked = false;
};
loplugin::Plugin::Registration<OslEndian> X("oslendian");