diff options
author | dim <dim@FreeBSD.org> | 2012-12-02 13:20:44 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-12-02 13:20:44 +0000 |
commit | 056abd2059c65a3e908193aeae16fad98017437c (patch) | |
tree | 2732d02d7d51218d6eed98ac7fcfc5b8794896b5 /include/clang/Analysis | |
parent | cc73504950eb7b5dff2dded9bedd67bc36d64641 (diff) | |
download | FreeBSD-src-056abd2059c65a3e908193aeae16fad98017437c.zip FreeBSD-src-056abd2059c65a3e908193aeae16fad98017437c.tar.gz |
Vendor import of clang release_32 branch r168974 (effectively, 3.2 RC2):
http://llvm.org/svn/llvm-project/cfe/branches/release_32@168974
Diffstat (limited to 'include/clang/Analysis')
-rw-r--r-- | include/clang/Analysis/Analyses/FormatString.h | 24 | ||||
-rw-r--r-- | include/clang/Analysis/Analyses/ThreadSafety.h | 3 | ||||
-rw-r--r-- | include/clang/Analysis/AnalysisContext.h | 35 | ||||
-rw-r--r-- | include/clang/Analysis/CFG.h | 6 | ||||
-rw-r--r-- | include/clang/Analysis/DomainSpecific/ObjCNoReturn.h | 46 | ||||
-rw-r--r-- | include/clang/Analysis/ProgramPoint.h | 7 |
6 files changed, 99 insertions, 22 deletions
diff --git a/include/clang/Analysis/Analyses/FormatString.h b/include/clang/Analysis/Analyses/FormatString.h index 7f50ee3..5cb9731 100644 --- a/include/clang/Analysis/Analyses/FormatString.h +++ b/include/clang/Analysis/Analyses/FormatString.h @@ -23,6 +23,8 @@ namespace clang { +class TargetInfo; + //===----------------------------------------------------------------------===// /// Common components of both fprintf and fscanf format strings. namespace analyze_format_string { @@ -115,11 +117,14 @@ public: // C99 conversion specifiers. cArg, dArg, + DArg, // Apple extension iArg, - IntArgBeg = cArg, IntArgEnd = iArg, + IntArgBeg = dArg, IntArgEnd = iArg, oArg, + OArg, // Apple extension uArg, + UArg, // Apple extension xArg, XArg, UIntArgBeg = oArg, UIntArgEnd = XArg, @@ -157,7 +162,7 @@ public: ScanfConvBeg = ScanListArg, ScanfConvEnd = ScanListArg }; - ConversionSpecifier(bool isPrintf) + ConversionSpecifier(bool isPrintf = true) : IsPrintf(isPrintf), Position(0), EndScanList(0), kind(InvalidSpecifier) {} ConversionSpecifier(bool isPrintf, const char *pos, Kind k) @@ -189,10 +194,14 @@ public: return EndScanList ? EndScanList - Position : 1; } + bool isIntArg() const { return kind >= IntArgBeg && kind <= IntArgEnd; } bool isUIntArg() const { return kind >= UIntArgBeg && kind <= UIntArgEnd; } + bool isAnyIntArg() const { return kind >= IntArgBeg && kind <= UIntArgEnd; } const char *toString() const; bool isPrintfKind() const { return IsPrintf; } + + llvm::Optional<ConversionSpecifier> getStandardSpecifier() const; protected: bool IsPrintf; @@ -348,10 +357,12 @@ public: bool usesPositionalArg() const { return UsesPositionalArg; } - bool hasValidLengthModifier() const; + bool hasValidLengthModifier(const TargetInfo &Target) const; bool hasStandardLengthModifier() const; + llvm::Optional<LengthModifier> getCorrectedLengthModifier() const; + bool hasStandardConversionSpecifier(const LangOptions &LangOpt) const; bool hasStandardLengthConversionCombination() const; @@ -378,7 +389,6 @@ public: : ConversionSpecifier(true, pos, k) {} bool isObjCArg() const { return kind >= ObjCBeg && kind <= ObjCEnd; } - bool isIntArg() const { return kind >= IntArgBeg && kind <= IntArgEnd; } bool isDoubleArg() const { return kind >= DoubleArgBeg && kind <= DoubleArgEnd; } unsigned getLength() const { @@ -623,10 +633,12 @@ public: }; bool ParsePrintfString(FormatStringHandler &H, - const char *beg, const char *end, const LangOptions &LO); + const char *beg, const char *end, const LangOptions &LO, + const TargetInfo &Target); bool ParseScanfString(FormatStringHandler &H, - const char *beg, const char *end, const LangOptions &LO); + const char *beg, const char *end, const LangOptions &LO, + const TargetInfo &Target); } // end analyze_format_string namespace } // end clang namespace diff --git a/include/clang/Analysis/Analyses/ThreadSafety.h b/include/clang/Analysis/Analyses/ThreadSafety.h index 742cc04..ef6b821 100644 --- a/include/clang/Analysis/Analyses/ThreadSafety.h +++ b/include/clang/Analysis/Analyses/ThreadSafety.h @@ -132,7 +132,8 @@ public: /// \param Loc -- The location of the protected operation. virtual void handleMutexNotHeld(const NamedDecl *D, ProtectedOperationKind POK, Name LockName, - LockKind LK, SourceLocation Loc) {} + LockKind LK, SourceLocation Loc, + Name *PossibleMatch=0) {} /// Warn when a function is called while an excluded mutex is locked. For /// example, the mutex may be locked inside the function. diff --git a/include/clang/Analysis/AnalysisContext.h b/include/clang/Analysis/AnalysisContext.h index 46b4e93..5246678 100644 --- a/include/clang/Analysis/AnalysisContext.h +++ b/include/clang/Analysis/AnalysisContext.h @@ -72,7 +72,7 @@ class AnalysisDeclContext { /// AnalysisDeclContext. This may be null. AnalysisDeclContextManager *Manager; - const Decl *D; + const Decl * const D; OwningPtr<CFG> cfg, completeCFG; OwningPtr<CFGStmtMap> cfgStmtMap; @@ -81,9 +81,6 @@ class AnalysisDeclContext { CFG::BuildOptions::ForcedBlkExprs *forcedBlkExprs; bool builtCFG, builtCompleteCFG; - - OwningPtr<LiveVariables> liveness; - OwningPtr<LiveVariables> relaxedLiveness; OwningPtr<ParentMap> PM; OwningPtr<PseudoConstantAnalysis> PCA; OwningPtr<CFGReverseBlockReachabilityAnalysis> CFA; @@ -104,9 +101,15 @@ public: ~AnalysisDeclContext(); - ASTContext &getASTContext() { return D->getASTContext(); } + ASTContext &getASTContext() const { return D->getASTContext(); } const Decl *getDecl() const { return D; } + /// Return the AnalysisDeclContextManager (if any) that created + /// this AnalysisDeclContext. + AnalysisDeclContextManager *getManager() const { + return Manager; + } + /// Return the build options used to construct the CFG. CFG::BuildOptions &getCFGBuildOptions() { return cfgBuildOptions; @@ -234,9 +237,10 @@ public: const StackFrameContext *getCurrentStackFrame() const; - virtual void Profile(llvm::FoldingSetNodeID &ID) = 0; + /// Return true if the current LocationContext has no caller context. + virtual bool inTopFrame() const; - static bool classof(const LocationContext*) { return true; } + virtual void Profile(llvm::FoldingSetNodeID &ID) = 0; public: static void ProfileCommon(llvm::FoldingSetNodeID &ID, @@ -270,6 +274,9 @@ public: const CFGBlock *getCallSiteBlock() const { return Block; } + /// Return true if the current LocationContext has no caller context. + virtual bool inTopFrame() const { return getParent() == 0; } + unsigned getIndex() const { return Index; } void Profile(llvm::FoldingSetNodeID &ID); @@ -379,11 +386,17 @@ class AnalysisDeclContextManager { ContextMap Contexts; LocationContextManager LocContexts; CFG::BuildOptions cfgBuildOptions; + + /// Flag to indicate whether or not bodies should be synthesized + /// for well-known functions. + bool SynthesizeBodies; public: AnalysisDeclContextManager(bool useUnoptimizedCFG = false, - bool addImplicitDtors = false, - bool addInitializers = false); + bool addImplicitDtors = false, + bool addInitializers = false, + bool addTemporaryDtors = false, + bool synthesizeBodies = false); ~AnalysisDeclContextManager(); @@ -396,6 +409,10 @@ public: CFG::BuildOptions &getCFGBuildOptions() { return cfgBuildOptions; } + + /// Return true if faux bodies should be synthesized for well-known + /// functions. + bool synthesizeBodies() const { return SynthesizeBodies; } const StackFrameContext *getStackFrame(AnalysisDeclContext *Ctx, LocationContext const *Parent, diff --git a/include/clang/Analysis/CFG.h b/include/clang/Analysis/CFG.h index 4d087e7..8cc5d81 100644 --- a/include/clang/Analysis/CFG.h +++ b/include/clang/Analysis/CFG.h @@ -88,8 +88,6 @@ public: return static_cast<const ElemTy*>(this); return 0; } - - static bool classof(const CFGElement *E) { return true; } }; class CFGStmt : public CFGElement { @@ -568,6 +566,7 @@ public: bool AddEHEdges; bool AddInitializers; bool AddImplicitDtors; + bool AddTemporaryDtors; bool alwaysAdd(const Stmt *stmt) const { return alwaysAddMask[stmt->getStmtClass()]; @@ -587,7 +586,8 @@ public: : forcedBlkExprs(0), PruneTriviallyFalseEdges(true) ,AddEHEdges(false) ,AddInitializers(false) - ,AddImplicitDtors(false) {} + ,AddImplicitDtors(false) + ,AddTemporaryDtors(false) {} }; /// \brief Provides a custom implementation of the iterator class to have the diff --git a/include/clang/Analysis/DomainSpecific/ObjCNoReturn.h b/include/clang/Analysis/DomainSpecific/ObjCNoReturn.h new file mode 100644 index 0000000..930c2bd --- /dev/null +++ b/include/clang/Analysis/DomainSpecific/ObjCNoReturn.h @@ -0,0 +1,46 @@ +//= ObjCNoReturn.h - Handling of Cocoa APIs known not to return --*- C++ -*---// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements special handling of recognizing ObjC API hooks that +// do not return but aren't marked as such in API headers. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_ANALYSIS_DS_OBJCNORETURN +#define LLVM_CLANG_ANALYSIS_DS_OBJCNORETURN + +#include "clang/Basic/IdentifierTable.h" + +namespace clang { + +class ASTContext; +class ObjCMessageExpr; + +class ObjCNoReturn { + /// Cached "raise" selector. + Selector RaiseSel; + + /// Cached identifier for "NSException". + IdentifierInfo *NSExceptionII; + + enum { NUM_RAISE_SELECTORS = 2 }; + + /// Cached set of selectors in NSException that are 'noreturn'. + Selector NSExceptionInstanceRaiseSelectors[NUM_RAISE_SELECTORS]; + +public: + ObjCNoReturn(ASTContext &C); + + /// Return true if the given message expression is known to never + /// return. + bool isImplicitNoReturn(const ObjCMessageExpr *ME); +}; +} + +#endif diff --git a/include/clang/Analysis/ProgramPoint.h b/include/clang/Analysis/ProgramPoint.h index 5de06cd..9479978 100644 --- a/include/clang/Analysis/ProgramPoint.h +++ b/include/clang/Analysis/ProgramPoint.h @@ -140,8 +140,6 @@ public: return ID.ComputeHash(); } - static bool classof(const ProgramPoint*) { return true; } - bool operator==(const ProgramPoint & RHS) const { return Data1 == RHS.Data1 && Data2 == RHS.Data2 && @@ -213,7 +211,9 @@ class StmtPoint : public ProgramPoint { public: StmtPoint(const Stmt *S, const void *p2, Kind k, const LocationContext *L, const ProgramPointTag *tag) - : ProgramPoint(S, p2, k, L, tag) {} + : ProgramPoint(S, p2, k, L, tag) { + assert(S); + } const Stmt *getStmt() const { return (const Stmt*) getData1(); } @@ -461,6 +461,7 @@ public: }; /// Represents a point when we begin processing an inlined call. +/// CallEnter uses the caller's location context. class CallEnter : public ProgramPoint { public: CallEnter(const Stmt *stmt, const StackFrameContext *calleeCtx, |