[llvm-branch-commits] [cfe-branch] r149376 - in /cfe/branches/tooling: ./ include/clang/Analysis/Analyses/ include/clang/Basic/ include/clang/Driver/ include/clang/Sema/ include/clang/StaticAnalyzer/Core/ include/clang/StaticAnalyzer/Core/PathSensitive/ lib/AST/ lib/Analysis/ lib/Basic/ lib/CodeGen/ lib/Driver/ lib/Headers/ lib/Sema/ lib/StaticAnalyzer/Checkers/ lib/StaticAnalyzer/Core/ test/Analysis/ test/CXX/expr/expr.const/ test/CodeGenCXX/ test/CodeGenObjC/ test/Driver/ test/Driver/prefixed-tools.c-helper/ test/Modules/ t...
Manuel Klimek
klimek at google.com
Tue Jan 31 02:14:41 PST 2012
Author: klimek
Date: Tue Jan 31 04:14:40 2012
New Revision: 149376
URL: http://llvm.org/viewvc/llvm-project?rev=149376&view=rev
Log:
Merging mainline.
Added:
cfe/branches/tooling/test/CodeGenObjC/ns_consume_null_check.m
- copied unchanged from r149375, cfe/trunk/test/CodeGenObjC/ns_consume_null_check.m
Removed:
cfe/branches/tooling/test/Driver/prefixed-tools.c
cfe/branches/tooling/test/Driver/prefixed-tools.c-helper/x86_64--linux-as
cfe/branches/tooling/test/Driver/prefixed-tools.c-helper/x86_64--linux-ld
Modified:
cfe/branches/tooling/ (props changed)
cfe/branches/tooling/include/clang/Analysis/Analyses/FormatString.h
cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td
cfe/branches/tooling/include/clang/Driver/ToolChain.h
cfe/branches/tooling/include/clang/Sema/Sema.h
cfe/branches/tooling/include/clang/StaticAnalyzer/Core/Checker.h
cfe/branches/tooling/include/clang/StaticAnalyzer/Core/CheckerManager.h
cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h
cfe/branches/tooling/lib/AST/Expr.cpp
cfe/branches/tooling/lib/AST/ExprConstant.cpp
cfe/branches/tooling/lib/AST/ItaniumMangle.cpp
cfe/branches/tooling/lib/Analysis/PrintfFormatString.cpp
cfe/branches/tooling/lib/Basic/Targets.cpp
cfe/branches/tooling/lib/CodeGen/CGDecl.cpp
cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp
cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp
cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp
cfe/branches/tooling/lib/CodeGen/CGRTTI.cpp
cfe/branches/tooling/lib/CodeGen/CodeGenAction.cpp
cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
cfe/branches/tooling/lib/Driver/Driver.cpp
cfe/branches/tooling/lib/Driver/ToolChain.cpp
cfe/branches/tooling/lib/Driver/ToolChains.cpp
cfe/branches/tooling/lib/Driver/ToolChains.h
cfe/branches/tooling/lib/Driver/Tools.cpp
cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp
cfe/branches/tooling/lib/Headers/module.map
cfe/branches/tooling/lib/Sema/SemaChecking.cpp
cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp
cfe/branches/tooling/lib/Sema/SemaOverload.cpp
cfe/branches/tooling/lib/Sema/SemaTemplate.cpp
cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/Checker.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/ProgramState.cpp
cfe/branches/tooling/test/Analysis/CFContainers.mm
cfe/branches/tooling/test/CXX/expr/expr.const/p2-0x.cpp
cfe/branches/tooling/test/CodeGenCXX/mangle.cpp
cfe/branches/tooling/test/CodeGenObjC/arc.m
cfe/branches/tooling/test/Modules/compiler_builtins.m
cfe/branches/tooling/test/Preprocessor/init.c
cfe/branches/tooling/test/Sema/conversion-64-32.c
cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp (props changed)
cfe/branches/tooling/test/SemaObjC/format-strings-objc.m
Propchange: cfe/branches/tooling/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 31 04:14:40 2012
@@ -1,3 +1,3 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:146581-149245
+/cfe/trunk:146581-149375
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/tooling/include/clang/Analysis/Analyses/FormatString.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Analysis/Analyses/FormatString.h?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Analysis/Analyses/FormatString.h (original)
+++ cfe/branches/tooling/include/clang/Analysis/Analyses/FormatString.h Tue Jan 31 04:14:40 2012
@@ -455,7 +455,7 @@
/// will return null if the format specifier does not have
/// a matching data argument or the matching argument matches
/// more than one type.
- ArgTypeResult getArgType(ASTContext &Ctx) const;
+ ArgTypeResult getArgType(ASTContext &Ctx, bool IsObjCLiteral) const;
const OptionalFlag &hasThousandsGrouping() const {
return HasThousandsGrouping;
Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td Tue Jan 31 04:14:40 2012
@@ -20,6 +20,10 @@
"cannot cast object of dynamic type %0 to type %1">;
def note_constexpr_overflow : Note<
"value %0 is outside the range of representable values of type %1">;
+def note_constexpr_negative_shift : Note<"negative shift count %0">;
+def note_constexpr_large_shift : Note<
+ "shift count %0 >= width of type %1 (%2 bit%s2)">;
+def note_constexpr_lshift_of_negative : Note<"left shift of negative value %0">;
def note_constexpr_invalid_function : Note<
"%select{non-constexpr|undefined}0 %select{function|constructor}1 %2 cannot "
"be used in a constant expression">;
@@ -49,6 +53,8 @@
def note_constexpr_typeid_polymorphic : Note<
"typeid applied to expression of polymorphic type %0 is "
"not allowed in a constant expression">;
+def note_constexpr_void_comparison : Note<
+ "comparison between unequal pointers to void has unspecified result">;
def note_constexpr_temporary_here : Note<"temporary created here">;
def note_constexpr_literal_here : Note<"literal written here">;
def note_constexpr_depth_limit_exceeded : Note<
Modified: cfe/branches/tooling/include/clang/Driver/ToolChain.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/ToolChain.h?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/ToolChain.h (original)
+++ cfe/branches/tooling/include/clang/Driver/ToolChain.h Tue Jan 31 04:14:40 2012
@@ -46,9 +46,6 @@
private:
const Driver &D;
const llvm::Triple Triple;
- /// The target triple originally requested by the user
- /// before modifications due to -m32 and without normalization.
- const std::string UserTriple;
/// The list of toolchain specific path prefixes to search for
/// files.
@@ -59,7 +56,7 @@
path_list ProgramPaths;
protected:
- ToolChain(const Driver &D, const llvm::Triple &T, const std::string &UT);
+ ToolChain(const Driver &D, const llvm::Triple &T);
/// \name Utilities for implementing subclasses.
///@{
@@ -90,9 +87,6 @@
std::string getTripleString() const {
return Triple.getTriple();
}
- const std::string &getUserTriple() const {
- return UserTriple;
- }
path_list &getFilePaths() { return FilePaths; }
const path_list &getFilePaths() const { return FilePaths; }
Modified: cfe/branches/tooling/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/Sema.h?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Sema.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Sema.h Tue Jan 31 04:14:40 2012
@@ -45,6 +45,7 @@
class APSInt;
template <typename ValueT> struct DenseMapInfo;
template <typename ValueT, typename ValueInfoT> class DenseSet;
+ class SmallBitVector;
}
namespace clang {
@@ -4702,14 +4703,14 @@
void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
bool OnlyDeduced,
unsigned Depth,
- SmallVectorImpl<bool> &Used);
+ llvm::SmallBitVector &Used);
void MarkDeducedTemplateParameters(FunctionTemplateDecl *FunctionTemplate,
- SmallVectorImpl<bool> &Deduced) {
+ llvm::SmallBitVector &Deduced) {
return MarkDeducedTemplateParameters(Context, FunctionTemplate, Deduced);
}
static void MarkDeducedTemplateParameters(ASTContext &Ctx,
FunctionTemplateDecl *FunctionTemplate,
- SmallVectorImpl<bool> &Deduced);
+ llvm::SmallBitVector &Deduced);
//===--------------------------------------------------------------------===//
// C++ Template Instantiation
Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/Checker.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/Checker.h?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/Checker.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/Checker.h Tue Jan 31 04:14:40 2012
@@ -230,7 +230,7 @@
class LiveSymbols {
template <typename CHECKER>
- static void _checkLiveSymbols(void *checker, const ProgramState *state,
+ static void _checkLiveSymbols(void *checker, ProgramStateRef state,
SymbolReaper &SR) {
((const CHECKER *)checker)->checkLiveSymbols(state, SR);
}
@@ -260,9 +260,9 @@
class RegionChanges {
template <typename CHECKER>
- static const ProgramState *
+ static ProgramStateRef
_checkRegionChanges(void *checker,
- const ProgramState *state,
+ ProgramStateRef state,
const StoreManager::InvalidatedSymbols *invalidated,
ArrayRef<const MemRegion *> Explicits,
ArrayRef<const MemRegion *> Regions) {
@@ -271,7 +271,7 @@
}
template <typename CHECKER>
static bool _wantsRegionChangeUpdate(void *checker,
- const ProgramState *state) {
+ ProgramStateRef state) {
return ((const CHECKER *)checker)->wantsRegionChangeUpdate(state);
}
@@ -306,8 +306,8 @@
class Assume {
template <typename CHECKER>
- static const ProgramState *_evalAssume(void *checker,
- const ProgramState *state,
+ static ProgramStateRef _evalAssume(void *checker,
+ ProgramStateRef state,
const SVal &cond,
bool assumption) {
return ((const CHECKER *)checker)->evalAssume(state, cond, assumption);
@@ -359,7 +359,7 @@
StringRef getTagDescription() const;
/// See CheckerManager::runCheckersForPrintState.
- virtual void printState(raw_ostream &Out, const ProgramState *State,
+ virtual void printState(raw_ostream &Out, ProgramStateRef State,
const char *NL, const char *Sep) const { }
};
Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/CheckerManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/CheckerManager.h?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/CheckerManager.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/CheckerManager.h Tue Jan 31 04:14:40 2012
@@ -244,7 +244,7 @@
/// Allows modifying SymbolReaper object. For example, checkers can explicitly
/// register symbols of interest as live. These symbols will not be marked
/// dead and removed.
- void runCheckersForLiveSymbols(const ProgramState *state,
+ void runCheckersForLiveSymbols(ProgramStateRef state,
SymbolReaper &SymReaper);
/// \brief Run checkers for dead symbols.
@@ -258,7 +258,7 @@
ExprEngine &Eng);
/// \brief True if at least one checker wants to check region changes.
- bool wantsRegionChangeUpdate(const ProgramState *state);
+ bool wantsRegionChangeUpdate(ProgramStateRef state);
/// \brief Run checkers for region changes.
///
@@ -269,15 +269,15 @@
/// For example, in the case of a function call, these would be arguments.
/// \param Regions The transitive closure of accessible regions,
/// i.e. all regions that may have been touched by this change.
- const ProgramState *
- runCheckersForRegionChanges(const ProgramState *state,
+ ProgramStateRef
+ runCheckersForRegionChanges(ProgramStateRef state,
const StoreManager::InvalidatedSymbols *invalidated,
ArrayRef<const MemRegion *> ExplicitRegions,
ArrayRef<const MemRegion *> Regions);
/// \brief Run checkers for handling assumptions on symbolic values.
- const ProgramState *runCheckersForEvalAssume(const ProgramState *state,
- SVal Cond, bool Assumption);
+ ProgramStateRef runCheckersForEvalAssume(ProgramStateRef state,
+ SVal Cond, bool Assumption);
/// \brief Run checkers for evaluating a call.
void runCheckersForEvalCall(ExplodedNodeSet &Dst,
@@ -298,7 +298,7 @@
/// \param State The state being printed
/// \param NL The preferred representation of a newline.
/// \param Sep The preferred separator between different kinds of data.
- void runCheckersForPrintState(raw_ostream &Out, const ProgramState *State,
+ void runCheckersForPrintState(raw_ostream &Out, ProgramStateRef State,
const char *NL, const char *Sep);
//===----------------------------------------------------------------------===//
@@ -345,17 +345,17 @@
typedef CheckerFn<void (SymbolReaper &, CheckerContext &)>
CheckDeadSymbolsFunc;
- typedef CheckerFn<void (const ProgramState *,SymbolReaper &)> CheckLiveSymbolsFunc;
+ typedef CheckerFn<void (ProgramStateRef,SymbolReaper &)> CheckLiveSymbolsFunc;
- typedef CheckerFn<const ProgramState * (const ProgramState *,
+ typedef CheckerFn<ProgramStateRef (ProgramStateRef,
const StoreManager::InvalidatedSymbols *symbols,
ArrayRef<const MemRegion *> ExplicitRegions,
ArrayRef<const MemRegion *> Regions)>
CheckRegionChangesFunc;
- typedef CheckerFn<bool (const ProgramState *)> WantsRegionChangeUpdateFunc;
+ typedef CheckerFn<bool (ProgramStateRef)> WantsRegionChangeUpdateFunc;
- typedef CheckerFn<const ProgramState * (const ProgramState *,
+ typedef CheckerFn<ProgramStateRef (ProgramStateRef,
const SVal &cond, bool assumption)>
EvalAssumeFunc;
Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h Tue Jan 31 04:14:40 2012
@@ -33,10 +33,10 @@
DefinedSVal Cond,
bool Assumption) = 0;
- std::pair<ProgramStateRef , ProgramStateRef >
+ std::pair<ProgramStateRef, ProgramStateRef >
assumeDual(ProgramStateRef state, DefinedSVal Cond)
{
- std::pair<ProgramStateRef , ProgramStateRef > res =
+ std::pair<ProgramStateRef, ProgramStateRef > res =
std::make_pair(assume(state, Cond, true), assume(state, Cond, false));
assert(!(!res.first && !res.second) && "System is over constrained.");
Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h Tue Jan 31 04:14:40 2012
@@ -119,14 +119,11 @@
explicit ExplodedNode(const ProgramPoint &loc, ProgramStateRef state,
bool IsSink)
: Location(loc), State(state) {
- const_cast<ProgramState*>(State)->incrementReferenceCount();
if (IsSink)
Succs.setFlag();
}
- ~ExplodedNode() {
- const_cast<ProgramState*>(State)->decrementReferenceCount();
- }
+ ~ExplodedNode() {}
/// getLocation - Returns the edge associated with the given node.
ProgramPoint getLocation() const { return Location; }
@@ -156,7 +153,7 @@
ProgramStateRef state,
bool IsSink) {
ID.Add(Loc);
- ID.AddPointer(state);
+ ID.AddPointer(state.getPtr());
ID.AddBoolean(IsSink);
}
@@ -370,6 +367,10 @@
/// Reclaim "uninteresting" nodes created since the last time this method
/// was called.
void reclaimRecentlyAllocatedNodes();
+
+private:
+ bool shouldCollect(const ExplodedNode *node);
+ void collectNode(ExplodedNode *node);
};
class ExplodedNodeSet {
Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h Tue Jan 31 04:14:40 2012
@@ -93,7 +93,6 @@
void setStore(const StoreRef &storeRef);
public:
-
/// This ctor is used when creating the first ProgramState object.
ProgramState(ProgramStateManager *mgr, const Environment& env,
StoreRef st, GenericDataMap gdm);
@@ -107,9 +106,6 @@
/// Return the ProgramStateManager associated with this state.
ProgramStateManager &getStateManager() const { return *stateMgr; }
- /// Return true if this state is referenced by a persistent ExplodedNode.
- bool referencedByExplodedNode() const { return refCount > 0; }
-
/// getEnvironment - Return the environment associated with this state.
/// The environment is the mapping from expressions to values.
const Environment& getEnvironment() const { return Env; }
@@ -127,7 +123,7 @@
/// Profile - Profile the contents of a ProgramState object for use in a
/// FoldingSet. Two ProgramState objects are considered equal if they
/// have the same Environment, Store, and GenericDataMap.
- static void Profile(llvm::FoldingSetNodeID& ID, ProgramStateRef V) {
+ static void Profile(llvm::FoldingSetNodeID& ID, const ProgramState *V) {
V->Env.Profile(ID);
ID.AddPointer(V->store);
V->GDM.Profile(ID);
@@ -376,14 +372,8 @@
void dumpTaint() const;
private:
- /// Increments the number of times this state is referenced by ExplodeNodes.
- void incrementReferenceCount() { ++refCount; }
-
- /// Decrement the number of times this state is referenced by ExplodeNodes.
- void decrementReferenceCount() {
- assert(refCount > 0);
- --refCount;
- }
+ friend void ProgramStateRetain(const ProgramState *state);
+ friend void ProgramStateRelease(const ProgramState *state);
ProgramStateRef
invalidateRegionsImpl(ArrayRef<const MemRegion *> Regions,
@@ -392,45 +382,13 @@
const CallOrObjCMessage *Call) const;
};
-class ProgramStateSet {
- typedef llvm::SmallPtrSet<ProgramStateRef,5> ImplTy;
- ImplTy Impl;
-public:
- ProgramStateSet() {}
-
- inline void Add(ProgramStateRef St) {
- Impl.insert(St);
- }
-
- typedef ImplTy::const_iterator iterator;
-
- inline unsigned size() const { return Impl.size(); }
- inline bool empty() const { return Impl.empty(); }
-
- inline iterator begin() const { return Impl.begin(); }
- inline iterator end() const { return Impl.end(); }
-
- class AutoPopulate {
- ProgramStateSet &S;
- unsigned StartSize;
- ProgramStateRef St;
- public:
- AutoPopulate(ProgramStateSet &s, ProgramStateRef st)
- : S(s), StartSize(S.size()), St(st) {}
-
- ~AutoPopulate() {
- if (StartSize == S.size())
- S.Add(St);
- }
- };
-};
-
//===----------------------------------------------------------------------===//
// ProgramStateManager - Factory object for ProgramStates.
//===----------------------------------------------------------------------===//
class ProgramStateManager {
friend class ProgramState;
+ friend void ProgramStateRelease(const ProgramState *state);
private:
/// Eng - The SubEngine that owns this state manager.
SubEngine *Eng; /* Can be null. */
@@ -453,10 +411,6 @@
/// A BumpPtrAllocator to allocate states.
llvm::BumpPtrAllocator &Alloc;
-
- /// A vector of recently allocated ProgramStates that can potentially be
- /// reused.
- std::vector<ProgramState *> recentlyAllocatedStates;
/// A vector of ProgramStates that we can reuse.
std::vector<ProgramState *> freeStates;
@@ -563,10 +517,6 @@
return S1->store == S2->store;
}
- /// Periodically called by ExprEngine to recycle ProgramStates that were
- /// created but never used for creating an ExplodedNode.
- void recycleUnusedStates();
-
//==---------------------------------------------------------------------==//
// Generic Data Map methods.
//==---------------------------------------------------------------------==//
Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h Tue Jan 31 04:14:40 2012
@@ -10,11 +10,31 @@
#ifndef LLVM_CLANG_PROGRAMSTATE_FWD_H
#define LLVM_CLANG_PROGRAMSTATE_FWD_H
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+
namespace clang {
namespace ento {
class ProgramState;
class ProgramStateManager;
- typedef const ProgramState* ProgramStateRef;
+ void ProgramStateRetain(const ProgramState *state);
+ void ProgramStateRelease(const ProgramState *state);
+}
+}
+
+namespace llvm {
+ template <> struct IntrusiveRefCntPtrInfo<const clang::ento::ProgramState> {
+ static void retain(const clang::ento::ProgramState *state) {
+ clang::ento::ProgramStateRetain(state);
+ }
+ static void release(const clang::ento::ProgramState *state) {
+ clang::ento::ProgramStateRelease(state);
+ }
+ };
+}
+
+namespace clang {
+namespace ento {
+ typedef llvm::IntrusiveRefCntPtr<const ProgramState> ProgramStateRef;
}
}
Modified: cfe/branches/tooling/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Expr.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Expr.cpp (original)
+++ cfe/branches/tooling/lib/AST/Expr.cpp Tue Jan 31 04:14:40 2012
@@ -1995,8 +1995,8 @@
// pointer, or member function pointer that does not have a non-throwing
// exception-specification
case CallExprClass:
- case CXXOperatorCallExprClass:
- case CXXMemberCallExprClass: {
+ case CXXMemberCallExprClass:
+ case CXXOperatorCallExprClass: {
const CallExpr *CE = cast<CallExpr>(this);
CanThrowResult CT;
if (isTypeDependent())
@@ -2068,34 +2068,34 @@
// Many other things have subexpressions, so we have to test those.
// Some are simple:
- case ParenExprClass:
- case MemberExprClass:
- case CXXReinterpretCastExprClass:
- case CXXConstCastExprClass:
case ConditionalOperatorClass:
case CompoundLiteralExprClass:
- case ExtVectorElementExprClass:
- case InitListExprClass:
- case DesignatedInitExprClass:
- case ParenListExprClass:
- case VAArgExprClass:
+ case CXXConstCastExprClass:
case CXXDefaultArgExprClass:
+ case CXXReinterpretCastExprClass:
+ case DesignatedInitExprClass:
case ExprWithCleanupsClass:
- case ObjCIvarRefExprClass:
+ case ExtVectorElementExprClass:
+ case InitListExprClass:
+ case MemberExprClass:
case ObjCIsaExprClass:
+ case ObjCIvarRefExprClass:
+ case ParenExprClass:
+ case ParenListExprClass:
case ShuffleVectorExprClass:
+ case VAArgExprClass:
return CanSubExprsThrow(C, this);
// Some might be dependent for other reasons.
- case UnaryOperatorClass:
case ArraySubscriptExprClass:
- case ImplicitCastExprClass:
+ case BinaryOperatorClass:
+ case CompoundAssignOperatorClass:
case CStyleCastExprClass:
case CXXStaticCastExprClass:
case CXXFunctionalCastExprClass:
- case BinaryOperatorClass:
- case CompoundAssignOperatorClass:
- case MaterializeTemporaryExprClass: {
+ case ImplicitCastExprClass:
+ case MaterializeTemporaryExprClass:
+ case UnaryOperatorClass: {
CanThrowResult CT = isTypeDependent() ? CT_Dependent : CT_Cannot;
return MergeCanThrow(CT, CanSubExprsThrow(C, this));
}
@@ -2115,15 +2115,68 @@
return cast<GenericSelectionExpr>(this)->getResultExpr()->CanThrow(C);
// Some expressions are always dependent.
- case DependentScopeDeclRefExprClass:
- case CXXUnresolvedConstructExprClass:
case CXXDependentScopeMemberExprClass:
+ case CXXUnresolvedConstructExprClass:
+ case DependentScopeDeclRefExprClass:
return CT_Dependent;
- default:
- // All other expressions don't have subexpressions, or else they are
- // unevaluated.
+ case AtomicExprClass:
+ case AsTypeExprClass:
+ case BinaryConditionalOperatorClass:
+ case BlockExprClass:
+ case BlockDeclRefExprClass:
+ case CUDAKernelCallExprClass:
+ case DeclRefExprClass:
+ case ObjCBridgedCastExprClass:
+ case ObjCIndirectCopyRestoreExprClass:
+ case ObjCProtocolExprClass:
+ case ObjCSelectorExprClass:
+ case OffsetOfExprClass:
+ case PackExpansionExprClass:
+ case PseudoObjectExprClass:
+ case SubstNonTypeTemplateParmExprClass:
+ case SubstNonTypeTemplateParmPackExprClass:
+ case UnaryExprOrTypeTraitExprClass:
+ case UnresolvedLookupExprClass:
+ case UnresolvedMemberExprClass:
+ // FIXME: Can any of the above throw? If so, when?
+ return CT_Cannot;
+
+ case AddrLabelExprClass:
+ case ArrayTypeTraitExprClass:
+ case BinaryTypeTraitExprClass:
+ case CXXBoolLiteralExprClass:
+ case CXXNoexceptExprClass:
+ case CXXNullPtrLiteralExprClass:
+ case CXXPseudoDestructorExprClass:
+ case CXXScalarValueInitExprClass:
+ case CXXThisExprClass:
+ case CXXUuidofExprClass:
+ case CharacterLiteralClass:
+ case ExpressionTraitExprClass:
+ case FloatingLiteralClass:
+ case GNUNullExprClass:
+ case ImaginaryLiteralClass:
+ case ImplicitValueInitExprClass:
+ case IntegerLiteralClass:
+ case ObjCEncodeExprClass:
+ case ObjCStringLiteralClass:
+ case OpaqueValueExprClass:
+ case PredefinedExprClass:
+ case SizeOfPackExprClass:
+ case StringLiteralClass:
+ case UnaryTypeTraitExprClass:
+ // These expressions can never throw.
return CT_Cannot;
+
+#define STMT(CLASS, PARENT) case CLASS##Class:
+#define STMT_RANGE(Base, First, Last)
+#define LAST_STMT_RANGE(BASE, FIRST, LAST)
+#define EXPR(CLASS, PARENT)
+#define ABSTRACT_STMT(STMT)
+#include "clang/AST/StmtNodes.inc"
+ case NoStmtClass:
+ llvm_unreachable("Invalid class for expression");
}
}
Modified: cfe/branches/tooling/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ExprConstant.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ExprConstant.cpp (original)
+++ cfe/branches/tooling/lib/AST/ExprConstant.cpp Tue Jan 31 04:14:40 2012
@@ -348,6 +348,24 @@
*Diag << v;
return *this;
}
+
+ OptionalDiagnostic &operator<<(const APSInt &I) {
+ if (Diag) {
+ llvm::SmallVector<char, 32> Buffer;
+ I.toString(Buffer);
+ *Diag << StringRef(Buffer.data(), Buffer.size());
+ }
+ return *this;
+ }
+
+ OptionalDiagnostic &operator<<(const APFloat &F) {
+ if (Diag) {
+ llvm::SmallVector<char, 32> Buffer;
+ F.toString(Buffer);
+ *Diag << StringRef(Buffer.data(), Buffer.size());
+ }
+ return *this;
+ }
};
struct EvalInfo {
@@ -1052,10 +1070,8 @@
template<typename T>
static bool HandleOverflow(EvalInfo &Info, const Expr *E,
const T &SrcValue, QualType DestType) {
- llvm::SmallVector<char, 32> Buffer;
- SrcValue.toString(Buffer);
Info.Diag(E->getExprLoc(), diag::note_constexpr_overflow)
- << StringRef(Buffer.data(), Buffer.size()) << DestType;
+ << SrcValue << DestType;
return false;
}
@@ -1086,9 +1102,10 @@
return true;
}
-static APSInt HandleIntToIntCast(QualType DestType, QualType SrcType,
- APSInt &Value, const ASTContext &Ctx) {
- unsigned DestWidth = Ctx.getIntWidth(DestType);
+static APSInt HandleIntToIntCast(EvalInfo &Info, const Expr *E,
+ QualType DestType, QualType SrcType,
+ APSInt &Value) {
+ unsigned DestWidth = Info.Ctx.getIntWidth(DestType);
APSInt Result = Value;
// Figure out if this is a truncate, extend or noop cast.
// If the input is signed, do a sign extend, noop, or truncate.
@@ -4314,6 +4331,18 @@
const CharUnits &LHSOffset = LHSValue.getLValueOffset();
const CharUnits &RHSOffset = RHSValue.getLValueOffset();
+
+ // C++11 [expr.rel]p3:
+ // Pointers to void (after pointer conversions) can be compared, with a
+ // result defined as follows: If both pointers represent the same
+ // address or are both the null pointer value, the result is true if the
+ // operator is <= or >= and false otherwise; otherwise the result is
+ // unspecified.
+ // We interpret this as applying to pointers to *cv* void.
+ if (LHSTy->isVoidPointerType() && LHSOffset != RHSOffset &&
+ E->getOpcode() != BO_EQ && E->getOpcode() != BO_NE)
+ CCEDiag(E, diag::note_constexpr_void_comparison);
+
switch (E->getOpcode()) {
default: llvm_unreachable("missing comparison operator");
case BO_LT: return Success(LHSOffset < RHSOffset, E);
@@ -4404,33 +4433,60 @@
case BO_Div:
if (RHS == 0)
return Error(E, diag::note_expr_divide_by_zero);
+ // Check for overflow case: INT_MIN / -1.
+ if (RHS.isNegative() && RHS.isAllOnesValue() &&
+ LHS.isSigned() && LHS.isMinSignedValue())
+ HandleOverflow(Info, E, -LHS.extend(LHS.getBitWidth() + 1), E->getType());
return Success(LHS / RHS, E);
case BO_Rem:
if (RHS == 0)
return Error(E, diag::note_expr_divide_by_zero);
return Success(LHS % RHS, E);
case BO_Shl: {
- // During constant-folding, a negative shift is an opposite shift.
+ // During constant-folding, a negative shift is an opposite shift. Such a
+ // shift is not a constant expression.
if (RHS.isSigned() && RHS.isNegative()) {
+ CCEDiag(E, diag::note_constexpr_negative_shift) << RHS;
RHS = -RHS;
goto shift_right;
}
shift_left:
- unsigned SA
- = (unsigned) RHS.getLimitedValue(LHS.getBitWidth()-1);
+ // C++11 [expr.shift]p1: Shift width must be less than the bit width of the
+ // shifted type.
+ unsigned SA = (unsigned) RHS.getLimitedValue(LHS.getBitWidth()-1);
+ if (SA != RHS) {
+ CCEDiag(E, diag::note_constexpr_large_shift)
+ << RHS << E->getType() << LHS.getBitWidth();
+ } else if (LHS.isSigned()) {
+ // C++11 [expr.shift]p2: A signed left shift must have a non-negative
+ // operand, and must not overflow.
+ if (LHS.isNegative())
+ CCEDiag(E, diag::note_constexpr_lshift_of_negative) << LHS;
+ else if (LHS.countLeadingZeros() <= SA)
+ HandleOverflow(Info, E, LHS.extend(LHS.getBitWidth() + SA) << SA,
+ E->getType());
+ }
+
return Success(LHS << SA, E);
}
case BO_Shr: {
- // During constant-folding, a negative shift is an opposite shift.
+ // During constant-folding, a negative shift is an opposite shift. Such a
+ // shift is not a constant expression.
if (RHS.isSigned() && RHS.isNegative()) {
+ CCEDiag(E, diag::note_constexpr_negative_shift) << RHS;
RHS = -RHS;
goto shift_left;
}
shift_right:
- unsigned SA =
- (unsigned) RHS.getLimitedValue(LHS.getBitWidth()-1);
+ // C++11 [expr.shift]p1: Shift width must be less than the bit width of the
+ // shifted type.
+ unsigned SA = (unsigned) RHS.getLimitedValue(LHS.getBitWidth()-1);
+ if (SA != RHS)
+ CCEDiag(E, diag::note_constexpr_large_shift)
+ << RHS << E->getType() << LHS.getBitWidth();
+
return Success(LHS >> SA, E);
}
@@ -4604,7 +4660,11 @@
if (!Visit(E->getSubExpr()))
return false;
if (!Result.isInt()) return Error(E);
- return Success(-Result.getInt(), E);
+ const APSInt &Value = Result.getInt();
+ if (Value.isSigned() && Value.isMinSignedValue())
+ HandleOverflow(Info, E, -Value.extend(Value.getBitWidth() + 1),
+ E->getType());
+ return Success(-Value, E);
}
case UO_Not: {
if (!Visit(E->getSubExpr()))
@@ -4703,8 +4763,8 @@
return Info.Ctx.getTypeSize(DestType) == Info.Ctx.getTypeSize(SrcType);
}
- return Success(HandleIntToIntCast(DestType, SrcType,
- Result.getInt(), Info.Ctx), E);
+ return Success(HandleIntToIntCast(Info, E, DestType, SrcType,
+ Result.getInt()), E);
}
case CK_PointerToIntegral: {
@@ -4716,6 +4776,9 @@
if (LV.getLValueBase()) {
// Only allow based lvalue casts if they are lossless.
+ // FIXME: Allow a larger integer size than the pointer size, and allow
+ // narrowing back down to pointer width in subsequent integral casts.
+ // FIXME: Check integer type's active bits, not its type size.
if (Info.Ctx.getTypeSize(DestType) != Info.Ctx.getTypeSize(SrcType))
return Error(E);
@@ -4726,7 +4789,7 @@
APSInt AsInt = Info.Ctx.MakeIntValue(LV.getLValueOffset().getQuantity(),
SrcType);
- return Success(HandleIntToIntCast(DestType, SrcType, AsInt, Info.Ctx), E);
+ return Success(HandleIntToIntCast(Info, E, DestType, SrcType, AsInt), E);
}
case CK_IntegralComplexToReal: {
@@ -5200,8 +5263,8 @@
QualType From
= E->getSubExpr()->getType()->getAs<ComplexType>()->getElementType();
- Result.IntReal = HandleIntToIntCast(To, From, Result.IntReal, Info.Ctx);
- Result.IntImag = HandleIntToIntCast(To, From, Result.IntImag, Info.Ctx);
+ Result.IntReal = HandleIntToIntCast(Info, E, To, From, Result.IntReal);
+ Result.IntImag = HandleIntToIntCast(Info, E, To, From, Result.IntImag);
return true;
}
Modified: cfe/branches/tooling/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ItaniumMangle.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/branches/tooling/lib/AST/ItaniumMangle.cpp Tue Jan 31 04:14:40 2012
@@ -610,17 +610,41 @@
// representation (IEEE on Itanium), high-order bytes first,
// without leading zeroes. For example: "Lf bf800000 E" is -1.0f
// on Itanium.
- // APInt::toString uses uppercase hexadecimal, and it's not really
- // worth embellishing that interface for this use case, so we just
- // do a second pass to lowercase things.
- typedef llvm::SmallString<20> buffer_t;
- buffer_t buffer;
- f.bitcastToAPInt().toString(buffer, 16, false);
-
- for (buffer_t::iterator i = buffer.begin(), e = buffer.end(); i != e; ++i)
- if (isupper(*i)) *i = tolower(*i);
+ // The 'without leading zeroes' thing seems to be an editorial
+ // mistake; see the discussion on cxx-abi-dev beginning on
+ // 2012-01-16.
+
+ // Our requirements here are just barely wierd enough to justify
+ // using a custom algorithm instead of post-processing APInt::toString().
+
+ llvm::APInt valueBits = f.bitcastToAPInt();
+ unsigned numCharacters = (valueBits.getBitWidth() + 3) / 4;
+ assert(numCharacters != 0);
+
+ // Allocate a buffer of the right number of characters.
+ llvm::SmallVector<char, 20> buffer;
+ buffer.set_size(numCharacters);
+
+ // Fill the buffer left-to-right.
+ for (unsigned stringIndex = 0; stringIndex != numCharacters; ++stringIndex) {
+ // The bit-index of the next hex digit.
+ unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
+
+ // Project out 4 bits starting at 'digitIndex'.
+ llvm::integerPart hexDigit
+ = valueBits.getRawData()[digitBitIndex / llvm::integerPartWidth];
+ hexDigit >>= (digitBitIndex % llvm::integerPartWidth);
+ hexDigit &= 0xF;
+
+ // Map that over to a lowercase hex digit.
+ static const char charForHex[16] = {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
+ };
+ buffer[stringIndex] = charForHex[hexDigit];
+ }
- Out.write(buffer.data(), buffer.size());
+ Out.write(buffer.data(), numCharacters);
}
void CXXNameMangler::mangleNumber(const llvm::APSInt &Value) {
Modified: cfe/branches/tooling/lib/Analysis/PrintfFormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/PrintfFormatString.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/PrintfFormatString.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/PrintfFormatString.cpp Tue Jan 31 04:14:40 2012
@@ -241,7 +241,8 @@
// Methods on PrintfSpecifier.
//===----------------------------------------------------------------------===//
-ArgTypeResult PrintfSpecifier::getArgType(ASTContext &Ctx) const {
+ArgTypeResult PrintfSpecifier::getArgType(ASTContext &Ctx,
+ bool IsObjCLiteral) const {
const PrintfConversionSpecifier &CS = getConversionSpecifier();
if (!CS.consumesDataArgument())
@@ -309,13 +310,19 @@
switch (CS.getKind()) {
case ConversionSpecifier::sArg:
- if (LM.getKind() == LengthModifier::AsWideChar)
+ if (LM.getKind() == LengthModifier::AsWideChar) {
+ if (IsObjCLiteral)
+ return Ctx.getPointerType(Ctx.UnsignedShortTy.withConst());
return ArgTypeResult(ArgTypeResult::WCStrTy, "wchar_t *");
+ }
return ArgTypeResult::CStrTy;
case ConversionSpecifier::SArg:
- // FIXME: This appears to be Mac OS X specific.
+ if (IsObjCLiteral)
+ return Ctx.getPointerType(Ctx.UnsignedShortTy.withConst());
return ArgTypeResult(ArgTypeResult::WCStrTy, "wchar_t *");
case ConversionSpecifier::CArg:
+ if (IsObjCLiteral)
+ return Ctx.UnsignedShortTy;
return ArgTypeResult(Ctx.WCharTy, "wchar_t");
case ConversionSpecifier::pArg:
return ArgTypeResult::CPointerTy;
Modified: cfe/branches/tooling/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Basic/Targets.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Basic/Targets.cpp (original)
+++ cfe/branches/tooling/lib/Basic/Targets.cpp Tue Jan 31 04:14:40 2012
@@ -570,7 +570,10 @@
static const char * const GCCRegNames[];
static const TargetInfo::GCCRegAlias GCCRegAliases[];
public:
- PPCTargetInfo(const std::string& triple) : TargetInfo(triple) {}
+ PPCTargetInfo(const std::string& triple) : TargetInfo(triple) {
+ LongDoubleWidth = LongDoubleAlign = 128;
+ LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble;
+ }
virtual void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const {
@@ -854,6 +857,7 @@
"i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32";
switch (getTriple().getOS()) {
+ case llvm::Triple::Linux:
case llvm::Triple::FreeBSD:
case llvm::Triple::NetBSD:
SizeType = UnsignedInt;
Modified: cfe/branches/tooling/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDecl.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDecl.cpp Tue Jan 31 04:14:40 2012
@@ -644,6 +644,16 @@
}
return true;
}
+
+ if (llvm::ConstantDataSequential *CDS =
+ dyn_cast<llvm::ConstantDataSequential>(Init)) {
+ for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
+ llvm::Constant *Elt = CDS->getElementAsConstant(i);
+ if (!canEmitInitWithFewStoresAfterMemset(Elt, NumStores))
+ return false;
+ }
+ return true;
+ }
// Anything else is hard and scary.
return false;
@@ -654,17 +664,26 @@
/// stores that would be required.
static void emitStoresForInitAfterMemset(llvm::Constant *Init, llvm::Value *Loc,
bool isVolatile, CGBuilderTy &Builder) {
- // Zero doesn't require any stores.
- if (isa<llvm::ConstantAggregateZero>(Init) ||
- isa<llvm::ConstantPointerNull>(Init) ||
- isa<llvm::UndefValue>(Init))
+ // Zero doesn't require a store.
+ if (Init->isNullValue() || isa<llvm::UndefValue>(Init))
return;
if (isa<llvm::ConstantInt>(Init) || isa<llvm::ConstantFP>(Init) ||
isa<llvm::ConstantVector>(Init) || isa<llvm::BlockAddress>(Init) ||
isa<llvm::ConstantExpr>(Init)) {
- if (!Init->isNullValue())
- Builder.CreateStore(Init, Loc, isVolatile);
+ Builder.CreateStore(Init, Loc, isVolatile);
+ return;
+ }
+
+ if (llvm::ConstantDataSequential *CDS =
+ dyn_cast<llvm::ConstantDataSequential>(Init)) {
+ for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
+ llvm::Constant *Elt = CDS->getElementAsConstant(i);
+
+ // Get a pointer to the element and emit it.
+ emitStoresForInitAfterMemset(Elt, Builder.CreateConstGEP2_32(Loc, 0, i),
+ isVolatile, Builder);
+ }
return;
}
@@ -673,9 +692,7 @@
for (unsigned i = 0, e = Init->getNumOperands(); i != e; ++i) {
llvm::Constant *Elt = cast<llvm::Constant>(Init->getOperand(i));
- if (Elt->isNullValue()) continue;
-
- // Otherwise, get a pointer to the element and emit it.
+ // Get a pointer to the element and emit it.
emitStoresForInitAfterMemset(Elt, Builder.CreateConstGEP2_32(Loc, 0, i),
isVolatile, Builder);
}
Modified: cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp Tue Jan 31 04:14:40 2012
@@ -811,7 +811,7 @@
// Resize the string to the right size, adding zeros at the end, or
// truncating as needed.
Str.resize(CAT->getSize().getZExtValue(), '\0');
- return llvm::ConstantArray::get(VMContext, Str, false);
+ return llvm::ConstantDataArray::getString(VMContext, Str, false);
}
llvm::Constant *VisitUnaryExtension(const UnaryOperator *E) {
Modified: cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp Tue Jan 31 04:14:40 2012
@@ -187,7 +187,7 @@
std::string name = prefix + Str;
llvm::Constant *ConstStr = TheModule.getGlobalVariable(name);
if (!ConstStr) {
- llvm::Constant *value = llvm::ConstantArray::get(VMContext, Str, true);
+ llvm::Constant *value = llvm::ConstantDataArray::getString(VMContext,Str);
ConstStr = new llvm::GlobalVariable(TheModule, value->getType(), true,
llvm::GlobalValue::LinkOnceODRLinkage, value, prefix + Str);
}
Modified: cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp Tue Jan 31 04:14:40 2012
@@ -1414,8 +1414,16 @@
CGF.EmitBlock(callBB);
}
- RValue complete(CodeGenFunction &CGF, RValue result, QualType resultType) {
+ RValue complete(CodeGenFunction &CGF, RValue result, QualType resultType,
+ const CallArgList &CallArgs,
+ const ObjCMethodDecl *Method) {
if (!NullBB) return result;
+
+ llvm::Value *NullInitPtr = 0;
+ if (result.isScalar() && !resultType->isVoidType()) {
+ NullInitPtr = CGF.CreateTempAlloca(result.getScalarVal()->getType());
+ CGF.Builder.CreateStore(result.getScalarVal(), NullInitPtr);
+ }
// Finish the call path.
llvm::BasicBlock *contBB = CGF.createBasicBlock("msgSend.cont");
@@ -1423,6 +1431,31 @@
// Emit the null-init block and perform the null-initialization there.
CGF.EmitBlock(NullBB);
+
+ // Release consumed arguments along the null-receiver path.
+ if (Method) {
+ CallArgList::const_iterator I = CallArgs.begin();
+ for (ObjCMethodDecl::param_const_iterator i = Method->param_begin(),
+ e = Method->param_end(); i != e; ++i, ++I) {
+ const ParmVarDecl *ParamDecl = (*i);
+ if (ParamDecl->hasAttr<NSConsumedAttr>()) {
+ RValue RV = I->RV;
+ assert(RV.isScalar() &&
+ "NullReturnState::complete - arg not on object");
+ CGF.EmitARCRelease(RV.getScalarVal(), true);
+ }
+ }
+ }
+
+ if (result.isScalar()) {
+ if (NullInitPtr)
+ CGF.EmitNullInitialization(NullInitPtr, resultType);
+ // Jump to the continuation block.
+ CGF.EmitBlock(contBB);
+ return NullInitPtr ? RValue::get(CGF.Builder.CreateLoad(NullInitPtr))
+ : result;
+ }
+
if (!resultType->isAnyComplexType()) {
assert(result.isAggregate() && "null init of non-aggregate result?");
CGF.EmitNullInitialization(result.getAggregateAddr(), resultType);
@@ -1668,9 +1701,24 @@
Fn = (ObjCABI == 2) ? ObjCTypes.getSendFn2(IsSuper)
: ObjCTypes.getSendFn(IsSuper);
}
+
+ bool requiresnullCheck = false;
+ if (CGM.getLangOptions().ObjCAutoRefCount && Method)
+ for (ObjCMethodDecl::param_const_iterator i = Method->param_begin(),
+ e = Method->param_end(); i != e; ++i) {
+ const ParmVarDecl *ParamDecl = (*i);
+ if (ParamDecl->hasAttr<NSConsumedAttr>()) {
+ if (!nullReturn.NullBB)
+ nullReturn.init(CGF, Arg0);
+ requiresnullCheck = true;
+ break;
+ }
+ }
+
Fn = llvm::ConstantExpr::getBitCast(Fn, llvm::PointerType::getUnqual(FTy));
RValue rvalue = CGF.EmitCall(FnInfo, Fn, Return, ActualArgs);
- return nullReturn.complete(CGF, rvalue, ResultType);
+ return nullReturn.complete(CGF, rvalue, ResultType, CallArgs,
+ requiresnullCheck ? Method : 0);
}
static Qualifiers::GC GetGCAttrTypeForType(ASTContext &Ctx, QualType FQT) {
@@ -3666,8 +3714,8 @@
if (!Entry)
Entry = CreateMetadataVar("\01L_OBJC_CLASS_NAME_",
- llvm::ConstantArray::get(VMContext,
- Ident->getNameStart()),
+ llvm::ConstantDataArray::getString(VMContext,
+ Ident->getNameStart()),
((ObjCABI == 2) ?
"__TEXT,__objc_classname,cstring_literals" :
"__TEXT,__cstring,cstring_literals"),
@@ -3875,7 +3923,7 @@
/// the given argument BitMap string container. Routine reads
/// two containers, IvarsInfo and SkipIvars which are assumed to be
/// filled already by the caller.
-llvm::Constant *CGObjCCommonMac::BuildIvarLayoutBitmap(std::string& BitMap) {
+llvm::Constant *CGObjCCommonMac::BuildIvarLayoutBitmap(std::string &BitMap) {
unsigned int WordsToScan, WordsToSkip;
llvm::Type *PtrTy = llvm::Type::getInt8PtrTy(VMContext);
@@ -3992,7 +4040,7 @@
llvm::GlobalVariable * Entry =
CreateMetadataVar("\01L_OBJC_CLASS_NAME_",
- llvm::ConstantArray::get(VMContext, BitMap.c_str()),
+ llvm::ConstantDataArray::getString(VMContext, BitMap),
((ObjCABI == 2) ?
"__TEXT,__objc_classname,cstring_literals" :
"__TEXT,__cstring,cstring_literals"),
@@ -4081,7 +4129,7 @@
// FIXME: Avoid std::string copying.
if (!Entry)
Entry = CreateMetadataVar("\01L_OBJC_METH_VAR_NAME_",
- llvm::ConstantArray::get(VMContext, Sel.getAsString()),
+ llvm::ConstantDataArray::getString(VMContext, Sel.getAsString()),
((ObjCABI == 2) ?
"__TEXT,__objc_methname,cstring_literals" :
"__TEXT,__cstring,cstring_literals"),
@@ -4103,7 +4151,7 @@
if (!Entry)
Entry = CreateMetadataVar("\01L_OBJC_METH_VAR_TYPE_",
- llvm::ConstantArray::get(VMContext, TypeStr),
+ llvm::ConstantDataArray::getString(VMContext, TypeStr),
((ObjCABI == 2) ?
"__TEXT,__objc_methtype,cstring_literals" :
"__TEXT,__cstring,cstring_literals"),
@@ -4124,7 +4172,7 @@
if (!Entry)
Entry = CreateMetadataVar("\01L_OBJC_METH_VAR_TYPE_",
- llvm::ConstantArray::get(VMContext, TypeStr),
+ llvm::ConstantDataArray::getString(VMContext, TypeStr),
((ObjCABI == 2) ?
"__TEXT,__objc_methtype,cstring_literals" :
"__TEXT,__cstring,cstring_literals"),
@@ -4139,8 +4187,8 @@
if (!Entry)
Entry = CreateMetadataVar("\01L_OBJC_PROP_NAME_ATTR_",
- llvm::ConstantArray::get(VMContext,
- Ident->getNameStart()),
+ llvm::ConstantDataArray::getString(VMContext,
+ Ident->getNameStart()),
"__TEXT,__cstring,cstring_literals",
1, true);
@@ -5768,6 +5816,20 @@
messageRef->setAlignment(16);
messageRef->setSection("__DATA, __objc_msgrefs, coalesced");
}
+
+ bool requiresnullCheck = false;
+ if (CGM.getLangOptions().ObjCAutoRefCount && method)
+ for (ObjCMethodDecl::param_const_iterator i = method->param_begin(),
+ e = method->param_end(); i != e; ++i) {
+ const ParmVarDecl *ParamDecl = (*i);
+ if (ParamDecl->hasAttr<NSConsumedAttr>()) {
+ if (!nullReturn.NullBB)
+ nullReturn.init(CGF, arg0);
+ requiresnullCheck = true;
+ break;
+ }
+ }
+
llvm::Value *mref =
CGF.Builder.CreateBitCast(messageRef, ObjCTypes.MessageRefPtrTy);
@@ -5785,7 +5847,8 @@
llvm::PointerType::getUnqual(fnType));
RValue result = CGF.EmitCall(fnInfo, callee, returnSlot, args);
- return nullReturn.complete(CGF, result, resultType);
+ return nullReturn.complete(CGF, result, resultType, formalArgs,
+ requiresnullCheck ? method : 0);
}
/// Generate code for a message send expression in the nonfragile abi.
Modified: cfe/branches/tooling/lib/CodeGen/CGRTTI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGRTTI.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGRTTI.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGRTTI.cpp Tue Jan 31 04:14:40 2012
@@ -125,7 +125,8 @@
// We know that the mangled name of the type starts at index 4 of the
// mangled name of the typename, so we can just index into it in order to
// get the mangled name of the type.
- llvm::Constant *Init = llvm::ConstantArray::get(VMContext, Name.substr(4));
+ llvm::Constant *Init = llvm::ConstantDataArray::getString(VMContext,
+ Name.substr(4));
llvm::GlobalVariable *GV =
CGM.CreateOrReplaceCXXRuntimeVariable(Name, Init->getType(), Linkage);
Modified: cfe/branches/tooling/lib/CodeGen/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenAction.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenAction.cpp Tue Jan 31 04:14:40 2012
@@ -220,18 +220,15 @@
SourceLocation LocCookie) {
// There are a couple of different kinds of errors we could get here. First,
// we re-format the SMDiagnostic in terms of a clang diagnostic.
-
- // Strip "error: " off the start of the message string.
StringRef Message = D.getMessage();
- if (Message.startswith("error: "))
- Message = Message.substr(7);
// If the SMDiagnostic has an inline asm source location, translate it.
FullSourceLoc Loc;
if (D.getLoc() != SMLoc())
Loc = ConvertBackendLocation(D, Context->getSourceManager());
-
+ // FIXME: Propagate ranges up as well.
+
// If this problem has clang-level source location information, report the
// issue as being an error in the source with a note showing the instantiated
// code.
Modified: cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp Tue Jan 31 04:14:40 2012
@@ -689,7 +689,7 @@
return i->second;
// Not found yet, create a new global.
- llvm::Constant *s = llvm::ConstantArray::get(getLLVMContext(), Str, true);
+ llvm::Constant *s = llvm::ConstantDataArray::getString(getLLVMContext(), Str);
llvm::GlobalValue *gv = new llvm::GlobalVariable(getModule(), s->getType(),
true, llvm::GlobalValue::PrivateLinkage, s, ".str");
gv->setSection(AnnotationSection);
@@ -1853,7 +1853,8 @@
llvm::ConstantInt::get(Ty, 0x07C8);
// String pointer.
- llvm::Constant *C = llvm::ConstantArray::get(VMContext, Entry.getKey().str());
+ llvm::Constant *C = llvm::ConstantDataArray::getString(VMContext,
+ Entry.getKey());
llvm::GlobalValue::LinkageTypes Linkage;
if (isUTF16)
@@ -1985,7 +1986,8 @@
Fields[0] = ConstantStringClassRef;
// String pointer.
- llvm::Constant *C = llvm::ConstantArray::get(VMContext, Entry.getKey().str());
+ llvm::Constant *C =
+ llvm::ConstantDataArray::getString(VMContext, Entry.getKey());
llvm::GlobalValue::LinkageTypes Linkage;
bool isConstant;
@@ -2081,29 +2083,28 @@
// Don't emit it as the address of the string, emit the string data itself
// as an inline array.
if (E->getCharByteWidth()==1) {
- return llvm::ConstantArray::get(VMContext,
+ return llvm::ConstantDataArray::getString(VMContext,
GetStringForStringLiteral(E), false);
- } else {
- llvm::ArrayType *AType =
- cast<llvm::ArrayType>(getTypes().ConvertType(E->getType()));
- llvm::Type *ElemTy = AType->getElementType();
- unsigned NumElements = AType->getNumElements();
- std::vector<llvm::Constant*> Elts;
- Elts.reserve(NumElements);
-
- for(unsigned i=0;i<E->getLength();++i) {
- unsigned value = E->getCodeUnit(i);
- llvm::Constant *C = llvm::ConstantInt::get(ElemTy,value,false);
- Elts.push_back(C);
- }
- for(unsigned i=E->getLength();i<NumElements;++i) {
- llvm::Constant *C = llvm::ConstantInt::get(ElemTy,0,false);
- Elts.push_back(C);
- }
-
- return llvm::ConstantArray::get(AType, Elts);
}
-
+
+ llvm::ArrayType *AType =
+ cast<llvm::ArrayType>(getTypes().ConvertType(E->getType()));
+ llvm::Type *ElemTy = AType->getElementType();
+ unsigned NumElements = AType->getNumElements();
+ std::vector<llvm::Constant*> Elts;
+ Elts.reserve(NumElements);
+
+ for(unsigned i=0;i<E->getLength();++i) {
+ unsigned value = E->getCodeUnit(i);
+ llvm::Constant *C = llvm::ConstantInt::get(ElemTy,value,false);
+ Elts.push_back(C);
+ }
+ for(unsigned i=E->getLength();i<NumElements;++i) {
+ llvm::Constant *C = llvm::ConstantInt::get(ElemTy,0,false);
+ Elts.push_back(C);
+ }
+
+ return llvm::ConstantArray::get(AType, Elts);
}
/// GetAddrOfConstantStringFromLiteral - Return a pointer to a
@@ -2152,7 +2153,7 @@
unsigned Alignment) {
// Create Constant for this string literal. Don't add a '\0'.
llvm::Constant *C =
- llvm::ConstantArray::get(CGM.getLLVMContext(), str, false);
+ llvm::ConstantDataArray::getString(CGM.getLLVMContext(), str, false);
// Create a global variable for this string
llvm::GlobalVariable *GV =
Modified: cfe/branches/tooling/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Driver.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Driver.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Driver.cpp Tue Jan 31 04:14:40 2012
@@ -1507,7 +1507,7 @@
std::string Driver::GetProgramPath(const char *Name, const ToolChain &TC,
bool WantFile) const {
- std::string TargetSpecificExecutable(TC.getUserTriple() + "-" + Name);
+ std::string TargetSpecificExecutable(DefaultTargetTriple + "-" + Name);
// Respect a limited subset of the '-Bprefix' functionality in GCC by
// attempting to use this prefix when lokup up program paths.
for (Driver::prefix_list::const_iterator it = PrefixDirs.begin(),
@@ -1574,10 +1574,13 @@
///
/// This routine provides the logic to compute a target triple from various
/// args passed to the driver and the default triple string.
-static llvm::Triple computeTargetTriple(StringRef TargetTriple,
+static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple,
const ArgList &Args,
StringRef DarwinArchName) {
- llvm::Triple Target(llvm::Triple::normalize(TargetTriple));
+ if (const Arg *A = Args.getLastArg(options::OPT_target))
+ DefaultTargetTriple = A->getValue(Args);
+
+ llvm::Triple Target(llvm::Triple::normalize(DefaultTargetTriple));
// Handle Darwin-specific options available here.
if (Target.isOSDarwin()) {
@@ -1624,19 +1627,14 @@
const ToolChain &Driver::getToolChain(const ArgList &Args,
StringRef DarwinArchName) const {
- std::string TargetTriple(DefaultTargetTriple);
- if (const Arg *A = Args.getLastArg(options::OPT_target))
- TargetTriple = A->getValue(Args);
-
- llvm::Triple Target = computeTargetTriple(TargetTriple, Args, DarwinArchName);
-
- std::string TargetIndex = TargetTriple + "::" + Target.str();
+ llvm::Triple Target = computeTargetTriple(DefaultTargetTriple, Args,
+ DarwinArchName);
- ToolChain *&TC = ToolChains[TargetIndex];
+ ToolChain *&TC = ToolChains[Target.str()];
if (!TC) {
switch (Target.getOS()) {
case llvm::Triple::AuroraUX:
- TC = new toolchains::AuroraUX(*this, Target, TargetTriple);
+ TC = new toolchains::AuroraUX(*this, Target);
break;
case llvm::Triple::Darwin:
case llvm::Triple::MacOSX:
@@ -1645,44 +1643,44 @@
Target.getArch() == llvm::Triple::x86_64 ||
Target.getArch() == llvm::Triple::arm ||
Target.getArch() == llvm::Triple::thumb)
- TC = new toolchains::DarwinClang(*this, Target, TargetTriple);
+ TC = new toolchains::DarwinClang(*this, Target);
else
- TC = new toolchains::Darwin_Generic_GCC(*this, Target, TargetTriple);
+ TC = new toolchains::Darwin_Generic_GCC(*this, Target);
break;
case llvm::Triple::DragonFly:
- TC = new toolchains::DragonFly(*this, Target, TargetTriple);
+ TC = new toolchains::DragonFly(*this, Target);
break;
case llvm::Triple::OpenBSD:
- TC = new toolchains::OpenBSD(*this, Target, TargetTriple);
+ TC = new toolchains::OpenBSD(*this, Target);
break;
case llvm::Triple::NetBSD:
- TC = new toolchains::NetBSD(*this, Target, TargetTriple);
+ TC = new toolchains::NetBSD(*this, Target);
break;
case llvm::Triple::FreeBSD:
- TC = new toolchains::FreeBSD(*this, Target, TargetTriple);
+ TC = new toolchains::FreeBSD(*this, Target);
break;
case llvm::Triple::Minix:
- TC = new toolchains::Minix(*this, Target, TargetTriple);
+ TC = new toolchains::Minix(*this, Target);
break;
case llvm::Triple::Linux:
if (Target.getArch() == llvm::Triple::hexagon)
- TC = new toolchains::Hexagon_TC(*this, Target, TargetTriple);
+ TC = new toolchains::Hexagon_TC(*this, Target);
else
- TC = new toolchains::Linux(*this, Target, TargetTriple);
+ TC = new toolchains::Linux(*this, Target);
break;
case llvm::Triple::Win32:
- TC = new toolchains::Windows(*this, Target, TargetTriple);
+ TC = new toolchains::Windows(*this, Target);
break;
case llvm::Triple::MinGW32:
// FIXME: We need a MinGW toolchain. Fallthrough for now.
default:
// TCE is an OSless target
if (Target.getArchName() == "tce") {
- TC = new toolchains::TCEToolChain(*this, Target, TargetTriple);
+ TC = new toolchains::TCEToolChain(*this, Target);
break;
}
- TC = new toolchains::Generic_GCC(*this, Target, TargetTriple);
+ TC = new toolchains::Generic_GCC(*this, Target);
break;
}
}
Modified: cfe/branches/tooling/lib/Driver/ToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/ToolChain.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/ToolChain.cpp (original)
+++ cfe/branches/tooling/lib/Driver/ToolChain.cpp Tue Jan 31 04:14:40 2012
@@ -20,9 +20,8 @@
using namespace clang::driver;
using namespace clang;
-ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
- const std::string &UserTriple)
- : D(D), Triple(T), UserTriple(UserTriple) {
+ToolChain::ToolChain(const Driver &D, const llvm::Triple &T)
+ : D(D), Triple(T) {
}
ToolChain::~ToolChain() {
Modified: cfe/branches/tooling/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/ToolChains.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/ToolChains.cpp (original)
+++ cfe/branches/tooling/lib/Driver/ToolChains.cpp Tue Jan 31 04:14:40 2012
@@ -45,9 +45,8 @@
/// Darwin - Darwin tool chain for i386 and x86_64.
-Darwin::Darwin(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple)
- : ToolChain(D, Triple, UserTriple), TargetInitialized(false),
+Darwin::Darwin(const Driver &D, const llvm::Triple& Triple)
+ : ToolChain(D, Triple), TargetInitialized(false),
ARCRuntimeForSimulator(ARCSimulator_None),
LibCXXForSimulator(LibCXXSimulator_None)
{
@@ -251,9 +250,8 @@
}
-DarwinClang::DarwinClang(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple)
- : Darwin(D, Triple, UserTriple)
+DarwinClang::DarwinClang(const Driver &D, const llvm::Triple& Triple)
+ : Darwin(D, Triple)
{
getProgramPaths().push_back(getDriver().getInstalledDir());
if (getDriver().getInstalledDir() != getDriver().Dir)
@@ -1389,9 +1387,8 @@
}
}
-Generic_GCC::Generic_GCC(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple)
- : ToolChain(D, Triple, UserTriple), GCCInstallation(getDriver(), Triple) {
+Generic_GCC::Generic_GCC(const Driver &D, const llvm::Triple& Triple)
+ : ToolChain(D, Triple), GCCInstallation(getDriver(), Triple) {
getProgramPaths().push_back(getDriver().getInstalledDir());
if (getDriver().getInstalledDir() != getDriver().Dir)
getProgramPaths().push_back(getDriver().Dir);
@@ -1461,9 +1458,8 @@
}
/// Hexagon Toolchain
-Hexagon_TC::Hexagon_TC(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple)
- : ToolChain(D, Triple, UserTriple) {
+Hexagon_TC::Hexagon_TC(const Driver &D, const llvm::Triple& Triple)
+ : ToolChain(D, Triple) {
getProgramPaths().push_back(getDriver().getInstalledDir());
if (getDriver().getInstalledDir() != getDriver().Dir.c_str())
getProgramPaths().push_back(getDriver().Dir);
@@ -1532,9 +1528,8 @@
/// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
/// Currently does not support anything else but compilation.
-TCEToolChain::TCEToolChain(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple)
- : ToolChain(D, Triple, UserTriple) {
+TCEToolChain::TCEToolChain(const Driver &D, const llvm::Triple& Triple)
+ : ToolChain(D, Triple) {
// Path mangling to find libexec
std::string Path(getDriver().Dir);
@@ -1586,9 +1581,8 @@
/// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly.
-OpenBSD::OpenBSD(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple)
- : Generic_ELF(D, Triple, UserTriple) {
+OpenBSD::OpenBSD(const Driver &D, const llvm::Triple& Triple)
+ : Generic_ELF(D, Triple) {
getFilePaths().push_back(getDriver().Dir + "/../lib");
getFilePaths().push_back("/usr/lib");
}
@@ -1627,9 +1621,8 @@
/// FreeBSD - FreeBSD tool chain which can call as(1) and ld(1) directly.
-FreeBSD::FreeBSD(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple)
- : Generic_ELF(D, Triple, UserTriple) {
+FreeBSD::FreeBSD(const Driver &D, const llvm::Triple& Triple)
+ : Generic_ELF(D, Triple) {
// When targeting 32-bit platforms, look for '/usr/lib32/crt1.o' and fall
// back to '/usr/lib' if it doesn't exist.
@@ -1674,9 +1667,8 @@
/// NetBSD - NetBSD tool chain which can call as(1) and ld(1) directly.
-NetBSD::NetBSD(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple)
- : Generic_ELF(D, Triple, UserTriple) {
+NetBSD::NetBSD(const Driver &D, const llvm::Triple& Triple)
+ : Generic_ELF(D, Triple) {
if (getDriver().UseStdLib) {
// When targeting a 32-bit platform, try the special directory used on
@@ -1725,9 +1717,8 @@
/// Minix - Minix tool chain which can call as(1) and ld(1) directly.
-Minix::Minix(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple)
- : Generic_ELF(D, Triple, UserTriple) {
+Minix::Minix(const Driver &D, const llvm::Triple& Triple)
+ : Generic_ELF(D, Triple) {
getFilePaths().push_back(getDriver().Dir + "/../lib");
getFilePaths().push_back("/usr/lib");
}
@@ -1757,9 +1748,8 @@
/// AuroraUX - AuroraUX tool chain which can call as(1) and ld(1) directly.
-AuroraUX::AuroraUX(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple)
- : Generic_GCC(D, Triple, UserTriple) {
+AuroraUX::AuroraUX(const Driver &D, const llvm::Triple& Triple)
+ : Generic_GCC(D, Triple) {
getProgramPaths().push_back(getDriver().getInstalledDir());
if (getDriver().getInstalledDir() != getDriver().Dir)
@@ -1974,9 +1964,8 @@
if (llvm::sys::fs::exists(Path)) Paths.push_back(Path.str());
}
-Linux::Linux(const Driver &D, const llvm::Triple &Triple,
- const std::string &UserTriple)
- : Generic_ELF(D, Triple, UserTriple) {
+Linux::Linux(const Driver &D, const llvm::Triple &Triple)
+ : Generic_ELF(D, Triple) {
llvm::Triple::ArchType Arch = Triple.getArch();
const std::string &SysRoot = getDriver().SysRoot;
@@ -2284,9 +2273,8 @@
/// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
-DragonFly::DragonFly(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple)
- : Generic_ELF(D, Triple, UserTriple) {
+DragonFly::DragonFly(const Driver &D, const llvm::Triple& Triple)
+ : Generic_ELF(D, Triple) {
// Path mangling to find libexec
getProgramPaths().push_back(getDriver().getInstalledDir());
Modified: cfe/branches/tooling/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/ToolChains.h?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/ToolChains.h (original)
+++ cfe/branches/tooling/lib/Driver/ToolChains.h Tue Jan 31 04:14:40 2012
@@ -119,8 +119,7 @@
mutable llvm::DenseMap<unsigned, Tool*> Tools;
public:
- Generic_GCC(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple);
+ Generic_GCC(const Driver &D, const llvm::Triple& Triple);
~Generic_GCC();
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
@@ -151,8 +150,7 @@
mutable llvm::DenseMap<unsigned, Tool*> Tools;
public:
- Hexagon_TC(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple);
+ Hexagon_TC(const Driver &D, const llvm::Triple& Triple);
~Hexagon_TC();
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
@@ -214,8 +212,7 @@
void AddDeploymentTarget(DerivedArgList &Args) const;
public:
- Darwin(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple);
+ Darwin(const Driver &D, const llvm::Triple& Triple);
~Darwin();
std::string ComputeEffectiveClangTriple(const ArgList &Args,
@@ -398,8 +395,7 @@
void AddGCCLibexecPath(unsigned darwinVersion);
public:
- DarwinClang(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple);
+ DarwinClang(const Driver &D, const llvm::Triple& Triple);
/// @name Darwin ToolChain Implementation
/// {
@@ -426,9 +422,8 @@
/// Darwin_Generic_GCC - Generic Darwin tool chain using gcc.
class LLVM_LIBRARY_VISIBILITY Darwin_Generic_GCC : public Generic_GCC {
public:
- Darwin_Generic_GCC(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple)
- : Generic_GCC(D, Triple, UserTriple) {}
+ Darwin_Generic_GCC(const Driver &D, const llvm::Triple& Triple)
+ : Generic_GCC(D, Triple) {}
std::string ComputeEffectiveClangTriple(const ArgList &Args,
types::ID InputType) const;
@@ -439,9 +434,8 @@
class LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC {
virtual void anchor();
public:
- Generic_ELF(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple)
- : Generic_GCC(D, Triple, UserTriple) {}
+ Generic_ELF(const Driver &D, const llvm::Triple& Triple)
+ : Generic_GCC(D, Triple) {}
virtual bool IsIntegratedAssemblerDefault() const {
// Default integrated assembler to on for x86.
@@ -452,8 +446,7 @@
class LLVM_LIBRARY_VISIBILITY AuroraUX : public Generic_GCC {
public:
- AuroraUX(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple);
+ AuroraUX(const Driver &D, const llvm::Triple& Triple);
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
const ActionList &Inputs) const;
@@ -461,8 +454,7 @@
class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
public:
- OpenBSD(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple);
+ OpenBSD(const Driver &D, const llvm::Triple& Triple);
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
const ActionList &Inputs) const;
@@ -470,8 +462,7 @@
class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
public:
- FreeBSD(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple);
+ FreeBSD(const Driver &D, const llvm::Triple& Triple);
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
const ActionList &Inputs) const;
@@ -479,8 +470,7 @@
class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
public:
- NetBSD(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple);
+ NetBSD(const Driver &D, const llvm::Triple& Triple);
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
const ActionList &Inputs) const;
@@ -488,8 +478,7 @@
class LLVM_LIBRARY_VISIBILITY Minix : public Generic_ELF {
public:
- Minix(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple);
+ Minix(const Driver &D, const llvm::Triple& Triple);
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
const ActionList &Inputs) const;
@@ -497,8 +486,7 @@
class LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_ELF {
public:
- DragonFly(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple);
+ DragonFly(const Driver &D, const llvm::Triple& Triple);
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
const ActionList &Inputs) const;
@@ -506,8 +494,7 @@
class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
public:
- Linux(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple);
+ Linux(const Driver &D, const llvm::Triple& Triple);
virtual bool HasNativeLLVMSupport() const;
@@ -533,8 +520,7 @@
/// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
class LLVM_LIBRARY_VISIBILITY TCEToolChain : public ToolChain {
public:
- TCEToolChain(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple);
+ TCEToolChain(const Driver &D, const llvm::Triple& Triple);
~TCEToolChain();
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
@@ -553,8 +539,7 @@
mutable llvm::DenseMap<unsigned, Tool*> Tools;
public:
- Windows(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple);
+ Windows(const Driver &D, const llvm::Triple& Triple);
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
const ActionList &Inputs) const;
Modified: cfe/branches/tooling/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Tools.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Tools.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Tools.cpp Tue Jan 31 04:14:40 2012
@@ -1352,7 +1352,6 @@
CmdArgs.push_back("-analyzer-checker=deadcode");
// Enable the following experimental checkers for testing.
- CmdArgs.push_back("-analyzer-checker=experimental.osx.cocoa.ContainerAPI");
CmdArgs.push_back("-analyzer-checker=security.insecureAPI.UncheckedReturn");
CmdArgs.push_back("-analyzer-checker=security.insecureAPI.getpw");
CmdArgs.push_back("-analyzer-checker=security.insecureAPI.gets");
Modified: cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp (original)
+++ cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp Tue Jan 31 04:14:40 2012
@@ -35,9 +35,8 @@
using namespace clang::driver::toolchains;
using namespace clang;
-Windows::Windows(const Driver &D, const llvm::Triple& Triple,
- const std::string &UserTriple)
- : ToolChain(D, Triple, UserTriple) {
+Windows::Windows(const Driver &D, const llvm::Triple& Triple)
+ : ToolChain(D, Triple) {
}
Tool &Windows::SelectTool(const Compilation &C, const JobAction &JA,
Modified: cfe/branches/tooling/lib/Headers/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Headers/module.map?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Headers/module.map (original)
+++ cfe/branches/tooling/lib/Headers/module.map Tue Jan 31 04:14:40 2012
@@ -36,10 +36,6 @@
header "stdint.h"
}
- explicit module tgmath {
- header "tgmath.h"
- }
-
explicit module intel {
requires x86
@@ -99,7 +95,7 @@
explicit module avx2 {
requires avx2
- export acx
+ export avx
header "avx2intrin.h"
}
@@ -136,6 +132,7 @@
}
// FIXME: mm_malloc.h
+ // FIXME: tgmath.h
// FIXME: unwind.h
explicit module varargs {
Modified: cfe/branches/tooling/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaChecking.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaChecking.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaChecking.cpp Tue Jan 31 04:14:40 2012
@@ -1586,6 +1586,13 @@
format_idx, firstDataArg, Type))
return; // Literal format string found, check done!
+ // Do not emit diag when the string param is a macro expansion and the
+ // format is either NSString or CFString. This is a hack to prevent
+ // diag when using the NSLocalizedString and CFCopyLocalizedString macros
+ // which are usually used in place of NS and CF string literals.
+ if (Type == FST_NSString && Args[format_idx]->getLocStart().isMacroID())
+ return;
+
// If there are no arguments specified, warn with -Wformat-security, otherwise
// warn only with -Wformat-nonliteral.
if (NumArgs == format_idx+1)
@@ -2155,7 +2162,8 @@
// Now type check the data expression that matches the
// format specifier.
const Expr *Ex = getDataArg(argIndex);
- const analyze_printf::ArgTypeResult &ATR = FS.getArgType(S.Context);
+ const analyze_printf::ArgTypeResult &ATR = FS.getArgType(S.Context,
+ IsObjCLiteral);
if (ATR.isValid() && !ATR.matchesType(S.Context, Ex->getType())) {
// Check if we didn't match because of an implicit cast from a 'char'
// or 'short' to an 'int'. This is done because printf is a varargs
@@ -3168,7 +3176,8 @@
}
};
-IntRange GetValueRange(ASTContext &C, llvm::APSInt &value, unsigned MaxWidth) {
+static IntRange GetValueRange(ASTContext &C, llvm::APSInt &value,
+ unsigned MaxWidth) {
if (value.isSigned() && value.isNegative())
return IntRange(value.getMinSignedBits(), false);
@@ -3180,8 +3189,8 @@
return IntRange(value.getActiveBits(), true);
}
-IntRange GetValueRange(ASTContext &C, APValue &result, QualType Ty,
- unsigned MaxWidth) {
+static IntRange GetValueRange(ASTContext &C, APValue &result, QualType Ty,
+ unsigned MaxWidth) {
if (result.isInt())
return GetValueRange(C, result.getInt(), MaxWidth);
@@ -3213,7 +3222,7 @@
/// range of values it might take.
///
/// \param MaxWidth - the width to which the value will be truncated
-IntRange GetExprRange(ASTContext &C, Expr *E, unsigned MaxWidth) {
+static IntRange GetExprRange(ASTContext &C, Expr *E, unsigned MaxWidth) {
E = E->IgnoreParens();
// Try a full evaluation first.
@@ -3431,16 +3440,16 @@
return IntRange::forValueOfType(C, E->getType());
}
-IntRange GetExprRange(ASTContext &C, Expr *E) {
+static IntRange GetExprRange(ASTContext &C, Expr *E) {
return GetExprRange(C, E, C.getIntWidth(E->getType()));
}
/// Checks whether the given value, which currently has the given
/// source semantics, has the same value when coerced through the
/// target semantics.
-bool IsSameFloatAfterCast(const llvm::APFloat &value,
- const llvm::fltSemantics &Src,
- const llvm::fltSemantics &Tgt) {
+static bool IsSameFloatAfterCast(const llvm::APFloat &value,
+ const llvm::fltSemantics &Src,
+ const llvm::fltSemantics &Tgt) {
llvm::APFloat truncated = value;
bool ignored;
@@ -3455,9 +3464,9 @@
/// target semantics.
///
/// The value might be a vector of floats (or a complex number).
-bool IsSameFloatAfterCast(const APValue &value,
- const llvm::fltSemantics &Src,
- const llvm::fltSemantics &Tgt) {
+static bool IsSameFloatAfterCast(const APValue &value,
+ const llvm::fltSemantics &Src,
+ const llvm::fltSemantics &Tgt) {
if (value.isFloat())
return IsSameFloatAfterCast(value.getFloat(), Src, Tgt);
@@ -3473,7 +3482,7 @@
IsSameFloatAfterCast(value.getComplexFloatImag(), Src, Tgt));
}
-void AnalyzeImplicitConversions(Sema &S, Expr *E, SourceLocation CC);
+static void AnalyzeImplicitConversions(Sema &S, Expr *E, SourceLocation CC);
static bool IsZero(Sema &S, Expr *E) {
// Suppress cases where we are comparing against an enum constant.
@@ -3502,7 +3511,7 @@
return E->getType()->isEnumeralType();
}
-void CheckTrivialUnsignedComparison(Sema &S, BinaryOperator *E) {
+static void CheckTrivialUnsignedComparison(Sema &S, BinaryOperator *E) {
BinaryOperatorKind op = E->getOpcode();
if (E->isValueDependent())
return;
@@ -3528,7 +3537,7 @@
/// Analyze the operands of the given comparison. Implements the
/// fallback case from AnalyzeComparison.
-void AnalyzeImpConvsInComparison(Sema &S, BinaryOperator *E) {
+static void AnalyzeImpConvsInComparison(Sema &S, BinaryOperator *E) {
AnalyzeImplicitConversions(S, E->getLHS(), E->getOperatorLoc());
AnalyzeImplicitConversions(S, E->getRHS(), E->getOperatorLoc());
}
@@ -3536,7 +3545,7 @@
/// \brief Implements -Wsign-compare.
///
/// \param E the binary operator to check for warnings
-void AnalyzeComparison(Sema &S, BinaryOperator *E) {
+static void AnalyzeComparison(Sema &S, BinaryOperator *E) {
// The type the comparison is being performed in.
QualType T = E->getLHS()->getType();
assert(S.Context.hasSameUnqualifiedType(T, E->getRHS()->getType())
@@ -3609,8 +3618,8 @@
/// Analyzes an attempt to assign the given value to a bitfield.
///
/// Returns true if there was something fishy about the attempt.
-bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init,
- SourceLocation InitLoc) {
+static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init,
+ SourceLocation InitLoc) {
assert(Bitfield->isBitField());
if (Bitfield->isInvalidDecl())
return false;
@@ -3664,7 +3673,7 @@
/// Analyze the given simple or compound assignment for warning-worthy
/// operations.
-void AnalyzeAssignment(Sema &S, BinaryOperator *E) {
+static void AnalyzeAssignment(Sema &S, BinaryOperator *E) {
// Just recurse on the LHS.
AnalyzeImplicitConversions(S, E->getLHS(), E->getOperatorLoc());
@@ -3683,16 +3692,25 @@
}
/// Diagnose an implicit cast; purely a helper for CheckImplicitConversion.
-void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T,
- SourceLocation CContext, unsigned diag) {
+static void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T,
+ SourceLocation CContext, unsigned diag,
+ bool pruneControlFlow = false) {
+ if (pruneControlFlow) {
+ S.DiagRuntimeBehavior(E->getExprLoc(), E,
+ S.PDiag(diag)
+ << SourceType << T << E->getSourceRange()
+ << SourceRange(CContext));
+ return;
+ }
S.Diag(E->getExprLoc(), diag)
<< SourceType << T << E->getSourceRange() << SourceRange(CContext);
}
/// Diagnose an implicit cast; purely a helper for CheckImplicitConversion.
-void DiagnoseImpCast(Sema &S, Expr *E, QualType T, SourceLocation CContext,
- unsigned diag) {
- DiagnoseImpCast(S, E, E->getType(), T, CContext, diag);
+static void DiagnoseImpCast(Sema &S, Expr *E, QualType T,
+ SourceLocation CContext, unsigned diag,
+ bool pruneControlFlow = false) {
+ DiagnoseImpCast(S, E, E->getType(), T, CContext, diag, pruneControlFlow);
}
/// Diagnose an implicit cast from a literal expression. Does not warn when the
@@ -3898,7 +3916,8 @@
return;
if (SourceRange.Width == 64 && TargetRange.Width == 32)
- return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_64_32);
+ return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_64_32,
+ /* pruneControlFlow */ true);
return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_precision);
}
Modified: cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp Tue Jan 31 04:14:40 2012
@@ -24,6 +24,7 @@
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
@@ -2526,7 +2527,7 @@
// Figure out which template parameters are deduced (or have default
// arguments).
- SmallVector<bool, 16> Deduced;
+ llvm::SmallBitVector Deduced;
Sema::MarkDeducedTemplateParameters(Ctx, FunTmpl, Deduced);
unsigned LastDeducibleArgument;
for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
Modified: cfe/branches/tooling/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaOverload.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaOverload.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaOverload.cpp Tue Jan 31 04:14:40 2012
@@ -4646,6 +4646,7 @@
// Check for a narrowing implicit conversion.
APValue PreNarrowingValue;
+ bool Diagnosed = false;
switch (SCS->getNarrowingKind(Context, Result.get(), PreNarrowingValue)) {
case NK_Variable_Narrowing:
// Implicit conversion to a narrower type, and the value is not a constant
@@ -4657,11 +4658,13 @@
Diag(From->getSourceRange().getBegin(), diag::err_cce_narrowing)
<< CCE << /*Constant*/1
<< PreNarrowingValue.getAsString(Context, QualType()) << T;
+ Diagnosed = true;
break;
case NK_Type_Narrowing:
Diag(From->getSourceRange().getBegin(), diag::err_cce_narrowing)
<< CCE << /*Constant*/0 << From->getType() << T;
+ Diagnosed = true;
break;
}
@@ -4674,12 +4677,19 @@
// The expression can't be folded, so we can't keep it at this position in
// the AST.
Result = ExprError();
- } else if (Notes.empty()) {
- // It's a constant expression.
+ } else {
Value = Eval.Val.getInt();
- return Result;
+
+ if (Notes.empty()) {
+ // It's a constant expression.
+ return Result;
+ }
}
+ // Only issue one narrowing diagnostic.
+ if (Diagnosed)
+ return Result;
+
// It's not a constant expression. Produce an appropriate diagnostic.
if (Notes.size() == 1 &&
Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr)
@@ -4690,7 +4700,7 @@
for (unsigned I = 0; I < Notes.size(); ++I)
Diag(Notes[I].first, Notes[I].second);
}
- return ExprError();
+ return Result;
}
/// dropPointerConversions - If the given standard conversion sequence
Modified: cfe/branches/tooling/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplate.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplate.cpp Tue Jan 31 04:14:40 2012
@@ -26,6 +26,7 @@
#include "clang/Sema/ParsedTemplate.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/PartialDiagnostic.h"
+#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/StringExtras.h"
using namespace clang;
using namespace sema;
@@ -5090,17 +5091,13 @@
// partial specialization are deducible from the template
// arguments. If not, this class template partial specialization
// will never be used.
- SmallVector<bool, 8> DeducibleParams;
- DeducibleParams.resize(TemplateParams->size());
+ llvm::SmallBitVector DeducibleParams(TemplateParams->size());
MarkUsedTemplateParameters(Partial->getTemplateArgs(), true,
TemplateParams->getDepth(),
DeducibleParams);
- unsigned NumNonDeducible = 0;
- for (unsigned I = 0, N = DeducibleParams.size(); I != N; ++I)
- if (!DeducibleParams[I])
- ++NumNonDeducible;
- if (NumNonDeducible) {
+ if (!DeducibleParams.all()) {
+ unsigned NumNonDeducible = DeducibleParams.size()-DeducibleParams.count();
Diag(TemplateNameLoc, diag::warn_partial_specs_not_deducible)
<< (NumNonDeducible > 1)
<< SourceRange(TemplateNameLoc, RAngleLoc);
Modified: cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplateDeduction.cpp Tue Jan 31 04:14:40 2012
@@ -20,7 +20,7 @@
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
-#include "llvm/ADT/BitVector.h"
+#include "llvm/ADT/SmallBitVector.h"
#include "TreeTransform.h"
#include <algorithm>
@@ -736,7 +736,7 @@
SmallVector<unsigned, 2> PackIndices;
QualType Pattern = Expansion->getPattern();
{
- llvm::BitVector SawIndices(TemplateParams->size());
+ llvm::SmallBitVector SawIndices(TemplateParams->size());
SmallVector<UnexpandedParameterPack, 2> Unexpanded;
S.collectUnexpandedParameterPacks(Pattern, Unexpanded);
for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
@@ -1745,7 +1745,7 @@
// parameter packs expanded by the pack expansion.
SmallVector<unsigned, 2> PackIndices;
{
- llvm::BitVector SawIndices(TemplateParams->size());
+ llvm::SmallBitVector SawIndices(TemplateParams->size());
SmallVector<UnexpandedParameterPack, 2> Unexpanded;
S.collectUnexpandedParameterPacks(Pattern, Unexpanded);
for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
@@ -3021,7 +3021,7 @@
QualType ParamPattern = ParamExpansion->getPattern();
SmallVector<unsigned, 2> PackIndices;
{
- llvm::BitVector SawIndices(TemplateParams->size());
+ llvm::SmallBitVector SawIndices(TemplateParams->size());
SmallVector<UnexpandedParameterPack, 2> Unexpanded;
collectUnexpandedParameterPacks(ParamPattern, Unexpanded);
for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
@@ -3474,7 +3474,7 @@
MarkUsedTemplateParameters(ASTContext &Ctx, QualType T,
bool OnlyDeduced,
unsigned Level,
- SmallVectorImpl<bool> &Deduced);
+ llvm::SmallBitVector &Deduced);
/// \brief If this is a non-static member function,
static void MaybeAddImplicitObjectParameterType(ASTContext &Context,
@@ -3622,8 +3622,7 @@
}
// Figure out which template parameters were used.
- SmallVector<bool, 4> UsedParameters;
- UsedParameters.resize(TemplateParams->size());
+ llvm::SmallBitVector UsedParameters(TemplateParams->size());
switch (TPOC) {
case TPOC_Call: {
unsigned NumParams = std::min(NumCallArguments,
@@ -4006,7 +4005,7 @@
const TemplateArgument &TemplateArg,
bool OnlyDeduced,
unsigned Depth,
- SmallVectorImpl<bool> &Used);
+ llvm::SmallBitVector &Used);
/// \brief Mark the template parameters that are used by the given
/// expression.
@@ -4015,7 +4014,7 @@
const Expr *E,
bool OnlyDeduced,
unsigned Depth,
- SmallVectorImpl<bool> &Used) {
+ llvm::SmallBitVector &Used) {
// We can deduce from a pack expansion.
if (const PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(E))
E = Expansion->getPattern();
@@ -4046,7 +4045,7 @@
NestedNameSpecifier *NNS,
bool OnlyDeduced,
unsigned Depth,
- SmallVectorImpl<bool> &Used) {
+ llvm::SmallBitVector &Used) {
if (!NNS)
return;
@@ -4063,7 +4062,7 @@
TemplateName Name,
bool OnlyDeduced,
unsigned Depth,
- SmallVectorImpl<bool> &Used) {
+ llvm::SmallBitVector &Used) {
if (TemplateDecl *Template = Name.getAsTemplateDecl()) {
if (TemplateTemplateParmDecl *TTP
= dyn_cast<TemplateTemplateParmDecl>(Template)) {
@@ -4087,7 +4086,7 @@
MarkUsedTemplateParameters(ASTContext &Ctx, QualType T,
bool OnlyDeduced,
unsigned Depth,
- SmallVectorImpl<bool> &Used) {
+ llvm::SmallBitVector &Used) {
if (T.isNull())
return;
@@ -4320,7 +4319,7 @@
const TemplateArgument &TemplateArg,
bool OnlyDeduced,
unsigned Depth,
- SmallVectorImpl<bool> &Used) {
+ llvm::SmallBitVector &Used) {
switch (TemplateArg.getKind()) {
case TemplateArgument::Null:
case TemplateArgument::Integral:
@@ -4365,7 +4364,7 @@
void
Sema::MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
bool OnlyDeduced, unsigned Depth,
- SmallVectorImpl<bool> &Used) {
+ llvm::SmallBitVector &Used) {
// C++0x [temp.deduct.type]p9:
// If the template argument list of P contains a pack expansion that is not
// the last template argument, the entire template argument list is a
@@ -4384,7 +4383,7 @@
void
Sema::MarkDeducedTemplateParameters(ASTContext &Ctx,
FunctionTemplateDecl *FunctionTemplate,
- SmallVectorImpl<bool> &Deduced) {
+ llvm::SmallBitVector &Deduced) {
TemplateParameterList *TemplateParams
= FunctionTemplate->getTemplateParameters();
Deduced.clear();
@@ -4404,14 +4403,9 @@
TemplateParameterList *TemplateParams
= FunctionTemplate->getTemplateParameters();
- SmallVector<bool, 4> Deduced;
- Deduced.resize(TemplateParams->size());
+ llvm::SmallBitVector Deduced(TemplateParams->size());
::MarkUsedTemplateParameters(S.Context, T, true, TemplateParams->getDepth(),
Deduced);
- for (unsigned I = 0, N = Deduced.size(); I != N; ++I)
- if (Deduced[I])
- return true;
-
- return false;
+ return Deduced.any();
}
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td Tue Jan 31 04:14:40 2012
@@ -39,6 +39,7 @@
def Cocoa : Package<"cocoa">, InPackage<OSX>;
def CocoaExperimental : Package<"cocoa">, InPackage<OSXExperimental>, Hidden;
def CoreFoundation : Package<"coreFoundation">, InPackage<OSX>;
+def Containers : Package<"Containers">, InPackage<CoreFoundation>;
def LLVM : Package<"llvm">;
def Debug : Package<"debug">;
@@ -368,10 +369,6 @@
let ParentPackage = CocoaExperimental in {
-def ObjCContainersASTChecker : Checker<"ContainerAPI">,
- HelpText<"Check for common pitfalls when using 'CFArray', 'CFDictionary', 'CFSet' APIs">,
- DescFile<"ObjCContainersASTChecker.cpp">;
-
def ObjCContainersChecker : Checker<"Containers">,
HelpText<"Deep checks for common pitfalls when using 'CFArray' APIs">,
DescFile<"ObjCContainersChecker.cpp">;
@@ -401,6 +398,11 @@
DescFile<"NSErrorChecker.cpp">;
}
+let ParentPackage = Containers in {
+def ObjCContainersASTChecker : Checker<"PointerSizedValues">,
+ HelpText<"Warns if 'CFArray', 'CFDictionary', 'CFSet' are created with non-pointer-size values">,
+ DescFile<"ObjCContainersASTChecker.cpp">;
+}
//===----------------------------------------------------------------------===//
// Checkers for LLVM development.
//===----------------------------------------------------------------------===//
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp Tue Jan 31 04:14:40 2012
@@ -79,7 +79,7 @@
void ObjCContainersChecker::addSizeInfo(const Expr *Array, const Expr *Size,
CheckerContext &C) const {
- const ProgramState *State = C.getState();
+ ProgramStateRef State = C.getState();
SVal SizeV = State->getSVal(Size, C.getLocationContext());
// Undefined is reported by another checker.
if (SizeV.isUnknownOrUndef())
@@ -124,7 +124,7 @@
// Check the array access.
if (Name.equals("CFArrayGetValueAtIndex")) {
- const ProgramState *State = C.getState();
+ ProgramStateRef State = C.getState();
// Retrieve the size.
// Find out if we saw this array symbol before and have information about it.
const Expr *ArrayExpr = CE->getArg(0);
@@ -140,8 +140,8 @@
// Now, check if 'Idx in [0, Size-1]'.
const QualType T = IdxExpr->getType();
- const ProgramState *StInBound = State->assumeInBound(Idx, Size, true, T);
- const ProgramState *StOutBound = State->assumeInBound(Idx, Size, false, T);
+ ProgramStateRef StInBound = State->assumeInBound(Idx, Size, true, T);
+ ProgramStateRef StOutBound = State->assumeInBound(Idx, Size, false, T);
if (StOutBound && !StInBound) {
ExplodedNode *N = C.generateSink(StOutBound);
if (!N)
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/Checker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/Checker.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/Checker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/Checker.cpp Tue Jan 31 04:14:40 2012
@@ -11,6 +11,7 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
using namespace clang;
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/ExplodedGraph.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExplodedGraph.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExplodedGraph.cpp Tue Jan 31 04:14:40 2012
@@ -66,20 +66,7 @@
// Node reclamation.
//===----------------------------------------------------------------------===//
-void ExplodedGraph::reclaimRecentlyAllocatedNodes() {
- if (!recentlyAllocatedNodes)
- return;
-
- // Only periodically relcaim nodes so that we can build up a set of
- // nodes that meet the reclamation criteria. Freshly created nodes
- // by definition have no successor, and thus cannot be reclaimed (see below).
- assert(reclaimCounter > 0);
- if (--reclaimCounter != 0)
- return;
- reclaimCounter = CounterTop;
-
- NodeList &nl = *getNodeList(recentlyAllocatedNodes);
-
+bool ExplodedGraph::shouldCollect(const ExplodedNode *node) {
// Reclaimn all nodes that match *all* the following criteria:
//
// (1) 1 predecessor (that has one successor)
@@ -90,61 +77,86 @@
// (6) The 'GDM' is the same as the predecessor.
// (7) The LocationContext is the same as the predecessor.
// (8) The PostStmt is for a non-consumed Stmt or Expr.
-
- for (NodeList::iterator i = nl.begin(), e = nl.end() ; i != e; ++i) {
- ExplodedNode *node = *i;
-
- // Conditions 1 and 2.
- if (node->pred_size() != 1 || node->succ_size() != 1)
- continue;
-
- ExplodedNode *pred = *(node->pred_begin());
- if (pred->succ_size() != 1)
- continue;
- ExplodedNode *succ = *(node->succ_begin());
- if (succ->pred_size() != 1)
- continue;
+ // Conditions 1 and 2.
+ if (node->pred_size() != 1 || node->succ_size() != 1)
+ return false;
+
+ const ExplodedNode *pred = *(node->pred_begin());
+ if (pred->succ_size() != 1)
+ return false;
+
+ const ExplodedNode *succ = *(node->succ_begin());
+ if (succ->pred_size() != 1)
+ return false;
+
+ // Condition 3.
+ ProgramPoint progPoint = node->getLocation();
+ if (!isa<PostStmt>(progPoint) ||
+ (isa<CallEnter>(progPoint) || isa<CallExit>(progPoint)))
+ return false;
+
+ // Condition 4.
+ PostStmt ps = cast<PostStmt>(progPoint);
+ if (ps.getTag())
+ return false;
+
+ if (isa<BinaryOperator>(ps.getStmt()))
+ return false;
- // Condition 3.
- ProgramPoint progPoint = node->getLocation();
- if (!isa<PostStmt>(progPoint) ||
- (isa<CallEnter>(progPoint) || isa<CallExit>(progPoint)))
- continue;
- // Condition 4.
- PostStmt ps = cast<PostStmt>(progPoint);
- if (ps.getTag())
- continue;
+ // Conditions 5, 6, and 7.
+ ProgramStateRef state = node->getState();
+ ProgramStateRef pred_state = pred->getState();
+ if (state->store != pred_state->store || state->GDM != pred_state->GDM ||
+ progPoint.getLocationContext() != pred->getLocationContext())
+ return false;
+
+ // Condition 8.
+ if (const Expr *Ex = dyn_cast<Expr>(ps.getStmt())) {
+ ParentMap &PM = progPoint.getLocationContext()->getParentMap();
+ if (!PM.isConsumedExpr(Ex))
+ return false;
+ }
+
+ return true;
+}
- if (isa<BinaryOperator>(ps.getStmt()))
- continue;
+void ExplodedGraph::collectNode(ExplodedNode *node) {
+ // Removing a node means:
+ // (a) changing the predecessors successor to the successor of this node
+ // (b) changing the successors predecessor to the predecessor of this node
+ // (c) Putting 'node' onto freeNodes.
+ assert(node->pred_size() == 1 || node->succ_size() == 1);
+ ExplodedNode *pred = *(node->pred_begin());
+ ExplodedNode *succ = *(node->succ_begin());
+ pred->replaceSuccessor(succ);
+ succ->replacePredecessor(pred);
+ if (!freeNodes)
+ freeNodes = new NodeList();
+ getNodeList(freeNodes)->push_back(node);
+ Nodes.RemoveNode(node);
+ --NumNodes;
+ node->~ExplodedNode();
+}
- // Conditions 5, 6, and 7.
- ProgramStateRef state = node->getState();
- ProgramStateRef pred_state = pred->getState();
- if (state->store != pred_state->store || state->GDM != pred_state->GDM ||
- progPoint.getLocationContext() != pred->getLocationContext())
- continue;
+void ExplodedGraph::reclaimRecentlyAllocatedNodes() {
+ if (!recentlyAllocatedNodes)
+ return;
- // Condition 8.
- if (const Expr *Ex = dyn_cast<Expr>(ps.getStmt())) {
- ParentMap &PM = progPoint.getLocationContext()->getParentMap();
- if (!PM.isConsumedExpr(Ex))
- continue;
- }
-
- // If we reach here, we can remove the node. This means:
- // (a) changing the predecessors successor to the successor of this node
- // (b) changing the successors predecessor to the predecessor of this node
- // (c) Putting 'node' onto freeNodes.
- pred->replaceSuccessor(succ);
- succ->replacePredecessor(pred);
- if (!freeNodes)
- freeNodes = new NodeList();
- getNodeList(freeNodes)->push_back(node);
- Nodes.RemoveNode(node);
- --NumNodes;
- node->~ExplodedNode();
+ // Only periodically relcaim nodes so that we can build up a set of
+ // nodes that meet the reclamation criteria. Freshly created nodes
+ // by definition have no successor, and thus cannot be reclaimed (see below).
+ assert(reclaimCounter > 0);
+ if (--reclaimCounter != 0)
+ return;
+ reclaimCounter = CounterTop;
+
+ NodeList &nl = *getNodeList(recentlyAllocatedNodes);
+
+ for (NodeList::iterator i = nl.begin(), e = nl.end() ; i != e; ++i) {
+ ExplodedNode *node = *i;
+ if (shouldCollect(node))
+ collectNode(node);
}
nl.clear();
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp Tue Jan 31 04:14:40 2012
@@ -238,13 +238,8 @@
void ExprEngine::ProcessStmt(const CFGStmt S,
ExplodedNode *Pred) {
- // TODO: Use RAII to remove the unnecessary, tagged nodes.
- //RegisterCreatedNodes registerCreatedNodes(getGraph());
-
// Reclaim any unnecessary nodes in the ExplodedGraph.
G.reclaimRecentlyAllocatedNodes();
- // Recycle any unused states in the ProgramStateManager.
- StateMgr.recycleUnusedStates();
currentStmt = S.getStmt();
PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
@@ -1856,7 +1851,7 @@
}
ProgramStateRef state = N->getState();
- Out << "\\|StateID: " << (void*) state
+ Out << "\\|StateID: " << (void*) state.getPtr()
<< " NodeID: " << (void*) N << "\\|";
state->printDOT(Out);
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/ProgramState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/ProgramState.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ProgramState.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ProgramState.cpp Tue Jan 31 04:14:40 2012
@@ -25,6 +25,26 @@
// FIXME: Move this elsewhere.
ConstraintManager::~ConstraintManager() {}
+namespace clang { namespace ento {
+/// Increments the number of times this state is referenced.
+
+void ProgramStateRetain(const ProgramState *state) {
+ ++const_cast<ProgramState*>(state)->refCount;
+}
+
+/// Decrement the number of times this state is referenced.
+void ProgramStateRelease(const ProgramState *state) {
+ assert(state->refCount > 0);
+ ProgramState *s = const_cast<ProgramState*>(state);
+ if (--s->refCount == 0) {
+ ProgramStateManager &Mgr = s->getStateManager();
+ Mgr.StateSet.RemoveNode(s);
+ s->~ProgramState();
+ Mgr.freeStates.push_back(s);
+ }
+}
+}}
+
ProgramState::ProgramState(ProgramStateManager *mgr, const Environment& env,
StoreRef st, GenericDataMap gdm)
: stateMgr(mgr),
@@ -328,23 +348,10 @@
return getPersistentState(State);
}
-void ProgramStateManager::recycleUnusedStates() {
- for (std::vector<ProgramState*>::iterator i = recentlyAllocatedStates.begin(),
- e = recentlyAllocatedStates.end(); i != e; ++i) {
- ProgramState *state = *i;
- if (state->referencedByExplodedNode())
- continue;
- StateSet.RemoveNode(state);
- freeStates.push_back(state);
- state->~ProgramState();
- }
- recentlyAllocatedStates.clear();
-}
-
ProgramStateRef ProgramStateManager::getPersistentStateWithGDM(
ProgramStateRef FromState,
ProgramStateRef GDMState) {
- ProgramState NewState = *FromState;
+ ProgramState NewState(*FromState);
NewState.GDM = GDMState->GDM;
return getPersistentState(NewState);
}
@@ -368,12 +375,11 @@
}
new (newState) ProgramState(State);
StateSet.InsertNode(newState, InsertPos);
- recentlyAllocatedStates.push_back(newState);
return newState;
}
ProgramStateRef ProgramState::makeWithStore(const StoreRef &store) const {
- ProgramState NewSt = *this;
+ ProgramState NewSt(*this);
NewSt.setStore(store);
return getStateManager().getPersistentState(NewSt);
}
Modified: cfe/branches/tooling/test/Analysis/CFContainers.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/CFContainers.mm?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/CFContainers.mm (original)
+++ cfe/branches/tooling/test/Analysis/CFContainers.mm Tue Jan 31 04:14:40 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.osx.cocoa.ContainerAPI,experimental.osx.cocoa.Containers -analyzer-store=region -triple x86_64-apple-darwin -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.coreFoundation.Containers.PointerSizedValues,experimental.osx.cocoa.Containers -analyzer-store=region -triple x86_64-apple-darwin -verify %s
typedef const struct __CFAllocator * CFAllocatorRef;
typedef const struct __CFString * CFStringRef;
Modified: cfe/branches/tooling/test/CXX/expr/expr.const/p2-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/expr/expr.const/p2-0x.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/expr/expr.const/p2-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/expr/expr.const/p2-0x.cpp Tue Jan 31 04:14:40 2012
@@ -118,6 +118,9 @@
void f(int n) {
switch (n) {
case (int)4.4e9: // expected-error {{constant expression}} expected-note {{value 4.4E+9 is outside the range of representable values of type 'int'}}
+ case (int)0x80000000u: // ok
+ case (int)10000000000ll: // expected-note {{here}}
+ case (unsigned int)10000000000ll: // expected-error {{duplicate case value}}
case (int)(unsigned)(long long)4.4e9: // ok
case (int)(float)1e300: // expected-error {{constant expression}} expected-note {{value 1.0E+300 is outside the range of representable values of type 'float'}}
case (int)((float)1e37 / 1e30): // ok
@@ -126,6 +129,30 @@
}
}
+ constexpr int int_min = ~0x7fffffff;
+ constexpr int minus_int_min = -int_min; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}}
+ constexpr int div0 = 3 / 0; // expected-error {{constant expression}} expected-note {{division by zero}} expected-warning {{undefined}}
+ constexpr int mod0 = 3 % 0; // expected-error {{constant expression}} expected-note {{division by zero}} expected-warning {{undefined}}
+ constexpr int int_min_div_minus_1 = int_min / -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}}
+
+ constexpr int shl_m1 = 0 << -1; // expected-error {{constant expression}} expected-note {{negative shift count -1}} expected-warning {{negative}}
+ constexpr int shl_0 = 0 << 0; // ok
+ constexpr int shl_31 = 0 << 31; // ok
+ constexpr int shl_32 = 0 << 32; // expected-error {{constant expression}} expected-note {{shift count 32 >= width of type 'int' (32}} expected-warning {{>= width of type}}
+ constexpr int shl_unsigned_negative = unsigned(-3) << 1; // ok
+ constexpr int shl_unsigned_into_sign = 1u << 31; // ok
+ constexpr int shl_unsigned_overflow = 1024u << 31; // ok
+ constexpr int shl_signed_negative = (-3) << 1; // expected-error {{constant expression}} expected-note {{left shift of negative value -3}}
+ constexpr int shl_signed_ok = 1 << 30; // ok
+ constexpr int shl_signed_into_sign = 1 << 31; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}}
+ constexpr int shl_signed_overflow = 1024 << 31; // expected-error {{constant expression}} expected-note {{value 2199023255552 is outside the range}} expected-warning {{requires 43 bits to represent}}
+ constexpr int shl_signed_ok2 = 1024 << 20; // ok
+
+ constexpr int shr_m1 = 0 >> -1; // expected-error {{constant expression}} expected-note {{negative shift count -1}} expected-warning {{negative}}
+ constexpr int shr_0 = 0 >> 0; // ok
+ constexpr int shr_31 = 0 >> 31; // ok
+ constexpr int shr_32 = 0 >> 32; // expected-error {{constant expression}} expected-note {{shift count 32 >= width of type}} expected-warning {{>= width of type}}
+
struct S {
int m;
};
@@ -349,10 +376,21 @@
// If two pointers point to non-static data members of the same object with
// different access control, the result is unspecified.
- // FIXME:
// [expr.rel]p3: Pointers to void can be compared [...] if both pointers
// represent the same address or are both the null pointer [...]; otherwise
// the result is unspecified.
+ struct S { int a, b; } s;
+ constexpr void *null = 0;
+ constexpr void *pv = (void*)&s.a;
+ constexpr void *qv = (void*)&s.b;
+ constexpr bool v1 = null < 0;
+ constexpr bool v2 = null < pv; // expected-error {{constant expression}}
+ constexpr bool v3 = null == pv; // ok
+ constexpr bool v4 = qv == pv; // ok
+ constexpr bool v5 = qv >= pv; // expected-error {{constant expression}} expected-note {{unequal pointers to void}}
+ constexpr bool v6 = qv > null; // expected-error {{constant expression}}
+ constexpr bool v7 = qv <= (void*)&s.b; // ok
+ constexpr bool v8 = qv > (void*)&s.a; // expected-error {{constant expression}} expected-note {{unequal pointers to void}}
// FIXME: Implement comparisons of pointers to members.
// [expr.eq]p2: If either is a pointer to a virtual member function and
Modified: cfe/branches/tooling/test/CodeGenCXX/mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/mangle.cpp?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/mangle.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/mangle.cpp Tue Jan 31 04:14:40 2012
@@ -361,6 +361,14 @@
j<A>(buffer);
}
// CHECK: define linkonce_odr void @_ZN5test01jINS_1AEEEvRAszdtcvT__E6buffer_c(
+
+ template <class T> void k(char (&buffer)[sizeof(T() + 0.0f)]) {}
+ void test5() {
+ char buffer[sizeof(float)];
+ k<float>(buffer);
+ }
+ // CHECK: define linkonce_odr void @_ZN5test01kIfEEvRAszplcvT__ELf00000000E_c(
+
}
namespace test1 {
Modified: cfe/branches/tooling/test/CodeGenObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjC/arc.m?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjC/arc.m (original)
+++ cfe/branches/tooling/test/CodeGenObjC/arc.m Tue Jan 31 04:14:40 2012
@@ -1489,8 +1489,13 @@
// CHECK-NEXT: [[T5:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T4]])
// CHECK-NEXT: [[T6:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES
// CHECK-NEXT: [[T7:%.*]] = bitcast [[TEST66]]* [[T3]] to i8*
-// CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*)*)(i8* [[T7]], i8* [[T6]], i8* [[T5]])
-// CHECK-NEXT: [[T8:%.*]] = bitcast [[TEST66]]* [[T3]] to i8*
+// CHECK-NEXT: [[SIX:%.*]] = icmp eq i8* [[T7]], null
+// CHECK-NEXT: br i1 [[SIX]], label [[NULINIT:%.*]], label [[CALL:%.*]]
+// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*)*)(i8* [[T7]], i8* [[T6]], i8* [[T5]])
+// CHECK-NEXT: br label [[CONT:%.*]]
+// CHECK: call void @objc_release(i8* [[T5]]) nounwind
+// CHECK-NEXT: br label [[CONT:%.*]]
+// CHECK: [[T8:%.*]] = bitcast [[TEST66]]* [[T3]] to i8*
// CHECK-NEXT: call void @objc_release(i8* [[T8]])
// CHECK-NEXT: ret void
Removed: cfe/branches/tooling/test/Driver/prefixed-tools.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/prefixed-tools.c?rev=149375&view=auto
==============================================================================
--- cfe/branches/tooling/test/Driver/prefixed-tools.c (original)
+++ cfe/branches/tooling/test/Driver/prefixed-tools.c (removed)
@@ -1,18 +0,0 @@
-// RUN: env PATH=%s-helper %clang -no-integrated-as -target x86_64--linux %s -o - > %t.log
-// RUN: env PATH=%s-helper %clang -no-integrated-as -m32 -target x86_64--linux %s -o - >> %t.log
-// RUN: FileCheck -input-file %t.log %s
-
-// FIXME: It had failed on Win32 due to inability of executing shell scripts.
-// Still it fails even with mingw MSYS bash.
-// REQUIRES: shell
-
-// CHECK: x86_64--linux-as called
-// CHECK: x86_64--linux-ld called
-// CHECK: x86_64--linux-as called
-// CHECK: x86_64--linux-ld called
-
-int
-main(void)
-{
- return 0;
-}
Removed: cfe/branches/tooling/test/Driver/prefixed-tools.c-helper/x86_64--linux-as
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/prefixed-tools.c-helper/x86_64--linux-as?rev=149375&view=auto
==============================================================================
--- cfe/branches/tooling/test/Driver/prefixed-tools.c-helper/x86_64--linux-as (original)
+++ cfe/branches/tooling/test/Driver/prefixed-tools.c-helper/x86_64--linux-as (removed)
@@ -1,2 +0,0 @@
-#!/bin/sh
-echo "x86_64--linux-as called"
Removed: cfe/branches/tooling/test/Driver/prefixed-tools.c-helper/x86_64--linux-ld
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/prefixed-tools.c-helper/x86_64--linux-ld?rev=149375&view=auto
==============================================================================
--- cfe/branches/tooling/test/Driver/prefixed-tools.c-helper/x86_64--linux-ld (original)
+++ cfe/branches/tooling/test/Driver/prefixed-tools.c-helper/x86_64--linux-ld (removed)
@@ -1,2 +0,0 @@
-#!/bin/sh
-echo "x86_64--linux-ld called"
Modified: cfe/branches/tooling/test/Modules/compiler_builtins.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Modules/compiler_builtins.m?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/test/Modules/compiler_builtins.m (original)
+++ cfe/branches/tooling/test/Modules/compiler_builtins.m Tue Jan 31 04:14:40 2012
@@ -1,9 +1,6 @@
// RUN: rm -rf %t
// RUN: %clang -fsyntax-only -fmodules -fmodule-cache-path %t %s -Xclang -verify
-// Note: disable test on MSVC, which doesn't have <complex.h>.
-// REQUIRES: shell
-
@import __compiler_builtins.float_constants;
float getFltMax() { return FLT_MAX; }
Modified: cfe/branches/tooling/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Preprocessor/init.c?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/test/Preprocessor/init.c (original)
+++ cfe/branches/tooling/test/Preprocessor/init.c Tue Jan 31 04:14:40 2012
@@ -525,7 +525,7 @@
// PPC64:#define __DBL_MIN_10_EXP__ (-307)
// PPC64:#define __DBL_MIN_EXP__ (-1021)
// PPC64:#define __DBL_MIN__ 2.2250738585072014e-308
-// PPC64:#define __DECIMAL_DIG__ 17
+// PPC64:#define __DECIMAL_DIG__ 33
// PPC64:#define __FLT_DENORM_MIN__ 1.40129846e-45F
// PPC64:#define __FLT_DIG__ 6
// PPC64:#define __FLT_EPSILON__ 1.19209290e-7F
@@ -552,19 +552,19 @@
// PPC64:#define __INTPTR_TYPE__ long int
// PPC64:#define __INTPTR_WIDTH__ 64
// PPC64:#define __INT_MAX__ 2147483647
-// PPC64:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
-// PPC64:#define __LDBL_DIG__ 15
-// PPC64:#define __LDBL_EPSILON__ 2.2204460492503131e-16
+// PPC64:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+// PPC64:#define __LDBL_DIG__ 31
+// PPC64:#define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L
// PPC64:#define __LDBL_HAS_DENORM__ 1
// PPC64:#define __LDBL_HAS_INFINITY__ 1
// PPC64:#define __LDBL_HAS_QUIET_NAN__ 1
-// PPC64:#define __LDBL_MANT_DIG__ 53
+// PPC64:#define __LDBL_MANT_DIG__ 106
// PPC64:#define __LDBL_MAX_10_EXP__ 308
// PPC64:#define __LDBL_MAX_EXP__ 1024
-// PPC64:#define __LDBL_MAX__ 1.7976931348623157e+308
-// PPC64:#define __LDBL_MIN_10_EXP__ (-307)
-// PPC64:#define __LDBL_MIN_EXP__ (-1021)
-// PPC64:#define __LDBL_MIN__ 2.2250738585072014e-308
+// PPC64:#define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L
+// PPC64:#define __LDBL_MIN_10_EXP__ (-291)
+// PPC64:#define __LDBL_MIN_EXP__ (-968)
+// PPC64:#define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L
// PPC64:#define __LONG_DOUBLE_128__ 1
// PPC64:#define __LONG_LONG_MAX__ 9223372036854775807LL
// PPC64:#define __LONG_MAX__ 9223372036854775807L
@@ -582,7 +582,7 @@
// PPC64:#define __SIZEOF_DOUBLE__ 8
// PPC64:#define __SIZEOF_FLOAT__ 4
// PPC64:#define __SIZEOF_INT__ 4
-// PPC64:#define __SIZEOF_LONG_DOUBLE__ 8
+// PPC64:#define __SIZEOF_LONG_DOUBLE__ 16
// PPC64:#define __SIZEOF_LONG_LONG__ 8
// PPC64:#define __SIZEOF_LONG__ 8
// PPC64:#define __SIZEOF_POINTER__ 8
@@ -603,6 +603,111 @@
// PPC64:#define __ppc64__ 1
// PPC64:#define __ppc__ 1
//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-linux-gnu -fno-signed-char < /dev/null | FileCheck -check-prefix PPC64-LINUX %s
+//
+// PPC64-LINUX:#define _ARCH_PPC 1
+// PPC64-LINUX:#define _ARCH_PPC64 1
+// PPC64-LINUX:#define _BIG_ENDIAN 1
+// PPC64-LINUX:#define _LP64 1
+// PPC64-LINUX:#define __BIG_ENDIAN__ 1
+// PPC64-LINUX:#define __CHAR16_TYPE__ unsigned short
+// PPC64-LINUX:#define __CHAR32_TYPE__ unsigned int
+// PPC64-LINUX:#define __CHAR_BIT__ 8
+// PPC64-LINUX:#define __CHAR_UNSIGNED__ 1
+// PPC64-LINUX:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// PPC64-LINUX:#define __DBL_DIG__ 15
+// PPC64-LINUX:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// PPC64-LINUX:#define __DBL_HAS_DENORM__ 1
+// PPC64-LINUX:#define __DBL_HAS_INFINITY__ 1
+// PPC64-LINUX:#define __DBL_HAS_QUIET_NAN__ 1
+// PPC64-LINUX:#define __DBL_MANT_DIG__ 53
+// PPC64-LINUX:#define __DBL_MAX_10_EXP__ 308
+// PPC64-LINUX:#define __DBL_MAX_EXP__ 1024
+// PPC64-LINUX:#define __DBL_MAX__ 1.7976931348623157e+308
+// PPC64-LINUX:#define __DBL_MIN_10_EXP__ (-307)
+// PPC64-LINUX:#define __DBL_MIN_EXP__ (-1021)
+// PPC64-LINUX:#define __DBL_MIN__ 2.2250738585072014e-308
+// PPC64-LINUX:#define __DECIMAL_DIG__ 33
+// PPC64-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// PPC64-LINUX:#define __FLT_DIG__ 6
+// PPC64-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F
+// PPC64-LINUX:#define __FLT_EVAL_METHOD__ 0
+// PPC64-LINUX:#define __FLT_HAS_DENORM__ 1
+// PPC64-LINUX:#define __FLT_HAS_INFINITY__ 1
+// PPC64-LINUX:#define __FLT_HAS_QUIET_NAN__ 1
+// PPC64-LINUX:#define __FLT_MANT_DIG__ 24
+// PPC64-LINUX:#define __FLT_MAX_10_EXP__ 38
+// PPC64-LINUX:#define __FLT_MAX_EXP__ 128
+// PPC64-LINUX:#define __FLT_MAX__ 3.40282347e+38F
+// PPC64-LINUX:#define __FLT_MIN_10_EXP__ (-37)
+// PPC64-LINUX:#define __FLT_MIN_EXP__ (-125)
+// PPC64-LINUX:#define __FLT_MIN__ 1.17549435e-38F
+// PPC64-LINUX:#define __FLT_RADIX__ 2
+// PPC64-LINUX:#define __INT16_TYPE__ short
+// PPC64-LINUX:#define __INT32_TYPE__ int
+// PPC64-LINUX:#define __INT64_C_SUFFIX__ L
+// PPC64-LINUX:#define __INT64_TYPE__ long int
+// PPC64-LINUX:#define __INT8_TYPE__ char
+// PPC64-LINUX:#define __INTMAX_MAX__ 9223372036854775807L
+// PPC64-LINUX:#define __INTMAX_TYPE__ long int
+// PPC64-LINUX:#define __INTMAX_WIDTH__ 64
+// PPC64-LINUX:#define __INTPTR_TYPE__ long int
+// PPC64-LINUX:#define __INTPTR_WIDTH__ 64
+// PPC64-LINUX:#define __INT_MAX__ 2147483647
+// PPC64-LINUX:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+// PPC64-LINUX:#define __LDBL_DIG__ 31
+// PPC64-LINUX:#define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L
+// PPC64-LINUX:#define __LDBL_HAS_DENORM__ 1
+// PPC64-LINUX:#define __LDBL_HAS_INFINITY__ 1
+// PPC64-LINUX:#define __LDBL_HAS_QUIET_NAN__ 1
+// PPC64-LINUX:#define __LDBL_MANT_DIG__ 106
+// PPC64-LINUX:#define __LDBL_MAX_10_EXP__ 308
+// PPC64-LINUX:#define __LDBL_MAX_EXP__ 1024
+// PPC64-LINUX:#define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L
+// PPC64-LINUX:#define __LDBL_MIN_10_EXP__ (-291)
+// PPC64-LINUX:#define __LDBL_MIN_EXP__ (-968)
+// PPC64-LINUX:#define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L
+// PPC64-LINUX:#define __LONG_DOUBLE_128__ 1
+// PPC64-LINUX:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// PPC64-LINUX:#define __LONG_MAX__ 9223372036854775807L
+// PPC64-LINUX:#define __LP64__ 1
+// PPC64-LINUX:#define __NATURAL_ALIGNMENT__ 1
+// PPC64-LINUX:#define __NO_INLINE__ 1
+// PPC64-LINUX:#define __POINTER_WIDTH__ 64
+// PPC64-LINUX:#define __POWERPC__ 1
+// PPC64-LINUX:#define __PTRDIFF_TYPE__ long int
+// PPC64-LINUX:#define __PTRDIFF_WIDTH__ 64
+// PPC64-LINUX:#define __REGISTER_PREFIX__
+// PPC64-LINUX:#define __SCHAR_MAX__ 127
+// PPC64-LINUX:#define __SHRT_MAX__ 32767
+// PPC64-LINUX:#define __SIG_ATOMIC_WIDTH__ 32
+// PPC64-LINUX:#define __SIZEOF_DOUBLE__ 8
+// PPC64-LINUX:#define __SIZEOF_FLOAT__ 4
+// PPC64-LINUX:#define __SIZEOF_INT__ 4
+// PPC64-LINUX:#define __SIZEOF_LONG_DOUBLE__ 16
+// PPC64-LINUX:#define __SIZEOF_LONG_LONG__ 8
+// PPC64-LINUX:#define __SIZEOF_LONG__ 8
+// PPC64-LINUX:#define __SIZEOF_POINTER__ 8
+// PPC64-LINUX:#define __SIZEOF_PTRDIFF_T__ 8
+// PPC64-LINUX:#define __SIZEOF_SHORT__ 2
+// PPC64-LINUX:#define __SIZEOF_SIZE_T__ 8
+// PPC64-LINUX:#define __SIZEOF_WCHAR_T__ 4
+// PPC64-LINUX:#define __SIZEOF_WINT_T__ 4
+// PPC64-LINUX:#define __SIZE_TYPE__ long unsigned int
+// PPC64-LINUX:#define __SIZE_WIDTH__ 64
+// PPC64-LINUX:#define __UINTMAX_TYPE__ long unsigned int
+// PPC64-LINUX:#define __USER_LABEL_PREFIX__
+// PPC64-LINUX:#define __WCHAR_MAX__ 2147483647
+// PPC64-LINUX:#define __WCHAR_TYPE__ int
+// PPC64-LINUX:#define __WCHAR_WIDTH__ 32
+// PPC64-LINUX:#define __WINT_TYPE__ unsigned int
+// PPC64-LINUX:#define __WINT_UNSIGNED__ 1
+// PPC64-LINUX:#define __WINT_WIDTH__ 32
+// PPC64-LINUX:#define __powerpc64__ 1
+// PPC64-LINUX:#define __powerpc__ 1
+// PPC64-LINUX:#define __ppc64__ 1
+// PPC64-LINUX:#define __ppc__ 1
+//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-none-none -fno-signed-char < /dev/null | FileCheck -check-prefix PPC %s
//
// PPC:#define _ARCH_PPC 1
@@ -625,7 +730,7 @@
// PPC:#define __DBL_MIN_10_EXP__ (-307)
// PPC:#define __DBL_MIN_EXP__ (-1021)
// PPC:#define __DBL_MIN__ 2.2250738585072014e-308
-// PPC:#define __DECIMAL_DIG__ 17
+// PPC:#define __DECIMAL_DIG__ 33
// PPC:#define __FLT_DENORM_MIN__ 1.40129846e-45F
// PPC:#define __FLT_DIG__ 6
// PPC:#define __FLT_EPSILON__ 1.19209290e-7F
@@ -652,19 +757,19 @@
// PPC:#define __INTPTR_TYPE__ long int
// PPC:#define __INTPTR_WIDTH__ 32
// PPC:#define __INT_MAX__ 2147483647
-// PPC:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
-// PPC:#define __LDBL_DIG__ 15
-// PPC:#define __LDBL_EPSILON__ 2.2204460492503131e-16
+// PPC:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+// PPC:#define __LDBL_DIG__ 31
+// PPC:#define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L
// PPC:#define __LDBL_HAS_DENORM__ 1
// PPC:#define __LDBL_HAS_INFINITY__ 1
// PPC:#define __LDBL_HAS_QUIET_NAN__ 1
-// PPC:#define __LDBL_MANT_DIG__ 53
+// PPC:#define __LDBL_MANT_DIG__ 106
// PPC:#define __LDBL_MAX_10_EXP__ 308
// PPC:#define __LDBL_MAX_EXP__ 1024
-// PPC:#define __LDBL_MAX__ 1.7976931348623157e+308
-// PPC:#define __LDBL_MIN_10_EXP__ (-307)
-// PPC:#define __LDBL_MIN_EXP__ (-1021)
-// PPC:#define __LDBL_MIN__ 2.2250738585072014e-308
+// PPC:#define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L
+// PPC:#define __LDBL_MIN_10_EXP__ (-291)
+// PPC:#define __LDBL_MIN_EXP__ (-968)
+// PPC:#define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L
// PPC:#define __LONG_DOUBLE_128__ 1
// PPC:#define __LONG_LONG_MAX__ 9223372036854775807LL
// PPC:#define __LONG_MAX__ 2147483647L
@@ -681,7 +786,7 @@
// PPC:#define __SIZEOF_DOUBLE__ 8
// PPC:#define __SIZEOF_FLOAT__ 4
// PPC:#define __SIZEOF_INT__ 4
-// PPC:#define __SIZEOF_LONG_DOUBLE__ 8
+// PPC:#define __SIZEOF_LONG_DOUBLE__ 16
// PPC:#define __SIZEOF_LONG_LONG__ 8
// PPC:#define __SIZEOF_LONG__ 4
// PPC:#define __SIZEOF_POINTER__ 4
@@ -701,6 +806,106 @@
// PPC:#define __WINT_WIDTH__ 32
// PPC:#define __ppc__ 1
//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-linux-gnu -fno-signed-char < /dev/null | FileCheck -check-prefix PPC-LINUX %s
+//
+// PPC-LINUX:#define _ARCH_PPC 1
+// PPC-LINUX:#define _BIG_ENDIAN 1
+// PPC-LINUX:#define __BIG_ENDIAN__ 1
+// PPC-LINUX:#define __CHAR16_TYPE__ unsigned short
+// PPC-LINUX:#define __CHAR32_TYPE__ unsigned int
+// PPC-LINUX:#define __CHAR_BIT__ 8
+// PPC-LINUX:#define __CHAR_UNSIGNED__ 1
+// PPC-LINUX:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// PPC-LINUX:#define __DBL_DIG__ 15
+// PPC-LINUX:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// PPC-LINUX:#define __DBL_HAS_DENORM__ 1
+// PPC-LINUX:#define __DBL_HAS_INFINITY__ 1
+// PPC-LINUX:#define __DBL_HAS_QUIET_NAN__ 1
+// PPC-LINUX:#define __DBL_MANT_DIG__ 53
+// PPC-LINUX:#define __DBL_MAX_10_EXP__ 308
+// PPC-LINUX:#define __DBL_MAX_EXP__ 1024
+// PPC-LINUX:#define __DBL_MAX__ 1.7976931348623157e+308
+// PPC-LINUX:#define __DBL_MIN_10_EXP__ (-307)
+// PPC-LINUX:#define __DBL_MIN_EXP__ (-1021)
+// PPC-LINUX:#define __DBL_MIN__ 2.2250738585072014e-308
+// PPC-LINUX:#define __DECIMAL_DIG__ 33
+// PPC-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// PPC-LINUX:#define __FLT_DIG__ 6
+// PPC-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F
+// PPC-LINUX:#define __FLT_EVAL_METHOD__ 0
+// PPC-LINUX:#define __FLT_HAS_DENORM__ 1
+// PPC-LINUX:#define __FLT_HAS_INFINITY__ 1
+// PPC-LINUX:#define __FLT_HAS_QUIET_NAN__ 1
+// PPC-LINUX:#define __FLT_MANT_DIG__ 24
+// PPC-LINUX:#define __FLT_MAX_10_EXP__ 38
+// PPC-LINUX:#define __FLT_MAX_EXP__ 128
+// PPC-LINUX:#define __FLT_MAX__ 3.40282347e+38F
+// PPC-LINUX:#define __FLT_MIN_10_EXP__ (-37)
+// PPC-LINUX:#define __FLT_MIN_EXP__ (-125)
+// PPC-LINUX:#define __FLT_MIN__ 1.17549435e-38F
+// PPC-LINUX:#define __FLT_RADIX__ 2
+// PPC-LINUX:#define __INT16_TYPE__ short
+// PPC-LINUX:#define __INT32_TYPE__ int
+// PPC-LINUX:#define __INT64_C_SUFFIX__ LL
+// PPC-LINUX:#define __INT64_TYPE__ long long int
+// PPC-LINUX:#define __INT8_TYPE__ char
+// PPC-LINUX:#define __INTMAX_MAX__ 9223372036854775807LL
+// PPC-LINUX:#define __INTMAX_TYPE__ long long int
+// PPC-LINUX:#define __INTMAX_WIDTH__ 64
+// PPC-LINUX:#define __INTPTR_TYPE__ long int
+// PPC-LINUX:#define __INTPTR_WIDTH__ 32
+// PPC-LINUX:#define __INT_MAX__ 2147483647
+// PPC-LINUX:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+// PPC-LINUX:#define __LDBL_DIG__ 31
+// PPC-LINUX:#define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L
+// PPC-LINUX:#define __LDBL_HAS_DENORM__ 1
+// PPC-LINUX:#define __LDBL_HAS_INFINITY__ 1
+// PPC-LINUX:#define __LDBL_HAS_QUIET_NAN__ 1
+// PPC-LINUX:#define __LDBL_MANT_DIG__ 106
+// PPC-LINUX:#define __LDBL_MAX_10_EXP__ 308
+// PPC-LINUX:#define __LDBL_MAX_EXP__ 1024
+// PPC-LINUX:#define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L
+// PPC-LINUX:#define __LDBL_MIN_10_EXP__ (-291)
+// PPC-LINUX:#define __LDBL_MIN_EXP__ (-968)
+// PPC-LINUX:#define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L
+// PPC-LINUX:#define __LONG_DOUBLE_128__ 1
+// PPC-LINUX:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// PPC-LINUX:#define __LONG_MAX__ 2147483647L
+// PPC-LINUX:#define __NATURAL_ALIGNMENT__ 1
+// PPC-LINUX:#define __NO_INLINE__ 1
+// PPC-LINUX:#define __POINTER_WIDTH__ 32
+// PPC-LINUX:#define __POWERPC__ 1
+// PPC-LINUX:#define __PTRDIFF_TYPE__ long int
+// PPC-LINUX:#define __PTRDIFF_WIDTH__ 32
+// PPC-LINUX:#define __REGISTER_PREFIX__
+// PPC-LINUX:#define __SCHAR_MAX__ 127
+// PPC-LINUX:#define __SHRT_MAX__ 32767
+// PPC-LINUX:#define __SIG_ATOMIC_WIDTH__ 32
+// PPC-LINUX:#define __SIZEOF_DOUBLE__ 8
+// PPC-LINUX:#define __SIZEOF_FLOAT__ 4
+// PPC-LINUX:#define __SIZEOF_INT__ 4
+// PPC-LINUX:#define __SIZEOF_LONG_DOUBLE__ 16
+// PPC-LINUX:#define __SIZEOF_LONG_LONG__ 8
+// PPC-LINUX:#define __SIZEOF_LONG__ 4
+// PPC-LINUX:#define __SIZEOF_POINTER__ 4
+// PPC-LINUX:#define __SIZEOF_PTRDIFF_T__ 4
+// PPC-LINUX:#define __SIZEOF_SHORT__ 2
+// PPC-LINUX:#define __SIZEOF_SIZE_T__ 4
+// PPC-LINUX:#define __SIZEOF_WCHAR_T__ 4
+// PPC-LINUX:#define __SIZEOF_WINT_T__ 4
+// PPC-LINUX:#define __SIZE_TYPE__ unsigned int
+// PPC-LINUX:#define __SIZE_WIDTH__ 32
+// PPC-LINUX:#define __UINTMAX_TYPE__ long long unsigned int
+// PPC-LINUX:#define __USER_LABEL_PREFIX__
+// PPC-LINUX:#define __WCHAR_MAX__ 2147483647
+// PPC-LINUX:#define __WCHAR_TYPE__ int
+// PPC-LINUX:#define __WCHAR_WIDTH__ 32
+// PPC-LINUX:#define __WINT_TYPE__ unsigned int
+// PPC-LINUX:#define __WINT_UNSIGNED__ 1
+// PPC-LINUX:#define __WINT_WIDTH__ 32
+// PPC-LINUX:#define __powerpc__ 1
+// PPC-LINUX:#define __ppc__ 1
+//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-none < /dev/null | FileCheck -check-prefix SPARC %s
//
// SPARC:#define __CHAR16_TYPE__ unsigned short
Modified: cfe/branches/tooling/test/Sema/conversion-64-32.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/conversion-64-32.c?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/conversion-64-32.c (original)
+++ cfe/branches/tooling/test/Sema/conversion-64-32.c Tue Jan 31 04:14:40 2012
@@ -13,3 +13,23 @@
int4 v127 = a; // no warning.
return v127;
}
+
+// <rdar://problem/10759934>
+// Don't warn about -Wshorten-64-to-32 in unreachable code.
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+int rdar10759934() {
+ uint32_t thing = 0;
+ uint64_t thing2 = 0;
+
+ switch (sizeof(thing2)) {
+ case 8:
+ break;
+ case 4:
+ thing = thing2; // no-warning
+ default:
+ break;
+ }
+
+ return 0;
+}
Propchange: cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 31 04:14:40 2012
@@ -1,2 +1,2 @@
/cfe/branches/type-system-rewrite/test/SemaCXX/warn-unreachable.cpp:134693-134817
-/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-149245
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-149375
Modified: cfe/branches/tooling/test/SemaObjC/format-strings-objc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/format-strings-objc.m?rev=149376&r1=149375&r2=149376&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/format-strings-objc.m (original)
+++ cfe/branches/tooling/test/SemaObjC/format-strings-objc.m Tue Jan 31 04:14:40 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wformat-nonliteral -fsyntax-only -verify %s
//===----------------------------------------------------------------------===//
// The following code is reduced using delta-debugging from
@@ -107,3 +107,43 @@
NSString * ns3 = ns1;
NSLog(ns3); // expected-warning {{format string is not a string literal}}}
}
+
+// Do not emit warnings when using NSLocalizedString
+extern NSString *GetLocalizedString(NSString *str);
+#define NSLocalizedString(key) GetLocalizedString(key)
+
+void check_NSLocalizedString() {
+ [Foo fooWithFormat:NSLocalizedString(@"format"), @"arg"]; // no-warning
+}
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+
+// Test that %S, %C, %ls check for 16 bit types in ObjC strings, as described at
+// http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265
+
+void test_percent_S() {
+ const unsigned short data[] = { 'a', 'b', 0 };
+ const unsigned short* ptr = data;
+ NSLog(@"%S", ptr); // no-warning
+
+ const wchar_t* wchar_ptr = L"ab";
+ NSLog(@"%S", wchar_ptr); // expected-warning{{format specifies type 'const unsigned short *' but the argument has type 'const wchar_t *'}}
+}
+
+void test_percent_ls() {
+ const unsigned short data[] = { 'a', 'b', 0 };
+ const unsigned short* ptr = data;
+ NSLog(@"%ls", ptr); // no-warning
+
+ const wchar_t* wchar_ptr = L"ab";
+ NSLog(@"%ls", wchar_ptr); // expected-warning{{format specifies type 'const unsigned short *' but the argument has type 'const wchar_t *'}}
+}
+
+void test_percent_C() {
+ const unsigned short data = 'a';
+ NSLog(@"%C", data); // no-warning
+
+ const wchar_t wchar_data = L'a';
+ NSLog(@"%C", wchar_data); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'wchar_t'}}
+}
More information about the llvm-branch-commits
mailing list