[llvm-branch-commits] [cfe-branch] r157177 - in /cfe/branches/tooling: ./ bindings/python/clang/ bindings/python/tests/cindex/ docs/ include/clang/AST/ include/clang/Analysis/Visitors/ include/clang/Basic/ include/clang/Driver/ include/clang/Lex/ include/clang/Parse/ include/clang/Sema/ include/clang/StaticAnalyzer/Core/PathSensitive/ lib/ARCMigrate/ lib/AST/ lib/Basic/ lib/CodeGen/ lib/Driver/ lib/Edit/ lib/Frontend/ lib/Lex/ lib/Parse/ lib/Sema/ lib/Serialization/ lib/StaticAnalyzer/Checkers/ lib/StaticAnalyzer/Core/ runtim...
Manuel Klimek
klimek at google.com
Mon May 21 01:15:07 PDT 2012
Author: klimek
Date: Mon May 21 03:15:06 2012
New Revision: 157177
URL: http://llvm.org/viewvc/llvm-project?rev=157177&view=rev
Log:
Merging mainline.
Added:
cfe/branches/tooling/docs/ThreadSanitizer.html
- copied unchanged from r157176, cfe/trunk/docs/ThreadSanitizer.html
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
- copied unchanged from r157176, cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
cfe/branches/tooling/test/ARCMT/objcmt-boxing.m
- copied unchanged from r157176, cfe/trunk/test/ARCMT/objcmt-boxing.m
cfe/branches/tooling/test/ARCMT/objcmt-boxing.m.result
- copied unchanged from r157176, cfe/trunk/test/ARCMT/objcmt-boxing.m.result
cfe/branches/tooling/test/Analysis/comparison-implicit-casts.cpp
- copied unchanged from r157176, cfe/trunk/test/Analysis/comparison-implicit-casts.cpp
cfe/branches/tooling/test/Analysis/cxx11-crashes.cpp
- copied unchanged from r157176, cfe/trunk/test/Analysis/cxx11-crashes.cpp
cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm
- copied unchanged from r157176, cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm
cfe/branches/tooling/test/CodeGenCUDA/address-spaces.cu
- copied unchanged from r157176, cfe/trunk/test/CodeGenCUDA/address-spaces.cu
cfe/branches/tooling/test/CodeGenCXX/debug-info-rvalue-ref.cpp
- copied unchanged from r157176, cfe/trunk/test/CodeGenCXX/debug-info-rvalue-ref.cpp
cfe/branches/tooling/test/Modules/Inputs/import-decl.h
- copied unchanged from r157176, cfe/trunk/test/Modules/Inputs/import-decl.h
cfe/branches/tooling/test/Modules/import-decl.cpp
- copied unchanged from r157176, cfe/trunk/test/Modules/import-decl.cpp
cfe/branches/tooling/test/Parser/cxx-extra-semi.cpp
- copied unchanged from r157176, cfe/trunk/test/Parser/cxx-extra-semi.cpp
cfe/branches/tooling/test/SemaCXX/no-rtti.cpp
- copied unchanged from r157176, cfe/trunk/test/SemaCXX/no-rtti.cpp
cfe/branches/tooling/test/SemaObjC/iboutlet.m
- copied unchanged from r157176, cfe/trunk/test/SemaObjC/iboutlet.m
cfe/branches/tooling/test/SemaObjC/mismatched-undefined-method.m
- copied unchanged from r157176, cfe/trunk/test/SemaObjC/mismatched-undefined-method.m
cfe/branches/tooling/test/SemaObjCXX/boxing-illegal-types.mm
- copied unchanged from r157176, cfe/trunk/test/SemaObjCXX/boxing-illegal-types.mm
Modified:
cfe/branches/tooling/ (props changed)
cfe/branches/tooling/bindings/python/clang/cindex.py
cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py
cfe/branches/tooling/bindings/python/tests/cindex/test_type.py
cfe/branches/tooling/docs/ObjectiveCLiterals.html
cfe/branches/tooling/include/clang/AST/ASTContext.h
cfe/branches/tooling/include/clang/AST/DeclarationName.h
cfe/branches/tooling/include/clang/AST/ExprObjC.h
cfe/branches/tooling/include/clang/AST/NSAPI.h
cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h
cfe/branches/tooling/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h
cfe/branches/tooling/include/clang/Basic/AddressSpaces.h
cfe/branches/tooling/include/clang/Basic/Attr.td
cfe/branches/tooling/include/clang/Basic/DiagnosticCommonKinds.td
cfe/branches/tooling/include/clang/Basic/DiagnosticDriverKinds.td
cfe/branches/tooling/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td
cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td
cfe/branches/tooling/include/clang/Basic/TokenKinds.def
cfe/branches/tooling/include/clang/Driver/CC1Options.td
cfe/branches/tooling/include/clang/Driver/Options.td
cfe/branches/tooling/include/clang/Lex/Lexer.h
cfe/branches/tooling/include/clang/Parse/Parser.h
cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h
cfe/branches/tooling/include/clang/Sema/DeclSpec.h
cfe/branches/tooling/include/clang/Sema/Sema.h
cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
cfe/branches/tooling/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
cfe/branches/tooling/lib/AST/ASTContext.cpp
cfe/branches/tooling/lib/AST/ASTImporter.cpp
cfe/branches/tooling/lib/AST/Decl.cpp
cfe/branches/tooling/lib/AST/DeclarationName.cpp
cfe/branches/tooling/lib/AST/NSAPI.cpp
cfe/branches/tooling/lib/Basic/Targets.cpp
cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp
cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp
cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp
cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
cfe/branches/tooling/lib/CodeGen/CodeGenModule.h
cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp
cfe/branches/tooling/lib/Driver/Driver.cpp
cfe/branches/tooling/lib/Driver/Tools.cpp
cfe/branches/tooling/lib/Driver/Types.cpp
cfe/branches/tooling/lib/Edit/RewriteObjCFoundationAPI.cpp
cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp
cfe/branches/tooling/lib/Frontend/Warnings.cpp
cfe/branches/tooling/lib/Lex/Lexer.cpp
cfe/branches/tooling/lib/Lex/PPDirectives.cpp
cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp
cfe/branches/tooling/lib/Parse/ParseDecl.cpp
cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp
cfe/branches/tooling/lib/Parse/ParseObjc.cpp
cfe/branches/tooling/lib/Parse/ParseStmt.cpp
cfe/branches/tooling/lib/Parse/ParseTentative.cpp
cfe/branches/tooling/lib/Parse/Parser.cpp
cfe/branches/tooling/lib/Sema/CodeCompleteConsumer.cpp
cfe/branches/tooling/lib/Sema/DeclSpec.cpp
cfe/branches/tooling/lib/Sema/SemaChecking.cpp
cfe/branches/tooling/lib/Sema/SemaDecl.cpp
cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp
cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp
cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp
cfe/branches/tooling/lib/Sema/SemaExpr.cpp
cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp
cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp
cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp
cfe/branches/tooling/lib/Sema/SemaStmt.cpp
cfe/branches/tooling/lib/Sema/SemaTemplate.cpp
cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp
cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp
cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp
cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineC.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/ObjCMessage.cpp
cfe/branches/tooling/runtime/compiler-rt/Makefile
cfe/branches/tooling/test/ARCMT/checking.m
cfe/branches/tooling/test/ARCMT/objcmt-numeric-literals.m.result
cfe/branches/tooling/test/Analysis/additive-folding-range-constraints.c
cfe/branches/tooling/test/Analysis/additive-folding.cpp
cfe/branches/tooling/test/Analysis/array-struct-region.c
cfe/branches/tooling/test/Analysis/base-init.cpp
cfe/branches/tooling/test/Analysis/bstring.c
cfe/branches/tooling/test/Analysis/constant-folding.c
cfe/branches/tooling/test/Analysis/dead-stores.m
cfe/branches/tooling/test/Analysis/global-region-invalidation.c
cfe/branches/tooling/test/Analysis/initializer.cpp
cfe/branches/tooling/test/Analysis/malloc.c
cfe/branches/tooling/test/Analysis/method-call.cpp
cfe/branches/tooling/test/Analysis/outofbound-notwork.c
cfe/branches/tooling/test/Analysis/ptr-arith.c
cfe/branches/tooling/test/Analysis/reference.cpp
cfe/branches/tooling/test/Analysis/string-fail.c
cfe/branches/tooling/test/Analysis/string.c
cfe/branches/tooling/test/Analysis/unused-ivars.m
cfe/branches/tooling/test/CXX/class/class.mem/p14.cpp
cfe/branches/tooling/test/CXX/except/except.spec/p5-pointers.cpp
cfe/branches/tooling/test/CodeGen/2008-01-25-ByValReadNone.c
cfe/branches/tooling/test/CodeGenCXX/cxx0x-delegating-ctors.cpp
cfe/branches/tooling/test/CodeGenCXX/visibility.cpp
cfe/branches/tooling/test/CodeGenObjC/boxing.m
cfe/branches/tooling/test/Driver/arclite-link.c
cfe/branches/tooling/test/Driver/flags.c
cfe/branches/tooling/test/Driver/warning-options.cpp
cfe/branches/tooling/test/Index/get-cursor.cpp
cfe/branches/tooling/test/Misc/warning-flags.c
cfe/branches/tooling/test/Modules/Inputs/module.map
cfe/branches/tooling/test/Parser/MicrosoftExtensions.c
cfe/branches/tooling/test/Parser/cxx-class.cpp
cfe/branches/tooling/test/Parser/cxx-undeclared-identifier.cpp
cfe/branches/tooling/test/Sema/attr-decl-after-definition.c
cfe/branches/tooling/test/Sema/format-strings.c
cfe/branches/tooling/test/Sema/switch.c
cfe/branches/tooling/test/SemaCXX/conversion.cpp
cfe/branches/tooling/test/SemaCXX/typo-correction.cpp
cfe/branches/tooling/test/SemaCXX/unknown-type-name.cpp
cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp (props changed)
cfe/branches/tooling/test/SemaObjC/boxing-illegal-types.m
cfe/branches/tooling/test/SemaObjC/category-1.m
cfe/branches/tooling/test/SemaObjC/continuation-class-err.m
cfe/branches/tooling/test/SemaObjC/continuation-class-property.m
cfe/branches/tooling/test/SemaObjC/duplicate-property-class-extension.m
cfe/branches/tooling/test/SemaObjC/narrow-property-type-in-cont-class.m
cfe/branches/tooling/test/SemaObjC/property-impl-misuse.m
cfe/branches/tooling/test/SemaObjC/property-typecheck-1.m
cfe/branches/tooling/test/SemaObjC/related-result-type-inference.m
cfe/branches/tooling/test/SemaTemplate/delegating-constructors.cpp
cfe/branches/tooling/test/SemaTemplate/typename-specifier.cpp
cfe/branches/tooling/test/Tooling/clang-check-args.cpp
cfe/branches/tooling/test/Tooling/clang-check-builtin-headers.cpp
cfe/branches/tooling/test/Tooling/clang-check-chdir.cpp
cfe/branches/tooling/test/Tooling/clang-check-pwd.cpp
cfe/branches/tooling/test/Tooling/clang-check.cpp
cfe/branches/tooling/test/Tooling/multi-jobs.cpp
cfe/branches/tooling/tools/libclang/IndexBody.cpp
cfe/branches/tooling/tools/libclang/RecursiveASTVisitor.h
cfe/branches/tooling/tools/scan-build/scan-build
cfe/branches/tooling/utils/clangVisualizers.txt
cfe/branches/tooling/www/get_started.html
Propchange: cfe/branches/tooling/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 21 03:15:06 2012
@@ -1,3 +1,3 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:146581-156833
+/cfe/trunk:146581-157176
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/tooling/bindings/python/clang/cindex.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/bindings/python/clang/cindex.py?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/bindings/python/clang/cindex.py (original)
+++ cfe/branches/tooling/bindings/python/clang/cindex.py Mon May 21 03:15:06 2012
@@ -929,7 +929,12 @@
@staticmethod
def from_location(tu, location):
- return Cursor_get(tu, location)
+ # We store a reference to the TU in the instance so the TU won't get
+ # collected before the cursor.
+ cursor = Cursor_get(tu, location)
+ cursor._tu = tu
+
+ return cursor
def __eq__(self, other):
return Cursor_eq(self, other)
@@ -1127,6 +1132,13 @@
return self._lexical_parent
+ @property
+ def translation_unit(self):
+ """Returns the TranslationUnit to which this Cursor belongs."""
+ # If this triggers an AttributeError, the instance was not properly
+ # created.
+ return self._tu
+
def get_children(self):
"""Return an iterator for accessing the children of this cursor."""
@@ -1135,6 +1147,9 @@
# FIXME: Document this assertion in API.
# FIXME: There should just be an isNull method.
assert child != Cursor_null()
+
+ # Create reference to TU so it isn't GC'd before Cursor.
+ child._tu = self._tu
children.append(child)
return 1 # continue
children = []
@@ -1147,6 +1162,22 @@
# FIXME: There should just be an isNull method.
if res == Cursor_null():
return None
+
+ # Store a reference to the TU in the Python object so it won't get GC'd
+ # before the Cursor.
+ tu = None
+ for arg in args:
+ if isinstance(arg, TranslationUnit):
+ tu = arg
+ break
+
+ if hasattr(arg, 'translation_unit'):
+ tu = arg.translation_unit
+ break
+
+ assert tu is not None
+
+ res._tu = tu
return res
@@ -1324,9 +1355,26 @@
return result
+ @property
+ def translation_unit(self):
+ """The TranslationUnit to which this Type is associated."""
+ # If this triggers an AttributeError, the instance was not properly
+ # instantiated.
+ return self._tu
+
@staticmethod
def from_result(res, fn, args):
assert isinstance(res, Type)
+
+ tu = None
+ for arg in args:
+ if hasattr(arg, 'translation_unit'):
+ tu = arg.translation_unit
+ break
+
+ assert tu is not None
+ res._tu = tu
+
return res
def get_canonical(self):
Modified: cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py (original)
+++ cfe/branches/tooling/bindings/python/tests/cindex/test_cursor.py Mon May 21 03:15:06 2012
@@ -1,4 +1,7 @@
+import gc
+
from clang.cindex import CursorKind
+from clang.cindex import TranslationUnit
from clang.cindex import TypeKind
from .util import get_cursor
from .util import get_cursors
@@ -38,6 +41,8 @@
tu_nodes = list(it)
assert len(tu_nodes) == 3
+ for cursor in tu_nodes:
+ assert cursor.translation_unit is not None
assert tu_nodes[0] != tu_nodes[1]
assert tu_nodes[0].kind == CursorKind.STRUCT_DECL
@@ -47,6 +52,7 @@
assert tu_nodes[0].location.line == 4
assert tu_nodes[0].location.column == 8
assert tu_nodes[0].hash > 0
+ assert tu_nodes[0].translation_unit is not None
s0_nodes = list(tu_nodes[0].get_children())
assert len(s0_nodes) == 2
@@ -67,6 +73,23 @@
assert tu_nodes[2].displayname == 'f0(int, int)'
assert tu_nodes[2].is_definition() == True
+def test_references():
+ """Ensure that references to TranslationUnit are kept."""
+ tu = get_tu('int x;')
+ cursors = list(tu.cursor.get_children())
+ assert len(cursors) > 0
+
+ cursor = cursors[0]
+ assert isinstance(cursor.translation_unit, TranslationUnit)
+
+ # Delete reference to TU and perform a full GC.
+ del tu
+ gc.collect()
+ assert isinstance(cursor.translation_unit, TranslationUnit)
+
+ # If the TU was destroyed, this should cause a segfault.
+ parent = cursor.semantic_parent
+
def test_canonical():
source = 'struct X; struct X; struct X { int member; };'
tu = get_tu(source)
Modified: cfe/branches/tooling/bindings/python/tests/cindex/test_type.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/bindings/python/tests/cindex/test_type.py?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/bindings/python/tests/cindex/test_type.py (original)
+++ cfe/branches/tooling/bindings/python/tests/cindex/test_type.py Mon May 21 03:15:06 2012
@@ -1,4 +1,7 @@
+import gc
+
from clang.cindex import CursorKind
+from clang.cindex import TranslationUnit
from clang.cindex import TypeKind
from nose.tools import raises
from .util import get_cursor
@@ -28,6 +31,7 @@
assert teststruct is not None, "Could not find teststruct."
fields = list(teststruct.get_children())
assert all(x.kind == CursorKind.FIELD_DECL for x in fields)
+ assert all(x.translation_unit is not None for x in fields)
assert fields[0].spelling == 'a'
assert not fields[0].type.is_const_qualified()
@@ -72,6 +76,26 @@
assert fields[7].type.get_pointee().get_pointee().kind == TypeKind.POINTER
assert fields[7].type.get_pointee().get_pointee().get_pointee().kind == TypeKind.INT
+def test_references():
+ """Ensure that a Type maintains a reference to a TranslationUnit."""
+
+ tu = get_tu('int x;')
+ children = list(tu.cursor.get_children())
+ assert len(children) > 0
+
+ cursor = children[0]
+ t = cursor.type
+
+ assert isinstance(t.translation_unit, TranslationUnit)
+
+ # Delete main TranslationUnit reference and force a GC.
+ del tu
+ gc.collect()
+ assert isinstance(t.translation_unit, TranslationUnit)
+
+ # If the TU was destroyed, this should cause a segfault.
+ decl = t.get_declaration()
+
constarrayInput="""
struct teststruct {
void *A[2];
Modified: cfe/branches/tooling/docs/ObjectiveCLiterals.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/docs/ObjectiveCLiterals.html?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/docs/ObjectiveCLiterals.html (original)
+++ cfe/branches/tooling/docs/ObjectiveCLiterals.html Mon May 21 03:15:06 2012
@@ -157,6 +157,18 @@
then the fixed underlying type will be used to select the correct <code>NSNumber</code> creation method.
</p>
+<p>
+Boxing a value of enum type will result in a <code>NSNumber</code> pointer with a creation method according to the underlying type of the enum,
+which can be a <a href="http://clang.llvm.org/docs/LanguageExtensions.html#objc_fixed_enum">fixed underlying type</a> or a compiler-defined
+integer type capable of representing the values of all the members of the enumeration:
+</p>
+
+<pre>
+typedef enum : unsigned char { Red, Green, Blue } Color;
+Color col = Red;
+NSNumber *nsCol = @(col); // => [NSNumber numberWithUnsignedChar:]
+</pre>
+
<h3>Boxed C Strings</h3>
<p>
Modified: cfe/branches/tooling/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/ASTContext.h?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/ASTContext.h (original)
+++ cfe/branches/tooling/include/clang/AST/ASTContext.h Mon May 21 03:15:06 2012
@@ -1528,12 +1528,12 @@
/// This routine adjusts the given parameter type @p T to the actual
/// parameter type used by semantic analysis (C99 6.7.5.3p[7,8],
/// C++ [dcl.fct]p3). The adjusted parameter type is returned.
- QualType getAdjustedParameterType(QualType T);
+ QualType getAdjustedParameterType(QualType T) const;
/// \brief Retrieve the parameter type as adjusted for use in the signature
/// of a function, decaying array and function types and removing top-level
/// cv-qualifiers.
- QualType getSignatureParameterType(QualType T);
+ QualType getSignatureParameterType(QualType T) const;
/// getArrayDecayedType - Return the properly qualified result of decaying the
/// specified array type to a pointer. This operation is non-trivial when
@@ -1721,15 +1721,12 @@
/// interface, or null if non exists.
const ObjCMethodDecl *getObjCMethodRedeclaration(
const ObjCMethodDecl *MD) const {
- llvm::DenseMap<const ObjCMethodDecl*, const ObjCMethodDecl*>::const_iterator
- I = ObjCMethodRedecls.find(MD);
- if (I == ObjCMethodRedecls.end())
- return 0;
- return I->second;
+ return ObjCMethodRedecls.lookup(MD);
}
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD,
const ObjCMethodDecl *Redecl) {
+ assert(!getObjCMethodRedeclaration(MD) && "MD already has a redeclaration");
ObjCMethodRedecls[MD] = Redecl;
}
Modified: cfe/branches/tooling/include/clang/AST/DeclarationName.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/DeclarationName.h?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/DeclarationName.h (original)
+++ cfe/branches/tooling/include/clang/AST/DeclarationName.h Mon May 21 03:15:06 2012
@@ -109,8 +109,8 @@
/// CXXSpecialName, returns a pointer to it. Otherwise, returns
/// a NULL pointer.
CXXSpecialName *getAsCXXSpecialName() const {
- if (getNameKind() >= CXXConstructorName &&
- getNameKind() <= CXXConversionFunctionName)
+ NameKind Kind = getNameKind();
+ if (Kind >= CXXConstructorName && Kind <= CXXConversionFunctionName)
return reinterpret_cast<CXXSpecialName *>(Ptr & ~PtrMask);
return 0;
}
@@ -156,14 +156,8 @@
friend class DeclarationNameTable;
friend class NamedDecl;
- /// getFETokenInfoAsVoid - Retrieves the front end-specified pointer
- /// for this name as a void pointer.
- void *getFETokenInfoAsVoid() const {
- if (getNameKind() == Identifier)
- return getAsIdentifierInfo()->getFETokenInfo<void>();
- return getFETokenInfoAsVoidSlow();
- }
-
+ /// getFETokenInfoAsVoidSlow - Retrieves the front end-specified pointer
+ /// for this name as a void pointer if it's not an identifier.
void *getFETokenInfoAsVoidSlow() const;
public:
@@ -273,7 +267,11 @@
/// declaration names, including normal identifiers and C++
/// constructors, destructors, and conversion functions.
template<typename T>
- T *getFETokenInfo() const { return static_cast<T*>(getFETokenInfoAsVoid()); }
+ T *getFETokenInfo() const {
+ if (const IdentifierInfo *Info = getAsIdentifierInfo())
+ return Info->getFETokenInfo<T>();
+ return static_cast<T*>(getFETokenInfoAsVoidSlow());
+ }
void setFETokenInfo(void *T);
Modified: cfe/branches/tooling/include/clang/AST/ExprObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/ExprObjC.h?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/ExprObjC.h (original)
+++ cfe/branches/tooling/include/clang/AST/ExprObjC.h Mon May 21 03:15:06 2012
@@ -421,19 +421,20 @@
/// The return type is "Protocol*".
class ObjCProtocolExpr : public Expr {
ObjCProtocolDecl *TheProtocol;
- SourceLocation AtLoc, RParenLoc;
+ SourceLocation AtLoc, ProtoLoc, RParenLoc;
public:
ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol,
- SourceLocation at, SourceLocation rp)
+ SourceLocation at, SourceLocation protoLoc, SourceLocation rp)
: Expr(ObjCProtocolExprClass, T, VK_RValue, OK_Ordinary, false, false,
false, false),
- TheProtocol(protocol), AtLoc(at), RParenLoc(rp) {}
+ TheProtocol(protocol), AtLoc(at), ProtoLoc(protoLoc), RParenLoc(rp) {}
explicit ObjCProtocolExpr(EmptyShell Empty)
: Expr(ObjCProtocolExprClass, Empty) {}
ObjCProtocolDecl *getProtocol() const { return TheProtocol; }
void setProtocol(ObjCProtocolDecl *P) { TheProtocol = P; }
+ SourceLocation getProtocolIdLoc() const { return ProtoLoc; }
SourceLocation getAtLoc() const { return AtLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; }
void setAtLoc(SourceLocation L) { AtLoc = L; }
@@ -450,6 +451,9 @@
// Iterators
child_range children() { return child_range(); }
+
+ friend class ASTStmtReader;
+ friend class ASTStmtWriter;
};
/// ObjCIvarRefExpr - A reference to an ObjC instance variable.
Modified: cfe/branches/tooling/include/clang/AST/NSAPI.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/NSAPI.h?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/NSAPI.h (original)
+++ cfe/branches/tooling/include/clang/AST/NSAPI.h Mon May 21 03:15:06 2012
@@ -16,6 +16,7 @@
namespace clang {
class ASTContext;
class QualType;
+ class Expr;
// \brief Provides info and caches identifiers/selectors for NSFoundation API.
class NSAPI {
@@ -37,15 +38,33 @@
enum NSStringMethodKind {
NSStr_stringWithString,
+ NSStr_stringWithUTF8String,
+ NSStr_stringWithCStringEncoding,
+ NSStr_stringWithCString,
NSStr_initWithString
};
- static const unsigned NumNSStringMethods = 2;
+ static const unsigned NumNSStringMethods = 5;
IdentifierInfo *getNSClassId(NSClassIdKindKind K) const;
/// \brief The Objective-C NSString selectors.
Selector getNSStringSelector(NSStringMethodKind MK) const;
+ /// \brief Return NSStringMethodKind if \param Sel is such a selector.
+ llvm::Optional<NSStringMethodKind> getNSStringMethodKind(Selector Sel) const;
+
+ /// \brief Returns true if the expression \param E is a reference of
+ /// "NSUTF8StringEncoding" enum constant.
+ bool isNSUTF8StringEncodingConstant(const Expr *E) const {
+ return isObjCEnumerator(E, "NSUTF8StringEncoding", NSUTF8StringEncodingId);
+ }
+
+ /// \brief Returns true if the expression \param E is a reference of
+ /// "NSASCIIStringEncoding" enum constant.
+ bool isNSASCIIStringEncodingConstant(const Expr *E) const {
+ return isObjCEnumerator(E, "NSASCIIStringEncoding",NSASCIIStringEncodingId);
+ }
+
/// \brief Enumerates the NSArray methods used to generate literals.
enum NSArrayMethodKind {
NSArr_array,
@@ -138,6 +157,8 @@
private:
bool isObjCTypedef(QualType T, StringRef name, IdentifierInfo *&II) const;
+ bool isObjCEnumerator(const Expr *E,
+ StringRef name, IdentifierInfo *&II) const;
ASTContext &Ctx;
@@ -156,6 +177,7 @@
mutable Selector NSNumberInstanceSelectors[NumNSNumberLiteralMethods];
mutable IdentifierInfo *BOOLId, *NSIntegerId, *NSUIntegerId;
+ mutable IdentifierInfo *NSASCIIStringEncodingId, *NSUTF8StringEncodingId;
};
} // end namespace clang
Modified: cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/branches/tooling/include/clang/AST/RecursiveASTVisitor.h Mon May 21 03:15:06 2012
@@ -1241,8 +1241,7 @@
DEF_TRAVERSE_DECL(AccessSpecDecl, { })
DEF_TRAVERSE_DECL(BlockDecl, {
- TypeSourceInfo *TInfo = D->getSignatureAsWritten();
- if (TInfo)
+ if (TypeSourceInfo *TInfo = D->getSignatureAsWritten())
TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
TRY_TO(TraverseStmt(D->getBody()));
// This return statement makes sure the traversal of nodes in
@@ -2130,7 +2129,10 @@
DEF_TRAVERSE_STMT(GNUNullExpr, { })
DEF_TRAVERSE_STMT(ImplicitValueInitExpr, { })
DEF_TRAVERSE_STMT(ObjCBoolLiteralExpr, { })
-DEF_TRAVERSE_STMT(ObjCEncodeExpr, { })
+DEF_TRAVERSE_STMT(ObjCEncodeExpr, {
+ if (TypeSourceInfo *TInfo = S->getEncodedTypeSourceInfo())
+ TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
+})
DEF_TRAVERSE_STMT(ObjCIsaExpr, { })
DEF_TRAVERSE_STMT(ObjCIvarRefExpr, { })
DEF_TRAVERSE_STMT(ObjCMessageExpr, { })
Modified: cfe/branches/tooling/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h (original)
+++ cfe/branches/tooling/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h Mon May 21 03:15:06 2012
@@ -69,6 +69,7 @@
DISPATCH_CASE(Field)
DISPATCH_CASE(UsingDirective)
DISPATCH_CASE(Using)
+ DISPATCH_CASE(NamespaceAlias)
default:
llvm_unreachable("Subtype of ScopedDecl not handled.");
}
@@ -90,6 +91,7 @@
DEFAULT_DISPATCH(ObjCCategory)
DEFAULT_DISPATCH(UsingDirective)
DEFAULT_DISPATCH(Using)
+ DEFAULT_DISPATCH(NamespaceAlias)
void VisitCXXRecordDecl(CXXRecordDecl *D) {
static_cast<ImplClass*>(this)->VisitRecordDecl(D);
Modified: cfe/branches/tooling/include/clang/Basic/AddressSpaces.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/AddressSpaces.h?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/AddressSpaces.h (original)
+++ cfe/branches/tooling/include/clang/Basic/AddressSpaces.h Mon May 21 03:15:06 2012
@@ -29,6 +29,10 @@
opencl_local,
opencl_constant,
+ cuda_device,
+ cuda_constant,
+ cuda_shared,
+
Last,
Count = Last-Offset
};
Modified: cfe/branches/tooling/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/Attr.td?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/Attr.td (original)
+++ cfe/branches/tooling/include/clang/Basic/Attr.td Mon May 21 03:15:06 2012
@@ -267,7 +267,7 @@
let Spellings = ["constant"];
}
-def CUDADevice : Attr {
+def CUDADevice : InheritableAttr {
let Spellings = ["device"];
}
@@ -275,7 +275,7 @@
let Spellings = ["global"];
}
-def CUDAHost : Attr {
+def CUDAHost : InheritableAttr {
let Spellings = ["host"];
}
Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticCommonKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticCommonKinds.td?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticCommonKinds.td Mon May 21 03:15:06 2012
@@ -108,4 +108,8 @@
"file '%0' modified since it was first processed">, DefaultFatal;
def err_unsupported_bom : Error<"%0 byte order mark detected in '%1', but "
"encoding is not supported">, DefaultFatal;
+def err_unable_to_rename_temp : Error<
+ "unable to rename temporary '%0' to output file '%1': '%2'">;
+def err_unable_to_make_temp : Error<
+ "unable to make temporary file: %0">;
}
Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticDriverKinds.td?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticDriverKinds.td Mon May 21 03:15:06 2012
@@ -33,8 +33,6 @@
"unsupported use of internal gcc -Z option '%0'">;
def err_drv_output_argument_with_multiple_files : Error<
"cannot specify -o when generating multiple output files">;
-def err_drv_unable_to_make_temp : Error<
- "unable to make temporary file: %0">;
def err_drv_unable_to_remove_file : Error<
"unable to remove file: %0">;
def err_drv_command_failure : Error<
@@ -110,7 +108,7 @@
"argument unused during compilation: '%0'">,
InGroup<DiagGroup<"unused-command-line-argument">>;
def warn_drv_empty_joined_argument : Warning<
- "joined argument expects addition arg: '%0'">,
+ "joined argument expects additional value: '%0'">,
InGroup<DiagGroup<"unused-command-line-argument">>;
def warn_drv_not_using_clang_cpp : Warning<
"not using the clang preprocessor due to user override">;
Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticFrontendKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticFrontendKinds.td?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticFrontendKinds.td Mon May 21 03:15:06 2012
@@ -48,14 +48,12 @@
"unable to interface with target machine">;
def err_fe_unable_to_open_output : Error<
"unable to open output file '%0': '%1'">;
-def err_fe_unable_to_rename_temp : Error<
- "unable to rename temporary '%0' to output file '%1': '%2'">;
def err_fe_unable_to_open_logfile : Error<
"unable to open logfile file '%0': '%1'">;
def err_fe_pth_file_has_no_source_header : Error<
"PTH file '%0' does not designate an original source header file for -include-pth">;
def warn_fe_macro_contains_embedded_newline : Warning<
- "macro '%0' contains embedded newline, text after the newline is ignored.">;
+ "macro '%0' contains embedded newline; text after the newline is ignored">;
def warn_fe_cc_print_header_failure : Warning<
"unable to open CC_PRINT_HEADERS file: %0 (using stderr)">;
def warn_fe_cc_log_diagnostics_failure : Warning<
@@ -93,14 +91,14 @@
"unknown warning option '%0'">,
InGroup<DiagGroup<"unknown-warning-option"> >;
def warn_unknown_negative_warning_option : Warning<
- "unknown warning option '%0'?">,
- InGroup<DiagGroup<"unknown-warning-option"> >, DefaultIgnore;
+ "unknown warning option '%0'">,
+ InGroup<DiagGroup<"unknown-warning-option"> >;
def warn_unknown_warning_option_suggest : Warning<
"unknown warning option '%0'; did you mean '%1'?">,
InGroup<DiagGroup<"unknown-warning-option"> >;
def warn_unknown_negative_warning_option_suggest : Warning<
"unknown warning option '%0'; did you mean '%1'?">,
- InGroup<DiagGroup<"unknown-warning-option"> >, DefaultIgnore;
+ InGroup<DiagGroup<"unknown-warning-option"> >;
def warn_unknown_warning_specifier : Warning<
"unknown %0 warning specifier: '%1'">,
InGroup<DiagGroup<"unknown-warning-option"> >;
Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticParseKinds.td Mon May 21 03:15:06 2012
@@ -21,15 +21,16 @@
let CategoryName = "Parse Issue" in {
def ext_empty_source_file : Extension<"ISO C forbids an empty source file">;
-def ext_top_level_semi : Extension<
- "extra ';' outside of a function">;
def warn_cxx98_compat_top_level_semi : Warning<
"extra ';' outside of a function is incompatible with C++98">,
InGroup<CXX98CompatPedantic>, DefaultIgnore;
-def ext_extra_struct_semi : Extension<
- "extra ';' inside a %0">;
-def ext_extra_ivar_semi : Extension<
- "extra ';' inside instance variable list">;
+def ext_extra_semi : Extension<
+ "extra ';' %select{"
+ "outside of a function|"
+ "inside a %1|"
+ "inside instance variable list|"
+ "after function definition}0">,
+ InGroup<DiagGroup<"extra-semi">>;
def ext_duplicate_declspec : Extension<"duplicate '%0' declaration specifier">;
def ext_plain_complex : ExtWarn<
@@ -650,7 +651,8 @@
"%0 is not an availability stage; use 'introduced', 'deprecated', or "
"'obsoleted'">;
def err_availability_redundant : Error<
- "redundant %0 availability change; only the last specified change will " "be used">;
+ "redundant %0 availability change; only the last specified change will "
+ "be used">;
def warn_availability_and_unavailable : Warning<
"'unavailable' availability overrides all other availability information">,
InGroup<Availability>;
Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td Mon May 21 03:15:06 2012
@@ -593,7 +593,7 @@
"default property attribute 'assign' not appropriate for non-GC object">,
InGroup<ObjCPropertyNoAttribute>;
def warn_property_attr_mismatch : Warning<
- "property attribute in continuation class does not match the primary class">;
+ "property attribute in class extension does not match the primary class">;
def warn_objc_property_copy_missing_on_block : Warning<
"'copy' attribute must be specified for the block property "
"when -fobjc-gc-only is specified">;
@@ -634,16 +634,16 @@
"(property should be marked 'atomic' if this is intended)">,
InGroup<CustomAtomic>, DefaultIgnore;
def err_use_continuation_class : Error<
- "illegal redeclaration of property in continuation class %0"
+ "illegal redeclaration of property in class extension %0"
" (attribute must be 'readwrite', while its primary must be 'readonly')">;
def err_type_mismatch_continuation_class : Error<
- "type of property %0 in continuation class does not match "
+ "type of property %0 in class extension does not match "
"property type in primary class">;
def err_use_continuation_class_redeclaration_readwrite : Error<
- "illegal redeclaration of 'readwrite' property in continuation class %0"
+ "illegal redeclaration of 'readwrite' property in class extension %0"
" (perhaps you intended this to be a 'readwrite' redeclaration of a "
"'readonly' public property?)">;
-def err_continuation_class : Error<"continuation class has no primary class">;
+def err_continuation_class : Error<"class extension has no primary class">;
def err_property_type : Error<"property cannot have array or function type %0">;
def error_missing_property_context : Error<
"missing context for property implementation declaration">;
@@ -685,6 +685,8 @@
def error_property_ivar_type : Error<
"type of property %0 (%1) does not match type of ivar %2 (%3)">;
+def error_property_accessor_type : Error<
+ "type of property %0 (%1) does not match type of accessor %2 (%3)">;
def error_ivar_in_superclass_use : Error<
"property %0 attempting to use ivar %1 declared in super class %2">;
def error_weak_property : Error<
@@ -709,6 +711,12 @@
"undeclared selector %0">, InGroup<UndeclaredSelector>, DefaultIgnore;
def warn_implicit_atomic_property : Warning<
"property is assumed atomic by default">, InGroup<ImplicitAtomic>, DefaultIgnore;
+def note_auto_readonly_iboutlet_fixup_suggest : Note<
+ "readonly IBOutlet property should be changed to be readwrite">;
+def warn_auto_readonly_iboutlet_property : Warning<
+ "readonly IBOutlet property when auto-synthesized may "
+ "not work correctly with 'nib' loader">,
+ InGroup<DiagGroup<"readonly-iboutlet-property">>;
def warn_auto_implicit_atomic_property : Warning<
"property is assumed atomic when auto-synthesizing the property">,
InGroup<ImplicitAtomic>, DefaultIgnore;
@@ -1540,6 +1548,8 @@
"cannot box a string value because NSString has not been declared">;
def err_objc_illegal_boxed_expression_type : Error<
"illegal type %0 used in a boxed expression">;
+def err_objc_incomplete_boxed_expression_type : Error<
+ "incomplete type %0 used in a boxed expression">;
def err_undeclared_nsarray : Error<
"NSArray must be available to use Objective-C array literals">;
def err_undeclared_nsdictionary : Error<
@@ -2357,6 +2367,8 @@
def note_member_of_template_here : Note<"member is declared here">;
def err_template_arg_must_be_type : Error<
"template argument for template type parameter must be a type">;
+def err_template_arg_must_be_type_suggest : Error<
+ "template argument for template type parameter must be a type; did you forget 'typename'?">;
def err_template_arg_must_be_expr : Error<
"template argument for non-type template parameter must be an expression">;
def err_template_arg_nontype_ambig : Error<
@@ -3811,7 +3823,7 @@
"consider using __builtin_trap() or qualifying pointer with 'volatile'">;
def warn_pointer_indirection_from_incompatible_type : Warning<
"dereference of type %1 that was reinterpret_cast from type %0 has undefined "
- "behavior.">,
+ "behavior">,
InGroup<DiagGroup<"undefined-reinterpret-cast">>, DefaultIgnore;
def err_objc_object_assignment : Error<
@@ -4116,7 +4128,7 @@
def err_bad_reinterpret_cast_reference : Error<
"reinterpret_cast of a %0 to %1 needs its address which is not allowed">;
def warn_undefined_reinterpret_cast : Warning<
- "reinterpret_cast from %0 to %1 has undefined behavior.">,
+ "reinterpret_cast from %0 to %1 has undefined behavior">,
InGroup<DiagGroup<"undefined-reinterpret-cast">>, DefaultIgnore;
// These messages don't adhere to the pattern.
@@ -4380,6 +4392,9 @@
def err_not_tag_in_scope : Error<
"no %select{struct|union|class|enum}0 named %1 in %2">;
+def err_no_typeid_with_fno_rtti : Error<
+ "cannot use typeid with -fno-rtti">;
+
def err_cannot_form_pointer_to_member_of_reference_type : Error<
"cannot form a pointer-to-member to member %0 of reference type %1">;
def err_incomplete_object_call : Error<
@@ -4928,9 +4943,9 @@
def err_operator_new_delete_dependent_result_type : Error<
"%0 cannot have a dependent return type; use %1 instead">;
def err_operator_new_delete_too_few_parameters : Error<
- "%0 must have at least one parameter.">;
+ "%0 must have at least one parameter">;
def err_operator_new_delete_template_too_few_parameters : Error<
- "%0 template must have at least two parameters.">;
+ "%0 template must have at least two parameters">;
def err_operator_new_dependent_param_type : Error<
"%0 cannot take a dependent type as first parameter; "
@@ -5225,6 +5240,8 @@
"overflow converting case value to switch condition type (%0 to %1)">,
InGroup<DiagGroup<"switch">>;
def err_duplicate_case : Error<"duplicate case value '%0'">;
+def err_duplicate_case_differing_expr : Error<
+ "duplicate case value: '%0' and '%1' both equal '%2'">;
def warn_case_empty_range : Warning<"empty case range specified">;
def warn_missing_case_for_condition :
Warning<"no case matching constant switch condition '%0'">;
Modified: cfe/branches/tooling/include/clang/Basic/TokenKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/TokenKinds.def?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/TokenKinds.def (original)
+++ cfe/branches/tooling/include/clang/Basic/TokenKinds.def Mon May 21 03:15:06 2012
@@ -486,28 +486,30 @@
ALIAS("__volatile__" , volatile , KEYALL)
// Microsoft extensions which should be disabled in strict conformance mode
-KEYWORD(__ptr64 , KEYMS)
-KEYWORD(__ptr32 , KEYMS)
-KEYWORD(__w64 , KEYMS)
-KEYWORD(__uuidof , KEYMS | KEYBORLAND)
-KEYWORD(__try , KEYMS | KEYBORLAND)
-KEYWORD(__finally , KEYMS | KEYBORLAND)
-KEYWORD(__leave , KEYMS | KEYBORLAND)
-KEYWORD(__int64 , KEYMS)
-KEYWORD(__if_exists , KEYMS)
-KEYWORD(__if_not_exists , KEYMS)
-ALIAS("__int8" , char , KEYMS)
-ALIAS("__int16" , short , KEYMS)
-ALIAS("__int32" , int , KEYMS)
-ALIAS("_asm" , asm , KEYMS)
-ALIAS("_cdecl" , __cdecl , KEYMS | KEYBORLAND)
-ALIAS("_fastcall" , __fastcall , KEYMS | KEYBORLAND)
-ALIAS("_stdcall" , __stdcall , KEYMS | KEYBORLAND)
-ALIAS("_thiscall" , __thiscall , KEYMS)
-ALIAS("_uuidof" , __uuidof , KEYMS | KEYBORLAND)
-ALIAS("_inline" , inline , KEYMS)
-ALIAS("_declspec" , __declspec , KEYMS)
-ALIAS("__interface" , struct , KEYMS)
+KEYWORD(__ptr64 , KEYMS)
+KEYWORD(__ptr32 , KEYMS)
+KEYWORD(__w64 , KEYMS)
+KEYWORD(__uuidof , KEYMS | KEYBORLAND)
+KEYWORD(__try , KEYMS | KEYBORLAND)
+KEYWORD(__finally , KEYMS | KEYBORLAND)
+KEYWORD(__leave , KEYMS | KEYBORLAND)
+KEYWORD(__int64 , KEYMS)
+KEYWORD(__if_exists , KEYMS)
+KEYWORD(__if_not_exists , KEYMS)
+ALIAS("__int8" , char , KEYMS)
+ALIAS("__int16" , short , KEYMS)
+ALIAS("__int32" , int , KEYMS)
+ALIAS("_asm" , asm , KEYMS)
+ALIAS("_alignof" , __alignof , KEYMS)
+ALIAS("__builtin_alignof", __alignof , KEYMS)
+ALIAS("_cdecl" , __cdecl , KEYMS | KEYBORLAND)
+ALIAS("_fastcall" , __fastcall , KEYMS | KEYBORLAND)
+ALIAS("_stdcall" , __stdcall , KEYMS | KEYBORLAND)
+ALIAS("_thiscall" , __thiscall , KEYMS)
+ALIAS("_uuidof" , __uuidof , KEYMS | KEYBORLAND)
+ALIAS("_inline" , inline , KEYMS)
+ALIAS("_declspec" , __declspec , KEYMS)
+ALIAS("__interface" , struct , KEYMS)
// Borland Extensions which should be disabled in strict conformance mode.
ALIAS("_pascal" , __pascal , KEYBORLAND)
Modified: cfe/branches/tooling/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/CC1Options.td?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/CC1Options.td (original)
+++ cfe/branches/tooling/include/clang/Driver/CC1Options.td Mon May 21 03:15:06 2012
@@ -147,7 +147,7 @@
def fforbid_guard_variables : Flag<"-fforbid-guard-variables">,
HelpText<"Emit an error if a C++ static local initializer would need a guard variable">;
def no_implicit_float : Flag<"-no-implicit-float">,
- HelpText<"Don't generate implicit floating point instructions (x86-only)">;
+ HelpText<"Don't generate implicit floating point instructions">;
def fdump_vtable_layouts : Flag<"-fdump-vtable-layouts">,
HelpText<"Dump the layouts of all vtables that will be emitted in a translation unit">;
def femit_coverage_notes : Flag<"-femit-coverage-notes">,
Modified: cfe/branches/tooling/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Driver/Options.td?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/Options.td (original)
+++ cfe/branches/tooling/include/clang/Driver/Options.td Mon May 21 03:15:06 2012
@@ -800,6 +800,8 @@
def msmall_data_threshold_EQ : Joined <"-msmall-data-threshold=">, Group<m_Group>;
def msoft_float : Flag<"-msoft-float">, Group<m_Group>, Flags<[CC1Option]>,
HelpText<"Use software floating point">;
+def mno_implicit_float : Flag<"-mno-implicit-float">, Group<m_Group>,
+ HelpText<"Don't generate implicit floating point instructions">;
def msse2 : Flag<"-msse2">, Group<m_x86_Features_Group>;
def msse3 : Flag<"-msse3">, Group<m_x86_Features_Group>;
def msse4a : Flag<"-msse4a">, Group<m_x86_Features_Group>;
Modified: cfe/branches/tooling/include/clang/Lex/Lexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Lex/Lexer.h?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Lex/Lexer.h (original)
+++ cfe/branches/tooling/include/clang/Lex/Lexer.h Mon May 21 03:15:06 2012
@@ -200,7 +200,7 @@
/// ReadToEndOfLine - Read the rest of the current preprocessor line as an
/// uninterpreted string. This switches the lexer out of directive mode.
- std::string ReadToEndOfLine();
+ void ReadToEndOfLine(SmallVectorImpl<char> *Result = 0);
/// Diag - Forwarding function for diagnostics. This translate a source
Modified: cfe/branches/tooling/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Parse/Parser.h?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Parse/Parser.h (original)
+++ cfe/branches/tooling/include/clang/Parse/Parser.h Mon May 21 03:15:06 2012
@@ -654,6 +654,17 @@
/// to the semicolon, consumes that extra token.
bool ExpectAndConsumeSemi(unsigned DiagID);
+ /// \brief The kind of extra semi diagnostic to emit.
+ enum ExtraSemiKind {
+ OutsideFunction = 0,
+ InsideStruct = 1,
+ InstanceVariableList = 2,
+ AfterDefinition = 3
+ };
+
+ /// \brief Consume any extra semi-colons until the end of the line.
+ void ConsumeExtraSemi(ExtraSemiKind Kind, const char* DiagMsg = "");
+
//===--------------------------------------------------------------------===//
// Scope manipulation
@@ -1742,7 +1753,8 @@
/// BracedCastResult.
/// Doesn't consume tokens.
TPResult
- isCXXDeclarationSpecifier(TPResult BracedCastResult = TPResult::False());
+ isCXXDeclarationSpecifier(TPResult BracedCastResult = TPResult::False(),
+ bool *HasMissingTypename = 0);
// "Tentative parsing" functions, used for disambiguation. If a parsing error
// is encountered they will return TPResult::Error().
@@ -1751,13 +1763,13 @@
// that more tentative parsing is necessary for disambiguation.
// They all consume tokens, so backtracking should be used after calling them.
- TPResult TryParseDeclarationSpecifier();
+ TPResult TryParseDeclarationSpecifier(bool *HasMissingTypename = 0);
TPResult TryParseSimpleDeclaration(bool AllowForRangeDecl);
TPResult TryParseTypeofSpecifier();
TPResult TryParseProtocolQualifiers();
TPResult TryParseInitDeclaratorList();
TPResult TryParseDeclarator(bool mayBeAbstract, bool mayHaveIdentifier=true);
- TPResult TryParseParameterDeclarationClause();
+ TPResult TryParseParameterDeclarationClause(bool *InvalidAsDeclaration = 0);
TPResult TryParseFunctionDeclarator();
TPResult TryParseBracketDeclarator();
Modified: cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/branches/tooling/include/clang/Sema/CodeCompleteConsumer.h Mon May 21 03:15:06 2012
@@ -644,9 +644,6 @@
RK_Pattern //< Refers to a precomputed pattern.
};
- /// \brief The kind of result stored here.
- ResultKind Kind;
-
/// \brief When Kind == RK_Declaration or RK_Pattern, the declaration we are
/// referring to. In the latter case, the declaration might be NULL.
NamedDecl *Declaration;
@@ -667,16 +664,19 @@
/// \brief The priority of this particular code-completion result.
unsigned Priority;
- /// \brief The cursor kind that describes this result.
- CXCursorKind CursorKind;
-
- /// \brief The availability of this result.
- CXAvailabilityKind Availability;
-
/// \brief Specifies which parameter (of a function, Objective-C method,
/// macro, etc.) we should start with when formatting the result.
unsigned StartParameter;
+ /// \brief The kind of result stored here.
+ ResultKind Kind : 3;
+
+ /// \brief The cursor kind that describes this result.
+ CXCursorKind CursorKind : 16;
+
+ /// \brief The availability of this result.
+ CXAvailabilityKind Availability : 8;
+
/// \brief Whether this result is hidden by another name.
bool Hidden : 1;
@@ -705,10 +705,10 @@
NestedNameSpecifier *Qualifier = 0,
bool QualifierIsInformative = false,
bool Accessible = true)
- : Kind(RK_Declaration), Declaration(Declaration),
- Priority(getPriorityFromDecl(Declaration)),
- Availability(CXAvailability_Available), StartParameter(0),
- Hidden(false), QualifierIsInformative(QualifierIsInformative),
+ : Declaration(Declaration), Priority(getPriorityFromDecl(Declaration)),
+ StartParameter(0), Kind(RK_Declaration),
+ Availability(CXAvailability_Available), Hidden(false),
+ QualifierIsInformative(QualifierIsInformative),
StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
DeclaringEntity(false), Qualifier(Qualifier) {
computeCursorKindAndAvailability(Accessible);
@@ -716,22 +716,22 @@
/// \brief Build a result that refers to a keyword or symbol.
CodeCompletionResult(const char *Keyword, unsigned Priority = CCP_Keyword)
- : Kind(RK_Keyword), Declaration(0), Keyword(Keyword), Priority(Priority),
- Availability(CXAvailability_Available),
- StartParameter(0), Hidden(false), QualifierIsInformative(0),
- StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
- DeclaringEntity(false), Qualifier(0) {
- computeCursorKindAndAvailability();
+ : Declaration(0), Keyword(Keyword), Priority(Priority), StartParameter(0),
+ Kind(RK_Keyword), CursorKind(CXCursor_NotImplemented),
+ Availability(CXAvailability_Available), Hidden(false),
+ QualifierIsInformative(0), StartsNestedNameSpecifier(false),
+ AllParametersAreInformative(false), DeclaringEntity(false), Qualifier(0)
+ {
}
/// \brief Build a result that refers to a macro.
CodeCompletionResult(IdentifierInfo *Macro, unsigned Priority = CCP_Macro)
- : Kind(RK_Macro), Declaration(0), Macro(Macro), Priority(Priority),
- Availability(CXAvailability_Available), StartParameter(0),
- Hidden(false), QualifierIsInformative(0),
- StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
- DeclaringEntity(false), Qualifier(0) {
- computeCursorKindAndAvailability();
+ : Declaration(0), Macro(Macro), Priority(Priority), StartParameter(0),
+ Kind(RK_Macro), CursorKind(CXCursor_MacroDefinition),
+ Availability(CXAvailability_Available), Hidden(false),
+ QualifierIsInformative(0), StartsNestedNameSpecifier(false),
+ AllParametersAreInformative(false), DeclaringEntity(false), Qualifier(0)
+ {
}
/// \brief Build a result that refers to a pattern.
@@ -740,8 +740,8 @@
CXCursorKind CursorKind = CXCursor_NotImplemented,
CXAvailabilityKind Availability = CXAvailability_Available,
NamedDecl *D = 0)
- : Kind(RK_Pattern), Declaration(D), Pattern(Pattern), Priority(Priority),
- CursorKind(CursorKind), Availability(Availability), StartParameter(0),
+ : Declaration(D), Pattern(Pattern), Priority(Priority), StartParameter(0),
+ Kind(RK_Pattern), CursorKind(CursorKind), Availability(Availability),
Hidden(false), QualifierIsInformative(0),
StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
DeclaringEntity(false), Qualifier(0)
@@ -752,11 +752,10 @@
/// declaration.
CodeCompletionResult(CodeCompletionString *Pattern, NamedDecl *D,
unsigned Priority)
- : Kind(RK_Pattern), Declaration(D), Pattern(Pattern), Priority(Priority),
- Availability(CXAvailability_Available), StartParameter(0),
- Hidden(false), QualifierIsInformative(false),
- StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
- DeclaringEntity(false), Qualifier(0) {
+ : Declaration(D), Pattern(Pattern), Priority(Priority), StartParameter(0),
+ Kind(RK_Pattern), Availability(CXAvailability_Available), Hidden(false),
+ QualifierIsInformative(false), StartsNestedNameSpecifier(false),
+ AllParametersAreInformative(false), DeclaringEntity(false), Qualifier(0) {
computeCursorKindAndAvailability();
}
Modified: cfe/branches/tooling/include/clang/Sema/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/DeclSpec.h?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/DeclSpec.h (original)
+++ cfe/branches/tooling/include/clang/Sema/DeclSpec.h Mon May 21 03:15:06 2012
@@ -853,12 +853,14 @@
assert(Other.Kind == IK_Identifier && "Cannot copy non-identifiers");
}
- /// \brief Destroy this unqualified-id.
- ~UnqualifiedId() { clear(); }
-
/// \brief Clear out this unqualified-id, setting it to default (invalid)
/// state.
- void clear();
+ void clear() {
+ Kind = IK_Identifier;
+ Identifier = 0;
+ StartLocation = SourceLocation();
+ EndLocation = SourceLocation();
+ }
/// \brief Determine whether this unqualified-id refers to a valid name.
bool isValid() const { return StartLocation.isValid(); }
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=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Sema.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Sema.h Mon May 21 03:15:06 2012
@@ -2402,7 +2402,10 @@
};
FullExprArg MakeFullExpr(Expr *Arg) {
- return FullExprArg(ActOnFinishFullExpr(Arg).release());
+ return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
+ }
+ FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC) {
+ return FullExprArg(ActOnFinishFullExpr(Arg, CC).release());
}
StmtResult ActOnExprStmt(FullExprArg Expr);
@@ -3795,7 +3798,11 @@
Stmt *MaybeCreateStmtWithCleanups(Stmt *SubStmt);
ExprResult MaybeCreateExprWithCleanups(ExprResult SubExpr);
- ExprResult ActOnFinishFullExpr(Expr *Expr);
+ ExprResult ActOnFinishFullExpr(Expr *Expr) {
+ return ActOnFinishFullExpr(Expr, Expr ? Expr->getExprLoc()
+ : SourceLocation());
+ }
+ ExprResult ActOnFinishFullExpr(Expr *Expr, SourceLocation CC);
StmtResult ActOnFinishFullStmt(Stmt *Stmt);
// Marks SS invalid if it represents an incomplete type.
@@ -4096,6 +4103,7 @@
SourceLocation AtLoc,
SourceLocation ProtoLoc,
SourceLocation LParenLoc,
+ SourceLocation ProtoIdLoc,
SourceLocation RParenLoc);
//===--------------------------------------------------------------------===//
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=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h Mon May 21 03:15:06 2012
@@ -672,7 +672,7 @@
const LocationContext *LCtx) const {
if (const Expr *Ex = dyn_cast<Expr>(S)) {
QualType T = Ex->getType();
- if (Ex->isLValue() || Loc::isLocType(T) || T->isIntegerType())
+ if (Ex->isGLValue() || Loc::isLocType(T) || T->isIntegerType())
return getSVal(S, LCtx);
}
Modified: cfe/branches/tooling/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/TransRetainReleaseDealloc.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/TransRetainReleaseDealloc.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/TransRetainReleaseDealloc.cpp Mon May 21 03:15:06 2012
@@ -63,17 +63,6 @@
break;
return true;
case OMF_autorelease:
- if (isRemovable(E)) {
- // An unused autorelease is badness. If we remove it the receiver
- // will likely die immediately while previously it was kept alive
- // by the autorelease pool. This is bad practice in general, leave it
- // and emit an error to force the user to restructure his code.
- Pass.TA.reportError("it is not safe to remove an unused 'autorelease' "
- "message; its receiver may be destroyed immediately",
- E->getLocStart(), E->getSourceRange());
- return true;
- }
- // Pass through.
case OMF_retain:
case OMF_release:
if (E->getReceiverKind() == ObjCMessageExpr::Instance)
Modified: cfe/branches/tooling/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ASTContext.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ASTContext.cpp (original)
+++ cfe/branches/tooling/lib/AST/ASTContext.cpp Mon May 21 03:15:06 2012
@@ -206,7 +206,10 @@
static const unsigned FakeAddrSpaceMap[] = {
1, // opencl_global
2, // opencl_local
- 3 // opencl_constant
+ 3, // opencl_constant
+ 4, // cuda_device
+ 5, // cuda_constant
+ 6 // cuda_shared
};
return &FakeAddrSpaceMap;
} else {
@@ -3473,7 +3476,7 @@
VAT->getBracketsRange()));
}
-QualType ASTContext::getAdjustedParameterType(QualType T) {
+QualType ASTContext::getAdjustedParameterType(QualType T) const {
// C99 6.7.5.3p7:
// A declaration of a parameter as "array of type" shall be
// adjusted to "qualified pointer to type", where the type
@@ -3492,7 +3495,7 @@
return T;
}
-QualType ASTContext::getSignatureParameterType(QualType T) {
+QualType ASTContext::getSignatureParameterType(QualType T) const {
T = getVariableArrayDecayedType(T);
T = getAdjustedParameterType(T);
return T.getUnqualifiedType();
Modified: cfe/branches/tooling/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ASTImporter.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ASTImporter.cpp (original)
+++ cfe/branches/tooling/lib/AST/ASTImporter.cpp Mon May 21 03:15:06 2012
@@ -1002,9 +1002,9 @@
}
// Check the fields for consistency.
- CXXRecordDecl::field_iterator Field2 = D2->field_begin(),
+ RecordDecl::field_iterator Field2 = D2->field_begin(),
Field2End = D2->field_end();
- for (CXXRecordDecl::field_iterator Field1 = D1->field_begin(),
+ for (RecordDecl::field_iterator Field1 = D1->field_begin(),
Field1End = D1->field_end();
Field1 != Field1End;
++Field1, ++Field2) {
Modified: cfe/branches/tooling/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Decl.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Decl.cpp (original)
+++ cfe/branches/tooling/lib/AST/Decl.cpp Mon May 21 03:15:06 2012
@@ -633,9 +633,19 @@
llvm::Optional<Visibility> NamedDecl::getExplicitVisibility() const {
// Use the most recent declaration of a variable.
- if (const VarDecl *var = dyn_cast<VarDecl>(this))
- return getVisibilityOf(var->getMostRecentDecl());
+ if (const VarDecl *Var = dyn_cast<VarDecl>(this)) {
+ if (llvm::Optional<Visibility> V =
+ getVisibilityOf(Var->getMostRecentDecl()))
+ return V;
+
+ if (Var->isStaticDataMember()) {
+ VarDecl *InstantiatedFrom = Var->getInstantiatedFromStaticDataMember();
+ if (InstantiatedFrom)
+ return getVisibilityOf(InstantiatedFrom);
+ }
+ return llvm::Optional<Visibility>();
+ }
// Use the most recent declaration of a function, and also handle
// function template specializations.
if (const FunctionDecl *fn = dyn_cast<FunctionDecl>(this)) {
Modified: cfe/branches/tooling/lib/AST/DeclarationName.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/DeclarationName.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/DeclarationName.cpp (original)
+++ cfe/branches/tooling/lib/AST/DeclarationName.cpp Mon May 21 03:15:06 2012
@@ -281,7 +281,7 @@
void *DeclarationName::getFETokenInfoAsVoidSlow() const {
switch (getNameKind()) {
case Identifier:
- llvm_unreachable("Handled by getFETokenInfoAsVoid()");
+ llvm_unreachable("Handled by getFETokenInfo()");
case CXXConstructorName:
case CXXDestructorName:
Modified: cfe/branches/tooling/lib/AST/NSAPI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/NSAPI.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/NSAPI.cpp (original)
+++ cfe/branches/tooling/lib/AST/NSAPI.cpp Mon May 21 03:15:06 2012
@@ -9,11 +9,13 @@
#include "clang/AST/NSAPI.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/Expr.h"
using namespace clang;
NSAPI::NSAPI(ASTContext &ctx)
- : Ctx(ctx), ClassIds(), BOOLId(0), NSIntegerId(0), NSUIntegerId(0) {
+ : Ctx(ctx), ClassIds(), BOOLId(0), NSIntegerId(0), NSUIntegerId(0),
+ NSASCIIStringEncodingId(0), NSUTF8StringEncodingId(0) {
}
IdentifierInfo *NSAPI::getNSClassId(NSClassIdKindKind K) const {
@@ -40,6 +42,21 @@
case NSStr_stringWithString:
Sel = Ctx.Selectors.getUnarySelector(&Ctx.Idents.get("stringWithString"));
break;
+ case NSStr_stringWithUTF8String:
+ Sel = Ctx.Selectors.getUnarySelector(
+ &Ctx.Idents.get("stringWithUTF8String"));
+ break;
+ case NSStr_stringWithCStringEncoding: {
+ IdentifierInfo *KeyIdents[] = {
+ &Ctx.Idents.get("stringWithCString"),
+ &Ctx.Idents.get("encoding")
+ };
+ Sel = Ctx.Selectors.getSelector(2, KeyIdents);
+ break;
+ }
+ case NSStr_stringWithCString:
+ Sel= Ctx.Selectors.getUnarySelector(&Ctx.Idents.get("stringWithCString"));
+ break;
case NSStr_initWithString:
Sel = Ctx.Selectors.getUnarySelector(&Ctx.Idents.get("initWithString"));
break;
@@ -50,6 +67,17 @@
return NSStringSelectors[MK];
}
+llvm::Optional<NSAPI::NSStringMethodKind>
+NSAPI::getNSStringMethodKind(Selector Sel) const {
+ for (unsigned i = 0; i != NumNSStringMethods; ++i) {
+ NSStringMethodKind MK = NSStringMethodKind(i);
+ if (Sel == getNSStringSelector(MK))
+ return MK;
+ }
+
+ return llvm::Optional<NSStringMethodKind>();
+}
+
Selector NSAPI::getNSArraySelector(NSArrayMethodKind MK) const {
if (NSArraySelectors[MK].isNull()) {
Selector Sel;
@@ -353,3 +381,21 @@
return false;
}
+
+bool NSAPI::isObjCEnumerator(const Expr *E,
+ StringRef name, IdentifierInfo *&II) const {
+ if (!Ctx.getLangOpts().ObjC1)
+ return false;
+ if (!E)
+ return false;
+
+ if (!II)
+ II = &Ctx.Idents.get(name);
+
+ if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts()))
+ if (const EnumConstantDecl *
+ EnumD = dyn_cast_or_null<EnumConstantDecl>(DRE->getDecl()))
+ return EnumD->getIdentifier() == II;
+
+ return false;
+}
Modified: cfe/branches/tooling/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Basic/Targets.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Basic/Targets.cpp (original)
+++ cfe/branches/tooling/lib/Basic/Targets.cpp Mon May 21 03:15:06 2012
@@ -949,7 +949,10 @@
static const unsigned PTXAddrSpaceMap[] = {
0, // opencl_global
4, // opencl_local
- 1 // opencl_constant
+ 1, // opencl_constant
+ 0, // cuda_device
+ 1, // cuda_constant
+ 4, // cuda_shared
};
class PTXTargetInfo : public TargetInfo {
static const char * const GCCRegNames[];
@@ -1074,6 +1077,99 @@
}
namespace {
+ static const unsigned NVPTXAddrSpaceMap[] = {
+ 1, // opencl_global
+ 3, // opencl_local
+ 4, // opencl_constant
+ 1, // cuda_device
+ 4, // cuda_constant
+ 3, // cuda_shared
+ };
+ class NVPTXTargetInfo : public TargetInfo {
+ static const char * const GCCRegNames[];
+ public:
+ NVPTXTargetInfo(const std::string& triple) : TargetInfo(triple) {
+ BigEndian = false;
+ TLSSupported = false;
+ LongWidth = LongAlign = 64;
+ AddrSpaceMap = &NVPTXAddrSpaceMap;
+ }
+ virtual void getTargetDefines(const LangOptions &Opts,
+ MacroBuilder &Builder) const {
+ Builder.defineMacro("__PTX__");
+ }
+ virtual void getTargetBuiltins(const Builtin::Info *&Records,
+ unsigned &NumRecords) const {
+ // FIXME: implement.
+ Records = 0;
+ NumRecords = 0;
+ }
+ virtual bool hasFeature(StringRef Feature) const {
+ return Feature == "nvptx";
+ }
+
+ virtual void getGCCRegNames(const char * const *&Names,
+ unsigned &NumNames) const;
+ virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
+ unsigned &NumAliases) const {
+ // No aliases.
+ Aliases = 0;
+ NumAliases = 0;
+ }
+ virtual bool validateAsmConstraint(const char *&Name,
+ TargetInfo::ConstraintInfo &info) const {
+ // FIXME: implement
+ return true;
+ }
+ virtual const char *getClobbers() const {
+ // FIXME: Is this really right?
+ return "";
+ }
+ virtual const char *getVAListDeclaration() const {
+ // FIXME: implement
+ return "typedef char* __builtin_va_list;";
+ }
+ virtual bool setCPU(const std::string &Name) {
+ return Name == "sm_10";
+ }
+ };
+
+ const char * const NVPTXTargetInfo::GCCRegNames[] = {
+ "r0"
+ };
+
+ void NVPTXTargetInfo::getGCCRegNames(const char * const *&Names,
+ unsigned &NumNames) const {
+ Names = GCCRegNames;
+ NumNames = llvm::array_lengthof(GCCRegNames);
+ }
+
+ class NVPTX32TargetInfo : public NVPTXTargetInfo {
+ public:
+ NVPTX32TargetInfo(const std::string& triple) : NVPTXTargetInfo(triple) {
+ PointerWidth = PointerAlign = 32;
+ SizeType = PtrDiffType = IntPtrType = TargetInfo::UnsignedInt;
+ DescriptionString
+ = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
+ "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-"
+ "n16:32:64";
+ }
+ };
+
+ class NVPTX64TargetInfo : public NVPTXTargetInfo {
+ public:
+ NVPTX64TargetInfo(const std::string& triple) : NVPTXTargetInfo(triple) {
+ PointerWidth = PointerAlign = 64;
+ SizeType = PtrDiffType = IntPtrType = TargetInfo::UnsignedLongLong;
+ DescriptionString
+ = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
+ "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-"
+ "n16:32:64";
+ }
+ };
+}
+
+namespace {
// MBlaze abstract base class
class MBlazeTargetInfo : public TargetInfo {
static const char * const GCCRegNames[];
@@ -3384,7 +3480,10 @@
static const unsigned TCEOpenCLAddrSpaceMap[] = {
3, // opencl_global
4, // opencl_local
- 5 // opencl_constant
+ 5, // opencl_constant
+ 0, // cuda_device
+ 0, // cuda_constant
+ 0 // cuda_shared
};
class TCETargetInfo : public TargetInfo{
@@ -4045,6 +4144,11 @@
case llvm::Triple::ptx64:
return new PTX64TargetInfo(T);
+ case llvm::Triple::nvptx:
+ return new NVPTX32TargetInfo(T);
+ case llvm::Triple::nvptx64:
+ return new NVPTX64TargetInfo(T);
+
case llvm::Triple::mblaze:
return new MBlazeTargetInfo(T);
Modified: cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGBlocks.cpp Mon May 21 03:15:06 2012
@@ -698,7 +698,7 @@
// Compute the address of the thing we're going to move into the
// block literal.
llvm::Value *src;
- if (ci->isNested()) {
+ if (BlockInfo && ci->isNested()) {
// We need to use the capture from the enclosing block.
const CGBlockInfo::Capture &enclosingCapture =
BlockInfo->getCapture(variable);
Modified: cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp Mon May 21 03:15:06 2012
@@ -576,8 +576,10 @@
const Type *Ty,
QualType PointeeTy,
llvm::DIFile Unit) {
- if (Tag == llvm::dwarf::DW_TAG_reference_type)
- return DBuilder.createReferenceType(CreatePointeeType(PointeeTy, Unit));
+ if (Tag == llvm::dwarf::DW_TAG_reference_type ||
+ Tag == llvm::dwarf::DW_TAG_rvalue_reference_type)
+ return DBuilder.createReferenceType(Tag,
+ CreatePointeeType(PointeeTy, Unit));
// Bit size, align and offset of the type.
// Size is always the size of a pointer. We can't use getTypeSize here
@@ -688,9 +690,7 @@
}
llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys);
-
- llvm::DIType DbgTy = DBuilder.createSubroutineType(Unit, EltTypeArray);
- return DbgTy;
+ return DBuilder.createSubroutineType(Unit, EltTypeArray);
}
@@ -2241,14 +2241,14 @@
// If Storage is an aggregate returned as 'sret' then let debugger know
// about this.
if (Arg->hasStructRetAttr())
- Ty = DBuilder.createReferenceType(Ty);
+ Ty = DBuilder.createReferenceType(llvm::dwarf::DW_TAG_reference_type, Ty);
else if (CXXRecordDecl *Record = VD->getType()->getAsCXXRecordDecl()) {
// If an aggregate variable has non trivial destructor or non trivial copy
// constructor than it is pass indirectly. Let debug info know about this
// by using reference of the aggregate type as a argument type.
if (!Record->hasTrivialCopyConstructor() ||
!Record->hasTrivialDestructor())
- Ty = DBuilder.createReferenceType(Ty);
+ Ty = DBuilder.createReferenceType(llvm::dwarf::DW_TAG_reference_type, Ty);
}
}
Modified: cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprCXX.cpp Mon May 21 03:15:06 2012
@@ -409,7 +409,6 @@
if (E->requiresZeroInitialization() && !Dest.isZeroed()) {
switch (E->getConstructionKind()) {
case CXXConstructExpr::CK_Delegating:
- assert(0 && "Delegating constructor should not need zeroing");
case CXXConstructExpr::CK_Complete:
EmitNullInitialization(Dest.getAddr(), E->getType());
break;
Modified: cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp Mon May 21 03:15:06 2012
@@ -1172,11 +1172,12 @@
DeferredDecls.erase(DDI);
}
+ unsigned AddrSpace = GetGlobalVarAddressSpace(D, Ty->getAddressSpace());
llvm::GlobalVariable *GV =
new llvm::GlobalVariable(getModule(), Ty->getElementType(), false,
llvm::GlobalValue::ExternalLinkage,
0, MangledName, 0,
- false, Ty->getAddressSpace());
+ false, AddrSpace);
// Handle things which are present even on external declarations.
if (D) {
@@ -1202,7 +1203,10 @@
GV->setThreadLocal(D->isThreadSpecified());
}
- return GV;
+ if (AddrSpace != Ty->getAddressSpace())
+ return llvm::ConstantExpr::getBitCast(GV, Ty);
+ else
+ return GV;
}
@@ -1487,6 +1491,20 @@
return llvmInit;
}
+unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D,
+ unsigned AddrSpace) {
+ if (LangOpts.CUDA && CodeGenOpts.CUDAIsDevice) {
+ if (D->hasAttr<CUDAConstantAttr>())
+ AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant);
+ else if (D->hasAttr<CUDASharedAttr>())
+ AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_shared);
+ else
+ AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_device);
+ }
+
+ return AddrSpace;
+}
+
void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
llvm::Constant *Init = 0;
QualType ASTTy = D->getType();
@@ -1566,7 +1584,7 @@
if (GV == 0 ||
GV->getType()->getElementType() != InitType ||
GV->getType()->getAddressSpace() !=
- getContext().getTargetAddressSpace(ASTTy)) {
+ GetGlobalVarAddressSpace(D, getContext().getTargetAddressSpace(ASTTy))) {
// Move the old entry aside so that we'll create a new one.
Entry->setName(StringRef());
Modified: cfe/branches/tooling/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenModule.h?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenModule.h Mon May 21 03:15:06 2012
@@ -517,6 +517,12 @@
CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty,
llvm::GlobalValue::LinkageTypes Linkage);
+ /// GetGlobalVarAddressSpace - Return the address space of the underlying
+ /// global variable for D, as determined by its declaration. Normally this
+ /// is the same as the address space of D's type, but in CUDA, address spaces
+ /// are associated with declarations, not types.
+ unsigned GetGlobalVarAddressSpace(const VarDecl *D, unsigned AddrSpace);
+
/// GetAddrOfGlobalVar - Return the llvm::Constant for the address of the
/// given global variable. If Ty is non-null and if the global doesn't exist,
/// then it will be greated with the specified type instead of whatever the
Modified: cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/TargetInfo.cpp Mon May 21 03:15:06 2012
@@ -3706,6 +3706,8 @@
case llvm::Triple::ptx32:
case llvm::Triple::ptx64:
+ case llvm::Triple::nvptx:
+ case llvm::Triple::nvptx64:
return *(TheTargetCodeGenInfo = new PTXTargetCodeGenInfo(Types));
case llvm::Triple::mblaze:
Modified: cfe/branches/tooling/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Driver.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Driver.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Driver.cpp Mon May 21 03:15:06 2012
@@ -1635,7 +1635,7 @@
llvm::sys::Path P(TmpDir);
P.appendComponent(Prefix);
if (P.makeUnique(false, &Error)) {
- Diag(clang::diag::err_drv_unable_to_make_temp) << Error;
+ Diag(clang::diag::err_unable_to_make_temp) << Error;
return "";
}
Modified: cfe/branches/tooling/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Tools.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Tools.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Tools.cpp Mon May 21 03:15:06 2012
@@ -755,6 +755,9 @@
if (A->getOption().matches(options::OPT_mno_global_merge))
CmdArgs.push_back("-mno-global-merge");
}
+
+ if (Args.hasArg(options::OPT_mno_implicit_float))
+ CmdArgs.push_back("-no-implicit-float");
}
// Get default architecture.
@@ -1304,6 +1307,27 @@
}
}
+/// If ThreadSanitizer is enabled, add appropriate linker flags (Linux).
+/// This needs to be called before we add the C run-time (malloc, etc).
+static void addTsanRTLinux(const ToolChain &TC, const ArgList &Args,
+ ArgStringList &CmdArgs) {
+ if (!Args.hasFlag(options::OPT_fthread_sanitizer,
+ options::OPT_fno_thread_sanitizer, false))
+ return;
+ if (!Args.hasArg(options::OPT_shared)) {
+ // LibTsan is "libclang_rt.tsan-<ArchName>.a" in the Linux library
+ // resource directory.
+ SmallString<128> LibTsan(TC.getDriver().ResourceDir);
+ llvm::sys::path::append(LibTsan, "lib", "linux",
+ (Twine("libclang_rt.tsan-") +
+ TC.getArchName() + ".a"));
+ CmdArgs.push_back(Args.MakeArgString(LibTsan));
+ CmdArgs.push_back("-lpthread");
+ CmdArgs.push_back("-ldl");
+ CmdArgs.push_back("-export-dynamic");
+ }
+}
+
static bool shouldUseFramePointer(const ArgList &Args,
const llvm::Triple &Triple) {
if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
@@ -4108,7 +4132,6 @@
Args.AddAllArgs(CmdArgs, options::OPT_t);
Args.AddAllArgs(CmdArgs, options::OPT_Z_Flag);
Args.AddAllArgs(CmdArgs, options::OPT_u_Group);
- Args.AddAllArgs(CmdArgs, options::OPT_A);
Args.AddLastArg(CmdArgs, options::OPT_e);
Args.AddAllArgs(CmdArgs, options::OPT_m_Separate);
Args.AddAllArgs(CmdArgs, options::OPT_r);
@@ -4122,8 +4145,7 @@
CmdArgs.push_back("-o");
CmdArgs.push_back(Output.getFilename());
- if (!Args.hasArg(options::OPT_A) &&
- !Args.hasArg(options::OPT_nostdlib) &&
+ if (!Args.hasArg(options::OPT_nostdlib) &&
!Args.hasArg(options::OPT_nostartfiles)) {
// Derived from startfile spec.
if (Args.hasArg(options::OPT_dynamiclib)) {
@@ -4224,7 +4246,11 @@
// This is more complicated in gcc...
CmdArgs.push_back("-lgomp");
- if (isObjCRuntimeLinked(Args)) {
+ AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+
+ if (isObjCRuntimeLinked(Args) &&
+ !Args.hasArg(options::OPT_nostdlib) &&
+ !Args.hasArg(options::OPT_nodefaultlibs)) {
// Avoid linking compatibility stubs on i386 mac.
if (!getDarwinToolChain().isTargetMacOS() ||
getDarwinToolChain().getArchName() != "i386") {
@@ -4244,8 +4270,6 @@
CmdArgs.push_back("-lobjc");
}
- AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
-
if (LinkingOutput) {
CmdArgs.push_back("-arch_multiple");
CmdArgs.push_back("-final_output");
@@ -4266,8 +4290,7 @@
getDarwinToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs);
}
- if (!Args.hasArg(options::OPT_A) &&
- !Args.hasArg(options::OPT_nostdlib) &&
+ if (!Args.hasArg(options::OPT_nostdlib) &&
!Args.hasArg(options::OPT_nostartfiles)) {
// endfile_spec is empty.
}
@@ -5328,6 +5351,7 @@
// Call this before we add the C run-time.
addAsanRTLinux(getToolChain(), Args, CmdArgs);
+ addTsanRTLinux(getToolChain(), Args, CmdArgs);
if (!Args.hasArg(options::OPT_nostdlib)) {
if (!Args.hasArg(options::OPT_nodefaultlibs)) {
Modified: cfe/branches/tooling/lib/Driver/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Types.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Types.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Types.cpp Mon May 21 03:15:06 2012
@@ -129,6 +129,7 @@
case TY_ObjCXX: case TY_PP_ObjCXX:
case TY_CXXHeader: case TY_PP_CXXHeader:
case TY_ObjCXXHeader: case TY_PP_ObjCXXHeader:
+ case TY_CUDA:
return true;
}
}
Modified: cfe/branches/tooling/lib/Edit/RewriteObjCFoundationAPI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Edit/RewriteObjCFoundationAPI.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Edit/RewriteObjCFoundationAPI.cpp (original)
+++ cfe/branches/tooling/lib/Edit/RewriteObjCFoundationAPI.cpp Mon May 21 03:15:06 2012
@@ -209,6 +209,10 @@
const NSAPI &NS, Commit &commit);
static bool rewriteToNumberLiteral(const ObjCMessageExpr *Msg,
const NSAPI &NS, Commit &commit);
+static bool rewriteToNumericBoxedExpression(const ObjCMessageExpr *Msg,
+ const NSAPI &NS, Commit &commit);
+static bool rewriteToStringBoxedExpression(const ObjCMessageExpr *Msg,
+ const NSAPI &NS, Commit &commit);
bool edit::rewriteToObjCLiteralSyntax(const ObjCMessageExpr *Msg,
const NSAPI &NS, Commit &commit) {
@@ -222,6 +226,8 @@
return rewriteToDictionaryLiteral(Msg, NS, commit);
if (II == NS.getNSClassId(NSAPI::ClassId_NSNumber))
return rewriteToNumberLiteral(Msg, NS, commit);
+ if (II == NS.getNSClassId(NSAPI::ClassId_NSString))
+ return rewriteToStringBoxedExpression(Msg, NS, commit);
return false;
}
@@ -372,7 +378,7 @@
return true;
}
- return false;
+ return rewriteToNumericBoxedExpression(Msg, NS, commit);
}
static bool rewriteToBoolLiteral(const ObjCMessageExpr *Msg,
@@ -386,7 +392,7 @@
return true;
}
- return false;
+ return rewriteToNumericBoxedExpression(Msg, NS, commit);
}
namespace {
@@ -488,10 +494,10 @@
literalE = UOE->getSubExpr();
}
- // Only integer and floating literals; non-literals or imaginary literal
- // cannot be rewritten.
+ // Only integer and floating literals, otherwise try to rewrite to boxed
+ // expression.
if (!isa<IntegerLiteral>(literalE) && !isa<FloatingLiteral>(literalE))
- return false;
+ return rewriteToNumericBoxedExpression(Msg, NS, commit);
ASTContext &Ctx = NS.getASTContext();
Selector Sel = Msg->getSelector();
@@ -511,7 +517,7 @@
case NSAPI::NSNumberWithShort:
case NSAPI::NSNumberWithUnsignedShort:
case NSAPI::NSNumberWithBool:
- return false;
+ return rewriteToNumericBoxedExpression(Msg, NS, commit);
case NSAPI::NSNumberWithUnsignedInt:
case NSAPI::NSNumberWithUnsignedInteger:
@@ -551,15 +557,16 @@
}
// We will need to modify the literal suffix to get the same type as the call.
- // Don't even try if it came from a macro.
+ // Try with boxed expression if it came from a macro.
if (ArgRange.getBegin().isMacroID())
- return false;
+ return rewriteToNumericBoxedExpression(Msg, NS, commit);
bool LitIsFloat = ArgTy->isFloatingType();
- // For a float passed to integer call, don't try rewriting. It is difficult
- // and a very uncommon case anyway.
+ // For a float passed to integer call, don't try rewriting to objc literal.
+ // It is difficult and a very uncommon case anyway.
+ // But try with boxed expression.
if (LitIsFloat && !CallIsFloating)
- return false;
+ return rewriteToNumericBoxedExpression(Msg, NS, commit);
// Try to modify the literal make it the same type as the method call.
// -Modify the suffix, and/or
@@ -570,11 +577,11 @@
if (const IntegerLiteral *IntE = dyn_cast<IntegerLiteral>(literalE))
isIntZero = !IntE->getValue().getBoolValue();
if (!getLiteralInfo(ArgRange, LitIsFloat, isIntZero, Ctx, LitInfo))
- return false;
+ return rewriteToNumericBoxedExpression(Msg, NS, commit);
// Not easy to do int -> float with hex/octal and uncommon anyway.
if (!LitIsFloat && CallIsFloating && (LitInfo.Hex || LitInfo.Octal))
- return false;
+ return rewriteToNumericBoxedExpression(Msg, NS, commit);
SourceLocation LitB = LitInfo.WithoutSuffRange.getBegin();
SourceLocation LitE = LitInfo.WithoutSuffRange.getEnd();
@@ -672,3 +679,203 @@
commit.insertWrap("(", Range, ")");
commit.insertBefore(Range.getBegin(), "(id)");
}
+
+//===----------------------------------------------------------------------===//
+// rewriteToNumericBoxedExpression.
+//===----------------------------------------------------------------------===//
+
+static bool isEnumConstant(const Expr *E) {
+ if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts()))
+ if (const ValueDecl *VD = DRE->getDecl())
+ return isa<EnumConstantDecl>(VD);
+
+ return false;
+}
+
+static bool rewriteToNumericBoxedExpression(const ObjCMessageExpr *Msg,
+ const NSAPI &NS, Commit &commit) {
+ if (Msg->getNumArgs() != 1)
+ return false;
+
+ const Expr *Arg = Msg->getArg(0);
+ if (Arg->isTypeDependent())
+ return false;
+
+ ASTContext &Ctx = NS.getASTContext();
+ Selector Sel = Msg->getSelector();
+ llvm::Optional<NSAPI::NSNumberLiteralMethodKind>
+ MKOpt = NS.getNSNumberLiteralMethodKind(Sel);
+ if (!MKOpt)
+ return false;
+ NSAPI::NSNumberLiteralMethodKind MK = *MKOpt;
+
+ const Expr *OrigArg = Arg->IgnoreImpCasts();
+ QualType FinalTy = Arg->getType();
+ QualType OrigTy = OrigArg->getType();
+ uint64_t FinalTySize = Ctx.getTypeSize(FinalTy);
+ uint64_t OrigTySize = Ctx.getTypeSize(OrigTy);
+
+ bool isTruncated = FinalTySize < OrigTySize;
+ bool needsCast = false;
+
+ if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) {
+ switch (ICE->getCastKind()) {
+ case CK_LValueToRValue:
+ case CK_NoOp:
+ case CK_UserDefinedConversion:
+ break;
+
+ case CK_IntegralCast: {
+ if (MK == NSAPI::NSNumberWithBool && OrigTy->isBooleanType())
+ break;
+ // Be more liberal with Integer/UnsignedInteger which are very commonly
+ // used.
+ if ((MK == NSAPI::NSNumberWithInteger ||
+ MK == NSAPI::NSNumberWithUnsignedInteger) &&
+ !isTruncated) {
+ if (OrigTy->getAs<EnumType>() || isEnumConstant(OrigArg))
+ break;
+ if ((MK==NSAPI::NSNumberWithInteger) == OrigTy->isSignedIntegerType() &&
+ OrigTySize >= Ctx.getTypeSize(Ctx.IntTy))
+ break;
+ }
+
+ needsCast = true;
+ break;
+ }
+
+ case CK_PointerToBoolean:
+ case CK_IntegralToBoolean:
+ case CK_IntegralToFloating:
+ case CK_FloatingToIntegral:
+ case CK_FloatingToBoolean:
+ case CK_FloatingCast:
+ case CK_FloatingComplexToReal:
+ case CK_FloatingComplexToBoolean:
+ case CK_IntegralComplexToReal:
+ case CK_IntegralComplexToBoolean:
+ case CK_AtomicToNonAtomic:
+ needsCast = true;
+ break;
+
+ case CK_Dependent:
+ case CK_BitCast:
+ case CK_LValueBitCast:
+ case CK_BaseToDerived:
+ case CK_DerivedToBase:
+ case CK_UncheckedDerivedToBase:
+ case CK_Dynamic:
+ case CK_ToUnion:
+ case CK_ArrayToPointerDecay:
+ case CK_FunctionToPointerDecay:
+ case CK_NullToPointer:
+ case CK_NullToMemberPointer:
+ case CK_BaseToDerivedMemberPointer:
+ case CK_DerivedToBaseMemberPointer:
+ case CK_MemberPointerToBoolean:
+ case CK_ReinterpretMemberPointer:
+ case CK_ConstructorConversion:
+ case CK_IntegralToPointer:
+ case CK_PointerToIntegral:
+ case CK_ToVoid:
+ case CK_VectorSplat:
+ case CK_CPointerToObjCPointerCast:
+ case CK_BlockPointerToObjCPointerCast:
+ case CK_AnyPointerToBlockPointerCast:
+ case CK_ObjCObjectLValueCast:
+ case CK_FloatingRealToComplex:
+ case CK_FloatingComplexCast:
+ case CK_FloatingComplexToIntegralComplex:
+ case CK_IntegralRealToComplex:
+ case CK_IntegralComplexCast:
+ case CK_IntegralComplexToFloatingComplex:
+ case CK_ARCProduceObject:
+ case CK_ARCConsumeObject:
+ case CK_ARCReclaimReturnedObject:
+ case CK_ARCExtendBlockObject:
+ case CK_NonAtomicToAtomic:
+ case CK_CopyAndAutoreleaseBlockObject:
+ return false;
+ }
+ }
+
+ if (needsCast)
+ return false;
+
+ SourceRange ArgRange = OrigArg->getSourceRange();
+ commit.replaceWithInner(Msg->getSourceRange(), ArgRange);
+
+ if (isa<ParenExpr>(OrigArg) || isa<IntegerLiteral>(OrigArg))
+ commit.insertBefore(ArgRange.getBegin(), "@");
+ else
+ commit.insertWrap("@(", ArgRange, ")");
+
+ return true;
+}
+
+//===----------------------------------------------------------------------===//
+// rewriteToStringBoxedExpression.
+//===----------------------------------------------------------------------===//
+
+static bool doRewriteToUTF8StringBoxedExpressionHelper(
+ const ObjCMessageExpr *Msg,
+ const NSAPI &NS, Commit &commit) {
+ const Expr *Arg = Msg->getArg(0);
+ if (Arg->isTypeDependent())
+ return false;
+
+ ASTContext &Ctx = NS.getASTContext();
+
+ const Expr *OrigArg = Arg->IgnoreImpCasts();
+ QualType OrigTy = OrigArg->getType();
+ if (OrigTy->isArrayType())
+ OrigTy = Ctx.getArrayDecayedType(OrigTy);
+
+ if (const StringLiteral *
+ StrE = dyn_cast<StringLiteral>(OrigArg->IgnoreParens())) {
+ commit.replaceWithInner(Msg->getSourceRange(), StrE->getSourceRange());
+ commit.insert(StrE->getLocStart(), "@");
+ return true;
+ }
+
+ if (const PointerType *PT = OrigTy->getAs<PointerType>()) {
+ QualType PointeeType = PT->getPointeeType();
+ if (Ctx.hasSameUnqualifiedType(PointeeType, Ctx.CharTy)) {
+ SourceRange ArgRange = OrigArg->getSourceRange();
+ commit.replaceWithInner(Msg->getSourceRange(), ArgRange);
+
+ if (isa<ParenExpr>(OrigArg) || isa<IntegerLiteral>(OrigArg))
+ commit.insertBefore(ArgRange.getBegin(), "@");
+ else
+ commit.insertWrap("@(", ArgRange, ")");
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static bool rewriteToStringBoxedExpression(const ObjCMessageExpr *Msg,
+ const NSAPI &NS, Commit &commit) {
+ Selector Sel = Msg->getSelector();
+
+ if (Sel == NS.getNSStringSelector(NSAPI::NSStr_stringWithUTF8String) ||
+ Sel == NS.getNSStringSelector(NSAPI::NSStr_stringWithCString)) {
+ if (Msg->getNumArgs() != 1)
+ return false;
+ return doRewriteToUTF8StringBoxedExpressionHelper(Msg, NS, commit);
+ }
+
+ if (Sel == NS.getNSStringSelector(NSAPI::NSStr_stringWithCStringEncoding)) {
+ if (Msg->getNumArgs() != 2)
+ return false;
+
+ const Expr *encodingArg = Msg->getArg(1);
+ if (NS.isNSUTF8StringEncodingConstant(encodingArg) ||
+ NS.isNSASCIIStringEncodingConstant(encodingArg))
+ return doRewriteToUTF8StringBoxedExpressionHelper(Msg, NS, commit);
+ }
+
+ return false;
+}
Modified: cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp Mon May 21 03:15:06 2012
@@ -456,7 +456,7 @@
FileMgr->FixupRelativePath(NewOutFile);
if (llvm::error_code ec = llvm::sys::fs::rename(it->TempFilename,
NewOutFile.str())) {
- getDiagnostics().Report(diag::err_fe_unable_to_rename_temp)
+ getDiagnostics().Report(diag::err_unable_to_rename_temp)
<< it->TempFilename << it->Filename << ec.message();
bool existed;
Modified: cfe/branches/tooling/lib/Frontend/Warnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/Warnings.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/Warnings.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/Warnings.cpp Mon May 21 03:15:06 2012
@@ -83,6 +83,7 @@
bool SetDiagnostic = (Report == 0);
for (unsigned i = 0, e = Opts.Warnings.size(); i != e; ++i) {
StringRef Opt = Opts.Warnings[i];
+ StringRef OrigOpt = Opts.Warnings[i];
// Treat -Wformat=0 as an alias for -Wno-format.
if (Opt == "format=0")
@@ -130,7 +131,7 @@
if ((Opt[5] != '=' && Opt[5] != '-') || Opt.size() == 6) {
if (Report)
Diags.Report(diag::warn_unknown_warning_specifier)
- << "-Werror" << ("-W" + Opt.str());
+ << "-Werror" << ("-W" + OrigOpt.str());
continue;
}
Specifier = Opt.substr(6);
@@ -158,7 +159,7 @@
if ((Opt[12] != '=' && Opt[12] != '-') || Opt.size() == 13) {
if (Report)
Diags.Report(diag::warn_unknown_warning_specifier)
- << "-Wfatal-errors" << ("-W" + Opt.str());
+ << "-Wfatal-errors" << ("-W" + OrigOpt.str());
continue;
}
Specifier = Opt.substr(13);
@@ -182,7 +183,8 @@
if (Report) {
if (DiagIDs->getDiagnosticsInGroup(Opt, _Diags))
- EmitUnknownDiagWarning(Diags, "-W", Opt, isPositive);
+ EmitUnknownDiagWarning(Diags, isPositive ? "-W" : "-Wno-", Opt,
+ isPositive);
} else {
Diags.setDiagnosticGroupMapping(Opt, Mapping);
}
Modified: cfe/branches/tooling/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/Lexer.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/Lexer.cpp (original)
+++ cfe/branches/tooling/lib/Lex/Lexer.cpp Mon May 21 03:15:06 2012
@@ -2286,10 +2286,9 @@
/// ReadToEndOfLine - Read the rest of the current preprocessor line as an
/// uninterpreted string. This switches the lexer out of directive mode.
-std::string Lexer::ReadToEndOfLine() {
+void Lexer::ReadToEndOfLine(SmallVectorImpl<char> *Result) {
assert(ParsingPreprocessorDirective && ParsingFilename == false &&
"Must be in a preprocessing directive!");
- std::string Result;
Token Tmp;
// CurPtr - Cache BufferPtr in an automatic variable.
@@ -2298,7 +2297,8 @@
char Char = getAndAdvanceChar(CurPtr, Tmp);
switch (Char) {
default:
- Result += Char;
+ if (Result)
+ Result->push_back(Char);
break;
case 0: // Null.
// Found end of file?
@@ -2306,11 +2306,12 @@
if (isCodeCompletionPoint(CurPtr-1)) {
PP->CodeCompleteNaturalLanguage();
cutOffLexing();
- return Result;
+ return;
}
// Nope, normal character, continue.
- Result += Char;
+ if (Result)
+ Result->push_back(Char);
break;
}
// FALL THROUGH.
@@ -2329,8 +2330,8 @@
}
assert(Tmp.is(tok::eod) && "Unexpected token!");
- // Finally, we're done, return the string we found.
- return Result;
+ // Finally, we're done;
+ return;
}
}
}
Modified: cfe/branches/tooling/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/PPDirectives.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/PPDirectives.cpp (original)
+++ cfe/branches/tooling/lib/Lex/PPDirectives.cpp Mon May 21 03:15:06 2012
@@ -1018,15 +1018,13 @@
// tokens. For example, this is allowed: "#warning ` 'foo". GCC does
// collapse multiple consequtive white space between tokens, but this isn't
// specified by the standard.
- std::string Message = CurLexer->ReadToEndOfLine();
+ SmallString<128> Message;
+ CurLexer->ReadToEndOfLine(&Message);
// Find the first non-whitespace character, so that we can make the
// diagnostic more succinct.
- StringRef Msg(Message);
- size_t i = Msg.find_first_not_of(' ');
- if (i < Msg.size())
- Msg = Msg.substr(i);
-
+ StringRef Msg = Message.str().ltrim(" ");
+
if (isWarning)
Diag(Tok, diag::pp_hash_warning) << Msg;
else
Modified: cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseCXXInlineMethods.cpp Mon May 21 03:15:06 2012
@@ -459,7 +459,7 @@
Actions.ActOnStartDelayedMemberDeclarations(getCurScope(),
Class.TagOrTemplate);
- {
+ if (!Class.LateParsedDeclarations.empty()) {
// C++11 [expr.prim.general]p4:
// Otherwise, if a member-declarator declares a non-static data member
// (9.2) of a class X, the expression this is a prvalue of type "pointer
Modified: cfe/branches/tooling/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseDecl.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseDecl.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseDecl.cpp Mon May 21 03:15:06 2012
@@ -742,7 +742,7 @@
if (!AlreadyHasClassScope)
Actions.ActOnStartDelayedMemberDeclarations(getCurScope(),
Class.TagOrTemplate);
- {
+ if (!Class.LateParsedDeclarations.empty()) {
// Allow 'this' within late-parsed attributes.
Sema::CXXThisScopeRAII ThisScope(Actions, Class.TagOrTemplate,
/*TypeQuals=*/0);
@@ -1050,6 +1050,7 @@
// C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
// declaration-specifiers init-declarator-list[opt] ';'
if (Tok.is(tok::semi)) {
+ DeclEnd = Tok.getLocation();
if (RequireSemi) ConsumeToken();
Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(getCurScope(), AS_none,
DS);
@@ -1638,12 +1639,13 @@
assert(!DS.hasTypeSpecifier() && "Type specifier checked above");
// Since we know that this either implicit int (which is rare) or an
- // error, do lookahead to try to do better recovery. This never applies within
- // a type specifier.
- // FIXME: Don't bail out here in languages with no implicit int (like
- // C++ with no -fms-extensions). This is much more likely to be an undeclared
- // type or typo than a use of implicit int.
+ // error, do lookahead to try to do better recovery. This never applies
+ // within a type specifier. Outside of C++, we allow this even if the
+ // language doesn't "officially" support implicit int -- we support
+ // implicit int as an extension in C99 and C11. Allegedly, MS also
+ // supports implicit int in C++ mode.
if (DSC != DSC_type_specifier && DSC != DSC_trailing &&
+ (!getLangOpts().CPlusPlus || getLangOpts().MicrosoftExt) &&
isValidAfterIdentifierInDeclarator(NextToken())) {
// If this token is valid for implicit int, e.g. "static x = 4", then
// we just avoid eating the identifier, so it will be parsed as the
@@ -1651,6 +1653,13 @@
return false;
}
+ if (getLangOpts().CPlusPlus &&
+ DS.getStorageClassSpec() == DeclSpec::SCS_auto) {
+ // Don't require a type specifier if we have the 'auto' storage class
+ // specifier in C++98 -- we'll promote it to a type specifier.
+ return false;
+ }
+
// Otherwise, if we don't consume this token, we are going to emit an
// error anyway. Try to recover from various common problems. Check
// to see if this was a reference to a tag name without a tag specified.
@@ -1699,6 +1708,50 @@
}
}
+ // Determine whether this identifier could plausibly be the name of something
+ // being declared (with a missing type).
+ if (DSC != DSC_type_specifier && DSC != DSC_trailing &&
+ (!SS || DSC == DSC_top_level || DSC == DSC_class)) {
+ // Look ahead to the next token to try to figure out what this declaration
+ // was supposed to be.
+ switch (NextToken().getKind()) {
+ case tok::comma:
+ case tok::equal:
+ case tok::kw_asm:
+ case tok::l_brace:
+ case tok::l_square:
+ case tok::semi:
+ // This looks like a variable declaration. The type is probably missing.
+ // We're done parsing decl-specifiers.
+ return false;
+
+ case tok::l_paren: {
+ // static x(4); // 'x' is not a type
+ // x(int n); // 'x' is not a type
+ // x (*p)[]; // 'x' is a type
+ //
+ // Since we're in an error case (or the rare 'implicit int in C++' MS
+ // extension), we can afford to perform a tentative parse to determine
+ // which case we're in.
+ TentativeParsingAction PA(*this);
+ ConsumeToken();
+ TPResult TPR = TryParseDeclarator(/*mayBeAbstract*/false);
+ PA.Revert();
+ if (TPR == TPResult::False())
+ return false;
+ // The identifier is followed by a parenthesized declarator.
+ // It's supposed to be a type.
+ break;
+ }
+
+ default:
+ // This is probably supposed to be a type. This includes cases like:
+ // int f(itn);
+ // struct S { unsinged : 4; };
+ break;
+ }
+ }
+
// This is almost certainly an invalid type name. Let the action emit a
// diagnostic and attempt to recover.
ParsedType T;
@@ -2649,10 +2702,8 @@
// Check for extraneous top-level semicolon.
if (Tok.is(tok::semi)) {
- Diag(Tok, diag::ext_extra_struct_semi)
- << DeclSpec::getSpecifierName((DeclSpec::TST)TagType)
- << FixItHint::CreateRemoval(Tok.getLocation());
- ConsumeToken();
+ ConsumeExtraSemi(InsideStruct,
+ DeclSpec::getSpecifierName((DeclSpec::TST)TagType));
continue;
}
Modified: cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseDeclCXX.cpp Mon May 21 03:15:06 2012
@@ -1929,9 +1929,8 @@
LateParsedAttrs.clear();
// Consume the ';' - it's optional unless we have a delete or default
- if (Tok.is(tok::semi)) {
- ConsumeToken();
- }
+ if (Tok.is(tok::semi))
+ ConsumeExtraSemi(AfterDefinition);
return;
}
@@ -2280,10 +2279,8 @@
// Check for extraneous top-level semicolon.
if (Tok.is(tok::semi)) {
- Diag(Tok, diag::ext_extra_struct_semi)
- << DeclSpec::getSpecifierName((DeclSpec::TST)TagType)
- << FixItHint::CreateRemoval(Tok.getLocation());
- ConsumeToken();
+ ConsumeExtraSemi(InsideStruct,
+ DeclSpec::getSpecifierName((DeclSpec::TST)TagType));
continue;
}
@@ -3007,10 +3004,8 @@
// Check for extraneous top-level semicolon.
if (Tok.is(tok::semi)) {
- Diag(Tok, diag::ext_extra_struct_semi)
- << DeclSpec::getSpecifierName((DeclSpec::TST)TagType)
- << FixItHint::CreateRemoval(Tok.getLocation());
- ConsumeToken();
+ ConsumeExtraSemi(InsideStruct,
+ DeclSpec::getSpecifierName((DeclSpec::TST)TagType));
continue;
}
Modified: cfe/branches/tooling/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseObjc.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseObjc.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseObjc.cpp Mon May 21 03:15:06 2012
@@ -1259,9 +1259,7 @@
// Check for extraneous top-level semicolon.
if (Tok.is(tok::semi)) {
- Diag(Tok, diag::ext_extra_ivar_semi)
- << FixItHint::CreateRemoval(Tok.getLocation());
- ConsumeToken();
+ ConsumeExtraSemi(InstanceVariableList);
continue;
}
@@ -2743,12 +2741,13 @@
return ExprError(Diag(Tok, diag::err_expected_ident));
IdentifierInfo *protocolId = Tok.getIdentifierInfo();
- ConsumeToken();
+ SourceLocation ProtoIdLoc = ConsumeToken();
T.consumeClose();
return Owned(Actions.ParseObjCProtocolExpression(protocolId, AtLoc, ProtoLoc,
T.getOpenLocation(),
+ ProtoIdLoc,
T.getCloseLocation()));
}
Modified: cfe/branches/tooling/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseStmt.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseStmt.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseStmt.cpp Mon May 21 03:15:06 2012
@@ -948,7 +948,7 @@
if (ParseParenExprOrCondition(CondExp, CondVar, IfLoc, true))
return StmtError();
- FullExprArg FullCondExp(Actions.MakeFullExpr(CondExp.get()));
+ FullExprArg FullCondExp(Actions.MakeFullExpr(CondExp.get(), IfLoc));
// C99 6.8.4p3 - In C99, the body of the if statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
@@ -1174,7 +1174,7 @@
if (ParseParenExprOrCondition(Cond, CondVar, WhileLoc, true))
return StmtError();
- FullExprArg FullCond(Actions.MakeFullExpr(Cond.get()));
+ FullExprArg FullCond(Actions.MakeFullExpr(Cond.get(), WhileLoc));
// C99 6.8.5p5 - In C99, the body of the if statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
@@ -1451,7 +1451,7 @@
Second.get());
}
SecondPartIsInvalid = Second.isInvalid();
- SecondPart = Actions.MakeFullExpr(Second.get());
+ SecondPart = Actions.MakeFullExpr(Second.get(), ForLoc);
}
if (Tok.isNot(tok::semi)) {
Modified: cfe/branches/tooling/lib/Parse/ParseTentative.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/ParseTentative.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/ParseTentative.cpp (original)
+++ cfe/branches/tooling/lib/Parse/ParseTentative.cpp Mon May 21 03:15:06 2012
@@ -827,6 +827,10 @@
/// be either a decl-specifier or a function-style cast, and TPResult::Error()
/// if a parsing error was found and reported.
///
+/// If HasMissingTypename is provided, a name with a dependent scope specifier
+/// will be treated as ambiguous if the 'typename' keyword is missing. If this
+/// happens, *HasMissingTypename will be set to 'true'.
+///
/// decl-specifier:
/// storage-class-specifier
/// type-specifier
@@ -918,7 +922,8 @@
/// [GNU] restrict
///
Parser::TPResult
-Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult) {
+Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
+ bool *HasMissingTypename) {
switch (Tok.getKind()) {
case tok::identifier: // foo::bar
// Check for need to substitute AltiVec __vector keyword
@@ -936,7 +941,7 @@
return (!getLangOpts().ObjC1 && Next.is(tok::identifier)) ?
TPResult::True() : TPResult::False();
}
- return isCXXDeclarationSpecifier(BracedCastResult);
+ return isCXXDeclarationSpecifier(BracedCastResult, HasMissingTypename);
case tok::coloncolon: { // ::foo::bar
const Token &Next = NextToken();
@@ -950,7 +955,7 @@
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
return TPResult::Error();
- return isCXXDeclarationSpecifier(BracedCastResult);
+ return isCXXDeclarationSpecifier(BracedCastResult, HasMissingTypename);
// decl-specifier:
// storage-class-specifier
@@ -1052,12 +1057,20 @@
bool isIdentifier = Tok.is(tok::identifier);
TPResult TPR = TPResult::False();
if (!isIdentifier)
- TPR = isCXXDeclarationSpecifier(BracedCastResult);
+ TPR = isCXXDeclarationSpecifier(BracedCastResult,
+ HasMissingTypename);
PA.Revert();
if (isIdentifier ||
TPR == TPResult::True() || TPR == TPResult::Error())
return TPResult::Error();
+
+ if (HasMissingTypename) {
+ // We can't tell whether this is a missing 'typename' or a valid
+ // expression.
+ *HasMissingTypename = true;
+ return TPResult::Ambiguous();
+ }
}
}
return TPResult::False();
@@ -1221,21 +1234,24 @@
return TPResult::Error();
}
-Parser::TPResult Parser::TryParseDeclarationSpecifier() {
- TPResult TPR = isCXXDeclarationSpecifier();
+Parser::TPResult
+Parser::TryParseDeclarationSpecifier(bool *HasMissingTypename) {
+ TPResult TPR = isCXXDeclarationSpecifier(TPResult::False(),
+ HasMissingTypename);
if (TPR != TPResult::Ambiguous())
return TPR;
if (Tok.is(tok::kw_typeof))
TryParseTypeofSpecifier();
else {
+ if (Tok.is(tok::annot_cxxscope))
+ ConsumeToken();
ConsumeToken();
if (getLangOpts().ObjC1 && Tok.is(tok::less))
TryParseProtocolQualifiers();
}
- assert(Tok.is(tok::l_paren) && "Expected '('!");
return TPResult::Ambiguous();
}
@@ -1263,9 +1279,28 @@
TentativeParsingAction PA(*this);
ConsumeParen();
- TPResult TPR = TryParseParameterDeclarationClause();
- if (TPR == TPResult::Ambiguous() && Tok.isNot(tok::r_paren))
- TPR = TPResult::False();
+ bool InvalidAsDeclaration = false;
+ TPResult TPR = TryParseParameterDeclarationClause(&InvalidAsDeclaration);
+ if (TPR == TPResult::Ambiguous()) {
+ if (Tok.isNot(tok::r_paren))
+ TPR = TPResult::False();
+ else {
+ const Token &Next = NextToken();
+ if (Next.is(tok::amp) || Next.is(tok::ampamp) ||
+ Next.is(tok::kw_const) || Next.is(tok::kw_volatile) ||
+ Next.is(tok::kw_throw) || Next.is(tok::kw_noexcept) ||
+ Next.is(tok::l_square) || isCXX0XVirtSpecifier(Next) ||
+ Next.is(tok::l_brace) || Next.is(tok::kw_try) ||
+ Next.is(tok::equal))
+ // The next token cannot appear after a constructor-style initializer,
+ // and can appear next in a function definition. This must be a function
+ // declarator.
+ TPR = TPResult::True();
+ else if (InvalidAsDeclaration)
+ // Use the absence of 'typename' as a tie-breaker.
+ TPR = TPResult::False();
+ }
+ }
SourceLocation TPLoc = Tok.getLocation();
PA.Revert();
@@ -1303,7 +1338,8 @@
/// attribute-specifier-seq[opt] decl-specifier-seq abstract-declarator[opt]
/// attributes[opt] '=' assignment-expression
///
-Parser::TPResult Parser::TryParseParameterDeclarationClause() {
+Parser::TPResult
+Parser::TryParseParameterDeclarationClause(bool *InvalidAsDeclaration) {
if (Tok.is(tok::r_paren))
return TPResult::True();
@@ -1336,7 +1372,7 @@
// decl-specifier-seq
// A parameter-declaration's initializer must be preceded by an '=', so
// decl-specifier-seq '{' is not a parameter in C++11.
- TPResult TPR = TryParseDeclarationSpecifier();
+ TPResult TPR = TryParseDeclarationSpecifier(InvalidAsDeclaration);
if (TPR != TPResult::Ambiguous())
return TPR;
Modified: cfe/branches/tooling/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Parse/Parser.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Parse/Parser.cpp (original)
+++ cfe/branches/tooling/lib/Parse/Parser.cpp Mon May 21 03:15:06 2012
@@ -202,6 +202,33 @@
return ExpectAndConsume(tok::semi, DiagID);
}
+void Parser::ConsumeExtraSemi(ExtraSemiKind Kind, const char* DiagMsg) {
+ if (!Tok.is(tok::semi)) return;
+
+ // AfterDefinition should only warn when placed on the same line as the
+ // definition. Otherwise, defer to another semi warning.
+ if (Kind == AfterDefinition && Tok.isAtStartOfLine()) return;
+
+ SourceLocation StartLoc = Tok.getLocation();
+ SourceLocation EndLoc = Tok.getLocation();
+ ConsumeToken();
+
+ while ((Tok.is(tok::semi) && !Tok.isAtStartOfLine())) {
+ EndLoc = Tok.getLocation();
+ ConsumeToken();
+ }
+
+ if (Kind == OutsideFunction && getLangOpts().CPlusPlus0x) {
+ Diag(StartLoc, diag::warn_cxx98_compat_top_level_semi)
+ << FixItHint::CreateRemoval(SourceRange(StartLoc, EndLoc));
+ return;
+ }
+
+ Diag(StartLoc, diag::ext_extra_semi)
+ << Kind << DiagMsg << FixItHint::CreateRemoval(SourceRange(StartLoc,
+ EndLoc));
+}
+
//===----------------------------------------------------------------------===//
// Error recovery.
//===----------------------------------------------------------------------===//
@@ -582,11 +609,7 @@
HandlePragmaPack();
return DeclGroupPtrTy();
case tok::semi:
- Diag(Tok, getLangOpts().CPlusPlus0x ?
- diag::warn_cxx98_compat_top_level_semi : diag::ext_top_level_semi)
- << FixItHint::CreateRemoval(Tok.getLocation());
-
- ConsumeToken();
+ ConsumeExtraSemi(OutsideFunction);
// TODO: Invoke action for top-level semicolon.
return DeclGroupPtrTy();
case tok::r_brace:
Modified: cfe/branches/tooling/lib/Sema/CodeCompleteConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/CodeCompleteConsumer.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/branches/tooling/lib/Sema/CodeCompleteConsumer.cpp Mon May 21 03:15:06 2012
@@ -573,14 +573,8 @@
}
case RK_Macro:
- Availability = CXAvailability_Available;
- CursorKind = CXCursor_MacroDefinition;
- break;
-
case RK_Keyword:
- Availability = CXAvailability_Available;
- CursorKind = CXCursor_NotImplemented;
- break;
+ llvm_unreachable("Macro and keyword kinds are handled by the constructors");
}
if (!Accessible)
Modified: cfe/branches/tooling/lib/Sema/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/DeclSpec.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/DeclSpec.cpp (original)
+++ cfe/branches/tooling/lib/Sema/DeclSpec.cpp Mon May 21 03:15:06 2012
@@ -935,13 +935,6 @@
StorageClassSpec != DeclSpec::SCS_typedef;
}
-void UnqualifiedId::clear() {
- Kind = IK_Identifier;
- Identifier = 0;
- StartLocation = SourceLocation();
- EndLocation = SourceLocation();
-}
-
void UnqualifiedId::setOperatorFunctionId(SourceLocation OperatorLoc,
OverloadedOperatorKind Op,
SourceLocation SymbolLocations[3]) {
Modified: cfe/branches/tooling/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaChecking.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaChecking.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaChecking.cpp Mon May 21 03:15:06 2012
@@ -2423,8 +2423,8 @@
S.PDiag(diag::warn_printf_conversion_argument_type_mismatch)
<< ATR.getRepresentativeTypeName(S.Context) << Ex->getType()
<< Ex->getSourceRange(),
- getLocationOfByte(CS.getStart()),
- /*IsStringLocation*/true,
+ Ex->getLocStart(),
+ /*IsStringLocation*/false,
getSpecifierRange(startSpecifier, specifierLen),
FixItHint::CreateReplacement(
getSpecifierRange(startSpecifier, specifierLen),
@@ -2436,8 +2436,8 @@
<< ATR.getRepresentativeTypeName(S.Context) << Ex->getType()
<< getSpecifierRange(startSpecifier, specifierLen)
<< Ex->getSourceRange(),
- getLocationOfByte(CS.getStart()),
- true,
+ Ex->getLocStart(),
+ /*IsStringLocation*/false,
getSpecifierRange(startSpecifier, specifierLen));
}
}
@@ -2591,8 +2591,8 @@
S.PDiag(diag::warn_printf_conversion_argument_type_mismatch)
<< ATR.getRepresentativeTypeName(S.Context) << Ex->getType()
<< Ex->getSourceRange(),
- getLocationOfByte(CS.getStart()),
- /*IsStringLocation*/true,
+ Ex->getLocStart(),
+ /*IsStringLocation*/false,
getSpecifierRange(startSpecifier, specifierLen),
FixItHint::CreateReplacement(
getSpecifierRange(startSpecifier, specifierLen),
@@ -2602,8 +2602,8 @@
S.PDiag(diag::warn_printf_conversion_argument_type_mismatch)
<< ATR.getRepresentativeTypeName(S.Context) << Ex->getType()
<< Ex->getSourceRange(),
- getLocationOfByte(CS.getStart()),
- /*IsStringLocation*/true,
+ Ex->getLocStart(),
+ /*IsStringLocation*/false,
getSpecifierRange(startSpecifier, specifierLen));
}
}
@@ -4250,9 +4250,10 @@
SourceLocation Loc = E->getSourceRange().getBegin();
if (Loc.isMacroID())
Loc = S.SourceMgr.getImmediateExpansionRange(Loc).first;
- S.Diag(Loc, diag::warn_impcast_null_pointer_to_integer)
- << T << clang::SourceRange(CC)
- << FixItHint::CreateReplacement(Loc, S.getFixItZeroLiteralForType(T));
+ if (!Loc.isMacroID() || CC.isMacroID())
+ S.Diag(Loc, diag::warn_impcast_null_pointer_to_integer)
+ << T << clang::SourceRange(CC)
+ << FixItHint::CreateReplacement(Loc, S.getFixItZeroLiteralForType(T));
return;
}
@@ -4345,14 +4346,15 @@
return;
}
-void CheckConditionalOperator(Sema &S, ConditionalOperator *E, QualType T);
+void CheckConditionalOperator(Sema &S, ConditionalOperator *E,
+ SourceLocation CC, QualType T);
void CheckConditionalOperand(Sema &S, Expr *E, QualType T,
SourceLocation CC, bool &ICContext) {
E = E->IgnoreParenImpCasts();
if (isa<ConditionalOperator>(E))
- return CheckConditionalOperator(S, cast<ConditionalOperator>(E), T);
+ return CheckConditionalOperator(S, cast<ConditionalOperator>(E), CC, T);
AnalyzeImplicitConversions(S, E, CC);
if (E->getType() != T)
@@ -4360,9 +4362,8 @@
return;
}
-void CheckConditionalOperator(Sema &S, ConditionalOperator *E, QualType T) {
- SourceLocation CC = E->getQuestionLoc();
-
+void CheckConditionalOperator(Sema &S, ConditionalOperator *E,
+ SourceLocation CC, QualType T) {
AnalyzeImplicitConversions(S, E->getCond(), CC);
bool Suspicious = false;
@@ -4404,7 +4405,7 @@
// were being fed directly into the output.
if (isa<ConditionalOperator>(E)) {
ConditionalOperator *CO = cast<ConditionalOperator>(E);
- CheckConditionalOperator(S, CO, T);
+ CheckConditionalOperator(S, CO, CC, T);
return;
}
Modified: cfe/branches/tooling/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDecl.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDecl.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDecl.cpp Mon May 21 03:15:06 2012
@@ -1698,9 +1698,30 @@
return false;
}
+static const Decl *getDefinition(Decl *D) {
+ if (TagDecl *TD = dyn_cast<TagDecl>(D))
+ return TD->getDefinition();
+ if (VarDecl *VD = dyn_cast<VarDecl>(D))
+ return VD->getDefinition();
+ if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+ const FunctionDecl* Def;
+ if (FD->hasBody(Def))
+ return Def;
+ }
+ return NULL;
+}
+
/// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
void Sema::mergeDeclAttributes(Decl *New, Decl *Old,
bool MergeDeprecation) {
+ // attributes declared post-definition are currently ignored
+ const Decl *Def = getDefinition(Old);
+ if (Def && Def != New && New->hasAttrs()) {
+ Diag(New->getLocation(), diag::warn_attribute_precede_definition);
+ Diag(Def->getLocation(), diag::note_previous_definition);
+ New->dropAttrs();
+ }
+
if (!Old->hasAttrs())
return;
@@ -2227,10 +2248,11 @@
mergeDeclAttributes(newMethod, oldMethod, mergeDeprecation);
// Merge attributes from the parameters.
- ObjCMethodDecl::param_const_iterator oi = oldMethod->param_begin();
+ ObjCMethodDecl::param_const_iterator oi = oldMethod->param_begin(),
+ oe = oldMethod->param_end();
for (ObjCMethodDecl::param_iterator
ni = newMethod->param_begin(), ne = newMethod->param_end();
- ni != ne; ++ni, ++oi)
+ ni != ne && oi != oe; ++ni, ++oi)
mergeParamDeclAttributes(*ni, *oi, Context);
CheckObjCMethodOverride(newMethod, oldMethod, true);
@@ -4250,18 +4272,6 @@
CheckMemberSpecialization(NewVD, Previous))
NewVD->setInvalidDecl();
}
-
- // attributes declared post-definition are currently ignored
- // FIXME: This should be handled in attribute merging, not
- // here.
- if (Previous.isSingleResult()) {
- VarDecl *Def = dyn_cast<VarDecl>(Previous.getFoundDecl());
- if (Def && (Def = Def->getDefinition()) &&
- Def != NewVD && D.hasAttributes()) {
- Diag(NewVD->getLocation(), diag::warn_attribute_precede_definition);
- Diag(Def->getLocation(), diag::note_previous_definition);
- }
- }
// If this is a locally-scoped extern C variable, update the map of
// such variables.
@@ -5664,17 +5674,6 @@
}
}
- // attributes declared post-definition are currently ignored
- // FIXME: This should happen during attribute merging
- if (D.isRedeclaration() && Previous.isSingleResult()) {
- const FunctionDecl *Def;
- FunctionDecl *PrevFD = dyn_cast<FunctionDecl>(Previous.getFoundDecl());
- if (PrevFD && PrevFD->isDefined(Def) && D.hasAttributes()) {
- Diag(NewFD->getLocation(), diag::warn_attribute_precede_definition);
- Diag(Def->getLocation(), diag::note_previous_definition);
- }
- }
-
AddKnownFunctionAttributes(NewFD);
if (NewFD->hasAttr<OverloadableAttr>() &&
Modified: cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp Mon May 21 03:15:06 2012
@@ -1642,47 +1642,28 @@
priority));
}
-static void handleDeprecatedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+template <typename AttrTy>
+static void handleAttrWithMessage(Sema &S, Decl *D, const AttributeList &Attr,
+ const char *Name) {
unsigned NumArgs = Attr.getNumArgs();
if (NumArgs > 1) {
S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments) << 1;
return;
}
-
- // Handle the case where deprecated attribute has a text message.
+
+ // Handle the case where the attribute has a text message.
StringRef Str;
if (NumArgs == 1) {
StringLiteral *SE = dyn_cast<StringLiteral>(Attr.getArg(0));
if (!SE) {
S.Diag(Attr.getArg(0)->getLocStart(), diag::err_attribute_not_string)
- << "deprecated";
+ << Name;
return;
}
Str = SE->getString();
}
- D->addAttr(::new (S.Context) DeprecatedAttr(Attr.getRange(), S.Context, Str));
-}
-
-static void handleUnavailableAttr(Sema &S, Decl *D, const AttributeList &Attr) {
- unsigned NumArgs = Attr.getNumArgs();
- if (NumArgs > 1) {
- S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments) << 1;
- return;
- }
-
- // Handle the case where unavailable attribute has a text message.
- StringRef Str;
- if (NumArgs == 1) {
- StringLiteral *SE = dyn_cast<StringLiteral>(Attr.getArg(0));
- if (!SE) {
- S.Diag(Attr.getArg(0)->getLocStart(),
- diag::err_attribute_not_string) << "unavailable";
- return;
- }
- Str = SE->getString();
- }
- D->addAttr(::new (S.Context) UnavailableAttr(Attr.getRange(), S.Context, Str));
+ D->addAttr(::new (S.Context) AttrTy(Attr.getRange(), S.Context, Str));
}
static void handleArcWeakrefUnavailableAttr(Sema &S, Decl *D,
@@ -2508,26 +2489,19 @@
/// getFormatAttrKind - Map from format attribute names to supported format
/// types.
static FormatAttrKind getFormatAttrKind(StringRef Format) {
- // Check for formats that get handled specially.
- if (Format == "NSString")
- return NSStringFormat;
- if (Format == "CFString")
- return CFStringFormat;
- if (Format == "strftime")
- return StrftimeFormat;
-
- // Otherwise, check for supported formats.
- if (Format == "scanf" || Format == "printf" || Format == "printf0" ||
- Format == "strfmon" || Format == "cmn_err" || Format == "vcmn_err" ||
- Format == "zcmn_err" ||
- Format == "kprintf") // OpenBSD.
- return SupportedFormat;
-
- if (Format == "gcc_diag" || Format == "gcc_cdiag" ||
- Format == "gcc_cxxdiag" || Format == "gcc_tdiag")
- return IgnoredFormat;
-
- return InvalidFormat;
+ return llvm::StringSwitch<FormatAttrKind>(Format)
+ // Check for formats that get handled specially.
+ .Case("NSString", NSStringFormat)
+ .Case("CFString", CFStringFormat)
+ .Case("strftime", StrftimeFormat)
+
+ // Otherwise, check for supported formats.
+ .Cases("scanf", "printf", "printf0", "strfmon", SupportedFormat)
+ .Cases("cmn_err", "vcmn_err", "zcmn_err", SupportedFormat)
+ .Case("kprintf", SupportedFormat) // OpenBSD.
+
+ .Cases("gcc_diag", "gcc_cdiag", "gcc_cxxdiag", "gcc_tdiag", IgnoredFormat)
+ .Default(InvalidFormat);
}
/// Handle __attribute__((init_priority(priority))) attributes based on
@@ -3849,7 +3823,9 @@
case AttributeList::AT_common: handleCommonAttr (S, D, Attr); break;
case AttributeList::AT_constant: handleConstantAttr (S, D, Attr); break;
case AttributeList::AT_constructor: handleConstructorAttr (S, D, Attr); break;
- case AttributeList::AT_deprecated: handleDeprecatedAttr (S, D, Attr); break;
+ case AttributeList::AT_deprecated:
+ handleAttrWithMessage<DeprecatedAttr>(S, D, Attr, "deprecated");
+ break;
case AttributeList::AT_destructor: handleDestructorAttr (S, D, Attr); break;
case AttributeList::AT_ext_vector_type:
handleExtVectorTypeAttr(S, scope, D, Attr);
@@ -3915,7 +3891,9 @@
case AttributeList::AT_packed: handlePackedAttr (S, D, Attr); break;
case AttributeList::AT_ms_struct: handleMsStructAttr (S, D, Attr); break;
case AttributeList::AT_section: handleSectionAttr (S, D, Attr); break;
- case AttributeList::AT_unavailable: handleUnavailableAttr (S, D, Attr); break;
+ case AttributeList::AT_unavailable:
+ handleAttrWithMessage<UnavailableAttr>(S, D, Attr, "unavailable");
+ break;
case AttributeList::AT_objc_arc_weak_reference_unavailable:
handleArcWeakrefUnavailableAttr (S, D, Attr);
break;
Modified: cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp Mon May 21 03:15:06 2012
@@ -1506,12 +1506,12 @@
CXXScopeSpec &SS = D.getCXXScopeSpec();
// Data members must have identifiers for names.
- if (Name.getNameKind() != DeclarationName::Identifier) {
+ if (!Name.isIdentifier()) {
Diag(Loc, diag::err_bad_variable_name)
<< Name;
return 0;
}
-
+
IdentifierInfo *II = Name.getAsIdentifierInfo();
// Member field could not be with "template" keyword.
@@ -2234,6 +2234,16 @@
if (DelegationInit.isInvalid())
return true;
+ // If we are in a dependent context, template instantiation will
+ // perform this type-checking again. Just save the arguments that we
+ // received in a ParenListExpr.
+ // FIXME: This isn't quite ideal, since our ASTs don't capture all
+ // of the information that we have about the base
+ // initializer. However, deconstructing the ASTs is a dicey process,
+ // and this approach is far more likely to get the corner cases right.
+ if (CurContext->isDependentContext())
+ DelegationInit = Owned(Init);
+
return new (Context) CXXCtorInitializer(Context, TInfo, InitRange.getBegin(),
DelegationInit.takeAs<Expr>(),
InitRange.getEnd());
@@ -4469,7 +4479,7 @@
if (Diags.getDiagnosticLevel(diag::warn_overloaded_virtual,
MD->getLocation()) == DiagnosticsEngine::Ignored)
return;
- if (MD->getDeclName().getNameKind() != DeclarationName::Identifier)
+ if (!MD->getDeclName().isIdentifier())
return;
CXXBasePaths Paths(/*FindAmbiguities=*/true, // true to look in all bases.
Modified: cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp Mon May 21 03:15:06 2012
@@ -173,10 +173,11 @@
Diag(Overridden->getLocation(), diag::note_previous_decl)
<< "method";
}
- ObjCMethodDecl::param_const_iterator oi = Overridden->param_begin();
+ ObjCMethodDecl::param_const_iterator oi = Overridden->param_begin(),
+ oe = Overridden->param_end();
for (ObjCMethodDecl::param_iterator
ni = NewMethod->param_begin(), ne = NewMethod->param_end();
- ni != ne; ++ni, ++oi) {
+ ni != ne && oi != oe; ++ni, ++oi) {
const ParmVarDecl *oldDecl = (*oi);
ParmVarDecl *newDecl = (*ni);
if (newDecl->hasAttr<NSConsumedAttr>() !=
@@ -1399,8 +1400,9 @@
true);
for (ObjCMethodDecl::param_iterator IM = ImpMethodDecl->param_begin(),
- IF = MethodDecl->param_begin(), EM = ImpMethodDecl->param_end();
- IM != EM; ++IM, ++IF) {
+ IF = MethodDecl->param_begin(), EM = ImpMethodDecl->param_end(),
+ EF = MethodDecl->param_end();
+ IM != EM && IF != EF; ++IM, ++IF) {
CheckMethodOverrideParam(*this, ImpMethodDecl, MethodDecl, *IM, *IF,
IsProtocolMethodDecl, false, true);
}
@@ -1421,8 +1423,9 @@
true);
for (ObjCMethodDecl::param_iterator IM = Method->param_begin(),
- IF = Overridden->param_begin(), EM = Method->param_end();
- IM != EM; ++IM, ++IF) {
+ IF = Overridden->param_begin(), EM = Method->param_end(),
+ EF = Overridden->param_end();
+ IM != EM && IF != EF; ++IM, ++IF) {
CheckMethodOverrideParam(*this, Method, Overridden, *IM, *IF,
IsProtocolMethodDecl, true, true);
}
@@ -1454,8 +1457,9 @@
IsProtocolMethodDecl, false, false);
if (match)
for (ObjCMethodDecl::param_iterator IM = ImpMethodDecl->param_begin(),
- IF = MethodDecl->param_begin(), EM = ImpMethodDecl->param_end();
- IM != EM; ++IM, ++IF) {
+ IF = MethodDecl->param_begin(), EM = ImpMethodDecl->param_end(),
+ EF = MethodDecl->param_end();
+ IM != EM && IF != EF; ++IM, ++IF) {
match = CheckMethodOverrideParam(*this, ImpMethodDecl, MethodDecl,
*IM, *IF,
IsProtocolMethodDecl, false, false);
@@ -1954,9 +1958,10 @@
return false;
ObjCMethodDecl::param_const_iterator
- li = left->param_begin(), le = left->param_end(), ri = right->param_begin();
+ li = left->param_begin(), le = left->param_end(), ri = right->param_begin(),
+ re = right->param_end();
- for (; li != le; ++li, ++ri) {
+ for (; li != le && ri != re; ++li, ++ri) {
assert(ri != right->param_end() && "Param mismatch");
const ParmVarDecl *lparm = *li, *rparm = *ri;
@@ -2520,7 +2525,8 @@
// interface and each other.
if (ObjCCategoryDecl *Category = dyn_cast<ObjCCategoryDecl>(container)) {
searchFromContainer(container);
- searchFromContainer(Category->getClassInterface());
+ if (ObjCInterfaceDecl *Interface = Category->getClassInterface())
+ searchFromContainer(Interface);
} else {
searchFromContainer(container);
}
@@ -2569,11 +2575,12 @@
// declaration.
if (ObjCCategoryDecl *category = impl->getCategoryDecl()) {
search(category);
- search(category->getClassInterface());
+ if (ObjCInterfaceDecl *Interface = category->getClassInterface())
+ search(Interface);
// Otherwise it overrides declarations from the class.
- } else {
- search(impl->getClassInterface());
+ } else if (ObjCInterfaceDecl *Interface = impl->getClassInterface()) {
+ search(Interface);
}
}
@@ -2598,7 +2605,8 @@
void searchFrom(ObjCImplementationDecl *impl) {
// A method in a class implementation overrides declarations from
// the class interface.
- search(impl->getClassInterface());
+ if (ObjCInterfaceDecl *Interface = impl->getClassInterface())
+ search(Interface);
}
@@ -2670,9 +2678,9 @@
isa<ObjCInterfaceDecl>(overridden->getDeclContext())) {
ObjCMethodDecl::param_iterator ParamI = ObjCMethod->param_begin(),
E = ObjCMethod->param_end();
- ObjCMethodDecl::param_iterator PrevI = overridden->param_begin();
- for (; ParamI != E; ++ParamI, ++PrevI) {
- // Number of parameters are the same and is guaranteed by selector match.
+ ObjCMethodDecl::param_iterator PrevI = overridden->param_begin(),
+ PrevE = overridden->param_end();
+ for (; ParamI != E && PrevI != PrevE; ++ParamI, ++PrevI) {
assert(PrevI != overridden->param_end() && "Param mismatch");
QualType T1 = Context.getCanonicalType((*ParamI)->getType());
QualType T2 = Context.getCanonicalType((*PrevI)->getType());
Modified: cfe/branches/tooling/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExpr.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExpr.cpp Mon May 21 03:15:06 2012
@@ -3314,7 +3314,7 @@
return ExprError();
Expr *Arg = Result.takeAs<Expr>();
- CheckImplicitConversions(Arg, Arg->getExprLoc());
+ CheckImplicitConversions(Arg, Param->getOuterLocStart());
// Build the default argument expression.
return Owned(CXXDefaultArgExpr::Create(Context, CallLoc, Param, Arg));
}
@@ -10040,7 +10040,8 @@
static ExprResult captureInLambda(Sema &S, LambdaScopeInfo *LSI,
VarDecl *Var, QualType FieldType,
QualType DeclRefType,
- SourceLocation Loc) {
+ SourceLocation Loc,
+ bool RefersToEnclosingLocal) {
CXXRecordDecl *Lambda = LSI->Lambda;
// Build the non-static data member.
@@ -10069,8 +10070,8 @@
// C++ [expr.prim.labda]p12:
// An entity captured by a lambda-expression is odr-used (3.2) in
// the scope containing the lambda-expression.
- Expr *Ref = new (S.Context) DeclRefExpr(Var, false, DeclRefType,
- VK_LValue, Loc);
+ Expr *Ref = new (S.Context) DeclRefExpr(Var, RefersToEnclosingLocal,
+ DeclRefType, VK_LValue, Loc);
Var->setReferenced(true);
Var->setUsed(true);
@@ -10413,7 +10414,8 @@
Expr *CopyExpr = 0;
if (BuildAndDiagnose) {
ExprResult Result = captureInLambda(*this, LSI, Var, CaptureType,
- DeclRefType, Loc);
+ DeclRefType, Loc,
+ I == N-1);
if (!Result.isInvalid())
CopyExpr = Result.take();
}
Modified: cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp Mon May 21 03:15:06 2012
@@ -379,6 +379,10 @@
return ExprError(Diag(OpLoc, diag::err_need_header_before_typeid));
}
+ if (!getLangOpts().RTTI) {
+ return ExprError(Diag(OpLoc, diag::err_no_typeid_with_fno_rtti));
+ }
+
QualType TypeInfoType = Context.getTypeDeclType(CXXTypeInfoDecl);
if (isType) {
@@ -5310,7 +5314,7 @@
return Owned(E);
}
-ExprResult Sema::ActOnFinishFullExpr(Expr *FE) {
+ExprResult Sema::ActOnFinishFullExpr(Expr *FE, SourceLocation CC) {
ExprResult FullExpr = Owned(FE);
if (!FullExpr.get())
@@ -5336,7 +5340,7 @@
if (FullExpr.isInvalid())
return ExprError();
- CheckImplicitConversions(FullExpr.get(), FullExpr.get()->getExprLoc());
+ CheckImplicitConversions(FullExpr.get(), CC);
return MaybeCreateExprWithCleanups(FullExpr);
}
Modified: cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp Mon May 21 03:15:06 2012
@@ -539,6 +539,17 @@
// Look for the appropriate method within NSNumber.
BoxingMethod = getNSNumberFactoryMethod(*this, SR.getBegin(), ValueType);
BoxedType = NSNumberPointer;
+
+ } else if (const EnumType *ET = ValueType->getAs<EnumType>()) {
+ if (!ET->getDecl()->isComplete()) {
+ Diag(SR.getBegin(), diag::err_objc_incomplete_boxed_expression_type)
+ << ValueType << ValueExpr->getSourceRange();
+ return ExprError();
+ }
+
+ BoxingMethod = getNSNumberFactoryMethod(*this, SR.getBegin(),
+ ET->getDecl()->getIntegerType());
+ BoxedType = NSNumberPointer;
}
if (!BoxingMethod) {
@@ -1001,8 +1012,9 @@
SourceLocation AtLoc,
SourceLocation ProtoLoc,
SourceLocation LParenLoc,
+ SourceLocation ProtoIdLoc,
SourceLocation RParenLoc) {
- ObjCProtocolDecl* PDecl = LookupProtocol(ProtocolId, ProtoLoc);
+ ObjCProtocolDecl* PDecl = LookupProtocol(ProtocolId, ProtoIdLoc);
if (!PDecl) {
Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId;
return true;
@@ -1012,7 +1024,7 @@
if (Ty.isNull())
return true;
Ty = Context.getObjCObjectPointerType(Ty);
- return new (Context) ObjCProtocolExpr(Ty, PDecl, AtLoc, RParenLoc);
+ return new (Context) ObjCProtocolExpr(Ty, PDecl, AtLoc, ProtoIdLoc, RParenLoc);
}
/// Try to capture an implicit reference to 'self'.
@@ -1386,14 +1398,15 @@
bool Super) {
const ObjCInterfaceType *IFaceT = OPT->getInterfaceType();
ObjCInterfaceDecl *IFace = IFaceT->getDecl();
-
- if (MemberName.getNameKind() != DeclarationName::Identifier) {
+
+ if (!MemberName.isIdentifier()) {
Diag(MemberLoc, diag::err_invalid_property_name)
<< MemberName << QualType(OPT, 0);
return ExprError();
}
-
+
IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
+
SourceRange BaseRange = Super? SourceRange(SuperLoc)
: BaseExpr->getSourceRange();
if (RequireCompleteType(MemberLoc, OPT->getPointeeType(),
Modified: cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaObjCProperty.cpp Mon May 21 03:15:06 2012
@@ -200,6 +200,53 @@
return (ObjCPropertyDecl::PropertyAttributeKind)attributesAsWritten;
}
+static std::string getPropertyAttributeString(const ObjCPropertyDecl *property,
+ unsigned Attributes) {
+ std::string attr;
+ if (!Attributes)
+ return attr;
+ attr = "(";
+ bool first = true;
+ if (Attributes & ObjCPropertyDecl::OBJC_PR_readonly)
+ {attr += !first ? ", readonly" : "readonly"; first = false; }
+ if (Attributes & ObjCPropertyDecl::OBJC_PR_readwrite)
+ {attr += !first ? ", readwrite" : "readwrite"; first = false; }
+ if (Attributes & ObjCPropertyDecl::OBJC_PR_getter)
+ {
+ if (!first)
+ attr += ", ";
+ attr += "getter=";
+ attr += property->getGetterName().getAsString();
+ first = false;
+ }
+ if (Attributes & ObjCPropertyDecl::OBJC_PR_setter)
+ {
+ if (!first)
+ attr += ", ";
+ attr += "setter=";
+ attr += property->getSetterName().getAsString();
+ first = false;
+ }
+ if (Attributes & ObjCPropertyDecl::OBJC_PR_assign)
+ {attr += !first ? ", assign" : "assign"; first = false; }
+ if (Attributes & ObjCPropertyDecl::OBJC_PR_retain)
+ {attr += !first ? ", retain" : "retain"; first = false; }
+ if (Attributes & ObjCPropertyDecl::OBJC_PR_strong)
+ {attr += !first ? ", strong" : "strong"; first = false; }
+ if (Attributes & ObjCPropertyDecl::OBJC_PR_weak)
+ {attr += !first ? ", weak" : "weak"; first = false; }
+ if (Attributes & ObjCPropertyDecl::OBJC_PR_copy)
+ {attr += !first ? ", copy" : "copy"; first = false; }
+ if (Attributes & ObjCPropertyDecl::OBJC_PR_unsafe_unretained)
+ {attr += !first ? ", unsafe_unretained" : "unsafe_unretained"; first = false; }
+ if (Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic)
+ {attr += !first ? ", nonatomic" : "nonatomic"; first = false; }
+ if (Attributes & ObjCPropertyDecl::OBJC_PR_atomic)
+ {attr += !first ? ", atomic" : "atomic"; first = false; }
+ attr += ")";
+ return attr;
+}
+
Decl *
Sema::HandlePropertyInClassExtension(Scope *S,
SourceLocation AtLoc,
@@ -628,6 +675,26 @@
return 0;
}
}
+
+ if (Synthesize&&
+ (PIkind & ObjCPropertyDecl::OBJC_PR_readonly) &&
+ property->hasAttr<IBOutletAttr>() &&
+ !AtLoc.isValid()) {
+ unsigned rwPIKind = (PIkind | ObjCPropertyDecl::OBJC_PR_readwrite);
+ rwPIKind &= (~ObjCPropertyDecl::OBJC_PR_readonly);
+ Diag(IC->getLocation(), diag::warn_auto_readonly_iboutlet_property);
+ Diag(property->getLocation(), diag::note_property_declare);
+ // FIXME. End location must be that of closing ')' which is currently
+ // unavailable. Need to add it.
+ SourceLocation endLoc =
+ property->getTypeSourceInfo()->getTypeLoc().getBeginLoc();
+ SourceRange PropSourceRange(property->getLParenLoc(), endLoc);
+ Diag(property->getLocation(),
+ diag::note_auto_readonly_iboutlet_fixup_suggest) <<
+ FixItHint::CreateReplacement(PropSourceRange, getPropertyAttributeString(property,
+ rwPIKind));
+ }
+
} else if ((CatImplClass = dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl))) {
if (Synthesize) {
Diag(AtLoc, diag::error_synthesize_category_decl);
@@ -1050,21 +1117,42 @@
bool Sema::DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *property,
ObjCMethodDecl *GetterMethod,
SourceLocation Loc) {
- if (GetterMethod &&
- !Context.hasSameType(GetterMethod->getResultType().getNonReferenceType(),
- property->getType().getNonReferenceType())) {
- AssignConvertType result = Incompatible;
- if (property->getType()->isObjCObjectPointerType())
- result = CheckAssignmentConstraints(Loc, GetterMethod->getResultType(),
- property->getType());
- if (result != Compatible) {
- Diag(Loc, diag::warn_accessor_property_type_mismatch)
- << property->getDeclName()
- << GetterMethod->getSelector();
- Diag(GetterMethod->getLocation(), diag::note_declared_at);
- return true;
+ if (!GetterMethod)
+ return false;
+ QualType GetterType = GetterMethod->getResultType().getNonReferenceType();
+ QualType PropertyIvarType = property->getType().getNonReferenceType();
+ bool compat = Context.hasSameType(PropertyIvarType, GetterType);
+ if (!compat) {
+ if (isa<ObjCObjectPointerType>(PropertyIvarType) &&
+ isa<ObjCObjectPointerType>(GetterType))
+ compat =
+ Context.canAssignObjCInterfaces(
+ PropertyIvarType->getAs<ObjCObjectPointerType>(),
+ GetterType->getAs<ObjCObjectPointerType>());
+ else if (CheckAssignmentConstraints(Loc, PropertyIvarType, GetterType)
+ != Compatible) {
+ Diag(Loc, diag::error_property_accessor_type)
+ << property->getDeclName() << PropertyIvarType
+ << GetterMethod->getSelector() << GetterType;
+ Diag(GetterMethod->getLocation(), diag::note_declared_at);
+ return true;
+ } else {
+ compat = true;
+ QualType lhsType =Context.getCanonicalType(PropertyIvarType).getUnqualifiedType();
+ QualType rhsType =Context.getCanonicalType(GetterType).getUnqualifiedType();
+ if (lhsType != rhsType && lhsType->isArithmeticType())
+ compat = false;
}
}
+
+ if (!compat) {
+ Diag(Loc, diag::warn_accessor_property_type_mismatch)
+ << property->getDeclName()
+ << GetterMethod->getSelector();
+ Diag(GetterMethod->getLocation(), diag::note_declared_at);
+ return true;
+ }
+
return false;
}
Modified: cfe/branches/tooling/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaStmt.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaStmt.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaStmt.cpp Mon May 21 03:15:06 2012
@@ -30,6 +30,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
using namespace clang;
using namespace sema;
@@ -768,8 +769,30 @@
if (i != 0 && CaseVals[i].first == CaseVals[i-1].first) {
// If we have a duplicate, report it.
- Diag(CaseVals[i].second->getLHS()->getLocStart(),
- diag::err_duplicate_case) << CaseVals[i].first.toString(10);
+ // First, determine if either case value has a name
+ StringRef PrevString, CurrString;
+ Expr *PrevCase = CaseVals[i-1].second->getLHS()->IgnoreParenCasts();
+ Expr *CurrCase = CaseVals[i].second->getLHS()->IgnoreParenCasts();
+ if (DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(PrevCase)) {
+ PrevString = DeclRef->getDecl()->getName();
+ }
+ if (DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(CurrCase)) {
+ CurrString = DeclRef->getDecl()->getName();
+ }
+ llvm::SmallString<16> CaseValStr;
+ CaseVals[i-1].first.toString(CaseValStr);
+
+ if (PrevString == CurrString)
+ Diag(CaseVals[i].second->getLHS()->getLocStart(),
+ diag::err_duplicate_case) <<
+ (PrevString.empty() ? CaseValStr.str() : PrevString);
+ else
+ Diag(CaseVals[i].second->getLHS()->getLocStart(),
+ diag::err_duplicate_case_differing_expr) <<
+ (PrevString.empty() ? CaseValStr.str() : PrevString) <<
+ (CurrString.empty() ? CaseValStr.str() : CurrString) <<
+ CaseValStr;
+
Diag(CaseVals[i-1].second->getLHS()->getLocStart(),
diag::note_duplicate_case_prev);
// FIXME: We really want to remove the bogus case stmt from the
Modified: cfe/branches/tooling/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplate.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplate.cpp Mon May 21 03:15:06 2012
@@ -2438,6 +2438,45 @@
return true;
}
+ case TemplateArgument::Expression: {
+ // We have a template type parameter but the template argument is an
+ // expression; see if maybe it is missing the "typename" keyword.
+ CXXScopeSpec SS;
+ DeclarationNameInfo NameInfo;
+
+ if (DeclRefExpr *ArgExpr = dyn_cast<DeclRefExpr>(Arg.getAsExpr())) {
+ SS.Adopt(ArgExpr->getQualifierLoc());
+ NameInfo = ArgExpr->getNameInfo();
+ } else if (DependentScopeDeclRefExpr *ArgExpr =
+ dyn_cast<DependentScopeDeclRefExpr>(Arg.getAsExpr())) {
+ SS.Adopt(ArgExpr->getQualifierLoc());
+ NameInfo = ArgExpr->getNameInfo();
+ } else if (CXXDependentScopeMemberExpr *ArgExpr =
+ dyn_cast<CXXDependentScopeMemberExpr>(Arg.getAsExpr())) {
+ SS.Adopt(ArgExpr->getQualifierLoc());
+ NameInfo = ArgExpr->getMemberNameInfo();
+ }
+
+ if (NameInfo.getName()) {
+ LookupResult Result(*this, NameInfo, LookupOrdinaryName);
+ LookupParsedName(Result, CurScope, &SS);
+
+ bool CouldBeType = Result.getResultKind() ==
+ LookupResult::NotFoundInCurrentInstantiation;
+
+ for (LookupResult::iterator I = Result.begin(), IEnd = Result.end();
+ !CouldBeType && I != IEnd; ++I) {
+ CouldBeType = isa<TypeDecl>(*I);
+ }
+ if (CouldBeType) {
+ SourceLocation Loc = AL.getSourceRange().getBegin();
+ Diag(Loc, diag::err_template_arg_must_be_type_suggest);
+ Diag(Param->getLocation(), diag::note_template_param_here);
+ return true;
+ }
+ }
+ // fallthrough
+ }
default: {
// We have a template type parameter but the template argument
// is not a type.
Modified: cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplateInstantiate.cpp Mon May 21 03:15:06 2012
@@ -1942,7 +1942,7 @@
CheckCompletedCXXClass(Instantiation);
// Attach any in-class member initializers now the class is complete.
- {
+ if (!FieldsWithMemberInitializers.empty()) {
// C++11 [expr.prim.general]p4:
// Otherwise, if a member-declarator declares a non-static data member
// (9.2) of a class X, the expression this is a prvalue of type "pointer
Modified: cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTReaderDecl.cpp Mon May 21 03:15:06 2012
@@ -1249,7 +1249,6 @@
SourceLocation *StoredLocs = reinterpret_cast<SourceLocation *>(D + 1);
for (unsigned I = 0, N = Record.back(); I != N; ++I)
StoredLocs[I] = ReadSourceLocation(Record, Idx);
- ++Idx;
}
void ASTDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) {
Modified: cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTReaderStmt.cpp Mon May 21 03:15:06 2012
@@ -873,6 +873,7 @@
VisitExpr(E);
E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
E->setAtLoc(ReadSourceLocation(Record, Idx));
+ E->ProtoLoc = ReadSourceLocation(Record, Idx);
E->setRParenLoc(ReadSourceLocation(Record, Idx));
}
Modified: cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp (original)
+++ cfe/branches/tooling/lib/Serialization/ASTWriterStmt.cpp Mon May 21 03:15:06 2012
@@ -837,6 +837,7 @@
VisitExpr(E);
Writer.AddDeclRef(E->getProtocol(), Record);
Writer.AddSourceLocation(E->getAtLoc(), Record);
+ Writer.AddSourceLocation(E->ProtoLoc, Record);
Writer.AddSourceLocation(E->getRParenLoc(), Record);
Code = serialization::EXPR_OBJC_PROTOCOL_EXPR;
}
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt Mon May 21 03:15:06 2012
@@ -31,6 +31,7 @@
DebugCheckers.cpp
DereferenceChecker.cpp
DivZeroChecker.cpp
+ ExprInspectionChecker.cpp
FixedAddressChecker.cpp
GenericTaintChecker.cpp
IdempotentOperationChecker.cpp
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=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td Mon May 21 03:15:06 2012
@@ -483,5 +483,9 @@
HelpText<"Mark tainted symbols as such.">,
DescFile<"TaintTesterChecker.cpp">;
+def ExprInspectionChecker : Checker<"ExprInspection">,
+ HelpText<"Check the analyzer's understanding of expressions">,
+ DescFile<"ExprInspectionChecker.cpp">;
+
} // end "debug"
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Mon May 21 03:15:06 2012
@@ -146,6 +146,8 @@
/// Check if this is one of the functions which can allocate/reallocate memory
/// pointed to by one of its arguments.
bool isMemFunction(const FunctionDecl *FD, ASTContext &C) const;
+ bool isFreeFunction(const FunctionDecl *FD, ASTContext &C) const;
+ bool isAllocationFunction(const FunctionDecl *FD, ASTContext &C) const;
static ProgramStateRef MallocMemReturnsAttr(CheckerContext &C,
const CallExpr *CE,
@@ -177,6 +179,9 @@
bool FreesMemOnFailure) const;
static ProgramStateRef CallocMem(CheckerContext &C, const CallExpr *CE);
+ ///\brief Check if the memory associated with this symbol was released.
+ bool isReleased(SymbolRef Sym, CheckerContext &C) const;
+
bool checkEscape(SymbolRef Sym, const Stmt *S, CheckerContext &C) const;
bool checkUseAfterFree(SymbolRef Sym, CheckerContext &C,
const Stmt *S = 0) const;
@@ -334,44 +339,75 @@
} // end anonymous namespace
void MallocChecker::initIdentifierInfo(ASTContext &Ctx) const {
- if (!II_malloc)
- II_malloc = &Ctx.Idents.get("malloc");
- if (!II_free)
- II_free = &Ctx.Idents.get("free");
- if (!II_realloc)
- II_realloc = &Ctx.Idents.get("realloc");
- if (!II_reallocf)
- II_reallocf = &Ctx.Idents.get("reallocf");
- if (!II_calloc)
- II_calloc = &Ctx.Idents.get("calloc");
- if (!II_valloc)
- II_valloc = &Ctx.Idents.get("valloc");
- if (!II_strdup)
- II_strdup = &Ctx.Idents.get("strdup");
- if (!II_strndup)
- II_strndup = &Ctx.Idents.get("strndup");
+ if (II_malloc)
+ return;
+ II_malloc = &Ctx.Idents.get("malloc");
+ II_free = &Ctx.Idents.get("free");
+ II_realloc = &Ctx.Idents.get("realloc");
+ II_reallocf = &Ctx.Idents.get("reallocf");
+ II_calloc = &Ctx.Idents.get("calloc");
+ II_valloc = &Ctx.Idents.get("valloc");
+ II_strdup = &Ctx.Idents.get("strdup");
+ II_strndup = &Ctx.Idents.get("strndup");
}
bool MallocChecker::isMemFunction(const FunctionDecl *FD, ASTContext &C) const {
+ if (isFreeFunction(FD, C))
+ return true;
+
+ if (isAllocationFunction(FD, C))
+ return true;
+
+ return false;
+}
+
+bool MallocChecker::isAllocationFunction(const FunctionDecl *FD,
+ ASTContext &C) const {
if (!FD)
return false;
+
IdentifierInfo *FunI = FD->getIdentifier();
if (!FunI)
return false;
initIdentifierInfo(C);
- if (FunI == II_malloc || FunI == II_free || FunI == II_realloc ||
+ if (FunI == II_malloc || FunI == II_realloc ||
FunI == II_reallocf || FunI == II_calloc || FunI == II_valloc ||
FunI == II_strdup || FunI == II_strndup)
return true;
- if (Filter.CMallocOptimistic && FD->hasAttrs() &&
- FD->specific_attr_begin<OwnershipAttr>() !=
- FD->specific_attr_end<OwnershipAttr>())
- return true;
+ if (Filter.CMallocOptimistic && FD->hasAttrs())
+ for (specific_attr_iterator<OwnershipAttr>
+ i = FD->specific_attr_begin<OwnershipAttr>(),
+ e = FD->specific_attr_end<OwnershipAttr>();
+ i != e; ++i)
+ if ((*i)->getOwnKind() == OwnershipAttr::Returns)
+ return true;
+ return false;
+}
+bool MallocChecker::isFreeFunction(const FunctionDecl *FD, ASTContext &C) const {
+ if (!FD)
+ return false;
+ IdentifierInfo *FunI = FD->getIdentifier();
+ if (!FunI)
+ return false;
+
+ initIdentifierInfo(C);
+
+ if (FunI == II_free || FunI == II_realloc || FunI == II_reallocf)
+ return true;
+
+ if (Filter.CMallocOptimistic && FD->hasAttrs())
+ for (specific_attr_iterator<OwnershipAttr>
+ i = FD->specific_attr_begin<OwnershipAttr>(),
+ e = FD->specific_attr_end<OwnershipAttr>();
+ i != e; ++i)
+ if ((*i)->getOwnKind() == OwnershipAttr::Takes ||
+ (*i)->getOwnKind() == OwnershipAttr::Holds)
+ return true;
return false;
}
@@ -995,7 +1031,8 @@
}
void MallocChecker::checkPreStmt(const CallExpr *CE, CheckerContext &C) const {
- if (isMemFunction(C.getCalleeDecl(CE), C.getASTContext()))
+ // We will check for double free in the post visit.
+ if (isFreeFunction(C.getCalleeDecl(CE), C.getASTContext()))
return;
// Check use after free, when a freed pointer is passed to a call.
@@ -1082,11 +1119,15 @@
C.addTransition(state);
}
-bool MallocChecker::checkUseAfterFree(SymbolRef Sym, CheckerContext &C,
- const Stmt *S) const {
+bool MallocChecker::isReleased(SymbolRef Sym, CheckerContext &C) const {
assert(Sym);
const RefState *RS = C.getState()->get<RegionState>(Sym);
- if (RS && RS->isReleased()) {
+ return (RS && RS->isReleased());
+}
+
+bool MallocChecker::checkUseAfterFree(SymbolRef Sym, CheckerContext &C,
+ const Stmt *S) const {
+ if (isReleased(Sym, C)) {
if (ExplodedNode *N = C.generateSink()) {
if (!BT_UseFree)
BT_UseFree.reset(new BugType("Use-after-free", "Memory Error"));
@@ -1109,7 +1150,7 @@
CheckerContext &C) const {
SymbolRef Sym = l.getLocSymbolInBase();
if (Sym)
- checkUseAfterFree(Sym, C);
+ checkUseAfterFree(Sym, C, S);
}
//===----------------------------------------------------------------------===//
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp Mon May 21 03:15:06 2012
@@ -47,6 +47,15 @@
return;
}
+ if (const PseudoObjectExpr *POE = dyn_cast<PseudoObjectExpr>(S))
+ for (PseudoObjectExpr::const_semantics_iterator
+ i = POE->semantics_begin(), e = POE->semantics_end(); i != e; ++i) {
+ const Expr *sub = *i;
+ if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(sub))
+ sub = OVE->getSourceExpr();
+ Scan(M, sub);
+ }
+
for (Stmt::const_child_iterator I=S->child_begin(),E=S->child_end(); I!=E;++I)
Scan(M, *I);
}
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=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngine.cpp Mon May 21 03:15:06 2012
@@ -1432,7 +1432,7 @@
const LocationContext *LCtx = Pred->getLocationContext();
if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
- assert(Ex->isLValue());
+ assert(Ex->isGLValue());
SVal V = state->getLValue(VD, Pred->getLocationContext());
// For references, the 'lvalue' is the pointer address stored in the
@@ -1449,7 +1449,7 @@
return;
}
if (const EnumConstantDecl *ED = dyn_cast<EnumConstantDecl>(D)) {
- assert(!Ex->isLValue());
+ assert(!Ex->isGLValue());
SVal V = svalBuilder.makeIntVal(ED->getInitVal());
Bldr.generateNode(Ex, Pred, state->BindExpr(Ex, LCtx, V));
return;
@@ -1492,7 +1492,7 @@
SVal V = state->getLValue(A->getType(),
state->getSVal(Idx, LCtx),
state->getSVal(Base, LCtx));
- assert(A->isLValue());
+ assert(A->isGLValue());
Bldr.generateNode(A, *it, state->BindExpr(A, LCtx, V),
false, 0, ProgramPoint::PostLValueKind);
}
@@ -1506,7 +1506,7 @@
ExplodedNodeSet Dst;
Decl *member = M->getMemberDecl();
if (VarDecl *VD = dyn_cast<VarDecl>(member)) {
- assert(M->isLValue());
+ assert(M->isGLValue());
Bldr.takeNodes(Pred);
VisitCommonDeclRefExpr(M, VD, Pred, Dst);
Bldr.addNodes(Dst);
@@ -1537,7 +1537,7 @@
// For all other cases, compute an lvalue.
SVal L = state->getLValue(field, baseExprVal);
- if (M->isLValue())
+ if (M->isGLValue())
Bldr.generateNode(M, Pred, state->BindExpr(M, LCtx, L), false, 0,
ProgramPoint::PostLValueKind);
else {
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineC.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineC.cpp Mon May 21 03:15:06 2012
@@ -50,7 +50,7 @@
}
// Simulate the effects of a "store": bind the value of the RHS
// to the L-Value represented by the LHS.
- SVal ExprVal = B->isLValue() ? LeftV : RightV;
+ SVal ExprVal = B->isGLValue() ? LeftV : RightV;
evalStore(Tmp2, B, LHS, *it, state->BindExpr(B, LCtx, ExprVal),
LeftV, RightV);
continue;
@@ -165,7 +165,7 @@
// In C++, assignment and compound assignment operators return an
// lvalue.
- if (B->isLValue())
+ if (B->isGLValue())
state = state->BindExpr(B, LCtx, location);
else
state = state->BindExpr(B, LCtx, Result);
@@ -332,7 +332,7 @@
// Compute the type of the result.
QualType resultType = CastE->getType();
- if (CastE->isLValue())
+ if (CastE->isGLValue())
resultType = getContext().getPointerType(resultType);
bool Failed = false;
@@ -381,7 +381,7 @@
case CK_MemberPointerToBoolean: {
// Recover some path-sensitivty by conjuring a new value.
QualType resultType = CastE->getType();
- if (CastE->isLValue())
+ if (CastE->isGLValue())
resultType = getContext().getPointerType(resultType);
const LocationContext *LCtx = Pred->getLocationContext();
SVal result = svalBuilder.getConjuredSymbolVal(NULL, CastE, LCtx,
@@ -408,7 +408,7 @@
const LocationContext *LC = Pred->getLocationContext();
state = state->bindCompoundLiteral(CL, LC, ILV);
- if (CL->isLValue())
+ if (CL->isGLValue())
B.generateNode(CL, Pred, state->BindExpr(CL, LC, state->getLValue(CL, LC)));
else
B.generateNode(CL, Pred, state->BindExpr(CL, LC, ILV));
@@ -459,7 +459,7 @@
// UnknownVal.
if (InitVal.isUnknown()) {
QualType Ty = InitEx->getType();
- if (InitEx->isLValue()) {
+ if (InitEx->isGLValue()) {
Ty = getContext().getPointerType(Ty);
}
@@ -689,7 +689,7 @@
}
case UO_Plus:
- assert(!U->isLValue());
+ assert(!U->isGLValue());
// FALL-THROUGH.
case UO_Deref:
case UO_AddrOf:
@@ -712,7 +712,7 @@
case UO_LNot:
case UO_Minus:
case UO_Not: {
- assert (!U->isLValue());
+ assert (!U->isGLValue());
const Expr *Ex = U->getSubExpr()->IgnoreParens();
ProgramStateRef state = Pred->getState();
const LocationContext *LCtx = Pred->getLocationContext();
@@ -837,7 +837,7 @@
// Since the lvalue-to-rvalue conversion is explicit in the AST,
// we bind an l-value if the operator is prefix and an lvalue (in C++).
- if (U->isLValue())
+ if (U->isGLValue())
state = state->BindExpr(U, LCtx, loc);
else
state = state->BindExpr(U, LCtx, U->isPostfix() ? V2 : Result);
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp Mon May 21 03:15:06 2012
@@ -510,7 +510,7 @@
else
ResultTy = CE->getType();
- if (CE->isLValue())
+ if (CE->isGLValue())
ResultTy = Eng.getContext().getPointerType(ResultTy);
// Conjure a symbol value to use as the result.
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/ObjCMessage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/ObjCMessage.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/ObjCMessage.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/ObjCMessage.cpp Mon May 21 03:15:06 2012
@@ -30,7 +30,7 @@
} else {
const CallExpr *FunctionCall = CallE.get<const CallExpr *>();
- isLVal = FunctionCall->isLValue();
+ isLVal = FunctionCall->isGLValue();
const Expr *Callee = FunctionCall->getCallee();
if (const FunctionDecl *FD = State->getSVal(Callee, LCtx).getAsFunctionDecl())
resultTy = FD->getResultType();
Modified: cfe/branches/tooling/runtime/compiler-rt/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/runtime/compiler-rt/Makefile?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/runtime/compiler-rt/Makefile (original)
+++ cfe/branches/tooling/runtime/compiler-rt/Makefile Mon May 21 03:15:06 2012
@@ -90,7 +90,7 @@
endif
ifeq ($(ARCH),x86_64)
RuntimeLibrary.linux.Configs += \
- full-x86_64 profile-x86_64 asan-x86_64
+ full-x86_64 profile-x86_64 asan-x86_64 tsan-x86_64
endif
endif
Modified: cfe/branches/tooling/test/ARCMT/checking.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/ARCMT/checking.m?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/ARCMT/checking.m (original)
+++ cfe/branches/tooling/test/ARCMT/checking.m Mon May 21 03:15:06 2012
@@ -89,8 +89,7 @@
[a retain];
[a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}}
[a release];
- [a autorelease]; // expected-error {{it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately}} \
- // expected-error {{ARC forbids explicit message send}}
+ [a autorelease];
CFStringRef cfstr;
NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \
Modified: cfe/branches/tooling/test/ARCMT/objcmt-numeric-literals.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/ARCMT/objcmt-numeric-literals.m.result?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/ARCMT/objcmt-numeric-literals.m.result (original)
+++ cfe/branches/tooling/test/ARCMT/objcmt-numeric-literals.m.result Mon May 21 03:15:06 2012
@@ -468,7 +468,7 @@
[NSNumber numberWithInteger:NO];
[NSNumber numberWithInteger:true];
[NSNumber numberWithInteger:false];
- [NSNumber numberWithInteger:VAL_INT];
+ @VAL_INT;
[NSNumber numberWithInteger:VAL_UINT];
[NSNumber numberWithUnsignedInteger:'a'];
@@ -498,5 +498,5 @@
[NSNumber numberWithUnsignedInteger:true];
[NSNumber numberWithUnsignedInteger:false];
[NSNumber numberWithUnsignedInteger:VAL_INT];
- [NSNumber numberWithUnsignedInteger:VAL_UINT];
+ @VAL_UINT;
}
Modified: cfe/branches/tooling/test/Analysis/additive-folding-range-constraints.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/additive-folding-range-constraints.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/additive-folding-range-constraints.c (original)
+++ cfe/branches/tooling/test/Analysis/additive-folding-range-constraints.c Mon May 21 03:15:06 2012
@@ -1,10 +1,7 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,unix.Malloc -verify -analyzer-constraints=range %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -analyzer-constraints=range %s
+
+void clang_analyzer_eval(int);
-// These are used to trigger warnings.
-typedef typeof(sizeof(int)) size_t;
-void *malloc(size_t);
-void free(void *);
-#define NULL ((void*)0)
#define UINT_MAX (~0U)
#define INT_MAX (UINT_MAX & (UINT_MAX >> 1))
#define INT_MIN (-INT_MAX - 1)
@@ -14,43 +11,27 @@
// solution range across an overflow boundary (Min for <, Max for >).
// This corresponds to one set of branches in RangeConstraintManager.
void smallAdjustmentGT (unsigned a) {
- void *b = NULL;
if (a+2 > 1)
- b = malloc(1);
- if (a == UINT_MAX-1 || a == UINT_MAX)
- return; // no-warning
- else if (a < UINT_MAX-1)
- free(b);
- return; // no-warning
+ clang_analyzer_eval(a < UINT_MAX-1); // expected-warning{{TRUE}}
+ else
+ clang_analyzer_eval(a == UINT_MAX-1 || a == UINT_MAX); // expected-warning{{TRUE}}
}
void smallAdjustmentGE (unsigned a) {
- void *b = NULL;
if (a+2 >= 1)
- b = malloc(1);
- if (a == UINT_MAX-1)
- return; // no-warning
- else if (a < UINT_MAX-1 || a == UINT_MAX)
- free(b);
- return; // no-warning
+ clang_analyzer_eval(a < UINT_MAX-1 || a == UINT_MAX); // expected-warning{{TRUE}}
+ else
+ clang_analyzer_eval(a == UINT_MAX-1); // expected-warning{{TRUE}}
}
void smallAdjustmentLT (unsigned a) {
- void *b = NULL;
if (a+1 < 2)
- b = malloc(1);
- if (a == 0 || a == UINT_MAX)
- free(b);
- return; // no-warning
+ clang_analyzer_eval(a == 0 || a == UINT_MAX); // expected-warning{{TRUE}}
}
void smallAdjustmentLE (unsigned a) {
- void *b = NULL;
if (a+1 <= 2)
- b = malloc(1);
- if (a == 0 || a == 1 || a == UINT_MAX)
- free(b);
- return; // no-warning
+ clang_analyzer_eval(a == 0 || a == 1 || a == UINT_MAX); // expected-warning{{TRUE}}
}
@@ -58,154 +39,102 @@
// comparison value over an overflow boundary (Min for <, Max for >).
// This corresponds to one set of branches in RangeConstraintManager.
void largeAdjustmentGT (unsigned a) {
- void *b = NULL;
if (a-2 > UINT_MAX-1)
- b = malloc(1);
- if (a == 1 || a == 0)
- free(b);
- else if (a > 1)
- free(b);
- return; // no-warning
+ clang_analyzer_eval(a == 1); // expected-warning{{TRUE}}
+ else
+ clang_analyzer_eval(a != 1); // expected-warning{{TRUE}}
}
void largeAdjustmentGE (unsigned a) {
- void *b = NULL;
if (a-2 >= UINT_MAX-1)
- b = malloc(1);
- if (a > 1)
- return; // no-warning
- else if (a == 1 || a == 0)
- free(b);
- return; // no-warning
+ clang_analyzer_eval(a == 1 || a == 0); // expected-warning{{TRUE}}
+ else
+ clang_analyzer_eval(a > 1); // expected-warning{{TRUE}}
}
void largeAdjustmentLT (unsigned a) {
- void *b = NULL;
if (a+2 < 1)
- b = malloc(1);
- if (a == UINT_MAX-1 || a == UINT_MAX)
- free(b);
- else if (a < UINT_MAX-1)
- return; // no-warning
- return; // no-warning
+ clang_analyzer_eval(a == UINT_MAX-1); // expected-warning{{TRUE}}
+ else
+ clang_analyzer_eval(a != UINT_MAX-1); // expected-warning{{TRUE}}
}
void largeAdjustmentLE (unsigned a) {
- void *b = NULL;
if (a+2 <= 1)
- b = malloc(1);
- if (a < UINT_MAX-1)
- return; // no-warning
- else if (a == UINT_MAX-1 || a == UINT_MAX)
- free(b);
- return; // no-warning
+ clang_analyzer_eval(a == UINT_MAX-1 || a == UINT_MAX); // expected-warning{{TRUE}}
+ else
+ clang_analyzer_eval(a < UINT_MAX-1); // expected-warning{{TRUE}}
}
// Test the nine cases in RangeConstraintManager's pinning logic.
+// For out-of-range tautologies, it may be the negation that actually
+// triggers the case in question.
void mixedComparisons1(signed char a) {
// Case 1: The range is entirely below the symbol's range.
int min = INT_MIN;
- if ((a - 2) < (min + 5LL))
- return; // expected-warning{{never executed}}
+ clang_analyzer_eval((a - 2) >= (min + 5LL)); // expected-warning{{TRUE}}
- if (a == 0)
- return; // no-warning
- if (a == 0x7F)
- return; // no-warning
- if (a == -0x80)
- return; // no-warning
- return; // no-warning
+ clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}}
}
void mixedComparisons2(signed char a) {
// Case 2: Only the lower end of the range is outside.
+ clang_analyzer_eval((a - 5) < (-0x81LL)); // expected-warning{{UNKNOWN}}
+
if ((a - 5) < (-0x81LL)) {
- if (a == 0)
- return; // expected-warning{{never executed}}
- if (a == 0x7F)
- return; // expected-warning{{never executed}}
- if (a == -0x80)
- return; // no-warning
- return; // no-warning
- } else {
- return; // no-warning
+ clang_analyzer_eval(a == 0); // expected-warning{{FALSE}}
+ clang_analyzer_eval(a == 0x7F); // expected-warning{{FALSE}}
+ clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}}
}
}
void mixedComparisons3(signed char a) {
// Case 3: The entire symbol range is covered.
- if ((a - 0x200) < -0x100LL) {
- if (a == 0)
- return; // no-warning
- if (a == 0x7F)
- return; // no-warning
- if (a == -0x80)
- return; // no-warning
- return; // no-warning
- } else {
- return; // expected-warning{{never executed}}
- }
+ clang_analyzer_eval((a - 0x200) < -0x100LL); // expected-warning{{TRUE}}
+
+ clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}}
}
void mixedComparisons4(signed char a) {
// Case 4: The range wraps around, but the lower wrap is out-of-range.
+ clang_analyzer_eval((a - 5) > 0LL); // expected-warning{{UNKNOWN}}
+
if ((a - 5) > 0LL) {
- if (a == 0)
- return; // expected-warning{{never executed}}
- if (a == 0x7F)
- return; // no-warning
- if (a == -0x80)
- return; // expected-warning{{never executed}}
- return; // no-warning
- } else {
- return; // no-warning
+ clang_analyzer_eval(a == 0); // expected-warning{{FALSE}}
+ clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a == -0x80); // expected-warning{{FALSE}}
}
}
void mixedComparisons5(signed char a) {
- // Case 5a: The range is inside and does not wrap.
- if ((a + 5) == 0LL) {
- if (a == 0)
- return; // expected-warning{{never executed}}
- if (a == 0x7F)
- return; // expected-warning{{never executed}}
- if (a == -0x80)
- return; // expected-warning{{never executed}}
- return; // no-warning
- } else {
- return; // no-warning
- }
-}
+ // Case 5: The range is inside and may or may not wrap.
+ clang_analyzer_eval((a + 5) == 0LL); // expected-warning{{UNKNOWN}}
-void mixedComparisons5Wrap(signed char a) {
- // Case 5b: The range is inside and does wrap.
- if ((a + 5) != 0LL) {
- if (a == 0)
- return; // no-warning
- if (a == 0x7F)
- return; // no-warning
- if (a == -0x80)
- return; // no-warning
- return; // no-warning
- } else {
- return; // no-warning
+ if ((a + 5) == 0LL) {
+ clang_analyzer_eval(a == 0); // expected-warning{{FALSE}}
+ clang_analyzer_eval(a == 0x7F); // expected-warning{{FALSE}}
+ clang_analyzer_eval(a == -0x80); // expected-warning{{FALSE}}
+ } else {
+ clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}}
}
}
void mixedComparisons6(signed char a) {
// Case 6: Only the upper end of the range is outside.
+ clang_analyzer_eval((a + 5) > 0x81LL); // expected-warning{{UNKNOWN}}
+
if ((a + 5) > 0x81LL) {
- if (a == 0)
- return; // expected-warning{{never executed}}
- if (a == 0x7F)
- return; // no-warning
- if (a == -0x80)
- return; // expected-warning{{never executed}}
- return; // no-warning
- } else {
- return; // no-warning
+ clang_analyzer_eval(a == 0); // expected-warning{{FALSE}}
+ clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a == -0x80); // expected-warning{{FALSE}}
}
}
@@ -213,30 +142,21 @@
// Case 7: The range wraps around but is entirely outside the symbol's range.
int min = INT_MIN;
- if ((a + 2) < (min + 5LL))
- return; // expected-warning{{never executed}}
+ clang_analyzer_eval((a + 2) >= (min + 5LL)); // expected-warning{{TRUE}}
- if (a == 0)
- return; // no-warning
- if (a == 0x7F)
- return; // no-warning
- if (a == -0x80)
- return; // no-warning
- return; // no-warning
+ clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}}
}
void mixedComparisons8(signed char a) {
// Case 8: The range wraps, but the upper wrap is out of range.
+ clang_analyzer_eval((a + 5) < 0LL); // expected-warning{{UNKNOWN}}
+
if ((a + 5) < 0LL) {
- if (a == 0)
- return; // expected-warning{{never executed}}
- if (a == 0x7F)
- return; // expected-warning{{never executed}}
- if (a == -0x80)
- return; // no-warning
- return; // no-warning
- } else {
- return; // no-warning
+ clang_analyzer_eval(a == 0); // expected-warning{{FALSE}}
+ clang_analyzer_eval(a == 0x7F); // expected-warning{{FALSE}}
+ clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}}
}
}
@@ -244,14 +164,9 @@
// Case 9: The range is entirely above the symbol's range.
int max = INT_MAX;
- if ((a + 2) > (max - 5LL))
- return; // expected-warning{{never executed}}
+ clang_analyzer_eval((a + 2) <= (max - 5LL)); // expected-warning{{TRUE}}
- if (a == 0)
- return; // no-warning
- if (a == 0x7F)
- return; // no-warning
- if (a == -0x80)
- return; // no-warning
- return; // no-warning
+ clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}}
}
Modified: cfe/branches/tooling/test/Analysis/additive-folding.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/additive-folding.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/additive-folding.cpp (original)
+++ cfe/branches/tooling/test/Analysis/additive-folding.cpp Mon May 21 03:15:06 2012
@@ -1,11 +1,8 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,unix.Malloc -verify -analyzer-constraints=basic %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,unix.Malloc -verify -analyzer-constraints=range %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -analyzer-constraints=basic -Wno-tautological-compare %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -analyzer-constraints=range -Wno-tautological-compare %s
+
+void clang_analyzer_eval(bool);
-// These are used to trigger warnings.
-typedef typeof(sizeof(int)) size_t;
-void *malloc(size_t);
-void free(void *);
-#define NULL ((void*)0)
#define UINT_MAX (~0U)
#define INT_MAX (UINT_MAX & (UINT_MAX >> 1))
#define INT_MIN (-INT_MAX - 1)
@@ -18,10 +15,7 @@
int b = a + 1;
--b;
- void *buf = malloc(1);
- if (a != 0 && b == 0)
- return; // expected-warning{{never executed}}
- free(buf);
+ clang_analyzer_eval(a != 0 && b == 0); // expected-warning{{FALSE}}
}
void oneLongExpression (int a) {
@@ -29,26 +23,17 @@
// the first term is on the left.
int b = 15 + a + 15 - 10 - 20;
- void *buf = malloc(1);
- if (a != 0 && b == 0)
- return; // expected-warning{{never executed}}
- free(buf);
+ clang_analyzer_eval(a != 0 && b == 0); // expected-warning{{FALSE}}
}
void mixedTypes (int a) {
- void *buf = malloc(1);
-
// Different additive types should not cause crashes when constant-folding.
// This is part of PR7406.
int b = a + 1LL;
- if (a != 0 && (b-1) == 0) // not crash
- return; // expected-warning{{never executed}}
+ clang_analyzer_eval(a != 0 && (b-1) == 0); // not crash, expected-warning{{FALSE}}
int c = a + 1U;
- if (a != 0 && (c-1) == 0) // not crash
- return; // expected-warning{{never executed}}
-
- free(buf);
+ clang_analyzer_eval(a != 0 && (c-1) == 0); // not crash, expected-warning{{FALSE}}
}
//---------------
@@ -57,206 +42,101 @@
// Equality and inequality only
void eq_ne (unsigned a) {
- void *b = NULL;
- if (a == UINT_MAX)
- b = malloc(1);
- if (a+1 != 0)
- return; // no-warning
- if (a-1 != UINT_MAX-1)
- return; // no-warning
- free(b);
-}
-
-void ne_eq (unsigned a) {
- void *b = NULL;
- if (a != UINT_MAX)
- b = malloc(1);
- if (a+1 == 0)
- return; // no-warning
- if (a-1 == UINT_MAX-1)
- return; // no-warning
- free(b);
+ if (a == UINT_MAX) {
+ clang_analyzer_eval(a+1 == 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a-1 == UINT_MAX-1); // expected-warning{{TRUE}}
+ } else {
+ clang_analyzer_eval(a+1 != 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a-1 != UINT_MAX-1); // expected-warning{{TRUE}}
+ }
}
// Mixed typed inequalities (part of PR7406)
// These should not crash.
void mixed_eq_ne (int a) {
- void *b = NULL;
- if (a == 1)
- b = malloc(1);
- if (a+1U != 2)
- return; // no-warning
- if (a-1U != 0)
- return; // expected-warning{{never executed}}
- free(b);
-}
-
-void mixed_ne_eq (int a) {
- void *b = NULL;
- if (a != 1)
- b = malloc(1);
- if (a+1U == 2)
- return; // no-warning
- if (a-1U == 0)
- return; // expected-warning{{never executed}}
- free(b);
+ if (a == 1) {
+ clang_analyzer_eval(a+1U == 2); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a-1U == 0); // expected-warning{{TRUE}}
+ } else {
+ clang_analyzer_eval(a+1U != 2); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a-1U != 0); // expected-warning{{TRUE}}
+ }
}
// Simple order comparisons with no adjustment
void baselineGT (unsigned a) {
- void *b = NULL;
if (a > 0)
- b = malloc(1);
- if (a == 0)
- return; // no-warning
- free(b);
+ clang_analyzer_eval(a != 0); // expected-warning{{TRUE}}
+ else
+ clang_analyzer_eval(a == 0); // expected-warning{{TRUE}}
}
void baselineGE (unsigned a) {
- void *b = NULL;
if (a >= UINT_MAX)
- b = malloc(1);
- if (a == UINT_MAX)
- free(b);
- return; // no-warning
+ clang_analyzer_eval(a == UINT_MAX); // expected-warning{{TRUE}}
+ else
+ clang_analyzer_eval(a != UINT_MAX); // expected-warning{{TRUE}}
}
void baselineLT (unsigned a) {
- void *b = NULL;
if (a < UINT_MAX)
- b = malloc(1);
- if (a == UINT_MAX)
- return; // no-warning
- free(b);
+ clang_analyzer_eval(a != UINT_MAX); // expected-warning{{TRUE}}
+ else
+ clang_analyzer_eval(a == UINT_MAX); // expected-warning{{TRUE}}
}
void baselineLE (unsigned a) {
- void *b = NULL;
if (a <= 0)
- b = malloc(1);
- if (a == 0)
- free(b);
- return; // no-warning
+ clang_analyzer_eval(a == 0); // expected-warning{{TRUE}}
+ else
+ clang_analyzer_eval(a != 0); // expected-warning{{TRUE}}
}
// Adjustment gives each of these an extra solution!
void adjustedGT (unsigned a) {
- void *b = NULL;
- if (a-1 > UINT_MAX-1)
- b = malloc(1);
- return; // expected-warning{{leak}}
+ clang_analyzer_eval(a-1 > UINT_MAX-1); // expected-warning{{UNKNOWN}}
}
void adjustedGE (unsigned a) {
- void *b = NULL;
+ clang_analyzer_eval(a-1 > UINT_MAX-1); // expected-warning{{UNKNOWN}}
+
if (a-1 >= UINT_MAX-1)
- b = malloc(1);
- if (a == UINT_MAX)
- free(b);
- return; // expected-warning{{leak}}
+ clang_analyzer_eval(a == UINT_MAX); // expected-warning{{UNKNOWN}}
}
void adjustedLT (unsigned a) {
- void *b = NULL;
- if (a+1 < 1)
- b = malloc(1);
- return; // expected-warning{{leak}}
+ clang_analyzer_eval(a+1 < 1); // expected-warning{{UNKNOWN}}
}
void adjustedLE (unsigned a) {
- void *b = NULL;
+ clang_analyzer_eval(a+1 <= 1); // expected-warning{{UNKNOWN}}
+
if (a+1 <= 1)
- b = malloc(1);
- if (a == 0)
- free(b);
- return; // expected-warning{{leak}}
+ clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}}
}
// Tautologies
-void tautologyGT (unsigned a) {
- void *b = malloc(1);
- if (a > UINT_MAX)
- return; // no-warning
- free(b);
-}
-
-void tautologyGE (unsigned a) {
- void *b = malloc(1);
- if (a >= 0) // expected-warning{{always true}}
- free(b);
- return; // no-warning
-}
-
-void tautologyLT (unsigned a) {
- void *b = malloc(1);
- if (a < 0) // expected-warning{{always false}}
- return; // expected-warning{{never executed}}
- free(b);
-}
-
-void tautologyLE (unsigned a) {
- void *b = malloc(1);
- if (a <= UINT_MAX)
- free(b);
- return; // no-warning
+// The negative forms are exercised as well
+// because clang_analyzer_eval tests both possibilities.
+void tautologies(unsigned a) {
+ clang_analyzer_eval(a <= UINT_MAX); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a >= 0); // expected-warning{{TRUE}}
}
// Tautologies from outside the range of the symbol
-void tautologyOutsideGT(unsigned char a) {
- void *b = malloc(1);
- if (a > 0x100)
- return; // expected-warning{{never executed}}
- if (a > -1)
- free(b);
- return; // no-warning
-}
-
-void tautologyOutsideGE(unsigned char a) {
- void *b = malloc(1);
- if (a >= 0x100)
- return; // expected-warning{{never executed}}
- if (a >= -1)
- free(b);
- return; // no-warning
-}
-
-void tautologyOutsideLT(unsigned char a) {
- void *b = malloc(1);
- if (a < -1)
- return; // expected-warning{{never executed}}
- if (a < 0x100)
- free(b);
- return; // no-warning
-}
-
-void tautologyOutsideLE (unsigned char a) {
- void *b = malloc(1);
- if (a <= -1)
- return; // expected-warning{{never executed}}
- if (a <= 0x100)
- free(b);
- return; // no-warning
-}
-
-void tautologyOutsideEQ(unsigned char a) {
- if (a == 0x100)
- malloc(1); // expected-warning{{never executed}}
- if (a == -1)
- malloc(1); // expected-warning{{never executed}}
-}
-
-void tautologyOutsideNE(unsigned char a) {
- void *sentinel = malloc(1);
- if (a != 0x100)
- free(sentinel);
-
- sentinel = malloc(1);
- if (a != -1)
- free(sentinel);
+void tautologiesOutside(unsigned char a) {
+ clang_analyzer_eval(a <= 0x100); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a < 0x100); // expected-warning{{TRUE}}
+
+ clang_analyzer_eval(a != 0x100); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a != -1); // expected-warning{{TRUE}}
+
+ clang_analyzer_eval(a > -1); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a >= -1); // expected-warning{{TRUE}}
}
@@ -267,64 +147,32 @@
int min = INT_MIN;
int b = a + 1;
- if (a == max && b != min)
- return; // expected-warning{{never executed}}
-}
-
-void mixedWraparoundGT(int a) {
- int max = INT_MAX;
-
- if ((a + 2) > (max + 1LL))
- return; // expected-warning{{never executed}}
+ clang_analyzer_eval(a == max && b != min); // expected-warning{{FALSE}}
}
-void mixedWraparoundGE(int a) {
+void mixedWraparoundLE_GT(int a) {
int max = INT_MAX;
int min = INT_MIN;
- if ((a + 2) >= (max + 1LL))
- return; // expected-warning{{never executed}}
-
- void *sentinel = malloc(1);
- if ((a - 2LL) >= min)
- free(sentinel);
- return; // expected-warning{{leak}}
-}
-
-void mixedWraparoundLT(int a) {
- int min = INT_MIN;
-
- if ((a - 2) < (min - 1LL))
- return; // expected-warning{{never executed}}
+ clang_analyzer_eval((a + 2) <= (max + 1LL)); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a - 2) > (min - 1LL)); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a + 2LL) <= max); // expected-warning{{UNKNOWN}}
}
-void mixedWraparoundLE(int a) {
+void mixedWraparoundGE_LT(int a) {
int max = INT_MAX;
int min = INT_MIN;
- if ((a - 2) <= (min - 1LL))
- return; // expected-warning{{never executed}}
-
- void *sentinel = malloc(1);
- if ((a + 2LL) <= max)
- free(sentinel);
- return; // expected-warning{{leak}}
-}
-
-void mixedWraparoundEQ(int a) {
- int max = INT_MAX;
-
- if ((a + 2) == (max + 1LL))
- return; // expected-warning{{never executed}}
+ clang_analyzer_eval((a + 2) < (max + 1LL)); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a - 2) >= (min - 1LL)); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a - 2LL) >= min); // expected-warning{{UNKNOWN}}
}
-void mixedWraparoundNE(int a) {
+void mixedWraparoundEQ_NE(int a) {
int max = INT_MAX;
- void *sentinel = malloc(1);
- if ((a + 2) != (max + 1LL))
- free(sentinel);
- return; // no-warning
+ clang_analyzer_eval((a + 2) != (max + 1LL)); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a + 2LL) == (max + 1LL)); // expected-warning{{UNKNOWN}}
}
@@ -332,85 +180,17 @@
void mixedSignedness(int a, unsigned b) {
int sMin = INT_MIN;
unsigned uMin = INT_MIN;
- if (a == sMin && a != uMin)
- return; // expected-warning{{never executed}}
- if (b == uMin && b != sMin)
- return; // expected-warning{{never executed}}
-}
-
-
-// PR12206/12510 - When SimpleSValBuilder figures out that a symbol is fully
-// constrained, it should cast the value to the result type in a binary
-// operation...unless the binary operation is a comparison, in which case the
-// two arguments should be the same type, but won't match the result type.
-//
-// This is easier to trigger in C++ mode, where the comparison result type is
-// 'bool' and is thus differently sized from int on pretty much every system.
-//
-// This is not directly related to additive folding, but we use SValBuilder's
-// additive folding to tickle the bug. ExprEngine will simplify fully-constrained
-// symbols, so SValBuilder will only see them if they are (a) part of an evaluated
-// SymExpr (e.g. with additive folding) or (b) generated by a checker (e.g.
-// unix.cstring's strlen() modelling).
-void PR12206(int x) {
- // Build a SymIntExpr, dependent on x.
- int local = x - 1;
-
- // Constrain the value of x.
- int value = 1 + (1 << (8 * sizeof(1 == 1))); // not representable by bool
- if (x != value) return;
-
- // Constant-folding will turn (local+1) back into the symbol for x.
- // The point of this dance is to make SValBuilder be responsible for
- // turning the symbol into a ConcreteInt, rather than ExprEngine.
-
- // Test relational operators.
- if ((local + 1) < 2)
- malloc(1); // expected-warning{{never executed}}
- if (2 > (local + 1))
- malloc(1); // expected-warning{{never executed}}
-
- // Test equality operators.
- if ((local + 1) == 1)
- malloc(1); // expected-warning{{never executed}}
- if (1 == (local + 1))
- malloc(1); // expected-warning{{never executed}}
-}
-
-void PR12206_truncation(signed char x) {
- // Build a SymIntExpr, dependent on x.
- signed char local = x - 1;
-
- // Constrain the value of x.
- if (x != 1) return;
-
- // Constant-folding will turn (local+1) back into the symbol for x.
- // The point of this dance is to make SValBuilder be responsible for
- // turning the symbol into a ConcreteInt, rather than ExprEngine.
-
- // Construct a value that cannot be represented by 'char',
- // but that has the same lower bits as x.
- signed int value = 1 + (1 << 8);
-
- // Test relational operators.
- if ((local + 1) >= value)
- malloc(1); // expected-warning{{never executed}}
- if (value <= (local + 1))
- malloc(1); // expected-warning{{never executed}}
-
- // Test equality operators.
- if ((local + 1) == value)
- malloc(1); // expected-warning{{never executed}}
- if (value == (local + 1))
- malloc(1); // expected-warning{{never executed}}
+
+ clang_analyzer_eval(a == sMin && a != uMin); // expected-warning{{FALSE}}
+ clang_analyzer_eval(b == uMin && b != sMin); // expected-warning{{FALSE}}
}
+
void multiplicativeSanityTest(int x) {
// At one point we were ignoring the *4 completely -- the constraint manager
- // would see x < 8 and then declare the next part unreachable.
+ // would see x < 8 and then declare the assertion to be known false.
if (x*4 < 8)
return;
- if (x == 3)
- malloc(1);
- return; // expected-warning{{leak}}
+
+ clang_analyzer_eval(x == 3); // expected-warning{{UNKNOWN}}
}
Modified: cfe/branches/tooling/test/Analysis/array-struct-region.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/array-struct-region.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/array-struct-region.c (original)
+++ cfe/branches/tooling/test/Analysis/array-struct-region.c Mon May 21 03:15:06 2012
@@ -1,25 +1,21 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,experimental.deadcode.UnreachableCode -analyzer-store=region -analyzer-constraints=basic -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,experimental.deadcode.UnreachableCode -analyzer-store=region -analyzer-constraints=range -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,debug.ExprInspection -analyzer-store=region -analyzer-constraints=basic -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,debug.ExprInspection -analyzer-store=region -analyzer-constraints=range -verify %s
+
+void clang_analyzer_eval(int);
int string_literal_init() {
char a[] = "abc";
char b[2] = "abc"; // expected-warning{{too long}}
char c[5] = "abc";
- if (a[1] != 'b')
- return 0; // expected-warning{{never executed}}
- if (b[1] != 'b')
- return 0; // expected-warning{{never executed}}
- if (c[1] != 'b')
- return 0; // expected-warning{{never executed}}
-
- if (a[3] != 0)
- return 0; // expected-warning{{never executed}}
- if (c[3] != 0)
- return 0; // expected-warning{{never executed}}
+ clang_analyzer_eval(a[1] == 'b'); // expected-warning{{TRUE}}
+ clang_analyzer_eval(b[1] == 'b'); // expected-warning{{TRUE}}
+ clang_analyzer_eval(c[1] == 'b'); // expected-warning{{TRUE}}
+
+ clang_analyzer_eval(a[3] == 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(c[3] == 0); // expected-warning{{TRUE}}
- if (c[4] != 0)
- return 0; // expected-warning{{never executed}}
+ clang_analyzer_eval(c[4] == 0); // expected-warning{{TRUE}}
return 42;
}
@@ -48,13 +44,16 @@
void struct_as_array() {
- struct simple { int x; };
+ struct simple { int x; int y; };
struct simple a;
struct simple *p = &a;
+
p->x = 5;
- if (!p[0].x)
- return; // expected-warning{{never executed}}
- if (p[0].x)
- return; // no-warning
+ clang_analyzer_eval(a.x == 5); // expected-warning{{TRUE}}
+ clang_analyzer_eval(p[0].x == 5); // expected-warning{{TRUE}}
+
+ p[0].y = 5;
+ clang_analyzer_eval(a.y == 5); // expected-warning{{TRUE}}
+ clang_analyzer_eval(p->y == 5); // expected-warning{{TRUE}}
}
Modified: cfe/branches/tooling/test/Analysis/base-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/base-init.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/base-init.cpp (original)
+++ cfe/branches/tooling/test/Analysis/base-init.cpp Mon May 21 03:15:06 2012
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -analyzer-inline-call -cfg-add-initializers -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store region -analyzer-ipa=inlining -cfg-add-initializers -verify %s
// XFAIL: *
+void clang_analyzer_eval(bool);
+
class A {
int x;
public:
@@ -24,8 +26,5 @@
void f() {
B b;
- if (b.getx() != 0) {
- int *p = 0;
- *p = 0; // no-warning
- }
+ clang_analyzer_eval(b.getx() == 0); // expected-warning{{TRUE}}
}
Modified: cfe/branches/tooling/test/Analysis/bstring.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/bstring.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/bstring.c (original)
+++ cfe/branches/tooling/test/Analysis/bstring.c Mon May 21 03:15:06 2012
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,unix.cstring.NullArg,experimental.unix.cstring.OutOfBounds,experimental.unix.cstring.BufferOverlap,experimental.unix.cstring.NotNullTerminated -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s
//===----------------------------------------------------------------------===
// Declarations
@@ -26,6 +26,8 @@
typedef typeof(sizeof(int)) size_t;
+void clang_analyzer_eval(int);
+
//===----------------------------------------------------------------------===
// memcpy()
//===----------------------------------------------------------------------===
@@ -52,12 +54,11 @@
memcpy(dst, src, 4); // no-warning
- if (memcpy(dst, src, 4) != dst) {
- (void)*(char*)0; // no-warning
- }
+ clang_analyzer_eval(memcpy(dst, src, 4) == dst); // expected-warning{{TRUE}}
- if (dst[0] != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ // If we actually model the copy, we can make this known.
+ // The important thing for now is that the old value has been invalidated.
+ clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}}
}
void memcpy1 () {
@@ -138,14 +139,13 @@
void memcpy_unknown_size (size_t n) {
char a[4], b[4] = {1};
- if (memcpy(a, b, n) != a)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(memcpy(a, b, n) == a); // expected-warning{{TRUE}}
}
void memcpy_unknown_size_warn (size_t n) {
char a[4];
- if (memcpy(a, 0, n) != a) // expected-warning{{Null pointer argument in call to memory copy function}}
- (void)*(char*)0; // no-warning
+ void *result = memcpy(a, 0, n); // expected-warning{{Null pointer argument in call to memory copy function}}
+ clang_analyzer_eval(result == a); // no-warning (above is fatal)
}
//===----------------------------------------------------------------------===
@@ -174,12 +174,11 @@
mempcpy(dst, src, 4); // no-warning
- if (mempcpy(dst, src, 4) != &dst[4]) {
- (void)*(char*)0; // no-warning
- }
+ clang_analyzer_eval(mempcpy(dst, src, 4) == &dst[4]); // expected-warning{{TRUE}}
- if (dst[0] != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ // If we actually model the copy, we can make this known.
+ // The important thing for now is that the old value has been invalidated.
+ clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}}
}
void mempcpy1 () {
@@ -260,8 +259,8 @@
void mempcpy_unknown_size_warn (size_t n) {
char a[4];
- if (mempcpy(a, 0, n) != a) // expected-warning{{Null pointer argument in call to memory copy function}}
- (void)*(char*)0; // no-warning
+ void *result = mempcpy(a, 0, n); // expected-warning{{Null pointer argument in call to memory copy function}}
+ clang_analyzer_eval(result == a); // no-warning (above is fatal)
}
void mempcpy_unknownable_size (char *src, float n) {
@@ -295,12 +294,11 @@
memmove(dst, src, 4); // no-warning
- if (memmove(dst, src, 4) != dst) {
- (void)*(char*)0; // no-warning
- }
+ clang_analyzer_eval(memmove(dst, src, 4) == dst); // expected-warning{{TRUE}}
- if (dst[0] != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ // If we actually model the copy, we can make this known.
+ // The important thing for now is that the old value has been invalidated.
+ clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}}
}
void memmove1 () {
@@ -327,7 +325,7 @@
// __builtin_bcmp is not defined with const in Builtins.def.
int bcmp(/*const*/ void *s1, /*const*/ void *s2, size_t n);
#define memcmp bcmp
-
+//
#else /* VARIANT */
#define memcmp BUILTIN(memcmp)
@@ -360,34 +358,32 @@
void memcmp3 () {
char a[] = {1, 2, 3, 4};
- if (memcmp(a, a, 4))
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(memcmp(a, a, 4) == 0); // expected-warning{{TRUE}}
}
void memcmp4 (char *input) {
char a[] = {1, 2, 3, 4};
- if (memcmp(a, input, 4))
- (void)*(char*)0; // expected-warning{{null}}
+ clang_analyzer_eval(memcmp(a, input, 4) == 0); // expected-warning{{UNKNOWN}}
}
void memcmp5 (char *input) {
char a[] = {1, 2, 3, 4};
- if (memcmp(a, 0, 0)) // no-warning
- (void)*(char*)0; // no-warning
- if (memcmp(0, a, 0)) // no-warning
- (void)*(char*)0; // no-warning
- if (memcmp(a, input, 0)) // no-warning
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(memcmp(a, 0, 0) == 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(memcmp(0, a, 0) == 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(memcmp(a, input, 0) == 0); // expected-warning{{TRUE}}
}
void memcmp6 (char *a, char *b, size_t n) {
int result = memcmp(a, b, n);
if (result != 0)
- return;
- if (n == 0)
- (void)*(char*)0; // expected-warning{{null}}
+ clang_analyzer_eval(n != 0); // expected-warning{{TRUE}}
+ // else
+ // analyzer_assert_unknown(n == 0);
+
+ // We can't do the above comparison because n has already been constrained.
+ // On one path n == 0, on the other n != 0.
}
int memcmp7 (char *a, size_t x, size_t y, size_t n) {
@@ -411,8 +407,9 @@
bcopy(src, dst, 4); // no-warning
- if (dst[0] != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ // If we actually model the copy, we can make this known.
+ // The important thing for now is that the old value has been invalidated.
+ clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}}
}
void bcopy1 () {
Modified: cfe/branches/tooling/test/Analysis/constant-folding.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/constant-folding.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/constant-folding.c (original)
+++ cfe/branches/tooling/test/Analysis/constant-folding.c Mon May 21 03:15:06 2012
@@ -1,7 +1,6 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s
-// Trigger a warning if the analyzer reaches this point in the control flow.
-#define WARN ((void)*(char*)0)
+void clang_analyzer_eval(int);
// There should be no warnings unless otherwise indicated.
@@ -9,73 +8,71 @@
// Sema can already catch the simple comparison a==a,
// since that's usually a logic error (and not path-dependent).
int b = a;
- if (!(b==a)) WARN; // expected-warning{{never executed}}
- if (!(b>=a)) WARN; // expected-warning{{never executed}}
- if (!(b<=a)) WARN; // expected-warning{{never executed}}
- if (b!=a) WARN; // expected-warning{{never executed}}
- if (b>a) WARN; // expected-warning{{never executed}}
- if (b<a) WARN; // expected-warning{{never executed}}
+ clang_analyzer_eval(b == a); // expected-warning{{TRUE}}
+ clang_analyzer_eval(b >= a); // expected-warning{{TRUE}}
+ clang_analyzer_eval(b <= a); // expected-warning{{TRUE}}
+ clang_analyzer_eval(b != a); // expected-warning{{FALSE}}
+ clang_analyzer_eval(b > a); // expected-warning{{FALSE}}
+ clang_analyzer_eval(b < a); // expected-warning{{FALSE}}
}
void testSelfOperations (int a) {
- if ((a|a) != a) WARN; // expected-warning{{never executed}}
- if ((a&a) != a) WARN; // expected-warning{{never executed}}
- if ((a^a) != 0) WARN; // expected-warning{{never executed}}
- if ((a-a) != 0) WARN; // expected-warning{{never executed}}
+ clang_analyzer_eval((a|a) == a); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a&a) == a); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a^a) == 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a-a) == 0); // expected-warning{{TRUE}}
}
void testIdempotent (int a) {
- if ((a*1) != a) WARN; // expected-warning{{never executed}}
- if ((a/1) != a) WARN; // expected-warning{{never executed}}
- if ((a+0) != a) WARN; // expected-warning{{never executed}}
- if ((a-0) != a) WARN; // expected-warning{{never executed}}
- if ((a<<0) != a) WARN; // expected-warning{{never executed}}
- if ((a>>0) != a) WARN; // expected-warning{{never executed}}
- if ((a^0) != a) WARN; // expected-warning{{never executed}}
- if ((a&(~0)) != a) WARN; // expected-warning{{never executed}}
- if ((a|0) != a) WARN; // expected-warning{{never executed}}
+ clang_analyzer_eval((a*1) == a); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a/1) == a); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a+0) == a); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a-0) == a); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a<<0) == a); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a>>0) == a); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a^0) == a); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a&(~0)) == a); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a|0) == a); // expected-warning{{TRUE}}
}
void testReductionToConstant (int a) {
- if ((a*0) != 0) WARN; // expected-warning{{never executed}}
- if ((a&0) != 0) WARN; // expected-warning{{never executed}}
- if ((a|(~0)) != (~0)) WARN; // expected-warning{{never executed}}
+ clang_analyzer_eval((a*0) == 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a&0) == 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval((a|(~0)) == (~0)); // expected-warning{{TRUE}}
}
void testSymmetricIntSymOperations (int a) {
- if ((2+a) != (a+2)) WARN; // expected-warning{{never executed}}
- if ((2*a) != (a*2)) WARN; // expected-warning{{never executed}}
- if ((2&a) != (a&2)) WARN; // expected-warning{{never executed}}
- if ((2^a) != (a^2)) WARN; // expected-warning{{never executed}}
- if ((2|a) != (a|2)) WARN; // expected-warning{{never executed}}
+ clang_analyzer_eval((2+a) == (a+2)); // expected-warning{{TRUE}}
+ clang_analyzer_eval((2*a) == (a*2)); // expected-warning{{TRUE}}
+ clang_analyzer_eval((2&a) == (a&2)); // expected-warning{{TRUE}}
+ clang_analyzer_eval((2^a) == (a^2)); // expected-warning{{TRUE}}
+ clang_analyzer_eval((2|a) == (a|2)); // expected-warning{{TRUE}}
}
void testAsymmetricIntSymOperations (int a) {
- if (((~0) >> a) != (~0)) WARN; // expected-warning{{never executed}}
- if ((0 >> a) != 0) WARN; // expected-warning{{never executed}}
- if ((0 << a) != 0) WARN; // expected-warning{{never executed}}
+ clang_analyzer_eval(((~0) >> a) == (~0)); // expected-warning{{TRUE}}
+ clang_analyzer_eval((0 >> a) == 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval((0 << a) == 0); // expected-warning{{TRUE}}
// Unsigned right shift shifts in zeroes.
- if ((((unsigned)(~0)) >> ((unsigned) a)) != ((unsigned)(~0)))
- WARN; // expected-warning{{}}
+ clang_analyzer_eval(((~0U) >> a) != (~0U)); // expected-warning{{UNKNOWN}}
}
void testLocations (char *a) {
char *b = a;
- if (!(b==a)) WARN; // expected-warning{{never executed}}
- if (!(b>=a)) WARN; // expected-warning{{never executed}}
- if (!(b<=a)) WARN; // expected-warning{{never executed}}
- if (b!=a) WARN; // expected-warning{{never executed}}
- if (b>a) WARN; // expected-warning{{never executed}}
- if (b<a) WARN; // expected-warning{{never executed}}
- if (b-a) WARN; // expected-warning{{never executed}}
+ clang_analyzer_eval(b == a); // expected-warning{{TRUE}}
+ clang_analyzer_eval(b >= a); // expected-warning{{TRUE}}
+ clang_analyzer_eval(b <= a); // expected-warning{{TRUE}}
+ clang_analyzer_eval(b != a); // expected-warning{{FALSE}}
+ clang_analyzer_eval(b > a); // expected-warning{{FALSE}}
+ clang_analyzer_eval(b < a); // expected-warning{{FALSE}}
}
void testMixedTypeComparisons (char a, unsigned long b) {
if (a != 0) return;
if (b != 0x100) return;
- if (a > b) WARN; // expected-warning{{never executed}}
- if (b < a) WARN; // expected-warning{{never executed}}
- if (a == b) WARN; // expected-warning{{never executed}}
+ clang_analyzer_eval(a <= b); // expected-warning{{TRUE}}
+ clang_analyzer_eval(b >= a); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a != b); // expected-warning{{TRUE}}
}
Modified: cfe/branches/tooling/test/Analysis/dead-stores.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/dead-stores.m?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/dead-stores.m (original)
+++ cfe/branches/tooling/test/Analysis/dead-stores.m Mon May 21 03:15:06 2012
@@ -88,3 +88,23 @@
RDar10591355 *p = rdar10591355_aux();
^{ (void) p.x; }();
}
+
+ at interface Radar11059352_1 {
+ at private
+ int *_pathString;
+}
+ at property int *pathString;
+ at end
+ at interface Radar11059352 {
+ at private
+Radar11059352_1 *_Path;
+}
+ at end
+ at implementation Radar11059352
+
+- (int*)usePath {
+ Radar11059352_1 *xxxxx = _Path; // no warning
+ int *wp = xxxxx.pathString;
+ return wp;
+}
+ at end
Modified: cfe/branches/tooling/test/Analysis/global-region-invalidation.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/global-region-invalidation.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/global-region-invalidation.c (original)
+++ cfe/branches/tooling/test/Analysis/global-region-invalidation.c Mon May 21 03:15:06 2012
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -disable-free -analyzer-eagerly-assume -analyzer-checker=core,deadcode,experimental.security.taint,debug.TaintTest -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -disable-free -analyzer-eagerly-assume -analyzer-checker=core,deadcode,experimental.security.taint,debug.TaintTest,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
// Note, we do need to include headers here, since the analyzer checks if the function declaration is located in a system header.
#include "system-header-simulator.h"
@@ -73,3 +75,12 @@
}
return 0;
}
+
+void testAnalyzerEvalIsPure() {
+ extern int someGlobal;
+ if (someGlobal == 0) {
+ clang_analyzer_eval(someGlobal == 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(someGlobal == 0); // expected-warning{{TRUE}}
+ }
+}
+
Modified: cfe/branches/tooling/test/Analysis/initializer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/initializer.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/initializer.cpp (original)
+++ cfe/branches/tooling/test/Analysis/initializer.cpp Mon May 21 03:15:06 2012
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -cfg-add-initializers -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store region -cfg-add-initializers -verify %s
+
+void clang_analyzer_eval(bool);
class A {
int x;
@@ -7,8 +9,5 @@
};
A::A() : x(0) {
- if (x != 0) {
- int *p = 0;
- *p = 0; // no-warning
- }
+ clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
}
Modified: cfe/branches/tooling/test/Analysis/malloc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc.c (original)
+++ cfe/branches/tooling/test/Analysis/malloc.c Mon May 21 03:15:06 2012
@@ -8,6 +8,8 @@
void *realloc(void *ptr, size_t size);
void *reallocf(void *ptr, size_t size);
void *calloc(size_t nmemb, size_t size);
+char *strdup(const char *s);
+char *strndup(const char *s, size_t n);
void myfoo(int *p);
void myfooint(int p);
@@ -243,6 +245,12 @@
x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
}
+void f8() {
+ char *x = (char*) malloc(4);
+ free(x);
+ char *y = strndup(x, 4); // expected-warning{{Use of memory after it is freed}}
+}
+
void f7_realloc() {
char *x = (char*) malloc(4);
realloc(x,0);
@@ -653,10 +661,6 @@
}
// Test various allocation/deallocation functions.
-
-char *strdup(const char *s);
-char *strndup(const char *s, size_t n);
-
void testStrdup(const char *s, unsigned validIndex) {
char *s2 = strdup(s);
s2[validIndex + 1] = 'b';// expected-warning {{Memory is never released; potential leak}}
Modified: cfe/branches/tooling/test/Analysis/method-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/method-call.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/method-call.cpp (original)
+++ cfe/branches/tooling/test/Analysis/method-call.cpp Mon May 21 03:15:06 2012
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-inline-call -analyzer-store region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -analyzer-store region -verify %s
// XFAIL: *
+void clang_analyzer_eval(bool);
+
struct A {
int x;
A(int a) { x = a; }
@@ -9,33 +11,15 @@
void f1() {
A x(3);
- if (x.getx() == 3) {
- int *p = 0;
- *p = 3; // expected-warning{{Dereference of null pointer}}
- } else {
- int *p = 0;
- *p = 3; // no-warning
- }
+ clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}}
}
void f2() {
const A &x = A(3);
- if (x.getx() == 3) {
- int *p = 0;
- *p = 3; // expected-warning{{Dereference of null pointer}}
- } else {
- int *p = 0;
- *p = 3; // no-warning
- }
+ clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}}
}
void f3() {
const A &x = (A)3;
- if (x.getx() == 3) {
- int *p = 0;
- *p = 3; // expected-warning{{Dereference of null pointer}}
- } else {
- int *p = 0;
- *p = 3; // no-warning
- }
+ clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}}
}
Modified: cfe/branches/tooling/test/Analysis/outofbound-notwork.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/outofbound-notwork.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/outofbound-notwork.c (original)
+++ cfe/branches/tooling/test/Analysis/outofbound-notwork.c Mon May 21 03:15:06 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,experimental.unix,experimental.security.ArrayBound -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,experimental.security.ArrayBound -analyzer-store=region -verify %s
// XFAIL: *
// Once we better handle modeling of sizes of VLAs, we can pull this back
Modified: cfe/branches/tooling/test/Analysis/ptr-arith.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/ptr-arith.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/ptr-arith.c (original)
+++ cfe/branches/tooling/test/Analysis/ptr-arith.c Mon May 21 03:15:06 2012
@@ -1,8 +1,7 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core.FixedAddr,experimental.core.PointerArithm,experimental.core.PointerSub -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core.FixedAddr,experimental.core.PointerArithm,experimental.core.PointerSub -analyzer-store=region -verify -triple i686-apple-darwin9 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core.FixedAddr,experimental.core.PointerArithm,experimental.core.PointerSub,debug.ExprInspection -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core.FixedAddr,experimental.core.PointerArithm,experimental.core.PointerSub,debug.ExprInspection -analyzer-store=region -verify -triple i686-apple-darwin9 %s
-// Used to trigger warnings for unreachable paths.
-#define WARN do { int a, b; int c = &b-&a; } while (0)
+void clang_analyzer_eval(int);
void f1() {
int a[10];
@@ -67,111 +66,48 @@
void null_operand(int *a) {
start:
// LHS is a label, RHS is NULL
- if (&&start == 0)
- WARN; // no-warning
- if (&&start < 0)
- WARN; // no-warning
- if (&&start <= 0)
- WARN; // no-warning
- if (!(&&start != 0))
- WARN; // no-warning
- if (!(&&start > 0))
- WARN; // no-warning
- if (!(&&start >= 0))
- WARN; // no-warning
- if (!(&&start - 0))
- WARN; // no-warning
+ clang_analyzer_eval(&&start != 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(&&start >= 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(&&start > 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval((&&start - 0) != 0); // expected-warning{{TRUE}}
// LHS is a non-symbolic value, RHS is NULL
- if (&a == 0)
- WARN; // no-warning
- if (&a < 0)
- WARN; // no-warning
- if (&a <= 0)
- WARN; // no-warning
- if (!(&a != 0))
- WARN; // no-warning
- if (!(&a > 0))
- WARN; // no-warning
- if (!(&a >= 0))
- WARN; // no-warning
-
- if (!(&a - 0)) // expected-warning{{Pointer arithmetic done on non-array variables}}
- WARN; // no-warning
+ clang_analyzer_eval(&a != 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(&a >= 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(&a > 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval((&a - 0) != 0); // expected-warning{{TRUE}} expected-warning{{Pointer arithmetic done on non-array variables}}
// LHS is NULL, RHS is non-symbolic
// The same code is used for labels and non-symbolic values.
- if (0 == &a)
- WARN; // no-warning
- if (0 > &a)
- WARN; // no-warning
- if (0 >= &a)
- WARN; // no-warning
- if (!(0 != &a))
- WARN; // no-warning
- if (!(0 < &a))
- WARN; // no-warning
- if (!(0 <= &a))
- WARN; // no-warning
+ clang_analyzer_eval(0 != &a); // expected-warning{{TRUE}}
+ clang_analyzer_eval(0 <= &a); // expected-warning{{TRUE}}
+ clang_analyzer_eval(0 < &a); // expected-warning{{TRUE}}
// LHS is a symbolic value, RHS is NULL
- if (a == 0)
- WARN; // expected-warning{{}}
- if (a < 0)
- WARN; // no-warning
- if (a <= 0)
- WARN; // expected-warning{{}}
- if (!(a != 0))
- WARN; // expected-warning{{}}
- if (!(a > 0))
- WARN; // expected-warning{{}}
- if (!(a >= 0))
- WARN; // no-warning
- if (!(a - 0))
- WARN; // expected-warning{{}}
+ clang_analyzer_eval(a != 0); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a >= 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a <= 0); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval((a - 0) != 0); // expected-warning{{UNKNOWN}}
// LHS is NULL, RHS is a symbolic value
- if (0 == a)
- WARN; // expected-warning{{}}
- if (0 > a)
- WARN; // no-warning
- if (0 >= a)
- WARN; // expected-warning{{}}
- if (!(0 != a))
- WARN; // expected-warning{{}}
- if (!(0 < a))
- WARN; // expected-warning{{}}
- if (!(0 <= a))
- WARN; // no-warning
+ clang_analyzer_eval(0 != a); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(0 <= a); // expected-warning{{TRUE}}
+ clang_analyzer_eval(0 < a); // expected-warning{{UNKNOWN}}
}
void const_locs() {
char *a = (char*)0x1000;
char *b = (char*)0x1100;
start:
- if (a==b)
- WARN; // no-warning
- if (!(a!=b))
- WARN; // no-warning
- if (a>b)
- WARN; // no-warning
- if (b<a)
- WARN; // no-warning
- if (a>=b)
- WARN; // no-warning
- if (b<=a)
- WARN; // no-warning
- if (b-a != 0x100)
- WARN; // no-warning
-
- if (&&start == a)
- WARN; // expected-warning{{}}
- if (a == &&start)
- WARN; // expected-warning{{}}
- if (&a == (char**)a)
- WARN; // expected-warning{{}}
- if ((char**)a == &a)
- WARN; // expected-warning{{}}
+ clang_analyzer_eval(a != b); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a < b); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a <= b); // expected-warning{{TRUE}}
+ clang_analyzer_eval((b-a) == 0x100); // expected-warning{{TRUE}}
+
+ clang_analyzer_eval(&&start == a); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a == &&start); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(&a == (char**)a); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval((char**)a == &a); // expected-warning{{UNKNOWN}}
}
void array_matching_types() {
@@ -179,20 +115,10 @@
int *a = &array[2];
int *b = &array[5];
- if (a==b)
- WARN; // no-warning
- if (!(a!=b))
- WARN; // no-warning
- if (a>b)
- WARN; // no-warning
- if (b<a)
- WARN; // no-warning
- if (a>=b)
- WARN; // no-warning
- if (b<=a)
- WARN; // no-warning
- if ((b-a) == 0)
- WARN; // no-warning
+ clang_analyzer_eval(a != b); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a < b); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a <= b); // expected-warning{{TRUE}}
+ clang_analyzer_eval((b-a) != 0); // expected-warning{{TRUE}}
}
// This takes a different code path than array_matching_types()
@@ -201,49 +127,22 @@
int *a = &array[2];
char *b = (char*)&array[5];
- if (a==b) // expected-warning{{comparison of distinct pointer types}}
- WARN; // no-warning
- if (!(a!=b)) // expected-warning{{comparison of distinct pointer types}}
- WARN; // no-warning
- if (a>b) // expected-warning{{comparison of distinct pointer types}}
- WARN; // no-warning
- if (b<a) // expected-warning{{comparison of distinct pointer types}}
- WARN; // no-warning
- if (a>=b) // expected-warning{{comparison of distinct pointer types}}
- WARN; // no-warning
- if (b<=a) // expected-warning{{comparison of distinct pointer types}}
- WARN; // no-warning
+ clang_analyzer_eval(a != b); // expected-warning{{TRUE}} expected-warning{{comparison of distinct pointer types}}
+ clang_analyzer_eval(a < b); // expected-warning{{TRUE}} expected-warning{{comparison of distinct pointer types}}
+ clang_analyzer_eval(a <= b); // expected-warning{{TRUE}} expected-warning{{comparison of distinct pointer types}}
}
struct test { int x; int y; };
void struct_fields() {
struct test a, b;
- if (&a.x == &a.y)
- WARN; // no-warning
- if (!(&a.x != &a.y))
- WARN; // no-warning
- if (&a.x > &a.y)
- WARN; // no-warning
- if (&a.y < &a.x)
- WARN; // no-warning
- if (&a.x >= &a.y)
- WARN; // no-warning
- if (&a.y <= &a.x)
- WARN; // no-warning
-
- if (&a.x == &b.x)
- WARN; // no-warning
- if (!(&a.x != &b.x))
- WARN; // no-warning
- if (&a.x > &b.x)
- WARN; // expected-warning{{}}
- if (&b.x < &a.x)
- WARN; // expected-warning{{}}
- if (&a.x >= &b.x)
- WARN; // expected-warning{{}}
- if (&b.x <= &a.x)
- WARN; // expected-warning{{}}
+ clang_analyzer_eval(&a.x != &a.y); // expected-warning{{TRUE}}
+ clang_analyzer_eval(&a.x < &a.y); // expected-warning{{TRUE}}
+ clang_analyzer_eval(&a.x <= &a.y); // expected-warning{{TRUE}}
+
+ clang_analyzer_eval(&a.x != &b.x); // expected-warning{{TRUE}}
+ clang_analyzer_eval(&a.x > &b.x); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(&a.x >= &b.x); // expected-warning{{UNKNOWN}}
}
void mixed_region_types() {
@@ -251,35 +150,17 @@
int array[2];
void *a = &array, *b = &s;
- if (&a == &b)
- WARN; // no-warning
- if (!(&a != &b))
- WARN; // no-warning
- if (&a > &b)
- WARN; // expected-warning{{}}
- if (&b < &a)
- WARN; // expected-warning{{}}
- if (&a >= &b)
- WARN; // expected-warning{{}}
- if (&b <= &a)
- WARN; // expected-warning{{}}
+ clang_analyzer_eval(&a != &b); // expected-warning{{TRUE}}
+ clang_analyzer_eval(&a > &b); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(&a >= &b); // expected-warning{{UNKNOWN}}
}
void symbolic_region(int *p) {
int a;
- if (&a == p)
- WARN; // no-warning
- if (&a != p)
- WARN; // expected-warning{{}}
- if (&a > p)
- WARN; // expected-warning{{}}
- if (&a < p)
- WARN; // expected-warning{{}}
- if (&a >= p)
- WARN; // expected-warning{{}}
- if (&a <= p)
- WARN; // expected-warning{{}}
+ clang_analyzer_eval(&a != p); // expected-warning{{TRUE}}
+ clang_analyzer_eval(&a > p); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(&a >= p); // expected-warning{{UNKNOWN}}
}
void PR7527 (int *p) {
Modified: cfe/branches/tooling/test/Analysis/reference.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/reference.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/reference.cpp (original)
+++ cfe/branches/tooling/test/Analysis/reference.cpp Mon May 21 03:15:06 2012
@@ -1,11 +1,10 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-null-dereference %s
-// XFAIL
typedef typeof(sizeof(int)) size_t;
void malloc (size_t);
void f1() {
- int const &i = 3; // <--- **FIXME** This is currently not being modeled correctly.
+ int const &i = 3;
int b = i;
int *p = 0;
Modified: cfe/branches/tooling/test/Analysis/string-fail.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/string-fail.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/string-fail.c (original)
+++ cfe/branches/tooling/test/Analysis/string-fail.c Mon May 21 03:15:06 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s
// XFAIL: *
// This file is for tests that may eventually go into string.c, or may be
@@ -32,6 +32,7 @@
#define NULL 0
typedef typeof(sizeof(int)) size_t;
+void clang_analyzer_eval(int);
//===----------------------------------------------------------------------===
// strnlen()
@@ -43,8 +44,7 @@
void strnlen_liveness(const char *x) {
if (strnlen(x, 10) < 5)
return;
- if (strnlen(x, 10) < 5)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strnlen(x, 10) < 5); // expected-warning{{FALSE}}
}
void strnlen_subregion() {
@@ -57,43 +57,43 @@
size_t a = strnlen(z.a, 10);
z.b[0] = 5;
size_t b = strnlen(z.a, 10);
- if (a == 0 && b != 0)
- (void)*(char*)0; // expected-warning{{never executed}}
+ if (a == 0)
+ clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
use_two_stringsn(&z);
size_t c = strnlen(z.a, 10);
- if (a == 0 && c != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ if (a == 0)
+ clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}}
}
extern void use_stringn(char *);
void strnlen_argument(char *x) {
size_t a = strnlen(x, 10);
size_t b = strnlen(x, 10);
- if (a == 0 && b != 0)
- (void)*(char*)0; // expected-warning{{never executed}}
+ if (a == 0)
+ clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
use_stringn(x);
size_t c = strnlen(x, 10);
- if (a == 0 && c != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ if (a == 0)
+ clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}}
}
extern char global_strn[];
void strnlen_global() {
size_t a = strnlen(global_strn, 10);
size_t b = strnlen(global_strn, 10);
- if (a == 0 && b != 0)
- (void)*(char*)0; // expected-warning{{never executed}}
+ if (a == 0)
+ clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
// Call a function with unknown effects, which should invalidate globals.
use_stringn(0);
size_t c = strnlen(global_strn, 10);
- if (a == 0 && c != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ if (a == 0)
+ clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}}
}
void strnlen_indirect(char *x) {
@@ -101,13 +101,13 @@
char *p = x;
char **p2 = &p;
size_t b = strnlen(x, 10);
- if (a == 0 && b != 0)
- (void)*(char*)0; // expected-warning{{never executed}}
+ if (a == 0)
+ clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
extern void use_stringn_ptr(char*const*);
use_stringn_ptr(p2);
size_t c = strnlen(x, 10);
- if (a == 0 && c != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ if (a == 0)
+ clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}}
}
Modified: cfe/branches/tooling/test/Analysis/string.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/string.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/string.c (original)
+++ cfe/branches/tooling/test/Analysis/string.c Mon May 21 03:15:06 2012
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=experimental.security.taint,core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=experimental.security.taint,core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
//===----------------------------------------------------------------------===
// Declarations
@@ -26,6 +26,9 @@
#define NULL 0
typedef typeof(sizeof(int)) size_t;
+
+void clang_analyzer_eval(int);
+
int scanf(const char *restrict format, ...);
//===----------------------------------------------------------------------===
@@ -36,23 +39,20 @@
size_t strlen(const char *s);
void strlen_constant0() {
- if (strlen("123") != 3)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strlen("123") == 3); // expected-warning{{TRUE}}
}
void strlen_constant1() {
const char *a = "123";
- if (strlen(a) != 3)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strlen(a) == 3); // expected-warning{{TRUE}}
}
void strlen_constant2(char x) {
char a[] = "123";
- if (strlen(a) != 3)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strlen(a) == 3); // expected-warning{{TRUE}}
+
a[0] = x;
- if (strlen(a) != 3)
- (void)*(char*)0; // expected-warning{{null}}
+ clang_analyzer_eval(strlen(a) == 3); // expected-warning{{UNKNOWN}}
}
size_t strlen_null() {
@@ -78,43 +78,46 @@
size_t a = strlen(z.a);
z.b[0] = 5;
size_t b = strlen(z.a);
- if (a == 0 && b != 0)
- (void)*(char*)0; // expected-warning{{never executed}}
+ if (a == 0)
+ clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
use_two_strings(&z);
size_t c = strlen(z.a);
- if (a == 0 && c != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ if (a == 0)
+ clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}}
}
extern void use_string(char *);
void strlen_argument(char *x) {
size_t a = strlen(x);
size_t b = strlen(x);
- if (a == 0 && b != 0)
- (void)*(char*)0; // expected-warning{{never executed}}
+ if (a == 0)
+ clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
use_string(x);
size_t c = strlen(x);
- if (a == 0 && c != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ if (a == 0)
+ clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}}
}
extern char global_str[];
void strlen_global() {
size_t a = strlen(global_str);
size_t b = strlen(global_str);
- if (a == 0 && b != 0)
- (void)*(char*)0; // expected-warning{{never executed}}
+ if (a == 0) {
+ clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
+ // Make sure clang_analyzer_eval does not invalidate globals.
+ clang_analyzer_eval(strlen(global_str) == 0); // expected-warning{{TRUE}}
+ }
// Call a function with unknown effects, which should invalidate globals.
use_string(0);
size_t c = strlen(global_str);
- if (a == 0 && c != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ if (a == 0)
+ clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}}
}
void strlen_indirect(char *x) {
@@ -122,15 +125,15 @@
char *p = x;
char **p2 = &p;
size_t b = strlen(x);
- if (a == 0 && b != 0)
- (void)*(char*)0; // expected-warning{{never executed}}
+ if (a == 0)
+ clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
extern void use_string_ptr(char*const*);
use_string_ptr(p2);
size_t c = strlen(x);
- if (a == 0 && c != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ if (a == 0)
+ clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}}
}
void strlen_indirect2(char *x) {
@@ -141,15 +144,14 @@
use_string_ptr2(p2);
size_t c = strlen(x);
- if (a == 0 && c != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ if (a == 0)
+ clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}}
}
void strlen_liveness(const char *x) {
if (strlen(x) < 5)
return;
- if (strlen(x) < 5)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strlen(x) < 5); // expected-warning{{FALSE}}
}
//===----------------------------------------------------------------------===
@@ -159,43 +161,35 @@
size_t strnlen(const char *s, size_t maxlen);
void strnlen_constant0() {
- if (strnlen("123", 10) != 3)
- (void)*(char*)0; // expected-warning{{never executed}}
+ clang_analyzer_eval(strnlen("123", 10) == 3); // expected-warning{{TRUE}}
}
void strnlen_constant1() {
const char *a = "123";
- if (strnlen(a, 10) != 3)
- (void)*(char*)0; // expected-warning{{never executed}}
+ clang_analyzer_eval(strnlen(a, 10) == 3); // expected-warning{{TRUE}}
}
void strnlen_constant2(char x) {
char a[] = "123";
- if (strnlen(a, 10) != 3)
- (void)*(char*)0; // expected-warning{{never executed}}
+ clang_analyzer_eval(strnlen(a, 10) == 3); // expected-warning{{TRUE}}
a[0] = x;
- if (strnlen(a, 10) != 3)
- (void)*(char*)0; // expected-warning{{null}}
+ clang_analyzer_eval(strnlen(a, 10) == 3); // expected-warning{{UNKNOWN}}
}
void strnlen_constant4() {
- if (strnlen("123456", 3) != 3)
- (void)*(char*)0; // expected-warning{{never executed}}
+ clang_analyzer_eval(strnlen("123456", 3) == 3); // expected-warning{{TRUE}}
}
void strnlen_constant5() {
const char *a = "123456";
- if (strnlen(a, 3) != 3)
- (void)*(char*)0; // expected-warning{{never executed}}
+ clang_analyzer_eval(strnlen(a, 3) == 3); // expected-warning{{TRUE}}
}
void strnlen_constant6(char x) {
char a[] = "123456";
- if (strnlen(a, 3) != 3)
- (void)*(char*)0; // expected-warning{{never executed}}
+ clang_analyzer_eval(strnlen(a, 3) == 3); // expected-warning{{TRUE}}
a[0] = x;
- if (strnlen(a, 3) != 3)
- (void)*(char*)0; // expected-warning{{null}}
+ clang_analyzer_eval(strnlen(a, 3) == 3); // expected-warning{{UNKNOWN}}
}
size_t strnlen_null() {
@@ -212,10 +206,8 @@
}
void strnlen_zero() {
- if (strnlen("abc", 0) != 0)
- (void)*(char*)0; // expected-warning{{never executed}}
- if (strnlen(NULL, 0) != 0) // no-warning
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strnlen("abc", 0) == 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(strnlen(NULL, 0) == 0); // expected-warning{{TRUE}}
}
size_t strnlen_compound_literal() {
@@ -230,40 +222,26 @@
}
void strnlen_is_not_strlen(char *x) {
- if (strnlen(x, 10) != strlen(x))
- (void)*(char*)0; // expected-warning{{null}}
+ clang_analyzer_eval(strnlen(x, 10) == strlen(x)); // expected-warning{{UNKNOWN}}
}
void strnlen_at_limit(char *x) {
size_t len = strnlen(x, 10);
- if (len > 10)
- (void)*(char*)0; // expected-warning{{never executed}}
- if (len == 10)
- (void)*(char*)0; // expected-warning{{null}}
-}
-
-void strnlen_less_than_limit(char *x) {
- size_t len = strnlen(x, 10);
- if (len > 10)
- (void)*(char*)0; // expected-warning{{never executed}}
- if (len < 10)
- (void)*(char*)0; // expected-warning{{null}}
+ clang_analyzer_eval(len <= 10); // expected-warning{{TRUE}}
+ clang_analyzer_eval(len == 10); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(len < 10); // expected-warning{{UNKNOWN}}
}
void strnlen_at_actual(size_t limit) {
size_t len = strnlen("abc", limit);
- if (len > 3)
- (void)*(char*)0; // expected-warning{{never executed}}
- if (len == 3)
- (void)*(char*)0; // expected-warning{{null}}
-}
-
-void strnlen_less_than_actual(size_t limit) {
- size_t len = strnlen("abc", limit);
- if (len > 3)
- (void)*(char*)0; // expected-warning{{never executed}}
- if (len < 3)
- (void)*(char*)0; // expected-warning{{null}}
+ clang_analyzer_eval(len <= 3); // expected-warning{{TRUE}}
+ // This is due to eager assertion in strnlen.
+ if (limit == 0) {
+ clang_analyzer_eval(len == 0); // expected-warning{{TRUE}}
+ } else {
+ clang_analyzer_eval(len == 3); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(len < 3); // expected-warning{{UNKNOWN}}
+ }
}
//===----------------------------------------------------------------------===
@@ -304,14 +282,9 @@
void strcpy_effects(char *x, char *y) {
char a = x[0];
- if (strcpy(x, y) != x)
- (void)*(char*)0; // no-warning
-
- if (strlen(x) != strlen(y))
- (void)*(char*)0; // no-warning
-
- if (a != x[0])
- (void)*(char*)0; // expected-warning{{null}}
+ clang_analyzer_eval(strcpy(x, y) == x); // expected-warning{{TRUE}}
+ clang_analyzer_eval(strlen(x) == strlen(y)); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a == x[0]); // expected-warning{{UNKNOWN}}
}
void strcpy_overflow(char *y) {
@@ -348,14 +321,9 @@
void stpcpy_effect(char *x, char *y) {
char a = x[0];
- if (stpcpy(x, y) != &x[strlen(y)])
- (void)*(char*)0; // no-warning
-
- if (strlen(x) != strlen(y))
- (void)*(char*)0; // no-warning
-
- if (a != x[0])
- (void)*(char*)0; // expected-warning{{null}}
+ clang_analyzer_eval(stpcpy(x, y) == &x[strlen(y)]); // expected-warning{{TRUE}}
+ clang_analyzer_eval(strlen(x) == strlen(y)); // expected-warning{{TRUE}}
+ clang_analyzer_eval(a == x[0]); // expected-warning{{UNKNOWN}}
}
void stpcpy_overflow(char *y) {
@@ -409,11 +377,8 @@
if (strlen(y) != 4)
return;
- if (strcat(x, y) != x)
- (void)*(char*)0; // no-warning
-
- if ((int)strlen(x) != (orig_len + strlen(y)))
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcat(x, y) == x); // expected-warning{{TRUE}}
+ clang_analyzer_eval((int)strlen(x) == (orig_len + strlen(y))); // expected-warning{{TRUE}}
}
void strcat_overflow_0(char *y) {
@@ -442,29 +407,25 @@
void strcat_symbolic_dst_length(char *dst) {
strcat(dst, "1234");
- if (strlen(dst) < 4)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}}
}
void strcat_symbolic_src_length(char *src) {
char dst[8] = "1234";
strcat(dst, src);
- if (strlen(dst) < 4)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}}
}
void strcat_symbolic_dst_length_taint(char *dst) {
scanf("%s", dst); // Taint data.
strcat(dst, "1234");
- if (strlen(dst) < 4)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}}
}
void strcat_unknown_src_length(char *src, int offset) {
char dst[8] = "1234";
strcat(dst, &src[offset]);
- if (strlen(dst) < 4)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}}
}
// There is no strcat_unknown_dst_length because if we can't get a symbolic
@@ -513,14 +474,9 @@
void strncpy_effects(char *x, char *y) {
char a = x[0];
- if (strncpy(x, y, 5) != x)
- (void)*(char*)0; // no-warning
-
- if (strlen(x) != strlen(y))
- (void)*(char*)0; // expected-warning{{null}}
-
- if (a != x[0])
- (void)*(char*)0; // expected-warning{{null}}
+ clang_analyzer_eval(strncpy(x, y, 5) == x); // expected-warning{{TRUE}}
+ clang_analyzer_eval(strlen(x) == strlen(y)); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(a == x[0]); // expected-warning{{UNKNOWN}}
}
void strncpy_overflow(char *y) {
@@ -562,8 +518,7 @@
// strncpy does not null-terminate, so we have no idea what the strlen is
// after this.
- if (strlen(x) > 4)
- (void)*(int*)0; // expected-warning{{null}}
+ clang_analyzer_eval(strlen(x) > 4); // expected-warning{{UNKNOWN}}
}
void strncpy_exactly_matching_buffer2(char *y) {
@@ -574,8 +529,7 @@
strncpy(x, y, 4); // no-warning
// This time, we know that y fits in x anyway.
- if (strlen(x) > 3)
- (void)*(int*)0; // no-warning
+ clang_analyzer_eval(strlen(x) <= 3); // expected-warning{{TRUE}}
}
void strncpy_zero(char *src) {
@@ -628,11 +582,8 @@
if (strlen(y) != 4)
return;
- if (strncat(x, y, strlen(y)) != x)
- (void)*(char*)0; // no-warning
-
- if (strlen(x) != orig_len + strlen(y))
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncat(x, y, strlen(y)) == x); // expected-warning{{TRUE}}
+ clang_analyzer_eval(strlen(x) == (orig_len + strlen(y))); // expected-warning{{TRUE}}
}
void strncat_overflow_0(char *y) {
@@ -672,15 +623,13 @@
void strncat_symbolic_dst_length(char *dst) {
strncat(dst, "1234", 5);
- if (strlen(dst) < 4)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}}
}
void strncat_symbolic_src_length(char *src) {
char dst[8] = "1234";
strncat(dst, src, 3);
- if (strlen(dst) < 4)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}}
char dst2[8] = "1234";
strncat(dst2, src, 4); // expected-warning{{Size argument is greater than the free space in the destination buffer}}
@@ -689,8 +638,7 @@
void strncat_unknown_src_length(char *src, int offset) {
char dst[8] = "1234";
strncat(dst, &src[offset], 3);
- if (strlen(dst) < 4)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}}
char dst2[8] = "1234";
strncat(dst2, &src[offset], 4); // expected-warning{{Size argument is greater than the free space in the destination buffer}}
@@ -703,20 +651,18 @@
char dst[6] = "1234";
char src[] = "567";
strncat(dst, src, limit); // no-warning
- if (strlen(dst) < 4)
- (void)*(char*)0; // no-warning
- if (strlen(dst) == 4)
- (void)*(char*)0; // expected-warning{{null}}
+
+ clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}}
+ clang_analyzer_eval(strlen(dst) == 4); // expected-warning{{UNKNOWN}}
}
void strncat_unknown_limit(float limit) {
char dst[6] = "1234";
char src[] = "567";
strncat(dst, src, (size_t)limit); // no-warning
- if (strlen(dst) < 4)
- (void)*(char*)0; // no-warning
- if (strlen(dst) == 4)
- (void)*(char*)0; // expected-warning{{null}}
+
+ clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}}
+ clang_analyzer_eval(strlen(dst) == 4); // expected-warning{{UNKNOWN}}
}
void strncat_too_big(char *dst, char *src) {
@@ -746,41 +692,35 @@
int strcmp(const char * s1, const char * s2);
void strcmp_constant0() {
- if (strcmp("123", "123") != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcmp("123", "123") == 0); // expected-warning{{TRUE}}
}
void strcmp_constant_and_var_0() {
char *x = "123";
- if (strcmp(x, "123") != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcmp(x, "123") == 0); // expected-warning{{TRUE}}
}
void strcmp_constant_and_var_1() {
char *x = "123";
- if (strcmp("123", x) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcmp("123", x) == 0); // expected-warning{{TRUE}}
}
void strcmp_0() {
char *x = "123";
char *y = "123";
- if (strcmp(x, y) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcmp(x, y) == 0); // expected-warning{{TRUE}}
}
void strcmp_1() {
char *x = "234";
char *y = "123";
- if (strcmp(x, y) != 1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcmp(x, y) == 1); // expected-warning{{TRUE}}
}
void strcmp_2() {
char *x = "123";
char *y = "234";
- if (strcmp(x, y) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}}
}
void strcmp_null_0() {
@@ -798,39 +738,33 @@
void strcmp_diff_length_0() {
char *x = "12345";
char *y = "234";
- if (strcmp(x, y) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}}
}
void strcmp_diff_length_1() {
char *x = "123";
char *y = "23456";
- if (strcmp(x, y) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}}
}
void strcmp_diff_length_2() {
char *x = "12345";
char *y = "123";
- if (strcmp(x, y) != 1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcmp(x, y) == 1); // expected-warning{{TRUE}}
}
void strcmp_diff_length_3() {
char *x = "123";
char *y = "12345";
- if (strcmp(x, y) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}}
}
void strcmp_embedded_null () {
- if (strcmp("\0z", "\0y") != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcmp("\0z", "\0y") == 0); // expected-warning{{TRUE}}
}
void strcmp_unknown_arg (char *unknown) {
- if (strcmp(unknown, unknown) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcmp(unknown, unknown) == 0); // expected-warning{{TRUE}}
}
//===----------------------------------------------------------------------===
@@ -841,41 +775,35 @@
int strncmp(const char *s1, const char *s2, size_t n);
void strncmp_constant0() {
- if (strncmp("123", "123", 3) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncmp("123", "123", 3) == 0); // expected-warning{{TRUE}}
}
void strncmp_constant_and_var_0() {
char *x = "123";
- if (strncmp(x, "123", 3) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncmp(x, "123", 3) == 0); // expected-warning{{TRUE}}
}
void strncmp_constant_and_var_1() {
char *x = "123";
- if (strncmp("123", x, 3) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncmp("123", x, 3) == 0); // expected-warning{{TRUE}}
}
void strncmp_0() {
char *x = "123";
char *y = "123";
- if (strncmp(x, y, 3) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncmp(x, y, 3) == 0); // expected-warning{{TRUE}}
}
void strncmp_1() {
char *x = "234";
char *y = "123";
- if (strncmp(x, y, 3) != 1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncmp(x, y, 3) == 1); // expected-warning{{TRUE}}
}
void strncmp_2() {
char *x = "123";
char *y = "234";
- if (strncmp(x, y, 3) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncmp(x, y, 3) == -1); // expected-warning{{TRUE}}
}
void strncmp_null_0() {
@@ -893,55 +821,47 @@
void strncmp_diff_length_0() {
char *x = "12345";
char *y = "234";
- if (strncmp(x, y, 5) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}}
}
void strncmp_diff_length_1() {
char *x = "123";
char *y = "23456";
- if (strncmp(x, y, 5) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}}
}
void strncmp_diff_length_2() {
char *x = "12345";
char *y = "123";
- if (strncmp(x, y, 5) != 1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncmp(x, y, 5) == 1); // expected-warning{{TRUE}}
}
void strncmp_diff_length_3() {
char *x = "123";
char *y = "12345";
- if (strncmp(x, y, 5) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}}
}
void strncmp_diff_length_4() {
char *x = "123";
char *y = "12345";
- if (strncmp(x, y, 3) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncmp(x, y, 3) == 0); // expected-warning{{TRUE}}
}
void strncmp_diff_length_5() {
char *x = "012";
char *y = "12345";
- if (strncmp(x, y, 3) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncmp(x, y, 3) == -1); // expected-warning{{TRUE}}
}
void strncmp_diff_length_6() {
char *x = "234";
char *y = "12345";
- if (strncmp(x, y, 3) != 1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncmp(x, y, 3) == 1); // expected-warning{{TRUE}}
}
void strncmp_embedded_null () {
- if (strncmp("ab\0zz", "ab\0yy", 4) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncmp("ab\0zz", "ab\0yy", 4) == 0); // expected-warning{{TRUE}}
}
//===----------------------------------------------------------------------===
@@ -952,41 +872,35 @@
int strcasecmp(const char *s1, const char *s2);
void strcasecmp_constant0() {
- if (strcasecmp("abc", "Abc") != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcasecmp("abc", "Abc") == 0); // expected-warning{{TRUE}}
}
void strcasecmp_constant_and_var_0() {
char *x = "abc";
- if (strcasecmp(x, "Abc") != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcasecmp(x, "Abc") == 0); // expected-warning{{TRUE}}
}
void strcasecmp_constant_and_var_1() {
char *x = "abc";
- if (strcasecmp("Abc", x) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcasecmp("Abc", x) == 0); // expected-warning{{TRUE}}
}
void strcasecmp_0() {
char *x = "abc";
char *y = "Abc";
- if (strcasecmp(x, y) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcasecmp(x, y) == 0); // expected-warning{{TRUE}}
}
void strcasecmp_1() {
char *x = "Bcd";
char *y = "abc";
- if (strcasecmp(x, y) != 1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcasecmp(x, y) == 1); // expected-warning{{TRUE}}
}
void strcasecmp_2() {
char *x = "abc";
char *y = "Bcd";
- if (strcasecmp(x, y) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcasecmp(x, y) == -1); // expected-warning{{TRUE}}
}
void strcasecmp_null_0() {
@@ -1004,34 +918,29 @@
void strcasecmp_diff_length_0() {
char *x = "abcde";
char *y = "aBd";
- if (strcasecmp(x, y) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcasecmp(x, y) == -1); // expected-warning{{TRUE}}
}
void strcasecmp_diff_length_1() {
char *x = "abc";
char *y = "aBdef";
- if (strcasecmp(x, y) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcasecmp(x, y) == -1); // expected-warning{{TRUE}}
}
void strcasecmp_diff_length_2() {
char *x = "aBcDe";
char *y = "abc";
- if (strcasecmp(x, y) != 1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcasecmp(x, y) == 1); // expected-warning{{TRUE}}
}
void strcasecmp_diff_length_3() {
char *x = "aBc";
char *y = "abcde";
- if (strcasecmp(x, y) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcasecmp(x, y) == -1); // expected-warning{{TRUE}}
}
void strcasecmp_embedded_null () {
- if (strcasecmp("ab\0zz", "ab\0yy") != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strcasecmp("ab\0zz", "ab\0yy") == 0); // expected-warning{{TRUE}}
}
//===----------------------------------------------------------------------===
@@ -1042,41 +951,35 @@
int strncasecmp(const char *s1, const char *s2, size_t n);
void strncasecmp_constant0() {
- if (strncasecmp("abc", "Abc", 3) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncasecmp("abc", "Abc", 3) == 0); // expected-warning{{TRUE}}
}
void strncasecmp_constant_and_var_0() {
char *x = "abc";
- if (strncasecmp(x, "Abc", 3) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncasecmp(x, "Abc", 3) == 0); // expected-warning{{TRUE}}
}
void strncasecmp_constant_and_var_1() {
char *x = "abc";
- if (strncasecmp("Abc", x, 3) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncasecmp("Abc", x, 3) == 0); // expected-warning{{TRUE}}
}
void strncasecmp_0() {
char *x = "abc";
char *y = "Abc";
- if (strncasecmp(x, y, 3) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncasecmp(x, y, 3) == 0); // expected-warning{{TRUE}}
}
void strncasecmp_1() {
char *x = "Bcd";
char *y = "abc";
- if (strncasecmp(x, y, 3) != 1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncasecmp(x, y, 3) == 1); // expected-warning{{TRUE}}
}
void strncasecmp_2() {
char *x = "abc";
char *y = "Bcd";
- if (strncasecmp(x, y, 3) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncasecmp(x, y, 3) == -1); // expected-warning{{TRUE}}
}
void strncasecmp_null_0() {
@@ -1094,85 +997,45 @@
void strncasecmp_diff_length_0() {
char *x = "abcde";
char *y = "aBd";
- if (strncasecmp(x, y, 5) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncasecmp(x, y, 5) == -1); // expected-warning{{TRUE}}
}
void strncasecmp_diff_length_1() {
char *x = "abc";
char *y = "aBdef";
- if (strncasecmp(x, y, 5) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncasecmp(x, y, 5) == -1); // expected-warning{{TRUE}}
}
void strncasecmp_diff_length_2() {
char *x = "aBcDe";
char *y = "abc";
- if (strncasecmp(x, y, 5) != 1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncasecmp(x, y, 5) == 1); // expected-warning{{TRUE}}
}
void strncasecmp_diff_length_3() {
char *x = "aBc";
char *y = "abcde";
- if (strncasecmp(x, y, 5) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncasecmp(x, y, 5) == -1); // expected-warning{{TRUE}}
}
void strncasecmp_diff_length_4() {
char *x = "abcde";
char *y = "aBc";
- if (strncasecmp(x, y, 3) != 0)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncasecmp(x, y, 3) == 0); // expected-warning{{TRUE}}
}
void strncasecmp_diff_length_5() {
char *x = "abcde";
char *y = "aBd";
- if (strncasecmp(x, y, 3) != -1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncasecmp(x, y, 3) == -1); // expected-warning{{TRUE}}
}
void strncasecmp_diff_length_6() {
char *x = "aBDe";
char *y = "abc";
- if (strncasecmp(x, y, 3) != 1)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strncasecmp(x, y, 3) == 1); // expected-warning{{TRUE}}
}
void strncasecmp_embedded_null () {
- if (strncasecmp("ab\0zz", "ab\0yy", 4) != 0)
- (void)*(char*)0; // no-warning
-}
-
-//===----------------------------------------------------------------------===
-// Miscellaneous extras.
-//===----------------------------------------------------------------------===
-
-// See additive-folding.cpp for a description of this bug.
-// This test is insurance in case we significantly change how SymExprs are
-// evaluated. It isn't as good as additive-folding.cpp's version
-// because it will only actually be a test on systems where
-// sizeof(1 == 1) < sizeof(size_t).
-// We could add a triple if it becomes necessary.
-void PR12206(const char *x) {
- // This test is only useful under these conditions.
- size_t comparisonSize = sizeof(1 == 1);
- if (sizeof(size_t) <= comparisonSize) return;
-
- // Create a value that requires more bits to store than a comparison result.
- size_t value = 1UL;
- value <<= 8 * comparisonSize;
- value += 1;
-
- // Constrain the length of x.
- if (strlen(x) != value) return;
-
- // Test relational operators.
- if (strlen(x) < 2) { (void)*(char*)0; } // no-warning
- if (2 > strlen(x)) { (void)*(char*)0; } // no-warning
-
- // Test equality operators.
- if (strlen(x) == 1) { (void)*(char*)0; } // no-warning
- if (1 == strlen(x)) { (void)*(char*)0; } // no-warning
+ clang_analyzer_eval(strncasecmp("ab\0zz", "ab\0yy", 4) == 0); // expected-warning{{TRUE}}
}
Modified: cfe/branches/tooling/test/Analysis/unused-ivars.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/unused-ivars.m?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/unused-ivars.m (original)
+++ cfe/branches/tooling/test/Analysis/unused-ivars.m Mon May 21 03:15:06 2012
@@ -108,3 +108,24 @@
@implementation RDar8481311
@end
+
+ at class NSString;
+ at interface Radar11059352_1 {
+ at private
+ NSString *_pathString;
+}
+ at property (readonly, strong) NSString *pathString;
+ at end
+
+ at interface Radar11059352 {
+ at private
+Radar11059352_1 *_workspacePath;
+}
+ at end
+
+ at implementation Radar11059352
+
+- (void)useWorkspace {
+ NSString *workspacePathString = _workspacePath.pathString;
+}
+ at end
\ No newline at end of file
Modified: cfe/branches/tooling/test/CXX/class/class.mem/p14.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/class/class.mem/p14.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/class/class.mem/p14.cpp (original)
+++ cfe/branches/tooling/test/CXX/class/class.mem/p14.cpp Mon May 21 03:15:06 2012
@@ -9,8 +9,9 @@
};
struct X1 {
- int X1;
- X1(); // expected-error{{declarator requires an identifier}}
+ int X1; // expected-note{{hidden by a non-type declaration of 'X1' here}}
+ X1(); // expected-error{{must use 'struct' tag to refer to type 'X1' in this scope}} \
+ // expected-error{{expected member name or ';' after declaration specifiers}}
};
struct X2 {
Modified: cfe/branches/tooling/test/CXX/except/except.spec/p5-pointers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/except/except.spec/p5-pointers.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/except/except.spec/p5-pointers.cpp (original)
+++ cfe/branches/tooling/test/CXX/except/except.spec/p5-pointers.cpp Mon May 21 03:15:06 2012
@@ -65,9 +65,9 @@
void (*(*t7)())() throw(B1) = &s8; // valid
void (*(*t8)())() throw(A) = &s8; // expected-error {{return types differ}}
void (*(*t9)())() throw(D) = &s8; // expected-error {{return types differ}}
- void (*t10)(void (*)() throw(B1)) = &s9; // valid expected-warning{{disambiguated}}
- void (*t11)(void (*)() throw(A)) = &s9; // expected-error {{argument types differ}} expected-warning{{disambiguated}}
- void (*t12)(void (*)() throw(D)) = &s9; // expected-error {{argument types differ}} expected-warning{{disambiguated}}
+ void (*t10)(void (*)() throw(B1)) = &s9; // valid
+ void (*t11)(void (*)() throw(A)) = &s9; // expected-error {{argument types differ}}
+ void (*t12)(void (*)() throw(D)) = &s9; // expected-error {{argument types differ}}
}
// Member function stuff
Modified: cfe/branches/tooling/test/CodeGen/2008-01-25-ByValReadNone.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/2008-01-25-ByValReadNone.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/2008-01-25-ByValReadNone.c (original)
+++ cfe/branches/tooling/test/CodeGen/2008-01-25-ByValReadNone.c Mon May 21 03:15:06 2012
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -emit-llvm -o - %s | not grep readonly
// RUN: %clang_cc1 -emit-llvm -o - %s | not grep readnone
-// XFAIL: arm
+// XFAIL: arm,mips
// The struct being passed byval means that we cannot mark the
// function readnone. Readnone would allow stores to the arg to
Modified: cfe/branches/tooling/test/CodeGenCXX/cxx0x-delegating-ctors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/cxx0x-delegating-ctors.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/cxx0x-delegating-ctors.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/cxx0x-delegating-ctors.cpp Mon May 21 03:15:06 2012
@@ -54,3 +54,14 @@
delegator::delegator(int)
: delegator()
{}
+
+namespace PR12890 {
+ class X {
+ int x;
+ X() = default;
+ X(int);
+ };
+ X::X(int) : X() {}
+}
+// CHECK: define {{.*}} @_ZN7PR128901XC1Ei(%"class.PR12890::X"* %this, i32)
+// CHECK: call void @llvm.memset.p0i8.{{i32|i64}}(i8* {{.*}}, i8 0, {{i32|i64}} 4, i32 4, i1 false)
Modified: cfe/branches/tooling/test/CodeGenCXX/visibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/visibility.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/visibility.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/visibility.cpp Mon May 21 03:15:06 2012
@@ -54,6 +54,18 @@
// CHECK-HIDDEN: @_ZN6test299data_rectE = global
}
+namespace test40 {
+ template<typename T>
+ struct foo {
+ DEFAULT static int bar;
+ };
+ template<typename T>
+ int foo<T>::bar;
+ template struct foo<int>;
+ // CHECK: _ZN6test403fooIiE3barE = weak_odr global
+ // CHECK-HIDDEN: _ZN6test403fooIiE3barE = weak_odr global
+}
+
// CHECK: @_ZN5Test425VariableInHiddenNamespaceE = hidden global i32 10
// CHECK: @_ZN5Test71aE = hidden global
// CHECK: @_ZN5Test71bE = global
Modified: cfe/branches/tooling/test/CodeGenObjC/boxing.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjC/boxing.m?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjC/boxing.m (original)
+++ cfe/branches/tooling/test/CodeGenObjC/boxing.m Mon May 21 03:15:06 2012
@@ -85,4 +85,11 @@
@((NSUInteger)i);
// CHECK: load i8** [[stringWithUTF8StringSEL]]
const char *s; @(s);
+
+ typedef enum : NSInteger { Red, Green, Blue } Color;
+ // CHECK: load i8** [[WithIntegerSEL]]
+ @(Red);
+ Color col = Red;
+ // CHECK: load i8** [[WithIntegerSEL]]
+ @(col);
}
Modified: cfe/branches/tooling/test/Driver/arclite-link.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/arclite-link.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/arclite-link.c (original)
+++ cfe/branches/tooling/test/Driver/arclite-link.c Mon May 21 03:15:06 2012
@@ -1,10 +1,13 @@
// RUN: touch %t.o
-// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.8 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
// RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s
+// CHECK-ARCLITE-OSX: -lfoo
// CHECK-ARCLITE-OSX: libarclite_macosx.a
// CHECK-ARCLITE-OSX: -framework
// CHECK-ARCLITE-OSX: Foundation
// CHECK-ARCLITE-OSX: -lobjc
// CHECK-NOARCLITE-NOT: libarclite
+// CHECK-NOSTDLIB-NOT: -lobjc
Modified: cfe/branches/tooling/test/Driver/flags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/flags.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/flags.c (original)
+++ cfe/branches/tooling/test/Driver/flags.c Mon May 21 03:15:06 2012
@@ -7,3 +7,5 @@
// RUN: %clang -target i386-apple-darwin9 -### -S -mno-soft-float %s -msoft-float 2> %t.log
// RUN: grep '"-no-implicit-float"' %t.log
+// RUN: %clang -target armv7-apple-darwin10 -### -S -mno-implicit-float %s 2> %t.log
+// RUN: grep '"-no-implicit-float"' %t.log | count 1
Modified: cfe/branches/tooling/test/Driver/warning-options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/warning-options.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/warning-options.cpp (original)
+++ cfe/branches/tooling/test/Driver/warning-options.cpp Mon May 21 03:15:06 2012
@@ -2,3 +2,9 @@
// LARGE_VALUE_COPY_DEFAULT: -Wlarge-by-value-copy=64
// RUN: %clang -### -Wlarge-by-value-copy=128 %s 2>&1 | FileCheck -check-prefix=LARGE_VALUE_COPY_JOINED %s
// LARGE_VALUE_COPY_JOINED: -Wlarge-by-value-copy=128
+
+// RUN: %clang -c -Wmonkey -Wno-monkey -Wno-unused-command-line-arguments \
+// RUN: -Wno-unused-command-line-argument %s 2>&1 | FileCheck %s
+// CHECK: unknown warning option '-Wmonkey'
+// CHECK: unknown warning option '-Wno-monkey'
+// CHECK: unknown warning option '-Wno-unused-command-line-arguments'; did you mean '-Wno-unused-command-line-argument'?
Modified: cfe/branches/tooling/test/Index/get-cursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/get-cursor.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/get-cursor.cpp (original)
+++ cfe/branches/tooling/test/Index/get-cursor.cpp Mon May 21 03:15:06 2012
@@ -38,6 +38,13 @@
} catch (X e) {
X x;
}
+
+ struct LocalS {
+ void meth() {
+ int x;
+ ++x;
+ }
+ };
}
// RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s
@@ -93,3 +100,6 @@
// RUN: c-index-test -test-load-source-usrs local %s | FileCheck -check-prefix=CHECK-USR %s
// CHECK-USR: get-cursor.cpp c:get-cursor.cpp at 472@F at test#@e Extent=[38:12 - 38:15]
// CHECK-USR: get-cursor.cpp c:get-cursor.cpp at 483@F at test#@x Extent=[39:5 - 39:8]
+
+// RUN: c-index-test -cursor-at=%s:45:9 %s | FileCheck -check-prefix=CHECK-LOCALCLASS %s
+// CHECK-LOCALCLASS: 45:9 DeclRefExpr=x:44:11 Extent=[45:9 - 45:10] Spelling=x ([45:9 - 45:10])
Modified: cfe/branches/tooling/test/Misc/warning-flags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/warning-flags.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Misc/warning-flags.c (original)
+++ cfe/branches/tooling/test/Misc/warning-flags.c Mon May 21 03:15:06 2012
@@ -17,7 +17,7 @@
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (245):
+CHECK: Warnings without flags (242):
CHECK-NEXT: ext_anonymous_struct_union_qualified
CHECK-NEXT: ext_binary_literal
CHECK-NEXT: ext_cast_fn_obj
@@ -33,8 +33,6 @@
CHECK-NEXT: ext_expected_semi_decl_list
CHECK-NEXT: ext_explicit_instantiation_without_qualified_id
CHECK-NEXT: ext_explicit_specialization_storage_class
-CHECK-NEXT: ext_extra_ivar_semi
-CHECK-NEXT: ext_extra_struct_semi
CHECK-NEXT: ext_forward_ref_enum
CHECK-NEXT: ext_freestanding_complex
CHECK-NEXT: ext_hexconstant_invalid
@@ -65,7 +63,6 @@
CHECK-NEXT: ext_subscript_non_lvalue
CHECK-NEXT: ext_template_arg_extra_parens
CHECK-NEXT: ext_thread_before
-CHECK-NEXT: ext_top_level_semi
CHECK-NEXT: ext_typecheck_addrof_void
CHECK-NEXT: ext_typecheck_cast_nonscalar
CHECK-NEXT: ext_typecheck_cast_to_union
Modified: cfe/branches/tooling/test/Modules/Inputs/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Modules/Inputs/module.map?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Modules/Inputs/module.map (original)
+++ cfe/branches/tooling/test/Modules/Inputs/module.map Mon May 21 03:15:06 2012
@@ -84,3 +84,6 @@
module MethodPoolB {
header "MethodPoolB.h"
}
+module import_decl {
+ header "import-decl.h"
+}
Modified: cfe/branches/tooling/test/Parser/MicrosoftExtensions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/MicrosoftExtensions.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/MicrosoftExtensions.c (original)
+++ cfe/branches/tooling/test/Parser/MicrosoftExtensions.c Mon May 21 03:15:06 2012
@@ -29,6 +29,11 @@
}
_inline int foo99() { return 99; }
+void test_ms_alignof_alias() {
+ unsigned int s = _alignof(int);
+ s = __builtin_alignof(int);
+}
+
void *_alloca(int);
void foo() {
Modified: cfe/branches/tooling/test/Parser/cxx-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/cxx-class.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/cxx-class.cpp (original)
+++ cfe/branches/tooling/test/Parser/cxx-class.cpp Mon May 21 03:15:06 2012
@@ -14,9 +14,9 @@
public:
void m() {
int l = 2;
- };
+ }; // expected-warning{{extra ';' after function definition}}
- template<typename T> void mt(T) { };
+ template<typename T> void mt(T) { }
; // expected-warning{{extra ';' inside a class}}
virtual int vf() const volatile = 0;
Modified: cfe/branches/tooling/test/Parser/cxx-undeclared-identifier.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/cxx-undeclared-identifier.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/cxx-undeclared-identifier.cpp (original)
+++ cfe/branches/tooling/test/Parser/cxx-undeclared-identifier.cpp Mon May 21 03:15:06 2012
@@ -1,5 +1,17 @@
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+namespace ImplicitInt {
+ static a(4); // expected-error {{requires a type specifier}}
+ b(int n); // expected-error {{requires a type specifier}}
+ c (*p)[]; // expected-error {{unknown type name 'c'}}
+ itn f(char *p, *q); // expected-error {{unknown type name 'itn'}} expected-error {{requires a type specifier}}
+
+ struct S {
+ void f();
+ };
+ S::f() {} // expected-error {{requires a type specifier}}
+}
+
// PR7180
int f(a::b::c); // expected-error {{use of undeclared identifier 'a'}}
Modified: cfe/branches/tooling/test/Sema/attr-decl-after-definition.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/attr-decl-after-definition.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/attr-decl-after-definition.c (original)
+++ cfe/branches/tooling/test/Sema/attr-decl-after-definition.c Mon May 21 03:15:06 2012
@@ -17,3 +17,6 @@
int bar __attribute__((weak)); // expected-warning {{must precede definition}}
int bar;
+struct zed { // expected-note {{previous definition is here}}
+};
+struct __attribute__((visibility("hidden"))) zed; // expected-warning {{must precede definition}}
Modified: cfe/branches/tooling/test/Sema/format-strings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/format-strings.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/format-strings.c (original)
+++ cfe/branches/tooling/test/Sema/format-strings.c Mon May 21 03:15:06 2012
@@ -502,8 +502,13 @@
printf("%a", (long double)0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}}
// Test braced char[] initializers.
- const char kFormat18[] = { "%lld" }; // expected-note{{format string is defined here}}}
+ const char kFormat18[] = { "%lld" }; // expected-note{{format string is defined here}}
printf(kFormat18, 0); // expected-warning{{format specifies type}}
+
+ // Make sure we point at the offending argument rather than the format string.
+ const char kFormat19[] = "%d"; // expected-note{{format string is defined here}}
+ printf(kFormat19,
+ 0.0); // expected-warning{{format specifies}}
}
// PR 9466: clang: doesn't know about %Lu, %Ld, and %Lx
Modified: cfe/branches/tooling/test/Sema/switch.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/switch.c?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/switch.c (original)
+++ cfe/branches/tooling/test/Sema/switch.c Mon May 21 03:15:06 2012
@@ -9,7 +9,7 @@
switch (X) {
case 42: ; // expected-note {{previous case}}
case 5000000000LL: // expected-warning {{overflow}}
- case 42: // expected-error {{duplicate case value}}
+ case 42: // expected-error {{duplicate case value '42'}}
;
case 100 ... 99: ; // expected-warning {{empty case range}}
@@ -320,3 +320,32 @@
break;
}
}
+
+// PR9243
+#define TEST19MACRO 5
+void test19(int i) {
+ enum {
+ kTest19Enum1 = 7,
+ kTest19Enum2 = 7
+ };
+ const int a = 3;
+ switch (i) {
+ case 5: // expected-note {{previous case}}
+ case TEST19MACRO: // expected-error {{duplicate case value '5'}}
+
+ case 7: // expected-note {{previous case}}
+ case kTest19Enum1: // expected-error {{duplicate case value: '7' and 'kTest19Enum1' both equal '7'}} \
+ // expected-note {{previous case}}
+ case kTest19Enum1: // expected-error {{duplicate case value 'kTest19Enum1'}} \
+ // expected-note {{previous case}}
+ case kTest19Enum2: // expected-error {{duplicate case value: 'kTest19Enum1' and 'kTest19Enum2' both equal '7'}} \
+ // expected-note {{previous case}}
+ case (int)kTest19Enum2: //expected-error {{duplicate case value 'kTest19Enum2'}}
+
+ case 3: // expected-note {{previous case}}
+ case a: // expected-error {{duplicate case value: '3' and 'a' both equal '3'}} \
+ // expected-note {{previous case}}
+ case a: // expected-error {{duplicate case value 'a'}}
+ break;
+ }
+}
Modified: cfe/branches/tooling/test/SemaCXX/conversion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/conversion.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/conversion.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/conversion.cpp Mon May 21 03:15:06 2012
@@ -73,13 +73,22 @@
// Use FileCheck to ensure we don't get any unnecessary macro-expansion notes
// (that don't appear as 'real' notes & can't be seen/tested by -verify)
// CHECK-NOT: note:
- // CHECK: note: expanded from macro 'FNULL'
-#define FNULL NULL
- int a2 = FNULL; // expected-warning {{implicit conversion of NULL constant to 'int'}}
- // CHECK-NOT: note:
// CHECK: note: expanded from macro 'FINIT'
#define FINIT int a3 = NULL;
FINIT // expected-warning {{implicit conversion of NULL constant to 'int'}}
+
+ // we don't catch the case of #define FOO NULL ... int i = FOO; but that seems a bit narrow anyway
+ // and avoiding that helps us skip these cases:
+#define NULL_COND(cond) ((cond) ? &a : NULL)
+ bool bl2 = NULL_COND(true); // don't warn on NULL conversion through the conditional operator across a macro boundary
+ if (NULL_COND(true))
+ ;
+ while (NULL_COND(true))
+ ;
+ for (; NULL_COND(true); )
+ ;
+ do ;
+ while(NULL_COND(true));
}
namespace test4 {
Modified: cfe/branches/tooling/test/SemaCXX/typo-correction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/typo-correction.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/typo-correction.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/typo-correction.cpp Mon May 21 03:15:06 2012
@@ -190,3 +190,10 @@
};
test1::FooBar *b; // expected-error{{no type named 'FooBar' in namespace 'test1'; did you mean 'Foobar'?}}
}
+
+namespace ImplicitInt {
+ void f(int, unsinged); // expected-error{{did you mean 'unsigned'}}
+ struct S {
+ unsinged : 4; // expected-error{{did you mean 'unsigned'}}
+ };
+}
Modified: cfe/branches/tooling/test/SemaCXX/unknown-type-name.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/unknown-type-name.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/unknown-type-name.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/unknown-type-name.cpp Mon May 21 03:15:06 2012
@@ -20,6 +20,13 @@
typedef T type;
type f();
+
+ type g();
+
+ static int n;
+ static type m;
+ static int h(T::type, int); // expected-error{{missing 'typename'}}
+ static int h(T::type x, char); // expected-error{{missing 'typename'}}
};
template<typename T>
@@ -27,3 +34,52 @@
template<typename T>
A<T>::type A<T>::f() { return type(); } // expected-error{{missing 'typename'}}
+
+template<typename T>
+void f(T::type) { } // expected-error{{missing 'typename'}}
+
+template<typename T>
+void g(T::type x) { } // expected-error{{missing 'typename'}}
+
+template<typename T>
+void f(T::type, int) { } // expected-error{{missing 'typename'}}
+
+template<typename T>
+void f(T::type x, char) { } // expected-error{{missing 'typename'}}
+
+template<typename T>
+void f(int, T::type) { } // expected-error{{missing 'typename'}}
+
+template<typename T>
+void f(char, T::type x) { } // expected-error{{missing 'typename'}}
+
+template<typename T>
+void f(int, T::type, int) { } // expected-error{{missing 'typename'}}
+
+template<typename T>
+void f(int, T::type x, char) { } // expected-error{{missing 'typename'}}
+
+template<typename T> int A<T>::n(T::value); // ok
+template<typename T>
+A<T>::type // expected-error{{missing 'typename'}}
+A<T>::m(T::value, 0); // ok
+
+template<typename T> int A<T>::h(T::type, int) {} // expected-error{{missing 'typename'}}
+template<typename T> int A<T>::h(T::type x, char) {} // expected-error{{missing 'typename'}}
+
+template<typename T> int h(T::type, int); // expected-error{{missing 'typename'}}
+template<typename T> int h(T::type x, char); // expected-error{{missing 'typename'}}
+
+template<typename T> int junk1(T::junk); // expected-error{{declared as a template}}
+template<typename T> int junk2(T::junk) throw(); // expected-error{{missing 'typename'}}
+template<typename T> int junk3(T::junk) = delete; // expected-error{{missing 'typename'}} expected-warning{{C++11}}
+template<typename T> int junk4(T::junk j); // expected-error{{missing 'typename'}}
+
+// FIXME: We can tell this was intended to be a function because it does not
+// have a dependent nested name specifier.
+template<typename T> int i(T::type, int()); // expected-error{{variable 'i' declared as a template}}
+
+// FIXME: We know which type specifier should have been specified here. Provide
+// a fix-it to add 'typename A<T>::type'
+template<typename T>
+A<T>::g() { } // expected-error{{requires a type specifier}}
Propchange: cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 21 03:15:06 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-156833
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-157176
Modified: cfe/branches/tooling/test/SemaObjC/boxing-illegal-types.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/boxing-illegal-types.m?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/boxing-illegal-types.m (original)
+++ cfe/branches/tooling/test/SemaObjC/boxing-illegal-types.m Mon May 21 03:15:06 2012
@@ -1,5 +1,29 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wattributes %s
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+typedef signed char BOOL;
+
+ at interface NSNumber
+ at end
+ at interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
++ (NSNumber *)numberWithInteger:(NSInteger)value;
++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value;
+ at end
+
typedef struct {
int x, y, z;
} point;
@@ -19,3 +43,16 @@
void testInvalid() {
@(not_defined); // expected-error {{use of undeclared identifier 'not_defined'}}
}
+
+enum MyEnum {
+ ME_foo
+};
+
+enum ForwE;
+
+void testEnum(void *p) {
+ enum MyEnum myen;
+ id box = @(myen);
+ box = @(ME_foo);
+ box = @(*(enum ForwE*)p); // expected-error {{incomplete type 'enum ForwE' used in a boxed expression}}
+}
Modified: cfe/branches/tooling/test/SemaObjC/category-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/category-1.m?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/category-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/category-1.m Mon May 21 03:15:06 2012
@@ -99,3 +99,12 @@
@class I; // expected-note {{forward declaration}}
@implementation I(cat) // expected-error{{cannot find interface declaration}}
@end
+
+// <rdar://problem/11478173>
+ at interface Unrelated
+- foo;
+ at end
+
+ at interface Blah (Blarg) // expected-error{{cannot find interface declaration for 'Blah'}}
+- foo;
+ at end
Modified: cfe/branches/tooling/test/SemaObjC/continuation-class-err.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/continuation-class-err.m?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/continuation-class-err.m (original)
+++ cfe/branches/tooling/test/SemaObjC/continuation-class-err.m Mon May 21 03:15:06 2012
@@ -11,8 +11,8 @@
@end
@interface ReadOnly ()
- at property(readwrite, copy) id object; // expected-warning {{property attribute in continuation class does not match the primary class}}
- at property(readonly) id object1; // expected-error {{illegal redeclaration of property in continuation class 'ReadOnly' (attribute must be 'readwrite', while its primary must be 'readonly')}}
+ at property(readwrite, copy) id object; // expected-warning {{property attribute in class extension does not match the primary class}}
+ at property(readonly) id object1; // expected-error {{illegal redeclaration of property in class extension 'ReadOnly' (attribute must be 'readwrite', while its primary must be 'readonly')}}
@property (readwrite, assign) int indentLevel; // OK. assign the the default in any case.
@end
@@ -31,8 +31,8 @@
@end
@interface Bar ()
- at property (copy) id foo; // expected-error {{illegal redeclaration of property in continuation class 'Bar' (attribute must be 'readwrite', while its primary must be 'readonly')}}
- at property (copy) id fee; // expected-error {{illegal redeclaration of property in continuation class 'Bar' (attribute must be 'readwrite', while its primary must be 'readonly')}}
+ at property (copy) id foo; // expected-error {{illegal redeclaration of property in class extension 'Bar' (attribute must be 'readwrite', while its primary must be 'readonly')}}
+ at property (copy) id fee; // expected-error {{illegal redeclaration of property in class extension 'Bar' (attribute must be 'readwrite', while its primary must be 'readonly')}}
@end
@implementation Bar
Modified: cfe/branches/tooling/test/SemaObjC/continuation-class-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/continuation-class-property.m?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/continuation-class-property.m (original)
+++ cfe/branches/tooling/test/SemaObjC/continuation-class-property.m Mon May 21 03:15:06 2012
@@ -38,8 +38,8 @@
@end
@interface MyClass ()
- at property (readwrite) NSString *foo; // expected-error {{type of property 'NSString *' in continuation class does not match property type in primary class}}
- at property (readwrite, strong) NSRect bar; // expected-error {{type of property 'NSRect' in continuation class does not match property type in primary class}}
+ at property (readwrite) NSString *foo; // expected-error {{type of property 'NSString *' in class extension does not match property type in primary class}}
+ at property (readwrite, strong) NSRect bar; // expected-error {{type of property 'NSRect' in class extension does not match property type in primary class}}
@end
// rdar://10655530
Modified: cfe/branches/tooling/test/SemaObjC/duplicate-property-class-extension.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/duplicate-property-class-extension.m?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/duplicate-property-class-extension.m (original)
+++ cfe/branches/tooling/test/SemaObjC/duplicate-property-class-extension.m Mon May 21 03:15:06 2012
@@ -9,7 +9,7 @@
@interface Foo ()
@property (readwrite) char foo; // expected-note 2 {{property declared here}}
@property (readwrite) char NewProperty; // expected-note 2 {{property declared here}}
- at property (readwrite) char bar; // expected-error{{illegal redeclaration of 'readwrite' property in continuation class 'Foo' (perhaps you intended this to be a 'readwrite' redeclaration of a 'readonly' public property?)}}
+ at property (readwrite) char bar; // expected-error{{illegal redeclaration of 'readwrite' property in class extension 'Foo' (perhaps you intended this to be a 'readwrite' redeclaration of a 'readonly' public property?)}}
@end
@interface Foo ()
Modified: cfe/branches/tooling/test/SemaObjC/narrow-property-type-in-cont-class.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/narrow-property-type-in-cont-class.m?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/narrow-property-type-in-cont-class.m (original)
+++ cfe/branches/tooling/test/SemaObjC/narrow-property-type-in-cont-class.m Mon May 21 03:15:06 2012
@@ -14,6 +14,6 @@
@interface GKTurnBasedMatchMakerKVO ()
@property(nonatomic,readwrite,retain) NSMutableArray* outline;
- at property(nonatomic,readwrite,retain) NSArray* err_outline; // expected-error {{type of property 'NSArray *' in continuation class does not match property type in primary class}}
+ at property(nonatomic,readwrite,retain) NSArray* err_outline; // expected-error {{type of property 'NSArray *' in class extension does not match property type in primary class}}
@end
Modified: cfe/branches/tooling/test/SemaObjC/property-impl-misuse.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/property-impl-misuse.m?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/property-impl-misuse.m (original)
+++ cfe/branches/tooling/test/SemaObjC/property-impl-misuse.m Mon May 21 03:15:06 2012
@@ -34,3 +34,16 @@
self.gradientStyle; // expected-error {{property 'gradientStyle' not found on object of type 'Class'}}
}
@end
+
+// rdar://1105153
+ at interface rdar1105153
+ at property int P; // expected-error {{type of property 'P' ('int') does not match type of accessor 'P' ('void')}}
+- (void)P; // expected-note {{declared here}}
+
+ at property int P1; // expected-warning {{type of property 'P1' does not match type of accessor 'P1'}}
+- (double) P1; // expected-note {{declared here}}
+
+ at property int P2; // expected-error {{type of property 'P2' ('int') does not match type of accessor 'P2' ('double *')}}
+- (double*)P2; // expected-note {{declared here}}
+
+ at end
Modified: cfe/branches/tooling/test/SemaObjC/property-typecheck-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/property-typecheck-1.m?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/property-typecheck-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/property-typecheck-1.m Mon May 21 03:15:06 2012
@@ -73,11 +73,11 @@
NSArray* first;
}
- at property (readonly) NSArray* pieces; // expected-warning {{type of property 'pieces' does not match type of accessor 'pieces'}}
- at property (readonly) NSMutableArray* first;
+ at property (readonly) NSArray* pieces;
+ at property (readonly) NSMutableArray* first; // expected-warning {{type of property 'first' does not match type of accessor 'first'}}
-- (NSMutableArray*) pieces; // expected-note {{declared here}} // expected-note {{declared here}}
-- (NSArray*) first;
+- (NSMutableArray*) pieces;
+- (NSArray*) first; // expected-note 2 {{declared here}}
@end
@interface Class2 {
@@ -90,12 +90,12 @@
- (id) lastPiece
{
- return container.pieces; // expected-warning {{type of property 'pieces' does not match type of accessor 'pieces'}}
+ return container.pieces;
}
- (id)firstPeice
{
- return container.first;
+ return container.first; // expected-warning {{type of property 'first' does not match type of accessor 'first'}}
}
@end
Modified: cfe/branches/tooling/test/SemaObjC/related-result-type-inference.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/related-result-type-inference.m?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/related-result-type-inference.m (original)
+++ cfe/branches/tooling/test/SemaObjC/related-result-type-inference.m Mon May 21 03:15:06 2012
@@ -178,3 +178,9 @@
return (id)self; // expected-warning {{returning 'Fail *' from a function with incompatible result type 'id<X>'}}
}
@end
+
+// <rdar://problem/11460990>
+
+ at interface WeirdNSString : NSString
+- (id)initWithCString:(const char*)string, void *blah;
+ at end
Modified: cfe/branches/tooling/test/SemaTemplate/delegating-constructors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaTemplate/delegating-constructors.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaTemplate/delegating-constructors.cpp (original)
+++ cfe/branches/tooling/test/SemaTemplate/delegating-constructors.cpp Mon May 21 03:15:06 2012
@@ -29,3 +29,21 @@
Foo f(1, 1);
}
}
+
+namespace PR12890 {
+ class Document
+ {
+ public:
+ Document() = default;
+
+ template <class T>
+ explicit
+ Document(T&& t) : Document()
+ {
+ }
+ };
+ void f()
+ {
+ Document d(1);
+ }
+}
Modified: cfe/branches/tooling/test/SemaTemplate/typename-specifier.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaTemplate/typename-specifier.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaTemplate/typename-specifier.cpp (original)
+++ cfe/branches/tooling/test/SemaTemplate/typename-specifier.cpp Mon May 21 03:15:06 2012
@@ -115,3 +115,37 @@
using typename BasicGeometry<mydim, int>::operator[]; // expected-error {{typename is allowed for identifiers only}}
};
}
+
+
+namespace missing_typename {
+template <class T1, class T2> struct pair {}; // expected-note 5 {{template parameter is declared here}}
+
+template <class T1, class T2>
+struct map {
+ typedef T1* iterator;
+};
+
+template <class T>
+class ExampleClass1 {
+ struct ExampleItem;
+
+
+ struct ExampleItemSet {
+ typedef ExampleItem* iterator;
+ };
+
+ void foo() {
+ pair<ExampleItemSet::iterator, int> i; // expected-error {{template argument for template type parameter must be a type; did you forget 'typename'?}}
+ }
+ pair<ExampleItemSet::iterator, int> elt; // expected-error {{template argument for template type parameter must be a type; did you forget 'typename'?}}
+
+
+ typedef map<int, ExampleItem*> ExampleItemMap;
+
+ static void bar() {
+ pair<ExampleItemMap::iterator, int> i; // expected-error {{template argument for template type parameter must be a type; did you forget 'typename'?}}
+ }
+ pair<ExampleItemMap::iterator, int> entry; // expected-error {{template argument for template type parameter must be a type; did you forget 'typename'?}}
+ pair<bar, int> foobar; // expected-error {{template argument for template type parameter must be a type}}
+};
+} // namespace missing_typename
Modified: cfe/branches/tooling/test/Tooling/clang-check-args.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Tooling/clang-check-args.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Tooling/clang-check-args.cpp (original)
+++ cfe/branches/tooling/test/Tooling/clang-check-args.cpp Mon May 21 03:15:06 2012
@@ -4,5 +4,4 @@
invalid;
// FIXME: JSON doesn't like path separator '\', on Win32 hosts.
-// FIXME: clang-check doesn't like gcc driver on cygming.
-// XFAIL: cygwin,mingw32,win32
+// XFAIL: win32
Modified: cfe/branches/tooling/test/Tooling/clang-check-builtin-headers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Tooling/clang-check-builtin-headers.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Tooling/clang-check-builtin-headers.cpp (original)
+++ cfe/branches/tooling/test/Tooling/clang-check-builtin-headers.cpp Mon May 21 03:15:06 2012
@@ -12,5 +12,4 @@
invalid;
// FIXME: JSON doesn't like path separator '\', on Win32 hosts.
-// FIXME: clang-check doesn't like gcc driver on cygming.
-// XFAIL: cygwin,mingw32,win32
+// XFAIL: win32
Modified: cfe/branches/tooling/test/Tooling/clang-check-chdir.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Tooling/clang-check-chdir.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Tooling/clang-check-chdir.cpp (original)
+++ cfe/branches/tooling/test/Tooling/clang-check-chdir.cpp Mon May 21 03:15:06 2012
@@ -14,5 +14,4 @@
invalid;
// FIXME: JSON doesn't like path separator '\', on Win32 hosts.
-// FIXME: clang-check doesn't like gcc driver on cygming.
-// XFAIL: cygwin,mingw32,win32
+// XFAIL: win32
Modified: cfe/branches/tooling/test/Tooling/clang-check-pwd.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Tooling/clang-check-pwd.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Tooling/clang-check-pwd.cpp (original)
+++ cfe/branches/tooling/test/Tooling/clang-check-pwd.cpp Mon May 21 03:15:06 2012
@@ -8,6 +8,5 @@
// CHECK: C++ requires
invalid;
-// FIXME: JSON doesn't like path separator '\', on Win32 hosts.
-// FIXME: clang-check doesn't like gcc driver on cygming.
-// XFAIL: cygwin,mingw32,win32
+// REQUIRES: shell
+// XFAIL: mingw32
Modified: cfe/branches/tooling/test/Tooling/clang-check.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Tooling/clang-check.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Tooling/clang-check.cpp (original)
+++ cfe/branches/tooling/test/Tooling/clang-check.cpp Mon May 21 03:15:06 2012
@@ -9,5 +9,4 @@
invalid;
// FIXME: JSON doesn't like path separator '\', on Win32 hosts.
-// FIXME: clang-check doesn't like gcc driver on cygming.
-// XFAIL: cygwin,mingw32,win32
+// XFAIL: win32
Modified: cfe/branches/tooling/test/Tooling/multi-jobs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Tooling/multi-jobs.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/test/Tooling/multi-jobs.cpp (original)
+++ cfe/branches/tooling/test/Tooling/multi-jobs.cpp Mon May 21 03:15:06 2012
@@ -3,6 +3,5 @@
// CHECK: C++ requires
invalid;
-// FIXME: clang-check doesn't like gcc driver on cygming.
-// XFAIL: cygwin,mingw32,win32
-
+// FIXME: JSON doesn't like path separator '\', on Win32 hosts.
+// XFAIL: win32
Modified: cfe/branches/tooling/tools/libclang/IndexBody.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/IndexBody.cpp?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/IndexBody.cpp (original)
+++ cfe/branches/tooling/tools/libclang/IndexBody.cpp Mon May 21 03:15:06 2012
@@ -90,6 +90,12 @@
return true;
}
+ bool VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
+ IndexCtx.handleReference(E->getProtocol(), E->getProtocolIdLoc(),
+ Parent, ParentDC, E, CXIdxEntityRef_Direct);
+ return true;
+ }
+
bool VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
if (ObjCMethodDecl *MD = E->getBoxingMethod())
IndexCtx.handleReference(MD, E->getLocStart(),
Modified: cfe/branches/tooling/tools/libclang/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/RecursiveASTVisitor.h?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/RecursiveASTVisitor.h (original)
+++ cfe/branches/tooling/tools/libclang/RecursiveASTVisitor.h Mon May 21 03:15:06 2012
@@ -1188,7 +1188,8 @@
DEF_TRAVERSE_DECL(AccessSpecDecl, { })
DEF_TRAVERSE_DECL(BlockDecl, {
- TRY_TO(TraverseTypeLoc(D->getSignatureAsWritten()->getTypeLoc()));
+ if (TypeSourceInfo *TInfo = D->getSignatureAsWritten())
+ TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
TRY_TO(TraverseStmt(D->getBody()));
// This return statement makes sure the traversal of nodes in
// decls_begin()/decls_end() (done in the DEF_TRAVERSE_DECL macro)
@@ -2079,7 +2080,10 @@
DEF_TRAVERSE_STMT(GNUNullExpr, { })
DEF_TRAVERSE_STMT(ImplicitValueInitExpr, { })
DEF_TRAVERSE_STMT(ObjCBoolLiteralExpr, { })
-DEF_TRAVERSE_STMT(ObjCEncodeExpr, { })
+DEF_TRAVERSE_STMT(ObjCEncodeExpr, {
+ if (TypeSourceInfo *TInfo = S->getEncodedTypeSourceInfo())
+ TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
+})
DEF_TRAVERSE_STMT(ObjCIsaExpr, { })
DEF_TRAVERSE_STMT(ObjCIvarRefExpr, { })
DEF_TRAVERSE_STMT(ObjCMessageExpr, { })
Modified: cfe/branches/tooling/tools/scan-build/scan-build
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/scan-build/scan-build?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/tools/scan-build/scan-build (original)
+++ cfe/branches/tooling/tools/scan-build/scan-build Mon May 21 03:15:06 2012
@@ -98,6 +98,7 @@
$Clang = $ClangSB;
}
my $ClangCXX = $Clang . "++";
+my $ClangVersion = HtmlEscape(`$Clang --version`);
##----------------------------------------------------------------------------##
# GetHTMLRunDir - Construct an HTML directory name for the current sub-run.
@@ -590,6 +591,7 @@
<tr><th>User:</th><td>${UserName}\@${HostName}</td></tr>
<tr><th>Working Directory:</th><td>${CurrentDir}</td></tr>
<tr><th>Command Line:</th><td>${CmdArgs}</td></tr>
+<tr><th>Clang Version:</th><td>${ClangVersion}</td></tr>
<tr><th>Date:</th><td>${Date}</td></tr>
ENDTEXT
Modified: cfe/branches/tooling/utils/clangVisualizers.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/clangVisualizers.txt?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/utils/clangVisualizers.txt (original)
+++ cfe/branches/tooling/utils/clangVisualizers.txt Mon May 21 03:15:06 2012
@@ -53,6 +53,11 @@
)
}
+llvm::SmallString<*>{
+ preview ([$e.BeginX,s])
+ stringview ([$e.BeginX,sb])
+}
+
llvm::StringRef{
preview ([$e.Data,s])
stringview ([$e.Data,sb])
Modified: cfe/branches/tooling/www/get_started.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/www/get_started.html?rev=157177&r1=157176&r2=157177&view=diff
==============================================================================
--- cfe/branches/tooling/www/get_started.html (original)
+++ cfe/branches/tooling/www/get_started.html Mon May 21 03:15:06 2012
@@ -83,15 +83,12 @@
</li>
<li>If you intend to work on Clang C++ support, you may need to tell it how
- to find your C++ standard library headers. If Clang cannot find your
- system libstdc++ headers, please follow these instructions:
- <ul>
- <li>'<tt>gcc -v -x c++ /dev/null -fsyntax-only</tt>' to get the
- path.</li>
- <li>Look for the comment "FIXME: temporary hack:
- hard-coded paths" in <tt>clang/lib/Frontend/InitHeaderSearch.cpp</tt> and
- change the lines below to include that path.</li>
- </ul>
+ to find your C++ standard library headers. In general, Clang will detect
+ the best version of libstdc++ headers available and use them - it will
+ look both for system installations of libstdc++ as well as installations
+ adjacent to Clang itself. If your configuration fits neither of these
+ scenarios, you can use the <tt>--with-gcc-toolchain</tt> configure option
+ to tell Clang where the gcc containing the desired libstdc++ is installed.
</li>
<li>Try it out (assuming you add llvm/Debug+Asserts/bin to your path):
<ul>
More information about the llvm-branch-commits
mailing list