Introduce Transform::Config::DropDefaultArg
Currently only implemented for the STL collection. This could eventually be used to allow customization of which default argument to strip and which class template. For now, it is only used to prevent the addition of template default template argument to the STL collection ... which we would any strip. This fixes the secondary issue in ROOT-6020 (one class template instance having more than one corresponding TClass due to the inconsistency in the normalization (not adding vs not stripping)
This commit is contained in:
parent
1004034c75
commit
c6501ffe97
@ -27,6 +27,7 @@ namespace clang {
|
||||
class QualType;
|
||||
class Sema;
|
||||
class TagDecl;
|
||||
class TemplateDecl;
|
||||
class Type;
|
||||
class TypedefNameDecl;
|
||||
}
|
||||
@ -135,6 +136,12 @@ namespace utils {
|
||||
SkipCollection m_toSkip;
|
||||
ReplaceCollection m_toReplace;
|
||||
|
||||
///\brief Returns the number of default argument that should be dropped.
|
||||
/// from the name of the template instances.
|
||||
///
|
||||
///\param[in] decl - The declaration being analyzed.
|
||||
unsigned int DropDefaultArg(clang::TemplateDecl &Template) const;
|
||||
|
||||
bool empty() const { return m_toSkip.size()==0 && m_toReplace.empty(); }
|
||||
};
|
||||
|
||||
|
@ -583,6 +583,32 @@ namespace utils {
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
Transform::Config::DropDefaultArg(clang::TemplateDecl &Template) const
|
||||
{
|
||||
/// Return the number of default argument to drop.
|
||||
|
||||
if (Analyze::IsStdClass(Template)) {
|
||||
static const char *stls[] = //container names
|
||||
{"vector","list","deque","map","multimap","set","multiset",0};
|
||||
static unsigned int values[] = //number of default arg.
|
||||
{1,1,1,2,2,2,2};
|
||||
StringRef name = Template.getName();
|
||||
for(int k=0;stls[k];k++) {
|
||||
if ( name.equals(stls[k]) ) return values[k];
|
||||
}
|
||||
}
|
||||
// Check in some struct if the Template decl is registered something like
|
||||
/*
|
||||
DefaultCollection::const_iterator iter;
|
||||
iter = m_defaultArgs.find(&Template);
|
||||
if (iter != m_defaultArgs.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool ShouldKeepTypedef(QualType QT,
|
||||
const llvm::SmallSet<const Type*, 4>& TypesToSkip)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user