Remove code duplication

This commit is contained in:
Philippe Canal 2015-04-16 03:33:55 -05:00 committed by sftnight
parent e216aea985
commit 2fc94b3fa9
3 changed files with 22 additions and 9 deletions

View File

@ -8,6 +8,7 @@
//------------------------------------------------------------------------------
#include "cling/Interpreter/CIFactory.h"
#include "ClingUtils.h"
#include "DeclCollector.h"
#include "cling-compiledata.h"
@ -650,15 +651,13 @@ namespace {
// In addition, clang also defined __GNUC__, we add the following two macros
// to allow scripts, and more important, dictionary generation to know which
// of the two is the underlying compiler.
#define stringify(s) stringifyx(s)
#define stringifyx(s) #s
#ifdef __clang__
CI->getInvocation().getPreprocessorOpts()
.addMacroDef("__CLING__clang__=" stringify(__clang__));
.addMacroDef("__CLING__clang__=" ClingStringify(__clang__));
#elif defined(__GNUC__)
CI->getInvocation().getPreprocessorOpts()
.addMacroDef("__CLING__GNUC__=" stringify(__GNUC__));
.addMacroDef("__CLING__GNUC__=" ClingStringify(__GNUC__));
#endif
if (CI->getDiagnostics().hasErrorOccurred())

View File

@ -0,0 +1,16 @@
//--------------------------------------------------------------------*- C++ -*-
// CLING - the C++ LLVM-based InterpreterG :)
// author: Axel Naumann <axel@cern.ch>
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------
#ifndef CLING_UTILS_H
#define CLING_UTILS_H
#define ClingStringify(s) ClingStringifyx(s)
#define ClingStringifyx(s) #s
#endif // CLING_UTILS_H

View File

@ -8,6 +8,7 @@
//------------------------------------------------------------------------------
#include "cling/Interpreter/Interpreter.h"
#include "ClingUtils.h"
#include "cling-compiledata.h"
#include "DynamicLookup.h"
@ -47,9 +48,6 @@
#include <string>
#include <vector>
#define stringify(s) stringifyx(s)
#define stringifyx(s) #s
using namespace clang;
namespace {
@ -222,7 +220,7 @@ namespace cling {
for (auto&& I: IncrParserTransactions)
m_IncrParser->commitTransaction(I);
// Disable suggestions for ROOT
bool showSuggestions = !llvm::StringRef(stringify(CLING_VERSION)).startswith("ROOT");
bool showSuggestions = !llvm::StringRef(ClingStringify(CLING_VERSION)).startswith("ROOT");
std::unique_ptr<InterpreterCallbacks>
AutoLoadCB(new AutoloadCallback(this, showSuggestions));
setCallbacks(std::move(AutoLoadCB));
@ -242,7 +240,7 @@ namespace cling {
}
const char* Interpreter::getVersion() const {
return stringify(CLING_VERSION);
return ClingStringify(CLING_VERSION);
}
void Interpreter::handleFrontendOptions() {