[llvm-branch-commits] [cfe-branch] r149603 - in /cfe/branches/tooling: ./ include/clang-c/ include/clang/ include/clang/AST/ include/clang/Basic/ include/clang/Config/ include/clang/Driver/ include/clang/Frontend/ include/clang/Sema/ include/clang/StaticAnalyzer/Core/PathSensitive/ lib/ARCMigrate/ lib/AST/ lib/Analysis/ lib/Basic/ lib/CodeGen/ lib/Driver/ lib/Frontend/ lib/Headers/ lib/Lex/ lib/Sema/ lib/StaticAnalyzer/Checkers/ lib/StaticAnalyzer/Core/ test/ARCMT/ test/Analysis/ test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/ test/...
Manuel Klimek
klimek at google.com
Thu Feb 2 02:59:12 PST 2012
Author: klimek
Date: Thu Feb 2 04:59:12 2012
New Revision: 149603
URL: http://llvm.org/viewvc/llvm-project?rev=149603&view=rev
Log:
Merging mainline.
Added:
cfe/branches/tooling/include/clang/Config/config.h.in
- copied unchanged from r149602, cfe/trunk/include/clang/Config/config.h.in
cfe/branches/tooling/lib/Frontend/DependencyGraph.cpp
- copied unchanged from r149602, cfe/trunk/lib/Frontend/DependencyGraph.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
- copied unchanged from r149602, cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
cfe/branches/tooling/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
- copied unchanged from r149602, cfe/trunk/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
cfe/branches/tooling/test/Analysis/cstring-syntax-cxx.cpp
- copied unchanged from r149602, cfe/trunk/test/Analysis/cstring-syntax-cxx.cpp
cfe/branches/tooling/test/Analysis/cstring-syntax.c
- copied unchanged from r149602, cfe/trunk/test/Analysis/cstring-syntax.c
cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp
- copied unchanged from r149602, cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp
cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp
- copied unchanged from r149602, cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp
cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
- copied unchanged from r149602, cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
- copied unchanged from r149602, cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
cfe/branches/tooling/test/CodeGenCXX/debug-info-limit-type.cpp
- copied unchanged from r149602, cfe/trunk/test/CodeGenCXX/debug-info-limit-type.cpp
cfe/branches/tooling/test/Index/complete-enums.cpp
- copied unchanged from r149602, cfe/trunk/test/Index/complete-enums.cpp
cfe/branches/tooling/test/Sema/warn-strncat-size.c
- copied unchanged from r149602, cfe/trunk/test/Sema/warn-strncat-size.c
cfe/branches/tooling/test/SemaCXX/indirect-goto.cpp
- copied unchanged from r149602, cfe/trunk/test/SemaCXX/indirect-goto.cpp
cfe/branches/tooling/test/SemaCXX/pragma-visibility.cpp
- copied unchanged from r149602, cfe/trunk/test/SemaCXX/pragma-visibility.cpp
Modified:
cfe/branches/tooling/ (props changed)
cfe/branches/tooling/CMakeLists.txt
cfe/branches/tooling/include/clang-c/Index.h
cfe/branches/tooling/include/clang-c/Makefile
cfe/branches/tooling/include/clang/AST/ASTImporter.h
cfe/branches/tooling/include/clang/AST/DeclCXX.h
cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td
cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td
cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td
cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td
cfe/branches/tooling/include/clang/Driver/CC1Options.td
cfe/branches/tooling/include/clang/Frontend/DependencyOutputOptions.h
cfe/branches/tooling/include/clang/Frontend/FrontendAction.h
cfe/branches/tooling/include/clang/Frontend/Utils.h
cfe/branches/tooling/include/clang/Makefile
cfe/branches/tooling/include/clang/Sema/ScopeInfo.h
cfe/branches/tooling/include/clang/Sema/Sema.h
cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
cfe/branches/tooling/lib/ARCMigrate/TransUnbridgedCasts.cpp
cfe/branches/tooling/lib/AST/ASTImporter.cpp
cfe/branches/tooling/lib/AST/Decl.cpp
cfe/branches/tooling/lib/AST/DeclCXX.cpp
cfe/branches/tooling/lib/AST/Expr.cpp
cfe/branches/tooling/lib/AST/ExprConstant.cpp
cfe/branches/tooling/lib/Analysis/CFG.cpp
cfe/branches/tooling/lib/Analysis/FormatString.cpp
cfe/branches/tooling/lib/Basic/Targets.cpp
cfe/branches/tooling/lib/CodeGen/CGClass.cpp
cfe/branches/tooling/lib/CodeGen/CGCleanup.cpp
cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp
cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h
cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp
cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp
cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp
cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.h
cfe/branches/tooling/lib/CodeGen/CGRTTI.cpp
cfe/branches/tooling/lib/CodeGen/CGStmt.cpp
cfe/branches/tooling/lib/CodeGen/CMakeLists.txt
cfe/branches/tooling/lib/CodeGen/CodeGenAction.cpp
cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
cfe/branches/tooling/lib/Driver/Driver.cpp
cfe/branches/tooling/lib/Driver/ToolChains.cpp
cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp
cfe/branches/tooling/lib/Frontend/ASTUnit.cpp
cfe/branches/tooling/lib/Frontend/CMakeLists.txt
cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp
cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp
cfe/branches/tooling/lib/Frontend/FrontendActions.cpp
cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp
cfe/branches/tooling/lib/Frontend/Warnings.cpp
cfe/branches/tooling/lib/Headers/module.map
cfe/branches/tooling/lib/Lex/PPDirectives.cpp
cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp
cfe/branches/tooling/lib/Sema/SemaAttr.cpp
cfe/branches/tooling/lib/Sema/SemaCXXScopeSpec.cpp
cfe/branches/tooling/lib/Sema/SemaChecking.cpp
cfe/branches/tooling/lib/Sema/SemaCodeComplete.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/SemaExprMember.cpp
cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp
cfe/branches/tooling/lib/Sema/SemaInit.cpp
cfe/branches/tooling/lib/Sema/SemaLookup.cpp
cfe/branches/tooling/lib/Sema/SemaOverload.cpp
cfe/branches/tooling/lib/Sema/SemaStmt.cpp
cfe/branches/tooling/lib/Sema/SemaTemplate.cpp
cfe/branches/tooling/lib/Sema/SemaTemplateVariadic.cpp
cfe/branches/tooling/lib/Sema/SemaType.cpp
cfe/branches/tooling/lib/Sema/TreeTransform.h
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td
cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp
cfe/branches/tooling/lib/StaticAnalyzer/Core/CheckerContext.cpp
cfe/branches/tooling/test/ARCMT/checking.m
cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast-2.m
cfe/branches/tooling/test/Analysis/CFContainers.mm
cfe/branches/tooling/test/Analysis/bstring.c
cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
cfe/branches/tooling/test/Analysis/security-syntax-checks.m
cfe/branches/tooling/test/Analysis/string.c
cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
cfe/branches/tooling/test/CXX/expr/expr.const/p2-0x.cpp
cfe/branches/tooling/test/CodeGenCXX/arm.cpp
cfe/branches/tooling/test/CodeGenCXX/for-range-temporaries.cpp
cfe/branches/tooling/test/CodeGenCXX/pragma-visibility.cpp
cfe/branches/tooling/test/Driver/darwin-ld.c
cfe/branches/tooling/test/Driver/parsing.c
cfe/branches/tooling/test/Driver/rewrite-objc.m
cfe/branches/tooling/test/Driver/target.c
cfe/branches/tooling/test/Frontend/rewrite-macros.c
cfe/branches/tooling/test/Index/retain-target-options.c
cfe/branches/tooling/test/Misc/serialized-diags-no-category.c
cfe/branches/tooling/test/Misc/warn-in-system-header.c
cfe/branches/tooling/test/Modules/compiler_builtins.m
cfe/branches/tooling/test/Preprocessor/line-directive.c
cfe/branches/tooling/test/Sema/MicrosoftExtensions.c
cfe/branches/tooling/test/Sema/attr-availability-ios.c
cfe/branches/tooling/test/Sema/constant-conversion.c
cfe/branches/tooling/test/Sema/conversion-64-32.c
cfe/branches/tooling/test/Sema/format-strings-scanf.c
cfe/branches/tooling/test/Sema/format-strings.c
cfe/branches/tooling/test/SemaCXX/constant-expression-cxx11.cpp
cfe/branches/tooling/test/SemaCXX/for-range-examples.cpp
cfe/branches/tooling/test/SemaCXX/format-strings.cpp
cfe/branches/tooling/test/SemaCXX/lambda-expressions.cpp
cfe/branches/tooling/test/SemaCXX/warn-memset-bad-sizeof.cpp
cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp (props changed)
cfe/branches/tooling/test/SemaObjC/arc-bridged-cast.m
cfe/branches/tooling/test/SemaObjC/arc-cf.m
cfe/branches/tooling/test/SemaObjC/arc-type-conversion.m
cfe/branches/tooling/test/SemaObjC/arc-unbridged-cast.m
cfe/branches/tooling/test/SemaObjC/arc.m
cfe/branches/tooling/test/SemaObjC/continuation-class-err.m
cfe/branches/tooling/test/SemaObjC/default-synthesize.m
cfe/branches/tooling/test/SemaObjCXX/arc-unbridged-cast.mm
cfe/branches/tooling/utils/analyzer/SATestBuild.py
Propchange: cfe/branches/tooling/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 2 04:59:12 2012
@@ -1,3 +1,3 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:146581-149380
+/cfe/trunk:146581-149602
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/tooling/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/CMakeLists.txt?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/CMakeLists.txt (original)
+++ cfe/branches/tooling/CMakeLists.txt Thu Feb 2 04:59:12 2012
@@ -223,6 +223,7 @@
FILES_MATCHING
PATTERN "*.def"
PATTERN "*.h"
+ PATTERN "config.h" EXCLUDE
PATTERN ".svn" EXCLUDE
)
Modified: cfe/branches/tooling/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang-c/Index.h?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang-c/Index.h (original)
+++ cfe/branches/tooling/include/clang-c/Index.h Thu Feb 2 04:59:12 2012
@@ -1984,7 +1984,7 @@
/**
* \brief Returns non-zero if \arg cursor is null.
*/
-int clang_Cursor_isNull(CXCursor);
+CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor);
/**
* \brief Compute a hash value for the given cursor.
Modified: cfe/branches/tooling/include/clang-c/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang-c/Makefile?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang-c/Makefile (original)
+++ cfe/branches/tooling/include/clang-c/Makefile Thu Feb 2 04:59:12 2012
@@ -27,6 +27,11 @@
cd $(PROJ_OBJ_ROOT)/tools/clang/include && \
for hdr in `find clang-c -type f '!' '(' -name 'Makefile' ')' -print \
| grep -v CVS | grep -v .tmp | grep -v .dir` ; do \
+ instdir=`dirname "$(IntIncludeDir)/$$hdr"` ; \
+ if test \! -d "$$instdir" ; then \
+ $(EchoCmd) Making install directory $$instdir ; \
+ $(MKDIR) $$instdir ;\
+ fi ; \
$(DataInstall) $$hdr $(IntIncludeDir)/$$hdr ; \
done ; \
fi
Modified: cfe/branches/tooling/include/clang/AST/ASTImporter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/ASTImporter.h?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/ASTImporter.h (original)
+++ cfe/branches/tooling/include/clang/AST/ASTImporter.h Thu Feb 2 04:59:12 2012
@@ -255,6 +255,12 @@
/// \brief Return the set of declarations that we know are not equivalent.
NonEquivalentDeclSet &getNonEquivalentDecls() { return NonEquivalentDecls; }
+
+ /// \brief Called for ObjCInterfaceDecl, ObjCProtocolDecl, and TagDecl.
+ /// Mark the Decl as complete, filling it in as much as possible.
+ ///
+ /// \param D A declaration in the "to" context.
+ virtual void CompleteDecl(Decl* D);
/// \brief Note that we have imported the "from" declaration by mapping it
/// to the (potentially-newly-created) "to" declaration.
Modified: cfe/branches/tooling/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/AST/DeclCXX.h?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/AST/DeclCXX.h (original)
+++ cfe/branches/tooling/include/clang/AST/DeclCXX.h Thu Feb 2 04:59:12 2012
@@ -2774,6 +2774,9 @@
const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
AccessSpecifier AS);
+const PartialDiagnostic &operator<<(const PartialDiagnostic &DB,
+ AccessSpecifier AS);
+
} // end namespace clang
#endif
Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticASTKinds.td Thu Feb 2 04:59:12 2012
@@ -36,18 +36,35 @@
"cannot be used to initialize a member in a constant expression}3">;
def note_constexpr_array_index : Note<"cannot refer to element %0 of "
"%select{array of %2 elements|non-array object}1 in a constant expression">;
+def note_constexpr_float_arithmetic : Note<
+ "floating point arithmetic produces %select{an infinity|a NaN}0">;
def note_constexpr_pointer_arithmetic : Note<
"cannot refer to element %0 of non-array object in a constant "
"expression">;
+def note_constexpr_pointer_subtraction_not_same_array : Note<
+ "subtracted pointers are not elements of the same array">;
+def note_constexpr_pointer_comparison_base_classes : Note<
+ "comparison of addresses of subobjects of different base classes "
+ "has unspecified value">;
+def note_constexpr_pointer_comparison_base_field : Note<
+ "comparison of address of base class subobject %0 of class %1 to field %2 "
+ "has unspecified value">;
+def note_constexpr_pointer_comparison_differing_access : Note<
+ "comparison of address of fields %0 and %2 of %4 with differing access "
+ "specifiers (%1 vs %3) has unspecified value">;
+def note_constexpr_compare_virtual_mem_ptr : Note<
+ "comparison of pointer to virtual member function %0 has unspecified value">;
def note_constexpr_past_end : Note<
"dereferenced pointer past the end of %select{|subobject of }0"
"%select{temporary|%2}1 is not a constant expression">;
def note_constexpr_past_end_subobject : Note<
- "cannot access %select{base class|derived class|field|array element}0 of "
+ "cannot %select{access base class of|access derived class of|access field of|"
+ "access array element of|ERROR|call member function on}0 "
"pointer past the end of object">;
def note_constexpr_null_subobject : Note<
"cannot %select{access base class of|access derived class of|access field of|"
- "access array element of|perform pointer arithmetic on}0 null pointer">;
+ "access array element of|perform pointer arithmetic on|"
+ "call member function on}0 null pointer">;
def note_constexpr_var_init_non_constant : Note<
"initializer of %0 is not a constant expression">;
def note_constexpr_typeid_polymorphic : Note<
Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticGroups.td Thu Feb 2 04:59:12 2012
@@ -158,6 +158,7 @@
def : DiagGroup<"switch-default">;
def : DiagGroup<"synth">;
def SizeofArrayArgument : DiagGroup<"sizeof-array-argument">;
+def StrncatSize : DiagGroup<"strncat-size">;
def TautologicalCompare : DiagGroup<"tautological-compare">;
def HeaderHygiene : DiagGroup<"header-hygiene">;
Modified: cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticLexKinds.td Thu Feb 2 04:59:12 2012
@@ -148,8 +148,13 @@
//===----------------------------------------------------------------------===//
// Preprocessor Diagnostics
//===----------------------------------------------------------------------===//
-def pp_hash_warning : Warning<"#warning%0">,
+
+let CategoryName = "User Defined Issues" in {
+def pp_hash_warning : Warning<"%0">,
InGroup<PoundWarning>, DefaultWarnShowInSystemHeader;
+def err_pp_hash_error : Error<"%0">;
+}
+
def pp_include_next_in_primary : Warning<
"#include_next in primary source file">;
def pp_include_macros_out_of_predefines : Error<
@@ -223,7 +228,6 @@
InGroup<CXX98CompatPedantic>, DefaultIgnore;
def err_pp_invalid_directive : Error<"invalid preprocessing directive">;
-def err_pp_hash_error : Error<"#error%0">;
def err_pp_file_not_found : Error<"'%0' file not found">, DefaultFatal;
def err_pp_error_opening_file : Error<
"error opening file '%0': %1">, DefaultFatal;
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=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/tooling/include/clang/Basic/DiagnosticSemaKinds.td Thu Feb 2 04:59:12 2012
@@ -314,6 +314,15 @@
InGroup<DiagGroup<"strlcpy-strlcat-size">>;
def note_strlcpycat_wrong_size : Note<
"change size argument to be the size of the destination">;
+
+def warn_strncat_large_size : Warning<
+ "the value of the size argument in 'strncat' is too large, might lead to a "
+ "buffer overflow">, InGroup<StrncatSize>, DefaultIgnore;
+def warn_strncat_src_size : Warning<"size argument in 'strncat' call appears "
+ "to be size of the source">, InGroup<StrncatSize>, DefaultIgnore;
+def note_strncat_wrong_size : Note<
+ "change the argument to be the free space in the destination buffer minus "
+ "the terminating null byte">;
/// main()
// static/inline main() are not errors in C, just in C++.
@@ -363,6 +372,14 @@
"only variables can be arguments to '#pragma unused'">;
def err_unsupported_pragma_weak : Error<
"using '#pragma weak' to refer to an undeclared identifier is not yet supported">;
+def err_pragma_push_visibility_mismatch : Error<
+ "#pragma visibility push with no matching #pragma visibility pop">;
+def note_surrounding_namespace_ends_here : Note<
+ "surrounding namespace with visibility attribute ends here">;
+def err_pragma_pop_visibility_mismatch : Error<
+ "#pragma visibility pop with no matching #pragma visibility push">;
+def note_surrounding_namespace_starts_here : Note<
+ "surrounding namespace with visibility attribute starts here">;
/// Objective-C parser diagnostics
def err_duplicate_class_def : Error<
@@ -3309,9 +3326,11 @@
def note_arc_bridge : Note<
"use __bridge to convert directly (no change in ownership)">;
def note_arc_bridge_transfer : Note<
- "use __bridge_transfer to transfer ownership of a +1 %0 into ARC">;
+ "use %select{__bridge_transfer|CFBridgingRelease call}1 to transfer "
+ "ownership of a +1 %0 into ARC">;
def note_arc_bridge_retained : Note<
- "use __bridge_retained to make an ARC object available as a +1 %0">;
+ "use %select{__bridge_retained|CFBridgingRetain call}1 to make an "
+ "ARC object available as a +1 %0">;
} // ARC Casting category
@@ -4066,9 +4085,11 @@
"%0 in capture list does not name a variable">;
def err_capture_non_automatic_variable : Error<
"%0 cannot be captured because it does not have automatic storage duration">;
-def err_implicit_this_capture : Error<
- "'this' cannot be implicitly captured in this context">;
-
+def err_this_capture : Error<
+ "'this' cannot be %select{implicitly |}0captured in this context">;
+def err_lambda_capture_block : Error<
+ "__block variable %0 cannot be captured in a lambda">;
+
def err_operator_arrow_circular : Error<
"circular pointer delegation detected">;
def err_pseudo_dtor_base_not_scalar : Error<
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=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Driver/CC1Options.td (original)
+++ cfe/branches/tooling/include/clang/Driver/CC1Options.td Thu Feb 2 04:59:12 2012
@@ -233,6 +233,8 @@
def dependency_file : Separate<"-dependency-file">,
HelpText<"Filename (or -) to write dependency output to">;
+def dependency_graphviz : Separate<"-dependency-graphviz">,
+ HelpText<"Filename to write GraphViz-formatted header dependencies to">;
def sys_header_deps : Flag<"-sys-header-deps">,
HelpText<"Include system headers in dependency output">;
def header_include_file : Separate<"-header-include-file">,
Modified: cfe/branches/tooling/include/clang/Frontend/DependencyOutputOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/DependencyOutputOptions.h?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/DependencyOutputOptions.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/DependencyOutputOptions.h Thu Feb 2 04:59:12 2012
@@ -25,7 +25,7 @@
/// dependency, which can avoid some 'make'
/// problems.
unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency list
-
+
/// The file to write dependency output to.
std::string OutputFile;
@@ -39,6 +39,9 @@
/// must contain at least one entry.
std::vector<std::string> Targets;
+ /// \brief The file to write GraphViz-formatted header dependencies to.
+ std::string GraphvizOutputFile;
+
public:
DependencyOutputOptions() {
IncludeSystemHeaders = 0;
Modified: cfe/branches/tooling/include/clang/Frontend/FrontendAction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/FrontendAction.h?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/FrontendAction.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/FrontendAction.h Thu Feb 2 04:59:12 2012
@@ -85,7 +85,7 @@
/// EndSourceFileAction - Callback at the end of processing a single input;
/// this is guaranteed to only be called following a successful call to
- /// BeginSourceFileAction (and BeingSourceFile).
+ /// BeginSourceFileAction (and BeginSourceFile).
virtual void EndSourceFileAction() {}
/// @}
@@ -183,8 +183,8 @@
/// automatically be shared with the AST file in between \see
/// BeginSourceFile() and \see EndSourceFile().
///
- /// \return True on success; the compilation of this file should be aborted
- /// and neither Execute nor EndSourceFile should be called.
+ /// \return True on success; on failure the compilation of this file should
+ /// be aborted and neither Execute nor EndSourceFile should be called.
bool BeginSourceFile(CompilerInstance &CI, const FrontendInputFile &Input);
/// Execute - Set the source managers main input file, and run the action.
Modified: cfe/branches/tooling/include/clang/Frontend/Utils.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Frontend/Utils.h?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Frontend/Utils.h (original)
+++ cfe/branches/tooling/include/clang/Frontend/Utils.h Thu Feb 2 04:59:12 2012
@@ -73,6 +73,11 @@
void AttachDependencyFileGen(Preprocessor &PP,
const DependencyOutputOptions &Opts);
+/// AttachDependencyGraphGen - Create a dependency graph generator, and attach
+/// it to the given preprocessor.
+ void AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile,
+ StringRef SysRoot);
+
/// AttachHeaderIncludeGen - Create a header include list generator, and attach
/// it to the given preprocessor.
///
Modified: cfe/branches/tooling/include/clang/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Makefile?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Makefile (original)
+++ cfe/branches/tooling/include/clang/Makefile Thu Feb 2 04:59:12 2012
@@ -33,6 +33,11 @@
-o -name '*.inc' \
')' -print \
| grep -v CVS | grep -v .tmp | grep -v .dir` ; do \
+ instdir=$(DESTDIR)`dirname "$(PROJ_includedir)/$$hdr"` ; \
+ if test \! -d "$$instdir" ; then \
+ $(EchoCmd) Making install directory $$instdir ; \
+ $(MKDIR) $$instdir ;\
+ fi ; \
$(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
done ; \
fi
Modified: cfe/branches/tooling/include/clang/Sema/ScopeInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Sema/ScopeInfo.h?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/branches/tooling/include/clang/Sema/ScopeInfo.h Thu Feb 2 04:59:12 2012
@@ -18,7 +18,6 @@
#include "clang/Basic/PartialDiagnostic.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/SetVector.h"
namespace clang {
@@ -140,15 +139,18 @@
// copy constructor.
llvm::PointerIntPair<Expr*, 1, bool> CopyExprAndNested;
+ /// \brief The source location at which the first capture occurred..
+ SourceLocation Loc;
+
public:
- Capture(VarDecl *Var, bool isByref, bool isNested, Expr *Cpy)
+ Capture(VarDecl *Var, bool isByref, bool isNested, SourceLocation Loc,
+ Expr *Cpy)
: VarAndKind(Var, isByref ? Cap_ByRef : Cap_ByVal),
CopyExprAndNested(Cpy, isNested) {}
enum IsThisCapture { ThisCapture };
- Capture(IsThisCapture, bool isNested)
- : VarAndKind(0, Cap_This),
- CopyExprAndNested(0, isNested) {
+ Capture(IsThisCapture, bool isNested, SourceLocation Loc)
+ : VarAndKind(0, Cap_This), CopyExprAndNested(0, isNested), Loc(Loc) {
}
bool isThisCapture() const { return VarAndKind.getInt() == Cap_This; }
@@ -160,6 +162,10 @@
VarDecl *getVariable() const {
return VarAndKind.getPointer();
}
+
+ /// \brief Retrieve the location at which this variable was captured.
+ SourceLocation getLocation() const { return Loc; }
+
Expr *getCopyExpr() const {
return CopyExprAndNested.getPointer();
}
@@ -188,16 +194,45 @@
/// or null if unknown.
QualType ReturnType;
- void AddCapture(VarDecl *Var, bool isByref, bool isNested, Expr *Cpy) {
- Captures.push_back(Capture(Var, isByref, isNested, Cpy));
+ void AddCapture(VarDecl *Var, bool isByref, bool isNested, SourceLocation Loc,
+ Expr *Cpy) {
+ Captures.push_back(Capture(Var, isByref, isNested, Loc, Cpy));
CaptureMap[Var] = Captures.size();
}
- void AddThisCapture(bool isNested) {
- Captures.push_back(Capture(Capture::ThisCapture, isNested));
+ void AddThisCapture(bool isNested, SourceLocation Loc) {
+ Captures.push_back(Capture(Capture::ThisCapture, isNested, Loc));
CXXThisCaptureIndex = Captures.size();
}
+ /// \brief Determine whether the C++ 'this' is captured.
+ bool isCXXThisCaptured() const { return CXXThisCaptureIndex != 0; }
+
+ /// \brief Retrieve the capture of C++ 'this', if it has been captured.
+ Capture &getCXXThisCapture() {
+ assert(isCXXThisCaptured() && "this has not been captured");
+ return Captures[CXXThisCaptureIndex - 1];
+ }
+
+ /// \brief Determine whether the given variable has been captured.
+ bool isCaptured(VarDecl *Var) const {
+ return CaptureMap.count(Var) > 0;
+ }
+
+ /// \brief Retrieve the capture of the given variable, if it has been
+ /// captured already.
+ Capture &getCapture(VarDecl *Var) {
+ assert(isCaptured(Var) && "Variable has not been captured");
+ return Captures[CaptureMap[Var] - 1];
+ }
+
+ const Capture &getCapture(VarDecl *Var) const {
+ llvm::DenseMap<VarDecl*, unsigned>::const_iterator Known
+ = CaptureMap.find(Var);
+ assert(Known != CaptureMap.end() && "Variable has not been captured");
+ return Captures[Known->second - 1];
+ }
+
static bool classof(const FunctionScopeInfo *FSI) {
return FSI->Kind == SK_Block || FSI->Kind == SK_Lambda;
}
@@ -250,6 +285,11 @@
virtual ~LambdaScopeInfo();
+ /// \brief Note when
+ void finishedExplicitCaptures() {
+ NumExplicitCaptures = Captures.size();
+ }
+
static bool classof(const FunctionScopeInfo *FSI) {
return FSI->Kind == SK_Lambda;
}
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=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/Sema/Sema.h (original)
+++ cfe/branches/tooling/include/clang/Sema/Sema.h Thu Feb 2 04:59:12 2012
@@ -1786,7 +1786,7 @@
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo,
Sema::LookupNameKind LookupKind,
Scope *S, CXXScopeSpec *SS,
- CorrectionCandidateCallback *CCC,
+ CorrectionCandidateCallback &CCC,
DeclContext *MemberContext = 0,
bool EnteringContext = false,
const ObjCObjectPointerType *OPT = 0);
@@ -2265,7 +2265,19 @@
ExprResult TranformToPotentiallyEvaluated(Expr *E);
ExprResult HandleExprEvaluationContextForTypeof(Expr *E);
- void MarkDeclarationReferenced(SourceLocation Loc, Decl *D);
+ // Functions for marking a declaration referenced. These functions also
+ // contain the relevant logic for marking if a reference to a function or
+ // variable is an odr-use (in the C++11 sense). There are separate variants
+ // for expressions referring to a decl; these exist because odr-use marking
+ // needs to be delayed for some constant variables when we build one of the
+ // named expressions.
+ void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D);
+ void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func);
+ void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var);
+ void MarkBlockDeclRefReferenced(BlockDeclRefExpr *E);
+ void MarkDeclRefReferenced(DeclRefExpr *E);
+ void MarkMemberReferenced(MemberExpr *E);
+
void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T);
void MarkDeclarationsReferencedInExpr(Expr *E);
@@ -3085,7 +3097,12 @@
/// \brief Make sure the value of 'this' is actually available in the current
/// context, if it is a potentially evaluated context.
- void CheckCXXThisCapture(SourceLocation Loc);
+ ///
+ /// \param Loc The location at which the capture of 'this' occurs.
+ ///
+ /// \param Explicit Whether 'this' is explicitly captured in a lambda
+ /// capture list.
+ void CheckCXXThisCapture(SourceLocation Loc, bool Explicit = false);
/// ActOnCXXBoolLiteral - Parse {true,false} literals.
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind);
@@ -5620,7 +5637,8 @@
/// PushNamespaceVisibilityAttr - Note that we've entered a
/// namespace with a visibility attribute.
- void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr);
+ void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
+ SourceLocation Loc);
/// AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used,
/// add an appropriate visibility attribute.
@@ -5628,7 +5646,7 @@
/// PopPragmaVisibility - Pop the top element of the visibility stack; used
/// for '#pragma GCC visibility' and visibility attributes on namespaces.
- void PopPragmaVisibility();
+ void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
/// FreeVisContext - Deallocate and null out VisContext.
void FreeVisContext();
@@ -6342,6 +6360,9 @@
void CheckStrlcpycatArguments(const CallExpr *Call,
IdentifierInfo *FnName);
+ void CheckStrncatArguments(const CallExpr *Call,
+ IdentifierInfo *FnName);
+
void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
SourceLocation ReturnLoc);
void CheckFloatComparison(SourceLocation Loc, Expr* LHS, Expr* RHS);
Modified: cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h (original)
+++ cfe/branches/tooling/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h Thu Feb 2 04:59:12 2012
@@ -164,6 +164,8 @@
/// Given a function declaration and a name checks if this is a C lib
/// function with the given name.
bool isCLibraryFunction(const FunctionDecl *FD, StringRef Name);
+ static bool isCLibraryFunction(const FunctionDecl *FD, StringRef Name,
+ ASTContext &Context);
/// \brief Depending on wither the location corresponds to a macro, return
/// either the macro name or the token spelling.
Modified: cfe/branches/tooling/lib/ARCMigrate/TransUnbridgedCasts.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ARCMigrate/TransUnbridgedCasts.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ARCMigrate/TransUnbridgedCasts.cpp (original)
+++ cfe/branches/tooling/lib/ARCMigrate/TransUnbridgedCasts.cpp Thu Feb 2 04:59:12 2012
@@ -128,6 +128,21 @@
if (fname.endswith("Retain") ||
fname.find("Create") != StringRef::npos ||
fname.find("Copy") != StringRef::npos) {
+ // Do not migrate to couple of bridge transfer casts which
+ // cancel each other out. Leave it unchanged so error gets user
+ // attention instead.
+ if (FD->getName() == "CFRetain" &&
+ FD->getNumParams() == 1 &&
+ FD->getParent()->isTranslationUnit() &&
+ FD->getLinkage() == ExternalLinkage) {
+ Expr *Arg = callE->getArg(0);
+ if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) {
+ const Expr *sub = ICE->getSubExpr();
+ QualType T = sub->getType();
+ if (T->isObjCObjectPointerType())
+ return;
+ }
+ }
castToObjCObject(E, /*retained=*/true);
return;
}
Modified: cfe/branches/tooling/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ASTImporter.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ASTImporter.cpp (original)
+++ cfe/branches/tooling/lib/AST/ASTImporter.cpp Thu Feb 2 04:59:12 2012
@@ -86,7 +86,7 @@
void ImportDeclarationNameLoc(const DeclarationNameInfo &From,
DeclarationNameInfo& To);
void ImportDeclContext(DeclContext *FromDC, bool ForceImport = false);
-
+
/// \brief What we should import from the definition.
enum ImportDefinitionKind {
/// \brief Import the default subset of the definition, which might be
@@ -100,14 +100,19 @@
IDK_Basic
};
+ bool shouldForceImportDeclContext(ImportDefinitionKind IDK) {
+ return IDK == IDK_Everything ||
+ (IDK == IDK_Default && !Importer.isMinimalImport());
+ }
+
bool ImportDefinition(RecordDecl *From, RecordDecl *To,
ImportDefinitionKind Kind = IDK_Default);
bool ImportDefinition(EnumDecl *From, EnumDecl *To,
- bool ForceImport = false);
+ ImportDefinitionKind Kind = IDK_Default);
bool ImportDefinition(ObjCInterfaceDecl *From, ObjCInterfaceDecl *To,
- bool ForceImport = false);
+ ImportDefinitionKind Kind = IDK_Default);
bool ImportDefinition(ObjCProtocolDecl *From, ObjCProtocolDecl *To,
- bool ForceImport = false);
+ ImportDefinitionKind Kind = IDK_Default);
TemplateParameterList *ImportTemplateParameterList(
TemplateParameterList *Params);
TemplateArgument ImportTemplateArgument(const TemplateArgument &From);
@@ -1793,7 +1798,7 @@
llvm_unreachable("Unknown name kind.");
}
-void ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) {
+void ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) {
if (Importer.isMinimalImport() && !ForceImport) {
Importer.ImportContext(FromDC);
return;
@@ -1892,8 +1897,7 @@
ToCXX->setBases(Bases.data(), Bases.size());
}
- if (Kind == IDK_Everything ||
- (Kind == IDK_Default && !Importer.isMinimalImport()))
+ if (shouldForceImportDeclContext(Kind))
ImportDeclContext(From, /*ForceImport=*/true);
To->completeDefinition();
@@ -1901,9 +1905,12 @@
}
bool ASTNodeImporter::ImportDefinition(EnumDecl *From, EnumDecl *To,
- bool ForceImport) {
- if (To->getDefinition() || To->isBeingDefined())
+ ImportDefinitionKind Kind) {
+ if (To->getDefinition() || To->isBeingDefined()) {
+ if (Kind == IDK_Everything)
+ ImportDeclContext(From, /*ForceImport=*/true);
return false;
+ }
To->startDefinition();
@@ -1914,8 +1921,9 @@
QualType ToPromotionType = Importer.Import(From->getPromotionType());
if (ToPromotionType.isNull())
return true;
-
- ImportDeclContext(From, ForceImport);
+
+ if (shouldForceImportDeclContext(Kind))
+ ImportDeclContext(From, /*ForceImport=*/true);
// FIXME: we might need to merge the number of positive or negative bits
// if the enumerator lists don't match.
@@ -3125,9 +3133,10 @@
bool ASTNodeImporter::ImportDefinition(ObjCProtocolDecl *From,
ObjCProtocolDecl *To,
- bool ForceImport) {
+ ImportDefinitionKind Kind) {
if (To->getDefinition()) {
- ImportDeclContext(From);
+ if (shouldForceImportDeclContext(Kind))
+ ImportDeclContext(From);
return false;
}
@@ -3155,8 +3164,10 @@
To->setProtocolList(Protocols.data(), Protocols.size(),
ProtocolLocs.data(), Importer.getToContext());
- // Import all of the members of this protocol.
- ImportDeclContext(From);
+ if (shouldForceImportDeclContext(Kind)) {
+ // Import all of the members of this protocol.
+ ImportDeclContext(From, /*ForceImport=*/true);
+ }
return false;
}
@@ -3211,7 +3222,7 @@
bool ASTNodeImporter::ImportDefinition(ObjCInterfaceDecl *From,
ObjCInterfaceDecl *To,
- bool ForceImport) {
+ ImportDefinitionKind Kind) {
if (To->getDefinition()) {
// Check consistency of superclass.
ObjCInterfaceDecl *FromSuper = From->getSuperClass();
@@ -3242,7 +3253,8 @@
diag::note_odr_objc_missing_superclass);
}
- ImportDeclContext(From);
+ if (shouldForceImportDeclContext(Kind))
+ ImportDeclContext(From);
return false;
}
@@ -3298,9 +3310,10 @@
To->setImplementation(Impl);
}
- // Import all of the members of this class.
- ImportDeclContext(From);
-
+ if (shouldForceImportDeclContext(Kind)) {
+ // Import all of the members of this class.
+ ImportDeclContext(From, /*ForceImport=*/true);
+ }
return false;
}
@@ -4190,15 +4203,51 @@
return FromDC;
DeclContext *ToDC = cast_or_null<DeclContext>(Import(cast<Decl>(FromDC)));
- if (RecordDecl *ToRecord = dyn_cast_or_null<RecordDecl>(ToDC)) {
- // When we're using a record declaration as a context, we need it to have
- // a definition.
- ASTNodeImporter Importer(*this);
-
+ if (!ToDC)
+ return 0;
+
+ // When we're using a record/enum/Objective-C class/protocol as a context, we
+ // need it to have a definition.
+ if (RecordDecl *ToRecord = dyn_cast<RecordDecl>(ToDC)) {
RecordDecl *FromRecord = cast<RecordDecl>(FromDC);
- if (FromRecord->isCompleteDefinition())
- Importer.ImportDefinition(FromRecord, ToRecord,
- ASTNodeImporter::IDK_Basic);
+ if (ToRecord->isCompleteDefinition()) {
+ // Do nothing.
+ } else if (FromRecord->isCompleteDefinition()) {
+ ASTNodeImporter(*this).ImportDefinition(FromRecord, ToRecord,
+ ASTNodeImporter::IDK_Basic);
+ } else {
+ CompleteDecl(ToRecord);
+ }
+ } else if (EnumDecl *ToEnum = dyn_cast<EnumDecl>(ToDC)) {
+ EnumDecl *FromEnum = cast<EnumDecl>(FromDC);
+ if (ToEnum->isCompleteDefinition()) {
+ // Do nothing.
+ } else if (FromEnum->isCompleteDefinition()) {
+ ASTNodeImporter(*this).ImportDefinition(FromEnum, ToEnum,
+ ASTNodeImporter::IDK_Basic);
+ } else {
+ CompleteDecl(ToEnum);
+ }
+ } else if (ObjCInterfaceDecl *ToClass = dyn_cast<ObjCInterfaceDecl>(ToDC)) {
+ ObjCInterfaceDecl *FromClass = cast<ObjCInterfaceDecl>(FromDC);
+ if (ToClass->getDefinition()) {
+ // Do nothing.
+ } else if (ObjCInterfaceDecl *FromDef = FromClass->getDefinition()) {
+ ASTNodeImporter(*this).ImportDefinition(FromDef, ToClass,
+ ASTNodeImporter::IDK_Basic);
+ } else {
+ CompleteDecl(ToClass);
+ }
+ } else if (ObjCProtocolDecl *ToProto = dyn_cast<ObjCProtocolDecl>(ToDC)) {
+ ObjCProtocolDecl *FromProto = cast<ObjCProtocolDecl>(FromDC);
+ if (ToProto->getDefinition()) {
+ // Do nothing.
+ } else if (ObjCProtocolDecl *FromDef = FromProto->getDefinition()) {
+ ASTNodeImporter(*this).ImportDefinition(FromDef, ToProto,
+ ASTNodeImporter::IDK_Basic);
+ } else {
+ CompleteDecl(ToProto);
+ }
}
return ToDC;
@@ -4450,7 +4499,7 @@
if (EnumDecl *ToEnum = dyn_cast<EnumDecl>(To)) {
if (!ToEnum->getDefinition()) {
Importer.ImportDefinition(cast<EnumDecl>(FromDC), ToEnum,
- /*ForceImport=*/true);
+ ASTNodeImporter::IDK_Everything);
return;
}
}
@@ -4458,7 +4507,7 @@
if (ObjCInterfaceDecl *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
if (!ToIFace->getDefinition()) {
Importer.ImportDefinition(cast<ObjCInterfaceDecl>(FromDC), ToIFace,
- /*ForceImport=*/true);
+ ASTNodeImporter::IDK_Everything);
return;
}
}
@@ -4466,7 +4515,7 @@
if (ObjCProtocolDecl *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
if (!ToProto->getDefinition()) {
Importer.ImportDefinition(cast<ObjCProtocolDecl>(FromDC), ToProto,
- /*ForceImport=*/true);
+ ASTNodeImporter::IDK_Everything);
return;
}
}
@@ -4565,6 +4614,26 @@
return FromContext.getDiagnostics().Report(Loc, DiagID);
}
+void ASTImporter::CompleteDecl (Decl *D) {
+ if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
+ if (!ID->getDefinition())
+ ID->startDefinition();
+ }
+ else if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl>(D)) {
+ if (!PD->getDefinition())
+ PD->startDefinition();
+ }
+ else if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
+ if (!TD->getDefinition() && !TD->isBeingDefined()) {
+ TD->startDefinition();
+ TD->setCompleteDefinition(true);
+ }
+ }
+ else {
+ assert (0 && "CompleteDecl called on a Decl that can't be completed");
+ }
+}
+
Decl *ASTImporter::Imported(Decl *From, Decl *To) {
ImportedDecls[From] = To;
return To;
Modified: cfe/branches/tooling/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Decl.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Decl.cpp (original)
+++ cfe/branches/tooling/lib/AST/Decl.cpp Thu Feb 2 04:59:12 2012
@@ -2333,6 +2333,7 @@
return Builtin::BIstrncasecmp;
case Builtin::BI__builtin_strncat:
+ case Builtin::BI__builtin___strncat_chk:
case Builtin::BIstrncat:
return Builtin::BIstrncat;
@@ -2340,6 +2341,10 @@
case Builtin::BIstrndup:
return Builtin::BIstrndup;
+ case Builtin::BI__builtin_strlen:
+ case Builtin::BIstrlen:
+ return Builtin::BIstrlen;
+
default:
if (isExternC()) {
if (FnInfo->isStr("memset"))
@@ -2360,6 +2365,8 @@
return Builtin::BIstrncat;
else if (FnInfo->isStr("strndup"))
return Builtin::BIstrndup;
+ else if (FnInfo->isStr("strlen"))
+ return Builtin::BIstrlen;
}
break;
}
Modified: cfe/branches/tooling/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/DeclCXX.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/DeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/AST/DeclCXX.cpp Thu Feb 2 04:59:12 2012
@@ -970,11 +970,7 @@
if (!hasDefinition())
return true;
- return isPOD() &&
- data().HasOnlyCMembers &&
- !data().HasPrivateFields &&
- !data().HasProtectedFields &&
- !data().NumBases;
+ return isPOD() && data().HasOnlyCMembers;
}
static CanQualType GetConversionType(ASTContext &Context, NamedDecl *Conv) {
@@ -1977,3 +1973,8 @@
AccessSpecifier AS) {
return DB << getAccessName(AS);
}
+
+const PartialDiagnostic &clang::operator<<(const PartialDiagnostic &DB,
+ AccessSpecifier AS) {
+ return DB << getAccessName(AS);
+}
Modified: cfe/branches/tooling/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/Expr.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/Expr.cpp (original)
+++ cfe/branches/tooling/lib/AST/Expr.cpp Thu Feb 2 04:59:12 2012
@@ -2178,6 +2178,7 @@
case NoStmtClass:
llvm_unreachable("Invalid class for expression");
}
+ llvm_unreachable("Bogus StmtClass");
}
Expr* Expr::IgnoreParens() {
Modified: cfe/branches/tooling/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/AST/ExprConstant.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/AST/ExprConstant.cpp (original)
+++ cfe/branches/tooling/lib/AST/ExprConstant.cpp Thu Feb 2 04:59:12 2012
@@ -45,6 +45,7 @@
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/SmallString.h"
#include <cstring>
+#include <functional>
using namespace clang;
using llvm::APSInt;
@@ -77,25 +78,27 @@
}
/// Get an LValue path entry, which is known to not be an array index, as a
- /// field declaration.
- const FieldDecl *getAsField(APValue::LValuePathEntry E) {
+ /// field or base class.
+ APValue::BaseOrMemberType getAsBaseOrMember(APValue::LValuePathEntry E) {
APValue::BaseOrMemberType Value;
Value.setFromOpaqueValue(E.BaseOrMember);
- return dyn_cast<FieldDecl>(Value.getPointer());
+ return Value;
+ }
+
+ /// Get an LValue path entry, which is known to not be an array index, as a
+ /// field declaration.
+ const FieldDecl *getAsField(APValue::LValuePathEntry E) {
+ return dyn_cast<FieldDecl>(getAsBaseOrMember(E).getPointer());
}
/// Get an LValue path entry, which is known to not be an array index, as a
/// base class declaration.
const CXXRecordDecl *getAsBaseClass(APValue::LValuePathEntry E) {
- APValue::BaseOrMemberType Value;
- Value.setFromOpaqueValue(E.BaseOrMember);
- return dyn_cast<CXXRecordDecl>(Value.getPointer());
+ return dyn_cast<CXXRecordDecl>(getAsBaseOrMember(E).getPointer());
}
/// Determine whether this LValue path entry for a base class names a virtual
/// base class.
bool isVirtualBaseClass(APValue::LValuePathEntry E) {
- APValue::BaseOrMemberType Value;
- Value.setFromOpaqueValue(E.BaseOrMember);
- return Value.getInt();
+ return getAsBaseOrMember(E).getInt();
}
/// Find the path length and type of the most-derived subobject in the given
@@ -127,7 +130,8 @@
// The order of this enum is important for diagnostics.
enum CheckSubobjectKind {
- CSK_Base, CSK_Derived, CSK_Field, CSK_ArrayToPointer, CSK_ArrayIndex
+ CSK_Base, CSK_Derived, CSK_Field, CSK_ArrayToPointer, CSK_ArrayIndex,
+ CSK_This
};
/// A path from a glvalue to a subobject of that glvalue.
@@ -509,6 +513,22 @@
return CheckingPotentialConstantExpression && EvalStatus.Diag->empty();
}
};
+
+ /// Object used to treat all foldable expressions as constant expressions.
+ struct FoldConstant {
+ bool Enabled;
+
+ explicit FoldConstant(EvalInfo &Info)
+ : Enabled(Info.EvalStatus.Diag && Info.EvalStatus.Diag->empty() &&
+ !Info.EvalStatus.HasSideEffects) {
+ }
+ // Treat the value we've computed since this object was created as constant.
+ void Fold(EvalInfo &Info) {
+ if (Enabled && !Info.EvalStatus.Diag->empty() &&
+ !Info.EvalStatus.HasSideEffects)
+ Info.EvalStatus.Diag->clear();
+ }
+ };
}
bool SubobjectDesignator::checkSubobject(EvalInfo &Info, const Expr *E,
@@ -813,6 +833,15 @@
}
};
+ /// Compare two member pointers, which are assumed to be of the same type.
+ static bool operator==(const MemberPtr &LHS, const MemberPtr &RHS) {
+ if (!LHS.getDecl() || !RHS.getDecl())
+ return !LHS.getDecl() && !RHS.getDecl();
+ if (LHS.getDecl()->getCanonicalDecl() != RHS.getDecl()->getCanonicalDecl())
+ return false;
+ return LHS.Path == RHS.Path;
+ }
+
/// Kinds of constant expression checking, for diagnostics.
enum CheckConstantExpressionKind {
CCEK_Constant, ///< A normal constant.
@@ -1469,6 +1498,59 @@
return true;
}
+/// Find the position where two subobject designators diverge, or equivalently
+/// the length of the common initial subsequence.
+static unsigned FindDesignatorMismatch(QualType ObjType,
+ const SubobjectDesignator &A,
+ const SubobjectDesignator &B,
+ bool &WasArrayIndex) {
+ unsigned I = 0, N = std::min(A.Entries.size(), B.Entries.size());
+ for (/**/; I != N; ++I) {
+ if (!ObjType.isNull() && ObjType->isArrayType()) {
+ // Next subobject is an array element.
+ if (A.Entries[I].ArrayIndex != B.Entries[I].ArrayIndex) {
+ WasArrayIndex = true;
+ return I;
+ }
+ ObjType = ObjType->castAsArrayTypeUnsafe()->getElementType();
+ } else {
+ if (A.Entries[I].BaseOrMember != B.Entries[I].BaseOrMember) {
+ WasArrayIndex = false;
+ return I;
+ }
+ if (const FieldDecl *FD = getAsField(A.Entries[I]))
+ // Next subobject is a field.
+ ObjType = FD->getType();
+ else
+ // Next subobject is a base class.
+ ObjType = QualType();
+ }
+ }
+ WasArrayIndex = false;
+ return I;
+}
+
+/// Determine whether the given subobject designators refer to elements of the
+/// same array object.
+static bool AreElementsOfSameArray(QualType ObjType,
+ const SubobjectDesignator &A,
+ const SubobjectDesignator &B) {
+ if (A.Entries.size() != B.Entries.size())
+ return false;
+
+ bool IsArray = A.MostDerivedArraySize != 0;
+ if (IsArray && A.MostDerivedPathLength != A.Entries.size())
+ // A is a subobject of the array element.
+ return false;
+
+ // If A (and B) designates an array element, the last entry will be the array
+ // index. That doesn't have to match. Otherwise, we're in the 'implicit array
+ // of length 1' case, and the entire path must match.
+ bool WasArrayIndex;
+ unsigned CommonLength = FindDesignatorMismatch(ObjType, A, B, WasArrayIndex);
+ return CommonLength >= A.Entries.size() - IsArray;
+}
+
/// HandleLValueToRValueConversion - Perform an lvalue-to-rvalue conversion on
/// the given lvalue. This can also be used for 'lvalue-to-lvalue' conversions
/// for looking up the glvalue referred to by an entity of reference type.
@@ -1519,6 +1601,8 @@
// parameters are constant expressions even if they're non-const.
// In C, such things can also be folded, although they are not ICEs.
const VarDecl *VD = dyn_cast<VarDecl>(D);
+ if (const VarDecl *VDef = VD->getDefinition())
+ VD = VDef;
if (!VD || VD->isInvalidDecl()) {
Info.Diag(Loc);
return false;
@@ -2268,12 +2352,35 @@
}
RetTy VisitConditionalOperator(const ConditionalOperator *E) {
+ bool IsBcpCall = false;
+ // If the condition (ignoring parens) is a __builtin_constant_p call,
+ // the result is a constant expression if it can be folded without
+ // side-effects. This is an important GNU extension. See GCC PR38377
+ // for discussion.
+ if (const CallExpr *CallCE =
+ dyn_cast<CallExpr>(E->getCond()->IgnoreParenCasts()))
+ if (CallCE->isBuiltinCall() == Builtin::BI__builtin_constant_p)
+ IsBcpCall = true;
+
+ // Always assume __builtin_constant_p(...) ? ... : ... is a potential
+ // constant expression; we can't check whether it's potentially foldable.
+ if (Info.CheckingPotentialConstantExpression && IsBcpCall)
+ return false;
+
+ FoldConstant Fold(Info);
+
bool BoolResult;
if (!EvaluateAsBooleanCondition(E->getCond(), BoolResult, Info))
return false;
Expr *EvalExpr = BoolResult ? E->getTrueExpr() : E->getFalseExpr();
- return StmtVisitorTy::Visit(EvalExpr);
+ if (!StmtVisitorTy::Visit(EvalExpr))
+ return false;
+
+ if (IsBcpCall)
+ Fold.Fold(Info);
+
+ return true;
}
RetTy VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
@@ -2353,6 +2460,9 @@
} else
return Error(E);
+ if (This && !This->checkSubobject(Info, E, CSK_This))
+ return false;
+
const FunctionDecl *Definition = 0;
Stmt *Body = FD->getBody(Definition);
APValue Result;
@@ -4125,6 +4235,23 @@
A.getLValueFrame() == B.getLValueFrame();
}
+/// Perform the given integer operation, which is known to need at most BitWidth
+/// bits, and check for overflow in the original type (if that type was not an
+/// unsigned type).
+template<typename Operation>
+static APSInt CheckedIntArithmetic(EvalInfo &Info, const Expr *E,
+ const APSInt &LHS, const APSInt &RHS,
+ unsigned BitWidth, Operation Op) {
+ if (LHS.isUnsigned())
+ return Op(LHS, RHS);
+
+ APSInt Value(Op(LHS.extend(BitWidth), RHS.extend(BitWidth)), false);
+ APSInt Result = Value.trunc(LHS.getBitWidth());
+ if (Result.extend(BitWidth) != Value)
+ HandleOverflow(Info, E, Value, E->getType());
+ return Result;
+}
+
bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
if (E->isAssignmentOp())
return Error(E);
@@ -4295,9 +4422,9 @@
(!RHSValue.Base && !RHSValue.Offset.isZero()))
return Error(E);
// It's implementation-defined whether distinct literals will have
- // distinct addresses. In clang, we do not guarantee the addresses are
- // distinct. However, we do know that the address of a literal will be
- // non-null.
+ // distinct addresses. In clang, the result of such a comparison is
+ // unspecified, so it is not a constant expression. However, we do know
+ // that the address of a literal will be non-null.
if ((IsLiteralLValue(LHSValue) || IsLiteralLValue(RHSValue)) &&
LHSValue.Base && RHSValue.Base)
return Error(E);
@@ -4312,11 +4439,22 @@
return Success(E->getOpcode() == BO_NE, E);
}
- // FIXME: Implement the C++11 restrictions:
- // - Pointer subtractions must be on elements of the same array.
- // - Pointer comparisons must be between members with the same access.
+ const CharUnits &LHSOffset = LHSValue.getLValueOffset();
+ const CharUnits &RHSOffset = RHSValue.getLValueOffset();
+
+ SubobjectDesignator &LHSDesignator = LHSValue.getLValueDesignator();
+ SubobjectDesignator &RHSDesignator = RHSValue.getLValueDesignator();
if (E->getOpcode() == BO_Sub) {
+ // C++11 [expr.add]p6:
+ // Unless both pointers point to elements of the same array object, or
+ // one past the last element of the array object, the behavior is
+ // undefined.
+ if (!LHSDesignator.Invalid && !RHSDesignator.Invalid &&
+ !AreElementsOfSameArray(getType(LHSValue.Base),
+ LHSDesignator, RHSDesignator))
+ CCEDiag(E, diag::note_constexpr_pointer_subtraction_not_same_array);
+
QualType Type = E->getLHS()->getType();
QualType ElementType = Type->getAs<PointerType>()->getPointeeType();
@@ -4324,14 +4462,28 @@
if (!HandleSizeof(Info, ElementType, ElementSize))
return false;
- CharUnits Diff = LHSValue.getLValueOffset() -
- RHSValue.getLValueOffset();
- return Success(Diff / ElementSize, E);
+ // FIXME: LLVM and GCC both compute LHSOffset - RHSOffset at runtime,
+ // and produce incorrect results when it overflows. Such behavior
+ // appears to be non-conforming, but is common, so perhaps we should
+ // assume the standard intended for such cases to be undefined behavior
+ // and check for them.
+
+ // Compute (LHSOffset - RHSOffset) / Size carefully, checking for
+ // overflow in the final conversion to ptrdiff_t.
+ APSInt LHS(
+ llvm::APInt(65, (int64_t)LHSOffset.getQuantity(), true), false);
+ APSInt RHS(
+ llvm::APInt(65, (int64_t)RHSOffset.getQuantity(), true), false);
+ APSInt ElemSize(
+ llvm::APInt(65, (int64_t)ElementSize.getQuantity(), true), false);
+ APSInt TrueResult = (LHS - RHS) / ElemSize;
+ APSInt Result = TrueResult.trunc(Info.Ctx.getIntWidth(E->getType()));
+
+ if (Result.extend(65) != TrueResult)
+ HandleOverflow(Info, E, TrueResult, E->getType());
+ return Success(Result, E);
}
- const CharUnits &LHSOffset = LHSValue.getLValueOffset();
- const CharUnits &RHSOffset = RHSValue.getLValueOffset();
-
// C++11 [expr.rel]p3:
// Pointers to void (after pointer conversions) can be compared, with a
// result defined as follows: If both pointers represent the same
@@ -4340,9 +4492,51 @@
// unspecified.
// We interpret this as applying to pointers to *cv* void.
if (LHSTy->isVoidPointerType() && LHSOffset != RHSOffset &&
- E->getOpcode() != BO_EQ && E->getOpcode() != BO_NE)
+ E->isRelationalOp())
CCEDiag(E, diag::note_constexpr_void_comparison);
+ // C++11 [expr.rel]p2:
+ // - If two pointers point to non-static data members of the same object,
+ // or to subobjects or array elements fo such members, recursively, the
+ // pointer to the later declared member compares greater provided the
+ // two members have the same access control and provided their class is
+ // not a union.
+ // [...]
+ // - Otherwise pointer comparisons are unspecified.
+ if (!LHSDesignator.Invalid && !RHSDesignator.Invalid &&
+ E->isRelationalOp()) {
+ bool WasArrayIndex;
+ unsigned Mismatch =
+ FindDesignatorMismatch(getType(LHSValue.Base), LHSDesignator,
+ RHSDesignator, WasArrayIndex);
+ // At the point where the designators diverge, the comparison has a
+ // specified value if:
+ // - we are comparing array indices
+ // - we are comparing fields of a union, or fields with the same access
+ // Otherwise, the result is unspecified and thus the comparison is not a
+ // constant expression.
+ if (!WasArrayIndex && Mismatch < LHSDesignator.Entries.size() &&
+ Mismatch < RHSDesignator.Entries.size()) {
+ const FieldDecl *LF = getAsField(LHSDesignator.Entries[Mismatch]);
+ const FieldDecl *RF = getAsField(RHSDesignator.Entries[Mismatch]);
+ if (!LF && !RF)
+ CCEDiag(E, diag::note_constexpr_pointer_comparison_base_classes);
+ else if (!LF)
+ CCEDiag(E, diag::note_constexpr_pointer_comparison_base_field)
+ << getAsBaseClass(LHSDesignator.Entries[Mismatch])
+ << RF->getParent() << RF;
+ else if (!RF)
+ CCEDiag(E, diag::note_constexpr_pointer_comparison_base_field)
+ << getAsBaseClass(RHSDesignator.Entries[Mismatch])
+ << LF->getParent() << LF;
+ else if (!LF->getParent()->isUnion() &&
+ LF->getAccess() != RF->getAccess())
+ CCEDiag(E, diag::note_constexpr_pointer_comparison_differing_access)
+ << LF << LF->getAccess() << RF << RF->getAccess()
+ << LF->getParent();
+ }
+ }
+
switch (E->getOpcode()) {
default: llvm_unreachable("missing comparison operator");
case BO_LT: return Success(LHSOffset < RHSOffset, E);
@@ -4354,6 +4548,45 @@
}
}
}
+
+ if (LHSTy->isMemberPointerType()) {
+ assert(E->isEqualityOp() && "unexpected member pointer operation");
+ assert(RHSTy->isMemberPointerType() && "invalid comparison");
+
+ MemberPtr LHSValue, RHSValue;
+
+ bool LHSOK = EvaluateMemberPointer(E->getLHS(), LHSValue, Info);
+ if (!LHSOK && Info.keepEvaluatingAfterFailure())
+ return false;
+
+ if (!EvaluateMemberPointer(E->getRHS(), RHSValue, Info) || !LHSOK)
+ return false;
+
+ // C++11 [expr.eq]p2:
+ // If both operands are null, they compare equal. Otherwise if only one is
+ // null, they compare unequal.
+ if (!LHSValue.getDecl() || !RHSValue.getDecl()) {
+ bool Equal = !LHSValue.getDecl() && !RHSValue.getDecl();
+ return Success(E->getOpcode() == BO_EQ ? Equal : !Equal, E);
+ }
+
+ // Otherwise if either is a pointer to a virtual member function, the
+ // result is unspecified.
+ if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(LHSValue.getDecl()))
+ if (MD->isVirtual())
+ CCEDiag(E, diag::note_constexpr_compare_virtual_mem_ptr) << MD;
+ if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(RHSValue.getDecl()))
+ if (MD->isVirtual())
+ CCEDiag(E, diag::note_constexpr_compare_virtual_mem_ptr) << MD;
+
+ // Otherwise they compare equal if and only if they would refer to the
+ // same member of the same most derived object or the same subobject if
+ // they were dereferenced with a hypothetical object of the associated
+ // class type.
+ bool Equal = LHSValue == RHSValue;
+ return Success(E->getOpcode() == BO_EQ ? Equal : !Equal, E);
+ }
+
if (!LHSTy->isIntegralOrEnumerationType() ||
!RHSTy->isIntegralOrEnumerationType()) {
// We can't continue from here for non-integral types.
@@ -4424,24 +4657,31 @@
switch (E->getOpcode()) {
default:
return Error(E);
- case BO_Mul: return Success(LHS * RHS, E);
- case BO_Add: return Success(LHS + RHS, E);
- case BO_Sub: return Success(LHS - RHS, E);
+ case BO_Mul:
+ return Success(CheckedIntArithmetic(Info, E, LHS, RHS,
+ LHS.getBitWidth() * 2,
+ std::multiplies<APSInt>()), E);
+ case BO_Add:
+ return Success(CheckedIntArithmetic(Info, E, LHS, RHS,
+ LHS.getBitWidth() + 1,
+ std::plus<APSInt>()), E);
+ case BO_Sub:
+ return Success(CheckedIntArithmetic(Info, E, LHS, RHS,
+ LHS.getBitWidth() + 1,
+ std::minus<APSInt>()), E);
case BO_And: return Success(LHS & RHS, E);
case BO_Xor: return Success(LHS ^ RHS, E);
case BO_Or: return Success(LHS | RHS, E);
case BO_Div:
+ case BO_Rem:
if (RHS == 0)
return Error(E, diag::note_expr_divide_by_zero);
- // Check for overflow case: INT_MIN / -1.
+ // Check for overflow case: INT_MIN / -1 or INT_MIN % -1. The latter is not
+ // actually undefined behavior in C++11 due to a language defect.
if (RHS.isNegative() && RHS.isAllOnesValue() &&
LHS.isSigned() && LHS.isMinSignedValue())
HandleOverflow(Info, E, -LHS.extend(LHS.getBitWidth() + 1), E->getType());
- return Success(LHS / RHS, E);
- case BO_Rem:
- if (RHS == 0)
- return Error(E, diag::note_expr_divide_by_zero);
- return Success(LHS % RHS, E);
+ return Success(E->getOpcode() == BO_Rem ? LHS % RHS : LHS / RHS, E);
case BO_Shl: {
// During constant-folding, a negative shift is an opposite shift. Such a
// shift is not a constant expression.
@@ -5028,17 +5268,21 @@
default: return Error(E);
case BO_Mul:
Result.multiply(RHS, APFloat::rmNearestTiesToEven);
- return true;
+ break;
case BO_Add:
Result.add(RHS, APFloat::rmNearestTiesToEven);
- return true;
+ break;
case BO_Sub:
Result.subtract(RHS, APFloat::rmNearestTiesToEven);
- return true;
+ break;
case BO_Div:
Result.divide(RHS, APFloat::rmNearestTiesToEven);
- return true;
+ break;
}
+
+ if (Result.isInfinity() || Result.isNaN())
+ CCEDiag(E, diag::note_constexpr_float_arithmetic) << Result.isNaN();
+ return true;
}
bool FloatExprEvaluator::VisitFloatingLiteral(const FloatingLiteral *E) {
Modified: cfe/branches/tooling/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/CFG.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/CFG.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/CFG.cpp Thu Feb 2 04:59:12 2012
@@ -696,8 +696,6 @@
if (B == E)
return;
- CFGBlock::iterator InsertPos;
-
// We need to append the destructors in reverse order, but any one of them
// may be a no-return destructor which changes the CFG. As a result, buffer
// this sequence up and replay them in reverse order when appending onto the
Modified: cfe/branches/tooling/lib/Analysis/FormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Analysis/FormatString.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Analysis/FormatString.cpp (original)
+++ cfe/branches/tooling/lib/Analysis/FormatString.cpp Thu Feb 2 04:59:12 2012
@@ -373,7 +373,7 @@
std::string ArgTypeResult::getRepresentativeTypeName(ASTContext &C) const {
std::string S = getRepresentativeType(C).getAsString();
- if (Name)
+ if (Name && S != Name)
return std::string("'") + Name + "' (aka '" + S + "')";
return std::string("'") + S + "'";
}
Modified: cfe/branches/tooling/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Basic/Targets.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Basic/Targets.cpp (original)
+++ cfe/branches/tooling/lib/Basic/Targets.cpp Thu Feb 2 04:59:12 2012
@@ -119,33 +119,12 @@
// Get the platform type and version number from the triple.
unsigned Maj, Min, Rev;
-
- // If no version was given, default to to 10.4.0, for simplifying tests.
- if (Triple.getOSName() == "darwin" || Triple.getOSName() == "osx") {
+ if (Triple.isMacOSX()) {
+ Triple.getMacOSXVersion(Maj, Min, Rev);
PlatformName = "macosx";
- Min = Rev = 0;
- Maj = 8;
} else {
- // Otherwise, honor all three triple forms ("-darwinNNN[-iphoneos]",
- // "-osxNNN", and "-iosNNN").
-
- if (Triple.getOS() == llvm::Triple::Darwin) {
- // For historical reasons that make little sense, the version passed here
- // is the "darwin" version, which drops the 10 and offsets by 4.
- Triple.getOSVersion(Maj, Min, Rev);
-
- if (Triple.getEnvironmentName() == "iphoneos") {
- PlatformName = "ios";
- } else {
- PlatformName = "macosx";
- Rev = Min;
- Min = Maj - 4;
- Maj = 10;
- }
- } else {
- Triple.getOSVersion(Maj, Min, Rev);
- PlatformName = llvm::Triple::getOSTypeName(Triple.getOS());
- }
+ Triple.getOSVersion(Maj, Min, Rev);
+ PlatformName = llvm::Triple::getOSTypeName(Triple.getOS());
}
// If -target arch-pc-win32-macho option specified, we're
@@ -157,7 +136,7 @@
}
// Set the appropriate OS version define.
- if (PlatformName == "ios") {
+ if (Triple.getOS() == llvm::Triple::IOS) {
assert(Maj < 10 && Min < 100 && Rev < 100 && "Invalid version!");
char Str[6];
Str[0] = '0' + Maj;
Modified: cfe/branches/tooling/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGClass.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGClass.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGClass.cpp Thu Feb 2 04:59:12 2012
@@ -1197,8 +1197,8 @@
CGDebugInfo *DI = getDebugInfo();
if (DI && CGM.getCodeGenOpts().LimitDebugInfo) {
- // If debug info for this class has been emitted then this is the right time
- // to do so.
+ // If debug info for this class has not been emitted then this is the
+ // right time to do so.
const CXXRecordDecl *Parent = D->getParent();
DI->getOrCreateRecordType(CGM.getContext().getTypeDeclType(Parent),
Parent->getLocation());
Modified: cfe/branches/tooling/lib/CodeGen/CGCleanup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGCleanup.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGCleanup.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGCleanup.cpp Thu Feb 2 04:59:12 2012
@@ -502,9 +502,9 @@
// The only uses should be fixup switches.
llvm::SwitchInst *si = cast<llvm::SwitchInst>(use.getUser());
- if (si->getNumCases() == 2 && si->getDefaultDest() == unreachableBB) {
+ if (si->getNumCases() == 1 && si->getDefaultDest() == unreachableBB) {
// Replace the switch with a branch.
- llvm::BranchInst::Create(si->getSuccessor(1), si);
+ llvm::BranchInst::Create(si->getCaseSuccessor(0), si);
// The switch operand is a load from the cleanup-dest alloca.
llvm::LoadInst *condition = cast<llvm::LoadInst>(si->getCondition());
Modified: cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDebugInfo.cpp Thu Feb 2 04:59:12 2012
@@ -671,8 +671,12 @@
if (isa<FunctionNoProtoType>(Ty))
EltTys.push_back(DBuilder.createUnspecifiedParameter());
else if (const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(Ty)) {
- for (unsigned i = 0, e = FTP->getNumArgs(); i != e; ++i)
- EltTys.push_back(getOrCreateType(FTP->getArgType(i), Unit));
+ for (unsigned i = 0, e = FTP->getNumArgs(); i != e; ++i) {
+ if (CGM.getCodeGenOpts().LimitDebugInfo)
+ EltTys.push_back(getOrCreateLimitedType(FTP->getArgType(i), Unit));
+ else
+ EltTys.push_back(getOrCreateType(FTP->getArgType(i), Unit));
+ }
}
llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys);
@@ -681,7 +685,6 @@
return DbgTy;
}
-
void CGDebugInfo::
CollectRecordStaticVars(const RecordDecl *RD, llvm::DIType FwdDecl) {
@@ -1634,9 +1637,12 @@
// Unwrap the type as needed for debug information.
Ty = UnwrapTypeForDebugInfo(Ty);
-
+
+ // Check if we already have the type. If we've gotten here and
+ // have a forward declaration of the type we may want the full type.
+ // Go ahead and create it if that's the case.
llvm::DIType T = getTypeOrNull(Ty);
- if (T.Verify()) return T;
+ if (T.Verify() && !T.isForwardDecl()) return T;
// Otherwise create the type.
llvm::DIType Res = CreateTypeNode(Ty, Unit);
@@ -1646,6 +1652,64 @@
return Res;
}
+/// getOrCreateLimitedType - Get the type from the cache or create a new
+/// limited type if necessary.
+llvm::DIType CGDebugInfo::getOrCreateLimitedType(QualType Ty,
+ llvm::DIFile Unit) {
+ if (Ty.isNull())
+ return llvm::DIType();
+
+ // Unwrap the type as needed for debug information.
+ Ty = UnwrapTypeForDebugInfo(Ty);
+
+ llvm::DIType T = getTypeOrNull(Ty);
+ if (T.Verify()) return T;
+
+ // Otherwise create the type.
+ llvm::DIType Res = CreateLimitedTypeNode(Ty, Unit);
+
+ // And update the type cache.
+ TypeCache[Ty.getAsOpaquePtr()] = Res;
+ return Res;
+}
+
+// TODO: Not safe to use for inner types or for fields. Currently only
+// used for by value arguments to functions anything else needs to be
+// audited carefully.
+llvm::DIType CGDebugInfo::CreateLimitedType(const RecordType *Ty) {
+ RecordDecl *RD = Ty->getDecl();
+
+ // For templated records we want the full type information and
+ // our forward decls don't handle this correctly.
+ if (isa<ClassTemplateSpecializationDecl>(RD))
+ return CreateType(Ty);
+
+ llvm::DIDescriptor RDContext
+ = createContextChain(cast<Decl>(RD->getDeclContext()));
+
+ return createRecordFwdDecl(RD, RDContext);
+}
+
+/// CreateLimitedTypeNode - Create a new debug type node, but only forward
+/// declare composite types that haven't been processed yet.
+llvm::DIType CGDebugInfo::CreateLimitedTypeNode(QualType Ty,llvm::DIFile Unit) {
+
+ // Work out details of type.
+ switch (Ty->getTypeClass()) {
+#define TYPE(Class, Base)
+#define ABSTRACT_TYPE(Class, Base)
+#define NON_CANONICAL_TYPE(Class, Base)
+#define DEPENDENT_TYPE(Class, Base) case Type::Class:
+ #include "clang/AST/TypeNodes.def"
+ llvm_unreachable("Dependent types cannot show up in debug information");
+
+ case Type::Record:
+ return CreateLimitedType(cast<RecordType>(Ty));
+ default:
+ return CreateTypeNode(Ty, Unit);
+ }
+}
+
/// CreateTypeNode - Create a new debug type node.
llvm::DIType CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile Unit) {
// Handle qualifiers, which recursively handles what they refer to.
@@ -2090,7 +2154,6 @@
addr, ArgNo);
// Insert an llvm.dbg.declare into the current block.
- // Insert an llvm.dbg.declare into the current block.
llvm::Instruction *Call =
DBuilder.insertDeclare(Storage, D, Builder.GetInsertBlock());
Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope));
Modified: cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CGDebugInfo.h Thu Feb 2 04:59:12 2012
@@ -73,6 +73,9 @@
llvm::DenseMap<const FunctionDecl *, llvm::WeakVH> SPCache;
llvm::DenseMap<const NamespaceDecl *, llvm::WeakVH> NameSpaceCache;
+ /// Helper functions for getOrCreateLimitedType.
+ llvm::DIType CreateLimitedType(const RecordType *Ty);
+
/// Helper functions for getOrCreateType.
llvm::DIType CreateType(const BuiltinType *Ty);
llvm::DIType CreateType(const ComplexType *Ty);
@@ -257,9 +260,17 @@
/// necessary.
llvm::DIType getOrCreateType(QualType Ty, llvm::DIFile F);
+ /// getOrCreateLimitedType - Get the type from the cache or create a flat
+ /// limited type.
+ llvm::DIType getOrCreateLimitedType(QualType Ty, llvm::DIFile F);
+
/// CreateTypeNode - Create type metadata for a source language type.
llvm::DIType CreateTypeNode(QualType Ty, llvm::DIFile F);
+ /// CreateLimitedTypeNode - Create type metadata for a source language type,
+ /// but create as little as possible.
+ llvm::DIType CreateLimitedTypeNode(QualType Ty, llvm::DIFile F);
+
/// CreateMemberType - Create new member and increase Offset by FType's size.
llvm::DIType CreateMemberType(llvm::DIFile Unit, QualType FType,
StringRef Name, uint64_t *Offset);
Modified: cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGExprConstant.cpp Thu Feb 2 04:59:12 2012
@@ -811,7 +811,7 @@
// Resize the string to the right size, adding zeros at the end, or
// truncating as needed.
Str.resize(CAT->getSize().getZExtValue(), '\0');
- return llvm::ConstantDataArray::getString(VMContext, Str, false);
+ return llvm::ConstantArray::get(VMContext, Str, false);
}
llvm::Constant *VisitUnaryExtension(const UnaryOperator *E) {
Modified: cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjCGNU.cpp Thu Feb 2 04:59:12 2012
@@ -18,7 +18,6 @@
#include "CodeGenModule.h"
#include "CodeGenFunction.h"
#include "CGCleanup.h"
-
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclObjC.h"
@@ -187,7 +186,7 @@
std::string name = prefix + Str;
llvm::Constant *ConstStr = TheModule.getGlobalVariable(name);
if (!ConstStr) {
- llvm::Constant *value = llvm::ConstantDataArray::getString(VMContext,Str);
+ llvm::Constant *value = llvm::ConstantArray::get(VMContext, Str, true);
ConstStr = new llvm::GlobalVariable(TheModule, value->getType(), true,
llvm::GlobalValue::LinkOnceODRLinkage, value, prefix + Str);
}
@@ -288,6 +287,10 @@
LazyRuntimeFunction IvarAssignFn, StrongCastAssignFn, MemMoveFn, WeakReadFn,
WeakAssignFn, GlobalAssignFn;
+ typedef std::pair<std::string, std::string> ClassAliasPair;
+ /// All classes that have aliases set for them.
+ std::vector<ClassAliasPair> ClassAliases;
+
protected:
/// Function used for throwing Objective-C exceptions.
LazyRuntimeFunction ExceptionThrowFn;
@@ -466,6 +469,7 @@
const ObjCContainerDecl *CD);
virtual void GenerateCategory(const ObjCCategoryImplDecl *CMD);
virtual void GenerateClass(const ObjCImplementationDecl *ClassDecl);
+ virtual void RegisterAlias(const ObjCCompatibleAliasDecl *OAD);
virtual llvm::Value *GenerateProtocolRef(CGBuilderTy &Builder,
const ObjCProtocolDecl *PD);
virtual void GenerateProtocol(const ObjCProtocolDecl *PD);
@@ -1934,6 +1938,15 @@
".objc_property_list");
}
+void CGObjCGNU::RegisterAlias(const ObjCCompatibleAliasDecl *OAD) {
+ // Get the class declaration for which the alias is specified.
+ ObjCInterfaceDecl *ClassDecl =
+ const_cast<ObjCInterfaceDecl *>(OAD->getClassInterface());
+ std::string ClassName = ClassDecl->getNameAsString();
+ std::string AliasName = OAD->getNameAsString();
+ ClassAliases.push_back(ClassAliasPair(ClassName,AliasName));
+}
+
void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
ASTContext &Context = CGM.getContext();
@@ -2349,6 +2362,46 @@
llvm::PointerType::getUnqual(ModuleTy), true);
llvm::Value *Register = CGM.CreateRuntimeFunction(FT, "__objc_exec_class");
Builder.CreateCall(Register, Module);
+
+ if (!ClassAliases.empty()) {
+ llvm::Type *ArgTypes[2] = {PtrTy, PtrToInt8Ty};
+ llvm::FunctionType *RegisterAliasTy =
+ llvm::FunctionType::get(Builder.getVoidTy(),
+ ArgTypes, false);
+ llvm::Function *RegisterAlias = llvm::Function::Create(
+ RegisterAliasTy,
+ llvm::GlobalValue::ExternalWeakLinkage, "class_registerAlias_np",
+ &TheModule);
+ llvm::BasicBlock *AliasBB =
+ llvm::BasicBlock::Create(VMContext, "alias", LoadFunction);
+ llvm::BasicBlock *NoAliasBB =
+ llvm::BasicBlock::Create(VMContext, "no_alias", LoadFunction);
+
+ // Branch based on whether the runtime provided class_registerAlias_np()
+ llvm::Value *HasRegisterAlias = Builder.CreateICmpNE(RegisterAlias,
+ llvm::Constant::getNullValue(RegisterAlias->getType()));
+ Builder.CreateCondBr(HasRegisterAlias, AliasBB, NoAliasBB);
+
+ // The true branch (has alias registration fucntion):
+ Builder.SetInsertPoint(AliasBB);
+ // Emit alias registration calls:
+ for (std::vector<ClassAliasPair>::iterator iter = ClassAliases.begin();
+ iter != ClassAliases.end(); ++iter) {
+ llvm::Constant *TheClass =
+ TheModule.getGlobalVariable(("_OBJC_CLASS_" + iter->first).c_str(),
+ true);
+ if (0 != TheClass) {
+ TheClass = llvm::ConstantExpr::getBitCast(TheClass, PtrTy);
+ Builder.CreateCall2(RegisterAlias, TheClass,
+ MakeConstantString(iter->second));
+ }
+ }
+ // Jump to end:
+ Builder.CreateBr(NoAliasBB);
+
+ // Missing alias registration function, just return from the function:
+ Builder.SetInsertPoint(NoAliasBB);
+ }
Builder.CreateRetVoid();
return LoadFunction;
Modified: cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjCMac.cpp Thu Feb 2 04:59:12 2012
@@ -1084,6 +1084,8 @@
virtual void GenerateClass(const ObjCImplementationDecl *ClassDecl);
+ virtual void RegisterAlias(const ObjCCompatibleAliasDecl *OAD) {};
+
virtual llvm::Value *GenerateProtocolRef(CGBuilderTy &Builder,
const ObjCProtocolDecl *PD);
@@ -1336,6 +1338,9 @@
virtual void GenerateCategory(const ObjCCategoryImplDecl *CMD);
virtual void GenerateClass(const ObjCImplementationDecl *ClassDecl);
+
+ virtual void RegisterAlias(const ObjCCompatibleAliasDecl *OAD) {};
+
virtual llvm::Value *GenerateProtocolRef(CGBuilderTy &Builder,
const ObjCProtocolDecl *PD);
@@ -3714,8 +3719,8 @@
if (!Entry)
Entry = CreateMetadataVar("\01L_OBJC_CLASS_NAME_",
- llvm::ConstantDataArray::getString(VMContext,
- Ident->getNameStart()),
+ llvm::ConstantArray::get(VMContext,
+ Ident->getNameStart()),
((ObjCABI == 2) ?
"__TEXT,__objc_classname,cstring_literals" :
"__TEXT,__cstring,cstring_literals"),
@@ -3923,7 +3928,7 @@
/// the given argument BitMap string container. Routine reads
/// two containers, IvarsInfo and SkipIvars which are assumed to be
/// filled already by the caller.
-llvm::Constant *CGObjCCommonMac::BuildIvarLayoutBitmap(std::string &BitMap) {
+llvm::Constant *CGObjCCommonMac::BuildIvarLayoutBitmap(std::string& BitMap) {
unsigned int WordsToScan, WordsToSkip;
llvm::Type *PtrTy = llvm::Type::getInt8PtrTy(VMContext);
@@ -4040,7 +4045,7 @@
llvm::GlobalVariable * Entry =
CreateMetadataVar("\01L_OBJC_CLASS_NAME_",
- llvm::ConstantDataArray::getString(VMContext, BitMap,false),
+ llvm::ConstantArray::get(VMContext, BitMap.c_str()),
((ObjCABI == 2) ?
"__TEXT,__objc_classname,cstring_literals" :
"__TEXT,__cstring,cstring_literals"),
@@ -4129,7 +4134,7 @@
// FIXME: Avoid std::string copying.
if (!Entry)
Entry = CreateMetadataVar("\01L_OBJC_METH_VAR_NAME_",
- llvm::ConstantDataArray::getString(VMContext, Sel.getAsString()),
+ llvm::ConstantArray::get(VMContext, Sel.getAsString()),
((ObjCABI == 2) ?
"__TEXT,__objc_methname,cstring_literals" :
"__TEXT,__cstring,cstring_literals"),
@@ -4151,7 +4156,7 @@
if (!Entry)
Entry = CreateMetadataVar("\01L_OBJC_METH_VAR_TYPE_",
- llvm::ConstantDataArray::getString(VMContext, TypeStr),
+ llvm::ConstantArray::get(VMContext, TypeStr),
((ObjCABI == 2) ?
"__TEXT,__objc_methtype,cstring_literals" :
"__TEXT,__cstring,cstring_literals"),
@@ -4172,7 +4177,7 @@
if (!Entry)
Entry = CreateMetadataVar("\01L_OBJC_METH_VAR_TYPE_",
- llvm::ConstantDataArray::getString(VMContext, TypeStr),
+ llvm::ConstantArray::get(VMContext, TypeStr),
((ObjCABI == 2) ?
"__TEXT,__objc_methtype,cstring_literals" :
"__TEXT,__cstring,cstring_literals"),
@@ -4187,8 +4192,8 @@
if (!Entry)
Entry = CreateMetadataVar("\01L_OBJC_PROP_NAME_ATTR_",
- llvm::ConstantDataArray::getString(VMContext,
- Ident->getNameStart()),
+ llvm::ConstantArray::get(VMContext,
+ Ident->getNameStart()),
"__TEXT,__cstring,cstring_literals",
1, true);
Modified: cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.h?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.h (original)
+++ cfe/branches/tooling/lib/CodeGen/CGObjCRuntime.h Thu Feb 2 04:59:12 2012
@@ -140,6 +140,9 @@
/// Generate a class structure for this class.
virtual void GenerateClass(const ObjCImplementationDecl *OID) = 0;
+ /// Register an class alias.
+ virtual void RegisterAlias(const ObjCCompatibleAliasDecl *OAD) = 0;
+
/// Generate an Objective-C message send operation.
///
/// \param Method - The method being called, this may be null if synthesizing
Modified: cfe/branches/tooling/lib/CodeGen/CGRTTI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGRTTI.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGRTTI.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGRTTI.cpp Thu Feb 2 04:59:12 2012
@@ -125,8 +125,7 @@
// We know that the mangled name of the type starts at index 4 of the
// mangled name of the typename, so we can just index into it in order to
// get the mangled name of the type.
- llvm::Constant *Init = llvm::ConstantDataArray::getString(VMContext,
- Name.substr(4));
+ llvm::Constant *Init = llvm::ConstantArray::get(VMContext, Name.substr(4));
llvm::GlobalVariable *GV =
CGM.CreateOrReplaceCXXRuntimeVariable(Name, Init->getType(), Linkage);
Modified: cfe/branches/tooling/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CGStmt.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CGStmt.cpp Thu Feb 2 04:59:12 2012
@@ -1221,7 +1221,7 @@
// Update the default block in case explicit case range tests have
// been chained on top.
- SwitchInsn->setSuccessor(0, CaseRangeBlock);
+ SwitchInsn->setDefaultDest(CaseRangeBlock);
// If a default was never emitted:
if (!DefaultBlock->getParent()) {
Modified: cfe/branches/tooling/lib/CodeGen/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CMakeLists.txt?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/CodeGen/CMakeLists.txt Thu Feb 2 04:59:12 2012
@@ -5,6 +5,7 @@
instrumentation
ipo
linker
+ vectorize
)
set(LLVM_USED_LIBS clangBasic clangAST clangFrontend)
Modified: cfe/branches/tooling/lib/CodeGen/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenAction.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenAction.cpp Thu Feb 2 04:59:12 2012
@@ -220,15 +220,18 @@
SourceLocation LocCookie) {
// There are a couple of different kinds of errors we could get here. First,
// we re-format the SMDiagnostic in terms of a clang diagnostic.
+
+ // Strip "error: " off the start of the message string.
StringRef Message = D.getMessage();
+ if (Message.startswith("error: "))
+ Message = Message.substr(7);
// If the SMDiagnostic has an inline asm source location, translate it.
FullSourceLoc Loc;
if (D.getLoc() != SMLoc())
Loc = ConvertBackendLocation(D, Context->getSourceManager());
-
- // FIXME: Propagate ranges up as well.
+
// If this problem has clang-level source location information, report the
// issue as being an error in the source with a note showing the instantiated
// code.
Modified: cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/branches/tooling/lib/CodeGen/CodeGenModule.cpp Thu Feb 2 04:59:12 2012
@@ -689,7 +689,7 @@
return i->second;
// Not found yet, create a new global.
- llvm::Constant *s = llvm::ConstantDataArray::getString(getLLVMContext(), Str);
+ llvm::Constant *s = llvm::ConstantArray::get(getLLVMContext(), Str, true);
llvm::GlobalValue *gv = new llvm::GlobalVariable(getModule(), s->getType(),
true, llvm::GlobalValue::PrivateLinkage, s, ".str");
gv->setSection(AnnotationSection);
@@ -1853,8 +1853,7 @@
llvm::ConstantInt::get(Ty, 0x07C8);
// String pointer.
- llvm::Constant *C = llvm::ConstantDataArray::getString(VMContext,
- Entry.getKey());
+ llvm::Constant *C = llvm::ConstantArray::get(VMContext, Entry.getKey().str());
llvm::GlobalValue::LinkageTypes Linkage;
if (isUTF16)
@@ -1986,8 +1985,7 @@
Fields[0] = ConstantStringClassRef;
// String pointer.
- llvm::Constant *C =
- llvm::ConstantDataArray::getString(VMContext, Entry.getKey());
+ llvm::Constant *C = llvm::ConstantArray::get(VMContext, Entry.getKey().str());
llvm::GlobalValue::LinkageTypes Linkage;
bool isConstant;
@@ -2083,28 +2081,29 @@
// Don't emit it as the address of the string, emit the string data itself
// as an inline array.
if (E->getCharByteWidth()==1) {
- return llvm::ConstantDataArray::getString(VMContext,
+ return llvm::ConstantArray::get(VMContext,
GetStringForStringLiteral(E), false);
+ } else {
+ llvm::ArrayType *AType =
+ cast<llvm::ArrayType>(getTypes().ConvertType(E->getType()));
+ llvm::Type *ElemTy = AType->getElementType();
+ unsigned NumElements = AType->getNumElements();
+ std::vector<llvm::Constant*> Elts;
+ Elts.reserve(NumElements);
+
+ for(unsigned i=0;i<E->getLength();++i) {
+ unsigned value = E->getCodeUnit(i);
+ llvm::Constant *C = llvm::ConstantInt::get(ElemTy,value,false);
+ Elts.push_back(C);
+ }
+ for(unsigned i=E->getLength();i<NumElements;++i) {
+ llvm::Constant *C = llvm::ConstantInt::get(ElemTy,0,false);
+ Elts.push_back(C);
+ }
+
+ return llvm::ConstantArray::get(AType, Elts);
}
-
- llvm::ArrayType *AType =
- cast<llvm::ArrayType>(getTypes().ConvertType(E->getType()));
- llvm::Type *ElemTy = AType->getElementType();
- unsigned NumElements = AType->getNumElements();
- std::vector<llvm::Constant*> Elts;
- Elts.reserve(NumElements);
-
- for(unsigned i=0;i<E->getLength();++i) {
- unsigned value = E->getCodeUnit(i);
- llvm::Constant *C = llvm::ConstantInt::get(ElemTy,value,false);
- Elts.push_back(C);
- }
- for(unsigned i=E->getLength();i<NumElements;++i) {
- llvm::Constant *C = llvm::ConstantInt::get(ElemTy,0,false);
- Elts.push_back(C);
- }
-
- return llvm::ConstantArray::get(AType, Elts);
+
}
/// GetAddrOfConstantStringFromLiteral - Return a pointer to a
@@ -2153,7 +2152,7 @@
unsigned Alignment) {
// Create Constant for this string literal. Don't add a '\0'.
llvm::Constant *C =
- llvm::ConstantDataArray::getString(CGM.getLLVMContext(), str, false);
+ llvm::ConstantArray::get(CGM.getLLVMContext(), str, false);
// Create a global variable for this string
llvm::GlobalVariable *GV =
@@ -2421,7 +2420,7 @@
break;
}
case Decl::ObjCCompatibleAlias:
- // compatibility-alias is a directive and has no code gen.
+ ObjCRuntime->RegisterAlias(cast<ObjCCompatibleAliasDecl>(D));
break;
case Decl::LinkageSpec:
Modified: cfe/branches/tooling/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/Driver.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/Driver.cpp (original)
+++ cfe/branches/tooling/lib/Driver/Driver.cpp Thu Feb 2 04:59:12 2012
@@ -7,10 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#ifdef HAVE_CLANG_CONFIG_H
-# include "clang/Config/config.h"
-#endif
-
#include "clang/Driver/Driver.h"
#include "clang/Driver/Action.h"
@@ -27,7 +23,6 @@
#include "clang/Basic/Version.h"
-#include "llvm/Config/config.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/OwningPtr.h"
@@ -41,6 +36,11 @@
#include "InputInfo.h"
#include "ToolChains.h"
+#ifdef HAVE_CLANG_CONFIG_H
+# include "clang/Config/config.h"
+#endif
+#include "llvm/Config/config.h"
+
#include <map>
using namespace clang::driver;
Modified: cfe/branches/tooling/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/ToolChains.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/ToolChains.cpp (original)
+++ cfe/branches/tooling/lib/Driver/ToolChains.cpp Thu Feb 2 04:59:12 2012
@@ -9,10 +9,6 @@
#include "ToolChains.h"
-#ifdef HAVE_CLANG_CONFIG_H
-# include "clang/Config/config.h"
-#endif
-
#include "clang/Driver/Arg.h"
#include "clang/Driver/ArgList.h"
#include "clang/Driver/Compilation.h"
@@ -37,6 +33,10 @@
#include <cstdlib> // ::getenv
+#ifdef HAVE_CLANG_CONFIG_H
+# include "clang/Config/config.h"
+#endif
+
#include "llvm/Config/config.h" // for CXX_INCLUDE_ROOT
using namespace clang::driver;
@@ -50,17 +50,19 @@
ARCRuntimeForSimulator(ARCSimulator_None),
LibCXXForSimulator(LibCXXSimulator_None)
{
- // Compute the initial Darwin version based on the host.
- bool HadExtra;
- std::string OSName = Triple.getOSName();
- if (!Driver::GetReleaseVersion(&OSName.c_str()[6],
- DarwinVersion[0], DarwinVersion[1],
- DarwinVersion[2], HadExtra))
- getDriver().Diag(diag::err_drv_invalid_darwin_version) << OSName;
-
+ // Compute the initial Darwin version from the triple
+ unsigned Major, Minor, Micro;
+ if (!Triple.getMacOSXVersion(Major, Minor, Micro))
+ getDriver().Diag(diag::err_drv_invalid_darwin_version) <<
+ Triple.getOSName();
llvm::raw_string_ostream(MacosxVersionMin)
- << "10." << std::max(0, (int)DarwinVersion[0] - 4) << '.'
- << DarwinVersion[1];
+ << Major << '.' << Minor << '.' << Micro;
+
+ // FIXME: DarwinVersion is only used to find GCC's libexec directory.
+ // It should be removed when we stop supporting that.
+ DarwinVersion[0] = Minor + 4;
+ DarwinVersion[1] = Micro;
+ DarwinVersion[2] = 0;
}
types::ID Darwin::LookupTypeForExtension(const char *Ext) const {
Modified: cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp (original)
+++ cfe/branches/tooling/lib/Driver/WindowsToolChain.cpp Thu Feb 2 04:59:12 2012
@@ -9,10 +9,6 @@
#include "ToolChains.h"
-#ifdef HAVE_CLANG_CONFIG_H
-# include "clang/Config/config.h"
-#endif
-
#include "clang/Driver/Arg.h"
#include "clang/Driver/ArgList.h"
#include "clang/Driver/Compilation.h"
Modified: cfe/branches/tooling/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/ASTUnit.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/ASTUnit.cpp Thu Feb 2 04:59:12 2012
@@ -982,6 +982,34 @@
}
+static void checkAndRemoveNonDriverDiags(SmallVectorImpl<StoredDiagnostic> &
+ StoredDiagnostics) {
+ // Get rid of stored diagnostics except the ones from the driver which do not
+ // have a source location.
+ for (unsigned I = 0; I < StoredDiagnostics.size(); ++I) {
+ if (StoredDiagnostics[I].getLocation().isValid()) {
+ StoredDiagnostics.erase(StoredDiagnostics.begin()+I);
+ --I;
+ }
+ }
+}
+
+static void checkAndSanitizeDiags(SmallVectorImpl<StoredDiagnostic> &
+ StoredDiagnostics,
+ SourceManager &SM) {
+ // The stored diagnostic has the old source manager in it; update
+ // the locations to refer into the new source manager. Since we've
+ // been careful to make sure that the source manager's state
+ // before and after are identical, so that we can reuse the source
+ // location itself.
+ for (unsigned I = 0, N = StoredDiagnostics.size(); I < N; ++I) {
+ if (StoredDiagnostics[I].getLocation().isValid()) {
+ FullSourceLoc Loc(StoredDiagnostics[I].getLocation(), SM);
+ StoredDiagnostics[I].setLocation(Loc);
+ }
+ }
+}
+
/// Parse the source file into a translation unit using the given compiler
/// invocation, replacing the current translation unit.
///
@@ -1052,7 +1080,7 @@
CleanTemporaryFiles();
if (!OverrideMainBuffer) {
- StoredDiagnostics.erase(stored_diag_afterDriver_begin(), stored_diag_end());
+ checkAndRemoveNonDriverDiags(StoredDiagnostics);
TopLevelDeclsInPreamble.clear();
}
@@ -1080,13 +1108,7 @@
// been careful to make sure that the source manager's state
// before and after are identical, so that we can reuse the source
// location itself.
- for (unsigned I = NumStoredDiagnosticsFromDriver,
- N = StoredDiagnostics.size();
- I < N; ++I) {
- FullSourceLoc Loc(StoredDiagnostics[I].getLocation(),
- getSourceManager());
- StoredDiagnostics[I].setLocation(Loc);
- }
+ checkAndSanitizeDiags(StoredDiagnostics, getSourceManager());
// Keep track of the override buffer;
SavedMainFileBuffer = OverrideMainBuffer;
@@ -1520,7 +1542,7 @@
// Clear out old caches and data.
getDiagnostics().Reset();
ProcessWarningOptions(getDiagnostics(), Clang->getDiagnosticOpts());
- StoredDiagnostics.erase(stored_diag_afterDriver_begin(), stored_diag_end());
+ checkAndRemoveNonDriverDiags(StoredDiagnostics);
TopLevelDecls.clear();
TopLevelDeclsInPreamble.clear();
@@ -1563,7 +1585,7 @@
PreambleDiagnostics.clear();
PreambleDiagnostics.insert(PreambleDiagnostics.end(),
stored_diag_afterDriver_begin(), stored_diag_end());
- StoredDiagnostics.erase(stored_diag_afterDriver_begin(), stored_diag_end());
+ checkAndRemoveNonDriverDiags(StoredDiagnostics);
// Keep track of the preamble we precompiled.
setPreambleFile(this, FrontendOpts.OutputFile);
@@ -2368,6 +2390,8 @@
Act->Execute();
Act->EndSourceFile();
}
+
+ checkAndSanitizeDiags(StoredDiagnostics, getSourceManager());
}
CXSaveError ASTUnit::Save(StringRef File) {
Modified: cfe/branches/tooling/lib/Frontend/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/CMakeLists.txt?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/Frontend/CMakeLists.txt Thu Feb 2 04:59:12 2012
@@ -19,6 +19,7 @@
CompilerInvocation.cpp
CreateInvocationFromCommandLine.cpp
DependencyFile.cpp
+ DependencyGraph.cpp
DiagnosticRenderer.cpp
FrontendAction.cpp
FrontendActions.cpp
Modified: cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/CompilerInstance.cpp Thu Feb 2 04:59:12 2012
@@ -275,7 +275,11 @@
const DependencyOutputOptions &DepOpts = getDependencyOutputOpts();
if (!DepOpts.OutputFile.empty())
AttachDependencyFileGen(*PP, DepOpts);
+ if (!DepOpts.GraphvizOutputFile.empty())
+ AttachDependencyGraphGen(*PP, DepOpts.GraphvizOutputFile,
+ getHeaderSearchOpts().Sysroot);
+
// Handle generating header include information, if requested.
if (DepOpts.ShowHeaderIncludes)
AttachHeaderIncludeGen(*PP);
Modified: cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/CompilerInvocation.cpp Thu Feb 2 04:59:12 2012
@@ -1191,6 +1191,7 @@
Opts.ShowHeaderIncludes = Args.hasArg(OPT_H);
Opts.HeaderIncludeOutputFile = Args.getLastArgValue(OPT_header_include_file);
Opts.AddMissingHeaderDeps = Args.hasArg(OPT_MG);
+ Opts.GraphvizOutputFile = Args.getLastArgValue(OPT_dependency_graphviz);
}
static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
Modified: cfe/branches/tooling/lib/Frontend/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/FrontendActions.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/FrontendActions.cpp Thu Feb 2 04:59:12 2012
@@ -126,6 +126,32 @@
Sysroot, OS);
}
+/// \brief Add an appropriate #include/#import for the given header within
+/// the current module context.
+static void addHeaderInclude(StringRef Header,
+ bool IsBuiltinModule,
+ const LangOptions &LangOpts,
+ llvm::SmallString<256> &Includes) {
+ if (IsBuiltinModule) {
+ // Our own builtin headers play some evil tricks that depend both on
+ // knowing that our headers will be found first and on include_next. To
+ // Make sure these include_next tricks work, we include with <> and
+ // just the filename itself rather than using an absolutely path.
+ // FIXME: Is there some sensible way to generalize this?
+ Includes += "#include <";
+ Includes += llvm::sys::path::filename(Header);
+ Includes += ">\n";
+ return;
+ }
+
+ if (LangOpts.ObjC1)
+ Includes += "#import \"";
+ else
+ Includes += "#include \"";
+ Includes += Header;
+ Includes += "\"\n";
+}
+
/// \brief Collect the set of header includes needed to construct the given
/// module.
///
@@ -137,31 +163,21 @@
FileManager &FileMgr,
ModuleMap &ModMap,
clang::Module *Module,
+ bool IsBuiltinModule,
llvm::SmallString<256> &Includes) {
// Don't collect any headers for unavailable modules.
if (!Module->isAvailable())
return;
// Add includes for each of these headers.
- for (unsigned I = 0, N = Module->Headers.size(); I != N; ++I) {
- if (LangOpts.ObjC1)
- Includes += "#import \"";
- else
- Includes += "#include \"";
- Includes += Module->Headers[I]->getName();
- Includes += "\"\n";
- }
+ for (unsigned I = 0, N = Module->Headers.size(); I != N; ++I)
+ addHeaderInclude(Module->Headers[I]->getName(), IsBuiltinModule, LangOpts,
+ Includes);
if (const FileEntry *UmbrellaHeader = Module->getUmbrellaHeader()) {
- if (Module->Parent) {
- // Include the umbrella header for submodules.
- if (LangOpts.ObjC1)
- Includes += "#import \"";
- else
- Includes += "#include \"";
- Includes += UmbrellaHeader->getName();
- Includes += "\"\n";
- }
+ if (Module->Parent)
+ addHeaderInclude(UmbrellaHeader->getName(), IsBuiltinModule, LangOpts,
+ Includes);
} else if (const DirectoryEntry *UmbrellaDir = Module->getUmbrellaDir()) {
// Add all of the headers we find in this subdirectory.
llvm::error_code EC;
@@ -183,13 +199,8 @@
if (ModMap.isHeaderInUnavailableModule(Header))
continue;
- // Include this header umbrella header for submodules.
- if (LangOpts.ObjC1)
- Includes += "#import \"";
- else
- Includes += "#include \"";
- Includes += Dir->path();
- Includes += "\"\n";
+ // Include this header.
+ addHeaderInclude(Dir->path(), IsBuiltinModule, LangOpts, Includes);
}
}
@@ -197,7 +208,8 @@
for (clang::Module::submodule_iterator Sub = Module->submodule_begin(),
SubEnd = Module->submodule_end();
Sub != SubEnd; ++Sub)
- collectModuleHeaderIncludes(LangOpts, FileMgr, ModMap, *Sub, Includes);
+ collectModuleHeaderIncludes(LangOpts, FileMgr, ModMap, *Sub,
+ IsBuiltinModule, Includes);
}
bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI,
@@ -249,10 +261,11 @@
const FileEntry *UmbrellaHeader = Module->getUmbrellaHeader();
// Collect the set of #includes we need to build the module.
+ bool IsBuiltinModule = StringRef(Module->Name).startswith("_Builtin_");
llvm::SmallString<256> HeaderContents;
collectModuleHeaderIncludes(CI.getLangOpts(), CI.getFileManager(),
CI.getPreprocessor().getHeaderSearchInfo().getModuleMap(),
- Module, HeaderContents);
+ Module, IsBuiltinModule, HeaderContents);
if (UmbrellaHeader && HeaderContents.empty()) {
// Simple case: we have an umbrella header and there are no additional
// includes, we can just parse the umbrella header directly.
Modified: cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/InitHeaderSearch.cpp Thu Feb 2 04:59:12 2012
@@ -11,10 +11,6 @@
//
//===----------------------------------------------------------------------===//
-#ifdef HAVE_CLANG_CONFIG_H
-# include "clang/Config/config.h"
-#endif
-
#include "clang/Frontend/Utils.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/LangOptions.h"
@@ -29,6 +25,11 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Path.h"
+
+#ifdef HAVE_CLANG_CONFIG_H
+# include "clang/Config/config.h"
+#endif
+
#include "llvm/Config/config.h"
using namespace clang;
using namespace clang::frontend;
Modified: cfe/branches/tooling/lib/Frontend/Warnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Frontend/Warnings.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Frontend/Warnings.cpp (original)
+++ cfe/branches/tooling/lib/Frontend/Warnings.cpp Thu Feb 2 04:59:12 2012
@@ -31,7 +31,8 @@
#include <algorithm>
using namespace clang;
-// EmitUnknownDiagWarning - Emit a warning and typo hint for unknown warning opts
+// EmitUnknownDiagWarning - Emit a warning and typo hint for unknown warning
+// opts
static void EmitUnknownDiagWarning(DiagnosticsEngine &Diags,
StringRef Prefix, StringRef Opt,
bool isPositive) {
Modified: cfe/branches/tooling/lib/Headers/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Headers/module.map?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Headers/module.map (original)
+++ cfe/branches/tooling/lib/Headers/module.map Thu Feb 2 04:59:12 2012
@@ -1,9 +1,4 @@
-module __compiler_builtins [system] {
- explicit module altivec {
- requires altivec
- header "altivec.h"
- }
-
+module _Builtin_stdlib [system] {
explicit module float_constants {
header "float.h"
}
@@ -36,6 +31,18 @@
header "stdint.h"
}
+ explicit module varargs {
+ requires unavailable
+ header "varargs.h"
+ }
+}
+
+module _Builtin_intrinsics [system] {
+ explicit module altivec {
+ requires altivec
+ header "altivec.h"
+ }
+
explicit module intel {
requires x86
@@ -129,14 +136,12 @@
requires mm3dnow
header "mm3dnow.h"
}
+
+ explicit module mm_malloc {
+ header "mm_malloc.h"
+ }
}
- // FIXME: mm_malloc.h
// FIXME: tgmath.h
// FIXME: unwind.h
-
- explicit module varargs {
- requires unavailable
- header "varargs.h"
- }
}
Modified: cfe/branches/tooling/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/PPDirectives.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/PPDirectives.cpp (original)
+++ cfe/branches/tooling/lib/Lex/PPDirectives.cpp Thu Feb 2 04:59:12 2012
@@ -1007,10 +1007,18 @@
// collapse multiple consequtive white space between tokens, but this isn't
// specified by the standard.
std::string Message = CurLexer->ReadToEndOfLine();
+
+ // 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);
+
if (isWarning)
- Diag(Tok, diag::pp_hash_warning) << Message;
+ Diag(Tok, diag::pp_hash_warning) << Msg;
else
- Diag(Tok, diag::err_pp_hash_error) << Message;
+ Diag(Tok, diag::err_pp_hash_error) << Msg;
}
/// HandleIdentSCCSDirective - Handle a #ident/#sccs directive.
Modified: cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/branches/tooling/lib/Lex/PPMacroExpansion.cpp Thu Feb 2 04:59:12 2012
@@ -616,6 +616,7 @@
.Case("objc_arc", LangOpts.ObjCAutoRefCount)
.Case("objc_arc_weak", LangOpts.ObjCAutoRefCount &&
LangOpts.ObjCRuntimeHasWeak)
+ .Case("objc_default_synthesize_properties", LangOpts.ObjC2)
.Case("objc_fixed_enum", LangOpts.ObjC2)
.Case("objc_instancetype", LangOpts.ObjC2)
.Case("objc_modules", LangOpts.ObjC2 && LangOpts.Modules)
@@ -1032,7 +1033,8 @@
}
OS << (int)Value;
- Tok.setKind(tok::numeric_constant);
+ if (IsValid)
+ Tok.setKind(tok::numeric_constant);
} else if (II == Ident__has_include ||
II == Ident__has_include_next) {
// The argument to these two builtins should be a parenthesized
Modified: cfe/branches/tooling/lib/Sema/SemaAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaAttr.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaAttr.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaAttr.cpp Thu Feb 2 04:59:12 2012
@@ -365,7 +365,7 @@
}
PushPragmaVisibility(*this, type, PragmaLoc);
} else {
- PopPragmaVisibility();
+ PopPragmaVisibility(false, PragmaLoc);
}
}
@@ -383,23 +383,44 @@
}
}
-void Sema::PushNamespaceVisibilityAttr(const VisibilityAttr *Attr) {
+void Sema::PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
+ SourceLocation Loc) {
// Visibility calculations will consider the namespace's visibility.
// Here we just want to note that we're in a visibility context
// which overrides any enclosing #pragma context, but doesn't itself
// contribute visibility.
- PushPragmaVisibility(*this, NoVisibility, SourceLocation());
+ PushPragmaVisibility(*this, NoVisibility, Loc);
}
-void Sema::PopPragmaVisibility() {
- // Pop visibility from stack, if there is one on the stack.
- if (VisContext) {
- VisStack *Stack = static_cast<VisStack*>(VisContext);
-
- Stack->pop_back();
- // To simplify the implementation, never keep around an empty stack.
- if (Stack->empty())
- FreeVisContext();
+void Sema::PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc) {
+ if (!VisContext) {
+ Diag(EndLoc, diag::err_pragma_pop_visibility_mismatch);
+ return;
}
- // FIXME: Add diag for pop without push.
+
+ // Pop visibility from stack
+ VisStack *Stack = static_cast<VisStack*>(VisContext);
+
+ const std::pair<unsigned, SourceLocation> *Back = &Stack->back();
+ bool StartsWithPragma = Back->first != NoVisibility;
+ if (StartsWithPragma && IsNamespaceEnd) {
+ Diag(Back->second, diag::err_pragma_push_visibility_mismatch);
+ Diag(EndLoc, diag::note_surrounding_namespace_ends_here);
+
+ // For better error recovery, eat all pushes inside the namespace.
+ do {
+ Stack->pop_back();
+ Back = &Stack->back();
+ StartsWithPragma = Back->first != NoVisibility;
+ } while (StartsWithPragma);
+ } else if (!StartsWithPragma && !IsNamespaceEnd) {
+ Diag(EndLoc, diag::err_pragma_pop_visibility_mismatch);
+ Diag(Back->second, diag::note_surrounding_namespace_starts_here);
+ return;
+ }
+
+ Stack->pop_back();
+ // To simplify the implementation, never keep around an empty stack.
+ if (Stack->empty())
+ FreeVisContext();
}
Modified: cfe/branches/tooling/lib/Sema/SemaCXXScopeSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaCXXScopeSpec.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaCXXScopeSpec.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaCXXScopeSpec.cpp Thu Feb 2 04:59:12 2012
@@ -500,7 +500,7 @@
TypoCorrection Corrected;
Found.clear();
if ((Corrected = CorrectTypo(Found.getLookupNameInfo(),
- Found.getLookupKind(), S, &SS, &Validator,
+ Found.getLookupKind(), S, &SS, Validator,
LookupCtx, EnteringContext))) {
std::string CorrectedStr(Corrected.getAsString(getLangOptions()));
std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOptions()));
Modified: cfe/branches/tooling/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaChecking.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaChecking.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaChecking.cpp Thu Feb 2 04:59:12 2012
@@ -456,6 +456,8 @@
// Handle memory setting and copying functions.
if (CMId == Builtin::BIstrlcpy || CMId == Builtin::BIstrlcat)
CheckStrlcpycatArguments(TheCall, FnInfo);
+ else if (CMId == Builtin::BIstrncat)
+ CheckStrncatArguments(TheCall, FnInfo);
else
CheckMemaccessArguments(TheCall, CMId, FnInfo);
@@ -2198,11 +2200,14 @@
os.str()));
}
else {
- S.Diag(getLocationOfByte(CS.getStart()),
- diag::warn_printf_conversion_argument_type_mismatch)
- << ATR.getRepresentativeTypeName(S.Context) << Ex->getType()
- << getSpecifierRange(startSpecifier, specifierLen)
- << Ex->getSourceRange();
+ EmitFormatDiagnostic(
+ S.PDiag(diag::warn_printf_conversion_argument_type_mismatch)
+ << ATR.getRepresentativeTypeName(S.Context) << Ex->getType()
+ << getSpecifierRange(startSpecifier, specifierLen)
+ << Ex->getSourceRange(),
+ getLocationOfByte(CS.getStart()),
+ true,
+ getSpecifierRange(startSpecifier, specifierLen));
}
}
@@ -2313,12 +2318,13 @@
// Check the length modifier is valid with the given conversion specifier.
const LengthModifier &LM = FS.getLengthModifier();
if (!FS.hasValidLengthModifier()) {
- S.Diag(getLocationOfByte(LM.getStart()),
- diag::warn_format_nonsensical_length)
- << LM.toString() << CS.toString()
- << getSpecifierRange(startSpecifier, specifierLen)
- << FixItHint::CreateRemoval(getSpecifierRange(LM.getStart(),
- LM.getLength()));
+ const CharSourceRange &R = getSpecifierRange(LM.getStart(), LM.getLength());
+ EmitFormatDiagnostic(S.PDiag(diag::warn_format_nonsensical_length)
+ << LM.toString() << CS.toString()
+ << getSpecifierRange(startSpecifier, specifierLen),
+ getLocationOfByte(LM.getStart()),
+ /*IsStringLocation*/true, R,
+ FixItHint::CreateRemoval(R));
}
// The remaining checks depend on the data arguments.
@@ -2352,11 +2358,13 @@
getSpecifierRange(startSpecifier, specifierLen),
os.str()));
} else {
- S.Diag(getLocationOfByte(CS.getStart()),
- diag::warn_printf_conversion_argument_type_mismatch)
+ EmitFormatDiagnostic(
+ S.PDiag(diag::warn_printf_conversion_argument_type_mismatch)
<< ATR.getRepresentativeTypeName(S.Context) << Ex->getType()
- << getSpecifierRange(startSpecifier, specifierLen)
- << Ex->getSourceRange();
+ << Ex->getSourceRange(),
+ getLocationOfByte(CS.getStart()),
+ /*IsStringLocation*/true,
+ getSpecifierRange(startSpecifier, specifierLen));
}
}
@@ -2677,6 +2685,99 @@
OS.str());
}
+/// Check if two expressions refer to the same declaration.
+static bool referToTheSameDecl(const Expr *E1, const Expr *E2) {
+ if (const DeclRefExpr *D1 = dyn_cast_or_null<DeclRefExpr>(E1))
+ if (const DeclRefExpr *D2 = dyn_cast_or_null<DeclRefExpr>(E2))
+ return D1->getDecl() == D2->getDecl();
+ return false;
+}
+
+static const Expr *getStrlenExprArg(const Expr *E) {
+ if (const CallExpr *CE = dyn_cast<CallExpr>(E)) {
+ const FunctionDecl *FD = CE->getDirectCallee();
+ if (!FD || FD->getMemoryFunctionKind() != Builtin::BIstrlen)
+ return 0;
+ return CE->getArg(0)->IgnoreParenCasts();
+ }
+ return 0;
+}
+
+// Warn on anti-patterns as the 'size' argument to strncat.
+// The correct size argument should look like following:
+// strncat(dst, src, sizeof(dst) - strlen(dest) - 1);
+void Sema::CheckStrncatArguments(const CallExpr *CE,
+ IdentifierInfo *FnName) {
+ // Don't crash if the user has the wrong number of arguments.
+ if (CE->getNumArgs() < 3)
+ return;
+ const Expr *DstArg = CE->getArg(0)->IgnoreParenCasts();
+ const Expr *SrcArg = CE->getArg(1)->IgnoreParenCasts();
+ const Expr *LenArg = CE->getArg(2)->IgnoreParenCasts();
+
+ // Identify common expressions, which are wrongly used as the size argument
+ // to strncat and may lead to buffer overflows.
+ unsigned PatternType = 0;
+ if (const Expr *SizeOfArg = getSizeOfExprArg(LenArg)) {
+ // - sizeof(dst)
+ if (referToTheSameDecl(SizeOfArg, DstArg))
+ PatternType = 1;
+ // - sizeof(src)
+ else if (referToTheSameDecl(SizeOfArg, SrcArg))
+ PatternType = 2;
+ } else if (const BinaryOperator *BE = dyn_cast<BinaryOperator>(LenArg)) {
+ if (BE->getOpcode() == BO_Sub) {
+ const Expr *L = BE->getLHS()->IgnoreParenCasts();
+ const Expr *R = BE->getRHS()->IgnoreParenCasts();
+ // - sizeof(dst) - strlen(dst)
+ if (referToTheSameDecl(DstArg, getSizeOfExprArg(L)) &&
+ referToTheSameDecl(DstArg, getStrlenExprArg(R)))
+ PatternType = 1;
+ // - sizeof(src) - (anything)
+ else if (referToTheSameDecl(SrcArg, getSizeOfExprArg(L)))
+ PatternType = 2;
+ }
+ }
+
+ if (PatternType == 0)
+ return;
+
+ if (PatternType == 1)
+ Diag(DstArg->getLocStart(), diag::warn_strncat_large_size)
+ << LenArg->getSourceRange();
+ else
+ Diag(DstArg->getLocStart(), diag::warn_strncat_src_size)
+ << LenArg->getSourceRange();
+
+ // Output a FIXIT hint if the destination is an array (rather than a
+ // pointer to an array). This could be enhanced to handle some
+ // pointers if we know the actual size, like if DstArg is 'array+2'
+ // we could say 'sizeof(array)-2'.
+ QualType DstArgTy = DstArg->getType();
+
+ // Only handle constant-sized or VLAs, but not flexible members.
+ if (const ConstantArrayType *CAT = Context.getAsConstantArrayType(DstArgTy)) {
+ // Only issue the FIXIT for arrays of size > 1.
+ if (CAT->getSize().getSExtValue() <= 1)
+ return;
+ } else if (!DstArgTy->isVariableArrayType()) {
+ return;
+ }
+
+ llvm::SmallString<128> sizeString;
+ llvm::raw_svector_ostream OS(sizeString);
+ OS << "sizeof(";
+ DstArg->printPretty(OS, Context, 0, getPrintingPolicy());
+ OS << ") - ";
+ OS << "strlen(";
+ DstArg->printPretty(OS, Context, 0, getPrintingPolicy());
+ OS << ") - 1";
+
+ Diag(LenArg->getLocStart(), diag::note_strncat_wrong_size)
+ << FixItHint::CreateReplacement(LenArg->getSourceRange(),
+ OS.str());
+}
+
//===--- CHECK: Return Address of Stack Variable --------------------------===//
static Expr *EvalVal(Expr *E, SmallVectorImpl<DeclRefExpr *> &refVars);
@@ -3657,8 +3758,8 @@
return false;
// Special-case bitfields of width 1: booleans are naturally 0/1, and
- // therefore don't strictly fit into a bitfield of width 1.
- if (FieldWidth == 1 && Value.getBoolValue() == TruncatedValue.getBoolValue())
+ // therefore don't strictly fit into a signed bitfield of width 1.
+ if (FieldWidth == 1 && Value == 1)
return false;
std::string PrettyValue = Value.toString(10);
Modified: cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaCodeComplete.cpp Thu Feb 2 04:59:12 2012
@@ -3637,10 +3637,7 @@
// If there are no prior enumerators in C++, check whether we have to
// qualify the names of the enumerators that we suggest, because they
// may not be visible in this scope.
- Qualifier = getRequiredQualification(Context, CurContext,
- Enum->getDeclContext());
-
- // FIXME: Scoped enums need to start with "EnumDecl" as the context!
+ Qualifier = getRequiredQualification(Context, CurContext, Enum);
}
// Add any enumerators that have not yet been mentioned.
Modified: cfe/branches/tooling/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDecl.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDecl.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDecl.cpp Thu Feb 2 04:59:12 2012
@@ -174,7 +174,7 @@
if (CorrectedII) {
TypeNameValidatorCCC Validator(true);
TypoCorrection Correction = CorrectTypo(Result.getLookupNameInfo(),
- Kind, S, SS, &Validator);
+ Kind, S, SS, Validator);
IdentifierInfo *NewII = Correction.getCorrectionAsIdentifierInfo();
TemplateTy Template;
bool MemberOfUnknownSpecialization;
@@ -371,7 +371,7 @@
TypeNameValidatorCCC Validator(false);
if (TypoCorrection Corrected = CorrectTypo(DeclarationNameInfo(&II, IILoc),
LookupOrdinaryName, S, SS,
- &Validator)) {
+ Validator)) {
std::string CorrectedStr(Corrected.getAsString(getLangOptions()));
std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOptions()));
@@ -576,7 +576,7 @@
CorrectionCandidateCallback DefaultValidator;
if (TypoCorrection Corrected = CorrectTypo(Result.getLookupNameInfo(),
Result.getLookupKind(), S,
- &SS, &DefaultValidator)) {
+ &SS, DefaultValidator)) {
unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
unsigned QualifiedDiag = diag::err_no_member_suggest;
std::string CorrectedStr(Corrected.getAsString(getLangOptions()));
@@ -1274,7 +1274,7 @@
DeclFilterCCC<ObjCInterfaceDecl> Validator;
if (TypoCorrection C = CorrectTypo(DeclarationNameInfo(Id, IdLoc),
LookupOrdinaryName, TUScope, NULL,
- &Validator)) {
+ Validator)) {
IDecl = C.getCorrectionDeclAs<ObjCInterfaceDecl>();
Diag(IdLoc, diag::err_undef_interface_suggest)
<< Id << IDecl->getDeclName()
@@ -2952,9 +2952,10 @@
SmallVector<NamedDecl*, 2> Chain;
Chain.push_back(Anon);
- if (InjectAnonymousStructOrUnionMembers(*this, S, CurContext,
- Record->getDefinition(),
- AS_none, Chain, true))
+ RecordDecl *RecordDef = Record->getDefinition();
+ if (!RecordDef || InjectAnonymousStructOrUnionMembers(*this, S, CurContext,
+ RecordDef, AS_none,
+ Chain, true))
Anon->setInvalidDecl();
return Anon;
@@ -4498,7 +4499,7 @@
// If the qualified name lookup yielded nothing, try typo correction
} else if ((Correction = SemaRef.CorrectTypo(Prev.getLookupNameInfo(),
Prev.getLookupKind(), 0, 0,
- &Validator, NewDC))) {
+ Validator, NewDC))) {
// Trap errors.
Sema::SFINAETrap Trap(SemaRef);
@@ -7359,7 +7360,7 @@
TypoCorrection Corrected;
DeclFilterCCC<FunctionDecl> Validator;
if (S && (Corrected = CorrectTypo(DeclarationNameInfo(&II, Loc),
- LookupOrdinaryName, S, 0, &Validator))) {
+ LookupOrdinaryName, S, 0, Validator))) {
std::string CorrectedStr = Corrected.getAsString(getLangOptions());
std::string CorrectedQuotedStr = Corrected.getQuoted(getLangOptions());
FunctionDecl *Func = Corrected.getCorrectionDeclAs<FunctionDecl>();
@@ -9044,6 +9045,8 @@
: ObjCIvarDecl::None;
// Must set ivar's DeclContext to its enclosing interface.
ObjCContainerDecl *EnclosingDecl = cast<ObjCContainerDecl>(CurContext);
+ if (!EnclosingDecl || EnclosingDecl->isInvalidDecl())
+ return 0;
ObjCContainerDecl *EnclosingContext;
if (ObjCImplementationDecl *IMPDecl =
dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
Modified: cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclAttr.cpp Thu Feb 2 04:59:12 2012
@@ -2160,7 +2160,7 @@
}
D->addAttr(::new (S.Context) CleanupAttr(Attr.getRange(), S.Context, FD));
- S.MarkDeclarationReferenced(Attr.getParameterLoc(), FD);
+ S.MarkFunctionReferenced(Attr.getParameterLoc(), FD);
}
/// Handle __attribute__((format_arg((idx)))) attribute based on
Modified: cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclCXX.cpp Thu Feb 2 04:59:12 2012
@@ -1882,7 +1882,7 @@
MemInitializerValidatorCCC Validator(ClassDecl);
if (R.empty() && BaseType.isNull() &&
(Corr = CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S, &SS,
- &Validator, ClassDecl))) {
+ Validator, ClassDecl))) {
std::string CorrectedStr(Corr.getAsString(getLangOptions()));
std::string CorrectedQuotedStr(Corr.getQuoted(getLangOptions()));
if (FieldDecl *Member = Corr.getCorrectionDeclAs<FieldDecl>()) {
@@ -2382,14 +2382,14 @@
ParmVarDecl *Param = Constructor->getParamDecl(0);
QualType ParamType = Param->getType().getNonReferenceType();
- SemaRef.MarkDeclarationReferenced(Constructor->getLocation(), Param);
-
Expr *CopyCtorArg =
DeclRefExpr::Create(SemaRef.Context, NestedNameSpecifierLoc(),
SourceLocation(), Param,
Constructor->getLocation(), ParamType,
VK_LValue, 0);
+ SemaRef.MarkDeclRefReferenced(cast<DeclRefExpr>(CopyCtorArg));
+
// Cast to the base class to avoid ambiguities.
QualType ArgTy =
SemaRef.Context.getQualifiedType(BaseSpec->getType().getUnqualifiedType(),
@@ -2454,8 +2454,6 @@
ParmVarDecl *Param = Constructor->getParamDecl(0);
QualType ParamType = Param->getType().getNonReferenceType();
- SemaRef.MarkDeclarationReferenced(Constructor->getLocation(), Param);
-
// Suppress copying zero-width bitfields.
if (Field->isBitField() && Field->getBitWidthValue(SemaRef.Context) == 0)
return false;
@@ -2465,6 +2463,8 @@
SourceLocation(), Param,
Loc, ParamType, VK_LValue, 0);
+ SemaRef.MarkDeclRefReferenced(cast<DeclRefExpr>(MemberExprBase));
+
if (Moving) {
MemberExprBase = CastForMoving(SemaRef, MemberExprBase);
}
@@ -2796,7 +2796,7 @@
Constructor->setCtorInitializers(initializer);
if (CXXDestructorDecl *Dtor = LookupDestructor(Constructor->getParent())) {
- MarkDeclarationReferenced(Initializer->getSourceLocation(), Dtor);
+ MarkFunctionReferenced(Initializer->getSourceLocation(), Dtor);
DiagnoseUseOfDecl(Dtor, Initializer->getSourceLocation());
}
@@ -3272,7 +3272,7 @@
<< Field->getDeclName()
<< FieldType);
- MarkDeclarationReferenced(Location, const_cast<CXXDestructorDecl*>(Dtor));
+ MarkFunctionReferenced(Location, const_cast<CXXDestructorDecl*>(Dtor));
}
llvm::SmallPtrSet<const RecordType *, 8> DirectVirtualBases;
@@ -3304,7 +3304,7 @@
<< Base->getType()
<< Base->getSourceRange());
- MarkDeclarationReferenced(Location, const_cast<CXXDestructorDecl*>(Dtor));
+ MarkFunctionReferenced(Location, const_cast<CXXDestructorDecl*>(Dtor));
}
// Virtual bases.
@@ -3332,7 +3332,7 @@
PDiag(diag::err_access_dtor_vbase)
<< VBase->getType());
- MarkDeclarationReferenced(Location, const_cast<CXXDestructorDecl*>(Dtor));
+ MarkFunctionReferenced(Location, const_cast<CXXDestructorDecl*>(Dtor));
}
}
@@ -5306,7 +5306,7 @@
if (FindDeallocationFunction(Loc, RD, Name, OperatorDelete))
return true;
- MarkDeclarationReferenced(Loc, OperatorDelete);
+ MarkFunctionReferenced(Loc, OperatorDelete);
Destructor->setOperatorDelete(OperatorDelete);
}
@@ -5683,7 +5683,7 @@
// FIXME: Should we be merging attributes?
if (const VisibilityAttr *Attr = Namespc->getAttr<VisibilityAttr>())
- PushNamespaceVisibilityAttr(Attr);
+ PushNamespaceVisibilityAttr(Attr, Loc);
if (IsStd)
StdNamespace = Namespc;
@@ -5758,7 +5758,7 @@
Namespc->setRBraceLoc(RBrace);
PopDeclContext();
if (Namespc->hasAttr<VisibilityAttr>())
- PopPragmaVisibility();
+ PopPragmaVisibility(true, RBrace);
}
CXXRecordDecl *Sema::getStdBadAlloc() const {
@@ -5953,7 +5953,7 @@
R.clear();
if (TypoCorrection Corrected = S.CorrectTypo(R.getLookupNameInfo(),
R.getLookupKind(), Sc, &SS,
- &Validator)) {
+ Validator)) {
std::string CorrectedStr(Corrected.getAsString(S.getLangOptions()));
std::string CorrectedQuotedStr(Corrected.getQuoted(S.getLangOptions()));
if (DeclContext *DC = S.computeDeclContext(SS, false))
@@ -9030,7 +9030,7 @@
CheckNonNullArguments(NonNull, ExprArgs.get(), ConstructLoc);
}
- MarkDeclarationReferenced(ConstructLoc, Constructor);
+ MarkFunctionReferenced(ConstructLoc, Constructor);
return Owned(CXXConstructExpr::Create(Context, DeclInitType, ConstructLoc,
Constructor, Elidable, Exprs, NumExprs,
HadMultipleCandidates, RequiresZeroInit,
@@ -9052,7 +9052,7 @@
Expr *Temp = TempResult.takeAs<Expr>();
CheckImplicitConversions(Temp, VD->getLocation());
- MarkDeclarationReferenced(VD->getLocation(), Constructor);
+ MarkFunctionReferenced(VD->getLocation(), Constructor);
Temp = MaybeCreateExprWithCleanups(Temp);
VD->setInit(Temp);
@@ -9068,7 +9068,7 @@
if (ClassDecl->isDependentContext()) return;
CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
- MarkDeclarationReferenced(VD->getLocation(), Destructor);
+ MarkFunctionReferenced(VD->getLocation(), Destructor);
CheckDestructorAccess(VD->getLocation(), Destructor,
PDiag(diag::err_access_dtor_var)
<< VD->getDeclName()
@@ -10905,7 +10905,7 @@
// C++ [basic.def.odr]p2:
// [...] A virtual member function is used if it is not pure. [...]
if (MD->isVirtual() && !MD->isPure())
- MarkDeclarationReferenced(Loc, MD);
+ MarkFunctionReferenced(Loc, MD);
}
// Only classes that have virtual bases need a VTT.
@@ -10965,7 +10965,7 @@
->getAs<RecordType>()) {
CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
if (CXXDestructorDecl *Destructor = LookupDestructor(RD)) {
- MarkDeclarationReferenced(Field->getLocation(), Destructor);
+ MarkFunctionReferenced(Field->getLocation(), Destructor);
CheckDestructorAccess(Field->getLocation(), Destructor,
PDiag(diag::err_access_dtor_ivar)
<< Context.getBaseElementType(Field->getType()));
Modified: cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaDeclObjC.cpp Thu Feb 2 04:59:12 2012
@@ -423,7 +423,7 @@
ObjCInterfaceValidatorCCC Validator(IDecl);
if (TypoCorrection Corrected = CorrectTypo(
DeclarationNameInfo(SuperName, SuperLoc), LookupOrdinaryName, TUScope,
- NULL, &Validator)) {
+ NULL, Validator)) {
PrevDecl = Corrected.getCorrectionDeclAs<ObjCInterfaceDecl>();
Diag(SuperLoc, diag::err_undef_superclass_suggest)
<< SuperName << ClassName << PrevDecl->getDeclName();
@@ -655,7 +655,7 @@
DeclFilterCCC<ObjCProtocolDecl> Validator;
TypoCorrection Corrected = CorrectTypo(
DeclarationNameInfo(ProtocolId[i].first, ProtocolId[i].second),
- LookupObjCProtocolName, TUScope, NULL, &Validator);
+ LookupObjCProtocolName, TUScope, NULL, Validator);
if ((PDecl = Corrected.getCorrectionDeclAs<ObjCProtocolDecl>())) {
Diag(ProtocolId[i].second, diag::err_undeclared_protocol_suggest)
<< ProtocolId[i].first << Corrected.getCorrection();
@@ -893,7 +893,7 @@
ObjCInterfaceValidatorCCC Validator;
if (TypoCorrection Corrected = CorrectTypo(
DeclarationNameInfo(ClassName, ClassLoc), LookupOrdinaryName, TUScope,
- NULL, &Validator)) {
+ NULL, Validator)) {
// Suggest the (potentially) correct interface name. However, put the
// fix-it hint itself in a separate note, since changing the name in
// the warning would make the fix-it change semantics.However, don't
Modified: cfe/branches/tooling/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExpr.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExpr.cpp Thu Feb 2 04:59:12 2012
@@ -1263,7 +1263,8 @@
i != e; ++i) {
BlockScopeInfo *innerBlock = cast<BlockScopeInfo>(S.FunctionScopes[i]);
innerBlock->AddCapture(Cap.getVariable(), Cap.isReferenceCapture(),
- /*nested*/ true, Cap.getCopyExpr());
+ /*nested*/ true, Cap.getLocation(),
+ Cap.getCopyExpr());
}
return Cap.isReferenceCapture() ? CR_CaptureByRef : CR_Capture;
@@ -1330,8 +1331,6 @@
return CR_Error;
}
- S.MarkDeclarationReferenced(loc, var);
-
// The BlocksAttr indicates the variable is bound by-reference.
bool byRef = var->hasAttr<BlocksAttr>();
@@ -1377,7 +1376,7 @@
cast<BlockScopeInfo>(S.FunctionScopes[functionScopesIndex]);
// Build a valid capture in this scope.
- blockScope->AddCapture(var, byRef, /*nested*/ false, copyExpr);
+ blockScope->AddCapture(var, byRef, /*nested*/ false, loc, copyExpr);
// Propagate that to inner captures if necessary.
return propagateCapture(S, functionScopesIndex,
@@ -1410,6 +1409,8 @@
NameInfo.getLoc(), true);
}
+ S.MarkBlockDeclRefReferenced(BDRE);
+
return S.Owned(BDRE);
}
@@ -1441,13 +1442,13 @@
}
}
- MarkDeclarationReferenced(NameInfo.getLoc(), D);
+ DeclRefExpr *E = DeclRefExpr::Create(Context,
+ SS ? SS->getWithLocInContext(Context)
+ : NestedNameSpecifierLoc(),
+ SourceLocation(),
+ D, NameInfo, Ty, VK);
- Expr *E = DeclRefExpr::Create(Context,
- SS ? SS->getWithLocInContext(Context)
- : NestedNameSpecifierLoc(),
- SourceLocation(),
- D, NameInfo, Ty, VK);
+ MarkDeclRefReferenced(E);
// Just in case we're building an illegal pointer-to-member.
FieldDecl *FD = dyn_cast<FieldDecl>(D);
@@ -1611,7 +1612,7 @@
// We didn't find anything, so try to correct for a typo.
TypoCorrection Corrected;
if (S && (Corrected = CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(),
- S, &SS, &CCC))) {
+ S, &SS, CCC))) {
std::string CorrectedStr(Corrected.getAsString(getLangOptions()));
std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOptions()));
R.setLookupName(Corrected.getCorrection());
@@ -2003,7 +2004,7 @@
if (SelfExpr.isInvalid())
return ExprError();
- MarkDeclarationReferenced(Loc, IV);
+ MarkAnyDeclReferenced(Loc, IV);
return Owned(new (Context)
ObjCIvarRefExpr(IV, IV->getType(), Loc,
SelfExpr.take(), true, true));
@@ -3741,7 +3742,7 @@
DeclRefExpr *ConfigDR = new (Context) DeclRefExpr(
ConfigDecl, ConfigQTy, VK_LValue, LLLLoc);
- MarkDeclarationReferenced(LLLLoc, ConfigDecl);
+ MarkFunctionReferenced(LLLLoc, ConfigDecl);
return ActOnCallExpr(S, ConfigDR, LLLLoc, ExecConfig, GGGLoc, 0,
/*IsExecConfig=*/true);
@@ -9435,9 +9436,7 @@
}
void Sema::PopExpressionEvaluationContext() {
- // Pop the current expression evaluation context off the stack.
- ExpressionEvaluationContextRecord Rec = ExprEvalContexts.back();
- ExprEvalContexts.pop_back();
+ ExpressionEvaluationContextRecord& Rec = ExprEvalContexts.back();
// When are coming out of an unevaluated context, clear out any
// temporaries that we may have created as part of the evaluation of
@@ -9452,6 +9451,9 @@
} else {
ExprNeedsCleanups |= Rec.ParentNeedsCleanups;
}
+
+ // Pop the current expression evaluation context off the stack.
+ ExprEvalContexts.pop_back();
}
void Sema::DiscardCleanupsInEvaluationContext() {
@@ -9467,55 +9469,49 @@
return TranformToPotentiallyEvaluated(E);
}
-/// \brief Note that the given declaration was referenced in the source code.
-///
-/// This routine should be invoke whenever a given declaration is referenced
-/// in the source code, and where that reference occurred. If this declaration
-/// reference means that the the declaration is used (C++ [basic.def.odr]p2,
-/// C99 6.9p3), then the declaration will be marked as used.
-///
-/// \param Loc the location where the declaration was referenced.
-///
-/// \param D the declaration that has been referenced by the source code.
-void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) {
- assert(D && "No declaration?");
-
- D->setReferenced();
-
- if (D->isUsed(false))
- return;
-
- if (!isa<VarDecl>(D) && !isa<FunctionDecl>(D))
- return;
-
+bool IsPotentiallyEvaluatedContext(Sema &SemaRef) {
// Do not mark anything as "used" within a dependent context; wait for
// an instantiation.
- if (CurContext->isDependentContext())
- return;
+ if (SemaRef.CurContext->isDependentContext())
+ return false;
- switch (ExprEvalContexts.back().Context) {
- case Unevaluated:
+ switch (SemaRef.ExprEvalContexts.back().Context) {
+ case Sema::Unevaluated:
// We are in an expression that is not potentially evaluated; do nothing.
// (Depending on how you read the standard, we actually do need to do
// something here for null pointer constants, but the standard's
// definition of a null pointer constant is completely crazy.)
- return;
+ return false;
- case ConstantEvaluated:
- case PotentiallyEvaluated:
+ case Sema::ConstantEvaluated:
+ case Sema::PotentiallyEvaluated:
// We are in a potentially evaluated expression (or a constant-expression
// in C++03); we need to do implicit template instantiation, implicitly
// define class members, and mark most declarations as used.
- break;
+ return true;
- case PotentiallyEvaluatedIfUsed:
+ case Sema::PotentiallyEvaluatedIfUsed:
// Referenced declarations will only be used if the construct in the
// containing expression is used.
- return;
+ return false;
}
+}
+
+/// \brief Mark a function referenced, and check whether it is odr-used
+/// (C++ [basic.def.odr]p2, C99 6.9p3)
+void Sema::MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func) {
+ assert(Func && "No function?");
+
+ Func->setReferenced();
+
+ if (Func->isUsed(false))
+ return;
+
+ if (!IsPotentiallyEvaluatedContext(*this))
+ return;
// Note that this declaration has been used.
- if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(D)) {
+ if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(Func)) {
if (Constructor->isDefaulted()) {
if (Constructor->isDefaultConstructor()) {
if (Constructor->isTrivial())
@@ -9532,12 +9528,13 @@
}
MarkVTableUsed(Loc, Constructor->getParent());
- } else if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(D)) {
+ } else if (CXXDestructorDecl *Destructor =
+ dyn_cast<CXXDestructorDecl>(Func)) {
if (Destructor->isDefaulted() && !Destructor->isUsed(false))
DefineImplicitDestructor(Loc, Destructor);
if (Destructor->isVirtual())
MarkVTableUsed(Loc, Destructor->getParent());
- } else if (CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(D)) {
+ } else if (CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
if (MethodDecl->isDefaulted() && MethodDecl->isOverloadedOperator() &&
MethodDecl->getOverloadedOperator() == OO_Equal) {
if (!MethodDecl->isUsed(false)) {
@@ -9549,99 +9546,143 @@
} else if (MethodDecl->isVirtual())
MarkVTableUsed(Loc, MethodDecl->getParent());
}
- if (FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
- // Recursive functions should be marked when used from another function.
- if (CurContext == Function) return;
-
- // Implicit instantiation of function templates and member functions of
- // class templates.
- if (Function->isImplicitlyInstantiable()) {
- bool AlreadyInstantiated = false;
- if (FunctionTemplateSpecializationInfo *SpecInfo
- = Function->getTemplateSpecializationInfo()) {
- if (SpecInfo->getPointOfInstantiation().isInvalid())
- SpecInfo->setPointOfInstantiation(Loc);
- else if (SpecInfo->getTemplateSpecializationKind()
- == TSK_ImplicitInstantiation)
- AlreadyInstantiated = true;
- } else if (MemberSpecializationInfo *MSInfo
- = Function->getMemberSpecializationInfo()) {
- if (MSInfo->getPointOfInstantiation().isInvalid())
- MSInfo->setPointOfInstantiation(Loc);
- else if (MSInfo->getTemplateSpecializationKind()
- == TSK_ImplicitInstantiation)
- AlreadyInstantiated = true;
- }
-
- if (!AlreadyInstantiated) {
- if (isa<CXXRecordDecl>(Function->getDeclContext()) &&
- cast<CXXRecordDecl>(Function->getDeclContext())->isLocalClass())
- PendingLocalImplicitInstantiations.push_back(std::make_pair(Function,
- Loc));
- else if (Function->getTemplateInstantiationPattern()->isConstexpr())
- // Do not defer instantiations of constexpr functions, to avoid the
- // expression evaluator needing to call back into Sema if it sees a
- // call to such a function.
- InstantiateFunctionDefinition(Loc, Function);
- else
- PendingInstantiations.push_back(std::make_pair(Function, Loc));
- }
- } else {
- // Walk redefinitions, as some of them may be instantiable.
- for (FunctionDecl::redecl_iterator i(Function->redecls_begin()),
- e(Function->redecls_end()); i != e; ++i) {
- if (!i->isUsed(false) && i->isImplicitlyInstantiable())
- MarkDeclarationReferenced(Loc, *i);
- }
+
+ // Recursive functions should be marked when used from another function.
+ // FIXME: Is this really right?
+ if (CurContext == Func) return;
+
+ // Implicit instantiation of function templates and member functions of
+ // class templates.
+ if (Func->isImplicitlyInstantiable()) {
+ bool AlreadyInstantiated = false;
+ if (FunctionTemplateSpecializationInfo *SpecInfo
+ = Func->getTemplateSpecializationInfo()) {
+ if (SpecInfo->getPointOfInstantiation().isInvalid())
+ SpecInfo->setPointOfInstantiation(Loc);
+ else if (SpecInfo->getTemplateSpecializationKind()
+ == TSK_ImplicitInstantiation)
+ AlreadyInstantiated = true;
+ } else if (MemberSpecializationInfo *MSInfo
+ = Func->getMemberSpecializationInfo()) {
+ if (MSInfo->getPointOfInstantiation().isInvalid())
+ MSInfo->setPointOfInstantiation(Loc);
+ else if (MSInfo->getTemplateSpecializationKind()
+ == TSK_ImplicitInstantiation)
+ AlreadyInstantiated = true;
}
- // Keep track of used but undefined functions.
- if (!Function->isPure() && !Function->hasBody() &&
- Function->getLinkage() != ExternalLinkage) {
- SourceLocation &old = UndefinedInternals[Function->getCanonicalDecl()];
- if (old.isInvalid()) old = Loc;
+ if (!AlreadyInstantiated) {
+ if (isa<CXXRecordDecl>(Func->getDeclContext()) &&
+ cast<CXXRecordDecl>(Func->getDeclContext())->isLocalClass())
+ PendingLocalImplicitInstantiations.push_back(std::make_pair(Func,
+ Loc));
+ else if (Func->getTemplateInstantiationPattern()->isConstexpr())
+ // Do not defer instantiations of constexpr functions, to avoid the
+ // expression evaluator needing to call back into Sema if it sees a
+ // call to such a function.
+ InstantiateFunctionDefinition(Loc, Func);
+ else
+ PendingInstantiations.push_back(std::make_pair(Func, Loc));
}
+ } else {
+ // Walk redefinitions, as some of them may be instantiable.
+ for (FunctionDecl::redecl_iterator i(Func->redecls_begin()),
+ e(Func->redecls_end()); i != e; ++i) {
+ if (!i->isUsed(false) && i->isImplicitlyInstantiable())
+ MarkFunctionReferenced(Loc, *i);
+ }
+ }
- Function->setUsed(true);
- return;
+ // Keep track of used but undefined functions.
+ if (!Func->isPure() && !Func->hasBody() &&
+ Func->getLinkage() != ExternalLinkage) {
+ SourceLocation &old = UndefinedInternals[Func->getCanonicalDecl()];
+ if (old.isInvalid()) old = Loc;
}
- if (VarDecl *Var = dyn_cast<VarDecl>(D)) {
- // Implicit instantiation of static data members of class templates.
- if (Var->isStaticDataMember() &&
- Var->getInstantiatedFromStaticDataMember()) {
- MemberSpecializationInfo *MSInfo = Var->getMemberSpecializationInfo();
- assert(MSInfo && "Missing member specialization information?");
- if (MSInfo->getPointOfInstantiation().isInvalid() &&
- MSInfo->getTemplateSpecializationKind()== TSK_ImplicitInstantiation) {
- MSInfo->setPointOfInstantiation(Loc);
- // This is a modification of an existing AST node. Notify listeners.
- if (ASTMutationListener *L = getASTMutationListener())
- L->StaticDataMemberInstantiated(Var);
- if (Var->isUsableInConstantExpressions())
- // Do not defer instantiations of variables which could be used in a
- // constant expression.
- InstantiateStaticDataMemberDefinition(Loc, Var);
- else
- PendingInstantiations.push_back(std::make_pair(Var, Loc));
- }
- }
+ Func->setUsed(true);
+}
- // Keep track of used but undefined variables. We make a hole in
- // the warning for static const data members with in-line
- // initializers.
- // FIXME: The hole we make for static const data members is too wide!
- // We need to implement the C++11 rules for odr-used.
- if (Var->hasDefinition() == VarDecl::DeclarationOnly
- && Var->getLinkage() != ExternalLinkage
- && !(Var->isStaticDataMember() && Var->hasInit())) {
- SourceLocation &old = UndefinedInternals[Var->getCanonicalDecl()];
- if (old.isInvalid()) old = Loc;
- }
+/// \brief Mark a variable referenced, and check whether it is odr-used
+/// (C++ [basic.def.odr]p2, C99 6.9p3). Note that this should not be
+/// used directly for normal expressions referring to VarDecl.
+void Sema::MarkVariableReferenced(SourceLocation Loc, VarDecl *Var) {
+ Var->setReferenced();
+
+ if (Var->isUsed(false))
+ return;
- D->setUsed(true);
+ if (!IsPotentiallyEvaluatedContext(*this))
return;
+
+ // Implicit instantiation of static data members of class templates.
+ if (Var->isStaticDataMember() &&
+ Var->getInstantiatedFromStaticDataMember()) {
+ MemberSpecializationInfo *MSInfo = Var->getMemberSpecializationInfo();
+ assert(MSInfo && "Missing member specialization information?");
+ if (MSInfo->getPointOfInstantiation().isInvalid() &&
+ MSInfo->getTemplateSpecializationKind()== TSK_ImplicitInstantiation) {
+ MSInfo->setPointOfInstantiation(Loc);
+ // This is a modification of an existing AST node. Notify listeners.
+ if (ASTMutationListener *L = getASTMutationListener())
+ L->StaticDataMemberInstantiated(Var);
+ if (Var->isUsableInConstantExpressions())
+ // Do not defer instantiations of variables which could be used in a
+ // constant expression.
+ InstantiateStaticDataMemberDefinition(Loc, Var);
+ else
+ PendingInstantiations.push_back(std::make_pair(Var, Loc));
+ }
+ }
+
+ // Keep track of used but undefined variables. We make a hole in
+ // the warning for static const data members with in-line
+ // initializers.
+ // FIXME: The hole we make for static const data members is too wide!
+ // We need to implement the C++11 rules for odr-used.
+ if (Var->hasDefinition() == VarDecl::DeclarationOnly
+ && Var->getLinkage() != ExternalLinkage
+ && !(Var->isStaticDataMember() && Var->hasInit())) {
+ SourceLocation &old = UndefinedInternals[Var->getCanonicalDecl()];
+ if (old.isInvalid()) old = Loc;
}
+
+ Var->setUsed(true);
+}
+
+static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc,
+ Decl *D, Expr *E) {
+ // TODO: Add special handling for variables
+ SemaRef.MarkAnyDeclReferenced(Loc, D);
+}
+
+/// \brief Perform reference-marking and odr-use handling for a
+/// BlockDeclRefExpr.
+void Sema::MarkBlockDeclRefReferenced(BlockDeclRefExpr *E) {
+ MarkExprReferenced(*this, E->getLocation(), E->getDecl(), E);
+}
+
+/// \brief Perform reference-marking and odr-use handling for a DeclRefExpr.
+void Sema::MarkDeclRefReferenced(DeclRefExpr *E) {
+ MarkExprReferenced(*this, E->getLocation(), E->getDecl(), E);
+}
+
+/// \brief Perform reference-marking and odr-use handling for a MemberExpr.
+void Sema::MarkMemberReferenced(MemberExpr *E) {
+ MarkExprReferenced(*this, E->getMemberLoc(), E->getMemberDecl(), E);
+}
+
+/// \brief Perform marking for a reference to an aribitrary declaration. It
+/// marks the declaration referenced, and performs odr-use checking for functions
+/// and variables. This method should not be used when building an normal
+/// expression which refers to a variable.
+void Sema::MarkAnyDeclReferenced(SourceLocation Loc, Decl *D) {
+ if (VarDecl *VD = dyn_cast<VarDecl>(D))
+ MarkVariableReferenced(Loc, VD);
+ else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
+ MarkFunctionReferenced(Loc, FD);
+ else
+ D->setReferenced();
}
namespace {
@@ -9665,7 +9706,7 @@
bool MarkReferencedDecls::TraverseTemplateArgument(
const TemplateArgument &Arg) {
if (Arg.getKind() == TemplateArgument::Declaration) {
- S.MarkDeclarationReferenced(Loc, Arg.getAsDecl());
+ S.MarkAnyDeclReferenced(Loc, Arg.getAsDecl());
}
return Inherited::TraverseTemplateArgument(Arg);
@@ -9698,37 +9739,37 @@
explicit EvaluatedExprMarker(Sema &S) : Inherited(S.Context), S(S) { }
void VisitDeclRefExpr(DeclRefExpr *E) {
- S.MarkDeclarationReferenced(E->getLocation(), E->getDecl());
+ S.MarkDeclRefReferenced(E);
}
void VisitMemberExpr(MemberExpr *E) {
- S.MarkDeclarationReferenced(E->getMemberLoc(), E->getMemberDecl());
+ S.MarkMemberReferenced(E);
Inherited::VisitMemberExpr(E);
}
void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
- S.MarkDeclarationReferenced(E->getLocStart(),
+ S.MarkFunctionReferenced(E->getLocStart(),
const_cast<CXXDestructorDecl*>(E->getTemporary()->getDestructor()));
Visit(E->getSubExpr());
}
void VisitCXXNewExpr(CXXNewExpr *E) {
if (E->getConstructor())
- S.MarkDeclarationReferenced(E->getLocStart(), E->getConstructor());
+ S.MarkFunctionReferenced(E->getLocStart(), E->getConstructor());
if (E->getOperatorNew())
- S.MarkDeclarationReferenced(E->getLocStart(), E->getOperatorNew());
+ S.MarkFunctionReferenced(E->getLocStart(), E->getOperatorNew());
if (E->getOperatorDelete())
- S.MarkDeclarationReferenced(E->getLocStart(), E->getOperatorDelete());
+ S.MarkFunctionReferenced(E->getLocStart(), E->getOperatorDelete());
Inherited::VisitCXXNewExpr(E);
}
void VisitCXXDeleteExpr(CXXDeleteExpr *E) {
if (E->getOperatorDelete())
- S.MarkDeclarationReferenced(E->getLocStart(), E->getOperatorDelete());
+ S.MarkFunctionReferenced(E->getLocStart(), E->getOperatorDelete());
QualType Destroyed = S.Context.getBaseElementType(E->getDestroyedType());
if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) {
CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
- S.MarkDeclarationReferenced(E->getLocStart(),
+ S.MarkFunctionReferenced(E->getLocStart(),
S.LookupDestructor(Record));
}
@@ -9736,12 +9777,12 @@
}
void VisitCXXConstructExpr(CXXConstructExpr *E) {
- S.MarkDeclarationReferenced(E->getLocStart(), E->getConstructor());
+ S.MarkFunctionReferenced(E->getLocStart(), E->getConstructor());
Inherited::VisitCXXConstructExpr(E);
}
void VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
- S.MarkDeclarationReferenced(E->getLocation(), E->getDecl());
+ S.MarkBlockDeclRefReferenced(E);
}
void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Modified: cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprCXX.cpp Thu Feb 2 04:59:12 2012
@@ -645,7 +645,7 @@
if (!Destructor)
return Owned(E);
- MarkDeclarationReferenced(E->getExprLoc(), Destructor);
+ MarkFunctionReferenced(E->getExprLoc(), Destructor);
CheckDestructorAccess(E->getExprLoc(), Destructor,
PDiag(diag::err_access_dtor_exception) << Ty);
return Owned(E);
@@ -670,9 +670,9 @@
return ThisTy;
}
-void Sema::CheckCXXThisCapture(SourceLocation Loc) {
+void Sema::CheckCXXThisCapture(SourceLocation Loc, bool Explicit) {
// We don't need to capture this in an unevaluated context.
- if (ExprEvalContexts.back().Context == Unevaluated)
+ if (ExprEvalContexts.back().Context == Unevaluated && !Explicit)
return;
// Otherwise, check that we can capture 'this'.
@@ -684,16 +684,19 @@
// 'this' is already being captured; there isn't anything more to do.
break;
}
+
if (CSI->ImpCaptureStyle == CapturingScopeInfo::ImpCap_LambdaByref ||
- CSI->ImpCaptureStyle == CapturingScopeInfo::ImpCap_Block) {
- // This closure can implicitly capture 'this'; continue looking upwards.
+ CSI->ImpCaptureStyle == CapturingScopeInfo::ImpCap_Block ||
+ Explicit) {
+ // This closure can capture 'this'; continue looking upwards.
// FIXME: Is this check correct? The rules in the standard are a bit
// unclear.
NumClosures++;
+ Explicit = false;
continue;
}
// This context can't implicitly capture 'this'; fail out.
- Diag(Loc, diag::err_implicit_this_capture);
+ Diag(Loc, diag::err_this_capture) << Explicit;
return;
}
break;
@@ -706,7 +709,7 @@
NumClosures; --idx, --NumClosures) {
CapturingScopeInfo *CSI = cast<CapturingScopeInfo>(FunctionScopes[idx]);
bool isNested = NumClosures > 1;
- CSI->AddThisCapture(isNested);
+ CSI->AddThisCapture(isNested, Loc);
}
}
@@ -1185,16 +1188,16 @@
// Mark the new and delete operators as referenced.
if (OperatorNew)
- MarkDeclarationReferenced(StartLoc, OperatorNew);
+ MarkFunctionReferenced(StartLoc, OperatorNew);
if (OperatorDelete)
- MarkDeclarationReferenced(StartLoc, OperatorDelete);
+ MarkFunctionReferenced(StartLoc, OperatorDelete);
// C++0x [expr.new]p17:
// If the new expression creates an array of objects of class type,
// access and ambiguity control are done for the destructor.
if (ArraySize && Constructor) {
if (CXXDestructorDecl *dtor = LookupDestructor(Constructor->getParent())) {
- MarkDeclarationReferenced(StartLoc, dtor);
+ MarkFunctionReferenced(StartLoc, dtor);
CheckDestructorAccess(StartLoc, dtor,
PDiag(diag::err_access_dtor)
<< Context.getBaseElementType(AllocType));
@@ -1514,7 +1517,7 @@
case OR_Success: {
// Got one!
FunctionDecl *FnDecl = Best->Function;
- MarkDeclarationReferenced(StartLoc, FnDecl);
+ MarkFunctionReferenced(StartLoc, FnDecl);
// The first argument is size_t, and the first parameter must be size_t,
// too. This is checked on declaration and can be assumed. (It can't be
// asserted on, though, since invalid decls are left in there.)
@@ -1953,7 +1956,7 @@
if (!PointeeRD->hasTrivialDestructor())
if (CXXDestructorDecl *Dtor = LookupDestructor(PointeeRD)) {
- MarkDeclarationReferenced(StartLoc,
+ MarkFunctionReferenced(StartLoc,
const_cast<CXXDestructorDecl*>(Dtor));
DiagnoseUseOfDecl(Dtor, StartLoc);
}
@@ -2002,7 +2005,7 @@
return ExprError();
}
- MarkDeclarationReferenced(StartLoc, OperatorDelete);
+ MarkFunctionReferenced(StartLoc, OperatorDelete);
// Check access and ambiguity of operator delete and destructor.
if (PointeeRD) {
@@ -2046,7 +2049,7 @@
ConditionVar->getType().getNonReferenceType(),
VK_LValue));
- MarkDeclarationReferenced(ConditionVar->getLocation(), ConditionVar);
+ MarkDeclRefReferenced(cast<DeclRefExpr>(Condition.get()));
if (ConvertToBoolean) {
Condition = CheckBooleanCondition(Condition.take(), StmtLoc);
@@ -3606,7 +3609,7 @@
break;
RHS = move(RHSRes);
if (Best->Function)
- Self.MarkDeclarationReferenced(QuestionLoc, Best->Function);
+ Self.MarkFunctionReferenced(QuestionLoc, Best->Function);
return false;
}
@@ -4207,7 +4210,7 @@
CXXTemporary *Temp = CXXTemporary::Create(Context, Destructor);
if (Destructor) {
- MarkDeclarationReferenced(E->getExprLoc(), Destructor);
+ MarkFunctionReferenced(E->getExprLoc(), Destructor);
CheckDestructorAccess(E->getExprLoc(), Destructor,
PDiag(diag::err_access_dtor_temp)
<< E->getType());
@@ -4684,7 +4687,7 @@
ExprValueKind VK = Expr::getValueKindForType(ResultType);
ResultType = ResultType.getNonLValueExprType(Context);
- MarkDeclarationReferenced(Exp.get()->getLocStart(), Method);
+ MarkFunctionReferenced(Exp.get()->getLocStart(), Method);
CXXMemberCallExpr *CE =
new (Context) CXXMemberCallExpr(Context, ME, 0, 0, ResultType, VK,
Exp.get()->getLocEnd());
@@ -4862,41 +4865,127 @@
Class->setLambda(true);
CurContext->addDecl(Class);
- QualType ThisCaptureType;
- llvm::DenseMap<VarDecl*, unsigned> CaptureMap;
- unsigned CXXThisCaptureIndex = 0;
- llvm::SmallVector<LambdaScopeInfo::Capture, 4> Captures;
+ // Build the call operator; we don't really have all the relevant information
+ // at this point, but we need something to attach child declarations to.
+ QualType MethodTy;
+ TypeSourceInfo *MethodTyInfo;
+ if (ParamInfo.getNumTypeObjects() == 0) {
+ // C++11 [expr.prim.lambda]p4:
+ // If a lambda-expression does not include a lambda-declarator, it is as
+ // if the lambda-declarator were ().
+ FunctionProtoType::ExtProtoInfo EPI;
+ EPI.TypeQuals |= DeclSpec::TQ_const;
+ MethodTy = Context.getFunctionType(Context.DependentTy,
+ /*Args=*/0, /*NumArgs=*/0, EPI);
+ MethodTyInfo = Context.getTrivialTypeSourceInfo(MethodTy);
+ } else {
+ assert(ParamInfo.isFunctionDeclarator() &&
+ "lambda-declarator is a function");
+ DeclaratorChunk::FunctionTypeInfo &FTI = ParamInfo.getFunctionTypeInfo();
+
+ // C++11 [expr.prim.lambda]p5:
+ // This function call operator is declared const (9.3.1) if and only if
+ // the lambda-expression’s parameter-declaration-clause is not followed
+ // by mutable. It is neither virtual nor declared volatile. [...]
+ if (!FTI.hasMutableQualifier())
+ FTI.TypeQuals |= DeclSpec::TQ_const;
+
+ // C++11 [expr.prim.lambda]p5:
+ // [...] Default arguments (8.3.6) shall not be specified in the
+ // parameter-declaration-clause of a lambda-declarator.
+ CheckExtraCXXDefaultArguments(ParamInfo);
+
+ MethodTyInfo = GetTypeForDeclarator(ParamInfo, CurScope);
+ // FIXME: Can these asserts actually fail?
+ assert(MethodTyInfo && "no type from lambda-declarator");
+ MethodTy = MethodTyInfo->getType();
+ assert(!MethodTy.isNull() && "no type from lambda declarator");
+ }
+
+ // C++11 [expr.prim.lambda]p5:
+ // The closure type for a lambda-expression has a public inline function
+ // call operator (13.5.4) whose parameters and return type are described by
+ // the lambda-expression’s parameter-declaration-clause and
+ // trailing-return-type respectively.
+ DeclarationName MethodName
+ = Context.DeclarationNames.getCXXOperatorName(OO_Call);
+ CXXMethodDecl *Method
+ = CXXMethodDecl::Create(Context,
+ Class,
+ ParamInfo.getSourceRange().getEnd(),
+ DeclarationNameInfo(MethodName,
+ /*NameLoc=*/SourceLocation()),
+ MethodTy,
+ MethodTyInfo,
+ /*isStatic=*/false,
+ SC_None,
+ /*isInline=*/true,
+ /*isConstExpr=*/false,
+ ParamInfo.getSourceRange().getEnd());
+ Method->setAccess(AS_public);
+ Class->addDecl(Method);
+ Method->setLexicalDeclContext(DC); // FIXME: Minor hack.
+
+ ProcessDeclAttributes(CurScope, Method, ParamInfo);
+
+ // Enter a new evaluation context to insulate the block from any
+ // cleanups from the enclosing full-expression.
+ PushExpressionEvaluationContext(PotentiallyEvaluated);
+
+ PushDeclContext(CurScope, Method);
+
+ // Introduce the lambda scope.
+ PushLambdaScope(Class);
+ LambdaScopeInfo *LSI = getCurLambda();
+ if (Intro.Default == LCD_ByCopy)
+ LSI->ImpCaptureStyle = LambdaScopeInfo::ImpCap_LambdaByval;
+ else if (Intro.Default == LCD_ByRef)
+ LSI->ImpCaptureStyle = LambdaScopeInfo::ImpCap_LambdaByref;
+
+ // Handle explicit captures.
for (llvm::SmallVector<LambdaCapture, 4>::const_iterator
- C = Intro.Captures.begin(), E = Intro.Captures.end(); C != E; ++C) {
+ C = Intro.Captures.begin(),
+ E = Intro.Captures.end();
+ C != E; ++C) {
if (C->Kind == LCK_This) {
- if (!ThisCaptureType.isNull()) {
- Diag(C->Loc, diag::err_capture_more_than_once) << "'this'";
+ // C++11 [expr.prim.lambda]p8:
+ // An identifier or this shall not appear more than once in a
+ // lambda-capture.
+ if (LSI->isCXXThisCaptured()) {
+ Diag(C->Loc, diag::err_capture_more_than_once)
+ << "'this'"
+ << SourceRange(LSI->getCXXThisCapture().getLocation());
continue;
}
+ // C++11 [expr.prim.lambda]p8:
+ // If a lambda-capture includes a capture-default that is =, the
+ // lambda-capture shall not contain this [...].
if (Intro.Default == LCD_ByCopy) {
Diag(C->Loc, diag::err_this_capture_with_copy_default);
continue;
}
- ThisCaptureType = getCurrentThisType();
+ // C++11 [expr.prim.lambda]p12:
+ // If this is captured by a local lambda expression, its nearest
+ // enclosing function shall be a non-static member function.
+ QualType ThisCaptureType = getCurrentThisType();
if (ThisCaptureType.isNull()) {
- Diag(C->Loc, diag::err_invalid_this_use);
+ Diag(C->Loc, diag::err_this_capture) << true;
continue;
}
- CheckCXXThisCapture(C->Loc);
-
- // FIXME: Need getCurCapture().
- bool isNested = getCurBlock() || getCurLambda();
- CapturingScopeInfo::Capture Cap(CapturingScopeInfo::Capture::ThisCapture,
- isNested);
- Captures.push_back(Cap);
- CXXThisCaptureIndex = Captures.size();
+
+ CheckCXXThisCapture(C->Loc, /*Explicit=*/true);
continue;
}
assert(C->Id && "missing identifier for capture");
+ // C++11 [expr.prim.lambda]p8:
+ // If a lambda-capture includes a capture-default that is &, the
+ // identifiers in the lambda-capture shall not be preceded by &.
+ // If a lambda-capture includes a capture-default that is =, [...]
+ // each identifier it contains shall be preceded by &.
if (C->Kind == LCK_ByRef && Intro.Default == LCD_ByRef) {
Diag(C->Loc, diag::err_reference_capture_with_reference_default);
continue;
@@ -4907,126 +4996,82 @@
DeclarationNameInfo Name(C->Id, C->Loc);
LookupResult R(*this, Name, LookupOrdinaryName);
- CXXScopeSpec ScopeSpec;
- LookupParsedName(R, CurScope, &ScopeSpec);
+ LookupName(R, CurScope);
if (R.isAmbiguous())
continue;
if (R.empty()) {
+ // FIXME: Disable corrections that would add qualification?
+ CXXScopeSpec ScopeSpec;
DeclFilterCCC<VarDecl> Validator;
if (DiagnoseEmptyLookup(CurScope, ScopeSpec, R, Validator))
continue;
}
+ // C++11 [expr.prim.lambda]p10:
+ // The identifiers in a capture-list are looked up using the usual rules
+ // for unqualified name lookup (3.4.1); each such lookup shall find a
+ // variable with automatic storage duration declared in the reaching
+ // scope of the local lambda expression.
+ // FIXME: Check reaching scope.
VarDecl *Var = R.getAsSingle<VarDecl>();
if (!Var) {
Diag(C->Loc, diag::err_capture_does_not_name_variable) << C->Id;
continue;
}
- if (CaptureMap.count(Var)) {
- Diag(C->Loc, diag::err_capture_more_than_once) << C->Id;
- continue;
- }
-
if (!Var->hasLocalStorage()) {
Diag(C->Loc, diag::err_capture_non_automatic_variable) << C->Id;
+ Diag(Var->getLocation(), diag::note_previous_decl) << C->Id;
+ continue;
+ }
+
+ if (Var->hasAttr<BlocksAttr>()) {
+ Diag(C->Loc, diag::err_lambda_capture_block) << C->Id;
+ Diag(Var->getLocation(), diag::note_previous_decl) << C->Id;
continue;
}
- // FIXME: This is completely wrong for nested captures and variables
- // with a non-trivial constructor.
- // FIXME: We should refuse to capture __block variables.
- Captures.push_back(LambdaScopeInfo::Capture(Var, C->Kind == LCK_ByRef,
- /*isNested*/false, 0));
- CaptureMap[Var] = Captures.size();
- }
-
- // Build the call operator; we don't really have all the relevant information
- // at this point, but we need something to attach child declarations to.
- QualType MethodTy;
- TypeSourceInfo *MethodTyInfo;
- if (ParamInfo.getNumTypeObjects() == 0) {
- FunctionProtoType::ExtProtoInfo EPI;
- EPI.TypeQuals |= DeclSpec::TQ_const;
- MethodTy = Context.getFunctionType(Context.DependentTy,
- /*Args=*/0, /*NumArgs=*/0, EPI);
- MethodTyInfo = Context.getTrivialTypeSourceInfo(MethodTy);
- } else {
- assert(ParamInfo.isFunctionDeclarator() &&
- "lambda-declarator is a function");
- DeclaratorChunk::FunctionTypeInfo &FTI = ParamInfo.getFunctionTypeInfo();
- if (!FTI.hasMutableQualifier())
- FTI.TypeQuals |= DeclSpec::TQ_const;
- MethodTyInfo = GetTypeForDeclarator(ParamInfo, CurScope);
- // FIXME: Can these asserts actually fail?
- assert(MethodTyInfo && "no type from lambda-declarator");
- MethodTy = MethodTyInfo->getType();
- assert(!MethodTy.isNull() && "no type from lambda declarator");
+ // C++11 [expr.prim.lambda]p8:
+ // An identifier or this shall not appear more than once in a
+ // lambda-capture.
+ if (LSI->isCaptured(Var)) {
+ Diag(C->Loc, diag::err_capture_more_than_once)
+ << C->Id
+ << SourceRange(LSI->getCapture(Var).getLocation());
+ continue;
+ }
+
+ // FIXME: If this is capture by copy, make sure that we can in fact copy
+ // the variable.
+ // FIXME: Unify with normal capture path, so we get all of the necessary
+ // nested captures.
+ LSI->AddCapture(Var, C->Kind == LCK_ByRef, /*isNested=*/false, C->Loc, 0);
}
-
- DeclarationName MethodName
- = Context.DeclarationNames.getCXXOperatorName(OO_Call);
- CXXMethodDecl *Method
- = CXXMethodDecl::Create(Context,
- Class,
- ParamInfo.getSourceRange().getEnd(),
- DeclarationNameInfo(MethodName,
- /*NameLoc=*/SourceLocation()),
- MethodTy,
- MethodTyInfo,
- /*isStatic=*/false,
- SC_None,
- /*isInline=*/true,
- /*isConstExpr=*/false,
- ParamInfo.getSourceRange().getEnd());
- Method->setAccess(AS_public);
- Class->addDecl(Method);
- Method->setLexicalDeclContext(DC); // FIXME: Is this really correct?
-
- ProcessDeclAttributes(CurScope, Method, ParamInfo);
-
- // Enter a new evaluation context to insulate the block from any
- // cleanups from the enclosing full-expression.
- PushExpressionEvaluationContext(PotentiallyEvaluated);
-
- PushDeclContext(CurScope, Method);
+ LSI->finishedExplicitCaptures();
// Set the parameters on the decl, if specified.
if (isa<FunctionProtoTypeLoc>(MethodTyInfo->getTypeLoc())) {
FunctionProtoTypeLoc Proto =
- cast<FunctionProtoTypeLoc>(MethodTyInfo->getTypeLoc());
+ cast<FunctionProtoTypeLoc>(MethodTyInfo->getTypeLoc());
Method->setParams(Proto.getParams());
CheckParmsForFunctionDef(Method->param_begin(),
Method->param_end(),
/*CheckParameterNames=*/false);
-
+
// Introduce our parameters into the function scope
for (unsigned p = 0, NumParams = Method->getNumParams(); p < NumParams; ++p) {
ParmVarDecl *Param = Method->getParamDecl(p);
Param->setOwningFunction(Method);
-
+
// If this has an identifier, add it to the scope stack.
if (Param->getIdentifier()) {
CheckShadow(CurScope, Param);
-
+
PushOnScopeChains(Param, CurScope);
}
}
}
- // Introduce the lambda scope.
- PushLambdaScope(Class);
-
- LambdaScopeInfo *LSI = getCurLambda();
- LSI->CXXThisCaptureIndex = CXXThisCaptureIndex;
- std::swap(LSI->CaptureMap, CaptureMap);
- std::swap(LSI->Captures, Captures);
- LSI->NumExplicitCaptures = Captures.size();
- if (Intro.Default == LCD_ByCopy)
- LSI->ImpCaptureStyle = LambdaScopeInfo::ImpCap_LambdaByval;
- else if (Intro.Default == LCD_ByRef)
- LSI->ImpCaptureStyle = LambdaScopeInfo::ImpCap_LambdaByref;
-
const FunctionType *Fn = MethodTy->getAs<FunctionType>();
QualType RetTy = Fn->getResultType();
if (RetTy != Context.DependentTy) {
Modified: cfe/branches/tooling/lib/Sema/SemaExprMember.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprMember.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprMember.cpp Thu Feb 2 04:59:12 2012
@@ -583,7 +583,7 @@
RecordMemberExprValidatorCCC Validator;
TypoCorrection Corrected = SemaRef.CorrectTypo(R.getLookupNameInfo(),
R.getLookupKind(), NULL,
- &SS, &Validator, DC);
+ &SS, Validator, DC);
R.clear();
if (NamedDecl *ND = Corrected.getCorrectionDecl()) {
std::string CorrectedStr(
@@ -776,7 +776,8 @@
}
/// \brief Build a MemberExpr AST node.
-static MemberExpr *BuildMemberExpr(ASTContext &C, Expr *Base, bool isArrow,
+static MemberExpr *BuildMemberExpr(Sema &SemaRef,
+ ASTContext &C, Expr *Base, bool isArrow,
const CXXScopeSpec &SS,
SourceLocation TemplateKWLoc,
ValueDecl *Member,
@@ -786,9 +787,12 @@
ExprValueKind VK, ExprObjectKind OK,
const TemplateArgumentListInfo *TemplateArgs = 0) {
assert((!isArrow || Base->isRValue()) && "-> base must be a pointer rvalue");
- return MemberExpr::Create(C, Base, isArrow, SS.getWithLocInContext(C),
- TemplateKWLoc, Member, FoundDecl, MemberNameInfo,
- TemplateArgs, Ty, VK, OK);
+ MemberExpr *E =
+ MemberExpr::Create(C, Base, isArrow, SS.getWithLocInContext(C),
+ TemplateKWLoc, Member, FoundDecl, MemberNameInfo,
+ TemplateArgs, Ty, VK, OK);
+ SemaRef.MarkMemberReferenced(E);
+ return E;
}
ExprResult
@@ -908,9 +912,8 @@
BaseExpr, OpLoc);
if (VarDecl *Var = dyn_cast<VarDecl>(MemberDecl)) {
- MarkDeclarationReferenced(MemberLoc, Var);
- return Owned(BuildMemberExpr(Context, BaseExpr, IsArrow, SS, TemplateKWLoc,
- Var, FoundDecl, MemberNameInfo,
+ return Owned(BuildMemberExpr(*this, Context, BaseExpr, IsArrow, SS,
+ TemplateKWLoc, Var, FoundDecl, MemberNameInfo,
Var->getType().getNonReferenceType(),
VK_LValue, OK_Ordinary));
}
@@ -926,17 +929,16 @@
type = MemberFn->getType();
}
- MarkDeclarationReferenced(MemberLoc, MemberDecl);
- return Owned(BuildMemberExpr(Context, BaseExpr, IsArrow, SS, TemplateKWLoc,
- MemberFn, FoundDecl, MemberNameInfo,
- type, valueKind, OK_Ordinary));
+ return Owned(BuildMemberExpr(*this, Context, BaseExpr, IsArrow, SS,
+ TemplateKWLoc, MemberFn, FoundDecl,
+ MemberNameInfo, type, valueKind,
+ OK_Ordinary));
}
assert(!isa<FunctionDecl>(MemberDecl) && "member function not C++ method?");
if (EnumConstantDecl *Enum = dyn_cast<EnumConstantDecl>(MemberDecl)) {
- MarkDeclarationReferenced(MemberLoc, MemberDecl);
- return Owned(BuildMemberExpr(Context, BaseExpr, IsArrow, SS, TemplateKWLoc,
- Enum, FoundDecl, MemberNameInfo,
+ return Owned(BuildMemberExpr(*this, Context, BaseExpr, IsArrow, SS,
+ TemplateKWLoc, Enum, FoundDecl, MemberNameInfo,
Enum->getType(), VK_RValue, OK_Ordinary));
}
@@ -1124,7 +1126,7 @@
Validator.IsObjCIvarLookup = IsArrow;
if (TypoCorrection Corrected = CorrectTypo(R.getLookupNameInfo(),
LookupMemberName, NULL, NULL,
- &Validator, IDecl)) {
+ Validator, IDecl)) {
IV = Corrected.getCorrectionDeclAs<ObjCIvarDecl>();
Diag(R.getNameLoc(),
diag::err_typecheck_member_reference_ivar_suggest)
@@ -1540,13 +1542,12 @@
MemberType = S.Context.getQualifiedType(MemberType, Combined);
}
- S.MarkDeclarationReferenced(MemberNameInfo.getLoc(), Field);
ExprResult Base =
S.PerformObjectMemberConversion(BaseExpr, SS.getScopeRep(),
FoundDecl, Field);
if (Base.isInvalid())
return ExprError();
- return S.Owned(BuildMemberExpr(S.Context, Base.take(), IsArrow, SS,
+ return S.Owned(BuildMemberExpr(S, S.Context, Base.take(), IsArrow, SS,
/*TemplateKWLoc=*/SourceLocation(),
Field, FoundDecl, MemberNameInfo,
MemberType, VK, OK));
Modified: cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaExprObjC.cpp Thu Feb 2 04:59:12 2012
@@ -265,7 +265,8 @@
if (captureIndex) break;
bool nested = isa<BlockScopeInfo>(FunctionScopes[idx-1]);
- blockScope->AddCapture(self, /*byref*/ false, nested, /*copy*/ 0);
+ blockScope->AddCapture(self, /*byref*/ false, nested, self->getLocation(),
+ /*copy*/ 0);
captureIndex = blockScope->Captures.size(); // +1
}
@@ -704,7 +705,7 @@
DeclFilterCCC<ObjCPropertyDecl> Validator;
if (TypoCorrection Corrected = CorrectTypo(
DeclarationNameInfo(MemberName, MemberLoc), LookupOrdinaryName, NULL,
- NULL, &Validator, IFace, false, OPT)) {
+ NULL, Validator, IFace, false, OPT)) {
ObjCPropertyDecl *Property =
Corrected.getCorrectionDeclAs<ObjCPropertyDecl>();
DeclarationName TypoResult = Corrected.getCorrection();
@@ -936,7 +937,7 @@
ObjCInterfaceOrSuperCCC Validator(getCurMethodDecl());
if (TypoCorrection Corrected = CorrectTypo(Result.getLookupNameInfo(),
Result.getLookupKind(), S, NULL,
- &Validator)) {
+ Validator)) {
if (Corrected.isKeyword()) {
// If we've found the keyword "super" (the only keyword that would be
// returned by CorrectTypo), this is a send to super.
@@ -1901,6 +1902,13 @@
};
}
+static bool
+KnownName(Sema &S, const char *name) {
+ LookupResult R(S, &S.Context.Idents.get(name), SourceLocation(),
+ Sema::LookupOrdinaryName);
+ return S.LookupName(R, S.TUScope, false);
+}
+
static void
diagnoseObjCARCConversion(Sema &S, SourceRange castRange,
QualType castType, ARCConversionTypeClass castACTC,
@@ -1936,6 +1944,7 @@
// Bridge from an ARC type to a CF type.
if (castACTC == ACTC_retainable && isAnyRetainable(exprACTC)) {
+
S.Diag(loc, diag::err_arc_cast_requires_bridge)
<< unsigned(CCK == Sema::CCK_ImplicitConversion) // cast|implicit
<< 2 // of C pointer type
@@ -1944,20 +1953,22 @@
<< castType
<< castRange
<< castExpr->getSourceRange();
-
+ bool br = KnownName(S, "CFBridgingRelease");
S.Diag(noteLoc, diag::note_arc_bridge)
<< (CCK != Sema::CCK_CStyleCast ? FixItHint() :
FixItHint::CreateInsertion(afterLParen, "__bridge "));
S.Diag(noteLoc, diag::note_arc_bridge_transfer)
- << castExprType
+ << castExprType << br
<< (CCK != Sema::CCK_CStyleCast ? FixItHint() :
- FixItHint::CreateInsertion(afterLParen, "__bridge_transfer "));
+ FixItHint::CreateInsertion(afterLParen,
+ br ? "CFBridgingRelease " : "__bridge_transfer "));
return;
}
// Bridge from a CF type to an ARC type.
if (exprACTC == ACTC_retainable && isAnyRetainable(castACTC)) {
+ bool br = KnownName(S, "CFBridgingRetain");
S.Diag(loc, diag::err_arc_cast_requires_bridge)
<< unsigned(CCK == Sema::CCK_ImplicitConversion) // cast|implicit
<< unsigned(castExprType->isBlockPointerType()) // of ObjC|block type
@@ -1971,9 +1982,10 @@
<< (CCK != Sema::CCK_CStyleCast ? FixItHint() :
FixItHint::CreateInsertion(afterLParen, "__bridge "));
S.Diag(noteLoc, diag::note_arc_bridge_retained)
- << castType
+ << castType << br
<< (CCK != Sema::CCK_CStyleCast ? FixItHint() :
- FixItHint::CreateInsertion(afterLParen, "__bridge_retained "));
+ FixItHint::CreateInsertion(afterLParen,
+ br ? "CFBridgingRetain " : "__bridge_retained"));
return;
}
@@ -2204,7 +2216,8 @@
case OBC_Bridge:
break;
- case OBC_BridgeRetained:
+ case OBC_BridgeRetained: {
+ bool br = KnownName(*this, "CFBridgingRelease");
Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
<< 2
<< FromType
@@ -2215,12 +2228,14 @@
Diag(BridgeKeywordLoc, diag::note_arc_bridge)
<< FixItHint::CreateReplacement(BridgeKeywordLoc, "__bridge");
Diag(BridgeKeywordLoc, diag::note_arc_bridge_transfer)
- << FromType
+ << FromType << br
<< FixItHint::CreateReplacement(BridgeKeywordLoc,
- "__bridge_transfer ");
+ br ? "CFBridgingRelease "
+ : "__bridge_transfer ");
Kind = OBC_Bridge;
break;
+ }
case OBC_BridgeTransfer:
// We must consume the Objective-C object produced by the cast.
@@ -2244,7 +2259,8 @@
SubExpr, 0, VK_RValue);
break;
- case OBC_BridgeTransfer:
+ case OBC_BridgeTransfer: {
+ bool br = KnownName(*this, "CFBridgingRetain");
Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
<< (FromType->isBlockPointerType()? 1 : 0)
<< FromType
@@ -2256,12 +2272,14 @@
Diag(BridgeKeywordLoc, diag::note_arc_bridge)
<< FixItHint::CreateReplacement(BridgeKeywordLoc, "__bridge ");
Diag(BridgeKeywordLoc, diag::note_arc_bridge_retained)
- << T
- << FixItHint::CreateReplacement(BridgeKeywordLoc, "__bridge_retained ");
+ << T << br
+ << FixItHint::CreateReplacement(BridgeKeywordLoc,
+ br ? "CFBridgingRetain " : "__bridge_retained");
Kind = OBC_Bridge;
break;
}
+ }
} else {
Diag(LParenLoc, diag::err_arc_bridge_cast_incompatible)
<< FromType << T << Kind
Modified: cfe/branches/tooling/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaInit.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaInit.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaInit.cpp Thu Feb 2 04:59:12 2012
@@ -1711,7 +1711,7 @@
FieldInitializerValidatorCCC Validator(RT->getDecl());
TypoCorrection Corrected = SemaRef.CorrectTypo(
DeclarationNameInfo(FieldName, D->getFieldLoc()),
- Sema::LookupMemberName, /*Scope=*/0, /*SS=*/0, &Validator,
+ Sema::LookupMemberName, /*Scope=*/0, /*SS=*/0, Validator,
RT->getDecl());
if (Corrected) {
std::string CorrectedStr(
@@ -3156,7 +3156,7 @@
// This is the overload that will actually be used for the initialization, so
// mark it as used.
- S.MarkDeclarationReferenced(DeclLoc, Function);
+ S.MarkFunctionReferenced(DeclLoc, Function);
// Compute the returned type of the conversion.
if (isa<CXXConversionDecl>(Function))
@@ -3679,7 +3679,7 @@
}
FunctionDecl *Function = Best->Function;
- S.MarkDeclarationReferenced(DeclLoc, Function);
+ S.MarkFunctionReferenced(DeclLoc, Function);
bool HadMultipleCandidates = (CandidateSet.size() > 1);
if (isa<CXXConstructorDecl>(Function)) {
@@ -4388,7 +4388,7 @@
return S.Owned(CurInitExpr);
}
- S.MarkDeclarationReferenced(Loc, Constructor);
+ S.MarkFunctionReferenced(Loc, Constructor);
// Determine the arguments required to actually perform the
// constructor call (we might have derived-to-base conversions, or
@@ -4531,7 +4531,7 @@
// An explicitly-constructed temporary, e.g., X(1, 2).
unsigned NumExprs = ConstructorArgs.size();
Expr **Exprs = (Expr **)ConstructorArgs.take();
- S.MarkDeclarationReferenced(Loc, Constructor);
+ S.MarkFunctionReferenced(Loc, Constructor);
S.DiagnoseUseOfDecl(Constructor, Loc);
TypeSourceInfo *TSInfo = Entity.getTypeSourceInfo();
@@ -4899,7 +4899,7 @@
= S.LookupDestructor(cast<CXXRecordDecl>(Record->getDecl()));
S.CheckDestructorAccess(CurInit.get()->getLocStart(), Destructor,
S.PDiag(diag::err_access_dtor_temp) << T);
- S.MarkDeclarationReferenced(CurInit.get()->getLocStart(), Destructor);
+ S.MarkFunctionReferenced(CurInit.get()->getLocStart(), Destructor);
S.DiagnoseUseOfDecl(Destructor, CurInit.get()->getLocStart());
}
}
Modified: cfe/branches/tooling/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaLookup.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaLookup.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaLookup.cpp Thu Feb 2 04:59:12 2012
@@ -32,6 +32,7 @@
#include "clang/Basic/Builtins.h"
#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringMap.h"
@@ -3536,7 +3537,7 @@
TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
Sema::LookupNameKind LookupKind,
Scope *S, CXXScopeSpec *SS,
- CorrectionCandidateCallback *CCC,
+ CorrectionCandidateCallback &CCC,
DeclContext *MemberContext,
bool EnteringContext,
const ObjCObjectPointerType *OPT) {
@@ -3572,7 +3573,7 @@
// If a callback object returns true for an empty typo correction candidate,
// assume it does not do any actual validation of the candidates.
TypoCorrection EmptyCorrection;
- bool ValidatingCallback = CCC && !CCC->ValidateCandidate(EmptyCorrection);
+ bool ValidatingCallback = !CCC.ValidateCandidate(EmptyCorrection);
// Perform name lookup to find visible, similarly-named entities.
bool IsUnqualifiedLookup = false;
@@ -3608,7 +3609,7 @@
// keyword case, we'll end up adding the keyword below.
if (Cached->second) {
if (!Cached->second.isKeyword() &&
- (!CCC || CCC->ValidateCandidate(Cached->second)))
+ CCC.ValidateCandidate(Cached->second))
Consumer.addCorrection(Cached->second);
} else {
// Only honor no-correction cache hits when a callback that will validate
@@ -3646,8 +3647,7 @@
}
}
- CorrectionCandidateCallback DefaultCCC;
- AddKeywordsToConsumer(*this, Consumer, S, CCC ? *CCC : DefaultCCC);
+ AddKeywordsToConsumer(*this, Consumer, S, CCC);
// If we haven't found anything, we're done.
if (Consumer.empty()) {
@@ -3704,7 +3704,7 @@
if (I->second.isResolved()) {
TypoCorrectionConsumer::result_iterator Prev = I;
++I;
- if (CCC && !CCC->ValidateCandidate(Prev->second))
+ if (!CCC.ValidateCandidate(Prev->second))
DI->second->erase(Prev);
continue;
}
@@ -3712,7 +3712,7 @@
// Perform name lookup on this name.
IdentifierInfo *Name = I->second.getCorrectionAsIdentifierInfo();
LookupPotentialTypoResult(*this, TmpRes, Name, S, SS, MemberContext,
- EnteringContext, CCC && CCC->IsObjCIvarLookup);
+ EnteringContext, CCC.IsObjCIvarLookup);
switch (TmpRes.getResultKind()) {
case LookupResult::NotFound:
@@ -3741,7 +3741,7 @@
TRD != TRDEnd; ++TRD)
I->second.addCorrectionDecl(*TRD);
++I;
- if (CCC && !CCC->ValidateCandidate(Prev->second))
+ if (!CCC.ValidateCandidate(Prev->second))
DI->second->erase(Prev);
break;
}
@@ -3750,7 +3750,7 @@
TypoCorrectionConsumer::result_iterator Prev = I;
I->second.setCorrectionDecl(TmpRes.getAsSingle<NamedDecl>());
++I;
- if (CCC && !CCC->ValidateCandidate(Prev->second))
+ if (!CCC.ValidateCandidate(Prev->second))
DI->second->erase(Prev);
break;
}
@@ -3868,7 +3868,7 @@
// WantObjCSuper is only true for CTC_ObjCMessageReceiver and for
// some instances of CTC_Unknown, while WantRemainingKeywords is true
// for CTC_Unknown but not for CTC_ObjCMessageReceiver.
- && CCC && CCC->WantObjCSuper && !CCC->WantRemainingKeywords
+ && CCC.WantObjCSuper && !CCC.WantRemainingKeywords
&& BestResults["super"].isKeyword()) {
// Prefer 'super' when we're completing in a message-receiver
// context.
Modified: cfe/branches/tooling/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaOverload.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaOverload.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaOverload.cpp Thu Feb 2 04:59:12 2012
@@ -2893,7 +2893,7 @@
// Record the standard conversion we used and the conversion function.
if (CXXConstructorDecl *Constructor
= dyn_cast<CXXConstructorDecl>(Best->Function)) {
- S.MarkDeclarationReferenced(From->getLocStart(), Constructor);
+ S.MarkFunctionReferenced(From->getLocStart(), Constructor);
// C++ [over.ics.user]p1:
// If the user-defined conversion is specified by a
@@ -2923,7 +2923,7 @@
}
if (CXXConversionDecl *Conversion
= dyn_cast<CXXConversionDecl>(Best->Function)) {
- S.MarkDeclarationReferenced(From->getLocStart(), Conversion);
+ S.MarkFunctionReferenced(From->getLocStart(), Conversion);
// C++ [over.ics.user]p1:
//
@@ -3793,7 +3793,7 @@
return false;
if (Best->Function)
- S.MarkDeclarationReferenced(DeclLoc, Best->Function);
+ S.MarkFunctionReferenced(DeclLoc, Best->Function);
ICS.setUserDefined();
ICS.UserDefined.Before = Best->Conversions[0].Standard;
ICS.UserDefined.After = Best->FinalConversion;
@@ -8817,7 +8817,7 @@
Fn = Resolver.getMatchingFunctionDecl();
assert(Fn);
FoundResult = *Resolver.getMatchingFunctionAccessPair();
- MarkDeclarationReferenced(AddressOfExpr->getLocStart(), Fn);
+ MarkFunctionReferenced(AddressOfExpr->getLocStart(), Fn);
if (Complain)
CheckAddressOfMemberAccess(AddressOfExpr, FoundResult);
}
@@ -9380,7 +9380,7 @@
switch (CandidateSet.BestViableFunction(*this, Fn->getLocStart(), Best)) {
case OR_Success: {
FunctionDecl *FDecl = Best->Function;
- MarkDeclarationReferenced(Fn->getExprLoc(), FDecl);
+ MarkFunctionReferenced(Fn->getExprLoc(), FDecl);
CheckUnresolvedLookupAccess(ULE, Best->FoundDecl);
DiagnoseUseOfDecl(FDecl, ULE->getNameLoc());
Fn = FixOverloadedFunctionReference(Fn, Best->FoundDecl, FDecl);
@@ -9534,7 +9534,7 @@
// We matched an overloaded operator. Build a call to that
// operator.
- MarkDeclarationReferenced(OpLoc, FnDecl);
+ MarkFunctionReferenced(OpLoc, FnDecl);
// Convert the arguments.
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
@@ -9755,7 +9755,7 @@
// We matched an overloaded operator. Build a call to that
// operator.
- MarkDeclarationReferenced(OpLoc, FnDecl);
+ MarkFunctionReferenced(OpLoc, FnDecl);
// Convert the arguments.
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
@@ -9962,7 +9962,7 @@
// We matched an overloaded operator. Build a call to that
// operator.
- MarkDeclarationReferenced(LLoc, FnDecl);
+ MarkFunctionReferenced(LLoc, FnDecl);
CheckMemberOperatorAccess(LLoc, Args[0], Args[1], Best->FoundDecl);
DiagnoseUseOfDecl(Best->FoundDecl, LLoc);
@@ -10211,7 +10211,7 @@
Best)) {
case OR_Success:
Method = cast<CXXMethodDecl>(Best->Function);
- MarkDeclarationReferenced(UnresExpr->getMemberLoc(), Method);
+ MarkFunctionReferenced(UnresExpr->getMemberLoc(), Method);
FoundDecl = Best->FoundDecl;
CheckUnresolvedMemberAccess(UnresExpr, Best->FoundDecl);
DiagnoseUseOfDecl(Best->FoundDecl, UnresExpr->getNameLoc());
@@ -10476,7 +10476,7 @@
RParenLoc);
}
- MarkDeclarationReferenced(LParenLoc, Best->Function);
+ MarkFunctionReferenced(LParenLoc, Best->Function);
CheckMemberOperatorAccess(LParenLoc, Object.get(), 0, Best->FoundDecl);
DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc);
@@ -10666,7 +10666,7 @@
return ExprError();
}
- MarkDeclarationReferenced(OpLoc, Best->Function);
+ MarkFunctionReferenced(OpLoc, Best->Function);
CheckMemberOperatorAccess(OpLoc, Base, 0, Best->FoundDecl);
DiagnoseUseOfDecl(Best->FoundDecl, OpLoc);
Modified: cfe/branches/tooling/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaStmt.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaStmt.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaStmt.cpp Thu Feb 2 04:59:12 2012
@@ -1611,6 +1611,7 @@
E = ExprRes.take();
if (DiagnoseAssignmentResult(ConvTy, StarLoc, DestTy, ETy, E, AA_Passing))
return StmtError();
+ E = MaybeCreateExprWithCleanups(E);
}
getCurFunction()->setHasIndirectGoto();
Modified: cfe/branches/tooling/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplate.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplate.cpp Thu Feb 2 04:59:12 2012
@@ -310,7 +310,7 @@
FilterCCC.WantCXXNamedCasts = true;
if (TypoCorrection Corrected = CorrectTypo(Found.getLookupNameInfo(),
Found.getLookupKind(), S, &SS,
- &FilterCCC, LookupCtx)) {
+ FilterCCC, LookupCtx)) {
Found.setLookupName(Corrected.getCorrection());
if (Corrected.getCorrectionDecl())
Found.addDecl(Corrected.getCorrectionDecl());
@@ -3630,7 +3630,7 @@
// Create the template argument.
Converted = TemplateArgument(Entity->getCanonicalDecl());
- S.MarkDeclarationReferenced(Arg->getLocStart(), Entity);
+ S.MarkAnyDeclReferenced(Arg->getLocStart(), Entity);
return false;
}
Modified: cfe/branches/tooling/lib/Sema/SemaTemplateVariadic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaTemplateVariadic.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaTemplateVariadic.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaTemplateVariadic.cpp Thu Feb 2 04:59:12 2012
@@ -753,7 +753,7 @@
case LookupResult::NotFoundInCurrentInstantiation:
if (TypoCorrection Corrected = CorrectTypo(R.getLookupNameInfo(),
R.getLookupKind(), S, 0,
- &Validator)) {
+ Validator)) {
std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOptions()));
ParameterPack = Corrected.getCorrectionDecl();
Diag(NameLoc, diag::err_sizeof_pack_no_pack_name_suggest)
Modified: cfe/branches/tooling/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/SemaType.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/SemaType.cpp (original)
+++ cfe/branches/tooling/lib/Sema/SemaType.cpp Thu Feb 2 04:59:12 2012
@@ -4212,7 +4212,8 @@
assert(!T->isDependentType() && "type should not be dependent");
bool Incomplete = RequireCompleteType(Loc, T, 0);
- if (T->isLiteralType() || (AllowIncompleteType && Incomplete))
+ if (T->isLiteralType() ||
+ (AllowIncompleteType && Incomplete && !T->isVoidType()))
return false;
if (PD.getDiagID() == 0)
Modified: cfe/branches/tooling/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Sema/TreeTransform.h?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Sema/TreeTransform.h (original)
+++ cfe/branches/tooling/lib/Sema/TreeTransform.h Thu Feb 2 04:59:12 2012
@@ -5326,6 +5326,7 @@
ExprResult Target = getDerived().TransformExpr(S->getTarget());
if (Target.isInvalid())
return StmtError();
+ Target = SemaRef.MaybeCreateExprWithCleanups(Target.take());
if (!getDerived().AlwaysRebuild() &&
Target.get() == S->getTarget())
@@ -5738,10 +5739,18 @@
ExprResult Cond = getDerived().TransformExpr(S->getCond());
if (Cond.isInvalid())
return StmtError();
+ if (Cond.get())
+ Cond = SemaRef.CheckBooleanCondition(Cond.take(), S->getColonLoc());
+ if (Cond.isInvalid())
+ return StmtError();
+ if (Cond.get())
+ Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.take());
ExprResult Inc = getDerived().TransformExpr(S->getInc());
if (Inc.isInvalid())
return StmtError();
+ if (Inc.get())
+ Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.take());
StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
if (LoopVar.isInvalid())
@@ -5940,7 +5949,7 @@
// Mark it referenced in the new context regardless.
// FIXME: this is a bit instantiation-specific.
- SemaRef.MarkDeclarationReferenced(E->getLocation(), ND);
+ SemaRef.MarkDeclRefReferenced(E);
return SemaRef.Owned(E);
}
@@ -6284,7 +6293,8 @@
// Mark it referenced in the new context regardless.
// FIXME: this is a bit instantiation-specific.
- SemaRef.MarkDeclarationReferenced(E->getMemberLoc(), Member);
+ SemaRef.MarkMemberReferenced(E);
+
return SemaRef.Owned(E);
}
@@ -7108,11 +7118,11 @@
// Mark any declarations we need as referenced.
// FIXME: instantiation-specific.
if (Constructor)
- SemaRef.MarkDeclarationReferenced(E->getLocStart(), Constructor);
+ SemaRef.MarkFunctionReferenced(E->getLocStart(), Constructor);
if (OperatorNew)
- SemaRef.MarkDeclarationReferenced(E->getLocStart(), OperatorNew);
+ SemaRef.MarkFunctionReferenced(E->getLocStart(), OperatorNew);
if (OperatorDelete)
- SemaRef.MarkDeclarationReferenced(E->getLocStart(), OperatorDelete);
+ SemaRef.MarkFunctionReferenced(E->getLocStart(), OperatorDelete);
if (E->isArray() && Constructor &&
!E->getAllocatedType()->isDependentType()) {
@@ -7121,7 +7131,7 @@
if (const RecordType *RecordT = ElementType->getAs<RecordType>()) {
CXXRecordDecl *Record = cast<CXXRecordDecl>(RecordT->getDecl());
if (CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(Record)) {
- SemaRef.MarkDeclarationReferenced(E->getLocStart(), Destructor);
+ SemaRef.MarkFunctionReferenced(E->getLocStart(), Destructor);
}
}
}
@@ -7193,15 +7203,15 @@
// Mark any declarations we need as referenced.
// FIXME: instantiation-specific.
if (OperatorDelete)
- SemaRef.MarkDeclarationReferenced(E->getLocStart(), OperatorDelete);
+ SemaRef.MarkFunctionReferenced(E->getLocStart(), OperatorDelete);
if (!E->getArgument()->isTypeDependent()) {
QualType Destroyed = SemaRef.Context.getBaseElementType(
E->getDestroyedType());
if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) {
CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
- SemaRef.MarkDeclarationReferenced(E->getLocStart(),
- SemaRef.LookupDestructor(Record));
+ SemaRef.MarkFunctionReferenced(E->getLocStart(),
+ SemaRef.LookupDestructor(Record));
}
}
@@ -7531,7 +7541,7 @@
!ArgumentChanged) {
// Mark the constructor as referenced.
// FIXME: Instantiation-specific
- SemaRef.MarkDeclarationReferenced(E->getLocStart(), Constructor);
+ SemaRef.MarkFunctionReferenced(E->getLocStart(), Constructor);
return SemaRef.Owned(E);
}
@@ -7592,7 +7602,7 @@
Constructor == E->getConstructor() &&
!ArgumentChanged) {
// FIXME: Instantiation-specific
- SemaRef.MarkDeclarationReferenced(E->getLocStart(), Constructor);
+ SemaRef.MarkFunctionReferenced(E->getLocStart(), Constructor);
return SemaRef.MaybeBindToTemporary(E);
}
@@ -8244,7 +8254,7 @@
ND == E->getDecl()) {
// Mark it referenced in the new context regardless.
// FIXME: this is a bit instantiation-specific.
- SemaRef.MarkDeclarationReferenced(E->getLocation(), ND);
+ SemaRef.MarkBlockDeclRefReferenced(E);
return SemaRef.Owned(E);
}
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=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CMakeLists.txt Thu Feb 2 04:59:12 2012
@@ -14,6 +14,7 @@
BasicObjCFoundationChecks.cpp
BuiltinFunctionChecker.cpp
CStringChecker.cpp
+ CStringSyntaxChecker.cpp
CallAndMessageChecker.cpp
CastSizeChecker.cpp
CastToStructChecker.cpp
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp Thu Feb 2 04:59:12 2012
@@ -286,10 +286,9 @@
}
static bool supportsNilWithFloatRet(const llvm::Triple &triple) {
- return triple.getVendor() == llvm::Triple::Apple &&
- (!triple.isMacOSXVersionLT(10,5) ||
- triple.getArch() == llvm::Triple::arm ||
- triple.getArch() == llvm::Triple::thumb);
+ return (triple.getVendor() == llvm::Triple::Apple &&
+ (triple.getOS() == llvm::Triple::IOS ||
+ !triple.isMacOSXVersionLT(10,5)));
}
void CallAndMessageChecker::HandleNilReceiver(CheckerContext &C,
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp Thu Feb 2 04:59:12 2012
@@ -516,7 +516,7 @@
"Call to function 'strcpy' is insecure as it does not "
"provide bounding of the memory buffer. Replace "
"unbounded copy functions with analogous functions that "
- "support length arguments such as 'strncpy'. CWE-119.",
+ "support length arguments such as 'strlcpy'. CWE-119.",
CELoc, &R, 1);
}
@@ -543,7 +543,7 @@
"Call to function 'strcat' is insecure as it does not "
"provide bounding of the memory buffer. Replace "
"unbounded copy functions with analogous functions that "
- "support length arguments such as 'strncat'. CWE-119.",
+ "support length arguments such as 'strlcat'. CWE-119.",
CELoc, &R, 1);
}
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=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/Checkers.td Thu Feb 2 04:59:12 2012
@@ -33,6 +33,7 @@
def Unix : Package<"unix">;
def UnixExperimental : Package<"unix">, InPackage<Experimental>, Hidden;
+def CString : Package<"cstring">, InPackage<UnixExperimental>, Hidden;
def OSX : Package<"osx">;
def OSXExperimental : Package<"osx">, InPackage<Experimental>, Hidden;
@@ -281,10 +282,6 @@
HelpText<"Check improper use of chroot">,
DescFile<"ChrootChecker.cpp">;
-def CStringChecker : Checker<"CString">,
- HelpText<"Check calls to functions in <string.h>">,
- DescFile<"CStringChecker.cpp">;
-
def MallocChecker : Checker<"Malloc">,
HelpText<"Check for potential memory leaks, double free, and use-after-free problems">,
DescFile<"MallocChecker.cpp">;
@@ -303,6 +300,17 @@
} // end "unix.experimental"
+let ParentPackage = CString in {
+
+def CStringChecker : Checker<"Generic">,
+ HelpText<"Check calls to functions in <string.h>">,
+ DescFile<"CStringChecker.cpp">;
+
+def CStringSyntaxChecker : Checker<"BadSizeArg">,
+ HelpText<"Check the size argument passed into C string functions for common erroneous patterns">,
+ DescFile<"CStringSyntaxChecker.cpp">;
+}
+
//===----------------------------------------------------------------------===//
// Mac OS X, Cocoa, and Core Foundation checkers.
//===----------------------------------------------------------------------===//
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp Thu Feb 2 04:59:12 2012
@@ -48,8 +48,17 @@
// The type could be either a pointer or array.
const Type *TP = T.getTypePtr();
QualType PointeeT = TP->getPointeeType();
- if (!PointeeT.isNull())
+ if (!PointeeT.isNull()) {
+ // If the type is a pointer to an array, check the size of the array
+ // elements. To avoid false positives coming from assumption that the
+ // values x and &x are equal when x is an array.
+ if (const Type *TElem = PointeeT->getArrayElementTypeNoTypeQual())
+ if (isPointerSize(TElem))
+ return true;
+
+ // Else, check the pointee size.
return isPointerSize(PointeeT.getTypePtr());
+ }
if (const Type *TElem = TP->getArrayElementTypeNoTypeQual())
return isPointerSize(TElem);
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/CheckerContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/CheckerContext.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/CheckerContext.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/CheckerContext.cpp Thu Feb 2 04:59:12 2012
@@ -37,19 +37,33 @@
bool CheckerContext::isCLibraryFunction(const FunctionDecl *FD,
- StringRef Name){
+ StringRef Name) {
+ return isCLibraryFunction(FD, Name, getASTContext());
+}
+
+bool CheckerContext::isCLibraryFunction(const FunctionDecl *FD,
+ StringRef Name, ASTContext &Context) {
// To avoid false positives (Ex: finding user defined functions with
// similar names), only perform fuzzy name matching when it's a builtin.
// Using a string compare is slow, we might want to switch on BuiltinID here.
unsigned BId = FD->getBuiltinID();
if (BId != 0) {
- ASTContext &Context = getASTContext();
StringRef BName = Context.BuiltinInfo.GetName(BId);
- if (StringRef(BName).find(Name) != StringRef::npos)
+ if (BName.find(Name) != StringRef::npos)
return true;
}
- if (FD->isExternC() && FD->getIdentifier()->getName().equals(Name))
+ const IdentifierInfo *II = FD->getIdentifier();
+ // If this is a special C++ name without IdentifierInfo, it can't be a
+ // C library function.
+ if (!II)
+ return false;
+
+ StringRef FName = II->getName();
+ if (FName.startswith("__inline"))
+ return (FName.find(Name) != StringRef::npos);
+
+ if (FD->isExternC() && FName.equals(Name))
return true;
return false;
Modified: cfe/branches/tooling/test/ARCMT/checking.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/ARCMT/checking.m?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/ARCMT/checking.m (original)
+++ cfe/branches/tooling/test/ARCMT/checking.m Thu Feb 2 04:59:12 2012
@@ -7,6 +7,10 @@
#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE
#endif
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
+
typedef int BOOL;
typedef unsigned NSUInteger;
@@ -95,7 +99,7 @@
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}} \
// expected-note {{use __bridge to convert directly (no change in ownership)}} \
- // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} \
+ // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} \
str = (NSString *)kUTTypePlainText;
str = b ? kUTTypeRTF : kUTTypePlainText;
str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText);
@@ -153,10 +157,10 @@
(void)(void*)voidp_val;
(void)(void**)arg; // expected-error {{disallowed}}
cvt((void*)arg); // expected-error 2 {{requires a bridged cast}} \
- // expected-note 2 {{use __bridge to}} expected-note {{use __bridge_transfer}} expected-note {{use __bridge_retained}}
+ // expected-note 2 {{use __bridge to}} expected-note {{use CFBridgingRelease call}} expected-note {{use CFBridgingRetain call}}
cvt(0);
(void)(__strong id**)(0);
- return arg; // expected-error {{requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use __bridge_retained}}
+ return arg; // expected-error {{requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRetain call}}
}
Modified: cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast-2.m?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast-2.m (original)
+++ cfe/branches/tooling/test/ARCMT/nonobjc-to-objc-cast-2.m Thu Feb 2 04:59:12 2012
@@ -9,13 +9,16 @@
@end
typedef const struct __CFString * CFStringRef;
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
void f(BOOL b) {
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}} \
// expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use __bridge_transfer to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}}
- void *vp = str; // expected-error {{requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use __bridge}}
+ // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}}
+ void *vp = str; // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRetain call}} expected-note {{use __bridge}}
}
void f2(NSString *s) {
@@ -23,7 +26,7 @@
ref = [(CFStringRef)[s string] retain]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef' (aka 'const struct __CFString *') requires a bridged cast}} \
// expected-error {{bad receiver type 'CFStringRef' (aka 'const struct __CFString *')}} \
// expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use __bridge_retained to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')}}
+ // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')}}
}
CFStringRef f3() {
Modified: cfe/branches/tooling/test/Analysis/CFContainers.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/CFContainers.mm?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/CFContainers.mm (original)
+++ cfe/branches/tooling/test/Analysis/CFContainers.mm Thu Feb 2 04:59:12 2012
@@ -164,3 +164,22 @@
const void *s1 = CFArrayGetValueAtIndex(A, sIndex);
const void *s2 = CFArrayGetValueAtIndex(A, sCount);// expected-warning {{Index is out of bounds}}
}
+
+typedef void* XX[3];
+void TestPointerToArray(int *elems, void *p1, void *p2, void *p3, unsigned count, void* fn[], char cp[]) {
+ void* x[] = { p1, p2, p3 };
+ CFArrayCreate(0, (const void **) &x, count, 0); // no warning
+
+ void* y[] = { p1, p2, p3 };
+ CFArrayCreate(0, (const void **) y, count, 0); // no warning
+ XX *z = &x;
+ CFArrayCreate(0, (const void **) z, count, 0); // no warning
+
+ CFArrayCreate(0, (const void **) &fn, count, 0); // false negative
+ CFArrayCreate(0, (const void **) fn, count, 0); // no warning
+ CFArrayCreate(0, (const void **) cp, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+
+ char cc[] = { 0, 2, 3 };
+ CFArrayCreate(0, (const void **) &cc, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+ CFArrayCreate(0, (const void **) cc, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+}
Modified: cfe/branches/tooling/test/Analysis/bstring.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/bstring.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/bstring.c (original)
+++ cfe/branches/tooling/test/Analysis/bstring.c Thu Feb 2 04:59:12 2012
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.unix.CString -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,experimental.unix.CString -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,experimental.unix.CString -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,experimental.unix.CString -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.unix.cstring.Generic -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,experimental.unix.cstring.Generic -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,experimental.unix.cstring.Generic -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,experimental.unix.cstring.Generic -analyzer-store=region -Wno-null-dereference -verify %s
//===----------------------------------------------------------------------===
// Declarations
Modified: cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m (original)
+++ cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m Thu Feb 2 04:59:12 2012
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin8 %s
// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin9 %s
-// RUN: %clang_cc1 -triple thumbv6-apple-darwin4.0.0-iphoneos -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin9 %s
+// RUN: %clang_cc1 -triple thumbv6-apple-ios4.0 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin9 %s
@interface MyClass {}
- (void *)voidPtrM;
Modified: cfe/branches/tooling/test/Analysis/security-syntax-checks.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/security-syntax-checks.m?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/security-syntax-checks.m (original)
+++ cfe/branches/tooling/test/Analysis/security-syntax-checks.m Thu Feb 2 04:59:12 2012
@@ -138,7 +138,7 @@
char x[4];
char *y;
- strcpy(x, y); //expected-warning{{Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strncpy'. CWE-119.}}
+ strcpy(x, y); //expected-warning{{Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119.}}
}
//===----------------------------------------------------------------------===
@@ -162,7 +162,7 @@
char x[4];
char *y;
- strcat(x, y); //expected-warning{{Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strncat'. CWE-119.}}
+ strcat(x, y); //expected-warning{{Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119.}}
}
//===----------------------------------------------------------------------===
Modified: cfe/branches/tooling/test/Analysis/string.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/string.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/string.c (original)
+++ cfe/branches/tooling/test/Analysis/string.c Thu Feb 2 04:59:12 2012
@@ -1,7 +1,7 @@
-// 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 -DVARIANT -analyzer-checker=core,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,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.unix.cstring.Generic,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,experimental.unix.cstring.Generic,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,experimental.unix.cstring.Generic,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=experimental.security.taint,core,experimental.unix.cstring.Generic,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
//===----------------------------------------------------------------------===
// Declarations
Modified: cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp (original)
+++ cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp Thu Feb 2 04:59:12 2012
@@ -40,6 +40,7 @@
// - its return type shall be a literal type;
constexpr NonLiteral NonLiteralReturn(); // expected-error {{constexpr function's return type 'NonLiteral' is not a literal type}}
+ constexpr void VoidReturn(); // expected-error {{constexpr function's return type 'void' is not a literal type}}
constexpr ~T(); // expected-error {{destructor cannot be marked constexpr}}
typedef NonLiteral F();
constexpr F NonLiteralReturn2; // expected-error {{constexpr function's return type 'NonLiteral' is not a literal type}}
Modified: cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp (original)
+++ cfe/branches/tooling/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp Thu Feb 2 04:59:12 2012
@@ -72,4 +72,10 @@
// expression with an unknown value, and diagnose if neither is constant.
constexpr S InitList4(int a) { return a ? (S){ a, ng } : (S){ a, ng }; };
+// __builtin_constant_p ? : is magical, and is always a potential constant.
+constexpr bool BcpCall(int n) {
+ return __builtin_constant_p((int*)n != &n) ? (int*)n != &n : (int*)n != &n;
+}
+static_assert(BcpCall(0), "");
+
}
Modified: cfe/branches/tooling/test/CXX/expr/expr.const/p2-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/expr/expr.const/p2-0x.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/expr/expr.const/p2-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/expr/expr.const/p2-0x.cpp Thu Feb 2 04:59:12 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -pedantic -verify -fcxx-exceptions %s -fconstexpr-depth 128
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -pedantic -verify -fcxx-exceptions %s -fconstexpr-depth 128 -triple i686-pc-linux-gnu
// A conditional-expression is a core constant expression unless it involves one
// of the following as a potentially evaluated subexpression [...]:
@@ -109,7 +109,6 @@
};
}
-// FIXME:
// - an operation that would have undefined behavior [Note: including, for
// example, signed integer overflow (Clause 5 [expr]), certain pointer
// arithmetic (5.7 [expr.add]), division by zero (5.6 [expr.mul]), or certain
@@ -134,6 +133,7 @@
constexpr int div0 = 3 / 0; // expected-error {{constant expression}} expected-note {{division by zero}} expected-warning {{undefined}}
constexpr int mod0 = 3 % 0; // expected-error {{constant expression}} expected-note {{division by zero}} expected-warning {{undefined}}
constexpr int int_min_div_minus_1 = int_min / -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}}
+ constexpr int int_min_mod_minus_1 = int_min % -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}}
constexpr int shl_m1 = 0 << -1; // expected-error {{constant expression}} expected-note {{negative shift count -1}} expected-warning {{negative}}
constexpr int shl_0 = 0 << 0; // ok
@@ -185,6 +185,73 @@
static_assert((B*)na == 0, "");
constexpr const int &nf = nb->n; // expected-error {{constant expression}} expected-note {{cannot access field of null pointer}}
constexpr const int &np = (*(int(*)[4])nullptr)[2]; // expected-error {{constant expression}} expected-note {{cannot access array element of null pointer}}
+
+ struct C {
+ constexpr int f() { return 0; }
+ } constexpr c = C();
+ constexpr int k1 = c.f(); // ok
+ constexpr int k2 = ((C*)nullptr)->f(); // expected-error {{constant expression}} expected-note {{cannot call member function on null pointer}}
+ constexpr int k3 = (&c)[1].f(); // expected-error {{constant expression}} expected-note {{cannot call member function on pointer past the end of object}}
+ C c2;
+ constexpr int k4 = c2.f(); // ok!
+
+ constexpr int diff1 = &a[2] - &a[0];
+ constexpr int diff2 = &a[1][3] - &a[1][0];
+ constexpr int diff3 = &a[2][0] - &a[1][0]; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}}
+ static_assert(&a[2][0] == &a[1][3], "");
+ constexpr int diff4 = (&b + 1) - &b;
+ constexpr int diff5 = &a[1][2].n - &a[1][0].n; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}}
+ constexpr int diff6 = &a[1][2].n - &a[1][2].n;
+ constexpr int diff7 = (A*)&a[0][1] - (A*)&a[0][0]; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}}
+ }
+
+ namespace Overflow {
+ // Signed int overflow.
+ constexpr int n1 = 2 * 3 * 3 * 7 * 11 * 31 * 151 * 331; // ok
+ constexpr int n2 = 65536 * 32768; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }}
+ constexpr int n3 = n1 + 1; // ok
+ constexpr int n4 = n3 + 1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }}
+ constexpr int n5 = -65536 * 32768; // ok
+ constexpr int n6 = 3 * -715827883; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }}
+ constexpr int n7 = -n3 + -1; // ok
+ constexpr int n8 = -1 + n7; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }}
+ constexpr int n9 = n3 - 0; // ok
+ constexpr int n10 = n3 - -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }}
+ constexpr int n11 = -1 - n3; // ok
+ constexpr int n12 = -2 - n3; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }}
+ constexpr int n13 = n5 + n5; // expected-error {{constant expression}} expected-note {{value -4294967296 is outside the range of }}
+ constexpr int n14 = n3 - n5; // expected-error {{constant expression}} expected-note {{value 4294967295 is outside the range of }}
+ constexpr int n15 = n5 * n5; // expected-error {{constant expression}} expected-note {{value 4611686018427387904 is outside the range of }}
+ constexpr signed char c1 = 100 * 2; // ok
+ constexpr signed char c2 = '\x64' * '\2'; // also ok
+ constexpr long long ll1 = 0x7fffffffffffffff; // ok
+ constexpr long long ll2 = ll1 + 1; // expected-error {{constant}} expected-note {{ 9223372036854775808 }}
+ constexpr long long ll3 = -ll1 - 1; // ok
+ constexpr long long ll4 = ll3 - 1; // expected-error {{constant}} expected-note {{ -9223372036854775809 }}
+ constexpr long long ll5 = ll3 * ll3; // expected-error {{constant}} expected-note {{ 85070591730234615865843651857942052864 }}
+
+ // Yikes.
+ char melchizedek[2200000000];
+ typedef decltype(melchizedek[1] - melchizedek[0]) ptrdiff_t;
+ constexpr ptrdiff_t d1 = &melchizedek[0x7fffffff] - &melchizedek[0]; // ok
+ constexpr ptrdiff_t d2 = &melchizedek[0x80000000u] - &melchizedek[0]; // expected-error {{constant expression}} expected-note {{ 2147483648 }}
+ constexpr ptrdiff_t d3 = &melchizedek[0] - &melchizedek[0x80000000u]; // ok
+ constexpr ptrdiff_t d4 = &melchizedek[0] - &melchizedek[0x80000001u]; // expected-error {{constant expression}} expected-note {{ -2147483649 }}
+
+ // Unsigned int overflow.
+ static_assert(65536u * 65536u == 0u, ""); // ok
+ static_assert(4294967295u + 1u == 0u, ""); // ok
+ static_assert(0u - 1u == 4294967295u, ""); // ok
+ static_assert(~0u * ~0u == 1u, ""); // ok
+
+ // Floating-point overflow and NaN.
+ constexpr float f1 = 1e38f * 3.4028f; // ok
+ constexpr float f2 = 1e38f * 3.4029f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}}
+ constexpr float f3 = 1e38f / -.2939f; // ok
+ constexpr float f4 = 1e38f / -.2938f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}}
+ constexpr float f5 = 2e38f + 2e38f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}}
+ constexpr float f6 = -2e38f - 2e38f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}}
+ constexpr float f7 = 0.f / 0.f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces a NaN}}
}
}
@@ -234,8 +301,6 @@
static_assert(((volatile const S&&)(S)0).i, ""); // expected-error {{constant expression}} expected-note {{subexpression}}
}
-// FIXME:
-//
// DR1312: The proposed wording for this defect has issues, so we ignore this
// bullet and instead prohibit casts from pointers to cv void (see core-20842
// and core-20845).
@@ -244,9 +309,23 @@
// glvalue of type cv1 T that refers to an object of type cv2 U, where T and U
// are neither the same type nor similar types (4.4 [conv.qual]);
-// FIXME:
// - an lvalue-to-rvalue conversion (4.1) that is applied to a glvalue that
// refers to a non-active member of a union or a subobject thereof;
+namespace LValueToRValueUnion {
+ // test/SemaCXX/constant-expression-cxx11.cpp contains more thorough testing
+ // of this.
+ union U { int a, b; } constexpr u = U();
+ static_assert(u.a == 0, "");
+ constexpr const int *bp = &u.b;
+ constexpr int b = *bp; // expected-error {{constant expression}} expected-note {{read of member 'b' of union with active member 'a'}}
+
+ extern const U pu;
+ constexpr const int *pua = &pu.a;
+ constexpr const int *pub = &pu.b;
+ constexpr U pu = { .b = 1 }; // expected-warning {{C99 feature}}
+ constexpr const int a2 = *pua; // expected-error {{constant expression}} expected-note {{read of member 'a' of union with active member 'b'}}
+ constexpr const int b2 = *pub; // ok
+}
// - an id-expression that refers to a variable or data member of reference type
// unless the reference has a preceding initialization, initialized with a
@@ -372,9 +451,43 @@
constexpr bool u13 = pf < pg; // expected-error {{constant expression}}
constexpr bool u14 = pf == pg;
- // FIXME:
// If two pointers point to non-static data members of the same object with
// different access control, the result is unspecified.
+ struct A {
+ public:
+ constexpr A() : a(0), b(0) {}
+ int a;
+ constexpr bool cmp() { return &a < &b; } // expected-error {{constexpr function never produces a constant expression}} expected-note {{comparison of address of fields 'a' and 'b' of 'A' with differing access specifiers (public vs private) has unspecified value}}
+ private:
+ int b;
+ };
+ class B {
+ public:
+ A a;
+ constexpr bool cmp() { return &a.a < &b.a; } // expected-error {{constexpr function never produces a constant expression}} expected-note {{comparison of address of fields 'a' and 'b' of 'B' with differing access specifiers (public vs protected) has unspecified value}}
+ protected:
+ A b;
+ };
+
+ // If two pointers point to different base sub-objects of the same object, or
+ // one points to a base subobject and the other points to a member, the result
+ // of the comparison is unspecified. This is not explicitly called out by
+ // [expr.rel]p2, but is covered by 'Other pointer comparisons are
+ // unspecified'.
+ struct C {
+ int c[2];
+ };
+ struct D {
+ int d;
+ };
+ struct E : C, D {
+ struct Inner {
+ int f;
+ } e;
+ } e;
+ constexpr bool base1 = &e.c[0] < &e.d; // expected-error {{constant expression}} expected-note {{comparison of addresses of subobjects of different base classes has unspecified value}}
+ constexpr bool base2 = &e.c[1] < &e.e.f; // expected-error {{constant expression}} expected-note {{comparison of address of base class subobject 'C' of class 'E' to field 'e' has unspecified value}}
+ constexpr bool base3 = &e.e.f < &e.d; // expected-error {{constant expression}} expected-note {{comparison of address of base class subobject 'D' of class 'E' to field 'e' has unspecified value}}
// [expr.rel]p3: Pointers to void can be compared [...] if both pointers
// represent the same address or are both the null pointer [...]; otherwise
@@ -391,10 +504,6 @@
constexpr bool v6 = qv > null; // expected-error {{constant expression}}
constexpr bool v7 = qv <= (void*)&s.b; // ok
constexpr bool v8 = qv > (void*)&s.a; // expected-error {{constant expression}} expected-note {{unequal pointers to void}}
-
- // FIXME: Implement comparisons of pointers to members.
- // [expr.eq]p2: If either is a pointer to a virtual member function and
- // neither is null, the result is unspecified.
}
// - an assignment or a compound assignment (5.17); or
Modified: cfe/branches/tooling/test/CodeGenCXX/arm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/arm.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/arm.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/arm.cpp Thu Feb 2 04:59:12 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=thumbv7-apple-darwin3.0.0-iphoneos -fno-use-cxa-atexit -target-abi apcs-gnu -emit-llvm -o - -fexceptions | FileCheck %s
+// RUN: %clang_cc1 %s -triple=thumbv7-apple-ios3.0 -fno-use-cxa-atexit -target-abi apcs-gnu -emit-llvm -o - -fexceptions | FileCheck %s
// CHECK: @_ZZN5test74testEvE1x = internal global i32 0, align 4
// CHECK: @_ZGVZN5test74testEvE1x = internal global i32 0
Modified: cfe/branches/tooling/test/CodeGenCXX/for-range-temporaries.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/for-range-temporaries.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/for-range-temporaries.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/for-range-temporaries.cpp Thu Feb 2 04:59:12 2012
@@ -1,6 +1,9 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -UDESUGAR %s | opt -instnamer -S | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -DDESUGAR %s | opt -instnamer -S | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -UDESUGAR -DTEMPLATE %s | opt -instnamer -S | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -DDESUGAR -DTEMPLATE %s | opt -instnamer -S | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -UDESUGAR -DTEMPLATE -DDEPENDENT %s | opt -instnamer -S | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -DDESUGAR -DTEMPLATE -DDEPENDENT %s | opt -instnamer -S | FileCheck %s
struct A {
A();
@@ -67,7 +70,11 @@
void body(const I &);
#ifdef TEMPLATE
+#ifdef DEPENDENT
template<typename D>
+#else
+template<typename>
+#endif
#endif
void for_temps() {
A a;
Modified: cfe/branches/tooling/test/CodeGenCXX/pragma-visibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/pragma-visibility.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/pragma-visibility.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/pragma-visibility.cpp Thu Feb 2 04:59:12 2012
@@ -60,11 +60,3 @@
// CHECK: define hidden void @_ZN1n1gEv
#pragma GCC visibility pop
}
-
-// We used to test this, but it's insane, so unless it happens in
-// headers, we should not support it.
-namespace n __attribute((visibility("hidden"))) {
- #pragma GCC visibility pop
- void h() {}
- // CHECK disabled: define void @_ZN1n1hEv
-}
Modified: cfe/branches/tooling/test/Driver/darwin-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/darwin-ld.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/darwin-ld.c (original)
+++ cfe/branches/tooling/test/Driver/darwin-ld.c Thu Feb 2 04:59:12 2012
@@ -109,3 +109,11 @@
// RUN: FileCheck -check-prefix=LINK_LAZY_LIBRARY %s < %t.log
// LINK_LAZY_LIBRARY: {{ld(.exe)?"}}
// LINK_LAZY_LIBRARY: "-lazy_library" "Library"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o 2> %t.log
+// RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log
+// RUN: FileCheck -check-prefix=LINK_VERSION_MIN %s < %t.log
+// LINK_VERSION_MIN: {{ld(.exe)?"}}
+// LINK_VERSION_MIN: "-macosx_version_min" "10.6.0"
+// LINK_VERSION_MIN: {{ld(.exe)?"}}
+// LINK_VERSION_MIN: "-macosx_version_min" "10.7.0"
Modified: cfe/branches/tooling/test/Driver/parsing.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/parsing.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/parsing.c (original)
+++ cfe/branches/tooling/test/Driver/parsing.c Thu Feb 2 04:59:12 2012
@@ -20,6 +20,3 @@
// RUN: %clang -ccc-print-options -Wally 2> %t
// RUN: grep 'Option 0 - Name: "-ccc-print-options", Values: {}' %t
// RUN: grep 'Option 1 - Name: "-W", Values: {"ally"}' %t
-
-
-
Modified: cfe/branches/tooling/test/Driver/rewrite-objc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/rewrite-objc.m?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/rewrite-objc.m (original)
+++ cfe/branches/tooling/test/Driver/rewrite-objc.m Thu Feb 2 04:59:12 2012
@@ -3,7 +3,7 @@
// TEST0: clang{{.*}}" "-cc1"
// TEST0: "-rewrite-objc"
// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-fragile-abi" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-fragile-abi" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
// TEST0: rewrite-objc.m"
// RUN: not %clang -ccc-no-clang -target unknown -rewrite-objc %s -o - -### 2>&1 | \
Modified: cfe/branches/tooling/test/Driver/target.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/target.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/target.c (original)
+++ cfe/branches/tooling/test/Driver/target.c Thu Feb 2 04:59:12 2012
@@ -5,7 +5,7 @@
// CHECK: Target: unknown-unknown-unknown
//
// Also, ensure we don't blindly hand our target selection logic down to GCC.
-// CHECK: "{{.*}}gcc"
+// CHECK: "{{.*gcc(\.[Ee][Xx][Ee])?}}"
// CHECK-NOT: "-target"
// CHECK-NOT: "unknown-unknown-unknown"
// CHECK: "-x" "assembler"
Modified: cfe/branches/tooling/test/Frontend/rewrite-macros.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Frontend/rewrite-macros.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Frontend/rewrite-macros.c (original)
+++ cfe/branches/tooling/test/Frontend/rewrite-macros.c Thu Feb 2 04:59:12 2012
@@ -9,7 +9,7 @@
_Pragma("mark")
// RUN: grep "//#warning eek" %t
-/* expected-warning {{#warning eek}} */ #warning eek
+/* expected-warning {{eek}} */ #warning eek
// RUN: grep "//#pragma mark mark" %t
#pragma mark mark
Modified: cfe/branches/tooling/test/Index/retain-target-options.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/retain-target-options.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/retain-target-options.c (original)
+++ cfe/branches/tooling/test/Index/retain-target-options.c Thu Feb 2 04:59:12 2012
@@ -2,7 +2,7 @@
// RUN: c-index-test -test-load-source-reparse 1 all -target x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s
// RUN: c-index-test -test-load-source-reparse 5 all -target x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s
-// CHECK: error: #error SSE4_1 used
+// CHECK: error: SSE4_1 used
#if defined(__SSE4_1__)
#error SSE4_1 used
#endif
Modified: cfe/branches/tooling/test/Misc/serialized-diags-no-category.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/serialized-diags-no-category.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Misc/serialized-diags-no-category.c (original)
+++ cfe/branches/tooling/test/Misc/serialized-diags-no-category.c Thu Feb 2 04:59:12 2012
@@ -7,6 +7,6 @@
// This test case tests that we can handle both fatal errors and errors without categories.
-// CHECK: {{.*[/\\]}}serialized-diags-no-category.c:1:2: error: #error foo []
+// CHECK: {{.*[/\\]}}serialized-diags-no-category.c:1:2: error: foo []
// CHECK: Number of diagnostics: 2
Modified: cfe/branches/tooling/test/Misc/warn-in-system-header.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/warn-in-system-header.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Misc/warn-in-system-header.c (original)
+++ cfe/branches/tooling/test/Misc/warn-in-system-header.c Thu Feb 2 04:59:12 2012
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -isystem %S %s -fsyntax-only -verify
#include <warn-in-system-header.h>
-// expected-warning {{#warning}}
+// expected-warning {{the cake is a lie}}
Modified: cfe/branches/tooling/test/Modules/compiler_builtins.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Modules/compiler_builtins.m?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Modules/compiler_builtins.m (original)
+++ cfe/branches/tooling/test/Modules/compiler_builtins.m Thu Feb 2 04:59:12 2012
@@ -1,20 +1,26 @@
// RUN: rm -rf %t
-// RUN: %clang -fsyntax-only -fmodules -fmodule-cache-path %t %s -Xclang -verify
+// RUN: %clang -fsyntax-only -fmodules -fmodule-cache-path %t -D__need_wint_t %s -Xclang -verify
- at import __compiler_builtins.float_constants;
+ at import _Builtin_stdlib.float_constants;
float getFltMax() { return FLT_MAX; }
- at import __compiler_builtins.limits;
+ at import _Builtin_stdlib.limits;
char getCharMax() { return CHAR_MAX; }
+// MS limits.h provides size_t.
+// XFAIL: win32
size_t size; // expected-error{{unknown type name 'size_t'}}
+ at import _Builtin_stdlib.stdint;
+
+intmax_t value;
+
#ifdef __SSE__
- at import __compiler_builtins.intel.sse;
+ at import _Builtin_intrinsics.intel.sse;
#endif
#ifdef __AVX2__
- at import __compiler_builtins.intel.avx2;
+ at import _Builtin_intrinsics.intel.avx2;
#endif
Modified: cfe/branches/tooling/test/Preprocessor/line-directive.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Preprocessor/line-directive.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Preprocessor/line-directive.c (original)
+++ cfe/branches/tooling/test/Preprocessor/line-directive.c Thu Feb 2 04:59:12 2012
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
-// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:92:2: error: #error ABC'
-// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:93:2: error: #error DEF'
+// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:92:2: error: ABC'
+// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:93:2: error: DEF'
#line 'a' // expected-error {{#line directive requires a positive integer argument}}
#line 0 // expected-error {{#line directive requires a positive integer argument}}
Modified: cfe/branches/tooling/test/Sema/MicrosoftExtensions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/MicrosoftExtensions.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/MicrosoftExtensions.c (original)
+++ cfe/branches/tooling/test/Sema/MicrosoftExtensions.c Thu Feb 2 04:59:12 2012
@@ -86,4 +86,13 @@
short sh = (short)ptr;
ch = (char)ptr;
sh = (short)ptr;
-}
+}
+
+
+typedef struct {
+ UNKNOWN u; // expected-error {{unknown type name 'UNKNOWN'}}
+} AA;
+
+typedef struct {
+ AA; // expected-warning {{anonymous structs are a Microsoft extension}}
+} BB;
Modified: cfe/branches/tooling/test/Sema/attr-availability-ios.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/attr-availability-ios.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/attr-availability-ios.c (original)
+++ cfe/branches/tooling/test/Sema/attr-availability-ios.c Thu Feb 2 04:59:12 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 "-triple" "x86_64-apple-darwin3.0.0-iphoneos" -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios3.0" -fsyntax-only -verify %s
void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1)));
void f1(int) __attribute__((availability(ios,introduced=2.1)));
Modified: cfe/branches/tooling/test/Sema/constant-conversion.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/constant-conversion.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/constant-conversion.c (original)
+++ cfe/branches/tooling/test/Sema/constant-conversion.c Thu Feb 2 04:59:12 2012
@@ -74,3 +74,9 @@
f.twoBits1 &= ~1; // no-warning
f.twoBits2 &= ~2; // no-warning
}
+
+void test8() {
+ enum E { A, B, C };
+ struct { enum E x : 1; } f;
+ f.x = C; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 2 to 0}}
+}
Modified: cfe/branches/tooling/test/Sema/conversion-64-32.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/conversion-64-32.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/conversion-64-32.c (original)
+++ cfe/branches/tooling/test/Sema/conversion-64-32.c Thu Feb 2 04:59:12 2012
@@ -13,23 +13,3 @@
int4 v127 = a; // no warning.
return v127;
}
-
-// <rdar://problem/10759934>
-// Don't warn about -Wshorten-64-to-32 in unreachable code.
-typedef unsigned int uint32_t;
-typedef unsigned long long uint64_t;
-int rdar10759934() {
- uint32_t thing = 0;
- uint64_t thing2 = 0;
-
- switch (sizeof(thing2)) {
- case 8:
- break;
- case 4:
- thing = thing2; // no-warning
- default:
- break;
- }
-
- return 0;
-}
Modified: cfe/branches/tooling/test/Sema/format-strings-scanf.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/format-strings-scanf.c?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/format-strings-scanf.c (original)
+++ cfe/branches/tooling/test/Sema/format-strings-scanf.c Thu Feb 2 04:59:12 2012
@@ -53,6 +53,10 @@
const char kFormat2[] = "%["; // expected-note{{format string is defined here}}}
scanf(kFormat2, str); // expected-warning{{no closing ']' for '%[' in scanf format string}}
scanf("%[", str); // expected-warning{{no closing ']' for '%[' in scanf format string}}
+ const char kFormat3[] = "%hu"; // expected-note{{format string is defined here}}}
+ scanf(kFormat3, &i); // expected-warning {{format specifies type 'unsigned short *' but the argument}}
+ const char kFormat4[] = "%lp"; // expected-note{{format string is defined here}}}
+ scanf(kFormat4, &i); // expected-warning {{length modifier 'l' results in undefined behavior or no effect with 'p' conversion specifier}}
}
void test_variants(int *i, const char *s, ...) {
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=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/format-strings.c (original)
+++ cfe/branches/tooling/test/Sema/format-strings.c Thu Feb 2 04:59:12 2012
@@ -468,6 +468,9 @@
// Make sure that the "format string is defined here" note is not emitted
// when the original string is within the argument expression.
printf(1 ? "yes %d" : "no %d"); // expected-warning 2{{more '%' conversions than data arguments}}
+
+ const char kFormat17[] = "%hu"; // expected-note{{format string is defined here}}}
+ printf(kFormat17, (int[]){0}); // expected-warning{{format specifies type 'unsigned short' but the argument}}
}
// PR 9466: clang: doesn't know about %Lu, %Ld, and %Lx
Modified: cfe/branches/tooling/test/SemaCXX/constant-expression-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/constant-expression-cxx11.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/constant-expression-cxx11.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/constant-expression-cxx11.cpp Thu Feb 2 04:59:12 2012
@@ -37,6 +37,7 @@
D d;
constexpr B *p = &d;
constexpr C *q = &d;
+
static_assert((void*)p != (void*)q, "");
static_assert((A*)p == (A*)q, "");
static_assert((Aa*)p != (Aa*)q, "");
@@ -65,7 +66,6 @@
struct Z : Y1, Y2 {};
Z z;
static_assert((X*)(Y1*)&z != (X*)(Y2*)&z, "");
-
}
namespace ConstCast {
@@ -666,7 +666,7 @@
constexpr Bottom *pb1 = (Base*)&derived;
constexpr Bottom *pb2 = (Base2*)&derived;
-static_assert(pb1 != pb2, "");
+static_assert(&pb1 != &pb2, "");
static_assert(pb1 == &bot1, "");
static_assert(pb2 == &bot2, "");
@@ -827,6 +827,18 @@
static_assert((s.*&S::f)() == 2, "");
static_assert((s.*s.pf)() == 2, "");
+ static_assert(pf == &S::f, "");
+ static_assert(pf == s.*&S::pf, "");
+ static_assert(pm == &S::m, "");
+ static_assert(pm != pn, "");
+ static_assert(s.pn != pn, "");
+ static_assert(s.pn == pm, "");
+ static_assert(pg != nullptr, "");
+ static_assert(pf != nullptr, "");
+ static_assert((int S::*)nullptr == nullptr, "");
+ static_assert(pg == pg, ""); // expected-error {{constant expression}} expected-note {{comparison of pointer to virtual member function 'g' has unspecified value}}
+ static_assert(pf != pg, ""); // expected-error {{constant expression}} expected-note {{comparison of pointer to virtual member function 'g' has unspecified value}}
+
template<int n> struct T : T<n-1> {};
template<> struct T<0> { int n; };
template<> struct T<30> : T<29> { int m; };
@@ -836,10 +848,13 @@
constexpr int (T<10>::*deepn) = &T<0>::n;
static_assert(&(t17.*deepn) == &t17.n, "");
+ static_assert(deepn == &T<2>::n, "");
constexpr int (T<15>::*deepm) = (int(T<10>::*))&T<30>::m;
constexpr int *pbad = &(t17.*deepm); // expected-error {{constant expression}}
static_assert(&(t30.*deepm) == &t30.m, "");
+ static_assert(deepm == &T<50>::m, "");
+ static_assert(deepm != deepn, "");
constexpr T<5> *p17_5 = &t17;
constexpr T<13> *p17_13 = (T<13>*)p17_5;
@@ -857,6 +872,14 @@
static_assert(&(p30_5->*(int(T<2>::*))deepm) == &t30.m, "");
static_assert(&(((T<17>*)p30_13)->*deepm) == &t30.m, "");
static_assert(&(p30_23->*deepm) == &t30.m, "");
+
+ struct Base { int n; };
+ template<int N> struct Mid : Base {};
+ struct Derived : Mid<0>, Mid<1> {};
+ static_assert(&Mid<0>::n == &Mid<1>::n, "");
+ static_assert((int Derived::*)(int Mid<0>::*)&Mid<0>::n !=
+ (int Derived::*)(int Mid<1>::*)&Mid<1>::n, "");
+ static_assert(&Mid<0>::n == (int Mid<0>::*)&Base::n, "");
}
namespace ArrayBaseDerived {
@@ -1090,3 +1113,17 @@
static_assert(s2.e == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
static_assert(s2.f == 7, "");
}
+
+namespace Fold {
+
+ // This macro forces its argument to be constant-folded, even if it's not
+ // otherwise a constant expression.
+ #define fold(x) (__builtin_constant_p(x) ? (x) : (x))
+
+ constexpr int n = (int)(char*)123; // expected-error {{constant expression}} expected-note {{reinterpret_cast}}
+ constexpr int m = fold((int)(char*)123); // ok
+ static_assert(m == 123, "");
+
+ #undef fold
+
+}
Modified: cfe/branches/tooling/test/SemaCXX/for-range-examples.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/for-range-examples.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/for-range-examples.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/for-range-examples.cpp Thu Feb 2 04:59:12 2012
@@ -158,3 +158,14 @@
for (int x : a.xs) { } // expected-error {{'xs' is a private member of 'test2::A'}}
}
}
+
+namespace test3 {
+ // Make sure this doesn't crash
+ struct A {};
+ struct B { ~B(); operator bool(); };
+ struct C { B operator!=(const C&); C& operator++(); int operator*(); };
+ C begin(const A&);
+ C end(const A&);
+ template<typename T> void f() { for (auto a : A()) {} }
+ void g() { f<int>(); }
+}
Modified: cfe/branches/tooling/test/SemaCXX/format-strings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/format-strings.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/format-strings.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/format-strings.cpp Thu Feb 2 04:59:12 2012
@@ -13,3 +13,7 @@
printf("%a", 1.0);
scanf("%afoobar", fp);
}
+
+void g() {
+ printf("%ls", "foo"); // expected-warning{{format specifies type 'wchar_t *' but the argument has type 'const char *'}}
+}
Modified: cfe/branches/tooling/test/SemaCXX/lambda-expressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/lambda-expressions.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/lambda-expressions.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/lambda-expressions.cpp Thu Feb 2 04:59:12 2012
@@ -3,14 +3,6 @@
namespace std { class type_info; };
namespace ExplicitCapture {
- int GlobalVar; // expected-note {{declared here}}
-
- namespace N {
- int AmbiguousVar; // expected-note {{candidate}}
- }
- int AmbiguousVar; // expected-note {{candidate}}
- using namespace N;
-
class C {
int Member;
@@ -18,28 +10,12 @@
void Overload();
virtual C& Overload(float);
- void ExplicitCapture() {
- int foo;
-
- [foo, foo] () {}; // expected-error {{'foo' can appear only once}} expected-error {{not supported yet}}
- [this, this] () {}; // expected-error {{'this' can appear only once}} expected-error {{not supported yet}}
- [=, foo] () {}; // expected-error {{'&' must precede a capture when}} expected-error {{not supported yet}}
- [=, &foo] () {}; // expected-error {{not supported yet}}
- [=, this] () {}; // expected-error {{'this' cannot appear}} expected-error {{not supported yet}}
- [&, foo] () {}; // expected-error {{not supported yet}}
- [&, &foo] () {}; // expected-error {{'&' cannot precede a capture when}} expected-error {{not supported yet}}
- [&, this] () {}; // expected-error {{not supported yet}}
- [&Overload] () {}; // expected-error {{does not name a variable}} expected-error {{not supported yet}}
- [&GlobalVar] () {}; // expected-error {{does not have automatic storage duration}} expected-error {{not supported yet}}
- [&AmbiguousVar] () {} // expected-error {{reference to 'AmbiguousVar' is ambiguous}} expected-error {{not supported yet}}
- [&Globalvar] () {}; // expected-error {{use of undeclared identifier 'Globalvar'; did you mean 'GlobalVar}}
- }
-
void ImplicitThisCapture() {
[](){(void)Member;}; // expected-error {{'this' cannot be implicitly captured in this context}} expected-error {{not supported yet}}
[&](){(void)Member;}; // expected-error {{not supported yet}}
- [this](){(void)Member;}; // expected-error {{not supported yet}}
- [this]{[this]{};};// expected-error 2 {{not supported yet}}
+ // 'this' captures below don't actually work yet
+ [this](){(void)Member;}; // expected-error{{lambda expressions are not supported yet}}
+ [this]{[this]{};}; // expected-error 2{{lambda expressions are not supported yet}}
[]{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}} expected-error 2 {{not supported yet}}
[]{Overload(3);}; // expected-error {{not supported yet}}
[]{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}} expected-error {{not supported yet}}
@@ -49,7 +25,7 @@
};
void f() {
- [this] () {}; // expected-error {{invalid use of 'this'}} expected-error {{not supported yet}}
+ [this] () {}; // expected-error {{'this' cannot be captured in this context}} expected-error {{not supported yet}}
}
}
Modified: cfe/branches/tooling/test/SemaCXX/warn-memset-bad-sizeof.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/warn-memset-bad-sizeof.cpp?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/warn-memset-bad-sizeof.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/warn-memset-bad-sizeof.cpp Thu Feb 2 04:59:12 2012
@@ -132,8 +132,6 @@
strncpy(buff, BAR, sizeof(BAR)); // \
// expected-warning {{argument to 'sizeof' in 'strncpy' call is the same expression as the source}}
- strncat(buff, BAR, sizeof(BAR)); // \
- // expected-warning {{argument to 'sizeof' in 'strncat' call is the same expression as the source}}
strndup(FOO, sizeof(FOO)); // \
// expected-warning {{argument to 'sizeof' in 'strndup' call is the same expression as the source}}
}
Propchange: cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 2 04:59:12 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-149380
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-149602
Modified: cfe/branches/tooling/test/SemaObjC/arc-bridged-cast.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-bridged-cast.m?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-bridged-cast.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-bridged-cast.m Thu Feb 2 04:59:12 2012
@@ -1,6 +1,8 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s
typedef const void *CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
typedef const struct __CFString *CFStringRef;
@interface NSString
@@ -35,8 +37,8 @@
void fixits() {
id obj1 = (id)CFCreateSomething(); // expected-error{{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \
// expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use __bridge_transfer to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
+ // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
CFTypeRef cf1 = (CFTypeRef)CreateSomething(); // expected-error{{cast of Objective-C pointer type 'id' to C pointer type 'CFTypeRef' (aka 'const void *') requires a bridged cast}} \
// expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use __bridge_retained to make an ARC object available as a +1 'CFTypeRef' (aka 'const void *')}}
+ // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFTypeRef' (aka 'const void *')}}
}
Modified: cfe/branches/tooling/test/SemaObjC/arc-cf.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-cf.m?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-cf.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-cf.m Thu Feb 2 04:59:12 2012
@@ -5,14 +5,16 @@
#endif
typedef const void *CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
typedef const struct __CFString *CFStringRef;
extern CFStringRef CFMakeString0(void);
extern CFStringRef CFCreateString0(void);
void test0() {
id x;
- x = (id) CFMakeString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
- x = (id) CFCreateString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
+ x = (id) CFMakeString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
+ x = (id) CFCreateString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
}
extern CFStringRef CFMakeString1(void) __attribute__((cf_returns_not_retained));
@@ -20,7 +22,7 @@
void test1() {
id x;
x = (id) CFMakeString1();
- x = (id) CFCreateString1(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
+ x = (id) CFCreateString1(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
}
#define CF_AUDIT_BEGIN _Pragma("clang arc_cf_code_audited begin")
@@ -38,6 +40,6 @@
id x;
x = (id) CFMakeString2();
x = (id) CFCreateString2();
- x = (id) CFMakeString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
- x = (id) CFCreateString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
+ x = (id) CFMakeString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
+ x = (id) CFCreateString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
}
Modified: cfe/branches/tooling/test/SemaObjC/arc-type-conversion.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-type-conversion.m?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-type-conversion.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-type-conversion.m Thu Feb 2 04:59:12 2012
@@ -1,5 +1,9 @@
// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks %s
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
+
void * cvt(id arg)
{
void* voidp_val;
@@ -14,13 +18,13 @@
cvt((void*)arg); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} \
// expected-error {{implicit conversion of C pointer type 'void *' to Objective-C pointer type 'id' requires a bridged cast}} \
// expected-note 2 {{use __bridge to convert directly (no change in ownership)}} \
- // expected-note {{use __bridge_retained to make an ARC object available as a +1 'void *'}} \
- // expected-note {{use __bridge_transfer to transfer ownership of a +1 'void *' into ARC}}
+ // expected-note {{use CFBridgingRetain call to make an ARC object available as a +1 'void *'}} \
+ // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'void *' into ARC}}
cvt(0);
(void)(__strong id**)(0);
return arg; // expected-error {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} \
// expected-note {{use __bridge to convert directly (no change in ownership)}} \
- // expected-note {{use __bridge_retained to make an ARC object available as a +1 'void *'}}
+ // expected-note {{use CFBridgingRetain call to make an ARC object available as a +1 'void *'}}
}
void to_void(__strong id *sip, __weak id *wip,
Modified: cfe/branches/tooling/test/SemaObjC/arc-unbridged-cast.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc-unbridged-cast.m?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc-unbridged-cast.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc-unbridged-cast.m Thu Feb 2 04:59:12 2012
@@ -1,6 +1,10 @@
// // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
typedef const struct __CFString * CFStringRef;
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
+
@interface Object
@property CFStringRef property;
@@ -35,15 +39,15 @@
x = (id) (cond ? (void*) 0 : auditedString());
x = (id) (cond ? (CFStringRef) @"help" : auditedString());
- x = (id) unauditedString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? unauditedString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
-
- x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
+ x = (id) unauditedString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? unauditedString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+
+ x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
x = (id) [object property];
x = (id) (cond ? [object property] : (void*) 0);
@@ -80,7 +84,7 @@
void testCFTaker(CFTaker *taker, id string) {
[taker takeOrdinary: (CFStringRef) string];
[taker takeVariadic: 1, (CFStringRef) string];
- [taker takeConsumed: (CFStringRef) string]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
+ [taker takeConsumed: (CFStringRef) string]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
}
void takeCFOrdinaryUnaudited(CFStringRef arg);
@@ -93,27 +97,27 @@
#pragma clang arc_cf_code_audited end
void testTakerFunctions(id string) {
- takeCFOrdinaryUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
- takeCFVariadicUnaudited(1, (CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
- takeCFConsumedUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
+ takeCFOrdinaryUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFVariadicUnaudited(1, (CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFConsumedUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
void (*taker)(CFStringRef) = 0;
- taker((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
+ taker((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
takeCFOrdinaryAudited((CFStringRef) string);
takeCFVariadicAudited(1, (CFStringRef) string);
- takeCFConsumedAudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
+ takeCFConsumedAudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
}
void testTakerFunctions_parens(id string) {
- takeCFOrdinaryUnaudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
- takeCFVariadicUnaudited(1, ((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
- takeCFConsumedUnaudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
+ takeCFOrdinaryUnaudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFVariadicUnaudited(1, ((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFConsumedUnaudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
void (*taker)(CFStringRef) = 0;
- taker(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
+ taker(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
takeCFOrdinaryAudited(((CFStringRef) string));
takeCFVariadicAudited(1, ((CFStringRef) string));
- takeCFConsumedAudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
+ takeCFConsumedAudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
}
Modified: cfe/branches/tooling/test/SemaObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/arc.m?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/arc.m (original)
+++ cfe/branches/tooling/test/SemaObjC/arc.m Thu Feb 2 04:59:12 2012
@@ -1,6 +1,9 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify %s
typedef unsigned long NSUInteger;
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
void test0(void (*fn)(int), int val) {
fn(val);
@@ -263,8 +266,8 @@
b = (vp == nil);
b = (nil == vp);
- b = (vp == op); // expected-error {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use __bridge_retained}}
- b = (op == vp); // expected-error {{implicit conversion of C pointer type 'void *' to Objective-C pointer type 'id' requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use __bridge_transfer}}
+ b = (vp == op); // expected-error {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRetain call}}
+ b = (op == vp); // expected-error {{implicit conversion of C pointer type 'void *' to Objective-C pointer type 'id' requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRelease call}}
}
void test12(id collection) {
@@ -404,10 +407,10 @@
id x;
x = (id) test19a; // expected-error {{bridged cast}} \
// expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use __bridge_transfer to transfer ownership of a +1 'struct Test19 *' into ARC}}
+ // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'struct Test19 *' into ARC}}
x = (id) test19b; // expected-error {{bridged cast}} \
// expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use __bridge_transfer to transfer ownership of a +1 'struct Test19 *' into ARC}}
+ // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'struct Test19 *' into ARC}}
}
// rdar://problem/8951453
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=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/continuation-class-err.m (original)
+++ cfe/branches/tooling/test/SemaObjC/continuation-class-err.m Thu Feb 2 04:59:12 2012
@@ -40,3 +40,12 @@
@synthesize fee = _fee;
@end
+// rdar://10752081
+ at interface MyOtherClass() // expected-error {{cannot find interface declaration for 'MyOtherClass'}}
+{
+ id array;
+}
+ at end
+
+ at implementation MyOtherClass // expected-warning {{cannot find interface declaration for 'MyOtherClass'}}
+ at end
Modified: cfe/branches/tooling/test/SemaObjC/default-synthesize.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/default-synthesize.m?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/default-synthesize.m (original)
+++ cfe/branches/tooling/test/SemaObjC/default-synthesize.m Thu Feb 2 04:59:12 2012
@@ -10,7 +10,9 @@
@end
@implementation SynthItAll
-//@synthesize howMany, what;
+#if !__has_feature(objc_default_synthesize_properties)
+ at synthesize howMany, what;
+#endif
@end
@@ -20,7 +22,9 @@
@end
@implementation SynthSetter
-//@synthesize howMany, what;
+#if !__has_feature(objc_default_synthesize_properties)
+ at synthesize howMany, what;
+#endif
- (int) howMany {
return self.howMany;
@@ -40,7 +44,9 @@
@end
@implementation SynthGetter
-//@synthesize howMany, what;
+#if !__has_feature(objc_default_synthesize_properties)
+ at synthesize howMany, what;
+#endif
// - (int) howMany
- (void) setHowMany: (int) value {
@@ -61,7 +67,9 @@
@end
@implementation SynthNone
-//@synthesize howMany, what; // REM: Redundant anyway
+#if !__has_feature(objc_default_synthesize_properties)
+ at synthesize howMany, what; // REM: Redundant anyway
+#endif
- (int) howMany {
return self.howMany;
@@ -112,7 +120,9 @@
@implementation D
- (int) Meth { return self.PROP; }
+#if __has_feature(objc_default_synthesize_properties)
@synthesize PROP=IVAR;
+#endif
@end
// rdar://10567333
Modified: cfe/branches/tooling/test/SemaObjCXX/arc-unbridged-cast.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjCXX/arc-unbridged-cast.mm?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjCXX/arc-unbridged-cast.mm (original)
+++ cfe/branches/tooling/test/SemaObjCXX/arc-unbridged-cast.mm Thu Feb 2 04:59:12 2012
@@ -1,6 +1,10 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
typedef const struct __CFString * CFStringRef;
+typedef const void * CFTypeRef;
+extern "C" CFTypeRef CFBridgingRetain(id X);
+extern "C" id CFBridgingRelease(CFTypeRef);
+
@interface Object
@property CFStringRef property;
@@ -35,15 +39,15 @@
x = (id) (cond ? (void*) 0 : auditedString());
x = (id) (cond ? (CFStringRef) @"help" : auditedString());
- x = (id) unauditedString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? unauditedString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
-
- x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
+ x = (id) unauditedString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? unauditedString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+
+ x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
x = (id) [object property];
x = (id) (cond ? [object property] : (void*) 0);
@@ -80,7 +84,7 @@
void testCFTaker(CFTaker *taker, id string) {
[taker takeOrdinary: (CFStringRef) string];
[taker takeVariadic: 1, (CFStringRef) string];
- [taker takeConsumed: (CFStringRef) string]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
+ [taker takeConsumed: (CFStringRef) string]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
}
void takeCFOrdinaryUnaudited(CFStringRef arg);
@@ -93,14 +97,14 @@
#pragma clang arc_cf_code_audited end
void testTakerFunctions(id string) {
- takeCFOrdinaryUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
- takeCFVariadicUnaudited(1, (CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
- takeCFConsumedUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
+ takeCFOrdinaryUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFVariadicUnaudited(1, (CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFConsumedUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
void (*taker)(CFStringRef) = 0;
- taker((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
+ taker((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
takeCFOrdinaryAudited((CFStringRef) string);
takeCFVariadicAudited(1, (CFStringRef) string);
- takeCFConsumedAudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use __bridge_retained to}}
+ takeCFConsumedAudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
}
Modified: cfe/branches/tooling/utils/analyzer/SATestBuild.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/analyzer/SATestBuild.py?rev=149603&r1=149602&r2=149603&view=diff
==============================================================================
--- cfe/branches/tooling/utils/analyzer/SATestBuild.py (original)
+++ cfe/branches/tooling/utils/analyzer/SATestBuild.py Thu Feb 2 04:59:12 2012
@@ -72,7 +72,7 @@
# The list of checkers used during analyzes.
# Currently, consists of all the non experimental checkers.
-Checkers="experimental.security.taint,core,deadcode,cplusplus,security,unix,osx,cocoa"
+Checkers="experimental.security.taint,core,deadcode,cplusplus,security,unix,osx,cocoa,experimental.osx.cocoa.Containers,experimental.unix.cstring.BadSizeArg"
Verbose = 1
More information about the llvm-branch-commits
mailing list