guillem-bartrina-sonarsource wrote:

@balazske Do you think we can move forward with this PR?

I have found a reduced crashing test case that would be fixed by this patch.

```cpp

// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t

// RUN: %clang_cc1 -std=c++14 -emit-pch -o %t/IdentifierTable.cpp.ast 
%t/IdentifierTable.cpp

// RUN: %clang_extdef_map %t/IdentifierTable.cpp -- -std=c++14 > 
%t/externalDefMap.tmp.txt
// On windows, absolute paths generated by extdef_map are not recognized,
// so CSA prepends the workdir path to them. Force relative paths to work
// around this issue.
// RUN: sed -e 's| .*IdentifierTable\.cpp| IdentifierTable.cpp.ast|' \
// RUN:   %t/externalDefMap.tmp.txt > %t/externalDefMap.txt

// RUN: %clang_cc1 -std=c++14 -analyze \
// RUN:   -analyzer-checker=core \
// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
// RUN:   -analyzer-config ctu-dir=%t \
// RUN:   -verify %t/main.cpp

//--- main.cpp

namespace llvm { void trigger(); }

void entry() { llvm::trigger(); }

//--- IdentifierTable.cpp

template <typename> using a = int;

namespace llvm {

// This function's deduced return type retains the alias-template sugar
// `a<int[]>`, whose template argument is an incomplete array type.
// ASTImporter's hasReturnTypeDeclaredInside() walks a deduced return type
// assuming it can never contain an incomplete/variable/dependent array
// (see IsTypeDeclaredInsideVisitor::VisitIncompleteArrayType()), which
// isn't true here, and hits its llvm_unreachable().
auto plainFunc() {
  return a<int[]>();
}

void trigger() {}

} // namespace llvm

```

https://github.com/llvm/llvm-project/pull/169504
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to