Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
build,chakrashim: enabled cpplint for chakrashim
Browse files Browse the repository at this point in the history
* Added support for the `cpplint` argument
* Added support for chakrashim to cpplint
* Updated cpplint filters to match the beginning of the line
* Updated cpplint filters to echo to nul as the message was misleading
* Fixed all cpplint failures in `deps/chakrashim/src`

PR-URL: #287
Reviewed-By: Sandeep Agarwal <saagarwa@microsoft.com>
  • Loading branch information
kfarnung committed Jun 13, 2017
1 parent d94d248 commit fa6b635
Show file tree
Hide file tree
Showing 61 changed files with 721 additions and 657 deletions.
77 changes: 38 additions & 39 deletions deps/chakrashim/src/base/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_BASE_LOGGING_H_
#define V8_BASE_LOGGING_H_
#ifndef DEPS_CHAKRASHIM_SRC_BASE_LOGGING_H_
#define DEPS_CHAKRASHIM_SRC_BASE_LOGGING_H_

#include <cstring>
#include <sstream>
Expand All @@ -30,14 +30,14 @@ void V8_Fatal(const char* file, int line, const char* format, ...);


namespace v8 {
namespace base {

// CHECK dies with a fatal error if condition is not true. It is *not*
// controlled by DEBUG, so the check will be executed regardless of
// compilation mode.
//
// We make sure CHECK et al. always evaluates their arguments, as
// doing CHECK(FunctionWithSideEffect()) is a common idiom.
namespace base {

// CHECK dies with a fatal error if condition is not true. It is *not*
// controlled by DEBUG, so the check will be executed regardless of
// compilation mode.
//
// We make sure CHECK et al. always evaluates their arguments, as
// doing CHECK(FunctionWithSideEffect()) is a common idiom.
#define CHECK(condition) \
do { \
if (V8_UNLIKELY(!(condition))) { \
Expand All @@ -48,8 +48,8 @@ namespace v8 {

#ifdef DEBUG

// Helper macro for binary operators.
// Don't use this macro directly in your code, use CHECK_EQ et al below.
// Helper macro for binary operators.
// Don't use this macro directly in your code, use CHECK_EQ et al below.
#define CHECK_OP(name, op, lhs, rhs) \
do { \
if (std::string* _msg = ::v8::base::Check##name##Impl( \
Expand All @@ -61,41 +61,40 @@ namespace v8 {

#else

// Make all CHECK functions discard their log strings to reduce code
// bloat for official release builds.

// Make all CHECK functions discard their log strings to reduce code
// bloat for official release builds.
#define CHECK_OP(name, op, lhs, rhs) CHECK((lhs)op(rhs))

#endif


// Build the error message string. This is separate from the "Impl"
// function template because it is not performance critical and so can
// be out of line, while the "Impl" code should be inline. Caller
// takes ownership of the returned string.
template <typename Lhs, typename Rhs>
std::string* MakeCheckOpString(Lhs const& lhs, Rhs const& rhs,
char const* msg) {
std::ostringstream ss;
ss << msg << " (" << lhs << " vs. " << rhs << ")";
return new std::string(ss.str());
}

// Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated
// in logging.cc.
// Build the error message string. This is separate from the "Impl"
// function template because it is not performance critical and so can
// be out of line, while the "Impl" code should be inline. Caller
// takes ownership of the returned string.
template <typename Lhs, typename Rhs>
std::string* MakeCheckOpString(Lhs const& lhs, Rhs const& rhs,
char const* msg) {
std::ostringstream ss;
ss << msg << " (" << lhs << " vs. " << rhs << ")";
return new std::string(ss.str());
}

// Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated
// in logging.cc.
#define DEFINE_MAKE_CHECK_OP_STRING(type) \
extern template std::string* MakeCheckOpString<type, type>( \
type const&, type const&, char const*);
DEFINE_MAKE_CHECK_OP_STRING(unsigned long long) // NOLINT(runtime/int)
#undef DEFINE_MAKE_CHECK_OP_STRING


// Helper functions for CHECK_OP macro.
// The (int, int) specialization works around the issue that the compiler
// will not instantiate the template version of the function on values of
// unnamed enum type - see comment below.
// The (float, float) and (double, double) instantiations are explicitly
// externialized to ensure proper 32/64-bit comparisons on x86.
// Helper functions for CHECK_OP macro.
// The (int, int) specialization works around the issue that the compiler
// will not instantiate the template version of the function on values of
// unnamed enum type - see comment below.
// The (float, float) and (double, double) instantiations are explicitly
// externialized to ensure proper 32/64-bit comparisons on x86.
#define DEFINE_CHECK_OP_IMPL(NAME, op) \
template <typename Lhs, typename Rhs> \
V8_INLINE std::string* Check##NAME##Impl(Lhs const& lhs, Rhs const& rhs, \
Expand All @@ -115,12 +114,12 @@ namespace v8 {

#define CHECK_LT(lhs, rhs) CHECK_OP(LT, <, lhs, rhs)

} // namespace base
} // namespace base
} // namespace v8


// The DCHECK macro is equivalent to CHECK except that it only
// generates code in debug builds.
// The DCHECK macro is equivalent to CHECK except that it only
// generates code in debug builds.
#ifdef DEBUG
#define DCHECK(condition) CHECK(condition)
#define DCHECK_LT(v1, v2) CHECK_LT(v1, v2)
Expand All @@ -129,4 +128,4 @@ namespace v8 {
#define DCHECK_LT(v1, v2) ((void) 0)
#endif

#endif // V8_BASE_LOGGING_H_
#endif // DEPS_CHAKRASHIM_SRC_BASE_LOGGING_H_
10 changes: 5 additions & 5 deletions deps/chakrashim/src/base/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_BASE_MACROS_H_
#define V8_BASE_MACROS_H_
#ifndef DEPS_CHAKRASHIM_SRC_BASE_MACROS_H_
#define DEPS_CHAKRASHIM_SRC_BASE_MACROS_H_

#include "logging.h"

Expand All @@ -17,14 +17,14 @@
// Note that the function doesn't need an implementation, as we only
// use its type.
template <typename T, size_t N>
char(&ArraySizeHelper(T(&array)[N]))[N];
char (&ArraySizeHelper(T (&array)[N]))[N];

#if !V8_CC_MSVC
// That gcc wants both of these prototypes seems mysterious. VC, for
// its part, can't decide which to use (another mystery). Matching of
// template overloads: the final frontier.
template <typename T, size_t N>
char(&ArraySizeHelper(const T(&array)[N]))[N];
char (&ArraySizeHelper(const T (&array)[N]))[N];
#endif

// A macro to disallow the evil copy constructor and operator= functions
Expand All @@ -48,4 +48,4 @@ char(&ArraySizeHelper(const T(&array)[N]))[N];
template <typename T>
inline void USE(T) { }

#endif // V8_BASE_MACROS_H_
#endif // DEPS_CHAKRASHIM_SRC_BASE_MACROS_H_
6 changes: 3 additions & 3 deletions deps/chakrashim/src/base/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
// implementation and the overhead of virtual methods for performance
// sensitive like mutex locking/unlocking.

#ifndef V8_BASE_PLATFORM_PLATFORM_H_
#define V8_BASE_PLATFORM_PLATFORM_H_
#ifndef DEPS_CHAKRASHIM_SRC_BASE_PLATFORM_PLATFORM_H_
#define DEPS_CHAKRASHIM_SRC_BASE_PLATFORM_PLATFORM_H_

#include <cstdarg>
#include "src/base/macros.h"
Expand Down Expand Up @@ -48,4 +48,4 @@ class OS {
} // namespace base
} // namespace v8

#endif // V8_BASE_PLATFORM_PLATFORM_H_
#endif // DEPS_CHAKRASHIM_SRC_BASE_PLATFORM_PLATFORM_H_
6 changes: 3 additions & 3 deletions deps/chakrashim/src/inspector/inspected-context.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_INSPECTOR_INSPECTEDCONTEXT_H_
#define V8_INSPECTOR_INSPECTEDCONTEXT_H_
#ifndef DEPS_CHAKRASHIM_SRC_INSPECTOR_INSPECTED_CONTEXT_H_
#define DEPS_CHAKRASHIM_SRC_INSPECTOR_INSPECTED_CONTEXT_H_

#include "src/base/macros.h"
#include "src/inspector/string-16.h"
Expand Down Expand Up @@ -56,4 +56,4 @@ class InspectedContext {

} // namespace v8_inspector

#endif // V8_INSPECTOR_INSPECTEDCONTEXT_H_
#endif // DEPS_CHAKRASHIM_SRC_INSPECTOR_INSPECTED_CONTEXT_H_
6 changes: 3 additions & 3 deletions deps/chakrashim/src/inspector/java-script-call-frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef V8_INSPECTOR_JAVASCRIPTCALLFRAME_H_
#define V8_INSPECTOR_JAVASCRIPTCALLFRAME_H_
#ifndef DEPS_CHAKRASHIM_SRC_INSPECTOR_JAVA_SCRIPT_CALL_FRAME_H_
#define DEPS_CHAKRASHIM_SRC_INSPECTOR_JAVA_SCRIPT_CALL_FRAME_H_

#include <vector>

Expand Down Expand Up @@ -78,4 +78,4 @@ using JavaScriptCallFrames = std::vector<std::unique_ptr<JavaScriptCallFrame>>;

} // namespace v8_inspector

#endif // V8_INSPECTOR_JAVASCRIPTCALLFRAME_H_
#endif // DEPS_CHAKRASHIM_SRC_INSPECTOR_JAVA_SCRIPT_CALL_FRAME_H_
6 changes: 3 additions & 3 deletions deps/chakrashim/src/inspector/protocol-platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_INSPECTOR_PROTOCOLPLATFORM_H_
#define V8_INSPECTOR_PROTOCOLPLATFORM_H_
#ifndef DEPS_CHAKRASHIM_SRC_INSPECTOR_PROTOCOL_PLATFORM_H_
#define DEPS_CHAKRASHIM_SRC_INSPECTOR_PROTOCOL_PLATFORM_H_

#include <memory>

Expand All @@ -18,4 +18,4 @@ std::unique_ptr<T> wrapUnique(T* ptr) {

} // namespace v8_inspector

#endif // V8_INSPECTOR_PROTOCOLPLATFORM_H_
#endif // DEPS_CHAKRASHIM_SRC_INSPECTOR_PROTOCOL_PLATFORM_H_
6 changes: 3 additions & 3 deletions deps/chakrashim/src/inspector/script-breakpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef V8_INSPECTOR_SCRIPTBREAKPOINT_H_
#define V8_INSPECTOR_SCRIPTBREAKPOINT_H_
#ifndef DEPS_CHAKRASHIM_SRC_INSPECTOR_SCRIPT_BREAKPOINT_H_
#define DEPS_CHAKRASHIM_SRC_INSPECTOR_SCRIPT_BREAKPOINT_H_

#include "src/inspector/string-16.h"

Expand All @@ -49,4 +49,4 @@ struct ScriptBreakpoint {

} // namespace v8_inspector

#endif // V8_INSPECTOR_SCRIPTBREAKPOINT_H_
#endif // DEPS_CHAKRASHIM_SRC_INSPECTOR_SCRIPT_BREAKPOINT_H_
6 changes: 3 additions & 3 deletions deps/chakrashim/src/inspector/search-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_INSPECTOR_SEARCHUTIL_H_
#define V8_INSPECTOR_SEARCHUTIL_H_
#ifndef DEPS_CHAKRASHIM_SRC_INSPECTOR_SEARCH_UTIL_H_
#define DEPS_CHAKRASHIM_SRC_INSPECTOR_SEARCH_UTIL_H_

#include "src/inspector/protocol/Debugger.h"
#include "src/inspector/string-util.h"
Expand All @@ -21,4 +21,4 @@ searchInTextByLinesImpl(V8InspectorSession*, const String16& text,

} // namespace v8_inspector

#endif // V8_INSPECTOR_SEARCHUTIL_H_
#endif // DEPS_CHAKRASHIM_SRC_INSPECTOR_SEARCH_UTIL_H_
6 changes: 4 additions & 2 deletions deps/chakrashim/src/inspector/string-16.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ static const UChar32 offsetsFromUTF8[6] = {0x00000000UL,
static_cast<UChar32>(0xFA082080UL),
static_cast<UChar32>(0x82082080UL)};

static inline UChar32 readUTF8Sequence(const char*& sequence, size_t length) {
static inline UChar32 readUTF8Sequence(
const char*& sequence, size_t length) { // NOLINT(runtime/references)
UChar32 character = 0;

// The cases all fall through.
Expand Down Expand Up @@ -355,7 +356,8 @@ ConversionResult convertUTF8ToUTF16(const char** sourceStart,

// Helper to write a three-byte UTF-8 code point to the buffer, caller must
// check room is available.
static inline void putUTF8Triple(char*& buffer, UChar ch) {
static inline void putUTF8Triple(char*& buffer, // NOLINT(runtime/references)
UChar ch) {
*buffer++ = static_cast<char>(((ch >> 12) & 0x0F) | 0xE0);
*buffer++ = static_cast<char>(((ch >> 6) & 0x3F) | 0x80);
*buffer++ = static_cast<char>((ch & 0x3F) | 0x80);
Expand Down
6 changes: 3 additions & 3 deletions deps/chakrashim/src/inspector/string-16.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_INSPECTOR_STRING16_H_
#define V8_INSPECTOR_STRING16_H_
#ifndef DEPS_CHAKRASHIM_SRC_INSPECTOR_STRING_16_H_
#define DEPS_CHAKRASHIM_SRC_INSPECTOR_STRING_16_H_

#include <stdint.h>
#include <cctype>
Expand Down Expand Up @@ -131,4 +131,4 @@ struct hash<v8_inspector::String16> {

#endif // !defined(__APPLE__) || defined(_LIBCPP_VERSION)

#endif // V8_INSPECTOR_STRING16_H_
#endif // DEPS_CHAKRASHIM_SRC_INSPECTOR_STRING_16_H_
9 changes: 5 additions & 4 deletions deps/chakrashim/src/inspector/string-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_INSPECTOR_STRINGUTIL_H_
#define V8_INSPECTOR_STRINGUTIL_H_
#ifndef DEPS_CHAKRASHIM_SRC_INSPECTOR_STRING_UTIL_H_
#define DEPS_CHAKRASHIM_SRC_INSPECTOR_STRING_UTIL_H_

#include "src/base/macros.h"
#include "src/inspector/string-16.h"
Expand All @@ -30,7 +30,8 @@ class StringUtil {
}
static String fromDouble(double number) { return String::fromDouble(number); }
static const size_t kNotFound = String::kNotFound;
static void builderReserve(StringBuilder& builder, size_t capacity) {
static void builderReserve(
StringBuilder& builder, size_t capacity) { // NOLINT(runtime/references)
builder.reserveCapacity(capacity);
}
};
Expand Down Expand Up @@ -73,4 +74,4 @@ class StringBufferImpl : public StringBuffer {

} // namespace v8_inspector

#endif // V8_INSPECTOR_STRINGUTIL_H_
#endif // DEPS_CHAKRASHIM_SRC_INSPECTOR_STRING_UTIL_H_
6 changes: 3 additions & 3 deletions deps/chakrashim/src/inspector/v8-console-agent-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_INSPECTOR_V8CONSOLEAGENTIMPL_H_
#define V8_INSPECTOR_V8CONSOLEAGENTIMPL_H_
#ifndef DEPS_CHAKRASHIM_SRC_INSPECTOR_V8_CONSOLE_AGENT_IMPL_H_
#define DEPS_CHAKRASHIM_SRC_INSPECTOR_V8_CONSOLE_AGENT_IMPL_H_

#include "src/base/macros.h"
#include "src/inspector/protocol/Console.h"
Expand Down Expand Up @@ -45,4 +45,4 @@ class V8ConsoleAgentImpl : public protocol::Console::Backend {

} // namespace v8_inspector

#endif // V8_INSPECTOR_V8CONSOLEAGENTIMPL_H_
#endif // DEPS_CHAKRASHIM_SRC_INSPECTOR_V8_CONSOLE_AGENT_IMPL_H_
3 changes: 1 addition & 2 deletions deps/chakrashim/src/inspector/v8-console-message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ V8ConsoleMessage::wrapArguments(V8InspectorSessionImpl* session,
if (m_type == ConsoleAPIType::kTable && generatePreview) {
// CHAKRA-TODO - Figure out what to do here.
CHAKRA_UNIMPLEMENTED();
}
else {
} else {
for (size_t i = 0; i < m_arguments.size(); ++i) {
// CHAKRA-TODO - Figure out what to do here.
v8::Local<v8::Value> arg = m_arguments[i]->Get(isolate);
Expand Down
6 changes: 3 additions & 3 deletions deps/chakrashim/src/inspector/v8-console-message.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_INSPECTOR_V8CONSOLEMESSAGE_H_
#define V8_INSPECTOR_V8CONSOLEMESSAGE_H_
#ifndef DEPS_CHAKRASHIM_SRC_INSPECTOR_V8_CONSOLE_MESSAGE_H_
#define DEPS_CHAKRASHIM_SRC_INSPECTOR_V8_CONSOLE_MESSAGE_H_

#include <deque>
#include "include/v8.h"
Expand Down Expand Up @@ -117,4 +117,4 @@ class V8ConsoleMessageStorage {

} // namespace v8_inspector

#endif // V8_INSPECTOR_V8CONSOLEMESSAGE_H_
#endif // DEPS_CHAKRASHIM_SRC_INSPECTOR_V8_CONSOLE_MESSAGE_H_
9 changes: 5 additions & 4 deletions deps/chakrashim/src/inspector/v8-console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,11 @@ void V8Console::valuesCallback(
info.GetReturnValue().Set(values);
}

static void setFunctionBreakpoint(ConsoleHelper& helper,
v8::Local<v8::Function> function,
V8DebuggerAgentImpl::BreakpointSource source,
const String16& condition, bool enable) {
static void setFunctionBreakpoint(
ConsoleHelper& helper, // NOLINT(runtime/references)
v8::Local<v8::Function> function,
V8DebuggerAgentImpl::BreakpointSource source,
const String16& condition, bool enable) {
V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent();
if (!debuggerAgent) return;
String16 scriptId = String16::fromInteger(function->ScriptId());
Expand Down
Loading

0 comments on commit fa6b635

Please sign in to comment.