clang-format suggestion

This commit is contained in:
Philippe Canal 2017-08-24 09:22:27 -05:00 committed by sftnight
parent 38c4b902cf
commit 6c368913e7
4 changed files with 44 additions and 49 deletions

View File

@ -10,8 +10,8 @@
#ifndef CLING_ORDERED_MAP_H
#define CLING_ORDERED_MAP_H
#include <unordered_map>
#include <cassert>
#include <unordered_map>
namespace cling {
namespace utils {
@ -23,8 +23,7 @@ namespace utils {
/// additional parameter to 'erase' so that a mapped value can be moved into
/// local storage before erasing the iterator occurs.
///
template <typename Key, typename Value>
class OrderedMap {
template <typename Key, typename Value> class OrderedMap {
typedef std::unordered_map<Key, Value> map_t;
// Would this be faster as a std::unoredered_map<Key, size_t> for erasure?
typedef std::vector<typename map_t::const_iterator> order_t;

View File

@ -103,7 +103,6 @@ IncrementalExecutor::IncrementalExecutor(clang::DiagnosticsEngine& diags,
// Keep in source: ~unique_ptr<ClingJIT> needs ClingJIT
IncrementalExecutor::~IncrementalExecutor() {}
void IncrementalExecutor::shuttingDown() {
// It is legal to register an atexit handler from within another atexit
// handler and furthor-more the standard says they need to run in reverse
@ -116,12 +115,12 @@ void IncrementalExecutor::shuttingDown() {
return;
Local.swap(m_AtExitFuncs);
}
for (auto&& Ordered: llvm::reverse(Local.ordered())) {
for (auto&& Ordered : llvm::reverse(Local.ordered())) {
for (auto&& AtExit : llvm::reverse(Ordered->second))
AtExit();
// The standard says that they need to run in reverse order, which means
// anything added from 'AtExit()' must now be run!
shuttingDown();
// The standard says that they need to run in reverse order, which means
// anything added from 'AtExit()' must now be run!
shuttingDown();
}
}
@ -301,8 +300,7 @@ void IncrementalExecutor::runAndRemoveStaticDestructors(Transaction* T) {
{
cling::internal::SpinLockGuard slg(m_AtExitFuncsSpinLock);
auto Itr = m_AtExitFuncs.find(T->getModule());
if (Itr == m_AtExitFuncs.end())
return;
if (Itr == m_AtExitFuncs.end()) return;
m_AtExitFuncs.erase(Itr, &Local);
} // end of spin lock lifetime block.

View File

@ -22,11 +22,11 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringRef.h"
#include <vector>
#include <unordered_set>
#include <atomic>
#include <map>
#include <memory>
#include <atomic>
#include <unordered_set>
#include <vector>
namespace clang {
class DiagnosticsEngine;
@ -93,10 +93,10 @@ namespace cling {
///\param [in] fromT - The unloading of this transaction will trigger the
/// atexit function.
///
CXAAtExitElement(void (*func) (void*), void* arg):
m_Func(func), m_Arg(arg) {}
CXAAtExitElement(void (*func)(void*), void* arg)
: m_Func(func), m_Arg(arg) {}
void operator () () const { (*m_Func)(m_Arg); }
void operator()() const { (*m_Func)(m_Arg); }
};
///\brief Atomic used as a spin lock to protect the access to m_AtExitFuncs

View File

@ -32,11 +32,15 @@ atexit(atexit_1);
at_quick_exit(atexit_2);
.undo
// Make sure at_quick_exit is resolved correctly (mangling issues on gcc < 5)
// CHECK-NEXT: atexit_2
// Make sure at_quick_exit is resolved correctly (mangling issues on gcc <
// 5)
// CHECK-NEXT: atexit_2
// Test reverse ordering in a single transaction.
static void atexitA() { printf("atexitA\n"); }
// Test reverse ordering in a single transaction.
static void
atexitA() {
printf("atexitA\n");
}
static void atexitB() { printf("atexitB\n"); }
static void atexitC() { printf("atexitC\n"); }
{
@ -45,11 +49,11 @@ static void atexitC() { printf("atexitC\n"); }
std::atexit(atexitC);
}
.undo
// CHECK-NEXT: atexitC
// CHECK-NEXT: atexitB
// CHECK-NEXT: atexitA
// CHECK-NEXT: atexitC
// CHECK-NEXT: atexitB
// CHECK-NEXT: atexitA
atexit(atexit_3);
atexit(atexit_3);
cling::Interpreter * gChild = 0;
{
@ -67,20 +71,14 @@ static void atexit_f() {
}
at_quick_exit(atexit_f);
void atExit0 () {
printf("atExit0\n");
}
void atExit1 () {
printf("atExit1\n");
}
void atExit2 () {
printf("atExit2\n");
}
void atExitA () {
void atExit0() { printf("atExit0\n"); }
void atExit1() { printf("atExit1\n"); }
void atExit2() { printf("atExit2\n"); }
void atExitA() {
printf("atExitA\n");
std::atexit(&atExit0);
}
void atExitB () {
void atExitB() {
printf("atExitB\n");
std::atexit(&atExit1);
std::atexit(&atExit2);
@ -91,14 +89,14 @@ void atExitB () {
std::atexit(&atExitB);
}
.undo
// CHECK-NEXT: atExitB
// CHECK-NEXT: atExit2
// CHECK-NEXT: atExit1
// CHECK-NEXT: atExitA
// CHECK-NEXT: atExit0
// CHECK-NEXT: atExitB
// CHECK-NEXT: atExit2
// CHECK-NEXT: atExit1
// CHECK-NEXT: atExitA
// CHECK-NEXT: atExit0
// Recusion at shutdown
struct ShutdownRecursion {
// Recusion at shutdown
struct ShutdownRecursion {
static void DtorAtExit0() { printf("ShutdownRecursion0\n"); }
static void DtorAtExit1() { printf("ShutdownRecursion1\n"); }
static void DtorAtExit2() { printf("ShutdownRecursion2\n"); }
@ -113,12 +111,12 @@ struct ShutdownRecursion {
// expected-no-diagnostics
.q
// Reversed registration order
// Reversed registration order
// CHECK-NEXT: ~ShutdownRecursion
// CHECK-NEXT: ShutdownRecursion2
// CHECK-NEXT: ShutdownRecursion1
// CHECK-NEXT: ShutdownRecursion0
// CHECK-NEXT: ~ShutdownRecursion
// CHECK-NEXT: ShutdownRecursion2
// CHECK-NEXT: ShutdownRecursion1
// CHECK-NEXT: ShutdownRecursion0
// CHECK-NEXT: atexit_f true
// CHECK-NEXT: atexit_3
// CHECK-NEXT: atexit_f true
// CHECK-NEXT: atexit_3