Skip to content

Commit

Permalink
clang++ support: extended configuration and fixed compilation errors …
Browse files Browse the repository at this point in the history
…to allow compilation of ROSE with clang++.
  • Loading branch information
mschordan committed Oct 22, 2015
1 parent 19310a7 commit 45243ff
Show file tree
Hide file tree
Showing 20 changed files with 76 additions and 50 deletions.
9 changes: 8 additions & 1 deletion config/compiler-defs.m4
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ dnl predefined by a specific compiler
# case $BACKEND_CXX_COMPILER in
case $compilerName in
# MS 10/22/2015: Support for LLVM
clang|clang++)
macroString="{\"rose_edg_required_macros_and_functions.h\"}"
compilerVendorName=llvm
echo "Support for clang as a backend for compiling ROSE generated code \"$BACKEND_CXX_COMPILER\" ";
echo "Support for clang as a backend for compiling ROSE generated code \"$macroString\" ";
;;
# Support for GNU gcc or g++ as a backend for compiling ROSE generated code
# JJW 7/25/2008: Added mpi* in here, assuming they are like gcc
# g++|gcc|mpicc|mpic++|mpicxx|mpiCC)
Expand Down
2 changes: 1 addition & 1 deletion config/create_system_headers
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fi
# g++|gcc|icpc|icc|mpicc|mpic++|mpiCC|mpicxx|roseTranslator)
# g++|gcc|icpc|icc|mpicc|mpic++|mpiCC|mpicxx|c++)
# g++*|gcc*|cc*|icpc|icc|mpicc|mpic++|mpiCC|mpicxx|c++|xt-xcc|xt-xc++)
g++*|gcc*|cc*|icpc|mpiicpc|icc|mpiicc|mpicc|mpic++|mpiCC|mpicxx|c++|xt-xcc|xt-xc++)
g++*|gcc*|cc*|icpc|mpiicpc|icc|mpiicc|mpicc|mpic++|mpiCC|mpicxx|c++|xt-xcc|xt-xc++|clang|clang++)
case "$compilerName" in
# gcc*|cc*|icc|mpicc|xt-xcc)
gcc*|cc*|icc|mpicc|mpiicc|xt-xcc)
Expand Down
4 changes: 2 additions & 2 deletions config/get_compiler_header_dirs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ compilerName="`basename $1`"
case "$compilerName" in
# DQ (3/21/2014): Added support for the MPI versions of the Intel compiler (as named on LC machines).
# Support for compiling ROSE with GNU g++ compiler
g++*|gcc*|icpc|icc|mpiicpc|mpiicc|mpicc|mpic++|mpiCC|mpicxx|cc|c++|xt-xcc|xt-xc++)
if [ "$compilerName" = "gcc" -o "$compilerName" = "icc" -o "$compilerName" = "mpicc" -o "$compilerName" = "mpiicc" -o "$compilerName" = "xt-xcc" -o "$compilerName" = "cc" ]
g++*|gcc*|icpc|icc|mpiicpc|mpiicc|mpicc|mpic++|mpiCC|mpicxx|cc|c++|xt-xcc|xt-xc++|clang|clang++)
if [ "$compilerName" = "gcc" -o "$compilerName" = "icc" -o "$compilerName" = "mpicc" -o "$compilerName" = "mpiicc" -o "$compilerName" = "xt-xcc" -o "$compilerName" = "cc" -o "$compilerName" = "clang" ]
then
language="c"
else
Expand Down
3 changes: 2 additions & 1 deletion src/3rdPartyLibraries/MSTL/DOTGeneration.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class DOTGeneration : public SgTopDownBottomUpProcessing<DOTInheritedAttribute,
DOTGeneration();
// generates a visualization of an AST subtree with root node node. The filename must be specified.
// DQ (10/30/2003) Make generate a virtual function
virtual void generate(std::string filename, Node node, traversalType tt=TOPDOWNBOTTOMUP);
// MS 10/22/2015: this function is never overwritten, but overloaded in subclasses. Let's keep it non-virtual for that reason.
void generate(std::string filename, Node node, traversalType tt=TOPDOWNBOTTOMUP);
virtual DOTInheritedAttribute evaluateInheritedAttribute(Node node, DOTInheritedAttribute ia);
virtual DOTSynthesizedAttribute evaluateSynthesizedAttribute(Node node, DOTInheritedAttribute ia, SubTreeSynthesizedAttributes l);

Expand Down
12 changes: 4 additions & 8 deletions src/3rdPartyLibraries/MSTL/TreeTraversal.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class PreOrderTraversal : public TreeTraversal<TreeNode> {
void traverse(TreeNode root);
protected:
virtual void preOrderVisit(TreeNode node)=0;
TreeTraversal<TreeNode>::nullNodeVisit;
};

template<typename TreeNode>
Expand All @@ -39,7 +38,6 @@ class InOrderTraversal : public TreeTraversal<TreeNode> {
void traverse(TreeNode root);
protected:
virtual void inOrderVisit(TreeNode node)=0;
TreeTraversal<TreeNode>::nullNodeVisit;
};

template<typename TreeNode>
Expand All @@ -48,15 +46,13 @@ class PostOrderTraversal : public TreeTraversal<TreeNode> {
void traverse(TreeNode root);
protected:
virtual void postOrderVisit(TreeNode node)=0;
TreeTraversal<TreeNode>::nullNodeVisit;
};

template<typename TreeNode>
class PrePostOrderTraversal : public TreeTraversal<TreeNode> {
protected:
virtual void preOrderVisit(TreeNode node)=0;
virtual void postOrderVisit(TreeNode node)=0;
TreeTraversal<TreeNode>::nullNodeVisit;
public:
void traverse(TreeNode node);
};
Expand All @@ -82,7 +78,7 @@ traverse(TreeNode node) {
typename PreOrderTraversal<TreeNode>::ChildrenContainer c;
if(this->isNullNode(node)) {
if(!this->skipNode(node)) {
nullNodeVisit();
this->nullNodeVisit();
}
return;
} else {
Expand All @@ -105,7 +101,7 @@ traverse(TreeNode node) {
typename InOrderTraversal<TreeNode>::childrenContainer c;
if(isNullNode(node)) {
if(!skipNode(node)) {
nullNodeVisit();
this->nullNodeVisit();
};
return;
}
Expand All @@ -130,7 +126,7 @@ traverse(TreeNode node) {
typename PostOrderTraversal<TreeNode>::childrenContainer c;
if(isNullNode(node)) {
if(!skipNode(node)) {
nullNodeVisit();
this->nullNodeVisit();
}
return;
}
Expand All @@ -152,7 +148,7 @@ traverse(TreeNode node) {
typename PrePostOrderTraversal<TreeNode>::ChildrenContainer c;
if(this->isNullNode(node)) {
if(!this->skipNode(node)) {
nullNodeVisit();
this->nullNodeVisit();
}
return;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/ROSETTA/Grammar/Support.code
Original file line number Diff line number Diff line change
Expand Up @@ -4931,7 +4931,7 @@ HEADER_QUALIFIED_NAME_END
HEADER_ATTRIBUTE_START
// SgAttribute(char* str);
int isSame(const std::string& str);
virtual bool isPragma() { return 0; } // MS02/22/02
//virtual bool isPragma() { return 0; } // MS02/22/02, 11/22/2015
// char *get_name() const;

protected:
Expand Down
5 changes: 4 additions & 1 deletion src/ROSETTA/src/buildAtermSupport.C
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,10 @@ Grammar::buildAtermConsumerSupportFunctions(Terminal & node, StringUtility::File

bool toBeTraversed = grammarString->getToBeTraversed().getValue();

bool isInConstructorParameterList = grammarString->getIsInConstructorParameterList();
// MS 11/12/2015: uses new function
// isInConstructorParameterList to allow to properly check
// on boolean return value
bool isInConstructorParameterList = grammarString->isInConstructorParameterList();

#if 0
outputFile << "// firstConstructorParameter = " << (firstConstructorParameter ? "true" : "false") << "\n";
Expand Down
7 changes: 4 additions & 3 deletions src/ROSETTA/src/grammar.C
Original file line number Diff line number Diff line change
Expand Up @@ -1259,8 +1259,6 @@ Grammar::buildConstructorParameterList ( Terminal & node, vector<GrammarString *
GrammarString *memberFunctionCopy= *gIt;
ROSE_ASSERT (memberFunctionCopy != NULL);

// DQ (11/7/2006): Rewritten to remove wrap logic (overly complex)
// if (memberFunctionCopy->getIsInConstructorParameterList() == true)
if (memberFunctionCopy->getIsInConstructorParameterList() == CONSTRUCTOR_PARAMETER)
{
constructorParameterList.push_back(memberFunctionCopy);
Expand Down Expand Up @@ -1955,9 +1953,12 @@ Grammar::editSubstitution ( Terminal & node, const StringUtility::FileWithLineNu
// printf ("listLength = %d \n",listLength);
vector<GrammarString *>::iterator sourceListIterator, targetListIterator;
for ( sourceListIterator = sourceList.begin(), targetListIterator = targetList.begin();
sourceListIterator != sourceList.end(), targetListIterator != targetList.end();
sourceListIterator != sourceList.end() || targetListIterator != targetList.end();
sourceListIterator++, targetListIterator++ )
{
// MS 11/22/2015: changed above loop test to check on both iterators (not just check one iterator as before).
// therefore the following inariant must hold or something is wrong
ROSE_ASSERT(sourceListIterator!=sourceList.end() && targetListIterator != targetList.end());
// These are done in the order in which the user specified them!

// fprintf (stderr, "targetList[index].getFunctionNameString() = %s \n",(*targetListIterator)->getFunctionPrototypeString().c_str());
Expand Down
22 changes: 14 additions & 8 deletions src/ROSETTA/src/grammarString.C
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@ GrammarString::infoFieldsToString() const {


bool
GrammarString::isInConstructorParameterList() const
{
return p_isInConstructorParameterList==CONSTRUCTOR_PARAMETER;
}

ConstructParamEnum
GrammarString::getIsInConstructorParameterList() const
{
return isInConstructorParameterList==CONSTRUCTOR_PARAMETER;
return p_isInConstructorParameterList;
}

TraversalFlag
Expand Down Expand Up @@ -852,7 +858,7 @@ GrammarString::~GrammarString()
GrammarString::GrammarString()
: pureVirtualFunction(0), functionNameString(""),
typeNameString(""), variableNameString(""),
defaultInitializerString(""), isInConstructorParameterList(CONSTRUCTOR_PARAMETER),
defaultInitializerString(""), p_isInConstructorParameterList(CONSTRUCTOR_PARAMETER),
toBeCopied(COPY_DATA), toBeTraversed(true), key(0),
automaticGenerationOfDataAccessFunctions(BUILD_ACCESS_FUNCTIONS),
toBeDeleted(false)
Expand All @@ -870,7 +876,7 @@ GrammarString::GrammarString(
// DQ (12/7/2003): Reordered parameters
: pureVirtualFunction(0), functionNameString(""),
typeNameString(inputTypeNameString), variableNameString(inputVariableNameString),
defaultInitializerString(inputDefaultInitializerString), isInConstructorParameterList(isConstructorParameter),
defaultInitializerString(inputDefaultInitializerString), p_isInConstructorParameterList(isConstructorParameter),
toBeCopied(_toBeCopied), toBeTraversed(true), key(0),
automaticGenerationOfDataAccessFunctions(BUILD_ACCESS_FUNCTIONS),
toBeDeleted(delete_flag)
Expand Down Expand Up @@ -900,7 +906,7 @@ GrammarString::GrammarString( const string& inputFunctionNameString )
// DQ (12/7/2003): Reordered parameters
: pureVirtualFunction(0), functionNameString(inputFunctionNameString),
typeNameString(""), variableNameString(""),
defaultInitializerString(""), isInConstructorParameterList(CONSTRUCTOR_PARAMETER),
defaultInitializerString(""), p_isInConstructorParameterList(CONSTRUCTOR_PARAMETER),
toBeCopied(COPY_DATA), toBeTraversed(true), key(0),
automaticGenerationOfDataAccessFunctions(BUILD_ACCESS_FUNCTIONS),
toBeDeleted(false)
Expand All @@ -913,7 +919,7 @@ GrammarString::GrammarString( const GrammarString & X )
// DQ (12/7/2003): Reordered parameters
: pureVirtualFunction(0), functionNameString(""),
typeNameString(""), variableNameString(""),
defaultInitializerString(""), isInConstructorParameterList(CONSTRUCTOR_PARAMETER),
defaultInitializerString(""), p_isInConstructorParameterList(CONSTRUCTOR_PARAMETER),
toBeCopied(X.toBeCopied), toBeTraversed(true), key(0),
automaticGenerationOfDataAccessFunctions(BUILD_ACCESS_FUNCTIONS),
toBeDeleted(false)
Expand Down Expand Up @@ -941,7 +947,7 @@ GrammarString::operator= ( const GrammarString & X )
key = X.key;
pureVirtualFunction = X.pureVirtualFunction;
automaticGenerationOfDataAccessFunctions = X.automaticGenerationOfDataAccessFunctions;
isInConstructorParameterList = X.isInConstructorParameterList;
p_isInConstructorParameterList = X.p_isInConstructorParameterList;
toBeTraversed = X.toBeTraversed;
toBeCopied = X.toBeCopied;
toBeDeleted = X.toBeDeleted;
Expand Down Expand Up @@ -1050,13 +1056,13 @@ GrammarString::setAutomaticGenerationOfDataAccessFunctions ( const BuildAccessEn
void
GrammarString::setIsInConstructorParameterList()
{
isInConstructorParameterList=CONSTRUCTOR_PARAMETER;
p_isInConstructorParameterList=CONSTRUCTOR_PARAMETER;
}

void
GrammarString::setIsInConstructorParameterList(ConstructParamEnum X)
{
isInConstructorParameterList= X;
p_isInConstructorParameterList= X;
}

void
Expand Down
9 changes: 5 additions & 4 deletions src/ROSETTA/src/grammarString.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GrammarString
std::string variableNameString;
std::string defaultInitializerString;
private:
ConstructParamEnum isInConstructorParameterList;
ConstructParamEnum p_isInConstructorParameterList;
public:
CopyConfigEnum toBeCopied; // used to guide cloning of AST nodes

Expand Down Expand Up @@ -120,10 +120,11 @@ class GrammarString
std::string containerElementTypeString(Terminal & node) const;
std::string containerAppendFunctionNameString(Terminal & node) const;

void setIsInConstructorParameterList();
// MS 2015: deprecated function. Use function setIsInConstructorParameterList() instead.
void setIsInConstructorParameterList(ConstructParamEnum X);
bool getIsInConstructorParameterList() const;
ConstructParamEnum getIsInConstructorParameterList() const;

void setIsInConstructorParameterList();
bool isInConstructorParameterList() const;

void setToBeTraversed(const TraversalFlag& X);
TraversalFlag getToBeTraversed() const;
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/SageIII/astTokenStream/createMap.C
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ createMap::internalMatchBetweenASTandTokenStreamSeparator(separator*
sep_it != tokenBraceMapForThisScope.end(); ++sep_it){

if(
(eq_it->begin_pos == sep_it->begin_pos)
eq_it->begin_pos == sep_it->begin_pos

){
tokenBraceMapForThisScope.erase(sep_it);
Expand Down
4 changes: 2 additions & 2 deletions src/midend/astDiagnostics/AstConsistencyTests.C
Original file line number Diff line number Diff line change
Expand Up @@ -3756,10 +3756,10 @@ TestExpressionTypes::visit ( SgNode* node )
{
SgExpression *parentExpr = isSgExpression(expression->get_parent());
if (parentExpr != NULL && !(
parentExpr->variantT() == V_SgAssignInitializer && expression->variantT() == V_SgStringVal
(parentExpr->variantT() == V_SgAssignInitializer && expression->variantT() == V_SgStringVal)
|| parentExpr->variantT() == V_SgDotExp
|| parentExpr->variantT() == V_SgArrowExp
|| isSgInitializer(parentExpr) && isSgInitializer(expression)))
|| (isSgInitializer(parentExpr) && isSgInitializer(expression))))
{
SgType* parentType = parentExpr->get_type();
parentType = parentType->stripTypedefsAndModifiers();
Expand Down
5 changes: 4 additions & 1 deletion src/midend/astProcessing/AstDOTGeneration.C
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,10 @@ commentAndCppInformation (SgNode* node)
if (commentsAndCppDirectives != NULL)
{
numberofCommentsAndCppDirectives = commentsAndCppDirectives->size();
if (numberofCommentsAndCppDirectives >= 0)
// MS 11/12/2015: disabled this test as size_t is unsigned;
// this test is always true and compilers issue a
// warning
//if (numberofCommentsAndCppDirectives >= 0)
{
// ss = string("comments = ") + StringUtility::numberToString(numberofCommentsAndCppDirectives) + "\\n";
ss += string("comments/directives (before) = ") + StringUtility::numberToString(numberByRelativePosition(commentsAndCppDirectives,PreprocessingInfo::before)) + "\\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ AstSharedMemoryParallelTopDownBottomUpProcessing<I, S>::traverseInParallel(
std::vector<SynthesizedAttributeTypeList *> finalResults(numberOfThreads);
for (i = 0; i < numberOfThreads; i++)
pthread_join(threads[i], (void **) &finalResults[i]);
delete threads;
delete[] threads;
#endif

// Flatten the nested list of traversal results.
Expand Down Expand Up @@ -382,7 +382,7 @@ AstSharedMemoryParallelTopDownProcessing<I>::traverseInParallel(
std::vector<void *> finalResults(numberOfThreads);
for (i = 0; i < numberOfThreads; i++)
pthread_join(threads[i], &finalResults[i]);
delete threads;
delete[] threads;

// Done!
}
Expand Down Expand Up @@ -563,7 +563,7 @@ AstSharedMemoryParallelBottomUpProcessing<S>::traverseInParallel(SgNode *basenod
std::vector<SynthesizedAttributeTypeList *> finalResults(numberOfThreads);
for (i = 0; i < numberOfThreads; i++)
pthread_join(threads[i], (void **) &finalResults[i]);
delete threads;
delete[] threads;

// Flatten the nested list of traversal results.
SynthesizedAttributeTypeList *flatFinalResults = new SynthesizedAttributeTypeList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ template class MidLevelRewrite<MidLevelInterfaceNodeCollection>;
template class MidLevelRewrite<HighLevelInterfaceNodeCollection>;
template class AbstractInterfaceNodeCollection<MidLevelCollectionTypedefs>;
template class AbstractInterfaceNodeCollection<HighLevelCollectionTypedefs>;
// MS: 11/22/2015: added missing declaration (required for linking with clang++)
template class TransformationStringTemplatedType<MidLevelCollectionTypedefs>;
template class TransformationStringTemplatedType<HighLevelCollectionTypedefs>;

4 changes: 3 additions & 1 deletion src/midend/astUtil/astInterface/AstInterface.C
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,9 @@ SgSymbol* AstInterfaceImpl::CreateDeclarationStmts( const string& _decl)
// DQ (1/2/2007): The use of _astInterface_Tmp.c does not provide a unique filename
// to support testing of the loop processor in parallel. This is modified below to
// make the name unique for each process.
char *uniqueFilename = "/tmp/_astInterface_Tmp_XXXXXX.c";
// MS 11/22/2015: introduced array to avoid deprecated conversion from string literal to char*
char uniqueFilenameDefault[] = "/tmp/_astInterface_Tmp_XXXXXX.c";
char *uniqueFilename = uniqueFilenameDefault;
#ifdef _MSC_VER
uniqueFilename = mktemp(uniqueFilename);
if (uniqueFilename == NULL) return NULL;
Expand Down
11 changes: 4 additions & 7 deletions src/midend/programAnalysis/systemDependenceGraph/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ noinst_LTLIBRARIES =
# noinst_LTLIBRARIES = libSDG.la
endif

libSDG_la_DEPENDENCIES =

# DQ (10/7/2015): I think we don't want to support this code any more (was not supported
# on GNU compilers greater than 4.6 and so should not be supported on Intel compilers.
# DQ (2/9/2014): This code does not compile using GNU g++ version 4.7 and later compilers.
Expand All @@ -22,13 +20,12 @@ libSDG_la_DEPENDENCIES =

# libSDG_la_SOURCES = staticCFG.C PDG.C SDG.C util.C defUseChains.C newDDG.C newCDG.C
if ROSE_USING_GCC_VERSION_LATER_4_6
libSDG_la_SOURCES =
# libSDG_la_SOURCES = staticCFG.C PDG.C SDG.C util.C defUseChains.C newDDG.C newCDG.C
# not supported anymore
else
libSDG_la_SOURCES =
# not supported anymore
# pkginclude_HEADERS = cong_staticCFG.h PDG.h util.h SDG.h defUseChains.h newCDG.h newDDG.h
# libSDG_la_DEPENDENCIES =
# libSDG_la_SOURCES = staticCFG.C PDG.C SDG.C util.C defUseChains.C newDDG.C newCDG.C
endif

pkginclude_HEADERS = cong_staticCFG.h PDG.h util.h SDG.h defUseChains.h newCDG.h newDDG.h

EXTRA_DIST =
5 changes: 3 additions & 2 deletions src/roseExtensions/failSafe/failSafePragma.C
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void FailSafe::removeAttribute(FailSafe::Attribute* attribute, SgNode* node)

AttributeList* cur_list = getAttributeList(node);
ROSE_ASSERT (cur_list != NULL);
(cur_list->attriList);
// (cur_list->attriList);
vector <Attribute* >::iterator h_pos = find ((cur_list->attriList).begin(), (cur_list->attriList).end(), attribute);
ROSE_ASSERT (h_pos != (cur_list->attriList).end());
(cur_list->attriList).erase (h_pos);
Expand Down Expand Up @@ -746,7 +746,8 @@ FailSafe::Attribute* FailSafe::parse_fail_safe_directive (SgPragmaDeclaration* p
c_sgnode = getNextStatement(pragmaDecl);
//A pragma can show up in front of the structured block affected
// or follow declarations it relies on (as data predicate)
if (c_sgnode == NULL);
// MS: 11/22/2015 removed ';' from "if (c_sgnode == NULL);"
if (c_sgnode == NULL)
c_sgnode = pragmaDecl; // use the pragma as the anchor AST to enable scope search
assert (c_sgnode != NULL);

Expand Down
3 changes: 2 additions & 1 deletion src/util/Sawyer/AddressMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ class AddressMapConstraints {
}
void
traverse(typename AddressMap::Visitor &visitor, MatchFlags flags=0) const {
return map_->traverse<typename AddressMap::Visitor>(visitor, *this, flags);
// MS 11/22/2015: added "template " (required by clang++)
return map_->template traverse<typename AddressMap::Visitor>(visitor, *this, flags);
}

Sawyer::Container::Interval<Address>
Expand Down
Loading

0 comments on commit 45243ff

Please sign in to comment.