jkorous-apple updated this revision to Diff 118104. jkorous-apple added a comment.
Ammenended as suggested. https://reviews.llvm.org/D38643 Files: lib/Index/USRGeneration.cpp test/Index/USR/array-type.cpp Index: test/Index/USR/array-type.cpp =================================================================== --- /dev/null +++ test/Index/USR/array-type.cpp @@ -0,0 +1,8 @@ +// RUN: c-index-test core -print-source-symbols -- %s | grep "function(Gen,TS)/C++" | grep foo | cut -s -d "|" -f 4 | uniq | wc -l | grep 3 + +// Function template specializations differing in array type parameter should have unique USRs. + +template<class buffer> void foo(buffer); +template<> void foo<char[16]>(char[16]); +template<> void foo<char[32]>(char[32]); +template<> void foo<char[64]>(char[64]); Index: lib/Index/USRGeneration.cpp =================================================================== --- lib/Index/USRGeneration.cpp +++ lib/Index/USRGeneration.cpp @@ -816,6 +816,20 @@ T = VT->getElementType(); continue; } + if (const ArrayType *const AT = dyn_cast<ArrayType>(T)) { + Out << "{"; + switch( AT->getSizeModifier() ) { + case ArrayType::Static : Out << "s"; break; + case ArrayType::Star : Out << "*"; break; + case ArrayType::Normal : Out << "n"; break; + } + if (const ConstantArrayType* const CAT = dyn_cast<ConstantArrayType>(T)) { + Out << CAT->getSize(); + } + Out << "}"; + T = AT->getElementType(); + continue; + } // Unhandled type. Out << ' ';
Index: test/Index/USR/array-type.cpp =================================================================== --- /dev/null +++ test/Index/USR/array-type.cpp @@ -0,0 +1,8 @@ +// RUN: c-index-test core -print-source-symbols -- %s | grep "function(Gen,TS)/C++" | grep foo | cut -s -d "|" -f 4 | uniq | wc -l | grep 3 + +// Function template specializations differing in array type parameter should have unique USRs. + +template<class buffer> void foo(buffer); +template<> void foo<char[16]>(char[16]); +template<> void foo<char[32]>(char[32]); +template<> void foo<char[64]>(char[64]); Index: lib/Index/USRGeneration.cpp =================================================================== --- lib/Index/USRGeneration.cpp +++ lib/Index/USRGeneration.cpp @@ -816,6 +816,20 @@ T = VT->getElementType(); continue; } + if (const ArrayType *const AT = dyn_cast<ArrayType>(T)) { + Out << "{"; + switch( AT->getSizeModifier() ) { + case ArrayType::Static : Out << "s"; break; + case ArrayType::Star : Out << "*"; break; + case ArrayType::Normal : Out << "n"; break; + } + if (const ConstantArrayType* const CAT = dyn_cast<ConstantArrayType>(T)) { + Out << CAT->getSize(); + } + Out << "}"; + T = AT->getElementType(); + continue; + } // Unhandled type. Out << ' ';
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits