#include "stagestack.h"

namespace OpenApoc {

void StageStack::Push(std::shared_ptr<Stage> newStage)
{

	// Pause any current stage
	if(this->Current())
		this->Current()->Pause();

	this->Stack.push(newStage);
	newStage->Begin();
}

std::shared_ptr<Stage> StageStack::Pop()
{
	std::shared_ptr<Stage> result = this->Current();

	if (result)
	{
		Stack.pop();
	}

	// If there's still an item on the stack, resume it
	if( this->Current() )
		this->Current()->Resume();

	return result;
}

std::shared_ptr<Stage> StageStack::Current()
{
	if (this->Stack.empty())
		return nullptr;
	else
		return this->Stack.top();
}

bool StageStack::IsEmpty()
{
	return this->Stack.empty();
}

void StageStack::Clear()
{
	while (!this->Stack.empty())
		this->Stack.pop();
}

}; //namespace OpenApoc

#include "stagestack.h"

namespace OpenApoc {

void StageStack::Push(std::shared_ptr<Stage> newStage)
{

	// Pause any current stage
	if(this->Current())
		this->Current()->Pause();

	this->Stack.push(newStage);
	newStage->Begin();
}

std::shared_ptr<Stage> StageStack::Pop()
{
	std::shared_ptr<Stage> result = this->Current();

	if (result)
	{
		result->Finish();
		Stack.pop();
	}

	// If there's still an item on the stack, resume it
	if( this->Current() )
		this->Current()->Resume();

	return result;
}

std::shared_ptr<Stage> StageStack::Current()
{
	if (this->Stack.empty())
		return nullptr;
	else
		return this->Stack.top();
}

bool StageStack::IsEmpty()
{
	return this->Stack.empty();
}

void StageStack::Clear()
{
	while (!this->IsEmpty())
		this->Pop();
}

}; //namespace OpenApoc

Call Finish() on Stages removed from the stack


// 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 "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include "webkit/tools/test_shell/test_shell_test.h"

using WebKit::WebView;

class WebViewTest : public TestShellTest {
};

TEST_F(WebViewTest, GetContentAsPlainText) {
  WebView* view = test_shell_->webView();
  ASSERT_TRUE(view != 0);

  view->setIsActive(true);
  EXPECT_TRUE(view->isActive());

  view->setIsActive(false);
  EXPECT_FALSE(view->isActive());

  view->setIsActive(true);
  EXPECT_TRUE(view->isActive());
}

// TODO(viettrungluu): add more tests

// 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 "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include "webkit/tools/test_shell/test_shell_test.h"

using WebKit::WebView;

class WebViewTest : public TestShellTest {
};

TEST_F(WebViewTest, ActiveState) {
  WebView* view = test_shell_->webView();
  ASSERT_TRUE(view != 0);

  view->setIsActive(true);
  EXPECT_TRUE(view->isActive());

  view->setIsActive(false);
  EXPECT_FALSE(view->isActive());

  view->setIsActive(true);
  EXPECT_TRUE(view->isActive());
}

// TODO(viettrungluu): add more tests

Rename unit test: WebViewTest.GetContentAsPlainText -> WebViewTest.ActiveState.


// Copyright 2014 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/at_exit.h"
#include "base/command_line.h"
#include "base/test/test_timeouts.h"
#include "mojo/application/application_runner_chromium.h"
#include "mojo/application/application_test_base_chromium.h"
#include "mojo/public/c/system/main.h"

MojoResult MojoMain(MojoHandle handle) {
  // An AtExitManager instance is needed to construct message loops.
  base::AtExitManager at_exit;

  // Initialize test timeouts, which requires CommandLine::ForCurrentProcess().
  // TODO(msw): Plumb relevant command line args before initializing timeouts.
  mojo::ApplicationRunnerChromium::InitBaseCommandLine();
  TestTimeouts::Initialize();

  return mojo::test::RunAllTests(handle);
}

// Copyright 2014 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/at_exit.h"
#include "base/command_line.h"
#include "base/test/test_timeouts.h"
#include "mojo/application/application_runner_chromium.h"
#include "mojo/application/application_test_base_chromium.h"
#include "mojo/public/c/system/main.h"

MojoResult MojoMain(MojoHandle handle) {
  // An AtExitManager instance is needed to construct message loops.
  base::AtExitManager at_exit;

  // Initialize the current process Commandline and test timeouts.
  mojo::ApplicationRunnerChromium::InitBaseCommandLine();
  TestTimeouts::Initialize();

  return mojo::test::RunAllTests(handle);
}

Update the application_test_main CommandLine comment.


// 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().


#include "photoeffects.hpp"
#include "stdio.h"

using namespace cv;

int tint(InputArray src, OutputArray dst,
        const Vec3b &colorTint, float density)
{
    CV_Assert(src.type() == CV_8UC3);
    CV_Assert(density >= 0.0f && density <= 1.0f);
    dst.create(src.size(), CV_8UC3);
    Mat image = src.getMat(), outputImage = dst.getMat();

    float negDen = 1 - density;
    for (int i = 0; i < image.rows; i++)
    {
        for (int j = 0; j < image.cols; j++)
        {
            Vec3b colorDest = image.at<Vec3b>(i, j);
            colorDest = colorTint * density + negDen * colorDest;
            outputImage.at<Vec3b>(i, j) = colorDest;
        }
    }
    return 0;
}

#include "photoeffects.hpp"
#include "stdio.h"

using namespace cv;

int tint(InputArray src, OutputArray dst,
        const Vec3b &colorTint, float density)
{
    CV_Assert(src.type() == CV_8UC3);
    CV_Assert(density >= 0.0f && density <= 1.0f);
    dst.create(src.size(), CV_8UC3);
    Mat image = src.getMat(), outputImage = dst.getMat();
    Mat matColTint(src.size(), CV_8UC3, Scalar(colorTint[0], colorTint[1], colorTint[2]));

    outputImage = matColTint * density + image * (1 - density);
    return 0;
}

Change to operations with Mat


#include "RedisClient.h"

#include <string>
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
    (void)argc;
    (void)argv;

    REDIS_ENDPOINT endpoints[1] = {
        { "127.0.0.1", 6379 },
        //{ "127.0.0.1", 6380 },
        //{ "127.0.0.1", 6381 },
    };

    REDIS_CONFIG conf = {
        (REDIS_ENDPOINT*)&endpoints,
        1,
        10000,
        5000,
        20,
        1,
    };

    RedisClient client(conf);

    cout << "Press <ENTER> to continue..." << endl;
    cin.get();

    string res = client.set("key0", "value0");
    cout << "SET: " << res << endl;

    cout << "Press <ENTER> to continue..." << endl;
    cin.get();

    res = client.get("key0");
    cout << "GET: " << res << endl;

    cout << "Press <ENTER> to continue..." << endl;
    cin.get();

    client.set("count0", "0");
    long long count0;
    for (long long i = 0; i < 1000; i++) {
        count0 = client.incr("count0");
    }
    cout << "INCR count0 to " << count0 << endl;

    return 0;
}

#include "RedisClient.h"

#include <string>
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
    (void)argc;
    (void)argv;

    REDIS_ENDPOINT endpoints[1] = {
        { "127.0.0.1", 6379 },
        //{ "127.0.0.1", 6380 },
        //{ "127.0.0.1", 6381 },
    };

    REDIS_CONFIG conf = {
        (REDIS_ENDPOINT*)&endpoints,
        1,
        10000,
        5000,
        20,
        1,
    };

    RedisClient client(conf);

    cout << "Press <ENTER> to continue..." << endl;
    cin.get();

    string res = client.set("key0", "value0");
    cout << "SET: " << res << endl;

    cout << "Press <ENTER> to continue..." << endl;
    cin.get();

    res = client.get("key0");
    cout << "GET: " << res << endl;

    cout << "Press <ENTER> to continue..." << endl;
    cin.get();

    client.set("count0", "0");
    long long count0;
    for (long long i = 0; i < 1000; i++) {
        count0 = client.incr("count0");
    }
    cout << "INCR count0 to " << count0 << endl;

    cout << "Press <ENTER> to continue..." << endl;
    cin.get();

    {
        RedisReplyPtr reply = client.redisCommand("PING");
        cout << "PING: " << reply->str << endl;
        // reply will be freed out of scope.
    }

    return 0;
}

Add example to use client.redisCommand directly.


#include <string>
#include <map>

#include "CalController.h"
#include "TEMLogger.h"

BOOST_LOG_INLINE_GLOBAL_LOGGER_INIT(my_cal_logger, severity_channel_logger_t) {
  return severity_channel_logger_t(keywords::channel = "CALIB");
}

severity_channel_logger_t& CalController::clg = my_cal_logger::get();

std::string CalController::getUserCommand() {
  std::string ui = "";
  while( !(commands.count(ui)) ) {
    std::cout << "What now?> ";
    std::getline(std::cin, ui);
    std::cin.clear();
  }
  return ui;
}
void CalController::showCalibrationControlMenu() {

  std::string m = "Entering calibration controller....\n"
                  "\n"
                  "-------------- Menu -----------------\n"
                  "Choose one of the following options:\n";

  std::map<std::string, std::string>::const_iterator citer;
  for(citer = commands.begin(); citer != commands.end(); ++citer) {
    m += citer->first;
    m += " - ";
    m += citer->second;
  }

  BOOST_LOG_SEV(clg, info) << m;

}

#include <string>
#include <map>

#include "CalController.h"
#include "TEMLogger.h"

BOOST_LOG_INLINE_GLOBAL_LOGGER_INIT(my_cal_logger, severity_channel_logger_t) {
  return severity_channel_logger_t(keywords::channel = "CALIB");
}

severity_channel_logger_t& CalController::clg = my_cal_logger::get();

std::string CalController::getUserCommand() {
  std::string ui = "";
  while( !(commands.count(ui)) ) {
    std::cout << "What now?> ";
    std::getline(std::cin, ui);
    std::cin.clear();
  }
  return ui;
}
void CalController::showCalibrationControlMenu() {

  std::string m = "Entering calibration controller....\n"
                  "\n"
                  "-------------- Menu -----------------\n"
                  "Choose one of the following options:\n";

  std::map<std::string, std::string>::const_iterator citer;
  for(citer = commands.begin(); citer != commands.end(); ++citer) {
    m += citer->first;
    m += " - ";
    m += citer->second;
    m += "\n";
  }

  BOOST_LOG_SEV(clg, info) << m;

}

Fix missing newline in cal controller menu


#include "test_env.h"
#include "TMP102.h"

#if defined(TARGET_KL25Z)
TMP102 temperature(PTC9, PTC8, 0x90);

#elif defined(TARGET_LPC812)
TMP102 temperature(D10, D11, 0x90);

#elif defined(TARGET_LPC4088)
TMP102 temperature(p9, p10, 0x90);

#elif defined(TARGET_LPC2368)
TMP102 temperature(p28, p27, 0x90);

#else
TMP102 temperature(p28, p27, 0x90);
#endif

int main()
{
    float t = temperature.read();

    printf("TMP102: Temperature: %f\n\r", t);
    // In our test environment (ARM office) we should get a temperature within
    // the range ]15, 30[C
    bool result = (t > 15.0) && (t < 30.0);
    notify_completion(result);
}

#include "test_env.h"
#include "TMP102.h"

#if defined(TARGET_KL25Z)
TMP102 temperature(PTC9, PTC8, 0x90);

#elif defined(TARGET_LPC812)
TMP102 temperature(D10, D11, 0x90);

#elif defined(TARGET_LPC4088)
TMP102 temperature(p9, p10, 0x90);

#elif defined(TARGET_LPC2368)
TMP102 temperature(p28, p27, 0x90);

#elif defined(TARGET_NUCLEO_F103RB) || \
    defined(TARGET_NUCLEO_L152RE) || \
    defined(TARGET_NUCLEO_F302R8) || \
    defined(TARGET_NUCLEO_F030R8) || \
    defined(TARGET_NUCLEO_F401RE) || \
    defined(TARGET_NUCLEO_F411RE) || \
    defined(TARGET_NUCLEO_F072RB) || \
    defined(TARGET_NUCLEO_F334R8) || \
    defined(TARGET_NUCLEO_L053R8)
TMP102 temperature(I2C_SDA, I2C_SCL, 0x90);

#else
TMP102 temperature(p28, p27, 0x90);
#endif

int main()
{
    float t = temperature.read();

    printf("TMP102: Temperature: %f\n\r", t);
    // In our test environment (ARM office) we should get a temperature within
    // the range ]15, 30[C
    bool result = (t > 15.0) && (t < 30.0);
    notify_completion(result);
}

Add NUCLEOs targets in TMP102 test


/*
 * Copyright © 2017 Collabora Ltd.
 *
 * This file is part of vkmark.
 *
 * vkmark 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) any later version.
 *
 * vkmark 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 vkmark. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *   Alexandros Frantzis <alexandros.frantzis@collabora.com>
 */

#include "default_benchmarks.h"

std::vector<std::string> DefaultBenchmarks::get()
{
    return std::vector<std::string>{
        "vertex:device-local=true",
        "vertex:device-local=false",
        "texture:anisotropy=0",
        "texture:anisotropy=16",
        "shading:shading=gouraud",
        "shading:shading=blinn-phong-inf",
        "shading:shading=phong",
        "shading:shading=cel",
        "cube",
        "clear"
    };
}

/*
 * Copyright © 2017 Collabora Ltd.
 *
 * This file is part of vkmark.
 *
 * vkmark 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) any later version.
 *
 * vkmark 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 vkmark. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *   Alexandros Frantzis <alexandros.frantzis@collabora.com>
 */

#include "default_benchmarks.h"

std::vector<std::string> DefaultBenchmarks::get()
{
    return std::vector<std::string>{
        "vertex:device-local=true",
        "vertex:device-local=false",
        "texture:anisotropy=0",
        "texture:anisotropy=16",
        "shading:shading=gouraud",
        "shading:shading=blinn-phong-inf",
        "shading:shading=phong",
        "shading:shading=cel",
        "desktop",
        "cube",
        "clear"
    };
}

Add 'desktop' to default benchmarks


#include "drivers/ublox_neo7.hpp"

#include "chprintf.h"
#include "unit_config.hpp"

void UBloxNEO7::init() {
}

GPSReading UBloxNEO7::readGPS() {
  GPSReading reading;

  // Read all available bytes until the newline character.
  std::size_t len = readUntil('\n');

  // Check if a full line is ready to be processed
  if(len > 0) {
    // TODO: Run parser
  }

  // TODO
  reading.lat = 1.2f;
  reading.lon = 3.4f;

  //char dbg_buf[16];
  //chsnprintf(dbg_buf, 12, "%12c", rxbuf.data());
  //chnWriteTimeout((BaseChannel*)&SD4, (uint8_t*)dbg_buf, 12, MS2ST(20));

  return reading;
}

#include "drivers/ublox_neo7.hpp"

#include "chprintf.h"
#include "unit_config.hpp"

void UBloxNEO7::init() {
}

GPSReading UBloxNEO7::readGPS() {
  GPSReading reading;

  // Read all available bytes until the newline character. NMEA dictates that
  // messages should end with a CRLF, but we'll only look for the LF.
  std::size_t len = readUntil('\n');

  // Check if a full line is ready to be processed
  if(len > 0) {
    // TODO: Run parser
  }

  // TODO
  reading.lat = 1.2f;
  reading.lon = 3.4f;

  //char dbg_buf[16];
  //chsnprintf(dbg_buf, 12, "%12c", rxbuf.data());
  //chnWriteTimeout((BaseChannel*)&SD4, (uint8_t*)dbg_buf, 12, MS2ST(20));

  return reading;
}

Add comment about NMEA CRLF.


/*
 * Copyright (c) 2016 Luke San Antonio
 * All rights reserved.
 *
 * This file provides the implementation for the engine's C interface,
 * specifically tailored for LuaJIT's FFI facilities.
 */

#include "redcrane.hpp"

namespace redc
{
  struct Model_Visitor : boost::static_visitor<glm::mat4>
  {
    glm::mat4 operator()(Mesh_Object const& msh) const
    {
      return msh.model;
    }
    glm::mat4 operator()(Cam_Object const& cam) const
    {
      return gfx::camera_model_matrix(cam.cam);
    }
  };

  glm::mat4 object_model(Object const& obj)
  {
    // Find current
    auto this_model = boost::apply_visitor(Model_Visitor{}, obj.obj);

    // Find parent
    glm::mat4 parent_model(1.0f);
    if(obj.parent)
    {
      parent_model = object_model(*obj.parent);
    }

    // First apply the child transformations then the parent transformations.
    return parent_model * this_model;
  }
}

/*
 * Copyright (c) 2016 Luke San Antonio
 * All rights reserved.
 *
 * This file provides the implementation for the engine's C interface,
 * specifically tailored for LuaJIT's FFI facilities.
 */

#include "redcrane.hpp"

namespace redc
{
  struct Model_Visitor : boost::static_visitor<glm::mat4>
  {
    glm::mat4 operator()(Mesh_Object const& msh) const
    {
      return msh.model;
    }
    glm::mat4 operator()(Cam_Object const& cam) const
    {
      return glm::inverse(gfx::camera_view_matrix(cam.cam));
    }
  };

  glm::mat4 object_model(Object const& obj)
  {
    // Find current
    auto this_model = boost::apply_visitor(Model_Visitor{}, obj.obj);

    // Find parent
    glm::mat4 parent_model(1.0f);
    if(obj.parent)
    {
      parent_model = object_model(*obj.parent);
    }

    // First apply the child transformations then the parent transformations.
    return parent_model * this_model;
  }
}

Fix objects parented to the camera


// torch4microscopic.cpp : R\[ AvP[ṼGg |Cg`܂B
//

#include "stdafx.h"

int main(int argc, char* argv[])
{
	return 0;
}

// torch4microscopic.cpp : R\[ AvP[ṼGg |Cg`܂B
//

#include "stdafx.h"

#include <iostream>
#include <vector>
#include <fstream>
#include <boost/program_options.hpp>

using namespace std;
using namespace boost::program_options;

int main(int argc, char* argv[])
{
	//IvV`
	options_description inout_options("path setting");
	options_description calc_options("calculation option");

	inout_options.add_options()
		("input,i", value<string>(), "input path")
		("output,o", value<string>(), "output path");

	calc_options.add_options()
		("amp_exp", "enable amplifier (exponential growth method)")
		("cutback", "enable subtraction for cutback (average lowest pixel)");

	variables_map cmd_values;

	try
	{
		options_description option_marged("");
		option_marged.add(inout_options).add(calc_options);

		if (!cmd_values.count("input") || cmd_values.count("output"))
		{
			cout << option_marged << endl;
		}

		store(parse_command_line(argc, argv, option_marged), cmd_values);
		notify(cmd_values);

	}
	catch (exception &e)
	{
		cout << e.what() << endl;
	}

	return 0;
}

Add for processing command line option.


// 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 "ui/aura/toplevel_window_container.h"

#include "base/utf_string_conversions.h"
#include "ui/aura/toplevel_window_event_filter.h"

namespace aura {

ToplevelWindowContainer::ToplevelWindowContainer()
    : Window(NULL) {
  set_name("ToplevelWindowContainer");
  SetEventFilter(new ToplevelWindowEventFilter(this));
}

ToplevelWindowContainer::~ToplevelWindowContainer() {
}

Window* ToplevelWindowContainer::GetTopmostWindowToActivate(
    Window* ignore) const {
  for (Window::Windows::const_reverse_iterator i = children().rbegin();
       i != children().rend(); ++i) {
         Window* w = *i;
    if (*i != ignore && (*i)->CanActivate())
      return *i;
  }
  return NULL;
}

ToplevelWindowContainer* ToplevelWindowContainer::AsToplevelWindowContainer() {
  return this;
}

const ToplevelWindowContainer*
    ToplevelWindowContainer::AsToplevelWindowContainer() const {
  return this;
}
}  // namespace aura

// 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 "ui/aura/toplevel_window_container.h"

#include "base/utf_string_conversions.h"
#include "ui/aura/toplevel_window_event_filter.h"

namespace aura {

ToplevelWindowContainer::ToplevelWindowContainer()
    : Window(NULL) {
  set_name("ToplevelWindowContainer");
  SetEventFilter(new ToplevelWindowEventFilter(this));
}

ToplevelWindowContainer::~ToplevelWindowContainer() {
}

Window* ToplevelWindowContainer::GetTopmostWindowToActivate(
    Window* ignore) const {
  for (Window::Windows::const_reverse_iterator i = children().rbegin();
       i != children().rend(); ++i) {
    if (*i != ignore && (*i)->CanActivate())
      return *i;
  }
  return NULL;
}

ToplevelWindowContainer* ToplevelWindowContainer::AsToplevelWindowContainer() {
  return this;
}

const ToplevelWindowContainer*
    ToplevelWindowContainer::AsToplevelWindowContainer() const {
  return this;
}
}  // namespace aura

Fix aura bustage on linux.


/*-------------------------------------------------------------------------
 * Vulkan CTS Framework
 * --------------------
 *
 * Copyright (c) 2018 The Khronos Group Inc.
 * Copyright (c) 2019 Intel Corporation
 *
 * 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.
 *
 *//*!
 * \file
 * \brief Stub no-op version of RenderDocUtil class
 *//*--------------------------------------------------------------------*/

#include "vkRenderDocUtil.hpp"

namespace vk
{

struct RenderDocPrivate
{
};

RenderDocUtil::RenderDocUtil (void)
{
}

RenderDocUtil::~RenderDocUtil (void)
{
}

bool RenderDocUtil::isValid (void)
{
	return false;
}

void RenderDocUtil::startFrame (vk::VkInstance instance)
{
}

void RenderDocUtil::endFrame (vk::VkInstance instance)
{
}

} // vk

/*-------------------------------------------------------------------------
 * Vulkan CTS Framework
 * --------------------
 *
 * Copyright (c) 2018 The Khronos Group Inc.
 * Copyright (c) 2019 Intel Corporation
 *
 * 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.
 *
 *//*!
 * \file
 * \brief Stub no-op version of RenderDocUtil class
 *//*--------------------------------------------------------------------*/

#include "vkRenderDocUtil.hpp"

namespace vk
{

struct RenderDocPrivate
{
};

RenderDocUtil::RenderDocUtil (void)
{
}

RenderDocUtil::~RenderDocUtil (void)
{
}

bool RenderDocUtil::isValid (void)
{
	return false;
}

void RenderDocUtil::startFrame (vk::VkInstance instance)
{
	DE_UNREF(instance);
}

void RenderDocUtil::endFrame (vk::VkInstance instance)
{
	DE_UNREF(instance);
}

} // vk

Fix build by adding DE_UNREF


// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s

struct X {
  X(int v);

  int value;
};

X::X(int v) {
  // CHECK_TEMPORARILY_DISABLED: call void @_ZN1XC2Ei(%struct.X* %this1, i32 %tmp), !dbg
  // TEMPORARY CHECK: X
  value = v;
}

// RUN: %clang -march=x86_64-apple-darwin10 -emit-llvm -g -S %s -o - | FileCheck %s

struct X {
  X(int v);

  int value;
};

X::X(int v) {
  // CHECK: call void @_ZN1XC2Ei(%struct.X* %this1, i32 %tmp), !dbg
  value = v;
}

Make this test darwin only.


#include <cstdint>

#include <APU.h>

static int null_dmc_reader(void*, unsigned int)
{
	return 0x55; // causes dmc sample to be flat
}

APU::APU()
{
	time = 0;
	frameLength = 29780;
	apu.dmc_reader(null_dmc_reader, NULL);
	apu.output(&buf);
	buf.clock_rate(1789773);
	buf.sample_rate(96000);
}

void APU::setDmcCallback(int (*f)(void* user_data, unsigned int), void* p)
{
	apu.dmc_reader(f, p);
}

void APU::writeRegister(uint16_t addr, uint8_t data)
{
	apu.write_register(clock(), addr, data);
}

int APU::getStatus()
{
	return apu.read_status(clock());
}

void APU::endFrame()
{
	time = 0;
	frameLength ^= 1;
	apu.end_frame(frameLength);
	buf.end_frame(frameLength);
}

long APU::samplesAvailable() const
{
	return buf.samples_avail();
}

long APU::readSamples(sample_t* buffer, long bufferSize)
{
	return buf.read_samples(buffer, bufferSize);
}

#include <cstdint>

#include <APU.h>

static int null_dmc_reader(void*, unsigned int)
{
	return 0x55; // causes dmc sample to be flat
}

APU::APU()
{
	time = 0;
	frameLength = 29780;
	apu.dmc_reader(null_dmc_reader, NULL);
	apu.output(&buf);
	buf.clock_rate(1789773);
	buf.sample_rate(44100);
}

void APU::setDmcCallback(int (*f)(void* user_data, unsigned int), void* p)
{
	apu.dmc_reader(f, p);
}

void APU::writeRegister(uint16_t addr, uint8_t data)
{
	apu.write_register(clock(), addr, data);
}

int APU::getStatus()
{
	return apu.read_status(clock());
}

void APU::endFrame()
{
	time = 0;
	frameLength ^= 1;
	apu.end_frame(frameLength);
	buf.end_frame(frameLength);
}

long APU::samplesAvailable() const
{
	return buf.samples_avail();
}

long APU::readSamples(sample_t* buffer, long bufferSize)
{
	return buf.read_samples(buffer, bufferSize);
}

Set apu default sample rate to 44100


//
// (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use.
//

#include "gettime.h"

// for best accuracy, getTime is implemented platform dependent.
// to avoid a global include of windows.h, this is a separate file.

#if defined(_WIN32)

#include <windows.h>

// returns a point in time in milliseconds (can only be used for time differences, not an absolute time)
double getTime() noexcept
{
    LARGE_INTEGER time;
    QueryPerformanceCounter(&time);
    LARGE_INTEGER freq;
    QueryPerformanceFrequency(&freq);

    return (static_cast<double>(time.LowPart) * 1000.0) / static_cast<double>(freq.LowPart);
}

#else

#include <sys/time.h>
double getTime()
{
    timeval t;
    gettimeofday(&t, nullptr);

    return (t.tv_sec * 1000000.0 + t.tv_usec) / 1000.0;
}

#endif

//
// (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use.
//

#include "gettime.h"

// for best accuracy, getTime is implemented platform dependent.
// to avoid a global include of windows.h, this is a separate file.

#if defined(_WIN32)

#include <windows.h>

// returns a point in time in milliseconds (can only be used for time differences, not an absolute time)
double getTime() noexcept
{
    LARGE_INTEGER time;
    QueryPerformanceCounter(&time);
    LARGE_INTEGER freq;
    QueryPerformanceFrequency(&freq);

    return (static_cast<double>(time.LowPart) * 1000.0) / static_cast<double>(freq.LowPart);
}

#else

#include <sys/time.h>
double getTime() noexcept
{
    timeval t;
    gettimeofday(&t, nullptr);

    return (t.tv_sec * 1000000.0 + t.tv_usec) / 1000.0;
}

#endif

Add noexcept for getTime() in Linux build


/**
 * $ g++ solution.cpp && ./a.out < input.txt
 */
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

/**
 * O(n^2) word-by-word comparison
 */
bool validate_line(string line) {
    string input1, input2;
    stringstream stream1(line);
    int counter1 = 0;
    while (stream1 >> input1) {
        stringstream stream2(line);
        int counter2 = 0;
        while (stream2 >> input2) {
            if (counter1 == counter2) {
                counter2++;
                continue;
            }
            if (input1 == input2) {
                return false;
            }
            counter2++;
        }
        counter1++;
    }
    return true;
}

int part1() {
    int total = 0;
    string line;
    while (getline(cin, line)) {
        if (validate_line(line)) {
            total++;
        }
    }
    return total;
}

int main() {
    cout << "Day 4!\n";
    cout << "Part 1: " << part1() << "\n";
}

/**
 * $ g++ solution.cpp && ./a.out < input.txt
 */
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

/**
 * O(n^2) word-by-word comparison
 */
bool part1_validate(string line) {
    string input1, input2;
    stringstream stream1(line);
    int counter1 = 0;
    while (stream1 >> input1) {
        stringstream stream2(line);
        int counter2 = 0;
        while (stream2 >> input2) {
            if (counter1 == counter2) {
                counter2++;
                continue;
            }
            if (input1 == input2) {
                return false;
            }
            counter2++;
        }
        counter1++;
    }
    return true;
}

int main() {
    cout << "Day 4!\n";
    int part1_total = 0;
    string line;
    while (getline(cin, line)) {
        if (part1_validate(line)) {
            part1_total++;
        }
    }
    cout << "Part 1: " << part1_total << "\n";
}

Rework to call part1-specific stuff line by line


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

#include "base/logging.h"

ChromeBrowserMainPartsAura::ChromeBrowserMainPartsAura(
    const MainFunctionParams& parameters) {
  NOTIMPLEMENTED();
}

void ChromeBrowserMainPartsAura::PreEarlyInitialization() {
  NOTIMPLEMENTED();
}

void ChromeBrowserMainPartsAura::PostMainMessageLoopStart() {
  NOTIMPLEMENTED();
}

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

#include "base/logging.h"

ChromeBrowserMainPartsAura::ChromeBrowserMainPartsAura(
    const MainFunctionParams& parameters)
  : ChromeBrowserMainParts(parameters) {
  NOTIMPLEMENTED();
}

void ChromeBrowserMainPartsAura::PreEarlyInitialization() {
  NOTIMPLEMENTED();
}

void ChromeBrowserMainPartsAura::PostMainMessageLoopStart() {
  NOTIMPLEMENTED();
}

Fix Aura compile error. My bad.


#include "hiker.hpp"
#define BOOST_TEST_MODULE HikerTest
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE(Life_the_universe_and_everything)
{
    // The initial code and test files are completely
    // *unrelated* to the chosen exercise. They are
    // merely a simple example to start you off.
    // You should now delete this comment!
    BOOST_REQUIRE(42, answer());
}

#include "hiker.hpp"
#define BOOST_TEST_MODULE HikerTest
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE(Life_the_universe_and_everything)
{
    // The initial code and test files are completely
    // *unrelated* to the chosen exercise. They are
    // merely a simple example to start you off.
    // You should now delete this comment!
    BOOST_REQUIRE_EQUAL(42, answer());
}

Use require equal for testing equality


#include <assert.h>
#include <stdio.h>

#include "utility.h"
#include "quadraticsieve.h"

void quadratic_sieve(long long& result, long long input, int& err)
{

}

Add a stub for the quadratic_sieve(...) procedure.


//===-- project_euler/Problem5.cpp ------------------------------*- C++ -*-===//
//
// ProjectEuler.net solutions by Will Mitchell
//
// This file is distributed under the MIT License. See LICENSE for details.
//
//===----------------------------------------------------------------------===//
///
/// \class project_euler::Problem5
/// \brief Smallest multiple
///
/// Question
/// --------
/// A palindromic number reads the same both ways. The largest palindrome made
/// from the product of two 2-digit numbers is 9009 = 91 * 99.
///
/// Find the largest palindrome made from the product of two 3-digit numbers.
///
//===----------------------------------------------------------------------===//
#include "Problem5.h"

#include <sstream>
using std::stringstream;
#include <string>
using std::string;

#include <gmpxx.h>

string project_euler::Problem5::answer() {
  if (!solved)
    solve();

  stringstream ss;

  ss << "The smallest positive number that is evenly divisible by all of the "
        "numbers from 1 to 20 is " << lcm;

  return ss.str();
}

std::string project_euler::Problem5::description() const {
  return "Problem 5: Smallest multiple";
}

void project_euler::Problem5::solve() {
  lcm = 1;

  for (unsigned long i = 1ul; i <= 20ul; ++i)
    mpz_lcm_ui(lcm.get_mpz_t(), lcm.get_mpz_t(), i);

  solved = true;
}

//===-- project_euler/Problem5.cpp ------------------------------*- C++ -*-===//
//
// ProjectEuler.net solutions by Will Mitchell
//
// This file is distributed under the MIT License. See LICENSE for details.
//
//===----------------------------------------------------------------------===//
///
/// \class project_euler::Problem5
/// \brief Smallest multiple
///
/// Question
/// --------
/// 2520 is the smallest number that can be divided by each of the numbers from
/// 1 to 10 without any remainder.
///
/// What is the smallest positive number that is evenly divisible by all of the
/// numbers from 1 to 20?
///
//===----------------------------------------------------------------------===//
#include "Problem5.h"

#include <sstream>
using std::stringstream;
#include <string>
using std::string;

#include <gmpxx.h>

string project_euler::Problem5::answer() {
  if (!solved)
    solve();

  stringstream ss;

  ss << "The smallest positive number that is evenly divisible by all of the "
        "numbers from 1 to 20 is "
     << lcm;

  return ss.str();
}

std::string project_euler::Problem5::description() const {
  return "Problem 5: Smallest multiple";
}

void project_euler::Problem5::solve() {
  lcm = 1;

  for (unsigned long i = 1ul; i <= 20ul; ++i)
    mpz_lcm_ui(lcm.get_mpz_t(), lcm.get_mpz_t(), i);

  solved = true;
}

Correct problem statement for problem 5


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

#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/ui_test_utils.h"
#include "googleurl/src/gurl.h"
#include "net/test/test_server.h"

// Tests that we throw errors when you try using extension APIs that aren't
// supported in content scripts.
//
// If you have added a new API to extension_api.json and this test starts
// failing, most likely you need to either mark it as "unprivileged" (if it
// should be available in content scripts) or update the list of privileged APIs
// in renderer_extension_bindings.js.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Stubs) {
  ASSERT_TRUE(test_server()->Start());

  ASSERT_TRUE(RunExtensionTest("stubs")) << message_;

  // Navigate to a simple http:// page, which should get the content script
  // injected and run the rest of the test.
  GURL url(test_server()->GetURL("file/extensions/test_file.html"));
  ui_test_utils::NavigateToURL(browser(), url);

  ResultCatcher catcher;
  ASSERT_TRUE(catcher.GetNextResult());
}

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

#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/ui_test_utils.h"
#include "googleurl/src/gurl.h"
#include "net/test/test_server.h"

// Tests that we throw errors when you try using extension APIs that aren't
// supported in content scripts.
//
// If you have added a new API to extension_api.json and this test starts
// failing, most likely you need to either mark it as "unprivileged" (if it
// should be available in content scripts) or update the list of privileged APIs
// in renderer_extension_bindings.js.
// Timey-outy on mac. http://crbug.com/89116
#if defined(OS_MACOSX)
#define MAYBE_Stubs DISABLED_Stubs
#else
#define MAYBE_Stubs Stubs
#endif
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Stubs) {
  ASSERT_TRUE(test_server()->Start());

  ASSERT_TRUE(RunExtensionTest("stubs")) << message_;

  // Navigate to a simple http:// page, which should get the content script
  // injected and run the rest of the test.
  GURL url(test_server()->GetURL("file/extensions/test_file.html"));
  ui_test_utils::NavigateToURL(browser(), url);

  ResultCatcher catcher;
  ASSERT_TRUE(catcher.GetNextResult());
}

Mark ExtensionApiTest.Stubs as disabled on mac due to timeouts.


// Copyright 2016 Mitchell Kember. Subject to the MIT License.
// Project Euler: Problem 44
// Coded triangle numbers

namespace problem_44 {

long nth_pentagonal_number(const long n) {
	return n * (3 * n - 1) / 2;
}

bool is_pentagonal(const long n) {
	const long limit = n / 2 + 1;
	const long two_n = n * 2;
	for (long i = 0; i <= limit; ++i) {
		if (i * (3 * i - 1) == two_n) {
			return true;
		}
	}
	return false;
}

long solve() {
	return 1;
}

} // namespace problem_44

// Copyright 2016 Mitchell Kember. Subject to the MIT License.
// Project Euler: Problem 44
// Coded triangle numbers

#include <cstdio>
#include <cmath>

namespace problem_44 {

long nth_pentagonal_number(const long n) {
	return n * (3 * n - 1) / 2;
}

bool is_pentagonal(const long n) {
	const long limit = n / 2 + 1;
	const long two_n = n * 2;
	for (long i = 0; i <= limit; ++i) {
		if (i * (3 * i - 1) == two_n) {
			return true;
		}
	}
	return false;
}

long solve() {
	for (long i = 1; true; ++i) {
		const long n = nth_pentagonal_number(i);
		printf("trying %ld\n", n);

		const long limit_j = (n-1)/3;
		for (long j = 1; j <= limit_j; ++j) {
			const long first = nth_pentagonal_number(j);
			for (long k = (long)(1 + sqrt(1+24*(n+first)))/6+1; true; ++k) {
				const long second = nth_pentagonal_number(k);
				const long diff = second - first;
				// printf("%ld - %ld = %ld\n", second, first, diff);
				if (diff == n) {
					if (is_pentagonal(first + second)) {
						return n;
					}
					break;
				}
				if (diff > n) {
					break;
				}
			}
		}
	}
}

} // namespace problem_44

Work on Problem 44 some more


/******************************************************************************
 * The MIT License (MIT)
 *
 * Copyright (c) 2016-2017 Baldur Karlsson
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 ******************************************************************************/

#include "os/posix/posix_hook.h"

void PosixHookInit()
{
}

void PosixHookLibrary(const char *name, dlopenCallback cb)
{
}

/******************************************************************************
 * The MIT License (MIT)
 *
 * Copyright (c) 2016-2017 Baldur Karlsson
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 ******************************************************************************/

#include "os/posix/posix_hook.h"

#include <dlfcn.h>

void PosixHookInit()
{
}

void PosixHookLibrary(const char *name, dlopenCallback cb)
{
  cb(dlopen(name, RTLD_NOW));
}

Load wrapped library early in case of Android


//===-- MSP430MCAsmInfo.cpp - MSP430 asm properties -----------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the declarations of the MSP430MCAsmInfo properties.
//
//===----------------------------------------------------------------------===//

#include "MSP430MCAsmInfo.h"
using namespace llvm;

MSP430MCAsmInfo::MSP430MCAsmInfo(const Target &T, const StringRef &TT) {
  AlignmentIsInBytes = false;
  AllowNameToStartWithDigit = true;
}

//===-- MSP430MCAsmInfo.cpp - MSP430 asm properties -----------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the declarations of the MSP430MCAsmInfo properties.
//
//===----------------------------------------------------------------------===//

#include "MSP430MCAsmInfo.h"
using namespace llvm;

MSP430MCAsmInfo::MSP430MCAsmInfo(const Target &T, const StringRef &TT) {
  AlignmentIsInBytes = false;
  AllowNameToStartWithDigit = true;
  PrivateGlobalPrefix = ".L";
}

Use '.L' for global private prefix (as mspgcc)


// 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 "sandbox/linux/seccomp-bpf/trap.h"

#include <signal.h>

#include "sandbox/linux/tests/unit_tests.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace sandbox {
namespace {

SANDBOX_TEST_ALLOW_NOISE(Trap, SigSysAction) {
  // This creates a global Trap instance, and registers the signal handler
  // (Trap::SigSysAction).
  Trap::Registry();

  // Send SIGSYS to self. If signal handler (SigSysAction) is not registered,
  // the process will be terminated with status code -SIGSYS.
  // Note that, SigSysAction handler would output an error message
  // "Unexpected SIGSYS received." so it is necessary to allow the noise.
  raise(SIGSYS);
}

}  // namespace
}  // namespace sandbox

// 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 "sandbox/linux/seccomp-bpf/trap.h"

#include <signal.h>

#include "sandbox/linux/tests/unit_tests.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace sandbox {
namespace {

#if !defined(THREAD_SANITIZER)
SANDBOX_TEST_ALLOW_NOISE(Trap, SigSysAction) {
  // This creates a global Trap instance, and registers the signal handler
  // (Trap::SigSysAction).
  Trap::Registry();

  // Send SIGSYS to self. If signal handler (SigSysAction) is not registered,
  // the process will be terminated with status code -SIGSYS.
  // Note that, SigSysAction handler would output an error message
  // "Unexpected SIGSYS received." so it is necessary to allow the noise.
  raise(SIGSYS);
}
#endif

}  // namespace
}  // namespace sandbox

Disable the failing Trap.SigSysAction test under TSan.


/****************************************************************************
 * Copyright (c) 2012-2019 by the DataTransferKit authors                   *
 * All rights reserved.                                                     *
 *                                                                          *
 * This file is part of the DataTransferKit library. DataTransferKit is     *
 * distributed under a BSD 3-clause license. For the licensing terms see    *
 * the LICENSE file in the top-level directory.                             *
 *                                                                          *
 * SPDX-License-Identifier: BSD-3-Clause                                    *
 ****************************************************************************/

#include <DTK_Search_Exception.hpp>

#include <boost/test/unit_test.hpp>

#define BOOST_TEST_MODULE DesignByContract

BOOST_AUTO_TEST_CASE( dumb )
{
    using namespace DataTransferKit;
    BOOST_CHECK_NO_THROW( DTK_SEARCH_ASSERT( true ) );
    BOOST_CHECK_THROW( DTK_SEARCH_ASSERT( false ), SearchException );
    std::string const prefix = "DTK Search exception: ";
    std::string const message = "Keep calm and chive on!";
    BOOST_CHECK_EXCEPTION( throw SearchException( message ), SearchException,
                           [&]( SearchException const &e ) {
                               return prefix + message == e.what();
                           } );
}

/****************************************************************************
 * Copyright (c) 2012-2019 by the DataTransferKit authors                   *
 * All rights reserved.                                                     *
 *                                                                          *
 * This file is part of the DataTransferKit library. DataTransferKit is     *
 * distributed under a BSD 3-clause license. For the licensing terms see    *
 * the LICENSE file in the top-level directory.                             *
 *                                                                          *
 * SPDX-License-Identifier: BSD-3-Clause                                    *
 ****************************************************************************/

#include <DTK_Search_Exception.hpp>

#include <boost/test/unit_test.hpp>

#define BOOST_TEST_MODULE DesignByContract

BOOST_AUTO_TEST_CASE( dumb )
{
    using namespace DataTransferKit;
    BOOST_CHECK_NO_THROW( DTK_SEARCH_ASSERT( true ) );
    std::string const prefix = "DTK Search exception: ";
    BOOST_CHECK_EXCEPTION(
        DTK_SEARCH_ASSERT( false ), SearchException,
        [&]( std::exception const &e ) {
            std::string const message = e.what();
            bool const message_starts_with_prefix = message.find( prefix ) == 0;
            bool const message_contains_filename =
                message.find( __FILE__ ) != std::string::npos;
            return message_starts_with_prefix && message_contains_filename;
        } );
    std::string const message = "Keep calm and chive on!";
    BOOST_CHECK_EXCEPTION( throw SearchException( message ), SearchException,
                           [&]( SearchException const &e ) {
                               return prefix + message == e.what();
                           } );
}

Check assertion macro message starts with prefix and contains filename


//Some useful equations
int main(){
  //area portion of a circle
  A = pi*r^2 * (theta/(2*pi))
  //area chord of a circle
  A = R * R * acos((R - h)/R) - (R - h) * sqrt(2 * R * h - h * h)
    // h is the height of the chord

}

//Some useful equations
int main(){
  //area portion of a circle
  A = pi*r^2 * (theta/(2*pi))
  //area chord of a circle
  A = R * R * acos((R - h)/R) - (R - h) * sqrt(2 * R * h - h * h)
    // h is the height of the chord h = R - hypot(x,y)
  // rotation matrix counnterclockwise
  [x' y'] = [[cost -sint] [sint cost]][x y]
  // rotation matrix clockwise
  [x' y'] = [[cost sint] [-sint cost]][x y]
}

Add rotation matrix , clockwise and counterclockwise.


// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest LLC.
//
// 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 <gtest/gtest.h>
#include <SurgSim/Framework/Runtime.h>
#include <SurgSim/Framework/Scene.h>

using namespace SurgSim::Framework;

TEST(SceneTest, ConstructorTest)
{
	ASSERT_NO_THROW( {Scene scene;});
}

// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest LLC.
//
// 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 <gtest/gtest.h>
#include "MockObjects.h"
#include <SurgSim/Framework/Runtime.h>
#include <SurgSim/Framework/Scene.h>

using namespace SurgSim::Framework;

TEST(SceneTest, ConstructorTest)
{
	ASSERT_NO_THROW( {Scene scene;});
}

TEST(SceneTest, ElementManagement)
{
	std::shared_ptr<Scene> scene(new Scene());
	std::shared_ptr<MockSceneElement> element1(new MockSceneElement("one"));
	std::shared_ptr<MockSceneElement> element2(new MockSceneElement("two"));

	EXPECT_EQ(0, scene->getSceneElements().size());

	EXPECT_TRUE(scene->addSceneElement(element1));
	EXPECT_EQ(1, scene->getSceneElements().size());
	EXPECT_TRUE(scene->addSceneElement(element2));
	EXPECT_EQ(2, scene->getSceneElements().size());

	EXPECT_FALSE(scene->addSceneElement(element1));
	EXPECT_EQ(2, scene->getSceneElements().size());

	EXPECT_EQ(element1, scene->getSceneElement("one"));
	EXPECT_EQ(element2, scene->getSceneElement("two"));
	EXPECT_EQ(nullptr, scene->getSceneElement("nonexistentelement"));
}

Add tests for Scene, SceneElement access


/*
 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
 *
 * 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.
 *
 */

// CLASS HEADER
#include "color-controller-impl.h"

namespace Dali
{

namespace Internal
{

namespace Adaptor
{

Dali::ColorController ColorController::Get()
{
  Dali::ColorController colorController;
  return colorController;
}

ColorController::ColorController()
{
}

ColorController::~ColorController()
{
}

bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue )
{
  return false;
}

bool ColorController::RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor)
{
  return false;
}

} // namespace Adaptor

} // namespace Internal

} // namespace Dali

/*
 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
 *
 * 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.
 *
 */

// CLASS HEADER
#include "color-controller-impl.h"

namespace Dali
{

namespace Internal
{

namespace Adaptor
{

Dali::ColorController ColorController::Get()
{
  return Dali::ColorController( new ColorController() );
}

ColorController::ColorController()
{
}

ColorController::~ColorController()
{
}

bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue )
{
  return false;
}

bool ColorController::RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor)
{
  return false;
}

} // namespace Adaptor

} // namespace Internal

} // namespace Dali

Fix for ColorController. Creates an internal implementation for the default color controller to avoid a crash if it's called.


// Test that -Weverything does not trigger any backend remarks.
//
// This was triggering backend remarks for which there were no frontend
// flags to filter them. The handler in BackendConsumer::DiagnosticHandlerImpl
// should not emitting diagnostics for unhandled kinds.

// RUN: %clang -c -Weverything -O0 -o /dev/null %s 2> %t.err
// RUN: FileCheck < %t.err %s

typedef __char32_t char32_t;
typedef long unsigned int size_t;
template <class _CharT>
struct __attribute__((__type_visibility__("default"))) char_traits;

template <>
struct __attribute__((__type_visibility__("default"))) char_traits<char32_t> {
  typedef char32_t char_type;
  static void assign(char_type& __c1, const char_type& __c2) throw() {
    __c1 = __c2;
  }
  static char_type* move(char_type* __s1, const char_type* __s2, size_t __n);
};
char32_t* char_traits<char32_t>::move(char_type* __s1, const char_type* __s2,
                                      size_t __n) {
  { assign(*--__s1, *--__s2); }
}

// CHECK-NOT: {{^remark:}}

// Test that -Weverything does not trigger any backend remarks.
//
// This was triggering backend remarks for which there were no frontend
// flags to filter them. The handler in BackendConsumer::DiagnosticHandlerImpl
// should not emitting diagnostics for unhandled kinds.

// RUN: %clang -c -S -Weverything -O0 -o /dev/null %s 2> %t.err
// RUN: FileCheck < %t.err %s

typedef __char32_t char32_t;
typedef long unsigned int size_t;
template <class _CharT>
struct __attribute__((__type_visibility__("default"))) char_traits;

template <>
struct __attribute__((__type_visibility__("default"))) char_traits<char32_t> {
  typedef char32_t char_type;
  static void assign(char_type& __c1, const char_type& __c2) throw() {
    __c1 = __c2;
  }
  static char_type* move(char_type* __s1, const char_type* __s2, size_t __n);
};
char32_t* char_traits<char32_t>::move(char_type* __s1, const char_type* __s2,
                                      size_t __n) {
  { assign(*--__s1, *--__s2); }
}

// CHECK-NOT: {{^remark:}}

Add missing -S to avoid invoking assembler unnecessarily.


#include "agent_based_epidemic_sim/util/records.h"

namespace abesim {

constexpr int kReadFlag = O_RDONLY;
constexpr int kWriteFlag = O_CREAT | O_WRONLY;

riegeli::RecordReader<RiegeliBytesSource> MakeRecordReader(
    absl::string_view filename) {
  return riegeli::RecordReader<RiegeliBytesSource>(
      std::forward_as_tuple(filename, kReadFlag));
}
riegeli::RecordWriter<RiegeliBytesSink> MakeRecordWriter(
    absl::string_view filename, const int parallelism) {
  return riegeli::RecordWriter<RiegeliBytesSink>(
      std::forward_as_tuple(filename, kWriteFlag),
      riegeli::RecordWriterBase::Options().set_parallelism(parallelism));
}

}  // namespace abesim

#include "agent_based_epidemic_sim/util/records.h"

namespace abesim {

constexpr int kReadFlag = O_RDONLY;
constexpr int kWriteFlag = O_CREAT | O_WRONLY;

riegeli::RecordReader<RiegeliBytesSource> MakeRecordReader(
    absl::string_view filename) {
  return riegeli::RecordReader(RiegeliBytesSource(filename, kReadFlag));
}
riegeli::RecordWriter<RiegeliBytesSink> MakeRecordWriter(
    absl::string_view filename, const int parallelism) {
  return riegeli::RecordWriter(
      RiegeliBytesSink(filename, kWriteFlag),
      riegeli::RecordWriterBase::Options().set_parallelism(parallelism));
}

}  // namespace abesim

Improve readability of constructor calls of Riegeli classes.


/**
 * \file
 * \brief chip::lowLevelInitialization() implementation for STM32L0
 *
 * \author Copyright (C) 2017 Cezary Gapinski cezary.gapinski@gmail.com
 *
 * \par License
 * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
 * distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include "distortos/chip/lowLevelInitialization.hpp"

namespace distortos
{

namespace chip
{

/*---------------------------------------------------------------------------------------------------------------------+
| global functions
+---------------------------------------------------------------------------------------------------------------------*/

void lowLevelInitialization()
{

}

}	// namespace chip

}	// namespace distortos

/**
 * \file
 * \brief chip::lowLevelInitialization() implementation for STM32L0
 *
 * \author Copyright (C) 2017 Cezary Gapinski cezary.gapinski@gmail.com
 *
 * \par License
 * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
 * distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include "distortos/chip/lowLevelInitialization.hpp"

#include "distortos/chip/STM32L0-FLASH.hpp"

namespace distortos
{

namespace chip
{

/*---------------------------------------------------------------------------------------------------------------------+
| global functions
+---------------------------------------------------------------------------------------------------------------------*/

void lowLevelInitialization()
{
#ifdef CONFIG_CHIP_STM32L0_FLASH_PREFETCH_ENABLE
	configurePrefetchBuffer(true);
#else	// !def CONFIG_CHIP_STM32L0_FLASH_PREFETCH_ENABLE
	configurePrefetchBuffer(false);
#endif	// !def CONFIG_CHIP_STM32L0_FLASH_PREFETCH_ENABLE
}

}	// namespace chip

}	// namespace distortos

Handle flash options in chip::lowLevelInitialization() for STM32L0


// Copyright (c) 2008-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/history/history_publisher.h"

#include "base/utf_string_conversions.h"

namespace history {

const char* const HistoryPublisher::kThumbnailImageFormat = "image/jpeg";

void HistoryPublisher::PublishPageThumbnail(
    const std::vector<unsigned char>& thumbnail, const GURL& url,
    const base::Time& time) const {
  PageData page_data = {
    time,
    url,
    NULL,
    NULL,
    kThumbnailImageFormat,
    &thumbnail,
  };

  PublishDataToIndexers(page_data);
}

void HistoryPublisher::PublishPageContent(const base::Time& time,
                                          const GURL& url,
                                          const std::wstring& title,
                                          const string16& contents) const {
  PageData page_data = {
    time,
    url,
    UTF16ToWide(contents).c_str(),
    title.c_str(),
    NULL,
    NULL,
  };

  PublishDataToIndexers(page_data);
}

}  // namespace history

// Copyright (c) 2008-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/history/history_publisher.h"

#include "base/utf_string_conversions.h"

namespace history {

const char* const HistoryPublisher::kThumbnailImageFormat = "image/jpeg";

void HistoryPublisher::PublishPageThumbnail(
    const std::vector<unsigned char>& thumbnail, const GURL& url,
    const base::Time& time) const {
  PageData page_data = {
    time,
    url,
    NULL,
    NULL,
    kThumbnailImageFormat,
    &thumbnail,
  };

  PublishDataToIndexers(page_data);
}

void HistoryPublisher::PublishPageContent(const base::Time& time,
                                          const GURL& url,
                                          const std::wstring& title,
                                          const string16& contents) const {
  std::wstring wide_contents = UTF16ToWide(contents);
  PageData page_data = {
    time,
    url,
    wide_contents.c_str(),
    title.c_str(),
    NULL,
    NULL,
  };

  PublishDataToIndexers(page_data);
}

}  // namespace history

Make sure the pointer in PageData::html remains valid while PageData is called.


// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/

#include <tao/pegtl.hpp>
#include <tao/pegtl/contrib/json.hpp>
#include <tao/pegtl/contrib/trace2.hpp>

namespace pegtl = TAO_PEGTL_NAMESPACE;

using grammar = pegtl::must< pegtl::json::text >;

int main( int argc, char** argv )  // NOLINT(bugprone-exception-escape)
{
   for( int i = 1; i < argc; ++i ) {
      std::cout << "Parsing " << argv[ i ] << std::endl;
      pegtl::argv_input in( argv, i );
      pegtl::trace< grammar >( in );
   }
   return 0;
}

// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/

#include <tao/pegtl.hpp>
#include <tao/pegtl/contrib/json.hpp>
#include <tao/pegtl/contrib/trace2.hpp>

namespace pegtl = TAO_PEGTL_NAMESPACE;

using grammar = pegtl::must< pegtl::json::text, pegtl::eof >;

int main( int argc, char** argv )  // NOLINT(bugprone-exception-escape)
{
   for( int i = 1; i < argc; ++i ) {
      std::cout << "Parsing " << argv[ i ] << std::endl;
      pegtl::argv_input in( argv, i );
      pegtl::trace< grammar >( in );
   }
   return 0;
}

Fix grammar to check for complete text


// RUN: rm -rf %t

// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/modules.cache \
// RUN:  -I %S/Inputs/odr_hash-Friend \
// RUN:  -emit-obj -o /dev/null \
// RUN:  -fmodules \
// RUN:  -fimplicit-module-maps \
// RUN:  -fmodules-cache-path=%t/modules.cache \
// RUN:  -std=c++11 -x c++ %s -verify

// expected-no-diagnostics

#include "Box.h"
#include "M1.h"
#include "M3.h"

void Run() {
  Box<> Present;
}

// RUN: rm -rf %t

// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/modules.cache \
// RUN:  -I %S/Inputs/odr_hash-Friend \
// RUN:  -emit-obj -o /dev/null \
// RUN:  -fmodules \
// RUN:  -fimplicit-module-maps \
// RUN:  -fmodules-cache-path=%t/modules.cache \
// RUN:  -std=c++11 -x c++ %s -verify

// UNSUPPORTED: windows

// expected-no-diagnostics

#include "Box.h"
#include "M1.h"
#include "M3.h"

void Run() {
  Box<> Present;
}

Disable test for Windows to fix Windows buildbots.


#include "stdafx.h"
#include "UserTypeToString.h"

UserTypeToString::UserTypeToString(std::string name, int age, double netWorth) : name(name), age(age), netWorth(netWorth)
{
}

UserTypeToString::~UserTypeToString()
{
}

std::ostream& operator<<(std::ostream& os, const UserTypeToString& obj)
{
    // write obj to stream
    os << "name - " << obj.name.c_str() << " age - " << obj.age << " netWorth - " << obj.netWorth;
    return os;
}

#include "stdafx.h"
#include "UserTypeToString.h"

UserTypeToString::UserTypeToString(std::string name, int age, double netWorth) : name(name), age(age), netWorth(netWorth)
{
}

UserTypeToString::~UserTypeToString()
{
}

/* when streaming an instance of this type to an ostream of any kind this function will build the string
   containing the state of the object.
*/
std::ostream& operator<<(std::ostream& os, const UserTypeToString& obj)
{
    // write obj to stream
    os << "name - " << obj.name.c_str() << " age - " << obj.age << " netWorth - " << obj.netWorth;
    return os;
}

Add function header to operator<< implementation


//===-- RISCVTargetInfo.cpp - RISCV Target Implementation -----------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "llvm/Support/TargetRegistry.h"
using namespace llvm;

namespace llvm {
Target &getTheRISCV32Target() {
  static Target TheRISCV32Target;
  return TheRISCV32Target;
}

Target &getTheRISCV64Target() {
  static Target TheRISCV64Target;
  return TheRISCV64Target;
}
}

extern "C" void LLVMInitializeRISCVTargetInfo() {
  RegisterTarget<Triple::riscv32> X(getTheRISCV32Target(), "riscv32",
                                    "32-bit RISC-V");
  RegisterTarget<Triple::riscv64> Y(getTheRISCV64Target(), "riscv64",
                                    "64-bit RISC-V");
}

//===-- RISCVTargetInfo.cpp - RISCV Target Implementation -----------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "llvm/Support/TargetRegistry.h"
using namespace llvm;

namespace llvm {
Target &getTheRISCV32Target() {
  static Target TheRISCV32Target;
  return TheRISCV32Target;
}

Target &getTheRISCV64Target() {
  static Target TheRISCV64Target;
  return TheRISCV64Target;
}
}

extern "C" void LLVMInitializeRISCVTargetInfo() {
  RegisterTarget<Triple::riscv32> X(getTheRISCV32Target(), "riscv32",
                                    "32-bit RISC-V", "RISCV");
  RegisterTarget<Triple::riscv64> Y(getTheRISCV64Target(), "riscv64",
                                    "64-bit RISC-V", "RISCV");
}

Fix RISCV build after r318352


// When we link a binary without the -debug flag, ASan should print out VAs
// instead of RVAs. The frames for main and do_uaf should be above 0x400000,
// which is the default image base of an executable.

// RUN: rm -f %t.pdb
// RUN: %clangxx_asan -c -O2 %s -o %t.obj
// RUN: link /nologo /OUT:%t.exe %t.obj %asan_lib %asan_cxx_lib
// RUN: not %run %t.exe 2>&1 | FileCheck %s

#include <stdlib.h>
#include <stdio.h>
int __attribute__((noinline)) do_uaf(void);
int main() {
  int r = do_uaf();
  printf("r: %d\n", r);
  return r;
}
int do_uaf(void) {
  char *x = (char*)malloc(10 * sizeof(char));
  free(x);
  return x[5];
  // CHECK: AddressSanitizer: heap-use-after-free
  // CHECK: #0 {{0x[a-f0-9]+ \(.*[\\/]unsymbolized.cc.*.exe\+0x40[a-f0-9]{4}\)}}
  // CHECK: #1 {{0x[a-f0-9]+ \(.*[\\/]unsymbolized.cc.*.exe\+0x40[a-f0-9]{4}\)}}
}

// When we link a binary without the -debug flag, ASan should print out VAs
// instead of RVAs. The frames for main and do_uaf should be above 0x400000,
// which is the default image base of an executable.

// RUN: rm -f %t.pdb
// RUN: %clangxx_asan -c -O2 %s -o %t.obj
// RUN: link /nologo /OUT:%t.exe %t.obj %asan_lib %asan_cxx_lib
// RUN: not %run %t.exe 2>&1 | FileCheck %s

#include <stdlib.h>
#include <stdio.h>
int __attribute__((noinline)) do_uaf(void);
int main() {
  int r = do_uaf();
  printf("r: %d\n", r);
  return r;
}
int do_uaf(void) {
  char *x = (char*)malloc(10 * sizeof(char));
  free(x);
  return x[5];
  // CHECK: AddressSanitizer: heap-use-after-free
  // CHECK: #0 {{0x[a-f0-9]+ \(.*[\\/]unsymbolized.cc.*.exe\+(0x40|0x14000)[a-f0-9]{4}\)}}
  // CHECK: #1 {{0x[a-f0-9]+ \(.*[\\/]unsymbolized.cc.*.exe\+(0x40|0x14000)[a-f0-9]{4}\)}}
}

Fix unsymbolize unittest. Adding win64 address.


#include "../lib/shared_mem.hpp"
#include <iostream>

std::shared_ptr<cs477::shm_pool> pool;
std::shared_ptr<cs477::bounded_queue<cs477::message, 1024>> rq_queue;
std::shared_ptr<cs477::bounded_queue<cs477::message, 1024>> rp_queue;

int main(int argc, char **argv) {
	pool = std::make_shared<cs477::shm_pool>();
	pool->create("primes-pool", 4096, 16384);
	rq_queue = std::make_shared<cs477::bounded_queue<cs477::message, 1024>>();
	rq_queue->create("primes-rq-queue");
	rp_queue = std::make_shared<cs477::bounded_queue<cs477::message, 1024>>();
	rp_queue->create("primes-rp-queue");
	std::cout << "test" << std::endl;
	std::cin.get();
  return 0;
}

#include "../lib/shared_mem.hpp"
#include <iostream>

const int PROCESS_COUNT = 3;

std::shared_ptr<cs477::shm_pool> pool;
std::shared_ptr<cs477::bounded_queue<cs477::message, 1024>> rq_queue;
std::shared_ptr<cs477::bounded_queue<cs477::message, 1024>> rp_queue;

int main(int argc, char **argv) {
	pool = std::make_shared<cs477::shm_pool>();
	pool->create("primes-pool", 4096, 16384);
	rq_queue = std::make_shared<cs477::bounded_queue<cs477::message, 1024>>();
	rq_queue->create("primes-rq-queue");
	rp_queue = std::make_shared<cs477::bounded_queue<cs477::message, 1024>>();
	rp_queue->create("primes-rp-queue");

	for (auto i = 0; i < PROCESS_COUNT; ++i) {
		cs477::buffer prime_block{pool};
		prime_block.allocate(4);
		rq_queue->write(prime_block.make_message());
	}

	std::cout << "test" << std::endl;
	std::cin.get();
  return 0;
}

Add progress for the night


/* RTcmix  - Copyright (C) 2000  The RTcmix Development Team
   See ``AUTHORS'' for a list of contributors. See ``LICENSE'' for
   the license to this software and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "../sys/mixerr.h"

extern "C" double checkInsts(char*, double*, short);

extern "C" {
	double rtdispatch(char *fname, double *pp, short n_args)
	{
		double rv;

		rv = checkInsts(fname, pp, n_args);
		return rv;
	}
}

/* RTcmix  - Copyright (C) 2000  The RTcmix Development Team
   See ``AUTHORS'' for a list of contributors. See ``LICENSE'' for
   the license to this software and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include <prototypes.h>
#include "../sys/mixerr.h"

extern "C" {
	double rtdispatch(char *fname, double *pp, short n_args)
	{
		double rv;

		rv = checkInsts(fname, pp, n_args);
		return rv;
	}
}

Move some prototypes to prototypes.h.


#include <wtl/string.hpp>
#include <wtl/exception.hpp>

#include <iostream>

int main() {
    std::cout << "__cplusplus: " << __cplusplus << std::endl;
    WTL_ASSERT((wtl::split("a b\tc") == std::vector<std::string>{"a", "b", "c"}));
    WTL_ASSERT((wtl::split<int>("1 2\t3") == std::vector<int>{1, 2, 3}));
    WTL_ASSERT(wtl::strip("  str  ") == "str");
    WTL_ASSERT(wtl::startswith("prefix", "pre"));
    WTL_ASSERT(!wtl::startswith("prefix", "post"));
    WTL_ASSERT(wtl::endswith("suffix", "fix"));
    WTL_ASSERT(!wtl::endswith("suffix", "suf"));
    return 0;
}

#include <wtl/string.hpp>
#include <wtl/exception.hpp>

#include <iostream>

void test_sto() {
    WTL_ASSERT(wtl::sto<bool>("1"));
    WTL_ASSERT(wtl::sto<int>("42") == 42);
    WTL_ASSERT(wtl::sto<long>("1729") == 1729l);
    WTL_ASSERT(wtl::sto<long long>("24601") == 24601ll);
    WTL_ASSERT(wtl::sto<unsigned>("42") == 42u);
    WTL_ASSERT(wtl::sto<unsigned long>("1729") == 1729ul);
    WTL_ASSERT(wtl::sto<unsigned long long>("24601") == 24601ull);
    WTL_ASSERT(wtl::sto<double>("3.14") - 3.14 < 1e-9);
}

int main() {
    std::cout << "__cplusplus: " << __cplusplus << std::endl;
    test_sto();
    WTL_ASSERT((wtl::split("a b\tc") == std::vector<std::string>{"a", "b", "c"}));
    WTL_ASSERT((wtl::split<int>("1 2\t3") == std::vector<int>{1, 2, 3}));
    WTL_ASSERT(wtl::strip("  str  ") == "str");
    WTL_ASSERT(wtl::startswith("abracadabra", "abr"));
    WTL_ASSERT(!wtl::startswith("abracadabra", "bra"));
    WTL_ASSERT(wtl::endswith("abracadabra", "bra"));
    WTL_ASSERT(!wtl::endswith("abracadabra", "abr"));
    WTL_ASSERT(wtl::replace("abracadabra", "br", "_") == "a_acada_a");
    return 0;
}

Add tests for sto() and replace()


#include "llvm/runner.hpp"

Runner::Runner(CompileVisitor::Link v): v(v) {
  llvm::InitializeNativeTarget();
  llvm::InitializeNativeTargetAsmPrinter();
  llvm::InitializeNativeTargetAsmParser();

  std::string onError = "";
  auto eb = new llvm::EngineBuilder(std::unique_ptr<llvm::Module>(v->getModule()));
  engine = eb
    ->setErrorStr(&onError)
    .setEngineKind(llvm::EngineKind::JIT)
    .create();
  for (const auto& pair : nameToFunPtr) {
    engine->addGlobalMapping(v->getModule()->getFunction(pair.first), pair.second);
  }
  engine->finalizeObject();
  if (onError != "") throw InternalError("ExecutionEngine error", {
    METADATA_PAIRS,
    {"supplied error string", onError}
  });
}

int Runner::run() {
  return engine->runFunctionAsMain(v->getEntryPoint(), {}, {});
}

ProgramResult Runner::runAndCapture() {
  // Capture stdout
  char buf[8192];
  std::fflush(stdout);
  std::freopen("/dev/null", "a", stdout);
  std::setbuf(stdout, buf);
  // Run program
  int exitCode = run();
  // Stop capturing stdout
  std::freopen("/dev/tty", "a", stdout);
  return {exitCode, buf};
}

#include "llvm/runner.hpp"

Runner::Runner(CompileVisitor::Link v): v(v) {
  llvm::InitializeNativeTarget();
  llvm::InitializeNativeTargetAsmPrinter();
  llvm::InitializeNativeTargetAsmParser();

  std::string onError = "";
  auto eb = new llvm::EngineBuilder(std::unique_ptr<llvm::Module>(v->getModule()));
  engine = eb
    ->setErrorStr(&onError)
    .setEngineKind(llvm::EngineKind::JIT)
    .create();
  for (const auto& pair : nameToFunPtr) {
    auto funPtr = v->getModule()->getFunction(pair.first);
    if (funPtr == nullptr) continue; // Function not used
    engine->addGlobalMapping(funPtr, pair.second);
  }
  engine->finalizeObject();
  if (onError != "") throw InternalError("ExecutionEngine error", {
    METADATA_PAIRS,
    {"supplied error string", onError}
  });
}

int Runner::run() {
  return engine->runFunctionAsMain(v->getEntryPoint(), {}, {});
}

ProgramResult Runner::runAndCapture() {
  // Capture stdout
  char buf[8192];
  std::fflush(stdout);
  std::freopen("/dev/null", "a", stdout);
  std::setbuf(stdout, buf);
  // Run program
  int exitCode = run();
  // Stop capturing stdout
  std::freopen("/dev/tty", "a", stdout);
  return {exitCode, buf};
}

Fix segfault with foreign function mappings


/*
 * ModSecurity, http://www.modsecurity.org/
 * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/)
 *
 * 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
 *
 * If any of the files related to licensing are missing or if you have any
 * other questions related to licensing please contact Trustwave Holdings, Inc.
 * directly using the email address security@modsecurity.org.
 *
 */

#include "src/actions/set_env.h"

#include <iostream>
#include <string>

#include "modsecurity/transaction.h"
#include "modsecurity/rule.h"
#include "src/utils/string.h"

namespace modsecurity {
namespace actions {

bool SetENV::init(std::string *error) {
    return true;
}

bool SetENV::evaluate(RuleWithActions *rule, Transaction *t) {
    std::string colNameExpanded(m_string->evaluate(t));

    auto pair = utils::string::ssplit_pair(colNameExpanded, '=');
    ms_dbg_a(t, 8, "Setting envoriment variable: "
        + pair.first + " to " + pair.second);
    setenv(pair.first.c_str(), pair.second.c_str(), /*overwrite*/ 1);

    return true;
}

}  // namespace actions
}  // namespace modsecurity

/*
 * ModSecurity, http://www.modsecurity.org/
 * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/)
 *
 * 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
 *
 * If any of the files related to licensing are missing or if you have any
 * other questions related to licensing please contact Trustwave Holdings, Inc.
 * directly using the email address security@modsecurity.org.
 *
 */

#include "src/actions/set_env.h"

#include <iostream>
#include <string>

#include "modsecurity/transaction.h"
#include "modsecurity/rule.h"
#include "src/utils/string.h"

namespace modsecurity {
namespace actions {

bool SetENV::init(std::string *error) {
    return true;
}

bool SetENV::evaluate(RuleWithActions *rule, Transaction *t) {
    std::string colNameExpanded(m_string->evaluate(t));

    auto pair = utils::string::ssplit_pair(colNameExpanded, '=');
    ms_dbg_a(t, 8, "Setting environment variable: "
        + pair.first + " to " + pair.second);
    setenv(pair.first.c_str(), pair.second.c_str(), /*overwrite*/ 1);

    return true;
}

}  // namespace actions
}  // namespace modsecurity

Fix typo in debug log text


// Check that stores in signal handlers are not recorded in origin history.
// This is, in fact, undesired behavior caused by our chained origins
// implementation being not async-signal-safe.

// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -m64 -O3 %s -o %t && \
// RUN:     not %run %t >%t.out 2>&1
// RUN: FileCheck %s < %t.out

// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -m64 -O3 %s -o %t && \
// RUN:     not %run %t >%t.out 2>&1
// RUN: FileCheck %s < %t.out

#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

volatile int x, y;

void SignalHandler(int signo) {
  y = x;
}

int main(int argc, char *argv[]) {
  int volatile z;
  x = z;

  signal(SIGUSR1, SignalHandler);
  kill(getpid(), SIGUSR1);
  signal(SIGUSR1, SIG_DFL);

  return y;
}

// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
// CHECK-NOT: in SignalHandler

// Check that stores in signal handlers are not recorded in origin history.
// This is, in fact, undesired behavior caused by our chained origins
// implementation being not async-signal-safe.

// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -m64 -O3 %s -o %t && \
// RUN:     not %run %t >%t.out 2>&1
// RUN: FileCheck %s < %t.out

// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -m64 -O3 %s -o %t && \
// RUN:     not %run %t >%t.out 2>&1
// RUN: FileCheck %s < %t.out

#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

volatile int x, y;

void SignalHandler(int signo) {
  y = x;
}

int main(int argc, char *argv[]) {
  int volatile z;
  x = z;

  signal(SIGHUP, SignalHandler);
  kill(getpid(), SIGHUP);
  signal(SIGHUP, SIG_DFL);

  return y;
}

// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
// CHECK-NOT: in SignalHandler

Use SIGHUP instead of SIGUSR1 in test.


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

#include "views/controls/menu/menu_config.h"

#include "grit/app_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/resource/resource_bundle.h"

namespace views {

// static
MenuConfig* MenuConfig::Create() {
  MenuConfig* config = new MenuConfig();
  ResourceBundle& rb = ResourceBundle::GetSharedInstance();
  config->font = rb.GetFont(ResourceBundle::BaseFont);
  config->arrow_width = rb.GetBitmapNamed(IDR_MENU_ARROW)->width();
  // Add 4 to force some padding between check and label.
  config->check_width = rb.GetBitmapNamed(IDR_MENU_CHECK)->width() + 4;
  config->check_height = rb.GetBitmapNamed(IDR_MENU_CHECK)->height();
  return config;
}

}  // namespace views

// 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 "views/controls/menu/menu_config.h"

#include "grit/app_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/resource/resource_bundle.h"

namespace views {

// static
MenuConfig* MenuConfig::Create() {
  MenuConfig* config = new MenuConfig();
  ResourceBundle& rb = ResourceBundle::GetSharedInstance();
#if defined(TOUCH_UI)
  config->font = rb.GetFont(ResourceBundle::LargeFont);
#else
  config->font = rb.GetFont(ResourceBundle::BaseFont);
#endif
  config->arrow_width = rb.GetBitmapNamed(IDR_MENU_ARROW)->width();
  // Add 4 to force some padding between check and label.
  config->check_width = rb.GetBitmapNamed(IDR_MENU_CHECK)->width() + 4;
  config->check_height = rb.GetBitmapNamed(IDR_MENU_CHECK)->height();
  return config;
}

}  // namespace views

Increase the base font size for touch ui


/*
 * SimNetworkFunctions.cpp
 *
 *  Created on: 18.04.2016
 *      Author: Marc Hartung
 */

#include "../../include/network_impl/SimNetworkFunctions.hpp"

#include <iostream>

namespace NetOff
{
    std::string createStringFromData(const char * data)
    {
        size_t num = getIntegralFromData<size_t>(data);
        const char * start = shift<size_t>(data);
        std::string res(start, num);
        return res;
    }

    size_t getStringDataSize(const std::string & str)
    {
        return sizeof(size_t) + sizeof(char) * (str.size() + 1);  // first is for saving how many chars will be there
    }

    size_t saveStringInData(const std::string & str, char * data)
    {
        char * p = saveShiftIntegralInData<size_t>(str.size(),data);
        for (size_t i = 0; i < str.size(); ++i)
        {
            *p = str[i];
            ++p;
        }
        return getStringDataSize(str);
    }

}

/*
 * SimNetworkFunctions.cpp
 *
 *  Created on: 18.04.2016
 *      Author: Marc Hartung
 */

#include "network_impl/SimNetworkFunctions.hpp"

#include <iostream>

namespace NetOff
{

    std::string createStringFromData(const char * data)
    {
        size_t num = getIntegralFromData<size_t>(data);
        const char * start = shift<size_t>(data);
        std::string res(start, num);
        return res;
    }

    size_t getStringDataSize(const std::string & str)
    {
        return sizeof(size_t) + sizeof(char) * (str.size() + 1);  // first is for saving how many chars will be there
    }

    size_t saveStringInData(const std::string & str, char * data)
    {
        char * p = saveShiftIntegralInData<size_t>(str.size(), data);
        for (auto& elem : str)
        {
            *p = elem;
            ++p;
        }
        return getStringDataSize(str);
    }

} /* End namespace NetOff */

Make use of range based for loop


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

#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "content/public/browser/user_metrics.h"

namespace chromeos {

StatsOptionsHandler::StatsOptionsHandler() {
}

// OptionsPageUIHandler implementation.
void StatsOptionsHandler::GetLocalizedValues(
    DictionaryValue* localized_strings) {
}

void StatsOptionsHandler::Initialize() {
}

// WebUIMessageHandler implementation.
void StatsOptionsHandler::RegisterMessages() {
  web_ui_->RegisterMessageCallback("metricsReportingCheckboxAction",
      base::Bind(&StatsOptionsHandler::HandleMetricsReportingCheckbox,
                 base::Unretained(this)));
}

void StatsOptionsHandler::HandleMetricsReportingCheckbox(
    const ListValue* args) {
#if defined(GOOGLE_CHROME_BUILD)
  const std::string checked_str = UTF16ToUTF8(ExtractStringValue(args));
  const bool enabled = (checked_str == "true");
  UserMetrics::RecordAction(
      enabled ?
      UserMetricsAction("Options_MetricsReportingCheckbox_Enable") :
      UserMetricsAction("Options_MetricsReportingCheckbox_Disable"));
#endif
}

}  // namespace chromeos

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

#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "content/public/browser/user_metrics.h"

using content::UserMetricsAction;

namespace chromeos {

StatsOptionsHandler::StatsOptionsHandler() {
}

// OptionsPageUIHandler implementation.
void StatsOptionsHandler::GetLocalizedValues(
    DictionaryValue* localized_strings) {
}

void StatsOptionsHandler::Initialize() {
}

// WebUIMessageHandler implementation.
void StatsOptionsHandler::RegisterMessages() {
  web_ui_->RegisterMessageCallback("metricsReportingCheckboxAction",
      base::Bind(&StatsOptionsHandler::HandleMetricsReportingCheckbox,
                 base::Unretained(this)));
}

void StatsOptionsHandler::HandleMetricsReportingCheckbox(
    const ListValue* args) {
#if defined(GOOGLE_CHROME_BUILD)
  const std::string checked_str = UTF16ToUTF8(ExtractStringValue(args));
  const bool enabled = (checked_str == "true");
  content::RecordAction(
      enabled ?
      UserMetricsAction("Options_MetricsReportingCheckbox_Enable") :
      UserMetricsAction("Options_MetricsReportingCheckbox_Disable"));
#endif
}

}  // namespace chromeos

Fix CrOS Official build from options2 copy.


#include "Limiter.h"
#include "Testing.h"

#include <iostream>

auto TestWithPeakLoadInTheBeginning(int maxAllowedRps)
{
	const auto startTime = std::chrono::steady_clock::now();
	int sentRequestsCount = 0;

	Limiter limiter(maxAllowedRps, 100);
	for (; sentRequestsCount < maxAllowedRps; ++sentRequestsCount)
	{
		ASSERT_EQUAL(limiter.ValidateRequest(), HttpResult::Code::Ok);
	}
	if (std::chrono::steady_clock::now() < startTime + std::chrono::seconds())
	{
		ASSERT_EQUAL(limiter.ValidateRequest(), HttpResult::Code::TooManyRequests);
	}
}

namespace LimiterSpecs
{
	static constexpr int minRPS = 1;
	static constexpr int maxRPS = 100'000;
};

int main()
{
	try
	{
		TestWithPeakLoadInTheBeginning(LimiterSpecs::maxRPS);
		std::cout << "All Tests passed successfully\n";
	}
	catch (AssertionException& e)
	{
		std::cout << "One or more of tests failed: " << e.what() << '\n';
	}
	system("pause");
	return 0;
}

#include "Limiter.h"
#include "Testing.h"

#include <iostream>

auto TestWithPeakLoadInTheBeginning(int maxAllowedRps)
{
	const auto startTime = std::chrono::steady_clock::now();
	int sentRequestsCount = 0;

	Limiter limiter(maxAllowedRps, 10000);
	for (; sentRequestsCount < maxAllowedRps; ++sentRequestsCount)
	{
		ASSERT_EQUAL(limiter.ValidateRequest(), HttpResult::Code::Ok);
	}
	auto expectedEndResult = std::chrono::steady_clock::now() < startTime + std::chrono::milliseconds(500)
		? HttpResult::Code::Ok
		: HttpResult::Code::TooManyRequests;

	while (std::chrono::steady_clock::now() < startTime + std::chrono::seconds(1))
	{
		ASSERT_EQUAL(limiter.ValidateRequest(), HttpResult::Code::TooManyRequests);
	}
	ASSERT_EQUAL(limiter.ValidateRequest(), HttpResult::Code::TooManyRequests);

	std::this_thread::sleep_until(startTime + std::chrono::milliseconds(1500));
	ASSERT_EQUAL(limiter.ValidateRequest(), expectedEndResult);
}

namespace LimiterSpecs
{
	static constexpr int minRPS = 1;
	static constexpr int maxRPS = 100'000;
};

int main()
{
	try
	{
		TestWithPeakLoadInTheBeginning(LimiterSpecs::maxRPS);
		std::cout << "All Tests passed successfully\n";
	}
	catch (AssertionException& e)
	{
		std::cout << "One or more of tests failed: " << e.what() << '\n';
	}
	system("pause");
	return 0;
}

Fix final condition in test


#include<iostream>
#include<boost/filesystem.hpp>
using namespace boost::filesystem;

//bool CopyDir(path const & source_path, path const & destination_path);

int main(int argc, char *argv[])
{
     if(argc < 3)
     {
          std::cout << "USAGE " << argv[0] << " source destination" << std::endl;
          return 1;
     }
     else
     {
          path source_path = argv[1];
          path destination_path = argv[2];
          if(exists(source_path))
          {
               if(is_regular_file(source_path) == true)
               {
                    copy_file(source_path, destination_path);
                    std::cout << "File has been copied" << std::endl;
               }
               else if(is_directory(source_path) == true)
               {
                    copy_directory(source_path, destination_path);
                    std::cout << "Directory has been copied" << std::endl;
               }
               else
               {
                    std::cerr << "It seems like the specified directory does not exist." << std::endl;
               }
          }
          else
          {
               std::cerr << "The specified directory could not be found" << std::endl;
          }
     }
     return 0;
}

#include<iostream>
#include<boost/filesystem.hpp>
using namespace boost::filesystem;

//bool CopyDir(path const & source_path, path const & destination_path);

int main(int argc, char *argv[])
{
     if(argc < 3)
     {
          std::cout << "USAGE " << argv[0] << " source destination" << std::endl;
          return 1;
     }
     else
     {
          path source_path = argv[1];
          path destination_path = argv[2];
          if(exists(source_path))
          {
               if(is_regular_file(source_path) == true)
               {
                    copy_file(source_path, destination_path); //Link dest path to buffer
                    std::cout << "File has been copied" << std::endl;
               }
               else if(is_directory(source_path) == true)
               {
                    copy_directory(source_path, destination_path);
                    std::cout << "Directory has been copied" << std::endl;
               }
               else
               {
                    std::cerr << "It seems like the specified directory does not exist." << std::endl;
               }
          }
          else
          {
               std::cerr << "The specified directory could not be found" << std::endl;
          }
     }
     return 0;
}

Add comment about linking place


// RUN: %clang_cc1 %s -triple i386-pc-windows-msvc19.0.0 -emit-obj \
// RUN:     -debug-info-kind=line-tables-only -fms-extensions
class __declspec(dllexport) A {
  A(int * = new int) {}
};
// CHECK: define {{.*}}void @"\01??_FA@@AAEXXZ"
// CHECK-SAME: !dbg ![[SP:[0-9]+]]
// CHECK-NOT: {{ret }}
// CHECK: call x86_thiscallcc %class.A* @"\01??0A@@AAE@PAH@Z"(%class.A* %this1, i32* %0)
// CHECK-SAME: !dbg ![[DBG:[0-9]+]]
// CHECK: ret void, !dbg ![[DBG]]
//
// CHECK: ![[SP]] = distinct !DISubprogram(
// CHECK-SAME:          line: 3
// CHECK-SAME:          isDefinition: true
// CHECK-SAME:          DIFlagArtificial
// CHECK-SAME:          ){{$}}
//
// CHECK: ![[DBG]] = !DILocation(line: 0

// RUN: %clang_cc1 %s -triple i386-pc-windows-msvc19.0.0 -emit-llvm \
// RUN:     -debug-info-kind=line-tables-only -fms-extensions -o - | FileCheck %s
class __declspec(dllexport) A {
  A(int * = new int) {}
};
// CHECK: define {{.*}}void @"\01??_FA@@AAEXXZ"
// CHECK-SAME: !dbg ![[SP:[0-9]+]]
// CHECK-NOT: {{ret }}
// CHECK: call x86_thiscallcc %class.A* @"\01??0A@@AAE@PAH@Z"(%class.A* %this1, i32* %0)
// CHECK-SAME: !dbg ![[DBG:[0-9]+]]
// CHECK: ret void, !dbg ![[DBG1:[0-9]+]]
//
// CHECK: ![[SP]] = distinct !DISubprogram(
// CHECK-SAME:          line: 4
// CHECK-SAME:          isDefinition: true
// CHECK-SAME:          DIFlagArtificial
// CHECK-SAME:          ){{$}}
//
// CHECK: ![[DBG1]] = !DILocation(line: 0
// CHECK: ![[DBG]] = !DILocation(line: 0

Add the missing FileCheck invocation to this testcase.


int main()
{
    int *a;
    int *n = a;
    a = n;
    *n = 5;
    return 0;
}

#include <stdio.h>

int main()
{
    int input;
    if (scanf("%d", &input) == 1)
    {
        if (input == 2)
        {
            int *a;
            int *n = a;
            a = n;
            *n = 5;
        }
        else
        {
            printf("OK\n");
        }
    }
    return 0;
}

Add a special condition so that static analyzers could write the exact condition when problem happens


extern "C"
{
    #include "packet_queue.h"
    #include "error.h"
    #include "nrf51.h"
    #include "nrf51_bitfields.h"
}

#include "CppUTest/TestHarness.h"

TEST_GROUP(packet_queue)
{

    void setup(void)
    {
    }

    void teardown(void)
    {
    }
};

TEST(packet_queue, test_packet_queue_init_succeed)
{
    packet_queue_t queue;
    LONGS_EQUAL(SUCCESS, packet_queue_init(&queue));
}

extern "C"
{
    #include "packet_queue.h"
    #include "error.h"
    #include "nrf51.h"
    #include "nrf51_bitfields.h"
}

#include "CppUTest/TestHarness.h"

TEST_GROUP(packet_queue)
{
    packet_queue_t queue;

    void setup(void)
    {
        packet_queue_init(&queue);
    }

    void teardown(void)
    {
    }
};

TEST(packet_queue, test_queue_init_succeed)
{
    packet_queue_t queue;
    LONGS_EQUAL(SUCCESS, packet_queue_init(&queue));
}

TEST(packet_queue, test_queue_new_queue_is_empty)
{
    LONGS_EQUAL(true, packet_queue_is_empty(&queue));
}

TEST(packet_queue, test_queue_add_queue_is_not_empty)
{
    radio_packet_t packet;
    packet_queue_add(&queue, &packet);

    LONGS_EQUAL(false, packet_queue_is_empty(&queue));
}

Test empty and non-empty queue.


#include <osgDB/ImageOptions>

using namespace osgDB;

ImageOptions::ImageOptions()
{
    init();
}

ImageOptions::ImageOptions(const std::string& str)
{
    init();
    _str = str;
}

void ImageOptions::init()
{
    _sourceImageSamplingMode = NEAREST;
    _sourceImageWindowMode = ALL_IMAGE;

    _destinationImageWindowMode = ALL_IMAGE;
}

#include <osgDB/ImageOptions>

using namespace osgDB;

ImageOptions::ImageOptions()
{
    init();
}

ImageOptions::ImageOptions(const std::string& str)
{
    init();
    _str = str;
}

void ImageOptions::init()
{
    _sourceImageSamplingMode = NEAREST;
    _sourceImageWindowMode = ALL_IMAGE;

    _destinationImageWindowMode = ALL_IMAGE;

    _destinationDataType = GL_NONE;
    _destinationPixelFormat = GL_NONE;
}

Set default values for datatype & pixelformat.


#pragma once

#include <threadingzeug/parallelfor.h>

namespace threadingzeug
{

int getNumberOfThreads()
{
	return std::max(static_cast<size_t>(2), static_cast<size_t>(std::thread::hardware_concurrency()));
}

} // namespace threadingzeug

Remove pragma from source file


/* Copyright 2020 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 "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/kernels/mlir_generated/unranked_op_gpu_base.h"

namespace tensorflow {

GENERATE_AND_REGISTER_UNARY_KERNEL(Neg, f16, DT_HALF, Eigen::half);
GENERATE_AND_REGISTER_UNARY_KERNEL(Neg, f32, DT_FLOAT, float);
GENERATE_AND_REGISTER_UNARY_KERNEL(Neg, f64, DT_DOUBLE, double);
GENERATE_AND_REGISTER_UNARY_KERNEL(Neg, i8, DT_INT8, int8);
GENERATE_AND_REGISTER_UNARY_KERNEL(Neg, i16, DT_DOUBLE, int16);
// TODO(b/25387198): We cannot use a regular GPU kernel for int32.
GENERATE_AND_REGISTER_UNARY_KERNEL(Neg, i64, DT_DOUBLE, int64);

}  // namespace tensorflow

/* Copyright 2020 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 "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/kernels/mlir_generated/unranked_op_gpu_base.h"

namespace tensorflow {

GENERATE_AND_REGISTER_UNARY_KERNEL(Neg, f16, DT_HALF, Eigen::half);
GENERATE_AND_REGISTER_UNARY_KERNEL(Neg, f32, DT_FLOAT, float);
GENERATE_AND_REGISTER_UNARY_KERNEL(Neg, f64, DT_DOUBLE, double);
GENERATE_AND_REGISTER_UNARY_KERNEL(Neg, i8, DT_INT8, int8);
GENERATE_AND_REGISTER_UNARY_KERNEL(Neg, i16, DT_INT16, int16);
// TODO(b/25387198): We cannot use a regular GPU kernel for int32.
GENERATE_AND_REGISTER_UNARY_KERNEL(Neg, i64, DT_INT64, int64);

}  // namespace tensorflow

Fix registration for Neg kernel.