build/clang-plugin/tests/TestMustOverride.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 #define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override")))
     2 // Ignore warnings not related to static analysis here
     3 #pragma GCC diagnostic ignored "-Woverloaded-virtual"
     5 struct S {
     6   virtual void f() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
     7   virtual void g() MOZ_MUST_OVERRIDE;
     8   virtual void h() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
     9 };
    10 struct C : S { // expected-error {{'C' must override 'f'}} expected-error {{'C' must override 'h'}}
    11   virtual void g() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
    12   virtual void h(int);
    13   void q() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
    14 };
    15 struct D : C { // expected-error {{'D' must override 'g'}} expected-error {{'D' must override 'q'}}
    16   virtual void f();
    17 };
    19 struct Base {
    20   virtual void VirtMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
    21   void NonVirtMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
    22   static void StaticMethod() MOZ_MUST_OVERRIDE;
    23 };
    25 struct DoesNotPropagate : Base {
    26   virtual void VirtMethod();
    27   void NonVirtMethod();
    28   static void StaticMethod();
    29 };
    31 struct Final : DoesNotPropagate { };
    33 struct Propagates : Base {
    34   virtual void VirtMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
    35   void NonVirtMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
    36   static void StaticMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
    37 };
    39 struct FailsFinal : Propagates { }; // expected-error {{'FailsFinal' must override 'VirtMethod'}} expected-error {{'FailsFinal' must override 'NonVirtMethod'}} expected-error {{'FailsFinal' must override 'StaticMethod'}}
    41 struct WrongOverload : Base { // expected-error {{'WrongOverload' must override 'VirtMethod'}} expected-error {{'WrongOverload' must override 'NonVirtMethod'}}
    42   virtual void VirtMethod() const;
    43   void NonVirtMethod(int param);
    44   static void StaticMethod();
    45 };
    47 namespace A { namespace B { namespace C {
    48   struct Param {};
    49   struct Base {
    50     void f(Param p) MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
    51   };
    52 }}}
    54 struct Param {};
    56 struct Derived : A::B::C::Base {
    57   typedef A::B::C::Param Typedef;
    58   void f(Typedef t);
    59 };
    61 struct BadDerived : A::B::C::Base { // expected-error {{'BadDerived' must override 'f'}}
    62   void f(Param p);
    63 };

mercurial