summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichelle McDaniel <adiaaida@gmail.com>2016-08-09 09:59:01 -0700
committerMichelle McDaniel <adiaaida@gmail.com>2016-08-11 09:53:34 -0700
commitab7d6a8df73d3d89210a778338feaa9fedf4146a (patch)
tree4da1d793e3c5102a82398c5e8d560cf032f164a4
parent7a84ab0f876d25464d1493c2d02de45da6f9da7e (diff)
downloadcoreclr-ab7d6a8df73d3d89210a778338feaa9fedf4146a.tar.gz
coreclr-ab7d6a8df73d3d89210a778338feaa9fedf4146a.tar.bz2
coreclr-ab7d6a8df73d3d89210a778338feaa9fedf4146a.zip
Prepare jit source for clang-tidy
In templates, clang-tidy will replace 0 with nullptr, but this is illegal for primitive types. This change replaces 0 in two templated functions with ZERO, which is defined to be 0 to avoid this issue. Additioanlly, we need to conditionally define some macros for running under __clang__ so they are found by clang-tidy.
-rw-r--r--src/inc/clrtypes.h2
-rw-r--r--src/inc/palclr.h7
-rw-r--r--src/inc/winwrap.h2
-rw-r--r--src/jit/compiler.h4
-rw-r--r--src/jit/jit.h8
-rw-r--r--src/pal/inc/pal.h2
6 files changed, 18 insertions, 7 deletions
diff --git a/src/inc/clrtypes.h b/src/inc/clrtypes.h
index 4ba5b1425a..5f9de0cbf1 100644
--- a/src/inc/clrtypes.h
+++ b/src/inc/clrtypes.h
@@ -12,7 +12,7 @@
#ifndef CLRTYPES_H_
#define CLRTYPES_H_
-#if defined(_MSC_VER) && (!defined(FEATURE_CORECLR) || defined(FEATURE_CORESYSTEM))
+#if defined(_MSC_VER) && !defined(SOURCE_FORMATTING) && (!defined(FEATURE_CORECLR) || defined(FEATURE_CORESYSTEM))
// Prefer intsafe.h when available, which defines many of the MAX/MIN
// values below (which is why they are in #ifndef blocks).
#include <intsafe.h>
diff --git a/src/inc/palclr.h b/src/inc/palclr.h
index 4ef7d58385..4bac965962 100644
--- a/src/inc/palclr.h
+++ b/src/inc/palclr.h
@@ -484,7 +484,14 @@
// and it provides __declspec(selectany) to instruct the linker to merge
// duplicate external const static data copies into one.
//
+#if defined(SOURCE_FORMATTING)
+#define SELECTANY extern
+#else
#define SELECTANY extern __declspec(selectany)
+#endif
+#if defined(SOURCE_FORMATTING)
+#define __annotation(x)
+#endif
#if defined(_DEBUG_IMPL) && !defined(JIT_BUILD) && !defined(JIT64_BUILD) && !defined(CROSS_COMPILE) && !defined(_TARGET_ARM_) // @ARMTODO: no contracts for speed
diff --git a/src/inc/winwrap.h b/src/inc/winwrap.h
index 47624a3290..91a71b700b 100644
--- a/src/inc/winwrap.h
+++ b/src/inc/winwrap.h
@@ -49,7 +49,7 @@
#include "registrywrapper.h"
#include "longfilepathwrappers.h"
-#ifdef _PREFAST_
+#if defined(_PREFAST_) || defined(SOURCE_FORMATTING)
//
// For PREFAST we don't want the C_ASSERT to be expanded since it always
// involves the comparison of two constants which causes PREfast warning 326
diff --git a/src/jit/compiler.h b/src/jit/compiler.h
index cef9ceec76..161ef8abd4 100644
--- a/src/jit/compiler.h
+++ b/src/jit/compiler.h
@@ -7782,13 +7782,13 @@ public :
template<typename T>
T dspPtr(T p)
{
- return (p == 0) ? 0 : (opts.dspDiffable ? T(0xD1FFAB1E) : p);
+ return (p == ZERO) ? ZERO : (opts.dspDiffable ? T(0xD1FFAB1E) : p);
}
template<typename T>
T dspOffset(T o)
{
- return (o == 0) ? 0 : (opts.dspDiffable ? T(0xD1FFAB1E) : o);
+ return (o == ZERO) ? ZERO : (opts.dspDiffable ? T(0xD1FFAB1E) : o);
}
static int dspTreeID(GenTree* tree)
diff --git a/src/jit/jit.h b/src/jit/jit.h
index cbff78f8a6..36cf690c9d 100644
--- a/src/jit/jit.h
+++ b/src/jit/jit.h
@@ -22,6 +22,10 @@
// ifdef. This macro allows us to anchor the comments to the regular flow of code.
#define CLANG_FORMAT_COMMENT_ANCHOR ;
+// Clang-tidy replaces 0 with nullptr in some templated functions, causing a build
+// break. Replacing those instances with ZERO avoids this change
+#define ZERO 0
+
#ifdef _MSC_VER
// These don't seem useful, so turning them off is no big deal
#pragma warning(disable:4510) // can't generate default constructor
@@ -861,13 +865,13 @@ public:
template<typename T>
T dspPtr(T p)
{
- return (p == 0) ? 0 : (JitTls::GetCompiler()->opts.dspDiffable ? T(0xD1FFAB1E) : p);
+ return (p == ZERO) ? ZERO : (JitTls::GetCompiler()->opts.dspDiffable ? T(0xD1FFAB1E) : p);
}
template<typename T>
T dspOffset(T o)
{
- return (o == 0) ? 0 : (JitTls::GetCompiler()->opts.dspDiffable ? T(0xD1FFAB1E) : o);
+ return (o == ZERO) ? ZERO : (JitTls::GetCompiler()->opts.dspDiffable ? T(0xD1FFAB1E) : o);
}
#else // !defined(DEBUG)
diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h
index e086717510..260528285e 100644
--- a/src/pal/inc/pal.h
+++ b/src/pal/inc/pal.h
@@ -186,7 +186,7 @@ extern "C" {
#define DECLSPEC_NORETURN PAL_NORETURN
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) || defined(SOURCE_FORMATTING)
#define __assume(x) (void)0
#define __annotation(x)
#endif //!MSC_VER