Index: lib/Analysis/BodyFarm.cpp =================================================================== --- lib/Analysis/BodyFarm.cpp +++ lib/Analysis/BodyFarm.cpp @@ -362,6 +362,12 @@ /* GetNonReferenceType=*/true); CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl(); + if (FlagCXXDecl == nullptr) { + DEBUG(llvm::dbgs() << "Flag field is not a CXX record: " + << "unknown std::call_once implementation." + << "Ignoring the call.\n"); + return nullptr; + } // Note: here we are assuming libc++ implementation of call_once, // which has a struct with a field `__state_`. Index: test/Analysis/call_once.cpp =================================================================== --- test/Analysis/call_once.cpp +++ test/Analysis/call_once.cpp @@ -231,3 +231,12 @@ int x = call_once(); clang_analyzer_eval(x == 5); // expected-warning{{TRUE}} } + +namespace std { +template +void call_once(d, e); +} +void g(); +void test_no_segfault_on_different_impl() { + std::call_once(g, false); // no-warning +}