//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#include "stdafx.h"

#define CATCH_CONFIG_RUNNER
#pragma warning(push)
// conversion from 'int' to 'char', possible loss of data
#pragma warning(disable:4244)
#include "catch.hpp"
#pragma warning(pop)

// Use nativetests.exe -? to get all command line options

int _cdecl main(int argc, char * const argv[])
{
    return Catch::Session().run(argc, argv);
}

//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#include "stdafx.h"

#define CATCH_CONFIG_RUNNER
#pragma warning(push)
// conversion from 'int' to 'char', possible loss of data
#pragma warning(disable:4242)
#pragma warning(disable:4244)
#include "catch.hpp"
#pragma warning(pop)

// Use nativetests.exe -? to get all command line options

int _cdecl main(int argc, char * const argv[])
{
    return Catch::Session().run(argc, argv);
}

Disable the warning on the nativetests.cpp


//! @file test-getfullyqualifiedname.cpp
//! @author George Fleming <v-geflem@microsoft.com>
//! @brief Unit tests for GetFullyQualifiedName

#include <stdio.h>
#include <gtest/gtest.h>
#include "getfullyqualifiedname.h"

//! Test fixture for GetComputerNameTest
class GetFullyQualifiedNameTest : public ::testing::Test
{
};

TEST_F(GetFullyQualifiedNameTest, ValidateLinuxGetFullyQualifiedDomainName)
{
    char expectedComputerName[HOST_NAME_MAX];

    //Get expected result from using linux command

    FILE *fPtr = popen("/bin/hostname --fqdn", "r");
    ASSERT_TRUE(fPtr != NULL);

    char *linePtr = fgets(expectedComputerName, sizeof(expectedComputerName), fPtr);
    ASSERT_TRUE(linePtr != NULL);

    // There's a tendency to have \n at end of fgets string, so remove it before compare
    size_t sz = strlen(expectedComputerName);
    if (sz > 0 && expectedComputerName[sz - 1] == '\n')
    {
        expectedComputerName[sz - 1] = '\0';
    }
    pclose(fPtr);

    ASSERT_STREQ(GetFullyQualifiedName(), expectedComputerName);
}

//! @file test-getfullyqualifiedname.cpp
//! @author George Fleming <v-geflem@microsoft.com>
//! @brief Unit tests for GetFullyQualifiedName

#include <stdio.h>
#include <gtest/gtest.h>
#include "getfullyqualifiedname.h"

//! Test fixture for GetComputerNameTest
class GetFullyQualifiedNameTest : public ::testing::Test
{
};

TEST_F(GetFullyQualifiedNameTest, ValidateLinuxGetFullyQualifiedDomainName)
{
    char expectedComputerName[HOST_NAME_MAX];

    //Get expected result from using linux command

    FILE *fPtr = popen("hostname --fqdn", "r");
    ASSERT_TRUE(fPtr != NULL);

    char *linePtr = fgets(expectedComputerName, sizeof(expectedComputerName), fPtr);
    ASSERT_TRUE(linePtr != NULL);

    // There's a tendency to have \n at end of fgets string, so remove it before compare
    size_t sz = strlen(expectedComputerName);
    if (sz > 0 && expectedComputerName[sz - 1] == '\n')
    {
        expectedComputerName[sz - 1] = '\0';
    }
    pclose(fPtr);

    ASSERT_STREQ(GetFullyQualifiedName(), expectedComputerName);
}

Change /bin/hostname to just hostname, and let sh figure out the path


#include "compiler/build_tables/item_set_closure.h"
#include <algorithm>
#include <set>
#include "tree_sitter/compiler.h"
#include "compiler/build_tables/follow_sets.h"
#include "compiler/build_tables/item.h"
#include "compiler/prepared_grammar.h"

namespace tree_sitter {
    using std::set;
    using rules::ISymbol;

    namespace build_tables {
        static bool contains(const ParseItemSet *items, const ParseItem &item) {
            if (items->empty()) return false;
            return (std::find(items->begin(), items->end(), item) != items->end());
        }

        static void add_item(ParseItemSet *item_set,
                             const ParseItem &item,
                             const PreparedGrammar &grammar) {
            if (!contains(item_set, item)) {
                item_set->insert(item);
                for (const auto &pair : follow_sets(item, grammar)) {
                    const ISymbol &non_terminal = pair.first;
                    const set<ISymbol> &terminals = pair.second;
                    for (const auto &terminal : terminals) {
                        ParseItem next_item(non_terminal, grammar.rule(non_terminal), 0, terminal);
                        add_item(item_set, next_item, grammar);
                    }
                }
            }
        }

        const ParseItemSet item_set_closure(const ParseItem &item,
                                            const PreparedGrammar &grammar) {
            ParseItemSet result;
            add_item(&result, item, grammar);
            return result;
        }
    }
}

#include "compiler/build_tables/item_set_closure.h"
#include <algorithm>
#include <set>
#include "tree_sitter/compiler.h"
#include "compiler/build_tables/follow_sets.h"
#include "compiler/build_tables/item.h"
#include "compiler/prepared_grammar.h"

namespace tree_sitter {
    using std::set;
    using rules::ISymbol;
    using std::vector;

    namespace build_tables {
        const ParseItemSet item_set_closure(const ParseItem &item,
                                            const PreparedGrammar &grammar) {
            ParseItemSet result;
            vector<ParseItem> items_to_add = { item };
            while (!items_to_add.empty()) {
                const ParseItem &item = items_to_add.back();
                items_to_add.pop_back();
                auto insertion_result = result.insert(item);
                if (insertion_result.second) {
                    result.insert(item);
                    for (const auto &pair : follow_sets(item, grammar)) {
                        const ISymbol &non_terminal = pair.first;
                        const set<ISymbol> &terminals = pair.second;
                        for (const auto &terminal : terminals) {
                            items_to_add.push_back(ParseItem(non_terminal, grammar.rule(non_terminal), 0, terminal));
                        }
                    }
                }
            }
            return result;
        }
    }
}

Optimize item set closure function

Optimize item set closure function


/*  This file is part of the KDE project
 *  Copyright (C) 2010 Casian Andrei <skeletk13@gmail.com>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) version 3, or any
 *  later version accepted by the membership of KDE e.V. (or its
 *  successor approved by the membership of KDE e.V.), Nokia Corporation
 *  (or its successors, if any) and the KDE Free Qt Foundation, which shall
 *  act as a proxy defined in Section 6 of version 3 of the license.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "capture_test.h"

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QApplication::setApplicationName("Primitive Phonon Application");

    MediaPlayer mp(NULL);
    mp.setWindowTitle("Primitive Phonon Application");
    mp.show();

    return app.exec();
}

/*  This file is part of the KDE project
 *  Copyright (C) 2010 Casian Andrei <skeletk13@gmail.com>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) version 3, or any
 *  later version accepted by the membership of KDE e.V. (or its
 *  successor approved by the membership of KDE e.V.), Nokia Corporation
 *  (or its successors, if any) and the KDE Free Qt Foundation, which shall
 *  act as a proxy defined in Section 6 of version 3 of the license.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "capture_test.h"

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QApplication::setApplicationName("Phonon Capture Test Application");

    MediaPlayer mp(NULL);
    mp.setWindowTitle("Phonon Capture Test Application");
    mp.show();

    return app.exec();
}

Modify title for capture app

Modify title for capture app


/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include "tensorflow/compiler/tf2xla/xla_op_registry.h"
#include "tensorflow/core/framework/kernel_def.pb.h"

namespace tensorflow {

bool GpuOpFilter(KernelDef* kdef) {
  // TODO(b/31361304): The GPU backend does not parallelize PRNG ops, leading to
  // slow code.
  // TODO(b/34969189) The implementation of TruncatedNormal generates illegal
  // code on GPU.
  if (kdef->op() == "RandomStandardNormal" || kdef->op() == "RandomUniform" ||
      kdef->op() == "RandomUniformInt" || kdef->op() == "TruncatedNormal") {
    return false;
  }
  return true;
}

REGISTER_XLA_BACKEND(DEVICE_GPU_XLA_JIT, kGpuAllTypes, GpuOpFilter);

}  // namespace tensorflow

/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include "tensorflow/compiler/tf2xla/xla_op_registry.h"
#include "tensorflow/core/framework/kernel_def.pb.h"

namespace tensorflow {

bool GpuOpFilter(KernelDef* kdef) {
  // TODO(b/31361304): The GPU backend does not parallelize PRNG ops, leading to
  // slow code.
  if (kdef->op() == "RandomStandardNormal" || kdef->op() == "RandomUniform" ||
      kdef->op() == "RandomUniformInt" || kdef->op() == "TruncatedNormal") {
    return false;
  }
  return true;
}

REGISTER_XLA_BACKEND(DEVICE_GPU_XLA_JIT, kGpuAllTypes, GpuOpFilter);

}  // namespace tensorflow

[XLA:GPU] Remove the comment that says b/34969189 blocking TruncateNormal.

The issue has been fixed and the GPU backend now supports atomic operations on
small data types.

PiperOrigin-RevId: 178401552


//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <strstream>

// There was an overflow in the dylib on older macOS versions
// UNSUPPORTED: availability=macosx10.8
// UNSUPPORTED: availability=macosx10.7

// class strstreambuf

// int overflow(int c);

#include <iostream>
#include <string>
#include <strstream>

int main() {
  std::ostrstream oss;
  std::string s;

  for (int i = 0; i < 4096; ++i)
    s.push_back((i % 16) + 'a');

  oss << s << std::ends;
  std::cout << oss.str();
  oss.freeze(false);

  return 0;
}

//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <strstream>

// class strstreambuf

// int overflow(int c);

#include <iostream>
#include <string>
#include <strstream>

int main() {
  std::ostrstream oss;
  std::string s;

  for (int i = 0; i < 4096; ++i)
    s.push_back((i % 16) + 'a');

  oss << s << std::ends;
  std::cout << oss.str();
  oss.freeze(false);

  return 0;
}

[libcxx] Mark strstreams tests as being supported on all OS X versions

I wasn't able to reproduce the issue referred to by the comment using
the libc++'s shipped with mac OS X 10.7 and 10.8, so I assume this may
have been fixed in a function that is now shipped in the headers. In
that case, the tests will pass no matter what dylib we're using.

In the worst case, some test bots will start failing and I'll understand
why I was wrong, and I can create an actual lit feature for it. Note
that I could just leave this test alone, but this change is on the path
towards eradicating vendor-specific availability markup from the test
suite.

git-svn-id: 756ef344af921d95d562d9e9f9389127a89a6314@347421 91177308-0d34-0410-b5e6-96231b3b80d8


#include "hierarchical_viewer.hpp"

HierarchicalViewer::HierarchicalViewer(QWidget *parent) : QTreeWidget(parent)
{
    /* Placeholders for testing purposes */
    setColumnCount(1);
    setHeaderLabel("Executable file");
    QTreeWidgetItem *filename = addRoot("hacker.out");
    QTreeWidgetItem *elf_header = addChild(filename, "ELF Header");
    QTreeWidgetItem *pht = addChild(filename, "Program Header Table");
    QTreeWidgetItem *sht = addChild(filename, "Section Header Table");
    addChild(pht, "--------NoThIng here");
    addChild(sht, "--------NoThIng here");

    addChild(elf_header, "e_ident");
    addChild(elf_header, "e_type");
    addChild(elf_header, "e_machine");
    addChild(elf_header, "e_e_version");
    addChild(elf_header, "e_entry");
}

QTreeWidgetItem *HierarchicalViewer::addRoot(const char *name)
{
    QTreeWidgetItem *item = new QTreeWidgetItem(this);
    item->setText(0, QString(name));
    addTopLevelItem(item);
    return item;
}

QTreeWidgetItem *HierarchicalViewer::addChild(QTreeWidgetItem *parent, const char *name)
{
    QTreeWidgetItem *item = new QTreeWidgetItem();
    item->setText(0, QString(name));
    parent->addChild(item);
    return item;
}

#include "hierarchical_viewer.hpp"

HierarchicalViewer::HierarchicalViewer(QWidget *parent) : QTreeWidget(parent)
{
    /* Placeholders for testing purposes */
    headerItem()->setHidden(true);
    QTreeWidgetItem *elf_header = addRoot("ELF Header");
    QTreeWidgetItem *pht = addRoot("Program Header Table");
    QTreeWidgetItem *sht = addRoot("Section Header Table");
    addChild(pht, "--------NoThIng here");
    addChild(sht, "--------NoThIng here");

    addChild(elf_header, "e_ident");
    addChild(elf_header, "e_type");
    addChild(elf_header, "e_machine");
    addChild(elf_header, "e_e_version");
    addChild(elf_header, "e_entry");
}

QTreeWidgetItem *HierarchicalViewer::addRoot(const char *name)
{
    QTreeWidgetItem *item = new QTreeWidgetItem(this);
    item->setText(0, QString(name));
    addTopLevelItem(item);
    return item;
}

QTreeWidgetItem *HierarchicalViewer::addChild(QTreeWidgetItem *parent, const char *name)
{
    QTreeWidgetItem *item = new QTreeWidgetItem();
    item->setText(0, QString(name));
    parent->addChild(item);
    return item;
}

Update hierarchicalViewer content placeholder to follow target look


#include "Genes/King_Protection_Gene.h"

#include <string>

#include "Genes/Gene.h"
#include "Game/Board.h"
#include "Game/Color.h"
#include "Game/Square.h"
#include "Moves/Move.h"

double King_Protection_Gene::score_board(const Board& board, Piece_Color perspective, size_t, double) const noexcept
{
    auto square_count = 0;

    for(size_t attack_index = 0; attack_index < 16; ++attack_index)
    {
        auto step = Move::attack_direction_from_index(attack_index);
        for(auto square : Square::square_line_from(board.find_king(perspective), step))
        {
            if(board.piece_on_square(square))
            {
                break;
            }
            else
            {
                ++square_count;
            }

            if(attack_index >= 8) // knight move
            {
                break;
            }
        }
    }

    constexpr const int max_square_count =  8      // knight attack
                                          + 7 + 7  // rooks/queen row/column attack
                                          + 7 + 6; // bishop/queen/pawn attack
    return double(max_square_count - square_count)/max_square_count; // return score [0, 1]
}

std::string King_Protection_Gene::name() const noexcept
{
    return "King Protection Gene";
}

#include "Genes/King_Protection_Gene.h"

#include <string>

#include "Genes/Gene.h"
#include "Game/Board.h"
#include "Game/Color.h"
#include "Game/Square.h"
#include "Moves/Move.h"

double King_Protection_Gene::score_board(const Board& board, Piece_Color perspective, size_t, double) const noexcept
{
    auto square_count = 0;
    auto king_square = board.find_king(perspective);

    for(size_t attack_index = 0; attack_index < 16; ++attack_index)
    {
        auto step = Move::attack_direction_from_index(attack_index);
        for(auto square : Square::square_line_from(king_square, step))
        {
            if(board.piece_on_square(square))
            {
                break;
            }
            else
            {
                ++square_count;
            }

            if(attack_index >= 8) // knight move
            {
                break;
            }
        }
    }

    constexpr const int max_square_count =  8      // knight attack
                                          + 7 + 7  // rooks/queen row/column attack
                                          + 7 + 6; // bishop/queen/pawn attack
    return double(max_square_count - square_count)/max_square_count; // return score [0, 1]
}

std::string King_Protection_Gene::name() const noexcept
{
    return "King Protection Gene";
}

Move unchanging lookup to outside of loop


/*
Copyright libCellML Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include <emscripten/bind.h>

// To work around multiple inheritance we have to create a combined Units
// and ImportedEntity class that we can bind with Emscripten.
#define JAVASCRIPT_BINDINGS
#include "libcellml/parser.h"

using namespace emscripten;

EMSCRIPTEN_BINDINGS(libcellml_parser) {

    class_<libcellml::Parser, base<libcellml::Logger>>("Parser")
        .smart_ptr<std::shared_ptr<libcellml::Parser>>("ParserPtr")
        .constructor(select_overload<libcellml::ParserPtr()>(&libcellml::Parser::create))
        .constructor(select_overload<libcellml::ParserPtr(bool)>(&libcellml::Parser::create))
        .function("parseModel", &libcellml::Parser::parseModel)
    ;
}

/*
Copyright libCellML Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include <emscripten/bind.h>

// To work around multiple inheritance we have to create a combined Units
// and ImportedEntity class that we can bind with Emscripten.
#define JAVASCRIPT_BINDINGS
#include "libcellml/parser.h"

using namespace emscripten;

EMSCRIPTEN_BINDINGS(libcellml_parser) {

    class_<libcellml::Parser, base<libcellml::Logger>>("Parser")
        .smart_ptr<std::shared_ptr<libcellml::Parser>>("ParserPtr")
        .constructor(select_overload<libcellml::ParserPtr()>(&libcellml::Parser::create))
        .constructor(select_overload<libcellml::ParserPtr(bool)>(&libcellml::Parser::create))
        .function("parseModel", &libcellml::Parser::parseModel)
        .function("isStrict", &libcellml::Parser::isStrict)
        .function("setStrict", &libcellml::Parser::setStrict)
    ;
}

Add in isStrict/setStrict to javascript bindings Parser class.


#include "qobjectfinalizer.h"
#include <QVariant>
#include "getvalue.h"
#include "pushvalue.h"
#include "toqobject.h"
#include "convert.h"

duk_ret_t dukpp03::qt::qobjectfinalizer(duk_context* ctx)
{
    QVariant* v = dukpp03::Finalizer<dukpp03::qt::BasicContext>::getVariantToFinalize(ctx);
    dukpp03::qt::BasicContext* parent  = static_cast<dukpp03::qt::BasicContext*>(dukpp03::AbstractContext::getContext(ctx));
    if (v)
    {
        if (parent->isVariantRegistered(v))
        {
            QVariant result;
            if (dukpp03::qt::Convert::convert("QObject*", v, result))
            {
                delete result.value<QObject*>();
            }
            delete v;
            parent->unregisterVariant(v);
        }
    }
    return 0;
}

#include "qobjectfinalizer.h"
#include <QVariant>
#include "getvalue.h"
#include "pushvalue.h"
#include "toqobject.h"
#include "convert.h"

duk_ret_t dukpp03::qt::qobjectfinalizer(duk_context* ctx)
{
    QVariant* v = dukpp03::Finalizer<dukpp03::qt::BasicContext>::getVariantToFinalize(ctx);
    dukpp03::qt::BasicContext* parent  = static_cast<dukpp03::qt::BasicContext*>(dukpp03::AbstractContext::getContext(ctx));
    if (v)
    {
        if (parent->isVariantRegistered(v))
        {
            QVariant result;
            if (dukpp03::qt::Convert::convert("QObject*", v, result))
            {
                delete result.value<QObject*>();
            }
            parent->unregisterVariant(v);
            delete v;
        }
    }
    return 0;
}

Patch for PVS-studio related checks.

[QT] Patch for PVS-studio related checks.


//===----------------------------------------------------------------------===//
//
//                         PelotonDB
//
// simple_optimizer.cpp
//
// Identification: /peloton/src/optimizer/simple_optimizer.cpp
//
// Copyright (c) 2016, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//

#include "optimizer/simple_optimizer.h"
#include "parser/peloton/abstract_parse.h"

#include "common/logger.h"

namespace peloton {
namespace optimizer {

SimpleOptimizer::SimpleOptimizer() {
}
;

SimpleOptimizer::~SimpleOptimizer() {
}
;

std::shared_ptr<planner::AbstractPlan> SimpleOptimizer::BuildPlanTree(
    const std::unique_ptr<parser::AbstractParse>& parse_tree) {

  if (parse_tree.get() == nullptr)
    return NULL;
  std::shared_ptr<planner::AbstractPlan> plan_tree;

  std::unique_ptr<planner::AbstractPlan> child_plan;

  // TODO: Transform the parse tree

  // One to one Mapping
  auto parse_item_node_type = parse_tree->GetParseNodeType();

  switch(parse_item_node_type){
    case PARSE_NODE_TYPE_SCAN:
      child_plan = new planner::SeqScanPlan();
      break;
  }

//  if (child_plan != nullptr) {
//      if (plan_tree != nullptr)
//        plan_tree->AddChild(child_plan);
//      else
//        plan_tree = child_plan;
//    }
  return plan_tree;
}

}  // namespace optimizer
}  // namespace peloton

//===----------------------------------------------------------------------===//
//
//                         PelotonDB
//
// simple_optimizer.cpp
//
// Identification: /peloton/src/optimizer/simple_optimizer.cpp
//
// Copyright (c) 2016, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//

#include "optimizer/simple_optimizer.h"
#include "parser/peloton/abstract_parse.h"

#include "common/logger.h"

namespace peloton {
namespace optimizer {

SimpleOptimizer::SimpleOptimizer() {
}
;

SimpleOptimizer::~SimpleOptimizer() {
}
;

std::shared_ptr<planner::AbstractPlan> SimpleOptimizer::BuildPlanTree(
    const std::unique_ptr<parser::AbstractParse>& parse_tree) {

  if (parse_tree.get() == nullptr)
    return NULL;
  std::shared_ptr<planner::AbstractPlan> plan_tree;

  std::unique_ptr<planner::AbstractPlan> child_plan;

  // TODO: Transform the parse tree

  // One to one Mapping
  auto parse_item_node_type = parse_tree->GetParseNodeType();

//  if (child_plan != nullptr) {
//      if (plan_tree != nullptr)
//        plan_tree->AddChild(child_plan);
//      else
//        plan_tree = child_plan;
//    }
  return plan_tree;
}

}  // namespace optimizer
}  // namespace peloton

Remove switch case temporarlily for bulid purposes


// FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316
// XFAIL: android

// RUN: %clangxx -fsanitize=undefined %s -O1 -o %t

// Regular run.
// RUN: %run %t -4 2> %t.out
// RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.out

// Good log_path.
// RUN: rm -f %t.log.*
// RUN: %env_ubsan_opts=log_path='"%t.log"' %run %t -4 2> %t.out
// RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.log.*

// Run w/o errors should not produce any log.
// RUN: rm -f %t.log.*
// RUN: %env_ubsan_opts=log_path='"%t.log"'  %run %t 4
// RUN: not cat %t.log.*

// FIXME: log_path is not supported on Windows yet.
// XFAIL: win32

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
  double a = atof(argv[1]);
  unsigned int ai = (unsigned int) a;
  printf("%f %u\n", a, ai);
  return 0;
}

// CHECK-ERROR: runtime error: value -4 is outside the range of representable values of type 'unsigned int'

// FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316
// XFAIL: android

// The globs below do not work in the lit shell.
// REQUIRES: shell

// RUN: %clangxx -fsanitize=undefined %s -O1 -o %t

// Regular run.
// RUN: %run %t -4 2> %t.out
// RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.out

// Good log_path.
// RUN: rm -f %t.log.*
// RUN: %env_ubsan_opts=log_path='"%t.log"' %run %t -4 2> %t.out
// RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.log.*

// Run w/o errors should not produce any log.
// RUN: rm -f %t.log.*
// RUN: %env_ubsan_opts=log_path='"%t.log"'  %run %t 4
// RUN: not cat %t.log.*

// FIXME: log_path is not supported on Windows yet.
// XFAIL: win32

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
  double a = atof(argv[1]);
  unsigned int ai = (unsigned int) a;
  printf("%f %u\n", a, ai);
  return 0;
}

// CHECK-ERROR: runtime error: value -4 is outside the range of representable values of type 'unsigned int'

Mark the log_path ubsan test as requiring a shell. It uses globs.

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@246566 91177308-0d34-0410-b5e6-96231b3b80d8


// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/renderer/renderer_logging.h"

#include "base/logging.h"
#include "googleurl/src/gurl.h"

namespace renderer_logging {

// Sets the URL that is logged if the renderer crashes. Use GURL() to clear
// the URL.
void SetActiveRendererURL(const GURL& url) {
  // TODO(port): Once breakpad is integrated we can turn this on.
  NOTIMPLEMENTED();
}

}  // namespace renderer_logging

// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/renderer/renderer_logging.h"

#include "base/logging.h"
#include "googleurl/src/gurl.h"

namespace renderer_logging {

// Sets the URL that is logged if the renderer crashes. Use GURL() to clear
// the URL.
void SetActiveRendererURL(const GURL& url) {
  // crbug.com/9646
}

}  // namespace renderer_logging

Comment out a very annoying NOTIMPLEMENTED().

Review URL: http://codereview.chromium.org/56183

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@13024 0039d316-1c4b-4281-b951-d872f2087c98


#include "fileplugin.h"

#include "direngine.h"
#ifdef Q_OS_WIN
#include "fileenginewin.h"
#endif
#include "fileenginefallback.h"

FilePlugin::FilePlugin(QObject *parent) :
    AbstractFileEnginePlugin(parent)
{
}

QStringList FilePlugin::schemes() const
{
    return QStringList() << "file" << "qrc";
}

AbstractFileEngine *FilePlugin::createFileEngine(const QString &scheme) const
{
    if (scheme == "qrc")
        return new FileEngineFallback;

    if (scheme != "file")
        return Q_NULLPTR;

#ifdef Q_OS_WIN
    return new FileEngineWin;
#else
    return new FileEngineFallback;
#endif
}

AbstractDirEngine *FilePlugin::createDirEngine(const QString &scheme) const
{
    if (scheme != "qrc" && scheme != "file")
        return Q_NULLPTR;

    return new DirEngine;
}

#include "fileplugin.h"

#include "syncdirengine.h"
#ifdef Q_OS_WIN
#include "fileenginewin.h"
#endif
#include "fileenginefallback.h"

#include <QIO/SyncDirEngineWrapper>

FilePlugin::FilePlugin(QObject *parent) :
    AbstractFileEnginePlugin(parent)
{
}

QStringList FilePlugin::schemes() const
{
    return QStringList() << "file" << "qrc";
}

AbstractFileEngine *FilePlugin::createFileEngine(const QString &scheme) const
{
    if (scheme == "qrc")
        return new FileEngineFallback;

    if (scheme != "file")
        return Q_NULLPTR;

#ifdef Q_OS_WIN
    return new FileEngineWin;
#else
    return new FileEngineFallback;
#endif
}

AbstractDirEngine *FilePlugin::createDirEngine(const QString &scheme) const
{
    if (scheme != "qrc" && scheme != "file")
        return Q_NULLPTR;

    return new SyncDirEngineWrapper(new SyncDirEngine);
}

Use sync dir engine instead of async

Use sync dir engine instead of async


#include <caf/set_scheduler.hpp>

#include "vast.h"
#include "vast/filesystem.h"
#include "vast/logger.h"
#include "vast/serialization.h"

#include "framework/unit.h"

int main(int argc, char* argv[])
{
  // Work around CAF bug that blocks VAST in our "distributed" actor unit test
  // when using less than three threads.
  if (std::thread::hardware_concurrency() == 1)
    caf::set_scheduler<>(3);

  vast::announce_builtin_types();

  auto cfg = unit::configuration::parse(argc, argv);
  if (! cfg)
  {
    std::cerr << cfg.error() << '\n';
    return 1;
  }

  auto log_dir = vast::path{*cfg->get("vast-log-dir")};

  if (! vast::logger::instance()->init(
          vast::logger::quiet,
          vast::logger::debug,
          false, false, log_dir))
  {
    std::cerr << "failed to initialize VAST's logger" << std::endl;
    return 1;
  }

  auto rc = unit::engine::run(*cfg);

  if (! cfg->check("vast-keep-logs"))
    vast::rm(log_dir);

  return vast::cleanup() && rc ? 0 : 1;
}

#include <caf/set_scheduler.hpp>

#include "vast.h"
#include "vast/filesystem.h"
#include "vast/logger.h"
#include "vast/serialization.h"

#include "framework/unit.h"

int main(int argc, char* argv[])
{
  // Because we use several blocking actors in the unit tests, we need at least
  // some real parallelism to avoid a deadlock.
  if (std::thread::hardware_concurrency() < 4)
    caf::set_scheduler<>(4);

  vast::announce_builtin_types();

  auto cfg = unit::configuration::parse(argc, argv);
  if (! cfg)
  {
    std::cerr << cfg.error() << '\n';
    return 1;
  }

  auto log_dir = vast::path{*cfg->get("vast-log-dir")};

  if (! vast::logger::instance()->init(
          vast::logger::quiet,
          vast::logger::debug,
          false, false, log_dir))
  {
    std::cerr << "failed to initialize VAST's logger" << std::endl;
    return 1;
  }

  auto rc = unit::engine::run(*cfg);

  if (! cfg->check("vast-keep-logs"))
    vast::rm(log_dir);

  return vast::cleanup() && rc ? 0 : 1;
}

Increase minimum threads in test suite to 4.


// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/i18n/icu_util.h"

namespace icu_util {

bool Initialize() {
  return true;
}

}  // namespace icu_util

// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/i18n/icu_util.h"

namespace base {
namespace i18n {

BASE_I18N_EXPORT bool InitializeICU() {
  return true;
}

}  // namespace i18n
}  // namespace base

Build Fix for Win: Make base_i18n_nacl_win64.dll.lib to be generated

Since r219164, using GYP_DEFINES=component=shared_library causes build error with missing base_i18n_nacl_win64.dll.lib.

This patch changes to use full qualified name of base::i18n::InitializeICU() renamed by r219164 from icu_util::Initialize().

BUG=n/a
TBR= tfarina@chromium.org

Review URL: https://codereview.chromium.org/23003029

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@219255 0039d316-1c4b-4281-b951-d872f2087c98


/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

===================================================================*/

#include "QmitkDataNodeSelectionProvider.h"
#include "internal/QmitkDataNodeSelection.h"

QmitkDataNodeSelectionProvider::QmitkDataNodeSelectionProvider()
 : berry::QtSelectionProvider()
{

}

berry::ISelection::ConstPointer QmitkDataNodeSelectionProvider::GetSelection() const
{
  return this->GetDataNodeSelection();
}

mitk::DataNodeSelection::ConstPointer
QmitkDataNodeSelectionProvider::GetDataNodeSelection() const
{
  if (qSelectionModel)
  {
    QmitkDataNodeSelection::ConstPointer sel(new QmitkDataNodeSelection(
        qSelectionModel->selection()));
    return sel;
  }

  return QmitkDataNodeSelection::ConstPointer(new QmitkDataNodeSelection());
}

void QmitkDataNodeSelectionProvider::FireSelectionChanged(
    const QItemSelection&  /*selected*/, const QItemSelection&  /*deselected*/)
{
  berry::ISelection::ConstPointer sel(this->GetDataNodeSelection());
  berry::SelectionChangedEvent::Pointer event(new berry::SelectionChangedEvent(
      berry::ISelectionProvider::Pointer(this), sel));
  selectionEvents.selectionChanged(event);
}

/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

===================================================================*/

#include "QmitkDataNodeSelectionProvider.h"
#include "internal/QmitkDataNodeSelection.h"

QmitkDataNodeSelectionProvider::QmitkDataNodeSelectionProvider()
 : berry::QtSelectionProvider()
{

}

berry::ISelection::ConstPointer QmitkDataNodeSelectionProvider::GetSelection() const
{
  return this->GetDataNodeSelection();
}

mitk::DataNodeSelection::ConstPointer
QmitkDataNodeSelectionProvider::GetDataNodeSelection() const
{
  if (qSelectionModel)
  {
    QmitkDataNodeSelection::ConstPointer sel(new QmitkDataNodeSelection(
        qSelectionModel->selection()));
    return sel;
  }

  return QmitkDataNodeSelection::ConstPointer(0);
}

void QmitkDataNodeSelectionProvider::FireSelectionChanged(
    const QItemSelection&  /*selected*/, const QItemSelection&  /*deselected*/)
{
  berry::ISelection::ConstPointer sel(this->GetDataNodeSelection());
  berry::SelectionChangedEvent::Pointer event(new berry::SelectionChangedEvent(
      berry::ISelectionProvider::Pointer(this), sel));
  selectionEvents.selectionChanged(event);
}

Return a NULL selection if QItemSelectionModel is set.


//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <iterator>

// reverse_iterator

// template <class Iterator> reverse_iterator<Iterator>
//     make_reverse_iterator(Iterator i);

#include <iterator>
#include <cassert>

#include "test_iterators.h"

#if _LIBCPP_STD_VER > 11

template <class It>
void
test(It i)
{
    const std::reverse_iterator<It> r = std::make_reverse_iterator(i);
    assert(r.base() == i);
}

int main()
{
    const char* s = "1234567890";
    random_access_iterator<const char*>b(s);
    random_access_iterator<const char*>e(s+10);
    while ( b != e )
    	test ( b++ );
}
#else
int main () {}
#endif

Remove a stray tab that snuck into a test. No functionality change

git-svn-id: 756ef344af921d95d562d9e9f9389127a89a6314@202739 91177308-0d34-0410-b5e6-96231b3b80d8


// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"

// Flaky, http://crbug.com/46601.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, FLAKY_Popup) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("popup/popup_main")) << message_;
}

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PopupFromInfobar) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
    switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("popup/popup_from_infobar")) << message_;
}

// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"

// Times out. See http://crbug.com/46601.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_Popup) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("popup/popup_main")) << message_;
}

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PopupFromInfobar) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
    switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("popup/popup_from_infobar")) << message_;
}

Disable ExtensionApiTest.Popup. It's been timing out for the last 750+ runs.

TBR=michaeln

BUG=46601
TEST=ExtensionApiTest.FLAKY_Popup no longer runs
Review URL: http://codereview.chromium.org/3603003

git-svn-id: dd90618784b6a4b323ea0c23a071cb1c9e6f2ac7@61170 4ff67af0-8c30-449e-8e8b-ad334ec8d88c


#include "NMakefile.hpp"

#include <configure/Build.hpp>
#include <configure/Filesystem.hpp>
#include <configure/quote.hpp>
#include <configure/Node.hpp>

namespace configure { namespace generators {

	bool NMakefile::is_available(Build& build)
	{
		return build.fs().which("nmake") != boost::none;
	}

	std::string NMakefile::dump_command(std::vector<std::string> const& cmd) const
	{ return quote<CommandParser::nmake>(cmd); }

	std::vector<std::string>
	NMakefile::build_command(std::string const& target) const
	{
		return {
			"nmake", "-nologo", "-f", (_build.directory() / "Makefile").string(),
			target.empty() ? "all" : target
		};
	}

	bool NMakefile::use_relative_path() const { return false; }

	void NMakefile::include_dependencies(std::ostream& out, bool /* XXX relative */) const
	{
		for (auto& node: _includes)
			out << "!include " << node->path().string() << std::endl;
	}

}}

#include "NMakefile.hpp"

#include <configure/Build.hpp>
#include <configure/Filesystem.hpp>
#include <configure/quote.hpp>
#include <configure/Node.hpp>

namespace configure { namespace generators {

	bool NMakefile::is_available(Build& build)
	{
		return build.fs().which("nmake") != boost::none;
	}

	std::string NMakefile::dump_command(std::vector<std::string> const& cmd) const
	{ return quote<CommandParser::nmake>(cmd); }

	std::vector<std::string>
	NMakefile::build_command(std::string const& target) const
	{
		return {
			"nmake", "-nologo", "-f", (_build.directory() / "Makefile").string(),
			target.empty() ? "all" : target
		};
	}

	bool NMakefile::use_relative_path() const { return false; }

	void NMakefile::include_dependencies(std::ostream& out, bool /* XXX relative */) const
	{
		for (auto& node: _includes)
			out
				<< "!IF EXISTS(" << node->path().string() << ")" << std::endl
				<< "  !INCLUDE " << node->path().string() << std::endl
				<< "!ENDIF" << std::endl;
	}

}}

Check that include files exists in nmakefiles.


#include <ros/ros.h>
#include <tf/transform_broadcaster.h>

int main(int argc, char** argv){
	ros::init(argc, argv, "static_tf_node");
	ros::NodeHandle n;

	ros::Rate r(100);

	tf::TransformBroadcaster broadcaster;

	while(n.ok()){
		broadcaster.sendTransform(
				tf::StampedTransform(
					tf::Transform(
						tf::Quaternion(0, 0, 0, 1),
						tf::Vector3(0.1, 0.0, 0.2)
					),
				ros::Time::now(),"base_link", "base_laser")
		);
		r.sleep();
	}
}

#include <ros/ros.h>
#include <tf/transform_broadcaster.h>

int main(int argc, char** argv){
  ros::init(argc, argv, "static_tf_node");
  ros::NodeHandle n;

  ros::Rate r(100);

  tf::TransformBroadcaster broadcaster;

  while(n.ok()){
    broadcaster.sendTransform(
        tf::StampedTransform(
          tf::Transform(tf::Quaternion(0, 0, 0, 1), tf::Vector3(0.1, 0.0, 0.2)),
          ros::Time::now(),
	  "base_link",
	  "base_laser"
        )
    );
    r.sleep();
  }
}

Replace tab to space of indent on static_tf


// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "retrytransienterrorspolicy.h"
#include <vespa/messagebus/errorcode.h>

namespace mbus {

RetryTransientErrorsPolicy::RetryTransientErrorsPolicy() :
    _enabled(true),
    _baseDelay(1.0)
{}

RetryTransientErrorsPolicy &
RetryTransientErrorsPolicy::setEnabled(bool enabled) {
    _enabled = enabled;
    return *this;
}

RetryTransientErrorsPolicy &
RetryTransientErrorsPolicy::setBaseDelay(double baseDelay) {
    _baseDelay = baseDelay;
    return *this;
}

bool
RetryTransientErrorsPolicy::canRetry(uint32_t errorCode) const {
    return _enabled && errorCode < ErrorCode::FATAL_ERROR;
}

double
RetryTransientErrorsPolicy::getRetryDelay(uint32_t retry) const {
    return _baseDelay * retry;
}

}

// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "retrytransienterrorspolicy.h"
#include <vespa/messagebus/errorcode.h>

namespace mbus {

RetryTransientErrorsPolicy::RetryTransientErrorsPolicy() :
    _enabled(true),
    _baseDelay(1.0)
{}

RetryTransientErrorsPolicy &
RetryTransientErrorsPolicy::setEnabled(bool enabled) {
    _enabled = enabled;
    return *this;
}

RetryTransientErrorsPolicy &
RetryTransientErrorsPolicy::setBaseDelay(double baseDelay) {
    _baseDelay = baseDelay;
    return *this;
}

bool
RetryTransientErrorsPolicy::canRetry(uint32_t errorCode) const {
    return _enabled.load(std::memory_order_relaxed) && errorCode < ErrorCode::FATAL_ERROR;
}

double
RetryTransientErrorsPolicy::getRetryDelay(uint32_t retry) const {
    return _baseDelay.load(std::memory_order_relaxed) * retry;
}

}

Use relaxed memory ordering for speed.

Use relaxed memory ordering for speed.


// RUN: %clang_cc1 -S -emit-llvm -o %t.ll %s -triple x86_64-apple-darwin10
// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o %t-c++11.ll %s -triple x86_64-apple-darwin10
// RUN: diff %t.ll  %t-c++11.ll

// rdar://12897704

struct sAFSearchPos {
    unsigned char *pos;
    unsigned char count;
};

static volatile struct sAFSearchPos testPositions;

static volatile struct sAFSearchPos arrayPositions[100][10][5];

int main() {
  return testPositions.count + arrayPositions[10][4][3].count;
}

// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s -triple x86_64-apple-darwin10 | FileCheck %s
// RUN: %clang_cc1 -S -emit-llvm -o %t.ll %s -triple x86_64-apple-darwin10
// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o %t-c++11.ll %s -triple x86_64-apple-darwin10
// RUN: diff %t.ll  %t-c++11.ll

// rdar://12897704

struct sAFSearchPos {
    unsigned char *pos;
    unsigned char count;
};

static volatile struct sAFSearchPos testPositions;
// CHECK: @_ZL13testPositions = internal global %struct.sAFSearchPos zeroinitializer

static volatile struct sAFSearchPos arrayPositions[100][10][5];
// CHECK: @_ZL14arrayPositions = internal global [100 x [10 x [5 x %struct.sAFSearchPos]]] zeroinitializer

int main() {
  return testPositions.count + arrayPositions[10][4][3].count;
}

Improve on my last test for patch for // rdar://12897704

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@172154 91177308-0d34-0410-b5e6-96231b3b80d8


// Check that we detect malloc/delete mismatch only if the approptiate flag
// is set.

// RUN: %clangxx_asan -g %s -o %t 2>&1
// RUN: ASAN_OPTIONS=alloc_dealloc_mismatch=1 %t 2>&1 | \
// RUN: %symbolize | FileCheck %s

// No error here.
// RUN: ASAN_OPTIONS=alloc_dealloc_mismatch=0 %t
#include <stdlib.h>

static volatile char *x;

int main() {
  x = (char*)malloc(10);
  x[0] = 0;
  delete x;
}
// CHECK: ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x
// CHECK-NEXT: #0{{.*}}operator delete
// CHECK-NEXT: #1{{.*}}main
// CHECK: is located 0 bytes inside of 10-byte region
// CHECK-NEXT: allocated by thread T0 here:
// CHECK-NEXT: #0{{.*}}malloc
// CHECK-NEXT: #1{{.*}}main
// CHECK: HINT: if you don't care about these warnings you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0

// Check that we detect malloc/delete mismatch only if the approptiate flag
// is set.

// RUN: %clangxx_asan -g %s -o %t 2>&1
// RUN: ASAN_OPTIONS=alloc_dealloc_mismatch=1 %t 2>&1 | \
// RUN: %symbolize | FileCheck %s

// No error here.
// RUN: ASAN_OPTIONS=alloc_dealloc_mismatch=0 %t
#include <stdlib.h>

static volatile char *x;

int main() {
  x = (char*)malloc(10);
  x[0] = 0;
  delete x;
}
// CHECK: ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x
// CHECK-NEXT: #0{{.*}}operator delete
// CHECK-NEXT: #1{{.*}}main
// CHECK: is located 0 bytes inside of 10-byte region
// CHECK-NEXT: allocated by thread T0 here:
// CHECK-NEXT: #0{{.*}}malloc
// CHECK-NEXT: #1{{.*}}main
// CHECK: HINT: {{.*}} you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0

[ASan] Fix another FileCheck pattern to be c++filt-proof.

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@170878 91177308-0d34-0410-b5e6-96231b3b80d8


// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "testing/gtest/include/gtest/gtest.h"

#include "base/basictypes.h"
#include "net/http/http_auth_handler_basic.h"

namespace net {

TEST(HttpAuthHandlerBasicTest, GenerateCredentials) {
  static const struct {
    const wchar_t* username;
    const wchar_t* password;
    const char* expected_credentials;
  } tests[] = {
    { L"foo", L"bar", "Basic Zm9vOmJhcg==" },
    // Empty password
    { L"anon", L"", "Basic YW5vbjo=" },
  };
  for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
    std::string challenge = "Basic realm=\"Atlantis\"";
    HttpAuthHandlerBasic basic;
    basic.InitFromChallenge(challenge.begin(), challenge.end(),
                            HttpAuth::AUTH_SERVER);
    std::string credentials = basic.GenerateCredentials(tests[i].username,
                                                        tests[i].password,
                                                        NULL, NULL);
    EXPECT_STREQ(tests[i].expected_credentials, credentials.c_str());
  }
}

} // namespace net

// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "testing/gtest/include/gtest/gtest.h"

#include "base/basictypes.h"
#include "net/http/http_auth_handler_basic.h"

namespace net {

TEST(HttpAuthHandlerBasicTest, GenerateCredentials) {
  static const struct {
    const wchar_t* username;
    const wchar_t* password;
    const char* expected_credentials;
  } tests[] = {
    { L"foo", L"bar", "Basic Zm9vOmJhcg==" },
    // Empty username
    { L"", L"foobar", "Basic OmZvb2Jhcg==" },
    // Empty password
    { L"anon", L"", "Basic YW5vbjo=" },
  };
  for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
    std::string challenge = "Basic realm=\"Atlantis\"";
    HttpAuthHandlerBasic basic;
    basic.InitFromChallenge(challenge.begin(), challenge.end(),
                            HttpAuth::AUTH_SERVER);
    std::string credentials = basic.GenerateCredentials(tests[i].username,
                                                        tests[i].password,
                                                        NULL, NULL);
    EXPECT_STREQ(tests[i].expected_credentials, credentials.c_str());
  }
}

} // namespace net

Add an HTTP basic auth unit test for an empty username.

R=eroman
BUG=297
Review URL: http://codereview.chromium.org/8859

git-svn-id: http://src.chromium.org/svn/trunk/src@4109 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

Former-commit-id: f9261bf0792274bf2ed1ada056a1d9dca2be377a


// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/sessions/session_restore_delegate.h"

#include "base/metrics/field_trial.h"
#include "chrome/browser/sessions/session_restore_stats_collector.h"
#include "chrome/browser/sessions/tab_loader.h"

// static
void SessionRestoreDelegate::RestoreTabs(
    const std::vector<RestoredTab>& tabs,
    const base::TimeTicks& restore_started) {
  // TODO(georgesak): make tests aware of that behavior so that they succeed if
  // tab loading is disabled.
  base::FieldTrial* trial =
      base::FieldTrialList::Find("SessionRestoreBackgroundLoading");
  bool active_only = true;
  if (!trial || trial->group_name() != "Disabled") {
    TabLoader::RestoreTabs(tabs, restore_started);
    active_only = false;
  }
  SessionRestoreStatsCollector::TrackTabs(tabs, restore_started, active_only);
}

// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/sessions/session_restore_delegate.h"

#include "base/metrics/field_trial.h"
#include "chrome/browser/sessions/session_restore_stats_collector.h"
#include "chrome/browser/sessions/tab_loader.h"

// static
void SessionRestoreDelegate::RestoreTabs(
    const std::vector<RestoredTab>& tabs,
    const base::TimeTicks& restore_started) {
  // TODO(georgesak): make tests aware of that behavior so that they succeed if
  // tab loading is disabled.
  base::FieldTrial* trial =
      base::FieldTrialList::Find("SessionRestoreBackgroundLoading");
  bool active_only = true;
  if (!trial || trial->group_name() == "Enabled") {
    TabLoader::RestoreTabs(tabs, restore_started);
    active_only = false;
  }
  SessionRestoreStatsCollector::TrackTabs(tabs, restore_started, active_only);
}

Change logic to enable for group Enabled (for A/B testing).

This allows to have multiple Disabled group, e.g. Disabled/Disabled_control, and thus eases experimentation.

TBR=sky@chromium.org
BUG=465815

Review URL: https://codereview.chromium.org/1062243002

Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#324099}


#include "ofxHapImageSequence.h"

ofxHapImageSequence::ofxHapImageSequence()
{

}

ofxHapImageSequence::ofxHapImageSequence(ofDirectory& directory)
{
    load(directory);
}

ofxHapImageSequence::ofxHapImageSequence(const std::string& path)
{
    load(path);
}

ofxHapImageSequence::~ofxHapImageSequence()
{

}

void ofxHapImageSequence::load(ofDirectory &directory)
{
    load(directory.path());
}

void ofxHapImageSequence::load(const std::string &path)
{
    directory_ = ofDirectory(path);
    directory_.allowExt(ofxHapImage::HapImageFileExtension());
    directory_.listDir();
    directory_.sort();
}

unsigned int ofxHapImageSequence::size()
{
    return directory_.size();
}

ofxHapImage ofxHapImageSequence::getImage(unsigned int index)
{
    return ofxHapImage(directory_[index]);
}

#include "ofxHapImageSequence.h"

ofxHapImageSequence::ofxHapImageSequence()
{

}

ofxHapImageSequence::ofxHapImageSequence(ofDirectory& directory)
{
    load(directory);
}

ofxHapImageSequence::ofxHapImageSequence(const std::string& path)
{
    load(path);
}

ofxHapImageSequence::~ofxHapImageSequence()
{

}

void ofxHapImageSequence::load(ofDirectory &directory)
{
    load(directory.path());
}

void ofxHapImageSequence::load(const std::string &path)
{
    ofFile file(path, ofFile::Reference);
    if (file.exists() && !file.isDirectory())
    {
        file = ofFile(file.getEnclosingDirectory(), ofFile::Reference);
    }
    // listDir() and sort() are slow in Debug builds on Windows
    directory_ = ofDirectory(file.getAbsolutePath());
    directory_.allowExt(ofxHapImage::HapImageFileExtension());
    directory_.listDir();
    directory_.sort();
}

unsigned int ofxHapImageSequence::size()
{
    return directory_.size();
}

ofxHapImage ofxHapImageSequence::getImage(unsigned int index)
{
    return ofxHapImage(directory_[index]);
}

Allow instantiation of sequence from file path

Accept a file path within the directory or directory path when
creating/loading an ofxHapImageSequence


#include <iostream>

class MyClass
{
	public:

		MyClass(int value) : m_fixedValue(value) {}

		const int m_fixedValue;

		static const int m_fixedStaticValue;
};

const int MyClass::m_fixedStaticValue = 9;

int main()
{
	const MyClass myInstance(9);
	std::cout << myInstance.m_fixedValue << std::endl;
	const_cast<int&>(myInstance.m_fixedValue) = 7;
	const_cast<int&>(myInstance.m_fixedStaticValue) = 7;
	std::cout << myInstance.m_fixedValue << std::endl;
}

#include <iostream>

class MyClass
{
	public:

		MyClass(int value) : m_fixedValue(value) {}

		const int m_fixedValue;

		static const int m_fixedStaticValue;
};

const int MyClass::m_fixedStaticValue = 9;

int main()
{
	const MyClass myInstance(9);
	std::cout << myInstance.m_fixedValue << std::endl;
	const_cast<int&>(myInstance.m_fixedValue) = 7;
	std::cout << myInstance.m_fixedValue << std::endl;
	const_cast<int&>(myInstance.m_fixedStaticValue) = 7;
	std::cout << MyClass::m_fixedStaticValue<< std::endl;
}

Put an additional print in place.

Put an additional print in place.

One can now see which const cast is causing the crash.


// Copyright 2004-present Facebook. All Rights Reserved.

#include <stdio.h>
#include <string.h>

#include "osquery/database.h"

namespace osquery {
namespace tables {

QueryData genArp() {
  Row r;
  QueryData results;
  FILE *proc_arp_fd;
  char *line = nullptr;
  size_t length;
  int ret;

  // We are already calling 'popen', let's give it some more work with sed to clean.
  proc_arp_fd = fopen("/proc/net/arp" , "r");
  if (proc_arp_fd == nullptr) {
    return results;
  }

  ret = getline(&line, &length, proc_arp_fd); // Discard first one. Just a header
  ret = getline(&line, &length, proc_arp_fd);
  while (ret > 0) {
    std::vector<std::string> fields;
    // IP address       HW type     Flags       HW address            Mask     Device
    boost::split(fields, line, boost::is_any_of(" "));

    r["ip"] = fields[0];
    r["mac"] = fields[3];
    r["iface"] = fields[5];

    results.push_back(r);

    line = nullptr;
    ret = getline(&line, &length, proc_arp_fd);
  }

  return results;
}
}
}

// Copyright 2004-present Facebook. All Rights Reserved.

#include <stdio.h>
#include <string.h>

#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp>

#include "osquery/database.h"

namespace osquery {
namespace tables {

QueryData genArp() {
  Row r;
  QueryData results;
  FILE *proc_arp_fd;
  char *line = nullptr;
  size_t length;
  int ret;

  // We are already calling 'popen', let's give it some more work with sed to clean.
  proc_arp_fd = fopen("/proc/net/arp" , "r");
  if (proc_arp_fd == nullptr) {
    return results;
  }

  ret = getline(&line, &length, proc_arp_fd); // Discard first one. Just a header
  ret = getline(&line, &length, proc_arp_fd);
  while (ret > 0) {
    std::vector<std::string> fields;
    // IP address       HW type     Flags       HW address            Mask     Device
    boost::split(fields, line, boost::is_any_of(" "), boost::token_compress_on);

    if (fields.size() == 6) {
      boost::trim(fields[0]);
      boost::trim(fields[3]);
      boost::trim(fields[5]);
      r["ip"] = fields[0];
      r["mac"] = fields[3];
      r["iface"] = fields[5];

      results.push_back(r);
    }

    free(line);
    line = nullptr;

    ret = getline(&line, &length, proc_arp_fd);
  }

  return results;
}
}
}

Fix boost split on linux to remove sscanf


#include <thread>
#include <atomic>
#include <iostream>
#include <vector>

struct AtomicCounter {
    std::atomic<int> value;

    void increment(){
        ++value;
    }

    void decrement(){
        --value;
    }

    int get(){
        return value.load();
    }
};

int main(){
    AtomicCounter counter;

    std::vector<std::thread> threads;
    for(int i = 0; i < 10; ++i){
        threads.push_back(std::thread([&counter](){
            for(int i = 0; i < 500; ++i){
                counter.increment();
            }
        }));
    }

    for(auto& thread : threads){
        thread.join();
    }

    std::cout << counter.get() << std::endl;

    return 0;
}

#include <thread>
#include <atomic>
#include <iostream>
#include <vector>

struct AtomicCounter {
    std::atomic<int> value;

    AtomicCounter() : value(0) {}

    void increment(){
        ++value;
    }

    void decrement(){
        --value;
    }

    int get(){
        return value.load();
    }
};

int main(){
    AtomicCounter counter;

    std::vector<std::thread> threads;
    for(int i = 0; i < 10; ++i){
        threads.push_back(std::thread([&counter](){
            for(int i = 0; i < 500; ++i){
                counter.increment();
            }
        }));
    }

    for(auto& thread : threads){
        thread.join();
    }

    std::cout << counter.get() << std::endl;

    return 0;
}

Make sure std::atomic is initialized correctly

G++ seems to have some issues with default initialization of
std::atomic


// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/web_applications/web_app.h"

namespace web_app {
namespace internals {

bool CreatePlatformShortcut(
    const FilePath& web_app_path,
    const FilePath& profile_path,
    const ShellIntegration::ShortcutInfo& shortcut_info) {
  return true;
}

}  // namespace internals
}  // namespace web_app

// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/web_applications/web_app.h"

namespace web_app {
namespace internals {

bool CreatePlatformShortcut(
    const FilePath& web_app_path,
    const FilePath& profile_path,
    const ShellIntegration::ShortcutInfo& shortcut_info) {
  return true;
}

void DeletePlatformShortcuts(const FilePath& profile_path,
                             const std::string& extension_id) {}

}  // namespace internals
}  // namespace web_app

Add dummy DeletePlatformShortcuts() for Android.

This is part of the unit_tests linking effort on Android.

BUG=136787

Review URL: https://chromiumcodereview.appspot.com/10693176

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@147276 0039d316-1c4b-4281-b951-d872f2087c98


// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/dropdown_bar_host.h"

#include "base/logging.h"
#include "ui/aura/window.h"
#include "ui/views/widget/widget.h"

using content::WebContents;

NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent(
     const WebContents* contents,
     const views::KeyEvent& key_event) {
  return NativeWebKeyboardEvent(key_event.native_event());
}

void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos,
                                              bool no_redraw) {
  if (!host_->IsVisible())
    host_->GetNativeView()->Show();
  host_->GetNativeView()->SetBounds(new_pos);
}

// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/dropdown_bar_host.h"

#include "base/logging.h"
#include "ui/aura/window.h"
#include "ui/views/widget/widget.h"

using content::WebContents;

NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent(
     const WebContents* contents,
     const views::KeyEvent& key_event) {
  return NativeWebKeyboardEvent(key_event.native_event());
}

void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos,
                                              bool no_redraw) {
  if (!host_->IsVisible())
    host_->GetNativeView()->Show();
  host_->GetNativeView()->SetBounds(new_pos);
  host_->StackAtTop();
}

aura: Fix findbar visibility when switching between tabs.

BUG=110936
TEST=manually

Review URL: https://chromiumcodereview.appspot.com/9293031

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@119909 0039d316-1c4b-4281-b951-d872f2087c98


/*
 * Copyright 2003-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/exception.h>
#include <apr_atomic.h>

using namespace log4cxx::helpers;

void ObjectPtrBase::checkNull(const int& null) {
        if (null != 0)
        {

                throw IllegalArgumentException("Attempt to set pointer to a non-zero numeric value.");
        }
}

void* ObjectPtrBase::exchange(volatile void** destination, void* newValue) {
#if defined(_WIN32)
    return InterlockedExchangePointer(destination, newValue);
#else
   return apr_atomic_casptr(destination, newValue, (const void*) *destination);
#endif
}

/*
 * Copyright 2003-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/exception.h>
#include <apr_atomic.h>

using namespace log4cxx::helpers;

void ObjectPtrBase::checkNull(const int& null) {
        if (null != 0)
        {

                throw IllegalArgumentException("Attempt to set pointer to a non-zero numeric value.");
        }
}

void* ObjectPtrBase::exchange(volatile void** destination, void* newValue) {
   return apr_atomic_casptr(destination, newValue, (const void*) *destination);
}

LOGCXX-132: Switch from InterlockedExchangePointer back to APR atomic

git-svn-id: a7c1976543b50a5b791fd6a475a0ba067ae951b4@407850 13f79535-47bb-0310-9956-ffa450edef68


//===-- XCoreTargetObjectFile.cpp - XCore object files --------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "XCoreTargetObjectFile.h"
#include "XCoreSubtarget.h"
#include "llvm/Target/TargetMachine.h"
using namespace llvm;

void XCoreTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM){
  TargetLoweringObjectFileELF::Initialize(Ctx, TM);

  TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
  DataSection = getOrCreateSection("\t.dp.data", false, SectionKind::DataRel);
  BSSSection_ = getOrCreateSection("\t.dp.bss", false, SectionKind::BSS);

  // TLS globals are lowered in the backend to arrays indexed by the current
  // thread id. After lowering they require no special handling by the linker
  // and can be placed in the standard data / bss sections.
  TLSDataSection = DataSection;
  TLSBSSSection = BSSSection_;

  if (TM.getSubtarget<XCoreSubtarget>().isXS1A())
    // FIXME: Why is this writable ("datarel")???
    ReadOnlySection = getOrCreateSection("\t.dp.rodata", false,
                                         SectionKind::DataRel);
  else
    ReadOnlySection = getOrCreateSection("\t.cp.rodata", false,
                                         SectionKind::ReadOnly);
}

Add newline at end of file to remove gcc warning.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@77791 91177308-0d34-0410-b5e6-96231b3b80d8


/*
 * QueryModule.cc
 *
 * Load the query subsystem as a module.
 * Copyright (c) 2008 Linas Vepstas <linas@linas.org>
 */

#include <opencog/query/PatternSCM.h>
#include "QueryModule.h"

using namespace opencog;

DECLARE_MODULE(QueryModule);

QueryModule::QueryModule(CogServer& cs) : Module(cs), _pat(NULL)
{
}

QueryModule::~QueryModule()
{
	delete _pat;
}

void QueryModule::init(void)
{
	_pat = new PatternSCM();
}

/*
 * QueryModule.cc
 *
 * Load the query subsystem as a module.
 * Copyright (c) 2008 Linas Vepstas <linas@linas.org>
 */

#include <opencog/query/PatternSCM.h>
#include "QueryModule.h"

using namespace opencog;

DECLARE_MODULE(QueryModule);

QueryModule::QueryModule(CogServer& cs) : Module(cs), _pat(NULL)
{
}

QueryModule::~QueryModule()
{
	delete _pat;
}

void QueryModule::init(void)
{
	_pat = new PatternSCM();
	_pat->module_init();
}

Call the Query Module's init

Call the Query Module's init


// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/views/controls/textfield/textfield_controller.h"

namespace views {

TextfieldController::IsCommandIdEnabled(int command_id) const {
  return false;
}

}  // namespace views

// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/views/controls/textfield/textfield_controller.h"

namespace views {

bool TextfieldController::IsCommandIdEnabled(int command_id) const {
  return false;
}

}  // namespace views

Fix the fix. Added missing return type.

Fix the fix. Added missing return type.

TBR=varunjain@chromium.org
TEST=ChromiumOS clang bots build

Review URL: https://chromiumcodereview.appspot.com/9233010

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@118450 0039d316-1c4b-4281-b951-d872f2087c98


Fix that bug where things didn't work but now they should


// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_apitest.h"

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Bookmarks) {
  // TODO(erikkay) no initial state for this test.
  ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_;
}

// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_apitest.h"

// TODO(brettw) bug 19866: this test is disabled because it is flaky.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_Bookmarks) {
  // TODO(erikkay) no initial state for this test.
  ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_;
}

Disable the Bookmarks ExtensionAPITest becuase it is flaky.

Review URL: http://codereview.chromium.org/173149

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@23877 0039d316-1c4b-4281-b951-d872f2087c98


// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_apitest.h"

#include "chrome/browser/browser.h"
#include "chrome/browser/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/common/pref_names.h"

// TODO(skerner): This test is flaky in chromeos.  Figure out why and fix.
#if defined(OS_LINUX) && defined(TOOLKIT_VIEWS)
#define MAYBE_Tabs DISABLED_Tabs
#else
#define MAYBE_Tabs Tabs
#endif

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Tabs) {
  StartHTTPServer();

  // The test creates a tab and checks that the URL of the new tab
  // is that of the new tab page.  Make sure the pref that controls
  // this is set.
  browser()->profile()->GetPrefs()->SetBoolean(
      prefs::kHomePageIsNewTabPage, true);

  ASSERT_TRUE(RunExtensionTest("tabs/basics")) << message_;
}

// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_apitest.h"

#include "chrome/browser/browser.h"
#include "chrome/browser/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/common/pref_names.h"

// TODO(skerner): This test is flaky in chromeos and on Mac OS X 10.6.  Figure
// out why and fix.
#if (defined(OS_LINUX) && defined(TOOLKIT_VIEWS)) || defined(OS_MACOSX)
#define MAYBE_Tabs DISABLED_Tabs
#else
#define MAYBE_Tabs Tabs
#endif

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Tabs) {
  StartHTTPServer();

  // The test creates a tab and checks that the URL of the new tab
  // is that of the new tab page.  Make sure the pref that controls
  // this is set.
  browser()->profile()->GetPrefs()->SetBoolean(
      prefs::kHomePageIsNewTabPage, true);

  ASSERT_TRUE(RunExtensionTest("tabs/basics")) << message_;
}

Disable ExtensionApiTest.Tabs on Mac.
TEST=no random redness on Mac OS X 10.6 bot
BUG=37387
TBR=skerner@

git-svn-id: http://src.chromium.org/svn/trunk/src@40616 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

Former-commit-id: 8a6a905d8137757370a84a53a6f8e3a06fa2bffd


// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"

#if defined(TOOLKIT_VIEWS)
// Need to port ExtensionInfoBarDelegate::CreateInfoBar() to other platforms.
// See http://crbug.com/39916 for details.
#define MAYBE_Infobars Infobars
#else
#define MAYBE_Infobars DISABLED_Infobars
#endif

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Infobars) {
  // TODO(finnur): Remove once infobars are no longer experimental (bug 39511).
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("infobars")) << message_;
}

// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"

#if defined(TOOLKIT_VIEWS)
#if defined (OS_WIN)
#define MAYBE_Infobars Infobars
#else
// Flaky on ChromeOS, see http://crbug.com/40141.
#define MAYBE_Infobars FLAKY_Infobars
#endif

#else
// Need to port ExtensionInfoBarDelegate::CreateInfoBar() to other platforms.
// See http://crbug.com/39916 for details.
#define MAYBE_Infobars DISABLED_Infobars
#endif

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Infobars) {
  // TODO(finnur): Remove once infobars are no longer experimental (bug 39511).
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("infobars")) << message_;
}

Mark a test as flaky on ChromeOS.

Mark a test as flaky on ChromeOS.

BUG=40141
TEST=None

Review URL: http://codereview.chromium.org/1575015

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@43384 0039d316-1c4b-4281-b951-d872f2087c98


// Copyright 2017, Dawid Kurek, <dawikur@gmail.com>

#include "lel/operation/unary.hpp"

#include "gtest/gtest.h"

TEST(unary_test, logical_not_can_be_used_in_constexpr) {
  std::logical_not<> logical_not;

  static_assert(logical_not(false), "");
}

TEST(unary_test, indirection_can_be_used_in_constexpr) {
  LeL::Operation::__Indirection indirection;

  int const val = 5;

  static_assert(indirection(&val) == 5, "");
}

Remove problemanic on VS test

Remove problemanic on VS test


// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/common/net/test_url_fetcher_factory.h"

TestURLFetcher::TestURLFetcher(int id,
                               const GURL& url,
                               URLFetcher::RequestType request_type,
                               URLFetcher::Delegate* d)
    : URLFetcher(url, request_type, d),
      id_(id),
      original_url_(url) {
}

URLFetcher* TestURLFetcherFactory::CreateURLFetcher(
    int id,
    const GURL& url,
    URLFetcher::RequestType request_type,
    URLFetcher::Delegate* d) {
  TestURLFetcher* fetcher = new TestURLFetcher(id, url, request_type, d);
  fetchers_[id] = fetcher;
  return fetcher;
}

TestURLFetcher* TestURLFetcherFactory::GetFetcherByID(int id) const {
  Fetchers::const_iterator i = fetchers_.find(id);
  return i == fetchers_.end() ? NULL : i->second;
}

void TestURLFetcherFactory::RemoveFetcherFromMap(int id) {
  Fetchers::const_iterator i = fetchers_.find(id);
  DCHECK(i != fetchers_.end());
  fetchers_.erase(i);
}

// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/common/net/test_url_fetcher_factory.h"

TestURLFetcher::TestURLFetcher(int id,
                               const GURL& url,
                               URLFetcher::RequestType request_type,
                               URLFetcher::Delegate* d)
    : URLFetcher(url, request_type, d),
      id_(id),
      original_url_(url) {
}

URLFetcher* TestURLFetcherFactory::CreateURLFetcher(
    int id,
    const GURL& url,
    URLFetcher::RequestType request_type,
    URLFetcher::Delegate* d) {
  TestURLFetcher* fetcher = new TestURLFetcher(id, url, request_type, d);
  fetchers_[id] = fetcher;
  return fetcher;
}

TestURLFetcher* TestURLFetcherFactory::GetFetcherByID(int id) const {
  Fetchers::const_iterator i = fetchers_.find(id);
  return i == fetchers_.end() ? NULL : i->second;
}

void TestURLFetcherFactory::RemoveFetcherFromMap(int id) {
  Fetchers::iterator i = fetchers_.find(id);
  DCHECK(i != fetchers_.end());
  fetchers_.erase(i);
}

Fix compile failure on GCC

Fix compile failure on GCC

BUG=54274
TEST=none

git-svn-id: http://src.chromium.org/svn/trunk/src@65426 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

Former-commit-id: 5e342b24ea929256ace9c305fff8b359ec232489


// Validate multiple reads

#include <sstream>
#include <string>

int main()
{
	std::istringstream stream{"John Smith 32"};

	std::string first_name;
	std::string family_name;
	int age;

	if (stream >> first_name &&
	    stream >> family_name &&
	    stream >> age) {
		// Use values
	}
}

// Ensure that multiple stream reads are successful before using the
// extracted values.
//
// We create a [`std::istringstream`](cpp/io/basic_istringstream) as
// the example input stream, which contains some values that we wish
// to read ([8]). This stream could be replaced by any other
// input stream, such as [`std::cin`](cpp/io/cin) or a file stream.
// We then create some objects on [10-11] into which we will read
// values from the stream.
//
// In the condition of the `if` statement on [14-16], we perform the
// extractions. The `&&` operators ensure that the condition
// is `true` only when all extractions succeed. Short-circuiting
// also ensures that an extraction is only evaluated if the previous
// extractions were successful.
//
// If you are reading values on multiple lines, consider [reading
// from the stream line-by-line](/common-tasks/read-line-by-line.html)
// and then parsing each line.

// Validate multiple reads

#include <sstream>
#include <string>

int main()
{
	std::istringstream stream{"Chief Executive Officer\n"
	                          "John Smith\n"
	                          "32"};

	std::string position;
	std::string first_name;
	std::string family_name;
	int age;

	if (std::getline(stream, position) &&
	    stream >> first_name >> family_name >> age) {
		// Use values
	}
}

// Ensure that multiple stream reads are successful before using the
// extracted values.
//
// We create a [`std::istringstream`](cpp/io/basic_istringstream) as
// the example input stream, which contains some values that we wish
// to read ([8-10]). This stream could be replaced by any other
// input stream, such as [`std::cin`](cpp/io/cin) or a file stream.
// We then create some objects on [12-15] into which we will read
// values from the stream.
//
// In the condition of the `if` statement on [17-20], we first perform
// an unformatted extraction with
// [`std::getline`](cpp/string/basic_string/getline) [17]
// and then a series of formatted extractions [18]. The `&&` operator
// ensures that the condition is `true` only when all extractions
// succeed. Short-circuiting also ensures that the second set of
// extractions are only attempted if the previous extraction was
// successful.
//
// If you are reading values on multiple lines, consider [reading
// from the stream line-by-line](/common-tasks/read-line-by-line.html)
// and then parsing each line.

Improve validate multiple reads sample

Improve validate multiple reads sample


void sink(...);
int source();

// --- accept ---

struct sockaddr {
	unsigned char length;
	int sa_family;
	char* sa_data;
};

int accept(int, const sockaddr*, int*);

void sink(sockaddr);

void test_accept() {
  int s = source();
  sockaddr addr;
  int size = sizeof(sockaddr);
  int a = accept(s, &addr, &size);

  sink(a); // $ ast=17:11 ir SPURIOUS: ast=18:12
  sink(addr); // $ ast,ir
}

void sink(...);
int source();

// --- accept ---

struct sockaddr {
	unsigned char length;
	int sa_family;
	char* sa_data;
};

int accept(int, sockaddr*, int*);

void sink(sockaddr);

void test_accept() {
  int s = source();
  sockaddr addr;
  int size = sizeof(sockaddr);
  int a = accept(s, &addr, &size);

  sink(a); // $ ast=17:11 ir SPURIOUS: ast=18:12
  sink(addr); // $ ast=17:11 ir SPURIOUS: ast=18:12
}

C++: Fix the `accept` prototype in the dataflow taint tests


/** @example user_touche.cpp
 Touche example. See documentation on the wiki.
 */

#include <ESP.h>

BinaryIntArraySerialStream stream(115200, 160);
TcpOStream oStream("localhost", 5204);
GestureRecognitionPipeline pipeline;

void setup()
{
    useStream(stream);
    useOutputStream(oStream);

    pipeline.setClassifier(SVM(SVM::POLY_KERNEL, SVM::C_SVC, false, true, true, 0.1, 1.0, 0, 0.5, 2));
    usePipeline(pipeline);

    useLeaveOneOutScoring(false);
}

/** @example user_touche.cpp
 Touche example. See documentation on the wiki.
 */

#include <ESP.h>

BinaryIntArraySerialStream stream(115200, 160);
TcpOStream oStream("localhost", 5204);
GestureRecognitionPipeline pipeline;

void setup()
{
    useStream(stream);
    useOutputStream(oStream);

    pipeline.setClassifier(SVM(SVM::POLY_KERNEL, SVM::C_SVC, false, true, true, 0.1, 1.0, 0, 0.5, 2));
    usePipeline(pipeline);

    setTruePositiveWarningThreshold(0.90);
    setFalseNegativeWarningThreshold(0.10);

    useLeaveOneOutScoring(false);
}

Add true-positive and false-negative warning thresholds to Touche example.


// request symbols
#include "cling/Interpreter/Interpreter.h"
#include "cling/Interpreter/CValuePrinter.h"
#include "cling/Interpreter/DynamicExprInfo.h"
#include "cling/Interpreter/InterpreterCallbacks.h"
#include "cling/Interpreter/LookupHelper.h"
#include "cling/Interpreter/ValuePrinter.h"
#include "cling/Interpreter/ValuePrinterInfo.h"
#include "cling/UserInterface/UserInterface.h"

#include "clang/AST/Type.h"

#include "llvm/Support/raw_ostream.h"

namespace cling {
void libcling__symbol_requester() {
   const char* const argv[] = {"libcling__symbol_requester", 0};
   cling::Interpreter I(1, argv);
   cling::UserInterface U(I);
   cling::ValuePrinterInfo VPI(0, 0); // asserts, but we don't call.
   printValuePublicDefault(llvm::outs(), 0, VPI);
   cling_PrintValue(0, 0, 0);
   flushOStream(llvm::outs());
   LookupHelper h(0);
   h.findType("");
   h.findScope("");
   h.findFunctionProto(0, "", "");
   h.findFunctionArgs(0, "", "");
   cling::runtime::internal::DynamicExprInfo DEI(0,0,false);
   DEI.getExpr();
   cling::InterpreterCallbacks cb(0);
}

}

// request symbols
#include "cling/Interpreter/Interpreter.h"
#include "cling/Interpreter/CValuePrinter.h"
#include "cling/Interpreter/DynamicExprInfo.h"
#include "cling/Interpreter/InterpreterCallbacks.h"
#include "cling/Interpreter/LookupHelper.h"
#include "cling/Interpreter/ValuePrinter.h"
#include "cling/Interpreter/ValuePrinterInfo.h"
#include "cling/UserInterface/UserInterface.h"

#include "clang/AST/Type.h"

#include "llvm/Support/raw_ostream.h"

namespace cling {
namespace internal {
void libcling__symbol_requester() {
   const char* const argv[] = {"libcling__symbol_requester", 0};
   cling::Interpreter I(1, argv);
   cling::UserInterface U(I);
   cling::ValuePrinterInfo VPI(0, 0); // asserts, but we don't call.
   printValuePublicDefault(llvm::outs(), 0, VPI);
   cling_PrintValue(0, 0, 0);
   flushOStream(llvm::outs());
   LookupHelper h(0);
   h.findType("");
   h.findScope("");
   h.findFunctionProto(0, "", "");
   h.findFunctionArgs(0, "", "");
   cling::runtime::internal::DynamicExprInfo DEI(0,0,false);
   DEI.getExpr();
   cling::InterpreterCallbacks cb(0);
}
}
}

Put the symbol requester func into the proper namespace!

git-svn-id: ecbadac9c76e8cf640a0bca86f6bd796c98521e3@46987 27541ba8-7e3a-0410-8455-c3a389f83636


#include "RandomGenerator.h"

RandomGenerator::RandomGenerator()
{
    // reset random seed - to generate different values each time.
    std::srand(time(0));
}

RandomGenerator::~RandomGenerator()
{
    std::cout << "Random deleted" << std::endl;
}

int RandomGenerator::getRandomNumber(int min, int max, bool includeMax)
{
    return std::rand() % ((max - min) + includeMax) + min;
}

#include "RandomGenerator.h"

RandomGenerator::RandomGenerator()
{
    // reset random seed - to generate different values each time.
    std::srand(time(0));
}

RandomGenerator::~RandomGenerator()
{
    std::cout << "Random deleted" << std::endl;
}

int RandomGenerator::getRandomNumber(int min, int max, bool includeMax)
{
    if (min == max)
    {
        return min;
    }

    return std::rand() % ((max - min) + includeMax) + min;
}

Fix bug with generating numbers.

Fix bug with generating numbers.


/*
    Copyright (c) 2009 Stephen Kelly <steveire@gmail.com>
*/

#include "include.h"

#include <QStringList>
#include <QtPlugin>

#include "parser.h"
#include "template.h"

#include <QDebug>

IncludeNodeFactory::IncludeNodeFactory()
{

}

Node* IncludeNodeFactory::getNode(const QString &tagContent, Parser *p)
{
  QStringList expr = tagContent.split(" ", QString::SkipEmptyParts);

  QString includeName = expr.at(1);
  int size = includeName.size();

  if (includeName.at(0) == QChar('\"') && includeName.at(size-1) == QChar('\"'))
  {
    return new ConstantIncludeNode(includeName.mid(1, size-2));
  }
  return new IncludeNode(includeName);
}

IncludeNode::IncludeNode(const QString &name)
{
  m_filterExpression = FilterExpression(name);
}

QString IncludeNode::render(Context *c)
{
  QString filename = m_filterExpression.resolve(c).toString();

  TemplateLoader *loader = TemplateLoader::instance();

  Template t = loader->loadByName(filename);

  return t.render(c);
}

ConstantIncludeNode::ConstantIncludeNode(const QString &name)
{
  m_name = name;
}

QString ConstantIncludeNode::render(Context *c)
{
  TemplateLoader *loader = TemplateLoader::instance();

  Template t = loader->loadByName(m_name);

  return t.render(c);
}

/*
    Copyright (c) 2009 Stephen Kelly <steveire@gmail.com>
*/

#include "include.h"

#include <QStringList>
#include <QtPlugin>

#include "parser.h"
#include "template.h"

#include <QDebug>

IncludeNodeFactory::IncludeNodeFactory()
{

}

Node* IncludeNodeFactory::getNode(const QString &tagContent, Parser *p)
{
  QStringList expr = tagContent.split(" ", QString::SkipEmptyParts);

  QString includeName = expr.at(1);
  int size = includeName.size();

  if ((includeName.startsWith("\"") && includeName.endsWith("\""))
    || ( includeName.startsWith("'") && includeName.endsWith("'") ))
  {
    return new ConstantIncludeNode(includeName.mid(1, size-2));
  }
  return new IncludeNode(includeName);
}

IncludeNode::IncludeNode(const QString &name)
{
  m_filterExpression = FilterExpression(name);
}

QString IncludeNode::render(Context *c)
{
  QString filename = m_filterExpression.resolve(c).toString();

  TemplateLoader *loader = TemplateLoader::instance();

  Template t = loader->loadByName(filename);

  return t.render(c);
}

ConstantIncludeNode::ConstantIncludeNode(const QString &name)
{
  m_name = name;
}

QString ConstantIncludeNode::render(Context *c)
{
  TemplateLoader *loader = TemplateLoader::instance();

  Template t = loader->loadByName(m_name);

  return t.render(c);
}

Allow both single and double quotes in string literals.


//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <locale>

// class money_base
// {
// public:
//     enum part {none, space, symbol, sign, value};
//     struct pattern {char field[4];};
// };

#include <locale>
#include <cassert>

int main()
{
    std::money_base mb;
    assert(mb.none == 0);
    assert(mb.space == 1);
    assert(mb.symbol == 2);
    assert(mb.sign == 3);
    assert(mb.value == 4);
    assert(sizeof(std::money_base::pattern) == 4);
    std::money_base::pattern p;
    p.field[0] = std::money_base::none;
}

//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <locale>

// class money_base
// {
// public:
//     enum part {none, space, symbol, sign, value};
//     struct pattern {char field[4];};
// };

#include <locale>
#include <cassert>

int main()
{
    std::money_base mb; ((void)mb);
    static_assert(std::money_base::none == 0, "");
    static_assert(std::money_base::space == 1, "");
    static_assert(std::money_base::symbol == 2, "");
    static_assert(std::money_base::sign == 3, "");
    static_assert(std::money_base::value == 4, "");
    static_assert(sizeof(std::money_base::pattern) == 4, "");
    std::money_base::pattern p;
    p.field[0] = std::money_base::none;
}

Use static_assert instead of runtime assert in std::money_base tests.

git-svn-id: 756ef344af921d95d562d9e9f9389127a89a6314@273360 91177308-0d34-0410-b5e6-96231b3b80d8


// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

#include <svdpi.h>
#include <cassert>

#include "cosim.h"
#include "spike_cosim.h"

extern "C" {
void *spike_cosim_init(const char *isa_string, svBitVecVal *start_pc,
                       svBitVecVal *start_mtvec,
                       const char *log_file_path_cstr) {
  assert(isa_string);

  std::string log_file_path;

  if (log_file_path_cstr) {
    log_file_path = log_file_path_cstr;
  }

  SpikeCosim *cosim = new SpikeCosim(isa_string, start_pc[0], start_mtvec[0],
                                     log_file_path, false, true);
  cosim->add_memory(0x80000000, 0x80000000);
  return static_cast<Cosim *>(cosim);
}

void spike_cosim_release(void *cosim_handle) {
  auto cosim = static_cast<Cosim *>(cosim_handle);

  delete cosim;
}
}

// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

#include <svdpi.h>
#include <cassert>

#include "cosim.h"
#include "spike_cosim.h"

extern "C" {
void *spike_cosim_init(const char *isa_string, svBitVecVal *start_pc,
                       svBitVecVal *start_mtvec,
                       const char *log_file_path_cstr) {
  assert(isa_string);

  std::string log_file_path;

  if (log_file_path_cstr) {
    log_file_path = log_file_path_cstr;
  }

  SpikeCosim *cosim = new SpikeCosim(isa_string, start_pc[0], start_mtvec[0],
                                     log_file_path, false, true);
  cosim->add_memory(0x80000000, 0x80000000);
  cosim->add_memory(0x00000000, 0x80000000);
  return static_cast<Cosim *>(cosim);
}

void spike_cosim_release(void *cosim_handle) {
  auto cosim = static_cast<Cosim *>(cosim_handle);

  delete cosim;
}
}

Add memory region to match UVM env

[dv,cosim] Add memory region to match UVM env

This extends our memory range to be between 0 and
0xFFFF_FFFF. This is needed because in the case of
no match between UVM memory model and spike memory
model, we see a mismatch.

Signed-off-by: Canberk Topal <e6b05429a51cc3258c31cb1f7836595b60921a29@lowrisc.org>


// BAD: on memory allocation error, the program terminates.
void badFunction(const int *source, std::size_t length) noexcept {
  int * dest = new int[length];
  std::memset(dest, 0, length);
// ..
}
// GOOD: memory allocation error will be handled.
void goodFunction(const int *source, std::size_t length) noexcept {
  try {
       int * dest = new int[length];
  } catch(std::bad_alloc)
  std::memset(dest, 0, length);
// ..
}
// BAD: memory allocation error will not be handled.
void badFunction(const int *source, std::size_t length) noexcept {
  try {
       int * dest = new (std::nothrow) int[length];
  } catch(std::bad_alloc)
  std::memset(dest, 0, length);
// ..
}
// GOOD: memory allocation error will be handled.
void goodFunction(const int *source, std::size_t length) noexcept {
  int * dest = new (std::nothrow) int[length];
  if (!dest) {
      return;
  }
  std::memset(dest, 0, length);
// ..
}

// BAD: on memory allocation error, the program terminates.
void badFunction(const int *source, std::size_t length) noexcept {
  int * dest = new int[length];
  std::memset(dest, 0, length);
// ..
}
// GOOD: memory allocation error will be handled.
void goodFunction(const int *source, std::size_t length) noexcept {
  try {
       int * dest = new int[length];
  } catch(std::bad_alloc) {
    // ...
  }
  std::memset(dest, 0, length);
// ..
}
// BAD: memory allocation error will not be handled.
void badFunction(const int *source, std::size_t length) noexcept {
  try {
       int * dest = new (std::nothrow) int[length];
  } catch(std::bad_alloc) {
    // ...
  }
  std::memset(dest, 0, length);
// ..
}
// GOOD: memory allocation error will be handled.
void goodFunction(const int *source, std::size_t length) noexcept {
  int * dest = new (std::nothrow) int[length];
  if (!dest) {
      return;
  }
  std::memset(dest, 0, length);
// ..
}

Apply suggestions from code review

Apply suggestions from code review

Co-authored-by: Geoffrey White <854c1cae7601ac2fa382d10716eb72ad2a572b90@users.noreply.github.com>


// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s

template<class X> class B {
public:
  explicit B(X* p = 0);
};

class A
{
public:
  A(int value) : m_a_value(value) {};
  A(int value, A* client_A) : m_a_value (value), m_client_A (client_A) {}

  virtual ~A() {}

private:
  int m_a_value;
  B<A> m_client_A;
};

int main(int argc, char **argv) {
  A reallyA (500);
}

// CHECK: ![[CLASSTYPE:.*]] = {{.*}} ; [ DW_TAG_class_type ] [A]
// CHECK: ![[ARTARG:.*]] = {{.*}} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1A]
// CHECK: metadata ![[CLASSTYPE]], {{.*}} ; [ DW_TAG_subprogram ] [line 12] [A]
// CHECK: metadata [[FUNCTYPE:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
// CHECK: [[FUNCTYPE]] = metadata !{null, metadata ![[ARTARG]], metadata !{{.*}}, metadata !{{.*}}}

// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s

template<class X> class B {
public:
  explicit B(X* p = 0);
};

class A
{
public:
  A(int value) : m_a_value(value) {};
  A(int value, A* client_A) : m_a_value (value), m_client_A (client_A) {}

  virtual ~A() {}

private:
  int m_a_value;
  B<A> m_client_A;
};

int main(int argc, char **argv) {
  A reallyA (500);
}

// CHECK: ![[CLASSTYPE:.*]] = {{.*}}, metadata !"_ZTS1A"} ; [ DW_TAG_class_type ] [A]
// CHECK: ![[ARTARG:.*]] = {{.*}} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1A]
// CHECK: metadata !"_ZTS1A", {{.*}} ; [ DW_TAG_subprogram ] [line 12] [A]
// CHECK: metadata [[FUNCTYPE:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
// CHECK: [[FUNCTYPE]] = metadata !{null, metadata ![[ARTARG]], metadata !{{.*}}, metadata !{{.*}}}

Debug Info: update testing cases when the context field of subprogram is updated
to use DIScopeRef.

Paired commit with r192378.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@192379 91177308-0d34-0410-b5e6-96231b3b80d8


// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_apitest.h"

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Storage) {
  ASSERT_TRUE(RunExtensionTest("storage")) << message_;
}

// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_apitest.h"

// This test is disabled. See bug 25746
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_Storage) {
  ASSERT_TRUE(RunExtensionTest("storage")) << message_;
}

Disable ExtensionApiTest.Storage because it crashes the browser_tests too.

BUG:25746

Review URL: http://codereview.chromium.org/328024

git-svn-id: dd90618784b6a4b323ea0c23a071cb1c9e6f2ac7@30021 4ff67af0-8c30-449e-8e8b-ad334ec8d88c


/******************************************************
 * This is CIR-KIT 3rd robot control driver.
 * Author : Arita Yuta(Kyutech)
 ******************************************************/
#include "cirkit_unit03_driver.hpp"

int main(int argc, char** argv)
{
  ros::init(argc, argv, "Third_robot_driver_node");
  ROS_INFO("Third robot driver for ROS.");

  ros::NodeHandle nh;

  cirkit::ThirdRobotDriver driver(nh);
  driver.run();

  return 0;
}

/******************************************************
 * This is CIR-KIT 3rd robot control driver.
 * Author : Arita Yuta(Kyutech)
 ******************************************************/
#include "cirkit_unit03_driver.hpp"

int main(int argc, char** argv)
{
  ros::init(argc, argv, "cirkit_unit03_driver_node");
  ROS_INFO("cirkit unit03 robot driver for ROS.");

  ros::NodeHandle nh;

  cirkit::ThirdRobotDriver driver(nh);
  driver.run();

  return 0;
}

Update node name to cirkit_unit03

Update node name to cirkit_unit03