// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -DTRY   | FileCheck %s -check-prefix=TRY
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -DTHROW | FileCheck %s -check-prefix=THROW

void external();

inline void not_emitted() {
  throw int(13); // no error
}

int main() {
  int rv = 0;
#ifdef TRY
  try {
    external(); // TRY: invoke void @"\01?external@@YAXXZ"
  } catch (int) {
    rv = 1;
    // TRY: call i8* @llvm.eh.begincatch
    // TRY: call void @llvm.eh.endcatch
  }
#endif
#ifdef THROW
  // THROW: call void @"\01?terminate@@YAXXZ"
  throw int(42);
#endif
  return rv;
}

// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -DTRY   | FileCheck %s -check-prefix=TRY
// FIXME: Disabled until catch IRgen change lands.
// RUNX: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -DTHROW | FileCheck %s -check-prefix=THROW

void external();

inline void not_emitted() {
  throw int(13); // no error
}

int main() {
  int rv = 0;
#ifdef TRY
  try {
    external(); // TRY: invoke void @"\01?external@@YAXXZ"
  } catch (int) {
    rv = 1;
    // TRY: call i8* @llvm.eh.begincatch
    // TRY: call void @llvm.eh.endcatch
  }
#endif
#ifdef THROW
  // THROW: call void @"\01?terminate@@YAXXZ"
  throw int(42);
#endif
  return rv;
}

Disable a Clang test until the begincatch change lands

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


#include <fastarduino/soft_uart.h>

constexpr const board::InterruptPin RX = board::InterruptPin::D0_PD0_PCI2;
#define PCI_NUM 2

REGISTER_UART_PCI_ISR(RX, PCI_NUM)

// Buffers for UARX
static const uint8_t INPUT_BUFFER_SIZE = 64;
static char input_buffer[INPUT_BUFFER_SIZE];

int main()
{
    board::init();
    sei();

    // Start UART
	typename interrupt::PCIType<RX>::TYPE pci;
	serial::soft::UARX_PCI<RX> uarx{input_buffer, pci};
	pci.enable();
	uarx.begin(115200);

    streams::istream in = uarx.in();

    // Wait for a char
    char value1;
    in >> streams::skipws >> value1;

    // Wait for an uint16_t
    uint16_t value2;
    in >> streams::skipws >> value2;

    return 0;
}

#include <fastarduino/soft_uart.h>

constexpr const board::InterruptPin RX = board::InterruptPin::D0_PD0_PCI2;
#define PCI_NUM 2

REGISTER_UARX_PCI_ISR(RX, PCI_NUM)

// Buffers for UARX
static const uint8_t INPUT_BUFFER_SIZE = 64;
static char input_buffer[INPUT_BUFFER_SIZE];

int main()
{
    board::init();
    sei();

    // Start UART
	typename interrupt::PCIType<RX>::TYPE pci;
	serial::soft::UARX_PCI<RX> uarx{input_buffer, pci};
	pci.enable();
	uarx.begin(115200);

    streams::istream in = uarx.in();

    // Wait for a char
    char value1;
    in >> streams::skipws >> value1;

    // Wait for an uint16_t
    uint16_t value2;
    in >> streams::skipws >> value2;

    return 0;
}

Fix tutorial SW UART example

Fix tutorial SW UART example


// RUN: %clang_cc1 %s -fsyntax-only -verify -Wmissing-noreturn -Wno-unreachable-code

// A destructor may be marked noreturn and should still influence the CFG.
namespace PR6884 {
  struct abort_struct {
    abort_struct() {} // Make this non-POD so the destructor is invoked.
    ~abort_struct() __attribute__((noreturn));
  };

  int f() {
    abort_struct();
  }

  int f2() {
    abort_struct s;
  } // expected-warning{{control reaches end of non-void function}}
}

// RUN: %clang_cc1 %s -fsyntax-only -verify -Wmissing-noreturn -Wno-unreachable-code

// A destructor may be marked noreturn and should still influence the CFG.
namespace PR6884 {
  struct abort_struct {
    abort_struct() {} // Make this non-POD so the destructor is invoked.
    ~abort_struct() __attribute__((noreturn));
  };

  // FIXME: Should either of these actually warn, since the destructor is
  //  marked noreturn?

  int f() {
    abort_struct();
  } // expected-warning{{control reaches end of non-void function}}

  int f2() {
    abort_struct s;
  } // expected-warning{{control reaches end of non-void function}}
}

Update test case, with comment to later investigate the correct behavior.  Now the behavior is at least consistent.

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


#include <log4cpp/Category.hh>
#include <log4cpp/Appender.hh>
#include <log4cpp/OstreamAppender.hh>
#include <log4cpp/Layout.hh>
#include <log4cpp/PatternLayout.hh>
#include <log4cpp/Priority.hh>

#include "LoggerFactory.h"

using namespace Log;

bool LoggerFactory::isCreated = false;
log4cpp::Category *LoggerFactory::instance;

LoggerFactory::LoggerFactory() {}

/* Factory for a simple log4cpp logger. */
log4cpp::Category* LoggerFactory::create() {
    log4cpp::Category *logger = &log4cpp::Category::getRoot();
    log4cpp::Appender *p_appender = new log4cpp::OstreamAppender("console", &std::cout);
    log4cpp::PatternLayout *layout = new log4cpp::PatternLayout();
    layout->setConversionPattern("%d{%Y-%m-%d %H:%M:%S} [%p] %c: %m%n");
    p_appender->setLayout(layout);

    logger->setPriority(log4cpp::Priority::DEBUG);
    logger->addAppender(p_appender);
    return logger;
}

/* Returns a singleton root logger. */
log4cpp::Category *LoggerFactory::getLogger() {
    if (!isCreated) {
        isCreated = true;
        instance = create();
    }
    return instance;
}

#include <log4cpp/Category.hh>
#include <log4cpp/Appender.hh>
#include <log4cpp/OstreamAppender.hh>
#include <log4cpp/Layout.hh>
#include <log4cpp/PatternLayout.hh>
#include <log4cpp/Priority.hh>

#include "LoggerFactory.h"

using namespace Log;

bool LoggerFactory::isCreated = false;
log4cpp::Category *LoggerFactory::instance;

LoggerFactory::LoggerFactory() {}

/* Factory for a simple log4cpp logger. */
log4cpp::Category* LoggerFactory::create() {
    log4cpp::Category *logger = &log4cpp::Category::getRoot();
    log4cpp::Appender *p_appender = new log4cpp::OstreamAppender("console", &std::cout);
    log4cpp::PatternLayout *layout = new log4cpp::PatternLayout();
    layout->setConversionPattern("%d{%Y-%m-%d %H:%M:%S} [%p] %c: %m%n");
    p_appender->setLayout(layout);

    logger->setPriority(log4cpp::Priority::INFO);
    logger->addAppender(p_appender);
    return logger;
}

/* Returns a singleton root logger. */
log4cpp::Category *LoggerFactory::getLogger() {
    if (!isCreated) {
        isCreated = true;
        instance = create();
    }
    return instance;
}

Change logging level to INFO (DEBUG is slowing down the execution too much).


// This code is in the public domain -- castano@gmail.com

#include "FileSystem.h"
#include <nvcore/nvcore.h>

#if NV_OS_WIN32
#include <direct.h>
#else
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#endif

using namespace nv;

bool FileSystem::exists(const char * path)
{
#if NV_OS_UNIX
	struct stat buf;
	return stat(path, &buf) == 0;
#else
	if (FILE * fp = fopen(path, "r"))
	{
		fclose(fp);
		return true;
	}
	return false;
#endif
}

bool FileSystem::createDirectory(const char * path)
{
#if NV_OS_WIN32
    return _mkdir(path) != -1;
#else
    return mkdir(path, 0777) != -1;
#endif
}

// This code is in the public domain -- castano@gmail.com

#include "FileSystem.h"
#include <nvcore/nvcore.h>

#if NV_OS_WIN32
#include <direct.h>
#else
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#endif

using namespace nv;

bool FileSystem::exists(const char * path)
{
#if NV_OS_UNIX
	return access(path, F_OK|R_OK) == 0;
	//struct stat buf;
	//return stat(path, &buf) == 0;
#else
	if (FILE * fp = fopen(path, "r"))
	{
		fclose(fp);
		return true;
	}
	return false;
#endif
}

bool FileSystem::createDirectory(const char * path)
{
#if NV_OS_WIN32
    return _mkdir(path) != -1;
#else
    return mkdir(path, 0777) != -1;
#endif
}

Implement exists with access instead of stat.

git-svn-id: bd2008fbba0f7d30fd6598b54f2cd88503fdd2e4@802 95f4ed2b-212e-0410-8b90-d31948207fce


// Copyright (c) 2013, Facebook, Inc.  All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.

#include <atomic>

#include "rocksdb/env.h"
#include "util/thread_status_updater.h"
#include "util/thread_status_util.h"

namespace rocksdb {

#ifndef NDEBUG
// the delay for debugging purpose.
static std::atomic<int> states_delay[ThreadStatus::NUM_STATE_TYPES];

void ThreadStatusUtil::TEST_SetStateDelay(
    const ThreadStatus::StateType state, int micro) {
  states_delay[state].store(micro, std::memory_order_relaxed);
}

void ThreadStatusUtil::TEST_StateDelay(
    const ThreadStatus::StateType state) {
  Env::Default()->SleepForMicroseconds(
      states_delay[state].load(std::memory_order_relaxed));
}

#endif  // !NDEBUG

}  // namespace rocksdb

// Copyright (c) 2013, Facebook, Inc.  All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.

#include <atomic>

#include "rocksdb/env.h"
#include "util/thread_status_updater.h"
#include "util/thread_status_util.h"

namespace rocksdb {

#ifndef NDEBUG
// the delay for debugging purpose.
static std::atomic<int> states_delay[ThreadStatus::NUM_STATE_TYPES];

void ThreadStatusUtil::TEST_SetStateDelay(
    const ThreadStatus::StateType state, int micro) {
  states_delay[state].store(micro, std::memory_order_relaxed);
}

void ThreadStatusUtil::TEST_StateDelay(const ThreadStatus::StateType state) {
  auto delay = states_delay[state].load(std::memory_order_relaxed);
  if (delay > 0) {
    Env::Default()->SleepForMicroseconds(delay);
  }
}

#endif  // !NDEBUG

}  // namespace rocksdb

Fix bad performance in debug mode

Fix bad performance in debug mode

Summary:
See github issue 574: https://github.com/facebook/rocksdb/issues/574

Basically when we're running in DEBUG mode we're calling `usleep(0)` on
every mutex lock. I bisected the issue to
https://reviews.facebook.net/D36963. Instead of calling sleep(0), this
diff just avoids calling SleepForMicroseconds() when delay is not set.

Test Plan:
    bpl=10485760;overlap=10;mcz=2;del=300000000;levels=2;ctrig=10000000; delay=10000000; stop=10000000; wbn=30; mbc=20; mb=1073741824;wbs=268435456; dds=1; sync=0; r=100000; t=1; vs=800; bs=65536; cs=1048576; of=500000; si=1000000; ./db_bench --benchmarks=fillrandom --disable_seek_compaction=1 --mmap_read=0 --statistics=1 --histogram=1 --num=$r --threads=$t --value_size=$vs --block_size=$bs --cache_size=$cs --bloom_bits=10 --cache_numshardbits=4 --open_files=$of --verify_checksum=1 --db=/tmp/rdb10test --sync=$sync --disable_wal=1 --compression_type=snappy --stats_interval=$si --compression_ratio=0.5 --disable_data_sync=$dds --write_buffer_size=$wbs --target_file_size_base=$mb --max_write_buffer_number=$wbn --max_background_compactions=$mbc --level0_file_num_compaction_trigger=$ctrig --level0_slowdown_writes_trigger=$delay --level0_stop_writes_trigger=$stop --num_levels=$levels --delete_obsolete_files_period_micros=$del --min_level_to_compress=$mcz --max_grandparent_overlap_factor=$overlap --stats_per_interval=1 --max_bytes_for_level_base=$bpl --memtablerep=vector --use_existing_db=0 --disable_auto_compactions=1 --source_compaction_factor=10000000 | grep ops

Before:
fillrandom   :     117.525 micros/op 8508 ops/sec;    6.6 MB/s
After:
fillrandom   :       1.283 micros/op 779502 ops/sec;  606.6 MB/s

Reviewers: rven, yhchiang, sdong

Reviewed By: sdong

Subscribers: meyering, dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D36963


/* 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_kernel.h"
#include "tensorflow/compiler/tf2xla/xla_op_registry.h"
#include "tensorflow/compiler/xla/client/xla_builder.h"

namespace tensorflow {
namespace {

class XlaReplicaIdOp : public XlaOpKernel {
 public:
  explicit XlaReplicaIdOp(OpKernelConstruction* ctx) : XlaOpKernel(ctx) {}
  void Compile(XlaOpKernelContext* ctx) override;

 private:
  TF_DISALLOW_COPY_AND_ASSIGN(XlaReplicaIdOp);
};

void XlaReplicaIdOp::Compile(XlaOpKernelContext* ctx) {
  ctx->SetOutput(
      0, xla::ConvertElementType(xla::ReplicaId(ctx->builder()), xla::S32));
}

REGISTER_XLA_OP(Name("XlaReplicaId"), XlaReplicaIdOp);

}  // namespace
}  // 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/mlir_xla_op_kernel.h"
#include "tensorflow/compiler/tf2xla/xla_op_kernel.h"
#include "tensorflow/compiler/tf2xla/xla_op_registry.h"
#include "tensorflow/compiler/xla/client/xla_builder.h"

namespace tensorflow {
namespace {

REGISTER_XLA_OP(Name("XlaReplicaId"), MlirXlaOpKernel);

}  // namespace
}  // namespace tensorflow

Remove the fallback to the old bridge for tf.XlaReplicaId

PiperOrigin-RevId: 409854723
Change-Id: I6d099e1874c56f24ada98b81036e14647af50c76


//===----------------------------------------------------------------------===//
//
//                     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.
//
//===----------------------------------------------------------------------===//

// <vector>

// void assign(size_type n, const_reference v);

#include <vector>
#include <algorithm>
#include <cassert>
#include <iostream>

#include "min_allocator.h"
#include "asan_testing.h"

bool is6(int x) { return x == 6; }

template <typename Vec>
void test ( Vec &v )
{
    std::cout << "Size, cap: " << v.size() << " " << v.capacity() << std::endl;
    v.assign(5, 6);
    std::cout << "Size, cap: " << v.size() << " " << v.capacity() << std::endl;
    assert(v.size() == 5);
    assert(is_contiguous_container_asan_correct(v));
    assert(std::all_of(v.begin(), v.end(), is6));
}

int main()
{
    {
    typedef std::vector<int> V;
    V d1;
    V d2;
    d2.reserve(10);  // no reallocation during assign.
    test(d1);
    test(d2);
    }

#if __cplusplus >= 201103L
    {
    typedef std::vector<int, min_allocator<int>> V;
    V d1;
    V d2;
    d2.reserve(10);  // no reallocation during assign.
    test(d1);
    test(d2);
    }
#endif
}

//===----------------------------------------------------------------------===//
//
//                     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.
//
//===----------------------------------------------------------------------===//

// <vector>

// void assign(size_type n, const_reference v);

#include <vector>
#include <algorithm>
#include <cassert>
#include <iostream>

#include "min_allocator.h"
#include "asan_testing.h"

bool is6(int x) { return x == 6; }

template <typename Vec>
void test ( Vec &v )
{
    v.assign(5, 6);
    assert(v.size() == 5);
    assert(is_contiguous_container_asan_correct(v));
    assert(std::all_of(v.begin(), v.end(), is6));
}

int main()
{
    {
    typedef std::vector<int> V;
    V d1;
    V d2;
    d2.reserve(10);  // no reallocation during assign.
    test(d1);
    test(d2);
    }

#if __cplusplus >= 201103L
    {
    typedef std::vector<int, min_allocator<int>> V;
    V d1;
    V d2;
    d2.reserve(10);  // no reallocation during assign.
    test(d1);
    test(d2);
    }
#endif
}

Remove some debugging printout lines. No functionality change.

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


// Copyright 2016 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 <stddef.h>
#include <stdint.h>
#ifndef OTS_FUZZER_NO_MAIN
#include <fstream>
#include <iostream>
#include <iterator>
#endif

#include "opentype-sanitiser.h"
#include "ots-memory-stream.h"

// Entry point for LibFuzzer.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  ots::OTSContext context;
  ots::MemoryStream stream((void*)data, size);
  context.Process(&stream, data, size);
  return 0;
}

#ifndef OTS_FUZZER_NO_MAIN
int main(int argc, char **argv) {
  for (int i = 1; i < argc; i++) {
    std::cout << argv[i] << std::endl;

    std::ifstream f(argv[i]);
    if (!f.good())
      return 1;

    std::string s((std::istreambuf_iterator<char>(f)),
                  (std::istreambuf_iterator<char>()));
    LLVMFuzzerTestOneInput((const uint8_t*)s.data(), s.size());
  }
  return 0;
}
#endif

// Copyright 2016 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 <stddef.h>
#include <stdint.h>
#ifndef OTS_FUZZER_NO_MAIN
#include <fstream>
#include <iostream>
#include <iterator>
#endif

#include "opentype-sanitiser.h"
#include "ots-memory-stream.h"

static uint8_t buffer[256 * 1024] = { 0 };

// Entry point for LibFuzzer.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  ots::OTSContext context;
  ots::MemoryStream stream(static_cast<void*>(buffer), sizeof(buffer));
  context.Process(&stream, data, size);
  return 0;
}

#ifndef OTS_FUZZER_NO_MAIN
int main(int argc, char **argv) {
  for (int i = 1; i < argc; i++) {
    std::cout << argv[i] << std::endl;

    std::ifstream f(argv[i]);
    if (!f.good())
      return 1;

    std::string s((std::istreambuf_iterator<char>(f)),
                  (std::istreambuf_iterator<char>()));
    LLVMFuzzerTestOneInput((const uint8_t*)s.data(), s.size());
  }
  return 0;
}
#endif

Fix thinko In inroduced while importing the fuzzer


#include "halley/maths/circle.h"
using namespace Halley;

bool Circle::contains(Vector2f point) const
{
	return (point - centre).squaredLength() <= radius * radius;
}

bool Circle::overlaps(const Circle& circle) const
{
	const float r = radius + circle.radius;
	return (circle.centre - centre).squaredLength() <= r * r;
}

Circle Circle::getSpanningCircle(const std::vector<Vector2f>& points)
{
	// TODO: should use Matousek, Sharir, Welzl's algorithm (https://en.wikipedia.org/wiki/Smallest-circle_problem#Matou%C5%A1ek,_Sharir,_Welzl's_algorithm)

	Vector2f centre;
	for (auto& p: points) {
		centre += p;
	}
	centre /= float(points.size());

	float radius2 = 0;
	for (auto& p: points) {
		const auto d = (p - centre).squaredLength();
		if (d > radius2) {
			radius2 = d;
		}
	}

	return Circle(centre, std::sqrtf(radius2));
}

#include "halley/maths/circle.h"
using namespace Halley;

bool Circle::contains(Vector2f point) const
{
	return (point - centre).squaredLength() <= radius * radius;
}

bool Circle::overlaps(const Circle& circle) const
{
	const float r = radius + circle.radius;
	return (circle.centre - centre).squaredLength() <= r * r;
}

Circle Circle::getSpanningCircle(const std::vector<Vector2f>& points)
{
	// TODO: should use Matousek, Sharir, Welzl's algorithm (https://en.wikipedia.org/wiki/Smallest-circle_problem#Matou%C5%A1ek,_Sharir,_Welzl's_algorithm)

	Vector2f centre;
	for (auto& p: points) {
		centre += p;
	}
	centre /= float(points.size());

	float radius2 = 0;
	for (auto& p: points) {
		const auto d = (p - centre).squaredLength();
		if (d > radius2) {
			radius2 = d;
		}
	}

	return Circle(centre, std::sqrt(radius2));
}

Rename std::sqrtf -> std::sqrt because gcc is not standards compliant on that for whatever reason.


//===----------------------------------------------------------------------===//
//
//                     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.
//
//===----------------------------------------------------------------------===//
//

// UNSUPPORTED: c++98, c++03

//  Tuples of smart pointers; based on bug #18350
//  auto_ptr doesn't have a copy constructor that takes a const &, but tuple does.

#include <tuple>
#include <memory>

int main () {
    {
    std::tuple<std::unique_ptr<char>> up;
    std::tuple<std::shared_ptr<char>> sp;
    std::tuple<std::weak_ptr  <char>> wp;
//     std::tuple<std::auto_ptr  <char>> ap;
    }
    {
    std::tuple<std::unique_ptr<char[]>> up;
    std::tuple<std::shared_ptr<char[]>> sp;
    std::tuple<std::weak_ptr  <char[]>> wp;
//     std::tuple<std::auto_ptr  <char[]>> ap;
    }
    {
    std::tuple<std::unique_ptr<char[5]>> up;
    std::tuple<std::shared_ptr<char[5]>> sp;
    std::tuple<std::weak_ptr  <char[5]>> wp;
//     std::tuple<std::auto_ptr  <char[5]>> ap;
    }
}

//===----------------------------------------------------------------------===//
//
//                     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.
//
//===----------------------------------------------------------------------===//
//

// UNSUPPORTED: c++98, c++03

//  Tuples of smart pointers; based on bug #18350
//  auto_ptr doesn't have a copy constructor that takes a const &, but tuple does.

#include <tuple>
#include <memory>

int main () {
    {
    std::tuple<std::unique_ptr<char>> up;
    std::tuple<std::shared_ptr<char>> sp;
    std::tuple<std::weak_ptr  <char>> wp;
    }
    {
    std::tuple<std::unique_ptr<char[]>> up;
    std::tuple<std::shared_ptr<char[]>> sp;
    std::tuple<std::weak_ptr  <char[]>> wp;
    }
    // Smart pointers of type 'T[N]' are not tested here since they are not
    // supported by the standard nor by libc++'s implementation.
    // See http://reviews.llvm.org/D21320 for move information.
}

Fix warning in tuple tests. The test suite should now run clean with most warnings enabled

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


#include "catch.hpp"

//#define KASSERT REQUIRE

#include <Segment.hh>

#include <cstring>

#define SEGMENTSIZE 4096

SCENARIO("Memory segment representation", "[kernelheap]")
{
   GIVEN("A memory segment")
   {
      char* memorySegment = new char[SEGMENTSIZE];
      memset(memorySegment, 0x55, SEGMENTSIZE);

      WHEN("Constructing a segment header for the segment")
      {
         Segment* segment = new(memorySegment) Segment();

         THEN("The size is zero")
         {
            CHECK(segment->getSize() == 0);
         }

         THEN("The segment is marked as unallocated")
         {
            CHECK(segment->isAllocated() == false);
         }

         AND_WHEN("Updating the checksum")
         {
            segment->updateChecksum();

            THEN("The checksum is valid")
            {
               CHECK(segment->verifyChecksum() == true);
            }

            AND_WHEN("The segment is mutated")
            {
               segment->setSize(1110);

               THEN("The checksum is no longer valid")
               {
                  CHECK(segment->verifyChecksum() == false);
               }
            }
         }
      }
   }
}

#include "catch.hpp"

//#define KASSERT REQUIRE

#include <Segment.hh>

#include <cstring>

#define SEGMENTSIZE 4096

SCENARIO("Memory segment representation", "[kernelheap]")
{
   GIVEN("A memory segment")
   {
      char* memorySegment = new char[SEGMENTSIZE];
      memset(memorySegment, 0x55, SEGMENTSIZE);

      WHEN("Constructing a segment header for the segment")
      {
         Segment* segment = new(memorySegment) Segment();

         THEN("The size is zero")
         {
            CHECK(segment->getSize() == 0);
         }

         THEN("The segment is marked as unallocated")
         {
            CHECK(segment->isAllocated() == false);
         }

         THEN("The segment checksum is valid")
         {
            CHECK(segment->verifyChecksum() == true);
         }

         AND_WHEN("Updating the checksum")
         {
            segment->updateChecksum();

            THEN("The checksum is valid")
            {
               CHECK(segment->verifyChecksum() == true);
            }

            AND_WHEN("The segment is mutated")
            {
               segment->setSize(1110);

               THEN("The checksum is no longer valid")
               {
                  CHECK(segment->verifyChecksum() == false);
               }
            }
         }
      }
   }
}

Check that newly created has correct checksum


// 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 "printing/backend/print_backend.h"

namespace printing {

PrinterBasicInfo::PrinterBasicInfo() : printer_status(0) {}

PrinterBasicInfo::~PrinterBasicInfo() {}

PrinterCapsAndDefaults::PrinterCapsAndDefaults() {}

PrinterCapsAndDefaults::~PrinterCapsAndDefaults() {}

PrintBackend::~PrintBackend() {}

}  // namespace printing

// 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 "printing/backend/print_backend.h"

namespace printing {

PrinterBasicInfo::PrinterBasicInfo()
    : printer_status(0),
      is_default(false) {}

PrinterBasicInfo::~PrinterBasicInfo() {}

PrinterCapsAndDefaults::PrinterCapsAndDefaults() {}

PrinterCapsAndDefaults::~PrinterCapsAndDefaults() {}

PrintBackend::~PrintBackend() {}

}  // namespace printing

Coverity: Initialize a variable in PrinterBasicInfo.

BUG=none
TEST=none
CID=16140

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

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


#include "ewk_settings_private.h"

#include "net/http/http_stream_factory.h"

void Ewk_Settings::setSpdyEnabled(bool flag)
{
  net::HttpStreamFactory::set_spdy_enabled(flag);
}

void Ewk_Settings::setCurrentLegacyFontSizeMode(tizen_webview::Legacy_Font_Size_Mode mode) {
    m_currentLegacyFontSizeMode = mode;
    m_preferences.current_legacy_font_size_mode = static_cast<content::LegacyFontSizeMode>(mode);
}

#include "ewk_settings_private.h"

#include "net/http/http_stream_factory.h"

void Ewk_Settings::setSpdyEnabled(bool flag)
{
  net::HttpStreamFactory::set_spdy_enabled(flag);
}

void Ewk_Settings::setCurrentLegacyFontSizeMode(tizen_webview::Legacy_Font_Size_Mode mode) {
    m_currentLegacyFontSizeMode = mode;
#if !defined(EWK_BRINGUP)
    m_preferences.current_legacy_font_size_mode = static_cast<content::LegacyFontSizeMode>(mode);
#endif
}

Disable call to WebPreferences::current_legacy_font_size_mode. Missing API.

Signed-off-by: Antonio Gomes <a1.gomes@sisa.samsung.com>

Conflicts:
	impl/API/ewk_settings_private.cc


// 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/webui/print_preview_ui.h"

#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/print_preview_handler.h"
#include "chrome/browser/ui/webui/print_preview_ui_html_source.h"
#include "content/browser/browser_thread.h"
#include "content/browser/tab_contents/tab_contents.h"

PrintPreviewUI::PrintPreviewUI(TabContents* contents)
    : WebUI(contents),
      html_source_(new PrintPreviewUIHTMLSource()) {
  // PrintPreviewUI owns |handler|.
  PrintPreviewHandler* handler = new PrintPreviewHandler();
  AddMessageHandler(handler->Attach(this));

  // Set up the chrome://print/ source.
  contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source_);
}

PrintPreviewUI::~PrintPreviewUI() {
}

PrintPreviewUIHTMLSource* PrintPreviewUI::html_source() {
  return html_source_.get();
}

void PrintPreviewUI::PreviewDataIsAvailable(int expected_pages_count) {
  FundamentalValue pages_count(expected_pages_count);
  CallJavascriptFunction("createPDFPlugin", pages_count);
}

// 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/webui/print_preview_ui.h"

#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/print_preview_handler.h"
#include "chrome/browser/ui/webui/print_preview_ui_html_source.h"
#include "content/browser/browser_thread.h"
#include "content/browser/tab_contents/tab_contents.h"

PrintPreviewUI::PrintPreviewUI(TabContents* contents)
    : WebUI(contents),
      html_source_(new PrintPreviewUIHTMLSource()) {
  // PrintPreviewUI owns |handler|.
  PrintPreviewHandler* handler = new PrintPreviewHandler();
  AddMessageHandler(handler->Attach(this));

  // Set up the chrome://print/ source.
  contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source_);
}

PrintPreviewUI::~PrintPreviewUI() {
}

PrintPreviewUIHTMLSource* PrintPreviewUI::html_source() {
  return html_source_.get();
}

void PrintPreviewUI::PreviewDataIsAvailable(int expected_pages_count) {
  FundamentalValue pages_count(expected_pages_count);
  CallJavascriptFunction("updatePrintPreview", pages_count);
}

Print Preview: Fix typo from r78639.

Print Preview: Fix typo from r78639.

BUG=76707
TEST=page count initialized correctly in print preview.
R=arv@chromium.org
Review URL: http://codereview.chromium.org/6688041

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


#include <nstd/Debug.h>
#include <nstd/Variant.h>

void_t testVariant()
{
  // test default constructor
  {
    Variant var;
    ASSERT(var.isNull());
    ASSERT(var.toBool() == false);
  }

  // test boolean constructor
  {
    Variant var(true);
    ASSERT(var.toBool() == true);
  }

  // test map constructor
  {
    HashMap<String, Variant> map;
    map.append("dasd", Variant(String("yes")));
    Variant var(map);
    ASSERT(((const Variant&)var).toMap().find("dasd")->toString() == "yes");
    ASSERT(var.toMap().find("dasd")->toString() == "yes");
  }

}

#include <nstd/Debug.h>
#include <nstd/Variant.h>

void_t testVariant()
{
  // test default constructor
  {
    Variant var;
    ASSERT(var.isNull());
    ASSERT(var.toBool() == false);
  }

  // test boolean constructor
  {
    Variant var(true);
    ASSERT(var.toBool() == true);
  }

  // test map constructor
  {
    HashMap<String, Variant> map;
    map.append(_T("dasd"), Variant(String(_T("yes"))));
    Variant var(map);
    ASSERT(((const Variant&)var).toMap().find(_T("dasd"))->toString() == _T("yes"));
    ASSERT(var.toMap().find(_T("dasd"))->toString() == _T("yes"));
  }

}

Use Unicode compatible in Variant test

Variant: Use Unicode compatible in Variant test


#include "square.h"
#include <gtest/gtest.h>

TEST(TestSuite, squareTwo)
{
  const double ret = square(2);
  ASSERT_EQ(4, ret);
}

TEST(TestSuite, squareFour)
{
  const double ret = square(4.1);
  ASSERT_EQ(16.81, ret);
}

// Run all the tests that were declared with TEST()
int main(int argc, char **argv){
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

#include "square.h"
#include <gtest/gtest.h>

TEST(TestSuite, squareTwo)
{
  const double ret = square(2);
  ASSERT_EQ(5, ret);
}

TEST(TestSuite, squareFour)
{
  const double ret = square(4.1);
  ASSERT_EQ(16.81, ret);
}

// Run all the tests that were declared with TEST()
int main(int argc, char **argv){
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

Make sure failed tests actually fail.

Make sure failed tests actually fail.


#include "HaxeRuntime.h"
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include "PrintfCaptureTypes.h"
#include "CoreMinimal.h"
#include "uhx/expose/HxcppRuntime.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>

#if PLATFORM_WINDOWS && !defined(vsnprintf)
	#define vsnprintf _vsnprintf
#endif

#define PRINTF_BUFFER_SIZE 2048

static FString& getPrintfString() {
	static FString str;
	return str;
}

void uhx_printf(const char * const format, ...) {
	va_list args;
	int len = 0;
	char buffer[PRINTF_BUFFER_SIZE];

	va_start( args, format );
	len = vsnprintf(buffer, PRINTF_BUFFER_SIZE, format, args);

	if (len < 0) {
		strcpy(buffer, "(internal printf capture format error)\n");
	} else {
		buffer[len] = '\0';
	}

	getPrintfString() += UTF8_TO_TCHAR(buffer);

	va_end(args);
}

unreal::UIntPtr PrintfHelper_obj::getAndFlush() {
	FString ret = getPrintfString();
	getPrintfString() = TEXT("");
	return uhx::expose::HxcppRuntime::constCharToString(TCHAR_TO_UTF8(*ret));
}

#include "HaxeRuntime.h"
#include "uhx/NoDeprecateHeader.h"

#include "PrintfCaptureTypes.h"
#include "CoreMinimal.h"
#include "uhx/expose/HxcppRuntime.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>

#if PLATFORM_WINDOWS && !defined(vsnprintf)
	#define vsnprintf _vsnprintf
#endif

#define PRINTF_BUFFER_SIZE 2048

static FString& getPrintfString() {
	static FString str;
	return str;
}

void uhx_printf(const char * const format, ...) {
	va_list args;
	int len = 0;
	char buffer[PRINTF_BUFFER_SIZE];

	va_start( args, format );
	len = vsnprintf(buffer, PRINTF_BUFFER_SIZE, format, args);

	if (len < 0) {
		strcpy(buffer, "(internal printf capture format error)\n");
	} else {
		buffer[len] = '\0';
	}

	getPrintfString() += UTF8_TO_TCHAR(buffer);

	va_end(args);
}

unreal::UIntPtr PrintfHelper_obj::getAndFlush() {
	FString ret = getPrintfString();
	getPrintfString() = TEXT("");
	return uhx::expose::HxcppRuntime::constCharToString(TCHAR_TO_UTF8(*ret));
}

#include "uhx/NoDeprecateFooter.h"

[CL-16676] Update to latest perforce change
Change 16676 by waneck@wnk-razer on 2018/03/08 15:01:22

[unreal.hx] Get rid of the CRT SECURE deprecation warnings on PrintfCapture


#include "Person.h"
#include <gtest/gtest.h>

TEST(GreeterTests, PersonGetNameTest) {
  Person p{"Woz"};
  ASSERT_STREQ(p.getName().c_str(), "Woz");
}

#include "Person.h"
#include <stdexcept>
#include <gtest/gtest.h>

TEST(GreeterTests, PersonValidCtorTest) {
	ASSERT_NO_THROW({
		Person p{"Alexa"};
	});
}

TEST(GreeterTests, PersonInvalidCtorTest) {
	ASSERT_THROW({
		Person p{""};
	}, std::invalid_argument);
}

TEST(GreeterTests, PersonGetNameTest) {
  Person p{"Woz"};
  ASSERT_STREQ(p.getName().c_str(), "Woz");
}

Add UT for invalid param in ctor

Add UT for invalid param in ctor


/*
Copyright (C) 2010 by Frank Richter

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

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
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "../memutil.h"

namespace CS {
  namespace Platform {
    namespace Implementation {

      size_t GetMaxVirtualSize()
      {
	// Guess available virtual address space ...
      #if CS_PROCESSOR_SIZE == 32
	// 32-bit: 2GiB virtual address space
	return 2 * 1024 * 1024;
      #else
	// 64-bit: 8TiB virtual address space
	return 8 * 1024 * 1024 * 1024;
      #endif
      }

    } // End namespace Implementation
  } // End namespace Platform
} // End namespace CS

/*
Copyright (C) 2010 by Frank Richter

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

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
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "../memutil.h"

namespace CS {
  namespace Platform {
    namespace Implementation {

      size_t GetMaxVirtualSize()
      {
	// Guess available virtual address space ...
      #if CS_PROCESSOR_SIZE == 32
	// 32-bit: 2GiB virtual address space
	return 2 * 1024 * 1024;
      #else
	// 64-bit: 8TiB virtual address space
	return 8 * size_t (1024 * 1024 * 1024);
      #endif
      }

    } // End namespace Implementation
  } // End namespace Platform
} // End namespace CS

Fix integer overflow reported by gcc

Fix integer overflow reported by gcc

git-svn-id: 28d9401aa571d5108e51b194aae6f24ca5964c06@34079 8cc4aa7f-3514-0410-904f-f2cc9021211c


#include "Logger.h"
#include <string>

void Logger::Start() {
#ifdef ENABLE_3RVX_LOGTOFILE
    /* Disable buffering */
    setvbuf(stdout, NULL, _IONBF, 0);
    setvbuf(stderr, NULL, _IONBF, 0);

    FILE *out, *err;
    _wfreopen_s(&out, L"3RVX_Log.txt", L"w", stdout);
    _wfreopen_s(&err, L"3RVX_Log.txt", L"w", stderr);
#else
#ifdef ENABLE_3RVX_LOG
    AllocConsole();
    FILE *in, *out, *err;
    freopen_s(&in, "CONIN$", "r", stdin);
    freopen_s(&out, "CONOUT$", "w", stdout);
    freopen_s(&err, "CONOUT$", "w", stderr);
#endif
#endif
}

void Logger::Stop() {
#ifdef ENABLE_3RVX_LOGTOFILE
    CLOG(L"Logger stopped.");
    fclose(stdout);
    fclose(stderr);
#else
#ifdef ENABLE_3RVX_LOG
    FreeConsole();
#endif
#endif
}

#include "Logger.h"
#include <string>

void Logger::Start() {
#ifdef ENABLE_3RVX_LOGTOFILE
    /* Disable buffering */
    setvbuf(stdout, NULL, _IONBF, 0);
    setvbuf(stderr, NULL, _IONBF, 0);

    FILE *out, *err;
    _wfreopen_s(&out, L"3RVX_Log.txt", L"w", stdout);
    _wfreopen_s(&err, L"3RVX_Log.txt", L"w", stderr);
#else
#if ENABLE_3RVX_LOG != 0
    AllocConsole();
    FILE *in, *out, *err;
    freopen_s(&in, "CONIN$", "r", stdin);
    freopen_s(&out, "CONOUT$", "w", stdout);
    freopen_s(&err, "CONOUT$", "w", stderr);
#endif
#endif
}

void Logger::Stop() {
#ifdef ENABLE_3RVX_LOGTOFILE
    CLOG(L"Logger stopped.");
    fclose(stdout);
    fclose(stderr);
#else
#if ENABLE_3RVX_LOG != 0
    FreeConsole();
#endif
#endif
}

Fix release build console bug

Fix release build console bug


// 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/chromeos/status_area_button.h"

#include "app/gfx/canvas.h"
#include "app/gfx/skbitmap_operations.h"
#include "app/resource_bundle.h"
#include "grit/theme_resources.h"
#include "views/border.h"
#include "views/view.h"

////////////////////////////////////////////////////////////////////////////////
// StatusAreaButton

StatusAreaButton::StatusAreaButton(views::ViewMenuDelegate* menu_delegate)
    : MenuButton(NULL, std::wstring(), menu_delegate, false) {
  set_border(NULL);
  SetShowHighlighted(true);
}

void StatusAreaButton::Paint(gfx::Canvas* canvas, bool for_drag) {
  int bitmap_id;

  switch(state()) {
    case BS_NORMAL:
      bitmap_id = IDR_STATUSBAR_CONTAINER;
      break;
    case BS_HOT:
      bitmap_id = IDR_STATUSBAR_CONTAINER_HOVER;
      break;
    case BS_PUSHED:
      bitmap_id = IDR_STATUSBAR_CONTAINER_PRESSED;
      break;
    default:
      NOTREACHED();
  }
  SkBitmap* container =
      ResourceBundle::GetSharedInstance().GetBitmapNamed(bitmap_id);
  canvas->DrawBitmapInt(*container, 0, 0);
  canvas->DrawBitmapInt(icon(), 0, 0);
}

// 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/chromeos/status_area_button.h"

#include "app/gfx/canvas.h"
#include "app/gfx/skbitmap_operations.h"
#include "app/resource_bundle.h"
#include "grit/theme_resources.h"
#include "views/border.h"
#include "views/view.h"

////////////////////////////////////////////////////////////////////////////////
// StatusAreaButton

StatusAreaButton::StatusAreaButton(views::ViewMenuDelegate* menu_delegate)
    : MenuButton(NULL, std::wstring(), menu_delegate, false) {
  set_border(NULL);
  SetShowHighlighted(true);
}

void StatusAreaButton::Paint(gfx::Canvas* canvas, bool for_drag) {
  int bitmap_id;

  switch(state()) {
    case BS_NORMAL:
      bitmap_id = IDR_STATUSBAR_CONTAINER;
      break;
    case BS_HOT:
      bitmap_id = IDR_STATUSBAR_CONTAINER_HOVER;
      break;
    case BS_PUSHED:
      bitmap_id = IDR_STATUSBAR_CONTAINER_PRESSED;
      break;
    default:
      bitmap_id = IDR_STATUSBAR_CONTAINER;
      NOTREACHED();
  }
  SkBitmap* container =
      ResourceBundle::GetSharedInstance().GetBitmapNamed(bitmap_id);
  canvas->DrawBitmapInt(*container, 0, 0);
  canvas->DrawBitmapInt(icon(), 0, 0);
}

Fix for Release build break

Fix for Release build break

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

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

Former-commit-id: 43f80bde7c30b954275cbe636b8522517653304d


#include "generator.h"

int main()
{
	QStringList l;
	l
	<< "kernel_metamodel.xml"
	<< "basicbehaviors_metamodel.xml"
	<< "trace.xml"
	<< "requirements_metamodel.xml"
	<< "class_metamodel.xml"
	<< "usecase_metamodel.xml"
	<< "sequence_metamodel.xml"
	//<< "communication_metamodel.xml"
	<< "statemachines_metamodel.xml"
	//<< "deployment.xml"
	//<< "component_metamodel.xml"
	//<< "timing_metamodel.xml"
	<< "activity_metamodel.xml"
	<< "package.xml"
	<< "bpel.xml"
	<< "qrealparallel_metamodel.xml";
	delete (new Generator(l));
	return 0;
}

#include "generator.h"

int main()
{
	QStringList l;
	l
	<< "kernel_metamodel.xml"
	<< "basicbehaviors_metamodel.xml"
	<< "trace.xml"
	<< "requirements_metamodel.xml"
	<< "class_metamodel.xml"
	<< "usecase_metamodel.xml"
	<< "sequence_metamodel.xml"
	//<< "communication_metamodel.xml"
	<< "statemachines_metamodel.xml"
	//<< "deployment.xml"
	//<< "component_metamodel.xml"
	//<< "timing_metamodel.xml"
	<< "activity_metamodel.xml"
	<< "package.xml"
	<< "bpel.xml"
	<< "qrealparallel_metamodel.xml";
	Generator generator(l);
	return 0;
}

Create generator object on stack. Testing build system.


//-------------------------------------------------------------------------------------------------------
// 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