jkorous-apple created this revision. Added array type mangling to USR generation. Included test from bug report.
Repository: rL LLVM 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,22 @@ T = VT->getElementType(); continue; } + if (const ArrayType *const AT = dyn_cast<ArrayType>(T)) { + VisitType(AT->getElementType()); + Out << "["; + + switch( AT->getSizeModifier() ) { + case ArrayType::Static : Out << "s"; break; + case ArrayType::Star : Out << "*"; break; + default : ; + } + if (const ConstantArrayType* const CAT = dyn_cast<ConstantArrayType>(T)) { + Out << CAT->getSize(); + } + + Out << "]"; + return; + } // 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,22 @@ T = VT->getElementType(); continue; } + if (const ArrayType *const AT = dyn_cast<ArrayType>(T)) { + VisitType(AT->getElementType()); + Out << "["; + + switch( AT->getSizeModifier() ) { + case ArrayType::Static : Out << "s"; break; + case ArrayType::Star : Out << "*"; break; + default : ; + } + if (const ConstantArrayType* const CAT = dyn_cast<ConstantArrayType>(T)) { + Out << CAT->getSize(); + } + + Out << "]"; + return; + } // Unhandled type. Out << ' ';
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits