mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-08 20:16:05 +00:00

While destructors will continue to not be inlined (unless the analyzer config option 'c++-inlining' is set to 'destructors'), leaving them out of the CFG is an incomplete model of the behavior of an object, and can cause false positive warnings (like PR13751, now working). Destructors for temporaries are still not on by default, since (a) we haven't actually checked this code to be sure it's fully correct (in particular, we probably need to be very careful with regard to lifetime-extension when a temporary is bound to a reference, C++11 [class.temporary]p5), and (b) ExprEngine doesn't actually do anything when it sees a temporary destructor in the CFG -- not even invalidate the object region. To enable temporary destructors, set the 'cfg-temporary-dtors' analyzer config option to '1'. The old -cfg-add-implicit-dtors cc1 option, which controlled all implicit destructors, has been removed. llvm-svn: 163264
53 lines
1.7 KiB
C++
53 lines
1.7 KiB
C++
//===-- AnalyzerOptions.cpp - Analysis Engine Options -----------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file contains special accessors for analyzer configuration options
|
|
// with string representations.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
|
|
#include "llvm/ADT/StringSwitch.h"
|
|
|
|
using namespace clang;
|
|
|
|
bool
|
|
AnalyzerOptions::mayInlineCXXMemberFunction(CXXInlineableMemberKind K) const {
|
|
if (IPAMode < Inlining)
|
|
return false;
|
|
|
|
if (!CXXMemberInliningMode) {
|
|
static const char *ModeKey = "c++-inlining";
|
|
std::string ModeStr = Config.lookup(ModeKey);
|
|
|
|
CXXInlineableMemberKind &MutableMode =
|
|
const_cast<CXXInlineableMemberKind &>(CXXMemberInliningMode);
|
|
|
|
MutableMode = llvm::StringSwitch<CXXInlineableMemberKind>(ModeStr)
|
|
.Case("", CIMK_MemberFunctions)
|
|
.Case("constructors", CIMK_Constructors)
|
|
.Case("destructors", CIMK_Destructors)
|
|
.Case("none", CIMK_None)
|
|
.Case("methods", CIMK_MemberFunctions)
|
|
.Default(CXXInlineableMemberKind());
|
|
|
|
if (!MutableMode) {
|
|
// FIXME: We should emit a warning here about an unknown inlining kind,
|
|
// but the AnalyzerOptions doesn't have access to a diagnostic engine.
|
|
MutableMode = CIMK_None;
|
|
}
|
|
}
|
|
|
|
return CXXMemberInliningMode >= K;
|
|
}
|
|
|
|
bool AnalyzerOptions::includeTemporaryDtorsInCFG() const {
|
|
return !Config.lookup("cfg-temporary-dtors").empty();
|
|
}
|