Backed out changeset fae8ad41a604 (bug 927430) because of build bustage on a CLOSED TREE
authorEhsan Akhgari <ehsan@mozilla.com>
Sun, 18 Jan 2015 19:04:23 -0500
changeset 224460 e5b597326bb94fa103e1f57685ada59d68bd92fc
parent 224459 fae8ad41a60416696c88968265cb7baef87bd648
child 224461 c09784f0bf81f13b65e2f6507a340af2b8a2a0e2
push id54235
push usereakhgari@mozilla.com
push dateMon, 19 Jan 2015 00:04:32 +0000
treeherdermozilla-inbound@e5b597326bb9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs927430
milestone38.0a1
backs outfae8ad41a60416696c88968265cb7baef87bd648
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset fae8ad41a604 (bug 927430) because of build bustage on a CLOSED TREE
build/clang-plugin/clang-plugin.cpp
build/clang-plugin/tests/Makefile.in
build/clang-plugin/tests/TestNANTestingExpr.cpp
build/clang-plugin/tests/TestNANTestingExprC.c
build/clang-plugin/tests/moz.build
--- a/build/clang-plugin/clang-plugin.cpp
+++ b/build/clang-plugin/clang-plugin.cpp
@@ -64,27 +64,21 @@ private:
     virtual void run(const MatchFinder::MatchResult &Result);
   };
 
   class TrivialCtorDtorChecker : public MatchFinder::MatchCallback {
   public:
     virtual void run(const MatchFinder::MatchResult &Result);
   };
 
-  class NaNExprChecker : public MatchFinder::MatchCallback {
-  public:
-    virtual void run(const MatchFinder::MatchResult &Result);
-  };
-
   ScopeChecker stackClassChecker;
   ScopeChecker globalClassChecker;
   NonHeapClassChecker nonheapClassChecker;
   ArithmeticArgChecker arithmeticArgChecker;
   TrivialCtorDtorChecker trivialCtorDtorChecker;
-  NaNExprChecker nanExprChecker;
   MatchFinder astMatcher;
 };
 
 namespace {
 
 bool isInIgnoredNamespace(const Decl *decl) {
   const DeclContext *DC = decl->getDeclContext()->getEnclosingNamespaceContext();
   const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC);
@@ -417,49 +411,16 @@ AST_MATCHER(UnaryOperator, unaryArithmet
   return opcode == UO_PostInc ||
          opcode == UO_PostDec ||
          opcode == UO_PreInc ||
          opcode == UO_PreDec ||
          opcode == UO_Plus ||
          opcode == UO_Minus ||
          opcode == UO_Not;
 }
-
-/// This matcher will match == and != binary operators.
-AST_MATCHER(BinaryOperator, binaryEqualityOperator) {
-  BinaryOperatorKind opcode = Node.getOpcode();
-  return opcode == BO_EQ || opcode == BO_NE;
-}
-
-/// This matcher will match floating point types.
-AST_MATCHER(QualType, isFloat) {
-  return Node->isRealFloatingType();
-}
-
-/// This matcher will match locations in system headers.  This is copied from
-/// isExpansionInSystemHeader in newer clangs.
-AST_POLYMORPHIC_MATCHER(isInSystemHeader,
-  AST_POLYMORPHIC_SUPPORTED_TYPES_3(Decl, Stmt, TypeLoc)) {
-  auto &SourceManager = Finder->getASTContext().getSourceManager();
-  auto ExpansionLoc = SourceManager.getExpansionLoc(Node.getLocStart());
-  if (ExpansionLoc.isInvalid()) {
-    return false;
-  }
-  return SourceManager.isInSystemHeader(ExpansionLoc);
-}
-
-/// This matcher will match locations in SkScalar.h.  This header contains a
-/// known NaN-testing expression which we would like to whitelist.
-AST_MATCHER(BinaryOperator, isInSkScalarDotH) {
-  SourceLocation Loc = Node.getOperatorLoc();
-  auto &SourceManager = Finder->getASTContext().getSourceManager();
-  SmallString<1024> FileName = SourceManager.getFilename(Loc);
-  return llvm::sys::path::rbegin(FileName)->equals("SkScalar.h");
-}
-
 }
 }
 
 namespace {
 
 bool isPlacementNew(const CXXNewExpr *expr) {
   // Regular new expressions aren't placement new
   if (expr->getNumPlacementArgs() == 0)
@@ -533,23 +494,16 @@ DiagnosticsMatcher::DiagnosticsMatcher()
                                         anyOf(hasDescendant(declRefExpr()), declRefExpr())))
               )).bind("node"))
           )
       )).bind("call"),
     &arithmeticArgChecker);
 
   astMatcher.addMatcher(recordDecl(hasTrivialCtorDtor()).bind("node"),
     &trivialCtorDtorChecker);
-
-  astMatcher.addMatcher(binaryOperator(allOf(binaryEqualityOperator(),
-          hasLHS(has(declRefExpr(hasType(qualType((isFloat())))).bind("lhs"))),
-          hasRHS(has(declRefExpr(hasType(qualType((isFloat())))).bind("rhs"))),
-          unless(anyOf(isInSystemHeader(), isInSkScalarDotH()))
-      )).bind("node"),
-    &nanExprChecker);
 }
 
 void DiagnosticsMatcher::ScopeChecker::run(
     const MatchFinder::MatchResult &Result) {
   DiagnosticsEngine &Diag = Result.Context->getDiagnostics();
   unsigned stackID = Diag.getDiagnosticIDs()->getCustomDiagID(
     DiagnosticIDs::Error, "variable of type %0 only valid on the stack");
   unsigned globalID = Diag.getDiagnosticIDs()->getCustomDiagID(
@@ -689,52 +643,16 @@ void DiagnosticsMatcher::TrivialCtorDtor
   const CXXRecordDecl *node = Result.Nodes.getNodeAs<CXXRecordDecl>("node");
 
   bool badCtor = !node->hasTrivialDefaultConstructor();
   bool badDtor = !node->hasTrivialDestructor();
   if (badCtor || badDtor)
     Diag.Report(node->getLocStart(), errorID) << node;
 }
 
-void DiagnosticsMatcher::NaNExprChecker::run(
-    const MatchFinder::MatchResult &Result) {
-  if (!Result.Context->getLangOpts().CPlusPlus) {
-    // mozilla::IsNaN is not usable in C, so there is no point in issuing these warnings.
-    return;
-  }
-
-  DiagnosticsEngine &Diag = Result.Context->getDiagnostics();
-  unsigned errorID = Diag.getDiagnosticIDs()->getCustomDiagID(
-      DiagnosticIDs::Error, "comparing a floating point value to itself for NaN checking can lead to incorrect results");
-  unsigned noteID = Diag.getDiagnosticIDs()->getCustomDiagID(
-      DiagnosticIDs::Note, "consider using mozilla::IsNaN instead");
-  const BinaryOperator *expr = Result.Nodes.getNodeAs<BinaryOperator>("node");
-  const DeclRefExpr *lhs = Result.Nodes.getNodeAs<DeclRefExpr>("lhs");
-  const DeclRefExpr *rhs = Result.Nodes.getNodeAs<DeclRefExpr>("rhs");
-  const ImplicitCastExpr *lhsExpr = dyn_cast<ImplicitCastExpr>(expr->getLHS());
-  const ImplicitCastExpr *rhsExpr = dyn_cast<ImplicitCastExpr>(expr->getRHS());
-  // The AST subtree that we are looking for will look like this:
-  // -BinaryOperator ==/!=
-  //  |-ImplicitCastExpr LValueToRValue
-  //  | |-DeclRefExpr
-  //  |-ImplicitCastExpr LValueToRValue
-  //    |-DeclRefExpr
-  // The check below ensures that we are dealing with the correct AST subtree shape, and
-  // also that both of the found DeclRefExpr's point to the same declaration.
-  if (lhs->getFoundDecl() == rhs->getFoundDecl() &&
-      lhsExpr && rhsExpr &&
-      std::distance(lhsExpr->child_begin(), lhsExpr->child_end()) == 1 &&
-      std::distance(rhsExpr->child_begin(), rhsExpr->child_end()) == 1 &&
-      *lhsExpr->child_begin() == lhs &&
-      *rhsExpr->child_begin() == rhs) {
-    Diag.Report(expr->getLocStart(), errorID);
-    Diag.Report(expr->getLocStart(), noteID);
-  }
-}
-
 class MozCheckAction : public PluginASTAction {
 public:
   ASTConsumerPtr CreateASTConsumer(CompilerInstance &CI, StringRef fileName) override {
 #if CLANG_VERSION_FULL >= 306
     std::unique_ptr<MozChecker> checker(make_unique<MozChecker>(CI));
 
     std::vector<std::unique_ptr<ASTConsumer>> consumers;
     consumers.push_back(std::move(checker));
--- a/build/clang-plugin/tests/Makefile.in
+++ b/build/clang-plugin/tests/Makefile.in
@@ -1,15 +1,14 @@
 # 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/.
 
 # Build without any warning flags, and with clang verify flag for a
 # syntax-only build (no codegen).
-OS_CFLAGS := $(filter-out -W%,$(OS_CFLAGS)) -fsyntax-only -Xclang -verify
 OS_CXXFLAGS := $(filter-out -W%,$(OS_CXXFLAGS)) -fsyntax-only -Xclang -verify
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(OBJS)
 
 # We don't actually build anything.
 .PHONY: $(OBJS)
deleted file mode 100644
--- a/build/clang-plugin/tests/TestNANTestingExpr.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-void test(bool x);
-void foo() {
-  float f, f2;
-  typedef double mydouble;
-  mydouble d;
-  double d2;
-  test(f == f); // expected-error{{comparing a floating point value to itself for NaN checking can lead to incorrect results}} expected-note{{consider using mozilla::IsNaN instead}}
-  test(d == d); // expected-error{{comparing a floating point value to itself for NaN checking can lead to incorrect results}} expected-note{{consider using mozilla::IsNaN instead}}
-  test(f != f); // expected-error{{comparing a floating point value to itself for NaN checking can lead to incorrect results}} expected-note{{consider using mozilla::IsNaN instead}}
-  test(d != d); // expected-error{{comparing a floating point value to itself for NaN checking can lead to incorrect results}} expected-note{{consider using mozilla::IsNaN instead}}
-  test(f != d);
-  test(d == (d - f));
-  test(f == f2);
-  test(d == d2);
-  test(d + 1 == d);
-}
deleted file mode 100644
--- a/build/clang-plugin/tests/TestNANTestingExprC.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* expected-no-diagnostics */
-void test(int x);
-void foo() {
-  float f, f2;
-  typedef double mydouble;
-  mydouble d;
-  double d2;
-  test(f == f);
-  test(d == d);
-  test(f != f);
-  test(d != d);
-  test(f != d);
-  test(d == (d - f));
-  test(f == f2);
-  test(d == d2);
-  test(d + 1 == d);
-}
--- a/build/clang-plugin/tests/moz.build
+++ b/build/clang-plugin/tests/moz.build
@@ -4,18 +4,16 @@
 # 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/.
 
 SOURCES += [
     'TestBadImplicitConversionCtor.cpp',
     'TestCustomHeap.cpp',
     'TestGlobalClass.cpp',
     'TestMustOverride.cpp',
-    'TestNANTestingExpr.cpp',
-    'TestNANTestingExprC.c',
     'TestNoArithmeticExprInArgument.cpp',
     'TestNonHeapClass.cpp',
     'TestStackClass.cpp',
     'TestTrivialCtorDtor.cpp',
 ]
 
 DISABLE_STL_WRAPPING = True
 NO_VISIBILITY_FLAGS = True